:root {
  color-scheme: light dark;
  --background: #f8fafc;
  --surface: #ffffff;
  --foreground: #1e293b;
  --muted-foreground: #64748b;
  --muted: #eaeff3;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --ring: #475569;
  --sidebar-width: 296px;
  --content-width: 780px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--foreground); font-size: 16px; line-height: 1.6; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
svg { width: 20px; height: 20px; flex: none; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; border-radius: 8px; background: var(--foreground); color: var(--surface); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 92%, transparent); backdrop-filter: blur(16px); }
.brand { color: var(--foreground); font-weight: 750; letter-spacing: -0.02em; text-decoration: none; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--foreground); cursor: pointer; }
.icon-button:hover { background: var(--muted); }
.menu-button { display: none; }
.search-button { margin-left: auto; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted-foreground); cursor: pointer; transition: border-color 180ms ease, color 180ms ease, box-shadow 180ms ease; }
.search-button:hover { border-color: var(--accent); color: var(--foreground); box-shadow: 0 6px 24px rgb(15 23 42 / 8%); }
kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--muted); font-size: 12px; }
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto; padding: 28px 18px 60px; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar-heading { padding: 0 10px 10px; color: var(--muted-foreground); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.book-nav, .doc-nav { margin: 0; padding: 0; list-style: none; }
.book-nav > li > a { display: flex; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px; border-radius: 8px; color: var(--foreground); font-size: 14px; font-weight: 600; text-decoration: none; }
.book-nav > li > a:hover, .book-nav > li > a[aria-current="page"] { background: var(--muted); }
.book-nav small { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.doc-nav { margin: 4px 0 14px 14px; padding-left: 14px; border-left: 1px solid var(--border); }
.doc-nav a { display: block; padding: 6px 4px; color: var(--muted-foreground); font-size: 13px; line-height: 1.35; text-decoration: none; }
.doc-nav a:hover { color: var(--accent); }
.content { width: 100%; min-width: 0; padding: 64px clamp(24px, 6vw, 96px) 100px; }
.hero, .page-header, .document { max-width: var(--content-width); margin: 0 auto; }
.hero { padding: clamp(24px, 6vw, 80px) 0 72px; }
.eyebrow { margin-bottom: 14px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .13em; }
.hero h1, .page-header h1, .document-header h1 { margin: 0; letter-spacing: -.045em; line-height: 1.05; }
.hero h1 { max-width: 720px; font-size: clamp(48px, 8vw, 96px); }
.hero > p { max-width: 650px; margin: 28px 0; color: var(--muted-foreground); font-size: clamp(18px, 2vw, 22px); }
.primary-search { margin: 0; padding: 0 18px; border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 700; }
.primary-search:hover { background: var(--accent-strong); color: #fff; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; max-width: 1120px; margin: 0 auto; }
.book-card { min-height: 230px; padding: 26px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.book-count { color: var(--muted-foreground); font-size: 13px; }
.book-card h2 { margin: 18px 0 10px; font-size: 23px; line-height: 1.2; }
.book-card h2 a { color: var(--foreground); text-decoration: none; }
.book-card p { min-height: 54px; color: var(--muted-foreground); font-size: 14px; }
.card-link { display: inline-block; margin-top: 16px; font-weight: 650; text-decoration: none; }
.page-header { margin-bottom: 48px; }
.page-header h1 { font-size: clamp(42px, 7vw, 72px); }
.page-header p { color: var(--muted-foreground); }
.document-list { max-width: var(--content-width); margin: 0 auto; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.document-list li { border-bottom: 1px solid var(--border); }
.document-list a { display: flex; justify-content: space-between; gap: 24px; padding: 18px 4px; color: var(--foreground); text-decoration: none; }
.document-list a:hover { color: var(--accent); }
.document-list time { color: var(--muted-foreground); font-size: 13px; white-space: nowrap; }
.breadcrumb { font-size: 14px; font-weight: 650; text-decoration: none; }
.document-header { padding-bottom: 32px; border-bottom: 1px solid var(--border); }
.document-header h1 { margin-top: 16px; font-size: clamp(38px, 6vw, 64px); }
.document-meta { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 22px; color: var(--muted-foreground); font-size: 13px; }
.document-meta a { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.document-meta svg { width: 14px; height: 14px; }
.prose { padding-top: 36px; font-family: ui-serif, Georgia, "Noto Serif SC", serif; font-size: 17px; line-height: 1.85; overflow-wrap: anywhere; }
.prose h2, .prose h3, .prose h4 { margin: 2em 0 .7em; font-family: Inter, ui-sans-serif, sans-serif; line-height: 1.25; letter-spacing: -.025em; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose pre { overflow: auto; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: #0f172a; color: #e2e8f0; font-size: 14px; line-height: 1.55; }
.prose :not(pre) > code { padding: 2px 5px; border-radius: 5px; background: var(--muted); font-size: .88em; }
.prose blockquote { margin-left: 0; padding: 3px 0 3px 18px; border-left: 3px solid var(--accent); color: var(--muted-foreground); }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.prose th, .prose td { padding: 9px 12px; border: 1px solid var(--border); }
.search-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(700px, calc(100vh - 48px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--foreground); box-shadow: 0 24px 80px rgb(15 23 42 / 25%); }
.search-dialog::backdrop { background: rgb(15 23 42 / 55%); backdrop-filter: blur(3px); }
.search-header { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-header input { width: 100%; min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--foreground); font-size: 18px; }
.search-results { max-height: 560px; overflow: auto; padding: 8px; }
.search-result { display: block; padding: 14px; border-radius: 10px; color: var(--foreground); text-decoration: none; }
.search-result:hover, .search-result:focus { background: var(--muted); }
.search-result strong, .search-result small { display: block; }
.search-result small { margin: 3px 0 7px; color: var(--accent); }
.search-result p { margin: 0; color: var(--muted-foreground); font-size: 13px; }
.empty-state { padding: 48px 24px; color: var(--muted-foreground); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .menu-button { display: inline-grid; }
  .shell { display: block; }
  .sidebar { position: fixed; top: 64px; bottom: 0; left: 0; z-index: 25; width: min(var(--sidebar-width), 88vw); height: auto; transform: translateX(-105%); transition: transform 200ms ease; }
  .sidebar.is-open { transform: translateX(0); }
  .backdrop { position: fixed; inset: 64px 0 0; z-index: 20; background: rgb(15 23 42 / 45%); }
  .backdrop:not([hidden]) { display: block; }
  .content { padding: 44px 22px 80px; }
  .search-button kbd { display: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 12px; }
  .topbar .search-button span { display: none; }
  .hero { padding-top: 16px; }
  .hero h1 { font-size: 47px; }
  .book-grid { grid-template-columns: 1fr; }
  .document-list a { display: block; }
  .document-list time { display: block; margin-top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root { --background: #0f172a; --surface: #111c30; --foreground: #e2e8f0; --muted-foreground: #94a3b8; --muted: #1e293b; --border: #2b3a50; --accent: #60a5fa; --accent-strong: #93c5fd; --ring: #94a3b8; }
  .book-card { box-shadow: none; }
}

