/* ===========================================================================
   Equity Research Companion — Alibaba Case Study
   Design philosophy: clean, modern, professional, with abundant whitespace and
   carefully chosen typography. Inspired by long-form editorial sites like
   Stratechery, The Pudding, and traditional sell-side research publications.
   =========================================================================== */

:root {
  /* Brand palette - sophisticated greys with a single accent */
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-card: #f5f3ee;
  --bg-dark: #1a1a1c;
  --bg-dark-elev: #25252a;
  --ink: #1a1a1c;
  --ink-2: #2c2c30;
  --ink-3: #5a5a62;
  --ink-4: #8a8a95;
  --ink-5: #b8b8c0;
  --rule: #e8e5dd;
  --rule-2: #d4d0c4;

  /* Accent colors - editorial */
  --accent: #b8460e;          /* burnt umber - the editorial red */
  --accent-2: #7a3013;
  --accent-soft: #e8d5c3;
  --positive: #2d6a3e;
  --positive-soft: #d8e8df;
  --negative: #8b2421;
  --negative-soft: #f0d5d4;
  --neutral: #4a5c7a;

  /* Chart palette - distinguishable, color-blind safe */
  --c1: #1f4e7a;
  --c2: #b8460e;
  --c3: #2d6a3e;
  --c4: #7a3a8a;
  --c5: #c89020;
  --c6: #4a5c7a;
  --c7: #8b2421;
  --c8: #5a7858;

  /* Typography */
  --serif: 'Source Serif 4', 'Times New Roman', 'Songti SC', 'Noto Serif SC', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;

  /* Layout tokens — one consistent column for everything */
  --content-w: 880px;     /* prose-comfortable, ~70ch at 16px */
  --wide-w: 880px;        /* keep charts the same width as prose */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-pad-y: clamp(3rem, 7vw, 6rem);
  --radius: 6px;
  --radius-lg: 12px;
  --shadow-s: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-m: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-l: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);

  /* Type scale (golden ratio inspired) */
  --t-tiny: 0.72rem;
  --t-xs: 0.82rem;
  --t-sm: 0.92rem;
  --t-base: 1.04rem;
  --t-lg: 1.22rem;
  --t-xl: 1.56rem;
  --t-2xl: 2.05rem;
  --t-3xl: 2.85rem;
  --t-4xl: 3.95rem;
  --t-5xl: 5.5rem;
}

/* ============================================================================ */
/* Base */
/* ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--t-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern', 'liga', 'onum';
  text-rendering: optimizeLegibility;
}

body[data-lang="cn"] {
  font-family: var(--sans);
  font-feature-settings: 'kern';
}

::selection { background: var(--accent-soft); color: var(--accent-2); }

img, svg { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}
a:hover { color: var(--accent-2); text-decoration-color: var(--accent); }

/* ============================================================================ */
/* Layout primitives */
/* ============================================================================ */
.container {
  width: 100%;
  max-width: var(--wide-w);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.container-wide {
  width: 100%;
  max-width: var(--wide-w);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.section {
  padding-top: var(--section-pad-y);
  padding-bottom: var(--section-pad-y);
  position: relative;
  scroll-margin-top: 4rem;
}

.section + .section { border-top: 1px solid var(--rule); }

.section-alt { background: var(--bg-card); }
.section-dark { background: var(--bg-dark); color: var(--ink-5); }
.section-dark h1,
.section-dark h2,
.section-dark h3,
.section-dark h4,
.section-dark .section-title,
.section-dark .chart-title { color: #fff; }
.section-dark .section-lede { color: var(--ink-5); }
.section-dark a { color: #f5b894; }
/* In dark sections, bolded prose text must be readable on the dark background.
   Override .prose strong (which is dark ink by default). */
.section-dark .prose strong,
.section-dark strong { color: #fff; }
.section-dark .prose em { color: var(--ink-5); }
.section-dark .prose li::marker { color: var(--c5); }
.section-dark .prose blockquote { color: var(--ink-5); border-left-color: var(--c5); }
.section-dark .chart-footnote,
.section-dark .chart-sub { color: var(--ink-4); }
.section-dark .table-wrap { border-color: var(--bg-dark-elev); }
.section-dark .data-table thead th { background: var(--bg-dark-elev); color: #fff; }
.section-dark .data-table td,
.section-dark .data-table th { border-bottom-color: var(--bg-dark-elev); color: var(--ink-5); }
.section-dark .data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.section-dark .data-table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Eyebrow / kicker label above section headings */
.eyebrow {
  display: inline-block;
  font-family: var(--sans);
  font-size: var(--t-tiny);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  padding-left: 1.6rem;
  position: relative;
}
.eyebrow::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 1.2rem; height: 1px;
  background: var(--accent);
  transform: translateY(-50%);
}

/* Section heading */
.section-title {
  font-family: var(--serif);
  font-size: var(--t-3xl);
  font-weight: 600;
  line-height: 1.12;
  margin: 0 0 1rem 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}
body[data-lang="cn"] .section-title { font-family: var(--sans); font-weight: 700; letter-spacing: 0; }

.section-lede {
  font-family: var(--serif);
  font-size: var(--t-lg);
  line-height: 1.55;
  color: var(--ink-3);
  margin: 0 0 3rem 0;
  font-style: italic;
  font-weight: 400;
}
body[data-lang="cn"] .section-lede { font-family: var(--sans); font-style: normal; }

/* ============================================================================ */
/* Top navigation */
/* ============================================================================ */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rule);
  transition: box-shadow 0.2s ease;
}
.topnav.scrolled { box-shadow: var(--shadow-s); }

.topnav-inner {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--t-lg);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
body[data-lang="cn"] .brand { font-family: var(--sans); }

.brand-mark {
  display: inline-block;
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.5rem;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;
  background: var(--bg);
  border-radius: 50%;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
  font-family: var(--sans);
  font-size: var(--t-sm);
}
.nav-menu a {
  color: var(--ink-3);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}
.nav-menu a:hover { color: var(--accent); }

.lang-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--rule-2);
  border-radius: 100px;
  padding: 3px;
  margin-left: 0.5rem;
}
.lang-toggle button {
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: var(--t-tiny);
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 100px;
  cursor: pointer;
  color: var(--ink-4);
  transition: all 0.18s ease;
}
.lang-toggle button.active {
  background: var(--ink);
  color: var(--bg);
}

.nav-burger {
  display: none;
  border: 0;
  background: none;
  width: 36px; height: 36px;
  margin-left: auto;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
}
.nav-burger svg { width: 22px; height: 22px; }

@media (max-width: 880px) {
  .nav-menu { display: none; }
  .nav-menu.open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg-elev);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--rule);
    box-shadow: var(--shadow-m);
  }
  .nav-menu.open a { padding: 0.85rem var(--gutter); border-bottom: 1px solid var(--rule); }
  .nav-menu.open .lang-toggle { margin: 0.5rem var(--gutter); }
  .nav-burger { display: inline-flex; align-items: center; justify-content: center; }
}

/* ============================================================================ */
/* Hero */
/* ============================================================================ */
.hero {
  padding: clamp(4rem, 10vw, 9rem) 0 clamp(3rem, 6vw, 5rem) 0;
  background:
    radial-gradient(60% 80% at 80% 20%, rgba(184,70,14,0.05) 0%, transparent 60%),
    radial-gradient(50% 70% at 20% 80%, rgba(31,78,122,0.05) 0%, transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}

.hero-grid {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}
@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
}

.hero-eyebrow {
  font-family: var(--sans);
  font-size: var(--t-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1.4rem;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, var(--t-5xl));
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 0 0 1.6rem 0;
  color: var(--ink);
}
body[data-lang="cn"] .hero-title { font-family: var(--sans); font-weight: 700; letter-spacing: -0.01em; }

.hero-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}
body[data-lang="cn"] .hero-title em { font-style: normal; }

.hero-sub {
  font-size: var(--t-lg);
  line-height: 1.55;
  color: var(--ink-3);
  max-width: 52ch;
  margin: 0 0 2.2rem 0;
}

.hero-cta {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.35rem;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-sm { padding: 0.55rem 0.95rem; font-size: var(--t-xs); }

/* Hero stat card */
.hero-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-l);
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.hero-card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.hero-card-row:last-child { border-bottom: 0; }
.hero-card-label {
  font-family: var(--sans);
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.hero-card-value {
  font-family: var(--serif);
  font-size: var(--t-xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.hero-card-value.pos { color: var(--positive); }
.hero-card-value.neg { color: var(--negative); }
.hero-card-value.accent { color: var(--accent); }

/* ============================================================================ */
/* Prose styling */
/* ============================================================================ */
/* Prose: single uniform column — everything (text, charts, tables, lists,
   callouts) shares the same left/right edges as the section container. */
.prose {
  max-width: 100%;
  margin: 0;
}

.prose h2 {
  font-family: var(--serif);
  font-size: var(--t-2xl);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 3rem 0 1rem;
}
body[data-lang="cn"] .prose h2 { font-family: var(--sans); font-weight: 700; }

.prose h3 {
  font-family: var(--serif);
  font-size: var(--t-xl);
  font-weight: 600;
  line-height: 1.25;
  margin: 2.4rem 0 0.8rem;
  color: var(--ink);
}
body[data-lang="cn"] .prose h3 { font-family: var(--sans); font-weight: 600; }

.prose h4 {
  font-family: var(--sans);
  font-size: var(--t-base);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin: 2rem 0 0.6rem;
}

.prose p {
  margin: 0 0 1.15em 0;
  hyphens: auto;
  -webkit-hyphens: auto;
}
body[data-lang="cn"] .prose p { hyphens: none; -webkit-hyphens: none; }

.prose p.lede {
  font-size: var(--t-lg);
  line-height: 1.6;
  color: var(--ink-2);
  font-weight: 400;
}

.prose p.lede::first-line { letter-spacing: 0; }

/* Drop cap for first paragraph after section title */
.prose .lede::first-letter {
  initial-letter: 3 2;
  -webkit-initial-letter: 3 2;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.12em;
  padding-right: 0.06em;
}
body[data-lang="cn"] .prose .lede::first-letter { initial-letter: normal; -webkit-initial-letter: normal; font-size: inherit; color: inherit; margin: 0; padding: 0; }

.prose strong { font-weight: 700; color: var(--ink); }
.prose em { font-style: italic; color: var(--ink-2); }
body[data-lang="cn"] .prose em { font-style: normal; font-weight: 600; }

.prose blockquote {
  margin: 2rem 0;
  padding: 0.5rem 0 0.5rem 1.5rem;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--ink-2);
  font-size: var(--t-lg);
  line-height: 1.55;
}
body[data-lang="cn"] .prose blockquote { font-style: normal; }

.prose ul, .prose ol {
  margin: 0 0 1.4em 0;
  padding-left: 1.4em;
}
.prose li { margin-bottom: 0.6em; }
.prose li::marker { color: var(--accent); }

/* Callout boxes */
.callout {
  margin: 2rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--t-sm);
}
.callout-title {
  font-family: var(--sans);
  font-size: var(--t-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.6rem 0;
}
.callout p:last-child { margin-bottom: 0; }
.callout.callout-tip { border-left-color: var(--positive); }
.callout.callout-tip .callout-title { color: var(--positive); }
.callout.callout-warn { border-left-color: var(--negative); }
.callout.callout-warn .callout-title { color: var(--negative); }
.callout.callout-formula { background: #1a1a1c; color: #f5f3ee; border-left-color: var(--c5); font-family: var(--mono); font-size: 0.95rem; }
.callout.callout-formula .callout-title { color: var(--c5); }

/* Pull quote */
.pullquote {
  font-family: var(--serif);
  font-size: var(--t-2xl);
  font-style: italic;
  line-height: 1.3;
  color: var(--ink-2);
  text-align: center;
  margin: 3rem auto;
  max-width: 22ch;
  position: relative;
  padding: 1.5rem 0;
}
body[data-lang="cn"] .pullquote { font-family: var(--sans); font-style: normal; }
.pullquote::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  width: 60px; height: 2px;
  background: var(--accent);
  transform: translateX(-50%);
}
.pullquote::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  width: 60px; height: 2px;
  background: var(--accent);
  transform: translateX(-50%);
}

/* Inline data dots */
.dot {
  display: inline-block;
  width: 0.55em; height: 0.55em;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.4em;
}
.dot.pos { background: var(--positive); }
.dot.neg { background: var(--negative); }
.dot.neu { background: var(--neutral); }

/* ============================================================================ */
/* Cards / Grids */
/* ============================================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: default;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-m);
  border-color: var(--rule-2);
}
.card-num {
  font-family: var(--serif);
  font-size: var(--t-3xl);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.5rem;
}
.card-h {
  font-family: var(--sans);
  font-size: var(--t-base);
  font-weight: 700;
  margin: 0 0 0.4rem 0;
  color: var(--ink);
}
.card-p {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin: 0;
  line-height: 1.55;
}

/* KPI tile */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 2rem 0;
}
.kpi-tile {
  background: var(--bg-elev);
  padding: 1.2rem 1.3rem;
}
.kpi-label {
  font-family: var(--sans);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  font-weight: 600;
}
.kpi-value {
  font-family: var(--serif);
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-top: 0.35rem;
}
.kpi-sub {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-4);
  margin-top: 0.2rem;
}

/* ============================================================================ */
/* Tables */
/* ============================================================================ */
.table-wrap {
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: var(--t-sm);
  min-width: 600px;
}
.data-table th,
.data-table td {
  padding: 0.7rem 0.9rem;
  text-align: right;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}
.data-table thead th {
  background: var(--bg-card);
  font-weight: 700;
  color: var(--ink-2);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--rule-2);
}
.data-table tbody tr:nth-child(even) { background: rgba(245,243,238,0.4); }
.data-table tbody tr:hover { background: var(--bg-card); }
.data-table .num { font-variant-numeric: tabular-nums; }
.data-table .pos { color: var(--positive); font-weight: 600; }
.data-table .neg { color: var(--negative); font-weight: 600; }
.data-table .total td { border-top: 2px solid var(--ink-3); font-weight: 700; background: var(--bg-card); }
.data-table .subtotal td { border-top: 1px solid var(--ink-4); font-weight: 600; }
.data-table .section-head td {
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--t-xs);
}
.data-table .indent { padding-left: 1.8rem; color: var(--ink-3); }
.data-table .accent-row td { color: var(--accent); font-weight: 600; }

/* ============================================================================ */
/* Charts */
/* ============================================================================ */
.chart-frame {
  margin: 2.5rem 0;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-s);
}
.chart-title {
  font-family: var(--sans);
  font-size: var(--t-base);
  font-weight: 700;
  margin: 0 0 0.3rem 0;
  color: var(--ink);
}
.chart-sub {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1.2rem 0;
}
.chart-host {
  position: relative;
  width: 100%;
  height: 360px;
}
.chart-host.tall { height: 480px; }
.chart-host.short { height: 240px; }
.chart-footnote {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-4);
  margin-top: 0.8rem;
  font-style: italic;
}
body[data-lang="cn"] .chart-footnote { font-style: normal; }

.chart-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  align-items: center;
}
.chart-controls label {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chart-controls input[type="range"] {
  flex: 1;
  min-width: 100px;
  accent-color: var(--accent);
}
.chart-controls input[type="number"],
.chart-controls select {
  font-family: var(--mono);
  font-size: var(--t-sm);
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--ink);
}
.chart-controls .val {
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--accent);
  min-width: 4.5rem;
  text-align: right;
  padding: 0 0.5rem;
}
.chart-controls .pill-group {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--rule-2);
  border-radius: 100px;
  padding: 2px;
}
.chart-controls .pill-group button {
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  cursor: pointer;
  color: var(--ink-3);
}
.chart-controls .pill-group button.on {
  background: var(--ink);
  color: var(--bg);
}

/* Legend chip */
.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: 0.5rem;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.legend i {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
}

/* DCF calculator output highlight */
.calc-output {
  background: linear-gradient(135deg, var(--ink) 0%, #2a2a32 100%);
  color: var(--bg);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.calc-out-cell { padding: 0.5rem 0.7rem; border-left: 3px solid var(--accent); }
.calc-out-label {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.calc-out-value {
  font-family: var(--serif);
  font-size: var(--t-2xl);
  font-weight: 600;
  color: #fff;
  margin-top: 0.3rem;
  letter-spacing: -0.01em;
}
.calc-out-value.accent { color: var(--c5); }

/* Section: split layout (text + visualization) */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
  margin: 2rem 0;
}
@media (max-width: 880px) { .split { grid-template-columns: 1fr; } }
.split-wide { grid-template-columns: 0.85fr 1.15fr; }
@media (max-width: 880px) { .split-wide { grid-template-columns: 1fr; } }

/* ============================================================================ */
/* Timeline */
/* ============================================================================ */
.timeline {
  position: relative;
  padding-left: 2rem;
  margin: 2rem 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--rule-2);
}
.tl-item {
  position: relative;
  padding-bottom: 1.6rem;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: -1.95rem; top: 8px;
  width: 14px; height: 14px;
  background: var(--bg);
  border: 3px solid var(--accent);
  border-radius: 50%;
}
.tl-date {
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.tl-event {
  font-family: var(--serif);
  font-size: var(--t-lg);
  font-weight: 600;
  margin: 0.2rem 0 0.3rem 0;
}
.tl-desc {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin: 0;
}

/* ============================================================================ */
/* Reading progress bar */
/* ============================================================================ */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s linear;
}

/* ============================================================================ */
/* TOC sidebar */
/* ============================================================================ */
.toc-sidebar {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-elev);
  padding: 8px 6px;
  border-radius: 100px;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-m);
  max-height: 70vh;
  overflow-y: auto;
}
.toc-sidebar a {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rule-2);
  position: relative;
  text-decoration: none;
  transition: all 0.18s ease;
}
.toc-sidebar a:hover { background: var(--accent); transform: scale(1.5); }
.toc-sidebar a.active { background: var(--accent); }
.toc-sidebar a::after {
  content: attr(data-label);
  position: absolute;
  right: 22px; top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: var(--t-xs);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.toc-sidebar a:hover::after { opacity: 1; }
@media (max-width: 1100px) { .toc-sidebar { display: none; } }

/* ============================================================================ */
/* Footer */
/* ============================================================================ */
.footer {
  background: var(--bg-dark);
  color: var(--ink-5);
  padding: 4rem 0 2rem;
  margin-top: 0;
}
.footer-grid {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr; gap: 2rem; } }
.footer h4 {
  color: #fff;
  font-family: var(--sans);
  font-size: var(--t-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 1rem 0;
}
.footer p, .footer li { font-size: var(--t-sm); line-height: 1.6; }
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin-bottom: 0.5rem; }
.footer a { color: var(--ink-5); text-decoration: none; }
.footer a:hover { color: #fff; }
.footer-bottom {
  max-width: var(--wide-w);
  margin: 3rem auto 0;
  padding: 1.5rem var(--gutter) 0;
  border-top: 1px solid var(--bg-dark-elev);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--sans);
  font-size: var(--t-xs);
  color: var(--ink-4);
}

/* ============================================================================ */
/* Utility */
/* ============================================================================ */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mt-3 { margin-top: 3rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 2rem; }
.gap-2 { gap: 2rem; }

.lang-en { display: var(--show-en, block); }
.lang-cn { display: var(--show-cn, none); }
body[data-lang="cn"] { --show-en: none; --show-cn: block; }
.lang-en.inline { display: var(--show-en-inline, inline); }
.lang-cn.inline { display: var(--show-cn-inline, none); }
body[data-lang="cn"] .lang-en.inline { display: none; }
body[data-lang="cn"] .lang-cn.inline { display: inline; }

/* SR-only */
.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;
}

/* Print friendly */
@media print {
  .topnav, .toc-sidebar, .lang-toggle, .read-progress { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .chart-frame { break-inside: avoid; }
}

/* ============================================================================ */
/* Animation */
/* ============================================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
