:root {
  --bg: #07111f;
  --bg-soft: #0b1728;
  --surface: #0e1d30;
  --surface-2: #12243a;
  --line: rgba(148, 180, 215, 0.18);
  --text: #eff7ff;
  --muted: #94a9c1;
  --accent: #5eead4;
  --accent-2: #5bb8ff;
  --ink: #142234;
  --paper: #f4f7fb;
  --paper-muted: #536477;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
body.dialog-open { overflow: hidden; }
a { color: inherit; }
button, select { font: inherit; }

.site-header {
  position: sticky; top: 0; z-index: 20; height: 72px; padding: 0 clamp(20px, 5vw, 76px);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(7,17,31,.84); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-size: 1.05rem; font-weight: 760; letter-spacing: .01em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: #041018; font-weight: 900; }
.brand-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-copy strong { color: #fff; line-height: 1; }
.brand-copy small { color: var(--muted); font-size: .7rem; font-weight: 500; line-height: 1.2; letter-spacing: 0; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.github-link, .contact-button { min-height: 42px; border-radius: 10px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: .92rem; }
.github-link { color: #cbd9e8; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.github-link svg { width: 18px; fill: currentColor; }
.github-link:hover { color: white; border-color: rgba(148,180,215,.4); }
.contact-button { border: 1px solid var(--accent); color: #05201e; background: var(--accent); cursor: pointer; }
.contact-button:hover, .primary-action:hover { filter: brightness(1.08); transform: translateY(-1px); }

.hero {
  position: relative; overflow: hidden; min-height: min(720px, calc(100vh - 72px));
  padding: clamp(70px, 10vw, 130px) clamp(20px, 8vw, 120px) 76px;
  display: flex; flex-direction: column; justify-content: center;
  background-image: linear-gradient(rgba(96,180,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(96,180,255,.05) 1px, transparent 1px);
  background-size: 52px 52px;
}
.hero::after { content: "FDE"; position: absolute; right: -1vw; bottom: -8vw; font-weight: 900; font-size: clamp(12rem, 27vw, 27rem); color: rgba(120,180,228,.035); letter-spacing: -.09em; pointer-events: none; }
.hero-glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; right: 5vw; top: 4%; background: radial-gradient(circle, rgba(39,180,205,.16), transparent 67%); pointer-events: none; }
.eyebrow, .section-label { color: var(--accent); font-size: .76rem; letter-spacing: .2em; font-weight: 800; }
.eyebrow { display: flex; align-items: center; gap: 12px; }
.eyebrow span { width: 34px; height: 2px; background: var(--accent); }
.hero h1 { position: relative; max-width: 950px; margin: 22px 0 12px; font-size: clamp(2.7rem, 6.4vw, 6.2rem); line-height: 1.06; letter-spacing: -.055em; }
.hero h1 em { color: transparent; font-style: normal; -webkit-text-stroke: 1px rgba(142,222,255,.75); }
.hero-subtitle { font-size: clamp(1.2rem, 2vw, 1.65rem); margin: 8px 0 14px; font-weight: 700; color: #dcecff; }
.hero-copy { max-width: 680px; color: var(--muted); font-size: 1.05rem; line-height: 1.85; margin: 0; }
.hero-actions { display: flex; gap: 12px; margin-top: 30px; }
.primary-action, .secondary-action { min-height: 48px; padding: 0 21px; border-radius: 10px; display: inline-flex; align-items: center; gap: 16px; text-decoration: none; font-weight: 750; transition: .2s ease; }
.primary-action { background: var(--accent); color: #06201d; }
.secondary-action { border: 1px solid var(--line); color: #d6e3ef; }
.book-meta { position: relative; display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 48px; color: var(--muted); font-size: .9rem; }
.book-meta strong { color: white; }

.reader-shell { background: var(--paper); color: var(--ink); padding: 72px clamp(20px, 6vw, 96px) 96px; }
.reader-page { min-height: calc(100vh - 72px); padding-top: clamp(48px, 6vw, 76px); }
.section-intro { max-width: 1240px; margin: 0 auto 34px; display: flex; gap: 20px; align-items: flex-start; }
.section-number { font-size: 3.3rem; line-height: 1; color: #ccd7e4; font-weight: 200; }
.section-intro h2 { font-size: clamp(1.65rem, 3vw, 2.5rem); margin: 5px 0 0; letter-spacing: -.035em; }
.reader-layout { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 290px minmax(0, 1fr); align-items: start; gap: 34px; }
.chapter-sidebar { border: 1px solid #dce4ed; border-radius: 16px; background: #fff; }
.sidebar-head { padding: 17px 19px; border-bottom: 1px solid #e5ebf1; font-weight: 800; }
#chapter-nav { padding: 8px; }
#chapter-nav button { width: 100%; border: 0; background: transparent; color: #536477; text-align: left; padding: 10px 11px; border-radius: 9px; cursor: pointer; font-size: .88rem; line-height: 1.35; }
#chapter-nav button:hover { background: #eff5f8; color: #0e5160; }
#chapter-nav button.active { background: #dff9f4; color: #075e5b; font-weight: 750; }
.static-chapter-nav { padding: 8px; }
.static-chapter-nav a { display: block; color: #536477; text-decoration: none; padding: 10px 11px; border-radius: 9px; font-size: .88rem; line-height: 1.35; }
.static-chapter-nav a:hover { background: #eff5f8; color: #0e5160; }
.static-chapter-nav a.active { background: #dff9f4; color: #075e5b; font-weight: 750; }
.chapter-content { min-height: 800px; background: #fff; border: 1px solid #dce4ed; border-radius: 18px; padding: clamp(26px, 5vw, 64px); box-shadow: 0 18px 55px rgba(31,54,79,.08); }
.chapter-content h1 { margin: 0 0 34px; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.15; letter-spacing: -.045em; }
.chapter-content h2 { margin: 2.3em 0 .75em; font-size: 1.42rem; color: #13293e; }
.chapter-content h3 { margin: 1.8em 0 .6em; color: #1f405d; }
.chapter-content p, .chapter-content li { color: #405267; font-size: 1rem; line-height: 1.9; }
.chapter-content blockquote { margin: 1.5em 0; padding: 14px 20px; border-left: 4px solid #27b8ab; background: #eefaf8; color: #1d5552; }
.chapter-content blockquote p { margin: 0; color: inherit; }
.chapter-content strong { color: #152d43; }
.chapter-content table { width: 100%; border-collapse: collapse; margin: 1.5em 0; display: block; overflow-x: auto; }
.chapter-content th, .chapter-content td { border: 1px solid #dbe4ec; padding: 10px 12px; text-align: left; min-width: 110px; }
.chapter-content th { background: #eff5f8; }
.chapter-pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; padding-top: 24px; border-top: 1px solid #dbe4ec; }
.chapter-pagination a { color: #087a75; font-weight: 700; line-height: 1.5; text-decoration: none; }
.chapter-pagination a:last-child { text-align: right; }
.loading-state, .error-state { padding: 70px 0; text-align: center; color: #66798d; }
.mobile-chapter-picker { display: none; max-width: 1240px; margin: 0 auto 16px; }
.mobile-chapter-picker label { display: block; font-weight: 750; margin-bottom: 8px; }
.mobile-chapter-picker select { width: 100%; padding: 13px; color: #172b3f; background: white; border: 1px solid #cedae5; border-radius: 10px; }

footer { min-height: 180px; padding: 48px clamp(20px, 6vw, 96px); display: flex; flex-direction: column; justify-content: center; gap: 16px; align-items: center; text-align: center; border-top: 1px solid var(--line); }
footer strong { font-size: 1.25rem; }
footer p, .footer-right { color: var(--muted); }
.footer-right { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.footer-right a { color: var(--accent); }

.contact-dialog { width: min(1040px, calc(100vw - 28px)); border: 1px solid rgba(148,180,215,.24); border-radius: 22px; color: var(--text); background: #0b1728; padding: clamp(22px, 4vw, 42px); box-shadow: 0 28px 100px rgba(0,0,0,.5); }
.contact-dialog::backdrop { background: rgba(2,8,18,.77); backdrop-filter: blur(8px); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.dialog-head h2 { margin: 5px 0 6px; font-size: 2rem; }
.dialog-head p { margin: 0; color: var(--muted); }
.close-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: white; font-size: 1.8rem; cursor: pointer; }
.qr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 30px; }
.qr-grid figure { margin: 0; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.qr-frame { background: white; border-radius: 10px; overflow: hidden; aspect-ratio: 1 / 1; display: grid; place-items: center; }
.qr-frame.dark { background: #181818; }
.qr-frame img { width: 100%; height: 100%; object-fit: cover; }
.qr-grid figcaption { display: flex; flex-direction: column; gap: 3px; padding: 13px 2px 2px; }
.qr-grid figcaption span { color: var(--muted); font-size: .87rem; }
.contact-email { text-align: center; color: var(--muted); margin: 24px 0 0; }
.contact-email a { color: var(--accent); }
.mobile-qr-tip, .group-expiry-tip { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: .88rem; }
.group-expiry-tip { margin-top: 7px; color: #b8c8d9; }
.qr-frame img { -webkit-touch-callout: default; user-select: auto; }

@media (max-width: 820px) {
  .site-header { height: 64px; padding: 0 16px; }
  .github-link span:not(:last-child) { display: none; }
  .github-link { padding: 0 12px; }
  .contact-button { padding: 0 13px; }
  .hero { min-height: auto; padding: 72px 20px 58px; }
  .hero h1 { font-size: clamp(2.55rem, 13vw, 4.2rem); }
  .hero-copy { font-size: 1rem; }
  .book-meta { display: grid; grid-template-columns: 1fr 1fr; margin-top: 38px; }
  .reader-shell { padding: 52px 16px 64px; }
  .section-number { font-size: 2.5rem; }
  .mobile-chapter-picker { display: block; }
  .reader-layout { display: block; }
  .chapter-sidebar { display: none; }
  .chapter-content { padding: 28px 20px; border-radius: 14px; }
  .chapter-content h1 { font-size: 2.15rem; }
  .chapter-content p, .chapter-content li { font-size: 1rem; line-height: 1.85; }
  footer { align-items: center; }
  .qr-grid { grid-template-columns: 1fr; }
  .qr-grid figure { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 12px; }
  .contact-dialog { max-height: calc(100vh - 24px); overflow: auto; }
}

@media (max-width: 430px) {
  .brand-copy small { display: none; }
  .github-link { width: 42px; padding: 0; }
  .github-link span { display: none !important; }
  .hero-actions { flex-direction: column; }
  .primary-action, .secondary-action { justify-content: center; }
  .qr-grid figure { grid-template-columns: 112px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
