/* Case study pages: same warm tokens as the home page; a calm reading column, soft panels and tables, and a footer link to the next study. */
:root {
  --bg: #FCFAF8;
  --surface: #F5EFEC;
  --soft: #EDF3F0;
  --ink: #2E2A30;
  --muted: #6F6670;
  --line: #E7DEDA;
  --accent: #3F7466;
  --mark: #D88C9A;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C181D; --surface: #252027; --soft: #1E2624; --ink: #F1EAEC; --muted: #B4A9AF;
    --line: #3A3239; --accent: #8CC3B2; --mark: #E7A4B0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C181D; --surface: #252027; --soft: #1E2624; --ink: #F1EAEC; --muted: #B4A9AF;
  --line: #3A3239; --accent: #8CC3B2; --mark: #E7A4B0; color-scheme: dark;
}
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 1.0625rem; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap {
  max-width: 50rem; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wide { max-width: 64rem; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; line-height: 1.12; font-optical-sizing: auto; }
h1 { font-size: clamp(2.2rem, 5.6vw, 3.6rem); font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); font-weight: 600; letter-spacing: -0.015em; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; max-width: 65ch; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; border-radius: 6px; }
.label { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.ph { background: color-mix(in srgb, var(--mark) 22%, transparent); border-bottom: 1px dashed var(--mark); padding-inline: 2px; }

header.top .wrap { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 20px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; display: flex; gap: 10px; align-items: center; }
.brand svg { color: var(--accent); }
.brand-sub { font-weight: 400; color: var(--muted); }
.back { font-family: var(--display); font-size: 0.95rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); }

.intro .wrap { padding-block: clamp(32px, 6vw, 72px) 28px; display: grid; gap: 18px; }
.intro .lede { font-size: clamp(1.1rem, 2vw, 1.3rem); }
.chip { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; padding: 4px 12px; border-radius: 99px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); white-space: nowrap; justify-self: start; }
.chip.spec { color: var(--ink); background: color-mix(in srgb, var(--mark) 26%, transparent); }

.meta .wrap > dl { background: var(--surface); border-radius: var(--radius); }
.meta dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 18px 28px; padding: 22px 24px; }
.meta dt { font-family: var(--mono); font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.meta dd { margin: 4px 0 0; font-size: 0.95rem; }

main section .wrap { padding-block: 44px 0; display: grid; gap: 16px; }
main section:last-of-type .wrap { padding-bottom: 64px; }
main ul, main ol { margin: 0; padding-left: 1.2em; max-width: 65ch; display: grid; gap: 6px; }

.callout { background: var(--soft); border-radius: 12px; padding: 16px 20px; font-size: 1.12rem; max-width: 60ch; }

.pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 680px) { .pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.panel { background: var(--surface); padding: 24px; border-radius: var(--radius); display: grid; gap: 10px; align-content: start; min-width: 0; }
.panel ul { font-size: 0.95rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.stats div { background: var(--surface); border-radius: var(--radius); padding: 18px; display: grid; gap: 4px; align-content: start; }
.stats strong { font-family: var(--display); font-weight: 600; font-size: 2.3rem; letter-spacing: -0.02em; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.stats span { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); line-height: 1.4; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); }
thead th { font-family: var(--mono); font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
tbody th { font-family: var(--display); font-weight: 600; }
tr.us td, tr.us th { color: var(--accent); }

.steps { list-style: none; padding: 0; counter-reset: s; display: grid; gap: 0; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); gap: 12px; padding-block: 12px; border-top: 1px solid var(--line); }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--mark) 30%, transparent); font-family: var(--mono); font-weight: 600; font-size: 0.82rem; color: var(--ink); margin-top: 1px; }

.sources { font-size: 0.9rem; color: var(--muted); }
.note { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

footer .wrap { padding-block: 28px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }
footer a { font-family: var(--display); font-weight: 600; text-decoration: none; }

.top-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.case-photo { margin: 0; }
.case-photo .wrap { padding-block: 0 8px; }
.case-photo img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; object-position: 50% 35%; border-radius: calc(var(--radius) * 1.5); }
.gallery { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 8px; }
@media (min-width: 640px) { .gallery { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; } }
.gallery figure { margin: 0; display: grid; gap: 8px; min-width: 0; }
.gallery img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); }
.gallery figure + figure img { aspect-ratio: 4 / 3.33; }
.gallery figcaption { font-family: var(--display); font-size: 0.88rem; color: var(--muted); }

/* Diagrams */
.diagram-fig { margin: 8px 0 0; display: grid; gap: 10px; min-width: 0; }
.diagram { overflow-x: auto; background: var(--surface); border-radius: var(--radius); padding: clamp(12px, 2.5vw, 24px); }
.diagram svg { display: block; width: 100%; min-width: 680px; height: auto; }
.diagram-fig figcaption { font-family: var(--display); font-size: 0.88rem; color: var(--muted); }
.d-node { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.d-node.accent { fill: var(--soft); stroke: color-mix(in srgb, var(--accent) 45%, transparent); }
.d-node.rose { fill: color-mix(in srgb, var(--mark) 22%, var(--bg)); stroke: color-mix(in srgb, var(--mark) 65%, transparent); }
.d-node.ghost { fill: none; stroke: var(--muted); stroke-dasharray: 5 5; }
.d-title { fill: var(--ink); font-family: var(--display); font-weight: 600; font-size: 15px; }
.d-sub { fill: var(--muted); font-family: var(--display); font-size: 12.5px; }
.d-kicker { fill: var(--accent); font-family: var(--display); font-weight: 600; font-size: 11px; letter-spacing: 0.08em; }
.d-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.d-line.dash { stroke-dasharray: 4 5; }
.d-head { fill: var(--muted); }

footer .social-foot { border-top: 0; padding-block: 0 28px; align-items: center; font-family: var(--display); font-size: 0.88rem; color: var(--muted); }
.social-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px; }
footer .social-links a { font-weight: 500; color: var(--muted); }
footer .social-links a:hover { color: var(--ink); }
