:root {
  --bg: #f5f7fb;
  --paper: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ef;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --code-bg: #0f172a;
  --code-ink: #e5edf8;
  --shadow: 0 18px 50px rgba(15, 23, 42, .10);
  --reader-font-size: 18px;
}
:root[data-theme="dark"] {
  --bg: #07111f;
  --paper: #0f172a;
  --ink: #e5edf8;
  --muted: #94a3b8;
  --line: #23324a;
  --accent: #60a5fa;
  --accent-2: #c4b5fd;
  --code-bg: #020617;
  --code-ink: #dbeafe;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.reader-shell { min-height: 100vh; display: grid; grid-template-columns: 310px minmax(0, 1fr) 260px; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; padding: 24px 18px; background: linear-gradient(180deg, #0f172a 0%, #111827 100%); color: #e5edf8; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: #ffffff; color: #172033; box-shadow: 0 10px 24px rgba(0, 0, 0, .22); font-weight: 900; letter-spacing: -.06em; }
.brand-title { font-weight: 800; line-height: 1.1; }
.brand-subtitle { color: #9fb0c9; font-size: 12px; margin-top: 4px; }
.sidebar-section-title { margin: 20px 0 10px; color: #93c5fd; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.chapter-list { display: grid; gap: 8px; }
.chapter-link { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px; border-radius: 14px; color: #dbeafe; border: 1px solid rgba(148, 163, 184, .18); background: rgba(255,255,255,.04); }
.chapter-link:hover { background: rgba(96, 165, 250, .14); text-decoration: none; }
.chapter-link.active { background: linear-gradient(135deg, rgba(37,99,235,.36), rgba(124,58,237,.28)); border-color: rgba(147, 197, 253, .55); }
.chapter-id { width: 34px; height: 34px; border-radius: 12px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.chapter-title { font-size: 14px; font-weight: 700; line-height: 1.25; }
.chapter-goal { font-size: 12px; color: #aab7cf; line-height: 1.35; margin-top: 4px; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(16px); }
.progress-wrap { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.progress-bar { width: 0%; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .12s ease; }
.search { flex: 1; max-width: 520px; position: relative; }
.search input { width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; background: var(--bg); color: var(--ink); outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.toolbar-button, .pdf-button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 10px 13px; cursor: pointer; font-weight: 700; }
.pdf-button { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border: 0; }
.toolbar-button:hover, .pdf-button:hover { transform: translateY(-1px); text-decoration: none; }
.reader { max-width: 930px; margin: 34px auto 80px; padding: 0 26px; }
.book-card { background: var(--paper); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.cover { padding: 34px 38px; background: radial-gradient(circle at top left, rgba(37,99,235,.22), transparent 35%), linear-gradient(135deg, color-mix(in srgb, var(--paper) 80%, #dbeafe), var(--paper)); border-bottom: 1px solid var(--line); }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 74%, #dbeafe); color: var(--accent); border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 800; }
.cover h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: .96; letter-spacing: -.04em; }
.cover p { color: var(--muted); font-size: 17px; line-height: 1.55; max-width: 760px; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 13px; }
.content { padding: 28px 42px 54px; font-size: var(--reader-font-size); line-height: 1.75; }
.content h1, .content h2, .content h3 { line-height: 1.18; letter-spacing: -.025em; }
.content h1 { font-size: 42px; }
.content h2 { margin-top: 54px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 30px; }
.content h3 { margin-top: 32px; font-size: 22px; }
.content p { margin: 14px 0; }
.content img { display: block; max-width: 100%; margin: 24px auto 8px; border-radius: 18px; border: 1px solid var(--line); background: white; box-shadow: 0 12px 35px rgba(15, 23, 42, .08); }
.figure-caption { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.content table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: .9em; overflow: hidden; border-radius: 16px; }
.content th, .content td { border: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.content th { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); text-align: left; }
.content blockquote { margin: 22px 0; padding: 16px 18px; border-left: 5px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--paper)); border-radius: 14px; }
.content div[style*="border-left"] { margin: 22px 0 !important; box-shadow: 0 10px 28px rgba(15,23,42,.06); }
pre { position: relative; background: var(--code-bg); color: var(--code-ink); border-radius: 18px; padding: 18px; overflow: auto; font-size: 14px; line-height: 1.55; }
code { font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace; }
.copy-code { position: absolute; right: 12px; top: 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: white; border-radius: 10px; padding: 6px 9px; cursor: pointer; font-size: 12px; }
.right-rail { position: sticky; top: 0; height: 100vh; overflow: auto; padding: 86px 18px 24px; border-left: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 68%, transparent); }
.rail-title { font-size: 12px; font-weight: 900; letter-spacing: .13em; color: var(--muted); text-transform: uppercase; margin-bottom: 12px; }
.outline { display: grid; gap: 7px; }
.outline a { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; padding: 7px 9px; border-radius: 10px; }
.outline a:hover, .outline a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); text-decoration: none; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 18px; margin-top: 28px; }
.home-card { display: block; padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: 0 12px 35px rgba(15,23,42,.06); }
.home-card:hover { text-decoration: none; transform: translateY(-2px); }
mark.search-hit { background: #fef08a; color: #713f12; border-radius: 4px; padding: 0 2px; }
@media (max-width: 1120px) { .reader-shell { grid-template-columns: 280px minmax(0, 1fr); } .right-rail { display: none; } }
@media (max-width: 820px) { .reader-shell { display: block; } .sidebar { position: relative; height: auto; max-height: 50vh; } .topbar { flex-wrap: wrap; } .content { padding: 22px; } }

.front-nav { display: grid; gap: 8px; margin-bottom: 14px; }
.front-link { display: block; padding: 9px 11px; border-radius: 13px; color: #dbeafe; border: 1px solid rgba(148, 163, 184, .18); background: rgba(255,255,255,.035); font-size: 13px; font-weight: 700; }
.front-link:hover { background: rgba(96, 165, 250, .14); text-decoration: none; }
.cover-showcase { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 28px; align-items: center; }
.cover-art { width: 100%; border-radius: 26px; box-shadow: 0 28px 70px rgba(15, 23, 42, .28); border: 1px solid var(--line); background: #061329; }
.title-page { text-align: center; padding: 46px 24px; }
.title-page h1 { font-size: clamp(42px, 7vw, 76px); margin: 10px 0; }
.title-page .subtitle { font-size: 22px; color: var(--muted); max-width: 720px; margin: 18px auto; }
.imprint-box { border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }
.author-card { display: grid; grid-template-columns: 190px 1fr; gap: 24px; align-items: start; }
.author-photo { width: 190px; max-height: 300px; object-fit: cover; object-position: center top; border-radius: 24px; box-shadow: 0 18px 45px rgba(15,23,42,.18); border: 1px solid var(--line); }
.cover-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.cover-compare img { width: 100%; border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 16px 42px rgba(15,23,42,.14); }
.toc-list { display: grid; gap: 12px; }
.toc-item { display: grid; grid-template-columns: 74px 1fr; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--paper) 86%, #dbeafe); }
.toc-item:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 12px 28px rgba(15,23,42,.08); }
.toc-number { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; font-weight: 900; }
.toc-title { display: block; color: var(--ink); font-weight: 850; font-size: 18px; margin-bottom: 4px; }
.toc-goal { display: block; color: var(--muted); font-size: 14px; line-height: 1.45; }
.toc-lab { display: block; color: var(--accent); font-size: 13px; margin-top: 7px; font-weight: 700; }
@media (max-width: 820px) { .cover-showcase, .author-card { grid-template-columns: 1fr; } .author-photo { width: 100%; max-width: 260px; } }

@media print { .sidebar, .topbar, .right-rail { display: none; } .reader-shell { display: block; } .reader { max-width: none; margin: 0; padding: 0; } .book-card { box-shadow: none; border: 0; } }
