/* ===== Shadow Libraries — Modern Theme ===== */
:root {
  --bg: #0b0c15;
  --surface: #13151f;
  --surface-2: #1a1c2a;
  --border: #252839;
  --text: #e6e8ff;
  --muted: #9aa0b8;
  --accent: #7c5cff;
  --accent-2: #00e0ff;
  --accent-3: #ff3c78;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
  --max-width: 1200px;
  --overlay: rgba(0,0,0,.5);
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --border: #e3e5f0;
  --text: #1b1d2e;
  --muted: #5c6178;
  --accent: #6d4cff;
  --accent-2: #00b8d4;
  --accent-3: #f43f6e;
  --shadow: 0 10px 30px rgba(20,20,40,.08);
  --overlay: rgba(255,255,255,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(124,92,255,.18), transparent),
    radial-gradient(900px 600px at 110% 10%, rgba(0,224,255,.12), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: none; }

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  min-height: 100vh;
}

.book-menu {
  width: 280px;
  flex-shrink: 0;
  background: rgba(19,21,31,.6);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  transition: transform .3s ease, background .3s ease;
}
[data-theme="light"] .book-menu { background: rgba(255,255,255,.7); }

.book-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.5rem;
}
.book-brand img { height: 32px; width: 32px; }
.book-brand span { font-size: 1.1rem; font-weight: 700; color: #fff; }
[data-theme="light"] .book-brand span { color: #1b1d2e; }

.subtitle {
  color: var(--muted) !important;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 1rem;
}

.book-menu ul { list-style: none; padding: 0; margin: 0; }
.book-menu li { margin: 2px 0; }
.book-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cdd1e6;
  font-size: 0.92rem;
  transition: background .15s ease, color .15s ease;
}
[data-theme="light"] .book-menu a { color: #3a3d55; }
.book-menu a:hover, .book-menu a.active {
  background: rgba(124,92,255,.12);
  color: #fff;
}
[data-theme="light"] .book-menu a:hover, [data-theme="light"] .book-menu a.active { color: #1b1d2e; }

.book-menu hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; opacity: 1; }
.bottom-nav { margin-top: auto; }

.section-label a { pointer-events: none; }

.book-menu ul ul { padding-left: 1rem; }
.book-menu ul ul a { font-size: 0.88rem; }

/* Toggle */
.toggle { display: none; }
.book-menu ul ul { display: none; }
.book-menu input.toggle:checked + label + ul { display: block; }
.book-menu label > img:last-child {
  transition: transform .2s ease;
}
.book-menu input.toggle:checked + label > img:last-child { transform: rotate(90deg); }

/* ===== Main Content ===== */
.book-page {
  flex: 1;
  padding: 2.5rem 2rem;
  max-width: 900px;
  min-width: 0;
}
.book-article { color: #d6d9f0; }
.book-article h1, .book-article h2, .book-article h3 {
  color: #fff;
  letter-spacing: -.2px;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
}
[data-theme="light"] .book-article h1,
[data-theme="light"] .book-article h2,
[data-theme="light"] .book-article h3 { color: #1b1d2e; }
.book-article h1 { font-size: 2.2rem; }
.book-article h2 { font-size: 1.6rem; }
.book-article h3 { font-size: 1.25rem; }
.book-article p { color: #c8cce0; margin-bottom: 1em; }
[data-theme="light"] .book-article p { color: #3a3d55; }
.book-article ul, .book-article ol { padding-left: 1.5em; margin-bottom: 1em; }
.book-article li { margin: 6px 0; }
.book-article a { color: var(--accent); }
.book-article a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }
.book-article blockquote {
  border-left: 3px solid var(--accent);
  background: rgba(124,92,255,.08);
  color: #d6d9f0;
  padding: 14px 18px;
  border-radius: 0 14px 14px 0;
  margin: 1em 0;
}
[data-theme="light"] .book-article blockquote { background: rgba(109,76,255,.06); color: #2a2d42; }
.book-article code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 8px;
  font-size: .9em;
}
.book-article pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
  margin-bottom: 1em;
}
.book-article details {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 10px 0;
}
.book-article summary { color: var(--text); cursor: pointer; }
.book-article hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ===== Hero / Cards / Buttons ===== */
.hero {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 44px 28px;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(124,92,255,.18), transparent),
    radial-gradient(600px 400px at 100% 100%, rgba(0,224,255,.10), transparent),
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
[data-theme="light"] .hero {
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(109,76,255,.10), transparent),
    radial-gradient(600px 400px at 100% 100%, rgba(0,184,212,.08), transparent),
    linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,.01));
}
.hero h1 {
  font-size: 2.4rem;
  margin: 0 0 10px;
  background: linear-gradient(90deg, #fff, #a78bfa, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="light"] .hero h1 {
  background: linear-gradient(90deg, #1b1d2e, #5b3df0, #0891b2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: #cbd0e8; font-size: 1.05rem; max-width: 640px; }
[data-theme="light"] .hero p { color: #2a2d42; }
.hero .actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(124,92,255,.18);
  border: 1px solid rgba(124,92,255,.45);
  color: #fff;
  font-weight: 600;
  transition: transform .12s ease, background .2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); background: rgba(124,92,255,.28); text-decoration: none; }
.btn.secondary { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #e6e8ff; }
.btn.secondary:hover { background: rgba(255,255,255,.10); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124,92,255,.15);
  color: #d4c7ff;
  font-size: .8rem;
  border: 1px solid rgba(124,92,255,.35);
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
}
[data-theme="light"] .card { background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,.01)); }
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(124,92,255,.45);
  box-shadow: 0 14px 36px rgba(124,92,255,.12);
  text-decoration: none;
  color: inherit;
}
.card h3 { margin: 6px 0 8px; font-size: 1.05rem; color: #fff; }
[data-theme="light"] .card h3 { color: #1b1d2e; }
.card p { color: #b8bcd8; font-size: .92rem; margin: 0; }
[data-theme="light"] .card p { color: #5c6178; }
.card .arrow { opacity: .6; font-weight: 700; color: #fff; margin-left: auto; }
[data-theme="light"] .card .arrow { color: #1b1d2e; }

/* ===== 404 ===== */
.not-found {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.not-found h1 {
  font-size: clamp(48px, 14vw, 160px);
  font-weight: 900;
  letter-spacing: -.04em;
  background: linear-gradient(90deg, #a78bfa, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="light"] .not-found h1 {
  background: linear-gradient(90deg, #5b3df0, #0891b2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.not-found h3 { margin-top: 8px; color: var(--text); }

/* ===== Mobile Controls ===== */
.menu-toggle, .theme-toggle, .menu-close {
  display: none;
  position: fixed;
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(19,21,31,.8);
  border: 1px solid var(--border);
  color: #fff;
  backdrop-filter: blur(12px);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
[data-theme="light"] .menu-toggle,
[data-theme="light"] .theme-toggle,
[data-theme="light"] .menu-close { background: rgba(255,255,255,.75); color: #1b1d2e; }

.menu-toggle { top: 12px; right: 12px; }
.theme-toggle { top: 12px; right: 68px; }
.menu-close { top: 12px; right: 12px; }

.menu-toggle svg, .menu-close svg { width: 22px; height: 22px; }

.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 50;
}

/* ===== Footer ===== */
.book-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 2rem;
}
.book-footer a { color: #c7caff; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2d42; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c8cbd8; }
::-webkit-scrollbar-thumb:hover { background: #3a3d55; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .book-menu {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 320px);
    z-index: 65;
    transform: translateX(-105%);
    background: rgba(19,21,31,.92);
    border-right: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
  }
  [data-theme="light"] .book-menu { background: rgba(255,255,255,.92); }
  .book-menu.open { transform: translateX(0); }

  .menu-toggle, .theme-toggle { display: inline-flex; }
  .book-menu.open ~ .menu-overlay { display: block; }
  .book-menu.open ~ .menu-close { display: inline-flex; }

  .book-page { padding: 22px 18px 70px; }
  .hero { padding: 28px 18px; }
  .hero h1 { font-size: 1.8rem; }
  .grid { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
  .menu-toggle, .theme-toggle, .menu-close, .menu-overlay { display: none !important; }
}
