/* ==========================================================================
   Variance Website Stylesheet
   Daylight-first native desktop software aesthetic aligned with theme.rs.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --surface: #ffffff;
  --panel: #f2f4f7;
  --hover: #e9edf1;
  --border: #e1e5ea;
  --border-strong: #c5ccd5;

  --ink: #1b2128;
  --ink-strong: #0e1318;
  --ink-2: #4e5966;
  --ink-3: #6e7987;

  --accent: #0f6b78;
  --accent-solid: #0f6b78;
  --accent-hover: #0b5661;
  --accent-soft: #e6f3f5;
  --accent-ink: #ffffff;

  --green: #1e7048;
  --green-soft: #ebf6f0;
  --green-border: #c1decb;
  --amber: #945907;
  --amber-soft: #fdf5e7;
  --amber-border: #ebd1a4;

  --code-bg: #f6f8fa;
  --code-border: #dde2e8;
  --code-ink: #1b222a;
  --code-muted: #667382;
  --code-kw: #0b5e6b;
  --code-str: #1f6c45;
  --code-ok: #1b7346;

  --shadow-frame:
    0 1px 2px rgba(14, 19, 24, 0.06),
    0 10px 30px -10px rgba(14, 19, 24, 0.12);
  --shadow-card: 0 1px 2px rgba(14, 19, 24, 0.04);

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

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --container: 1120px;
  --header-h: 56px;
}

[data-theme="dark"] {
  --bg: #13161a;
  --bg-subtle: #181c21;
  --surface: #181c21;
  --panel: #1d2228;
  --hover: #262d36;
  --border: #2a313b;
  --border-strong: #414c59;

  --ink: #e4e8ee;
  --ink-strong: #f5f7fa;
  --ink-2: #9ea9b6;
  --ink-3: #7d8997;

  --accent: #45b5c4;
  --accent-solid: #187583;
  --accent-hover: #1f8a9a;
  --accent-soft: #173239;
  --accent-ink: #ffffff;

  --green: #53b887;
  --green-soft: #152820;
  --green-border: #244a38;
  --amber: #e2a94b;
  --amber-soft: #292114;
  --amber-border: #4e3c1e;

  --code-bg: #101317;
  --code-border: #272e38;
  --code-ink: #dfe5ed;
  --code-muted: #7f8b9a;
  --code-kw: #6bc4d1;
  --code-str: #8fd1a2;
  --code-ok: #5bc691;

  --shadow-frame:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 14px 36px -10px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

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

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

a:hover {
  color: var(--accent-hover);
}

button,
input {
  font: inherit;
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-solid);
  color: var(--accent-ink);
  padding: 8px 14px;
  z-index: 200;
  font-size: 13px;
  font-weight: 500;
}

.skip-link:focus {
  left: 12px;
  top: 10px;
  border-radius: var(--radius-xs);
}

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

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink-strong);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--ink-strong);
}

.brand img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.brand-version {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  margin-left: 2px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.main-nav a {
  text-decoration: none;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: var(--radius-xs);
  transition: background 0.12s ease, color 0.12s ease;
}

.main-nav a:hover {
  color: var(--ink-strong);
  background: var(--hover);
}

.main-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px;
  font-size: 11.5px;
  font-weight: 600;
}

.lang-switch span,
.lang-switch a {
  padding: 3px 7px;
  border-radius: 3px;
  text-decoration: none;
  line-height: 1.2;
}

.lang-switch .lang-active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.lang-switch a {
  color: var(--ink-3);
}

.lang-switch a:hover {
  color: var(--ink-strong);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--ink-strong);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

.nav-toggle {
  display: none;
}

.reading-progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 95;
  pointer-events: none;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-strong);
}

.btn-secondary:hover {
  background: var(--hover);
  border-color: var(--ink-3);
  color: var(--ink-strong);
}

.btn-quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-2);
  padding: 6px 12px;
  font-size: 13px;
}

.btn-quiet:hover {
  background: var(--hover);
  color: var(--ink-strong);
}

/* ==========================================================================
   Typography & Sections
   ========================================================================== */
.display-h1 {
  font-weight: 650;
  font-size: clamp(2rem, 3.8vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--ink-strong);
  margin: 0 0 16px;
  text-wrap: balance;
}

.section-h2 {
  font-weight: 600;
  font-size: clamp(1.45rem, 2.3vw, 1.85rem);
  line-height: 1.2;
  letter-spacing: -0.024em;
  color: var(--ink-strong);
  margin: 0 0 12px;
  text-wrap: balance;
}

.section-lead {
  font-size: 15.5px;
  line-height: 1.66;
  color: var(--ink-2);
  margin: 0;
  max-width: 66ch;
}

.band {
  padding: 72px 0;
  border-bottom: 1px solid var(--border);
}

.band-subtle {
  background: var(--bg-subtle);
}

/* ==========================================================================
   Hero (Centered software showcase + direct 1-click download links)
   ========================================================================== */
.hero {
  padding: 60px 0 68px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.hero-center {
  max-width: 920px;
  margin: 0 auto 38px;
  text-align: center;
}

.hero-icon {
  width: 56px;
  height: 56px;
  border-radius: 13px;
  margin: 0 auto 18px;
  box-shadow: 0 2px 8px rgba(14, 19, 24, 0.12);
}

.hero-center .section-lead {
  margin: 0 auto 24px;
  max-width: 60ch;
}

.hero-primary-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.quick-dl-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-dl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.quick-dl-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-dl-chip svg {
  width: 12px;
  height: 12px;
  opacity: 0.72;
}

.hero-meta-line {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0;
}

/* Natural full-width application screenshot (zero letterbox bars) */
.app-shot {
  margin: 0;
}

.app-shot-frame {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-frame);
  cursor: zoom-in;
}

[data-theme="dark"] .app-shot-frame.shot-theme-aware {
  background: #13161a;
}

.app-shot-frame img {
  width: 100%;
  height: auto;
  display: block;
}

.app-shot-frame .shot-dark,
.app-shot-frame .shot-demo {
  display: none;
}

[data-theme="dark"] .app-shot-frame.shot-theme-aware:not(.is-demo) .shot-light {
  display: none;
}

[data-theme="dark"] .app-shot-frame.shot-theme-aware:not(.is-demo) .shot-dark {
  display: block;
}

.app-shot-frame.is-demo .shot-light,
.app-shot-frame.is-demo .shot-dark {
  display: none;
}

.app-shot-frame.is-demo .shot-demo {
  display: block;
}

.app-shot-bar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ==========================================================================
   Structured Tables & 3-Column Notes
   ========================================================================== */
.cols-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-top: 28px;
}

.cols-3 > * {
  min-width: 0;
}

.col-item h3 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 5px;
}

.col-item p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.58;
}

/* ==========================================================================
   Verification Section (Real ANOVA Screenshot + Clean Light Code Tabs)
   ========================================================================== */
.verify-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.verify-grid > * {
  min-width: 0;
}

.shot-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.shot-card-media {
  background: #ffffff;
  cursor: zoom-in;
}

.shot-card-media img {
  width: 100%;
  height: auto;
}

.shot-card figcaption {
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  line-height: 1.5;
}

/* Clean light-paper code viewer (matches site palette, no dark hacker gimmick) */
.code-box {
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  overflow: hidden;
}

.code-box-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--code-border);
}

.code-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.code-tab {
  position: relative;
  border: none;
  background: transparent;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.code-tab:hover {
  color: var(--ink-strong);
}

.code-tab[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
}

.code-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}

.code-copy-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-xs);
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.code-copy-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink-strong);
  background: var(--hover);
}

.code-panel {
  display: none;
  margin: 0;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--code-ink);
  overflow-x: auto;
  tab-size: 2;
}

.code-panel.is-active {
  display: block;
}

.tok-comment { color: var(--code-muted); }
.tok-kw { color: var(--code-kw); font-weight: 500; }
.tok-str { color: var(--code-str); }
.tok-ok { color: var(--code-ok); font-weight: 600; }

.validation-strip {
  margin-top: 24px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.validation-strip a {
  font-weight: 500;
  white-space: nowrap;
}

/* ==========================================================================
   Figures Gallery
   ========================================================================== */
.plate-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.plate {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.plate:hover {
  border-color: var(--border-strong);
}

.plate-canvas {
  background: #ffffff;
  padding: 10px;
  aspect-ratio: 920 / 650;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  border-bottom: 1px solid var(--border);
}

.plate-canvas img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.plate figcaption {
  padding: 11px 14px 13px;
}

.plate-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.plate-desc {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
}

.pub-meta {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px 32px;
}

.pub-meta > * {
  min-width: 0;
}

.pub-meta-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  font-size: 12.5px;
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--ink);
}

.preset-chip span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  margin-left: 4px;
}

/* ==========================================================================
   Nonlinear Regression + Analysis Families Table
   ========================================================================== */
.nonlin-shots {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.nonlin-shots > * {
  min-width: 0;
}

.nonlin-shots .shot-card-media {
  max-height: 460px;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.data-table,
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th,
.doc-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  white-space: nowrap;
}

.data-table td,
.doc-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: top;
  line-height: 1.55;
}

.data-table tbody tr:last-child td,
.doc-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-subtle);
}

.num-col {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ok-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  padding: 1px 7px;
  border-radius: var(--radius-xs);
}

/* ==========================================================================
   Direct Download Matrix (Home & /download/)
   ========================================================================== */
.dl-grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.dl-grid > * {
  min-width: 0;
}

.dl-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dl-card.is-recommended {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.dl-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dl-card h3,
.dl-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--ink-strong);
}

.dl-badge {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.dl-card.is-recommended .dl-badge {
  display: inline-block;
}

.dl-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

.dl-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.dl-links .btn {
  width: 100%;
  justify-content: center;
}

.dl-note {
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  line-height: 1.5;
}

.dl-note code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--panel);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--ink);
  word-break: break-all;
}

/* ==========================================================================
   Extras (Prism, CLI, Citation) & Subpages
   ========================================================================== */
.dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.dual-grid > * {
  min-width: 0;
}

.panel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.panel-card h2,
.panel-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink-strong);
}

.panel-card p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

.page-hero {
  padding: 48px 0 38px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.page-hero .display-h1 {
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  margin-bottom: 10px;
}

.val-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.seg-tabs {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 2px;
}

.seg-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.seg-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.filter-input {
  min-width: 240px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
}

.val-pane {
  display: none;
}

.val-pane.is-active {
  display: block;
}

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

.stat-row-4 > * {
  min-width: 0;
}

.stat-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 16px 18px;
}

.stat-box-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 4px;
}

.stat-box-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.stat-box-sub {
  font-size: 12px;
  color: var(--ink-3);
}

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

.info-grid-2 > * {
  min-width: 0;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 20px 22px;
}

.info-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 6px;
}

.info-card p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.prism-footnote {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ==========================================================================
   Online Bilingual Guide
   ========================================================================== */
.guide-shell {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 210px;
  gap: 38px;
  align-items: start;
}

.guide-shell.guide-home-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.guide-sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 22px 16px 32px 0;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}

.guide-search-wrap {
  position: relative;
  margin-bottom: 16px;
}

.guide-search-input {
  width: 100%;
  padding: 7px 28px 7px 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}

.guide-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  pointer-events: none;
}

.guide-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px 5px;
  font-size: 14px;
  display: none;
}

.guide-search-clear.is-visible {
  display: block;
}

.toc-part-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 16px 0 6px 8px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-link {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.38;
  color: var(--ink-2);
  border-left: 2px solid transparent;
}

.toc-link:hover {
  background: var(--hover);
  color: var(--ink-strong);
}

.toc-link.is-current {
  background: var(--accent-soft);
  color: var(--ink-strong);
  font-weight: 600;
  border-left-color: var(--accent);
}

.toc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.toc-link.is-current .toc-num {
  color: var(--accent);
}

.guide-main {
  padding: 34px 0 68px;
  min-width: 0;
  max-width: 750px;
}

.guide-mobile-bar {
  display: none;
  margin-bottom: 16px;
}

.chapter-header {
  padding-bottom: 18px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
}

.chapter-crumb {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  margin: 0 0 6px;
}

.chapter-header h1 {
  font-weight: 650;
  font-size: clamp(1.65rem, 2.8vw, 2.15rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
  color: var(--ink-strong);
  margin: 0 0 10px;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.guide-part-block {
  margin-top: 30px;
}

.guide-part-block h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 4px;
}

.guide-part-blurb {
  font-size: 13.5px;
  color: var(--ink-2);
  margin: 0 0 14px;
}

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

.chapter-card {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
}

.chapter-card:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.chapter-card-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding-top: 1px;
}

.chapter-card:hover .chapter-card-num {
  color: var(--accent);
}

.chapter-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.chapter-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-strong);
}

.chapter-card-min {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.chapter-card-desc {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prose {
  font-size: 15px;
  line-height: 1.72;
  color: var(--ink);
}

.prose h2 {
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.018em;
  color: var(--ink-strong);
  margin: 36px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 20px);
}

.prose h2:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.prose h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 24px 0 8px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}

.anchor-link {
  margin-left: 7px;
  color: var(--ink-3);
  text-decoration: none;
  opacity: 0;
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 400;
}

.prose h2:hover .anchor-link,
.prose h3:hover .anchor-link,
.anchor-link:focus {
  opacity: 1;
}

.prose p {
  margin: 0 0 14px;
}

.prose strong {
  color: var(--ink-strong);
  font-weight: 600;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--ink-strong);
}

.prose pre.formula-block {
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-xs);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.6;
  color: var(--ink-strong);
}

.prose pre.formula-block code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}

.prose ul,
.prose ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 5px;
}

.prose .table-wrap {
  margin: 18px 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.prose blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-2);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.callout {
  margin: 18px 0;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 3px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-label {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

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

.callout-tip .callout-label {
  color: var(--green);
}

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

.callout-pitfall .callout-label {
  color: var(--amber);
}

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

.callout-note .callout-label {
  color: var(--accent);
}

.chapter-xref a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13.5px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
}

.chapter-xref a:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.chapter-pager {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pager-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
}

.pager-card:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.pager-card.pager-next {
  text-align: right;
}

.pager-dir {
  font-size: 11.5px;
  color: var(--ink-3);
}

.pager-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}

.guide-outline {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 34px 0 32px;
  font-size: 12.5px;
}

.outline-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: 0 0 10px;
}

.outline-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border);
}

.outline-list a {
  display: block;
  padding: 4px 0;
  color: var(--ink-3);
  text-decoration: none;
  line-height: 1.4;
}

.outline-list a:hover {
  color: var(--ink-strong);
}

.outline-list a.is-active {
  color: var(--accent);
  font-weight: 500;
}

.guide-search-results {
  display: none;
}

.guide-search-results.is-active {
  display: block;
}

.search-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 20px 0 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-strong);
}

.search-group-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 3px;
}

.search-hit {
  display: block;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  margin-bottom: 8px;
}

.search-hit:hover {
  border-color: var(--accent);
}

.search-hit-sec {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 3px;
}

.search-hit-excerpt {
  font-size: 12.8px;
  color: var(--ink-2);
  line-height: 1.5;
}

.search-hit mark {
  background: var(--accent-soft);
  color: var(--ink-strong);
  padding: 0 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(11, 14, 18, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-inner {
  max-width: min(1320px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lightbox-inner img {
  max-width: 100%;
  max-height: calc(92vh - 50px);
  object-fit: contain;
  border-radius: var(--radius-xs);
  background: #ffffff;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #e5e9ee;
  font-size: 13px;
}

.lightbox-close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--bg-subtle);
  padding: 44px 0 32px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 0.7fr));
  gap: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.footer-col h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 10px;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-col a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1120px) {
  .guide-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 28px;
  }

  .guide-outline {
    display: none;
  }
}

@media (max-width: 940px) {
  .cols-3,
  .verify-grid,
  .pub-meta,
  .nonlin-shots,
  .dl-grid,
  .dual-grid,
  .info-grid-2 {
    grid-template-columns: 1fr;
  }

  .plate-grid,
  .stat-row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-shell,
  .guide-shell.guide-home-shell {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .guide-mobile-bar {
    display: flex;
  }

  .guide-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    width: min(310px, 86vw);
    background: var(--bg);
    padding: 20px 16px 32px;
    z-index: 120;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-frame);
  }

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

@media (max-width: 720px) {
  .wrap {
    padding: 0 18px;
  }

  .main-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 18px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    box-shadow: var(--shadow-frame);
  }

  .main-nav.is-open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .brand-version {
    display: none;
  }

  .band {
    padding: 48px 0;
  }

  .hero {
    padding: 36px 0 48px;
  }

  .plate-grid,
  .chapter-card-grid,
  .chapter-pager,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .stat-row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  .site-header,
  .site-footer,
  .guide-sidebar,
  .guide-outline,
  .reading-progress,
  .chapter-pager,
  .lightbox {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .guide-shell {
    display: block;
    max-width: 100%;
  }

  .guide-main {
    max-width: 100%;
    padding: 0;
  }
}
