/* ==========================================================================
   Concise Neonatal Surgery — site stylesheet
   One file, no framework. System fonts for zero font-loading cost.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f5f2;
  --bg-tint: #fdf3f8;
  --surface: #ffffff;
  --ink: #141a2b;
  --text: #2c3243;
  --muted: #5f6677;
  --faint: #8a90a0;
  --line: #e7e3dd;
  --line-strong: #d6d1c9;
  --brand: #c4286f;
  --brand-strong: #a01d5a;
  --brand-soft: #fbe8f1;
  --brand-ink: #7d1446;
  --accent: #0f766e;
  --accent-soft: #e2f3f1;
  --warn-soft: #fff6e6;
  --footer-bg: #f7f5f2;
  --footer-text: #4a5162;
  --shadow-sm: 0 1px 2px rgba(20, 26, 43, .06), 0 1px 3px rgba(20, 26, 43, .05);
  --shadow: 0 4px 14px -4px rgba(20, 26, 43, .10), 0 2px 4px rgba(20, 26, 43, .04);
  --shadow-lg: 0 24px 48px -16px rgba(20, 26, 43, .22);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
  --reader-size: 18px;
  --header-h: 68px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1117;
  --bg-soft: #141922;
  --bg-tint: #1c141b;
  --surface: #161b25;
  --ink: #f2f4f8;
  --text: #d5d9e2;
  --muted: #a0a7b5;
  --faint: #7a8293;
  --line: #262d3a;
  --line-strong: #343c4b;
  --brand: #f2689f;
  --brand-strong: #ff8db9;
  --brand-soft: #2b1622;
  --brand-ink: #ffb3d1;
  --accent: #4fd1c0;
  --accent-soft: #11302d;
  --warn-soft: #2b2414;
  --footer-bg: #141922;
  --footer-text: #a7aebb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 18px -6px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow-x: clip; } /* safety net: never let wide content create a sideways page scroll */
.reader-layout > *, .toc-layout > *, .split > *, .contact-grid > *, .hero-grid > *, .footer-grid > * { min-width: 0; }
img, svg, video { max-width: 100%; height: auto; }
img { display: block; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); color: var(--ink); }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 860px; }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15.5px; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(196, 40, 111, .55); }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #1a0a12; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { padding: 9px 15px; font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--brand-soft); color: var(--brand-ink);
}
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-muted { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand);
  margin-bottom: 14px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .site-header { background: var(--bg); } }
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--line); object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-top { font-family: var(--font-serif); font-style: italic; font-size: 15px; color: var(--brand); }
.brand-bottom { font-weight: 750; font-size: 16.5px; letter-spacing: -.01em; }
.main-nav { margin-left: auto; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.main-nav a {
  display: block; padding: 8px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 550; font-size: 15px;
}
.main-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 10px 0 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 14px;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--ink); }
.search-trigger kbd {
  font: 600 12px var(--font-mono); padding: 2px 7px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink);
}
.icon-btn:hover { border-color: var(--line-strong); }
.only-dark, .when-open { display: none; }
:root[data-theme="dark"] .only-dark { display: inline; }
:root[data-theme="dark"] .only-light { display: none; }
.nav-toggle { display: none; }
.nav-open .when-open { display: inline; }
.nav-open .when-closed { display: none; }

@media (max-width: 1080px) {
  .search-trigger-text, .search-trigger kbd { display: none; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .header-actions { margin-left: auto; }
  .main-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
    padding: 10px 20px 22px; display: none;
  }
  .nav-open .main-nav { display: block; }
  .main-nav ul { flex-direction: column; gap: 2px; }
  .main-nav a { padding: 13px 12px; font-size: 17px; }
}
@media (max-width: 380px) { .brand-bottom { font-size: 15px; } .brand-mark { width: 36px; height: 36px; } }

/* ---------- Sections / generic ---------- */
.section { padding: 88px 0; }
.section-sm { padding: 56px 0; }
.section-soft { background: var(--bg-soft); }
.section-head { max-width: 720px; margin-bottom: 44px; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.section-title { font-size: clamp(28px, 3.4vw, 40px); font-weight: 760; letter-spacing: -0.025em; }
.section-lead { font-size: 18px; color: var(--muted); margin: 0; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; text-decoration: none; }
.link-arrow .icon { transition: transform .15s; }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 72px 0 84px; background:
  radial-gradient(900px 420px at 85% -10%, var(--brand-soft), transparent 70%),
  radial-gradient(700px 380px at -10% 110%, var(--accent-soft), transparent 70%), var(--bg); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(38px, 5.6vw, 66px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.03; margin-bottom: 22px; }
.hero h1 .accent { color: var(--brand); font-family: var(--font-serif); font-style: italic; font-weight: 600; letter-spacing: -0.02em; }
.hero-lead { font-size: clamp(17px, 1.7vw, 20px); color: var(--muted); max-width: 590px; margin-bottom: 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 40px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, auto); gap: 8px 36px; justify-content: start; margin: 0; padding: 0; list-style: none; }
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 28px; font-weight: 780; color: var(--ink); letter-spacing: -0.02em; line-height: 1.1; }
.hero-stats span { font-size: 13.5px; color: var(--muted); }

.book-visual { position: relative; display: grid; place-items: center; min-height: 440px; }
.book-cover {
  position: relative; width: min(330px, 80%); aspect-ratio: 3 / 4.1; border-radius: 6px 16px 16px 6px;
  background: linear-gradient(155deg, #d83a82 0%, #b0205f 55%, #7c1544 100%);
  color: #fff; padding: 34px 30px 30px 40px; display: flex; flex-direction: column;
  box-shadow: inset 10px 0 18px -10px rgba(0,0,0,.45), inset -1px 0 0 rgba(255,255,255,.15), 30px 40px 60px -30px rgba(80, 10, 40, .55), 0 2px 4px rgba(0,0,0,.1);
  transform: perspective(1400px) rotateY(-14deg) rotateX(3deg); transform-origin: left center;
}
.book-cover::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.18); }
.book-cover-kicker { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; opacity: .85; font-weight: 600; }
.book-cover-title { font-family: var(--font-serif); font-size: 40px; line-height: 1.02; margin: 18px 0 0; font-weight: 600; color: #fff; }
.book-cover-title em { display: block; font-size: 28px; opacity: .9; }
.book-cover-mark { margin-top: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; opacity: .95; }
.book-cover-mark img { width: 58px; height: 58px; border-radius: 50%; background: #fff; padding: 2px; }
.book-pages {
  position: absolute; width: min(330px, 80%); aspect-ratio: 3 / 4.1; border-radius: 6px 16px 16px 6px;
  background: repeating-linear-gradient(90deg, #f4efe9 0 2px, #e9e2d9 2px 3px);
  transform: perspective(1400px) rotateY(-14deg) rotateX(3deg) translate(14px, 10px); transform-origin: left center; z-index: -1;
  box-shadow: 20px 30px 50px -30px rgba(0,0,0,.35);
}
.float-card {
  position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink); max-width: 230px;
}
.float-card .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.float-card strong { display: block; font-size: 14px; }
.float-card span { color: var(--muted); font-size: 12.5px; }
.float-1 { top: 46%; right: -6px; }
.float-2 { top: 66%; left: -2px; }
.float-2 .dot { background: var(--brand-soft); color: var(--brand); }

@media (max-width: 960px) {
  .hero { padding: 44px 0 56px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .book-visual { min-height: 0; order: -1; display: none; }
  .hero-stats { grid-template-columns: repeat(2, auto); gap: 18px 40px; }
}

/* ---------- Chapter cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1000px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid { grid-template-columns: minmax(0, 1fr); } }
.chapter-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px;
  transition: border-color .15s, box-shadow .2s, transform .2s;
}
.chapter-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.chapter-card .card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chapter-card .card-num { font: 700 12.5px var(--font-mono); color: var(--faint); }
.chapter-card h3 { font-size: 19px; font-weight: 720; margin: 2px 0 0; line-height: 1.28; }
.chapter-card h3 a { color: var(--ink); text-decoration: none; }
.chapter-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.chapter-card h3 a:hover { color: var(--brand); }
.chapter-card .card-excerpt { color: var(--muted); font-size: 14.5px; line-height: 1.55; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chapter-card .card-meta { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); }
.chapter-card .card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-author { font-size: 13.5px; color: var(--text); font-weight: 550; }

/* ---------- Sections grid (home) ---------- */
.sections-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; counter-reset: sec; }
@media (max-width: 1000px) { .sections-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .sections-grid { grid-template-columns: minmax(0, 1fr); } }
.section-tile {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center;
  padding: 18px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; color: var(--ink); transition: border-color .15s, background .15s;
}
.section-tile:hover { border-color: var(--brand); color: var(--ink); }
.section-tile .num {
  grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font: 750 16px var(--font-mono);
}
.section-tile strong { font-size: 15.5px; line-height: 1.3; font-weight: 680; }
.section-tile .progress { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.progress-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; max-width: 120px; border: 1px solid var(--line); }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #e86aa6); border-radius: 99px; }

/* ---------- Features ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 960px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .feature-grid { grid-template-columns: minmax(0, 1fr); } }
.feature { padding: 26px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.feature .f-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 16px; }
.feature:nth-child(3n+2) .f-icon { background: var(--accent-soft); color: var(--accent); }
.feature h3 { font-size: 18px; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: 15px; margin: 0; }

/* ---------- Mission split ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); gap: 32px; } }
.split-media { position: relative; }
.split-media img { width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); aspect-ratio: 3 / 2; object-fit: cover; }
.split-media .badge-card { position: absolute; left: -18px; bottom: -22px; }
@media (max-width: 600px) { .split-media .badge-card { left: 12px; } }
.check-list { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 12px; }
.check-list li { display: flex; gap: 12px; align-items: flex-start; }
.check-list .icon { color: var(--accent); margin-top: 3px; }

/* ---------- CTA band ---------- */
.cta-band {
  border-radius: var(--radius-lg); padding: 48px; display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center;
  background: linear-gradient(135deg, #1a2036 0%, #2a1530 100%); color: #e9ebf2;
}
.cta-band h2 { color: #fff; font-size: clamp(24px, 2.6vw, 32px); margin-bottom: 8px; }
.cta-band p { color: #c3c7d4; margin: 0; max-width: 620px; }
.cta-band .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.cta-band .btn-ghost:hover { border-color: #fff; }
@media (max-width: 760px) { .cta-band { grid-template-columns: minmax(0, 1fr); padding: 32px 24px; } }

/* ---------- Page hero (inner pages) ---------- */
.page-hero { padding: 54px 0 40px; background: linear-gradient(180deg, var(--bg-tint), var(--bg)); border-bottom: 1px solid var(--line); }
.page-hero h1 { font-size: clamp(32px, 4.4vw, 50px); font-weight: 790; letter-spacing: -0.03em; margin-bottom: 14px; }
.page-hero .lead { font-size: 18.5px; color: var(--muted); max-width: 720px; margin: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumbs li + li::before { content: "/"; color: var(--faint); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand); }

/* ---------- Table of contents page ---------- */
.toc-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 44px; padding-bottom: 90px; }
@media (max-width: 960px) { .toc-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; } }
.toc-side { position: sticky; top: calc(var(--header-h) + 24px); }
@media (max-width: 960px) { .toc-side { position: static; } }
.toc-tools { display: grid; gap: 12px; margin-bottom: 22px; }
.input {
  width: 100%; height: 46px; padding: 0 14px 0 42px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface) no-repeat 14px 50% / 18px; color: var(--ink); font-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a90a0' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--text); cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.toc-nav { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; max-height: calc(100vh - 260px); overflow: auto; }
.toc-nav a { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 14px; line-height: 1.35; }
.toc-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.toc-nav .n { font: 700 12px var(--font-mono); color: var(--faint); min-width: 20px; padding-top: 2px; }
@media (max-width: 960px) { .toc-nav { display: none; } }

.toc-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; overflow: hidden; }
.toc-section-head { display: flex; align-items: center; gap: 16px; padding: 18px 22px; background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.toc-section-head .num { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand); color: #fff; font: 750 15px var(--font-mono); flex: none; }
:root[data-theme="dark"] .toc-section-head .num { color: #1a0a12; }
.toc-section-head h2 { font-size: 19px; margin: 0; }
.toc-section-head .count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.chapter-list { list-style: none; margin: 0; padding: 6px 0; }
.chapter-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 4px 12px; align-items: baseline; padding: 11px 22px; border-top: 1px solid var(--line); }
.chapter-row:first-child { border-top: 0; }
.chapter-row .n { font: 650 13px var(--font-mono); color: var(--faint); }
.chapter-row .title { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.chapter-row a.title { text-decoration: none; }
.chapter-row a.title:hover { color: var(--brand); text-decoration: underline; }
.chapter-row .sub { grid-column: 2; font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chapter-row.is-draft .title { color: var(--muted); font-weight: 500; }
.chapter-row .status { font-size: 12px; }
@media (max-width: 600px) {
  .chapter-row { grid-template-columns: 34px 1fr; padding: 12px 16px; }
  .chapter-row .status { grid-column: 2; justify-self: start; }
  .toc-section-head { padding: 16px; }
}
.no-results { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- Chapter (reader) ---------- */
.read-progress { position: fixed; left: 0; top: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--brand), #f08bb9); z-index: 60; transition: width .08s linear; }
.chapter-hero { padding: 40px 0 34px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--bg-tint), var(--bg)); }
.chapter-hero .section-link { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); text-decoration: none; margin-bottom: 14px; }
.chapter-hero h1 { font-size: clamp(32px, 4.6vw, 52px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; margin-bottom: 20px; max-width: 900px; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; color: var(--muted); font-size: 14.5px; }
.byline .authors { display: flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; }
.avatars { display: flex; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 750; color: var(--brand-ink); background: var(--brand-soft); border: 2px solid var(--bg); }
.avatar + .avatar { margin-left: -10px; background: var(--accent-soft); color: var(--accent); }
.byline .meta-item { display: inline-flex; align-items: center; gap: 6px; }

.reader-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; padding-top: 40px; padding-bottom: 80px; align-items: start; }
.reader-side { position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow: auto; padding-right: 6px; scrollbar-width: thin; }
.reader-side h2 { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 0 0 12px; }
.otp { list-style: none; margin: 0 0 22px; padding: 0; border-left: 2px solid var(--line); }
.otp a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4; }
.otp .lvl-3 a { padding-left: 28px; font-size: 13.5px; }
.otp a:hover { color: var(--ink); }
.otp a.is-active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.reader-tools { display: flex; align-items: center; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
.reader-tools span { font-size: 13px; color: var(--muted); margin-right: auto; display: inline-flex; gap: 6px; align-items: center; }
.reader-tools button { width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 700; color: var(--ink); }
.reader-tools button:hover { border-color: var(--brand); color: var(--brand); }
.mobile-otp { display: none; margin-bottom: 26px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
.mobile-otp summary { padding: 14px 16px; cursor: pointer; font-weight: 650; display: flex; align-items: center; gap: 10px; list-style: none; color: var(--ink); }
.mobile-otp summary::-webkit-details-marker { display: none; }
.mobile-otp summary::after { content: "+"; margin-left: auto; font-size: 20px; color: var(--muted); }
.mobile-otp[open] summary::after { content: "–"; }
.mobile-otp .otp { margin: 0 16px 16px; }
@media (max-width: 1020px) {
  .reader-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 28px; }
  .reader-side { display: none; }
  .mobile-otp { display: block; }
}

/* Article typography */
.prose { max-width: 740px; font-family: var(--font-serif); font-size: var(--reader-size); line-height: 1.75; color: var(--text); overflow-wrap: break-word; }
.prose > * + * { margin-top: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h2 { font-family: var(--font-sans); font-size: 1.5em; font-weight: 760; margin: 2.1em 0 .7em; padding-top: 1.1em; border-top: 1px solid var(--line); letter-spacing: -0.02em; }
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-family: var(--font-sans); font-size: 1.16em; font-weight: 700; margin: 1.7em 0 .55em; letter-spacing: -0.01em; }
.prose h2 + h3 { margin-top: .4em; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose sup { font-family: var(--font-sans); font-size: .62em; color: var(--brand); font-weight: 600; line-height: 0; margin-left: 1px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: .35em 0; padding-left: .2em; }
.prose ul li::marker { color: var(--brand); }
.prose a { overflow-wrap: anywhere; }
.prose .caption, .prose figcaption { font-family: var(--font-sans); font-size: 14px; color: var(--muted); line-height: 1.5; }
.prose .caption { margin: -.3em 0 1.4em; font-style: italic; }
.prose .figures { display: grid; gap: 16px; margin: 1.8em 0; }
.prose .figures-2 { grid-template-columns: 1fr 1fr; }
.prose .figures-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .prose .figures-2, .prose .figures-3 { grid-template-columns: minmax(0, 1fr); } }
.prose figure { margin: 0; }
.prose .figures img {
  width: auto; max-width: 100%; max-height: 520px; margin: 0 auto; border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
.prose figcaption { margin-top: 10px; text-align: center; }
.prose .diagram { margin: 1.8em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); overflow: hidden; }
.prose .diagram pre { margin: 0; padding: 20px; overflow-x: auto; font: 13px/1.5 var(--font-mono); color: var(--ink); }
.prose .diagram figcaption { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface); text-align: left; font-weight: 600; }
.table-wrap { margin: 1.8em 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); -webkit-overflow-scrolling: touch; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 14.5px; line-height: 1.5; min-width: 520px; }
.prose caption { caption-side: top; text-align: left; padding: 14px 16px; font-weight: 650; color: var(--ink); font-size: 14.5px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { background: var(--bg-soft); color: var(--ink); font-weight: 680; font-size: 13.5px; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.prose td:first-child { font-weight: 600; color: var(--ink); }
.prose .references { font-family: var(--font-sans); font-size: 14px; line-height: 1.55; color: var(--muted); padding-left: 1.8em; }
.prose .references li { margin: .5em 0; padding-left: .3em; }
.prose .references li::marker { color: var(--faint); font-weight: 600; }

.chapter-end { max-width: 740px; margin-top: 56px; display: grid; gap: 20px; }
.cite-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--bg-soft); }
.cite-box h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cite-box p { font-family: var(--font-serif); font-size: 15.5px; margin: 0 0 14px; color: var(--text); }
.note-box { display: flex; gap: 14px; border-radius: var(--radius); padding: 18px 20px; background: var(--warn-soft); font-size: 14.5px; color: var(--text); }
.note-box .icon { color: #b7791f; margin-top: 2px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .pager { grid-template-columns: minmax(0, 1fr); } }
.pager a {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.pager a:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.pager .dir { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pager .t { color: var(--ink); font-weight: 680; font-size: 16px; line-height: 1.35; }
.pager .next { text-align: right; align-items: flex-end; }
.related { margin-top: 12px; }
.related h2 { font-size: 20px; margin-bottom: 14px; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.related li a, .related li span { display: flex; gap: 12px; align-items: baseline; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); background: var(--surface); }
.related li a:hover { border-color: var(--brand); color: var(--brand); }
.related li span { color: var(--muted); }
.related .n { font: 650 12.5px var(--font-mono); color: var(--faint); min-width: 26px; }

/* ---------- People ---------- */
.people-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 960px) { .people-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .people-grid { grid-template-columns: minmax(0, 1fr); } }
.person { display: flex; flex-direction: column; gap: 12px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.person-head { display: flex; gap: 14px; align-items: center; }
.person .avatar-lg { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 760; font-size: 18px; flex: none; overflow: hidden; }
.person .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.person:nth-child(3n+2) .avatar-lg { background: var(--accent-soft); color: var(--accent); }
.person h3 { font-size: 17.5px; margin: 0; }
.person .role { font-size: 14px; color: var(--muted); margin: 2px 0 0; }
.person ul { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px dashed var(--line); display: grid; gap: 6px; font-size: 14.5px; }
.person ul a { text-decoration: none; font-weight: 550; }
.person p { margin: 0; color: var(--muted); font-size: 14.5px; }

.empty-state { text-align: center; padding: 64px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--bg-soft); }
.empty-state .f-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 18px; background: var(--brand-soft); color: var(--brand); }
.empty-state h2 { font-size: 24px; }
.empty-state p { color: var(--muted); max-width: 520px; margin: 0 auto 22px; }

.sponsor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .sponsor-grid { grid-template-columns: repeat(2, 1fr); } }
.sponsor { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; text-align: center; color: #141a2b; text-decoration: none; }
.sponsor img { max-height: 90px; width: auto; object-fit: contain; }

/* ---------- About / prose pages ---------- */
.content-prose { font-size: 18px; line-height: 1.75; max-width: 760px; }
.content-prose p { color: var(--text); }
.content-prose .lead-p { font-size: 21px; line-height: 1.6; color: var(--ink); font-family: var(--font-serif); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 40px 0; }
@media (max-width: 700px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 20px; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--line); }
.stat strong { display: block; font-size: 30px; font-weight: 790; color: var(--ink); letter-spacing: -0.02em; }
.stat span { font-size: 14px; color: var(--muted); }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 48px; padding-top: 48px; padding-bottom: 90px; align-items: start; }
@media (max-width: 900px) { .contact-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
.contact-card { padding: 26px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-soft); }
.contact-card h2 { font-size: 20px; }
.contact-card p { color: var(--muted); }
.contact-line { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-weight: 600; color: var(--ink); font-size: 14.5px; overflow-wrap: anywhere; }
.contact-line .icon { color: var(--brand); }
.form { display: grid; gap: 18px; padding: 30px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 600px) { .form-row { grid-template-columns: minmax(0, 1fr); } .form { padding: 22px; } }
.field label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; color: var(--ink); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font: inherit; font-size: 15.5px;
}
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.alert { padding: 14px 16px; border-radius: 10px; font-size: 15px; font-weight: 550; }
.alert-ok { background: var(--accent-soft); color: var(--accent); }
.alert-err { background: var(--brand-soft); color: var(--brand-ink); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Footer ---------- */
.site-footer { background: var(--footer-bg); color: var(--footer-text); padding: 64px 0 28px; margin-top: 0; border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: 1.3fr .7fr 1.5fr; gap: 48px; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: minmax(0, 1fr); } }
.brand-light, .brand-light:hover { color: var(--ink); }
.brand-light .brand-top { color: var(--brand); }
.footer-brand p { margin: 18px 0; font-size: 15px; max-width: 420px; }
.footer-mail { display: inline-flex; align-items: center; gap: 8px; color: var(--brand); font-weight: 600; text-decoration: none; }
.footer-mail:hover { color: var(--brand-strong); }
.footer-title { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); margin: 6px 0 16px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 14.5px; }
.footer-links.cols-2 { grid-template-columns: 1fr 1fr; column-gap: 24px; }
@media (max-width: 560px) { .footer-links.cols-2 { grid-template-columns: minmax(0, 1fr); } }
.footer-links a { color: var(--footer-text); text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 13.5px; }
.footer-bottom p { margin: 0; }
.footer-note { color: var(--faint); }

/* ---------- Search overlay ---------- */
.search-overlay { position: fixed; inset: 0; z-index: 90; display: grid; justify-items: center; align-items: start; padding: 10vh 16px 16px; }
.search-overlay[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(12, 15, 24, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.search-panel { position: relative; width: min(680px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; }
.search-form { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-form input { flex: 1; height: 62px; border: 0; background: transparent; color: var(--ink); font-size: 18px; outline: none; min-width: 0; }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-esc { font: 600 12px var(--font-mono); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); cursor: pointer; }
.search-results { max-height: min(60vh, 520px); overflow: auto; padding: 8px; }
.search-hint, .search-empty { padding: 18px 14px; margin: 0; color: var(--muted); font-size: 15px; }
.search-item { display: block; padding: 12px 14px; border-radius: 10px; text-decoration: none; color: var(--text); }
.search-item:hover, .search-item.is-active { background: var(--brand-soft); }
.search-item .t { display: flex; align-items: center; gap: 8px; font-weight: 680; color: var(--ink); font-size: 16px; }
.search-item .s { font-size: 12.5px; color: var(--brand); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.search-item .x { font-size: 14px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-item mark { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--ink); border-radius: 3px; padding: 0 1px; }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding: 110px 0 120px; }
.not-found .code { font: 800 110px/1 var(--font-sans); letter-spacing: -0.05em; color: var(--brand-soft); -webkit-text-stroke: 2px var(--brand); }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .reader-side, .mobile-otp, .read-progress, .chapter-end .pager, .search-overlay, .reader-tools { display: none !important; }
  .reader-layout { display: block; padding: 0; }
  .prose { max-width: none; font-size: 11.5pt; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Reading mode (chapter pages) ---------- */
.read-mode-btn { margin-left: auto; }
@media (max-width: 640px) { .read-mode-btn { margin-left: 0; } }
.reading-toolbar {
  display: none; position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 55;
  align-items: center; gap: 4px; padding: 7px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.reading-toolbar button {
  height: 38px; min-width: 38px; padding: 0 10px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--ink); font-weight: 700; font-size: 14.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.reading-toolbar button:hover { background: var(--bg-soft); }
.reading-toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.reading-toolbar .sw { width: 30px; min-width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-strong); }
.reading-toolbar .sw-light, .reading-toolbar .sw-light:hover { background: #ffffff; }
.reading-toolbar .sw-paper, .reading-toolbar .sw-paper:hover { background: #f1e7d3; }
.reading-toolbar .sw-dark, .reading-toolbar .sw-dark:hover { background: #161b25; }
.reading-toolbar .sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.reading-toolbar .exit { background: var(--brand-soft); color: var(--brand-ink); padding: 0 14px; }
.reading-toolbar .exit:hover { background: var(--brand-soft); filter: brightness(.97); }
@media (max-width: 380px) { .reading-toolbar .exit-label { display: none; } .reading-toolbar .exit { padding: 0; } }

html.is-reading { scroll-padding-top: 24px; }
.is-reading .reading-toolbar { display: flex; }
.is-reading .site-header, .is-reading .site-footer, .is-reading .reader-side, .is-reading .breadcrumbs,
.is-reading .read-mode-btn, .is-reading .related, .is-reading .note-box { display: none !important; }
.is-reading .chapter-hero { background: var(--bg); border-bottom: 0; padding: 56px 0 4px; }
.is-reading .chapter-hero .container, .is-reading .reader-layout { max-width: 780px; }
.is-reading .chapter-hero h1 { font-size: clamp(30px, 4.2vw, 44px); }
.is-reading .reader-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 24px; padding-bottom: 130px; }
.is-reading .mobile-otp { display: block; }
.is-reading .prose { margin: 0 auto; line-height: 1.85; }
.is-reading .chapter-end { margin-left: auto; margin-right: auto; }
.is-reading body { transition: background-color .2s ease, color .2s ease; }

/* Paper (sepia) background, only inside reading mode */
:root.is-reading[data-paper] {
  --bg: #f6efe2; --bg-soft: #eee4d1; --bg-tint: #f6efe2; --surface: #fbf6ec;
  --ink: #2b2318; --text: #3d3426; --muted: #6d604c; --faint: #978a74;
  --line: #e2d6bf; --line-strong: #d3c4a8;
  --brand: #a3235c; --brand-strong: #861a4a; --brand-soft: #efdcd6; --brand-ink: #74163f;
  --accent: #116a62; --accent-soft: #dfe8dc; --warn-soft: #f1e4c8;
  color-scheme: light;
}
:root.is-reading[data-paper] .prose .figures img { background: #fff; }
@media print { .reading-toolbar, .read-mode-btn { display: none !important; } }
