:root {
  --bg: #f6f3ed;
  --paper: #fffdf8;
  --ink: #20242c;
  --muted: #68707e;
  --line: #ddd8ce;
  --navy: #17365d;
  --navy-2: #274d78;
  --blue-soft: #eef6ff;
  --amber: #b86b1b;
  --amber-soft: #fff5e6;
  --green: #24705a;
  --green-soft: #edf8f3;
  --sidebar: 292px;
  --header: 64px;
  --shadow: 0 16px 45px rgba(28, 35, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(39, 77, 120, 0.08), transparent 32rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.8;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.site-header {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto 0;
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  color: #fff;
  background: rgba(23, 54, 93, 0.97);
  box-shadow: 0 2px 14px rgba(17, 34, 58, 0.18);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 750;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--navy);
  background: #fff;
  border-radius: 9px;
  font-family: Georgia, serif;
  font-size: 19px;
}

.header-subtitle {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.menu-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  cursor: pointer;
}

.reading-progress {
  position: fixed;
  z-index: 60;
  inset: var(--header) auto auto 0;
  width: 0;
  height: 3px;
  background: #f6b85e;
}

.sidebar {
  position: fixed;
  z-index: 40;
  top: var(--header);
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  padding: 22px 18px 36px;
  overflow-y: auto;
  background: rgba(255, 253, 248, 0.96);
  border-right: 1px solid var(--line);
}

.sidebar-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.chapter-nav,
.section-nav {
  display: grid;
  gap: 4px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.chapter-nav a,
.section-nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: 0.18s ease;
}

.chapter-nav a {
  font-size: 14px;
  font-weight: 650;
}

.section-nav a {
  color: #586271;
  font-size: 13px;
  line-height: 1.45;
}

.chapter-nav a:hover,
.section-nav a:hover,
.section-nav a.active {
  color: var(--navy);
  background: #edf2f8;
}

.chapter-nav .current {
  color: #fff;
  background: var(--navy);
}

.chapter-nav .disabled {
  color: #a0a6af;
  cursor: default;
}

.sidebar-note {
  padding: 12px;
  color: #6e5a3d;
  background: var(--amber-soft);
  border: 1px solid #efd5ad;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.55;
}

.sidebar-overlay {
  display: none;
}

.reader-layout {
  min-height: 100vh;
  padding-top: var(--header);
  padding-left: var(--sidebar);
}

.reader {
  width: min(900px, calc(100% - 56px));
  margin: 0 auto;
  padding: 56px 0 100px;
}

.chapter-hero {
  margin-bottom: 30px;
  padding: 44px 48px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(23, 54, 93, 0.98), rgba(39, 77, 120, 0.92)),
    var(--navy);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.chapter-eyebrow {
  margin: 0 0 10px;
  color: #f8c47c;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-hero h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.22;
}

.chapter-en {
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.6;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.meta-pill {
  padding: 5px 10px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 12px;
}

.book-section {
  scroll-margin-top: calc(var(--header) + 28px);
  margin: 0 0 28px;
  padding: 38px 42px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.section-number {
  display: inline-block;
  margin-bottom: 9px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.book-section h2,
.book-section h3,
.book-section h4 {
  font-family: Georgia, "Songti SC", "STSong", serif;
}

.book-section h2 {
  margin: 0 0 6px;
  color: var(--navy);
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.3;
}

.book-section h3 {
  margin: 34px 0 10px;
  color: #283d57;
  font-size: 23px;
  line-height: 1.4;
  scroll-margin-top: calc(var(--header) + 30px);
}

.book-section h4 {
  margin: 26px 0 8px;
  color: #3b4653;
  font-size: 18px;
}

.section-en {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.source-page {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 7px;
  color: var(--navy-2);
  background: #edf2f8;
  border-radius: 999px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.translation {
  margin: 18px 0 0;
}

.translation p {
  margin: 0 0 1em;
  font-family: Georgia, "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: 16.5px;
  line-height: 1.95;
  text-align: justify;
}

.translation p:last-child,
.translation ul:last-child,
.translation ol:last-child {
  margin-bottom: 0;
}

.translation li {
  margin: 0.45em 0;
}

.book-figure {
  margin: 30px 0;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.book-figure img {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
}

.book-figure figcaption {
  margin-top: 12px;
  color: #636c78;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.book-table-wrap {
  margin: 24px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.book-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.book-table th,
.book-table td {
  min-width: 150px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.book-table th {
  color: #fff;
  background: var(--navy);
}

.book-table tr:last-child td {
  border-bottom: 0;
}

.quote {
  margin: 20px 0;
  padding: 18px 22px;
  color: #45505e;
  background: #f4f5f7;
  border-left: 4px solid #919aa5;
  font-family: Georgia, "Songti SC", serif;
}

.callout.note {
  background: var(--blue-soft);
  border-left-color: var(--navy-2);
}

.callout.tip {
  background: var(--green-soft);
  border-left-color: var(--green);
}

.callout.warning {
  background: var(--amber-soft);
  border-left-color: var(--amber);
}

.book-section pre {
  margin: 22px 0;
  padding: 18px 20px;
  overflow-x: auto;
  color: #e8eef6;
  background: #1d2733;
  border: 1px solid #344456;
  border-radius: 10px;
  font: 13.5px/1.65 "Cascadia Code", "SFMono-Regular", Consolas,
    "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.book-section :not(pre) > code {
  padding: 0.12em 0.38em;
  color: #713f12;
  background: #fff2d8;
  border-radius: 4px;
  font: 0.9em/1.4 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.equation {
  margin: 20px 0;
  padding: 14px 18px;
  overflow-x: auto;
  color: var(--navy);
  background: #f2f6fb;
  border: 1px solid #d6e1ed;
  border-radius: 9px;
  font-family: "Cambria Math", Georgia, serif;
  text-align: center;
}

.chapter-end {
  padding: 28px;
  color: #53606e;
  background: #eef1f5;
  border-radius: 14px;
  text-align: center;
}

.chapter-end strong {
  color: var(--navy);
}

.home {
  min-height: 100vh;
  padding: calc(var(--header) + 54px) 24px 90px;
}

.home-inner {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.home-hero {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 36px;
  align-items: center;
  margin-bottom: 42px;
  padding: 52px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), #315f8f);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.home-kicker {
  color: #f8c47c;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 10px 0 16px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.12;
}

.home-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.book-glyph {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  font-family: Georgia, serif;
  font-size: 78px;
  background: rgba(255, 255, 255, 0.08);
}

.home-note {
  margin-bottom: 30px;
  padding: 18px 20px;
  color: #604a2f;
  background: var(--amber-soft);
  border: 1px solid #efd5ad;
  border-radius: 12px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chapter-card {
  display: flex;
  gap: 18px;
  min-height: 140px;
  padding: 24px;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chapter-card.available:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.chapter-card.locked {
  opacity: 0.58;
}

.card-number {
  flex: 0 0 42px;
  color: var(--navy);
  font-family: Georgia, serif;
  font-size: 32px;
  line-height: 1;
}

.chapter-card h2 {
  margin: 0 0 7px;
  color: var(--navy);
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
  line-height: 1.4;
}

.chapter-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status {
  display: inline-block;
  margin-top: 12px;
  padding: 3px 8px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.status.pending {
  color: #757c86;
  background: #eff1f3;
}

@media (max-width: 880px) {
  .home-hero {
    grid-template-columns: 1fr;
  }

  .book-glyph {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --header: 58px;
  }

  .site-header {
    padding: 0 14px;
  }

  .header-subtitle {
    display: none;
  }

  .menu-button {
    display: inline-grid;
    place-items: center;
    margin-left: auto;
  }

  .sidebar {
    z-index: 80;
    top: 0;
    width: min(86vw, 320px);
    padding-top: 22px;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 14px 0 35px rgba(20, 28, 39, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: block;
    visibility: hidden;
    background: rgba(15, 23, 34, 0.45);
    opacity: 0;
    transition: 0.22s ease;
  }

  .sidebar-overlay.open {
    visibility: visible;
    opacity: 1;
  }

  .reader-layout {
    padding-left: 0;
  }

  .reader {
    width: min(100% - 24px, 900px);
    padding-top: 24px;
  }

  .chapter-hero,
  .book-section {
    padding: 28px 22px;
    border-radius: 13px;
  }

  .translation {
    margin-top: 14px;
  }

  .translation p {
    font-size: 16px;
    text-align: left;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }

  .home {
    padding: calc(var(--header) + 24px) 12px 60px;
  }

  .home-hero {
    padding: 32px 24px;
    border-radius: 16px;
  }
}

@media print {
  .site-header,
  .sidebar,
  .sidebar-overlay,
  .reading-progress {
    display: none !important;
  }

  .reader-layout {
    padding: 0;
  }

  .reader {
    width: 100%;
    padding: 0;
  }

  .book-section {
    break-inside: auto;
    box-shadow: none;
  }
}
