:root {
  --bg: #0e0b1a;
  --bg-hero: radial-gradient(ellipse at top, #2a1a4d 0%, #0e0b1a 70%);
  --purple: #5b2fa6;
  --gold: #c9a24b;
  --text: #d6d0e2;
  --text-dim: #b3a8c9;
  --panel: #171227;
  --border: #3a3055;
  --link: #b79cf0;
  --title: #cbb8f5;
  --menu-text: #e0d4ff;
}
:root.light {
  --bg: #f7f3ea;
  --bg-hero: radial-gradient(ellipse at top, #e8ddc8 0%, #f7f3ea 70%);
  --purple: #7a4fd6;
  --gold: #9c6f14;
  --text: #2a2333;
  --text-dim: #5c5470;
  --panel: #ffffff;
  --border: #ddd3c0;
  --link: #6a3fc0;
  --title: #4a2f8a;
  --menu-text: #f3ecff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.75;
  transition: background .15s ease, color .15s ease;
}
.hero {
  background: var(--bg-hero);
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  border-bottom: 3px solid var(--gold);
  position: relative;
}
.hero h1 { font-size: 2rem; color: var(--title); margin: 0 0 .5rem; }
.hero .subtitle { color: var(--text-dim); font-style: italic; max-width: 640px; margin: 0 auto; }

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  display: flex;
  align-items: center;
  gap: .45rem;
  font-family: -apple-system, sans-serif;
  font-size: .85rem;
  color: var(--text-dim);
}
.theme-toggle .switch { width: 40px; height: 22px; }
.theme-toggle .switch-track::before { height: 16px; width: 16px; }
.theme-toggle .switch input:checked + .switch-track::before { transform: translateX(18px); }

.hero-search { max-width: 420px; margin: 1.2rem auto 0; position: relative; font-family: -apple-system, sans-serif; }
.hero-search input {
  width: 100%;
  font-family: inherit;
  font-size: .9rem;
  padding: .55rem .9rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.hero-search input:focus { outline: none; border-color: var(--gold); }
.hero-search-results {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + .4rem);
  left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.hero-search-results.open { display: block; }
.hero-search-results a {
  display: block;
  padding: .55rem .9rem;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.hero-search-results a:last-child { border-bottom: none; }
.hero-search-results a:hover, .hero-search-results a.active { background: var(--purple); color: var(--menu-text); }
.hero-search-empty { padding: .6rem .9rem; font-size: .82rem; color: var(--text-dim); }

.menu {
  background: var(--purple);
  text-align: center;
  padding: .7rem 1rem;
  font-family: -apple-system, sans-serif;
  font-size: .85rem;
  letter-spacing: 1px;
}
.menu span, .menu a { color: var(--menu-text); margin: 0 .6rem; text-decoration: none; }
.menu .active { color: var(--gold); font-weight: bold; }
.menu-note { color: var(--menu-text); font-size: .7rem; margin-top: .3rem; opacity: .75; }

.layout {
  max-width: 1180px;
  margin: 2rem auto 4rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
}

.section-nav {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  font-family: -apple-system, sans-serif;
  position: sticky;
  top: 1.5rem;
}
.section-nav h3 {
  color: var(--gold);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 .8rem;
}
.section-nav ul { list-style: none; margin: 0; padding: 0; }
.section-nav li { margin-bottom: .6rem; }
.section-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: .85rem;
  line-height: 1.4;
  display: block;
}
.section-nav a:hover { color: var(--title); }
.section-nav li.active a { color: var(--gold); font-weight: bold; }
.section-nav .related-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: .9rem 0;
}
.section-nav .related-label {
  color: var(--gold);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 .6rem;
  opacity: .85;
}

article { min-width: 0; }
.article-title {
  color: var(--title);
  font-size: 1.7rem;
  border-bottom: 2px solid var(--gold);
  padding-bottom: .5rem;
  margin-top: 0;
}

.series-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: -.3rem 0 1.6rem;
  font-family: -apple-system, sans-serif;
  font-size: .82rem;
}
.series-nav a { color: var(--link); text-decoration: none; }
.series-nav a:hover { text-decoration: underline; }
.series-nav .series-prev { text-align: left; }
.series-nav .series-next { text-align: right; margin-left: auto; }
article h2 {
  color: var(--gold);
  font-size: 1.3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .4rem;
  margin-top: 2.2rem;
}
article p, article ul, article li { color: var(--text); }
article a { color: var(--link); }
article iframe { max-width: 100%; margin: 1rem 0; }

.yt-thumb {
  position: relative;
  display: block;
  max-width: 560px;
  margin: 1rem auto;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  aspect-ratio: 16 / 9;
}
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; }
.yt-thumb .yt-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  padding-left: 4px;
  transition: background .15s, transform .15s;
}
.yt-thumb:hover .yt-play { background: #cc0000; transform: translate(-50%, -50%) scale(1.08); }

figure { margin: 1.8rem auto; text-align: center; }
figure img { max-width: 100%; border-radius: 4px; border: 1px solid var(--border); }
figure.small img { max-width: 240px; }
figure.medium img { max-width: 440px; }
figure.large img { max-width: 100%; }
figcaption {
  font-size: .82rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: .5rem;
  font-family: -apple-system, sans-serif;
}

.missing-image {
  font-family: -apple-system, sans-serif;
  font-size: .82rem;
  color: var(--text-dim);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 1.2rem;
  margin: 1.5rem auto;
  max-width: 440px;
}

.license-footer {
  max-width: 980px;
  margin: 0 auto 3rem;
  padding: 1.2rem 1.5rem;
  border-top: 1px solid var(--border);
  font-family: -apple-system, sans-serif;
  font-size: .8rem;
  color: var(--text-dim);
  text-align: center;
}
.license-footer a { color: var(--link); }

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: .15s;
}
.switch-track::before {
  content: "";
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .15s;
}
.switch input:checked + .switch-track { background: var(--gold); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }
