/* ==========================================================================
   jiazhe868.github.io
   One stylesheet for the whole site. Colors are tokens on :root and are
   redefined for dark mode, so components never hard-code a color.
   ========================================================================== */

:root {
  --bg: #fcfcfb;
  --bg-2: #f5f4f0;
  --surface: #ffffff;
  --ink: #15171c;
  --ink-2: #3c424d;
  --muted: #6a707c;
  --line: #e8e6e1;
  --line-2: #d8d5ce;
  --accent: #c2410c;
  --accent-ink: #9a3412;
  --accent-soft: #fdf1ea;
  --code-bg: #f3f2ee;
  --paper: #ffffff;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.04), 0 8px 24px rgba(20, 22, 28, 0.06);
  --shadow-lg: 0 2px 4px rgba(20, 22, 28, 0.05), 0 18px 48px rgba(20, 22, 28, 0.1);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --wrap: 1160px;
  --prose: 700px;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 24px;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12;
    --bg-2: #12151a;
    --surface: #161a20;
    --ink: #eceef2;
    --ink-2: #c4c9d2;
    --muted: #8f96a3;
    --line: #242930;
    --line-2: #323843;
    --accent: #ff8a55;
    --accent-ink: #ffb089;
    --accent-soft: #2a1911;
    --code-bg: #1b1f26;
    --paper: #f7f7f5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 48px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d0f12;
  --bg-2: #12151a;
  --surface: #161a20;
  --ink: #eceef2;
  --ink-2: #c4c9d2;
  --muted: #8f96a3;
  --line: #242930;
  --line-2: #323843;
  --accent: #ff8a55;
  --accent-ink: #ffb089;
  --accent-soft: #2a1911;
  --code-bg: #1b1f26;
  --paper: #f7f7f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 48px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--ink);
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

p { margin: 0 0 1em; }

::selection { background: var(--accent); color: #fff; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--bg); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
}

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.site-header .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; letter-spacing: -0.01em; font-size: 16.5px; }
.brand:hover { color: var(--ink); }
.brand svg { width: 24px; height: 24px; transition: transform 0.6s cubic-bezier(.2,.7,.2,1); }
.brand:hover svg { transform: rotate(90deg); }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  padding: 7px 11px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--bg-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--bg-2); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px var(--gutter) 20px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  }
  .nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav a { padding: 12px 10px; font-size: 16px; }
}

/* ---------------------------------------------------------------- buttons, chips */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font-size: 14.5px; font-weight: 560; text-decoration: none; line-height: 1.2;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { color: var(--bg); transform: translateY(-1px); }
.btn .icon { width: 16px; height: 16px; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { color: var(--ink); border-color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.pill-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pill-links a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500; text-decoration: none;
}
.pill-links a:hover { color: var(--ink); border-color: var(--line-2); }
.pill-links .icon { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--ink-2); font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.arrow-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink); font-weight: 560; font-size: 15px; text-decoration: none;
}
.arrow-link .icon { width: 16px; height: 16px; transition: transform 0.15s ease; }
.arrow-link:hover .icon { transform: translateX(3px); }

/* ---------------------------------------------------------------- hero */

.hero { padding: 72px 0 24px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(2.7rem, 6vw, 4.2rem); letter-spacing: -0.035em; margin: 14px 0 18px; }
.hero .lead { font-size: clamp(1.08rem, 1.6vw, 1.24rem); line-height: 1.6; color: var(--ink-2); max-width: 680px; margin-bottom: 26px; }
.hero .lead strong { color: var(--ink); font-weight: 600; }
.hero .btn-row { margin-bottom: 22px; }

.portrait { position: relative; margin: 0; }
.portrait img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%;
  border-radius: 18px; background: var(--bg-2);
  box-shadow: var(--shadow-lg);
}
.portrait figcaption { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.45; }

@media (max-width: 860px) {
  .hero { padding-top: 40px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .portrait { max-width: 220px; order: -1; }
  .portrait img { aspect-ratio: 1; border-radius: 50%; }
  .portrait figcaption { display: none; }
}

/* Seismogram trace drawn under the hero */
.trace { margin: 36px 0 0; }
.trace svg { display: block; width: 100%; height: 92px; overflow: visible; }
.trace path { fill: none; stroke: var(--accent); stroke-width: 0.9; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.trace .baseline { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 4; }
.trace figcaption { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.01em; }
/* Reveal the trace from left to right at a steady pace, like a recording in progress. */
.js .trace svg.draw { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); animation: record 3.4s cubic-bezier(.3,.1,.3,1) 0.2s forwards; }
@keyframes record { to { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  .js .trace svg.draw { animation: none; -webkit-clip-path: none; clip-path: none; }
  html { scroll-behavior: auto; }
}
@media (max-width: 640px) {
  .trace svg { height: 64px; }
  .trace path { stroke-width: 0.65; }
  .trace figcaption { flex-direction: column; gap: 2px; }
}

/* ---------------------------------------------------------------- sections */

.section { padding: 88px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section--alt { background: var(--bg-2); }
.section-head { max-width: 760px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 12px 0 14px; }
.section-head p { color: var(--ink-2); font-size: 1.06rem; margin: 0; }
.section-foot { margin-top: 32px; }
@media (max-width: 640px) { .section { padding: 60px 0; } }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.stat { padding: 20px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-size: 1.75rem; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 6px; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* LLM lifecycle: three stage cards with connectors */
.stages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; counter-reset: stage; }
.stage {
  position: relative; display: flex; flex-direction: column;
  padding: 24px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.stage:not(:last-child)::after {
  content: ""; position: absolute; top: 50%; right: -17px; width: 12px; height: 12px;
  border-top: 2px solid var(--line-2); border-right: 2px solid var(--line-2);
  transform: translateY(-50%) rotate(45deg);
}
.stage .label { margin-bottom: 12px; }
.stage h3 { font-size: 1.28rem; margin-bottom: 4px; }
.stage .repo { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.stage p { color: var(--ink-2); font-size: 15px; }
.stage .thumb { margin: 4px -8px 16px; border-radius: var(--radius-sm); overflow: hidden; background: var(--paper); border: 1px solid var(--line); }
.stage .thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; padding: 8px; }
.kv { margin: auto 0 0; padding: 14px 0 0; border-top: 1px dashed var(--line-2); display: grid; gap: 7px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.stage .links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; font-size: 14px; }
.stage .links a { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.stage .links a:hover { color: var(--accent); }
.stage .links .icon { width: 15px; height: 15px; }
@media (max-width: 960px) {
  .stages { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .stage:not(:last-child)::after { top: auto; bottom: -21px; right: 50%; transform: translateX(50%) rotate(135deg); }
}

/* Feature: figure + text */
.feature { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.feature--flip .feature-media { order: 2; }
.feature-media { margin: 0; }
.feature-media .frame { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 14px; box-shadow: var(--shadow); }
.feature-media figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); }
.feature-body h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); margin: 12px 0 14px; }
.feature-body p { color: var(--ink-2); }
.feature-body ul { margin: 0 0 22px; padding: 0; list-style: none; display: grid; gap: 10px; }
.feature-body li { position: relative; padding-left: 22px; color: var(--ink-2); font-size: 15.5px; }
.feature-body li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }
.feature-body li b { color: var(--ink); font-weight: 600; }
@media (max-width: 900px) {
  .feature { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .feature--flip .feature-media { order: 0; }
}

/* Image strip linking to the earthquake gallery */
.quake-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.quake-card {
  display: flex; flex-direction: column; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow: hidden; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.quake-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-2); color: inherit; }
.quake-card .img { background: var(--paper); border-bottom: 1px solid var(--line); }
.quake-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; padding: 8px; }
.quake-card .meta { padding: 14px 16px 16px; }
.quake-card .when { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.quake-card h3 { font-size: 15.5px; line-height: 1.3; margin-top: 6px; letter-spacing: -0.01em; }
@media (max-width: 960px) { .quake-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .quake-grid { grid-template-columns: minmax(0, 1fr); } }

/* News */
.news { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.news li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.news time { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); padding-top: 2px; }
.news p { margin: 0; color: var(--ink-2); }
.news p strong { color: var(--ink); font-weight: 600; }
@media (max-width: 560px) { .news li { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.news-more { margin-top: 14px; }
.news-more summary { cursor: pointer; color: var(--ink-2); font-size: 14.5px; font-weight: 550; padding: 6px 0; list-style: none; }
.news-more summary::-webkit-details-marker { display: none; }
.news-more summary::before { content: "+"; display: inline-block; width: 18px; font-family: var(--font-mono); color: var(--accent); }
.news-more[open] summary::before { content: "−"; }
.news-more .news { margin-top: 8px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; }
@media (max-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr); gap: 48px; } }

/* ---------------------------------------------------------------- page layout */

.page-hero { padding: 64px 0 36px; border-bottom: 1px solid var(--line); }
.page-hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.3rem); letter-spacing: -0.03em; margin: 14px 0 16px; max-width: 900px; }
.page-hero .lead { font-size: clamp(1.05rem, 1.5vw, 1.2rem); color: var(--ink-2); max-width: 760px; margin-bottom: 22px; }
.page-hero .pill-links { margin-top: 4px; }

.page-body { padding: 48px 0 96px; }
.with-toc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 44px; align-items: start; }
.toc { position: sticky; top: calc(var(--header-h) + 28px); font-size: 13.5px; max-height: calc(100vh - var(--header-h) - 56px); overflow: auto; }
.toc .label { color: var(--muted); margin-bottom: 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc ol ol { border-left: 0; }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc ol ol a { padding-left: 26px; font-size: 13px; }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); border-left-color: var(--accent); }
@media (max-width: 1080px) {
  .with-toc { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

/* ---------------------------------------------------------------- prose */

.prose { font-size: 16.5px; line-height: 1.7; color: var(--ink-2); }
.prose > * { max-width: var(--prose); }
.prose > .fig--wide, .prose > .fig-row-wrap { max-width: 1000px; width: 100%; }
.prose p, .prose ul, .prose ol, .prose table, .prose blockquote, .prose pre { margin: 0 0 1.15em; }
.prose h2 { font-size: clamp(1.5rem, 2.6vw, 1.95rem); margin: 2.4em 0 0.7em; padding-top: 0.2em; }
.prose h3 { font-size: 1.2rem; margin: 2em 0 0.6em; letter-spacing: -0.015em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose h2 + h3 { margin-top: 1em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.prose a:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ol.lessons, .prose ol.flow { padding-left: 0; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 3em 0; }
.prose code { font-family: var(--font-mono); font-size: 0.86em; padding: 0.12em 0.36em; border-radius: 5px; background: var(--code-bg); color: var(--ink); }
.prose pre { padding: 16px 18px; border-radius: var(--radius-sm); background: var(--code-bg); overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.prose pre code { padding: 0; background: none; font-size: inherit; }
.prose blockquote { margin-left: 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.prose .lede { font-size: 1.12em; color: var(--ink); }

.table-wrap { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.prose table, .table-wrap table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.45; margin: 0; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink); font-weight: 600; font-size: 13px; background: var(--bg-2); }
.prose tr:last-child td { border-bottom: 0; }
.prose td.num, .prose th.num { text-align: right; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Figures */
.fig { margin: 2em 0 2.2em; }
.fig .frame { display: block; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 12px; cursor: zoom-in; }
.fig img { width: 100%; height: auto; margin: 0 auto; }
.fig figcaption { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.fig figcaption b { color: var(--ink-2); font-weight: 600; }
.fig-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 16px; align-items: start; }
.fig-row .fig { margin: 0; }
.fig-row-wrap { margin: 2em 0 2.2em; }
@media (max-width: 640px) { .fig-row { grid-template-columns: minmax(0, 1fr); } }

/* Lesson and note boxes */
.note {
  margin: 1.6em 0; padding: 18px 20px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: 15.5px; color: var(--ink-2);
}
.note > :last-child { margin-bottom: 0; }
.note .label { display: block; margin-bottom: 6px; }

.lessons { list-style: none; margin: 1.4em 0 2em; padding: 0; display: grid; gap: 8px; counter-reset: lesson; }
.lessons li {
  position: relative; margin: 0; padding: 13px 18px 13px 54px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 15px; line-height: 1.55; counter-increment: lesson;
}
.lessons li::before {
  content: counter(lesson, decimal-leading-zero);
  position: absolute; left: 18px; top: 14px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--accent);
}
.lessons li strong:first-child { display: block; color: var(--ink); margin-bottom: 2px; }

.metric-row { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px; margin: 1.6em 0 2em; }
.metric { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.metric b { display: block; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.03em; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric span { display: block; margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--muted); }
@media (max-width: 640px) { .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Pipeline diagram (pure HTML) */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 1.6em 0 2em; padding: 0; list-style: none; counter-reset: flow; }
.flow li { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); position: relative; }
@media (max-width: 640px) { .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flow li b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.flow li span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 3px; }
.flow li small { display: block; margin-bottom: 4px; font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.04em; }

/* Progress bars for the post-training ladder */
.ladder { margin: 1.6em 0 2em; padding: 18px 20px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ladder-row { display: grid; grid-template-columns: 210px minmax(0, 1fr) 64px; align-items: center; gap: 14px; padding: 8px 0; }
.ladder-row .name { font-size: 14px; color: var(--ink); line-height: 1.3; }
.ladder-row .name small { display: block; color: var(--muted); font-size: 12.5px; }
.ladder-row .bar { height: 10px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.ladder-row .bar i { display: block; height: 100%; border-radius: 999px; background: color-mix(in srgb, var(--accent) 55%, var(--line-2)); }
.ladder-row.is-best .bar i { background: var(--accent); }
.ladder-row.is-best .name, .ladder-row.is-best .val { font-weight: 600; }
.ladder-row.is-ref .bar i { background: repeating-linear-gradient(90deg, var(--line-2) 0 6px, transparent 6px 10px); }
.ladder-row.is-ref .name, .ladder-row.is-ref .val { color: var(--muted); }
.ladder-row .val { font-family: var(--font-mono); font-size: 13px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.ladder .foot { margin: 6px 0 8px; font-size: 12.5px; color: var(--muted); }
@media (max-width: 640px) {
  .ladder-row { grid-template-columns: minmax(0, 1fr) 56px; }
  .ladder-row .bar { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------------------------------------------------------------- earthquake gallery */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 36px; }
.filters button {
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: 500 13.5px/1.2 var(--font-sans);
}
.filters button:hover { border-color: var(--line-2); color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.studies { display: grid; gap: 28px; }
.study {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px;
  padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.study[hidden] { display: none; }
.study-media { margin: 0; display: grid; gap: 12px; align-content: start; }
.study-media .frame { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); padding: 10px; cursor: zoom-in; }
.study-media img { width: 100%; height: auto; }
.study-media figcaption { font-size: 13px; color: var(--muted); line-height: 1.45; }
.study-media .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.study-media .thumbs a { display: block; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); padding: 4px; cursor: zoom-in; }
.study-media .thumbs img { aspect-ratio: 4 / 3; object-fit: contain; }
.study-body .when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.study-body .when .chip { white-space: normal; line-height: 1.5; }
.study-body h2 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); margin-bottom: 6px; }
.study-body .ref { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; line-height: 1.45; }
.study-body .ref i { color: var(--ink-2); }
.study-body .summary { color: var(--ink-2); font-size: 15.5px; line-height: 1.65; }
.study-body .summary p { margin-bottom: 0.8em; }
.study-body .finding { margin: 16px 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 15px; line-height: 1.55; }
.study-body .finding b { display: block; margin-bottom: 2px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); }
.study-body .links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; font-size: 14px; }
.study-body .links a { color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.study-body .links a:hover { color: var(--accent); }
.study-body .links .icon { width: 15px; height: 15px; }
@media (max-width: 900px) {
  .study { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 20px; }
}

.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mini { display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mini[hidden] { display: none; }
.mini-img { display: block; margin: -8px -8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); cursor: zoom-in; }
.mini-img img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; padding: 8px; }
.mini .when { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.mini h3 { font-size: 16px; line-height: 1.35; letter-spacing: -0.01em; margin-bottom: 8px; }
.mini p { font-size: 14.5px; color: var(--ink-2); line-height: 1.6; }
.mini .ref { font-size: 12.5px; color: var(--muted); margin-top: auto; padding-top: 8px; }
.mini .ref a { color: inherit; }
.mini .ref a:hover { color: var(--accent); }
@media (max-width: 960px) { .mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .mini-grid { grid-template-columns: minmax(0, 1fr); } }

.theme-intro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 48px; }
.theme-intro div { padding: 18px 20px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.theme-intro h3 { font-size: 15.5px; margin-bottom: 6px; }
.theme-intro p { margin: 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
@media (max-width: 860px) { .theme-intro { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- publications */

.pub-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.pub-search { flex: 1 1 260px; max-width: 360px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 15px var(--font-sans); }
.pub-search::placeholder { color: var(--muted); }
.pub-year { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 24px; padding: 22px 0; border-top: 1px solid var(--line); }
.pub-year[hidden] { display: none; }
.pub-year > h2 { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; padding-top: 3px; }
.pub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.pub[hidden] { display: none; }
.pub-title { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.4; letter-spacing: -0.008em; }
.pub-title a { text-decoration: none; }
.pub-title a:hover { text-decoration: underline; }
.pub-authors { font-size: 14.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.5; }
.pub-authors b { color: var(--ink); font-weight: 600; }
.pub-venue { font-size: 14px; color: var(--muted); margin-top: 2px; }
.pub-venue i { color: var(--ink-2); }
.pub-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 7px; font-size: 13.5px; }
.pub-meta a { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.pub-meta a:hover { color: var(--accent); }
.pub-meta .icon { width: 14px; height: 14px; }
@media (max-width: 640px) { .pub-year { grid-template-columns: minmax(0, 1fr); gap: 10px; } }

/* ---------------------------------------------------------------- misc pages */

.cards-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 1.2em 0 2em; }
.cards-2 > div { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cards-2 h3 { margin: 0 0 8px; font-size: 15.5px; }
.cards-2 ul { margin: 0; padding-left: 1.1em; font-size: 15px; }
@media (max-width: 640px) { .cards-2 { grid-template-columns: minmax(0, 1fr); } }

.pdf-frame { width: 100%; height: min(80vh, 1100px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

/* ---------------------------------------------------------------- footer */

.site-footer { border-top: 1px solid var(--line); padding: 40px 0 48px; font-size: 14px; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px 32px; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer .foot-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-footer p { margin: 0; }

/* ---------------------------------------------------------------- lightbox */

.lightbox {
  width: min(96vw, 1500px); max-width: none; max-height: 94vh; padding: 0;
  border: 0; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 10, 14, 0.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.lightbox img { width: 100%; height: auto; max-height: calc(94vh - 70px); object-fit: contain; padding: 14px; }
.lightbox p { margin: 0; padding: 10px 18px 16px; font-size: 13.5px; color: #4a505b; line-height: 1.5; background: var(--paper); }
.lightbox .close { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.92); color: #222; border-color: #ddd; }

/* ---------------------------------------------------------------- 404 */

.notfound { min-height: 60vh; display: grid; place-content: center; text-align: center; gap: 14px; padding: 80px 0; }
.notfound h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); }

@media print {
  .site-header, .site-footer, .toc, .filters { display: none !important; }
  body { background: #fff; color: #000; }
}
