/* =============================================================
   Proof-Refactor — editorial paper aesthetic
   Display: Fraunces (variable serif)
   Body:    Geist
   Mono:    Geist Mono
   ============================================================= */

:root {
  --paper:        #f4f0e6;
  --paper-tint:   #ebe6d6;
  --paper-edge:   #ddd5c0;
  --ink:          #16140f;
  --ink-soft:     #36322a;
  --ink-mute:     #7c7567;
  --rule:         #cec6b1;
  --rule-soft:    #ddd5c0;
  --accent:       #3f5d3a;
  --accent-deep:  #2a4128;
  --accent-tint:  #dfe4d0;
  --neg:          #8a3a32;
  --pos:          #3f5d3a;
  --dark:         #14110c;
  --dark-soft:    #1d1a13;
  --light:        #faf7ee;

  --serif: "Fraunces", "Iowan Old Style", "Apple Garamond", Georgia, serif;
  --sans:  "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:  "JetBrains Mono", "Cascadia Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --max:   1200px;
  --gut:   clamp(20px, 4vw, 48px);

  --ease:  cubic-bezier(0.2, 0.7, 0.2, 1);

  --t-fast: 180ms var(--ease);
  --t-med:  360ms var(--ease);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

body.pr-page {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; }

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

.muted     { color: var(--ink-mute); }
.is-hidden { display: none !important; }

/* ----------------------------- layout primitives */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gut);
}

.section {
  padding: clamp(72px, 11vw, 144px) 0;
  position: relative;
}
.section-tight { padding: clamp(56px, 8vw, 108px) 0; }
.section-band {
  background: var(--paper-tint);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}

/* ----------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px var(--gut);
  background: color-mix(in srgb, var(--paper) 60%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: padding var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.topbar.is-shrunk {
  padding-top: 10px;
  padding-bottom: 10px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  border-bottom-color: color-mix(in srgb, var(--rule) 70%, transparent);
}

.topbar-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.topbar-mark svg { color: var(--accent); }

.topbar-nav {
  display: flex;
  gap: 22px;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
}
.topbar-nav a {
  text-decoration: none;
  padding: 4px 0;
  position: relative;
  transition: color var(--t-fast);
}
.topbar-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-med);
}
.topbar-nav a:hover { color: var(--ink); }
.topbar-nav a:hover::after { transform: scaleX(1); }

.topbar-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar-cta:hover { background: var(--ink); color: var(--light); }

/* ----------------------------- hero */
.hero {
  position: relative;
  padding: clamp(80px, 14vh, 160px) 0 clamp(40px, 6vh, 96px);
  overflow: hidden;
}

.hero-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(ellipse 70% 50% at 6% 14%, rgba(63, 93, 58, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 60% at 94% 10%, rgba(22, 20, 15, 0.06), transparent 60%),
    radial-gradient(ellipse 100% 80% at 50% 110%, rgba(22, 20, 15, 0.05), transparent 60%);
  z-index: 0;
}

.hero-wrap { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 32px;
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.05s forwards;
}
.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.display {
  font-family: var(--serif);
  font-weight: 400;
  font-style: normal;
  font-size: clamp(72px, 14vw, 188px);
  font-variation-settings: "opsz" 144;
  line-height: 0.86;
  letter-spacing: -0.045em;
  margin: 0 0 28px;
  color: var(--ink);
  opacity: 0;
  animation: rise 1.1s var(--ease) 0.12s forwards;
}
.display em {
  font-style: italic;
  font-weight: 350;
  color: var(--accent);
}
.display .amp {
  font-weight: 200;
  color: var(--ink-mute);
  padding: 0 0.04em;
}

.lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-variation-settings: "opsz" 30;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.35;
  letter-spacing: -0.012em;
  max-width: 720px;
  margin: 0 0 44px;
  color: var(--ink-soft);
  opacity: 0;
  animation: rise 1.1s var(--ease) 0.24s forwards;
}
.lede em { color: var(--accent-deep); font-weight: 400; }

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--ink);
  opacity: 0;
  animation: rise 1.0s var(--ease) 0.36s forwards;
}
.byline .author sup { color: var(--accent); font-weight: 600; }

.affil {
  font-size: 13px;
  color: var(--ink-mute);
  margin: 0 0 38px;
  opacity: 0;
  animation: rise 1.0s var(--ease) 0.42s forwards;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 64px;
  opacity: 0;
  animation: rise 1.0s var(--ease) 0.5s forwards;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--ink); color: var(--light); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost    { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink); background: var(--paper-tint); }
.btn-light    { background: var(--light); color: var(--dark); }
.btn-light:hover { background: var(--accent-tint); }

.hero-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  margin: 0;
  opacity: 0;
  animation: rise 1.0s var(--ease) 0.62s forwards;
}
.hero-meta > div { display: flex; flex-direction: column; gap: 6px; }
.hero-meta dt {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.hero-meta dd {
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: "opsz" 72;
  font-size: clamp(30px, 3.5vw, 42px);
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------- section heads */
.section-head {
  margin: 0 0 56px;
  max-width: 880px;
}
.section-head-case { max-width: 980px; }

.section-no {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 14px;
  text-transform: none;
}

.display-2 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 96;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.97;
  letter-spacing: -0.038em;
  margin: 0 0 22px;
  color: var(--ink);
}
.display-2 em { font-style: italic; font-weight: 350; color: var(--accent); }

.section-lede {
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: color-mix(in srgb, var(--paper-edge) 60%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-deep);
  font-weight: 500;
}
pre code,
pre > code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-weight: inherit;
  font-size: inherit;
}

/* ----------------------------- pipeline figure */
.figure-frame {
  margin: 0;
  background: var(--light);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: clamp(20px, 3vw, 40px);
  position: relative;
}
.figure-frame img {
  width: 100%;
  height: auto;
}
.figure-frame figcaption {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
  font-size: 13.5px;
  color: var(--ink-mute);
  max-width: 720px;
}
.figure-frame figcaption span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-right: 12px;
  font-weight: 600;
}

/* ----------------------------- big idea */
.big-idea { max-width: 1080px; }
.big-idea .display-2 { margin-bottom: 40px; }
.big-idea-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px 64px;
  margin-top: 8px;
}
.big-idea-body p {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.big-idea-body p em { font-style: italic; color: var(--ink); font-weight: 500; }
.big-idea-body p:first-child {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-variation-settings: "opsz" 36;
  font-size: 22px;
  line-height: 1.45;
  color: var(--ink);
  grid-column: 1 / -1;
  border-left: 2px solid var(--accent);
  padding-left: 24px;
}

/* ----------------------------- four phases */
.phases {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border-top: 1px solid var(--rule);
}
.phase {
  position: relative;
  padding: 44px 38px 44px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 32px;
  row-gap: 12px;
  align-items: start;
  transition: background var(--t-med);
}
.phase:nth-child(2n) {
  padding-left: 38px;
  border-left: 1px solid var(--rule);
}
.phase:hover { background: color-mix(in srgb, var(--paper-tint) 60%, transparent); }

.phase-num {
  font-family: var(--serif);
  font-weight: 200;
  font-variation-settings: "opsz" 144;
  font-size: clamp(72px, 8vw, 112px);
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: var(--accent);
  grid-row: 1 / span 2;
  display: block;
  min-width: 1.6ch;
}

.phase h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-variation-settings: "opsz" 48;
  font-size: clamp(26px, 3vw, 36px);
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 12px 0 0;
  color: var(--ink);
}
.phase p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 46ch;
}

/* ----------------------------- extract tactic split */
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 56px;
  align-items: end;
  margin-bottom: 56px;
}
.split-right p { margin: 0 0 18px; }
.split-right .section-lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-variation-settings: "opsz" 36;
  font-size: 22px;
  line-height: 1.4;
  color: var(--ink);
}

/* legacy .extract-grid / .extract-card removed — extract section now uses .case-grid / .case-pane */

/* ----------------------------- case study */
.section-head-case .display-2 .num {
  font-family: var(--serif);
  font-weight: 250;
  font-variation-settings: "opsz" 144;
  font-style: normal;
  color: var(--ink-mute);
  letter-spacing: -0.06em;
}
.section-head-case .display-2 .num.accent { color: var(--accent); }

.case-stat {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 26px 0;
  margin: 0 0 36px;
  gap: 18px;
}
.case-stat > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 22px;
  border-left: 1px solid var(--rule);
}
.case-stat > div:first-child { border-left: 0; padding-left: 0; }
.case-stat-num {
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: "opsz" 72;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.case-stat > div:nth-child(2) .case-stat-num { color: var(--accent); }
.case-stat > div > span:last-child {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}

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

.case-pane {
  background: var(--light);
  border: 1px solid var(--rule);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.case-pane-refactor { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent) inset; }

.case-pane-head,
.code-pane-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--paper-tint);
}
.case-pane-refactor .case-pane-head,
.code-pane.refactor-pane .code-pane-header { background: var(--accent-tint); }
.case-pane-head h4,
.code-pane-header h4 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.018em;
  margin: 0;
  color: var(--ink);
}
.case-pane-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Lean code blocks (.case-code, .lean-code) and syntax highlighting
   live in static/css/lean.css */

.case-foot {
  margin: 28px 0 0;
  font-size: 14px;
}
.link-underline {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding-bottom: 1px;
  transition: border-color var(--t-fast);
}
.link-underline:hover { border-bottom-color: var(--accent); }

/* ----------------------------- results table */
.results-table-wrap {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  overflow: auto;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  min-width: 720px;
}
.results-table thead th {
  padding: 16px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-mute);
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
.results-table thead th.num-col { text-align: right; }

.results-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: baseline;
}
.results-table td.num-col {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14.5px;
}
.results-table td strong { font-weight: 700; }

.results-table .row-divider td {
  border-bottom: 1px solid var(--ink-soft);
  padding: 22px 12px 10px;
}
.row-label {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.018em;
  color: var(--ink);
}

.row-highlight td { background: color-mix(in srgb, var(--accent-tint) 50%, transparent); }
.row-highlight td:first-child { background: color-mix(in srgb, var(--accent-tint) 50%, transparent); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted-row { color: var(--ink-mute); }

.results-note { margin: 24px 0 0; font-size: 14.5px; max-width: 760px; }

/* ----------------------------- ablation */
.ablation-grid {
  list-style: none;
  margin: 0 0 32px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
}
.ablation-grid li {
  background: var(--light);
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.abl-num {
  font-family: var(--serif);
  font-weight: 250;
  font-variation-settings: "opsz" 144;
  font-size: clamp(48px, 6vw, 72px);
  line-height: 0.9;
  letter-spacing: -0.05em;
}
.abl-num.pos { color: var(--pos); }
.abl-num.neg { color: var(--neg); }
.abl-label {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  font-weight: 600;
  text-transform: uppercase;
}
.ablation-note { font-size: 16px; max-width: 760px; }
.ablation-note em { font-style: italic; color: var(--ink); font-weight: 500; }

/* ----------------------------- dark CTA */
.cta-band {
  background: var(--dark);
  color: var(--light);
  padding: clamp(80px, 12vw, 160px) 0;
  position: relative;
  overflow: hidden;
}
.cta-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 60% at 82% 0%, rgba(63, 93, 58, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 70% at 4% 100%, rgba(244, 240, 230, 0.06), transparent 60%);
  pointer-events: none;
}
.cta-band .wrap { position: relative; }
.cta-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--light) 60%, transparent);
  margin: 0 0 16px;
}
.cta-title {
  font-family: var(--serif);
  font-weight: 350;
  font-variation-settings: "opsz" 144;
  font-size: clamp(48px, 7vw, 96px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0 0 22px;
  color: var(--light);
}
.cta-lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 22px;
  line-height: 1.4;
  color: color-mix(in srgb, var(--light) 80%, transparent);
  margin: 0 0 40px;
  max-width: 580px;
}

/* ----------------------------- bibtex */
.bib-card {
  position: relative;
  background: var(--dark);
  color: var(--light);
  border-radius: 18px;
  padding: 28px 32px;
  overflow: hidden;
}
.bib-card pre {
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: color-mix(in srgb, var(--light) 92%, transparent);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.bib-card code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-weight: 400;
}

.copy-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: color-mix(in srgb, var(--light) 8%, transparent);
  color: color-mix(in srgb, var(--light) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--light) 18%, transparent);
  border-radius: 999px;
  padding: 7px 13px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.copy-btn:hover { background: var(--accent); color: var(--light); border-color: var(--accent); }
.copy-btn.copied { background: var(--pos); border-color: var(--pos); color: var(--light); }

/* ----------------------------- footer */
.site-foot {
  border-top: 1px solid var(--rule-soft);
  padding: 36px 0;
  background: var(--paper);
}
.site-foot-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 13.5px;
  color: var(--ink-mute);
}
.site-foot-row p { margin: 0; }

/* ----------------------------- scroll-to-top */
.to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--light);
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-fast), transform var(--t-fast), background var(--t-fast);
  pointer-events: none;
  z-index: 30;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.to-top:hover { background: var(--accent-deep); }

/* ----------------------------- responsive */
@media (max-width: 1024px) {
  .big-idea-body { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; gap: 28px; }
  .extract-grid { grid-template-columns: 1fr; }
  .case-grid { grid-template-columns: 1fr; }
  .case-code { height: 460px; }
  .hero-meta { grid-template-columns: repeat(2, 1fr); }
  .ablation-grid { grid-template-columns: repeat(2, 1fr); }
  .phases { grid-template-columns: 1fr; }
  .phase:nth-child(2n) { padding-left: 0; border-left: 0; }
  .case-stat { grid-template-columns: 1fr; gap: 18px; }
  .case-stat > div { padding-left: 0; border-left: 0; padding-bottom: 14px; border-bottom: 1px solid var(--rule-soft); }
  .case-stat > div:last-child { border-bottom: 0; padding-bottom: 0; }
}

@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr; padding: 12px 18px; }
  .topbar-nav { display: none; }
  .hero { padding-top: 64px; }
  .display { font-size: clamp(56px, 16vw, 96px); }
  .hero-meta { grid-template-columns: 1fr 1fr; gap: 18px; }
  .ablation-grid { grid-template-columns: 1fr; }
  .ablation-grid li { padding: 28px 22px; }
  .abl-num { font-size: 48px; }
  .results-table { font-size: 14px; }
  .copy-btn .copy-text { display: none; }
}

/* =============================================================
   Showcase page (showcase.html)
   ============================================================= */

body.showcase-shell {
  background: var(--paper);
}

.showcase-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 8px clamp(14px, 2vw, 22px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 44px;
}

.showcase-bar .topbar-mark {
  font-size: 13px;
  font-weight: 600;
  gap: 7px;
}
.showcase-bar .topbar-mark svg { color: var(--accent); }

.showcase-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}
.showcase-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}
#problem-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.showcase-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.showcase-nav button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.showcase-nav button:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--light);
}
.showcase-nav button:disabled {
  color: var(--ink-mute);
  border-color: var(--rule-soft);
  background: transparent;
  cursor: default;
}
#page-label {
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
  font-size: 11px;
}

.showcase-main {
  padding: clamp(10px, 1.5vw, 18px) clamp(12px, 2vw, 24px) 18px;
  max-width: 1880px;
  margin: 0 auto;
}
.showcase-foot {
  text-align: center;
  margin: 36px auto 8px;
  font-size: 13px;
  max-width: 640px;
}

#showcase-status {
  text-align: center;
  padding: 40px 18px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-mute);
  font-weight: 500;
  letter-spacing: 0.01em;
}
#showcase-status.is-danger {
  color: var(--neg);
  max-width: 720px;
  margin: 0 auto;
}

.showcase-pages {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0 0 10px;
}
.page-dot {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-mute);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.page-dot:hover { color: var(--ink); border-color: var(--ink); }
.page-dot[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--light);
}

.showcase-example,
.minimal-example {
  margin: 0;
}

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

.code-pane {
  background: var(--light);
  border: 1px solid var(--rule);
  border-radius: 14px;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.code-pane.refactor-pane {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent) inset;
}

.lean-code { height: calc(100vh - 134px); }
body.wrap-lines .lean-code pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
}

@media screen and (max-width: 900px) {
  .code-grid { grid-template-columns: 1fr; }
  .showcase-bar { grid-template-columns: auto 1fr; gap: 12px; }
  .showcase-title { align-items: flex-start; }
  .showcase-nav { display: none; }
  .lean-code { height: 60vh; }
}
