/* Built Better Co. Operational Opportunity Calculator
   Layout: one calm reading column for questions; results widen to a two-column
   grid on larger screens. Everything is driven by the tokens below.

   BRANDING: the first :root block matches builtbetterco.com (warm paper
   background, brick red, charcoal, Source Sans 3). Change values here to
   restyle the whole calculator. Dark-mode values are only used when the page
   is opened with ?theme=auto or ?theme=dark. */

:root {
  /* Color */
  --bg: #f4f2eb;            /* page: warm paper */
  --surface: #fbfaf6;       /* cards and inputs */
  --surface-2: #eae8df;     /* quiet fills (sage-grey panel on the website) */
  --ink: #2a2a26;           /* charcoal: headings and primary text */
  --ink-2: #4f4e48;         /* secondary text */
  --ink-3: #605f58;         /* muted text, still AA on every surface */
  --line: #dcd9ce;
  --line-strong: #b3afa3;
  --accent: #d33a1e;        /* brick red: primary buttons and emphasis */
  --accent-hover: #b52f16;
  --accent-ink: #ffffff;
  --link: #b0301a;          /* red that passes AA for small text */
  --dark: #2a2a26;          /* charcoal buttons and selected states */
  --dark-hover: #000000;
  --dark-ink: #fbfaf6;
  --select-bg: #ecebe2;
  --focus: #2a2a26;
  --series-labor: #2b65a3;     /* chart: avoidable time */
  --series-turnover: #d33a1e;  /* chart: turnover */
  --on-labor: #ffffff;         /* text printed inside a labor segment */
  --on-turnover: #ffffff;      /* text printed inside a turnover segment */
  --strength-bg: #e3ecdc;
  --strength-ink: #2f5a2a;
  --gap-bg: #f6e7c8;
  --gap-ink: #6b4500;
  --example-ink: #6b4500;
  --example-line: #b98a3a;
  --error: #a1260f;
  --shadow: 0 1px 2px rgb(42 42 38 / 6%), 0 6px 20px rgb(42 42 38 / 6%);

  /* Type */
  --font-sans: "Source Sans 3", "Source Sans Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-2xl: clamp(2.1rem, 1.4rem + 3vw, 3.25rem);
  --text-hero: clamp(3rem, 2.2rem + 3.6vw, 4.5rem);

  /* Shape and space */
  --radius: 6px;
  --radius-sm: 4px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 56px;
  --col: 720px;
  --wide: 1060px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a17;
    --surface: #23221e;
    --surface-2: #2c2b26;
    --ink: #f1eee6;
    --ink-2: #cbc7bb;
    --ink-3: #a9a59a;
    --line: #3a3832;
    --line-strong: #57544b;
    --accent: #ef6a45;
    --accent-hover: #f5835f;
    --accent-ink: #1b1a17;
    --link: #f38b6b;
    --dark: #f1eee6;
    --dark-hover: #ffffff;
    --dark-ink: #1b1a17;
    --select-bg: #302f29;
    --focus: #f1eee6;
    --series-labor: #4a8ad0;
    --series-turnover: #e8603c;
    --on-labor: #0b0b0b;
    --on-turnover: #0b0b0b;
    --strength-bg: #22331f;
    --strength-ink: #b4d8a8;
    --gap-bg: #3b2e12;
    --gap-ink: #f0cd8a;
    --example-ink: #f0cd8a;
    --example-line: #a17a33;
    --error: #ff8a73;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a17;
  --surface: #23221e;
  --surface-2: #2c2b26;
  --ink: #f1eee6;
  --ink-2: #cbc7bb;
  --ink-3: #a9a59a;
  --line: #3a3832;
  --line-strong: #57544b;
  --accent: #ef6a45;
  --accent-hover: #f5835f;
  --accent-ink: #1b1a17;
  --link: #f38b6b;
  --dark: #f1eee6;
  --dark-hover: #ffffff;
  --dark-ink: #1b1a17;
  --select-bg: #302f29;
  --focus: #f1eee6;
  --series-labor: #4a8ad0;
  --series-turnover: #e8603c;
  --on-labor: #0b0b0b;
  --on-turnover: #0b0b0b;
  --strength-bg: #22331f;
  --strength-ink: #b4d8a8;
  --gap-bg: #3b2e12;
  --gap-ink: #f0cd8a;
  --example-ink: #f0cd8a;
  --example-line: #a17a33;
  --error: #ff8a73;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.1;
  font-weight: 800;
  text-wrap: balance;
  letter-spacing: -0.015em;
}
p { margin: 0; }
a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Frame ---------- */
.app {
  padding-block: var(--space-4) var(--space-7);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brandbar {
  max-width: var(--wide);
  margin: 0 auto var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; color: var(--ink); text-decoration: none; }
.wordmark:hover { color: var(--ink); }
.wordmark-name { font-weight: 900; color: var(--accent); letter-spacing: -0.01em; font-size: 1.25rem; line-height: 1; text-transform: uppercase; }
.wordmark-logo { height: 36px; width: auto; display: block; }
.wordmark-tool { color: var(--ink-3); font-size: var(--text-sm); font-weight: 600; }
.fullscreen-link { font-size: var(--text-sm); font-weight: 600; }
main { outline: none; }
.col { max-width: var(--col); margin: 0 auto; }
.wide { max-width: var(--wide); margin: 0 auto; }
.embedded .app { padding-block: var(--space-3) var(--space-5); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 50px; padding: 12px 22px;
  border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-weight: 700; font-size: var(--text-md); line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-dark { background: var(--dark); color: var(--dark-ink); }
.btn-dark:hover { background: var(--dark-hover); color: var(--dark-ink); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--link); padding-inline: 8px; min-height: 44px; }
.btn-quiet:hover { color: var(--accent-hover); text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ---------- Intro ---------- */
.intro { display: grid; gap: var(--space-5); }
.eyebrow {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink);
}
.intro h1 { font-size: var(--text-2xl); max-width: 18ch; letter-spacing: -0.025em; line-height: 1.02; }
.intro h1 em, .accent-word { font-style: normal; color: var(--accent); }
.lede { font-size: 1.1875rem; color: var(--ink-2); max-width: 58ch; line-height: 1.5; }
.promises { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); color: var(--ink-2); padding: 0; margin: 0; list-style: none; }
.promises li { display: flex; align-items: center; gap: 8px; }
.promises li::before { content: ""; width: 7px; height: 7px; background: var(--accent); flex: none; }
.stages { display: grid; gap: 0; grid-template-columns: 1fr; padding: 0; margin: var(--space-3) 0 0; list-style: none; border: 1px solid var(--ink); background: var(--surface); }
@media (min-width: 640px) { .stages { grid-template-columns: repeat(3, 1fr); } }
.stage { padding: var(--space-4) var(--space-4) var(--space-5); display: grid; gap: var(--space-1); align-content: start; border-bottom: 1px solid var(--line-strong); }
.stage:last-child { border-bottom: 0; }
@media (min-width: 640px) {
  .stage { border-bottom: 0; border-right: 1px solid var(--line-strong); }
  .stage:last-child { border-right: 0; }
}
.stage-name { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.stage-title { font-weight: 800; font-size: var(--text-lg); line-height: 1.2; }
.stage p { font-size: var(--text-sm); color: var(--ink-2); }
.fineprint { font-size: var(--text-sm); color: var(--ink-3); max-width: 64ch; }

/* ---------- Progress ---------- */
.progress { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }
.progress-text { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.progress-track { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.progress-track span { height: 5px; background: var(--line); }
.progress-track span.done { background: var(--ink); }
.progress-track span.current { background: var(--accent); }

/* ---------- Steps and fields ---------- */
.step { display: grid; gap: var(--space-6); }
.step-head { display: grid; gap: var(--space-2); }
.step-head h2 { font-size: var(--text-xl); outline: none; letter-spacing: -0.02em; }
.step-intro { color: var(--ink-2); max-width: 62ch; }
.field { display: grid; gap: 6px; }
.field > label, .field-label, legend.field-label {
  font-weight: 700; font-size: var(--text-md); line-height: 1.3; padding: 0;
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
}
.hint { font-size: var(--text-sm); color: var(--ink-3); max-width: 62ch; font-weight: 400; }
.input-wrap {
  display: flex; align-items: stretch; width: 100%; max-width: 300px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
}
.input-wrap:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--select-bg); }
.input-wrap input {
  flex: 1 1 auto; width: 100%; min-width: 0; border: 0; background: transparent; padding: 11px 12px; font-size: var(--text-md);
  font-variant-numeric: tabular-nums; outline: none;
}
.input-wrap .affix { display: flex; align-items: center; padding: 0 12px; color: var(--ink-3); font-size: var(--text-sm); white-space: nowrap; }
.input-wrap .affix:first-child { padding-right: 0; }
.field.invalid .input-wrap, .adjust-row.invalid .input-wrap { border-color: var(--error); }
.error { color: var(--error); font-size: var(--text-sm); font-weight: 600; }
.example-btn {
  justify-self: start; background: none; border: 0; padding: 8px 0; min-height: 36px; cursor: pointer;
  color: var(--link); font-size: var(--text-sm); font-weight: 600; text-decoration: underline; text-underline-offset: 0.15em;
}
.example-btn:hover { color: var(--accent-hover); }
.ex-chip {
  display: inline-flex; align-items: center;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--example-ink); border: 1px dashed var(--example-line); border-radius: 999px; padding: 0 8px;
}
.field-grid { display: grid; gap: var(--space-5); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.step > *, .field, .panel, .buildup-grid > *, .field-grid > *, .adjust-group > *, .card > *,
.fold-body > *, .results > *, .cards > *, .ladder > *, .looks > *, .method > *, .investigate > *, .adjust-groups > * { min-width: 0; }
[tabindex="-1"]:focus { outline: none; }

/* Option cards (radio and checkbox) */
.options { display: grid; gap: var(--space-2); }
@media (min-width: 620px) { .options.two { grid-template-columns: 1fr 1fr; } }
.option {
  position: relative; display: flex; gap: var(--space-3); align-items: flex-start;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; min-height: 50px;
}
.option:hover { border-color: var(--line-strong); }
.option input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--dark); flex: none; }
.option-text { display: grid; gap: 2px; }
.option-label { font-weight: 600; line-height: 1.3; }
.option-hint { font-size: var(--text-sm); color: var(--ink-3); }
.option:has(input:checked) { border-color: var(--ink); background: var(--select-bg); }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.invalid .option { border-color: var(--error); }

/* Segmented minutes control */
.minutes-list { display: grid; gap: var(--space-5); }
.seg-field { display: grid; gap: var(--space-2); }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; max-width: 540px; }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 6px 4px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 700; text-align: center; line-height: 1.15;
}
.seg label:hover span { border-color: var(--ink); }
.seg input:checked + span { background: var(--dark); border-color: var(--dark); color: var(--dark-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-field.invalid .seg span { border-color: var(--error); }

/* Two-way toggle (replacement cost mode) */
.toggle { display: inline-grid; grid-auto-flow: column; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); max-width: 100%; justify-self: start; }
.toggle label { position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { display: block; padding: 9px 14px; border-radius: 3px; font-size: var(--text-sm); font-weight: 700; color: var(--ink-2); }
.toggle input:checked + span { background: var(--dark); color: var(--dark-ink); }
.toggle input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.buildup-grid { display: grid; gap: var(--space-4); }
@media (min-width: 620px) { .buildup-grid { grid-template-columns: 1fr 1fr; } }
.buildup-grid .input-wrap { max-width: none; }
.buildup-grid .field > label { font-size: var(--text-sm); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); display: grid; gap: var(--space-4); }

/* Live reflection under a step */
.reflect {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
  color: var(--ink); font-size: var(--text-sm); display: grid; gap: var(--space-1);
}
.reflect:empty { display: none; }
.reflect strong { font-weight: 700; }
.warn {
  background: var(--gap-bg); color: var(--gap-ink); border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: 600;
}
#warnings:empty { display: none; }
.text-input {
  width: 100%; max-width: 540px; background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.text-input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--select-bg); }

.step-nav { display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap-reverse; border-top: 1px solid var(--line); padding-top: var(--space-5); }
.form-error { color: var(--error); font-weight: 700; font-size: var(--text-sm); }

/* ---------- Results ---------- */
.results { display: grid; gap: var(--space-7); }
.sample-banner {
  display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between;
  background: var(--gap-bg); color: var(--gap-ink); border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  font-weight: 700; font-size: var(--text-sm);
}
.sample-banner .btn { min-height: 42px; padding: 8px 14px; font-size: var(--text-sm); }
.results-head { display: grid; gap: var(--space-3); }
.results-head h1 { font-size: var(--text-2xl); letter-spacing: -0.025em; line-height: 1.04; max-width: 24ch; }
.summary-line { color: var(--ink-2); }
.jump { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); font-weight: 600; padding: 0; margin: 0; list-style: none; }

.hero {
  background: var(--surface); border: 1px solid var(--ink); border-radius: var(--radius-sm);
  padding: var(--space-5); display: grid; gap: var(--space-4);
}
@media (min-width: 820px) { .hero { padding: var(--space-6); } }
.hero-label { font-weight: 700; color: var(--ink-2); }
.hero-figure { font-size: var(--text-hero); font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.hero-figure small { font-size: var(--text-lg); font-weight: 600; color: var(--ink-2); letter-spacing: 0; margin-left: 8px; }
.hero-note { color: var(--ink-2); max-width: 66ch; }
.hero-note strong { color: var(--ink); }

/* Segmented bar: one whole split into parts */
.segbar { display: flex; gap: 2px; height: 28px; width: 100%; }
.segbar .part { border-radius: 4px; display: flex; align-items: center; padding: 0 8px; min-width: 0; font-size: var(--text-xs); font-weight: 700; white-space: nowrap; }
.segbar .part.labor { background: var(--series-labor); color: var(--on-labor); }
.segbar .part.turnover { background: var(--series-turnover); color: var(--on-turnover); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding: 0; margin: 0; list-style: none; font-size: var(--text-sm); color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.swatch.labor { background: var(--series-labor); }
.swatch.turnover { background: var(--series-turnover); }
.legend b { color: var(--ink); font-weight: 700; }

/* Cost today -> opportunity -> bottom line */
.ladder { display: grid; gap: var(--space-3); grid-template-columns: 1fr; align-items: start; padding: 0; margin: 0; list-style: none; }
@media (min-width: 820px) { .ladder { grid-template-columns: 1fr 1fr 1fr; } }
.rung { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-5); display: grid; gap: var(--space-2); align-content: start; }
.rung-step { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.rung-value { font-size: var(--text-xl); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.rung-value .unit { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.rung p { font-size: var(--text-sm); color: var(--ink-2); }
.rung p b { color: var(--ink); }
.rung.bottom { border: 1.5px solid var(--ink); }
.section-head { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.section-head h2 { font-size: var(--text-xl); letter-spacing: -0.02em; }
.section-head p { color: var(--ink-2); max-width: 66ch; }

.cards { display: grid; gap: var(--space-4); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-5); display: grid; gap: var(--space-4); align-content: start; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.card-head h3 { font-size: var(--text-lg); display: flex; align-items: center; gap: 8px; }
.card-amount { font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.02em; }
.card-amount .unit { font-size: var(--text-sm); color: var(--ink-2); font-weight: 600; letter-spacing: 0; }
.card p { color: var(--ink-2); }
.card p b { color: var(--ink); }
.tag { display: inline-flex; align-self: start; justify-self: start; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.formula {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); color: var(--ink); overflow-x: auto;
}
.formula .eq { font-weight: 800; white-space: nowrap; }
.formula-label { display: block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.note { font-size: var(--text-sm); color: var(--ink-3); }

/* Horizontal bars (time categories) */
.bars { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--space-3); align-items: center; }
.bar-name { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.bar-value { font-size: var(--text-sm); color: var(--ink-2); text-align: right; white-space: nowrap; }
.bar-track { grid-column: 1 / -1; height: 10px; }
.bar-fill { display: block; height: 100%; width: var(--w, 0%); background: var(--series-labor); border-radius: 0 4px 4px 0; }

.lines { display: grid; gap: 6px; margin: 0; padding: 0; }
.lines div { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.lines dt { color: var(--ink-2); }
.lines dd { margin: 0; font-weight: 600; white-space: nowrap; }
.lines .total { border-bottom: 0; }
.lines .total dt, .lines .total dd { color: var(--ink); font-weight: 800; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.chips li { font-size: var(--text-sm); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; color: var(--ink); background: var(--surface); }
.chips li.focus { border-color: var(--ink); background: var(--select-bg); font-weight: 700; }

.snapshot { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.snapshot li { display: grid; gap: 4px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.snapshot li:last-child { border-bottom: 0; padding-bottom: 0; }
.snap-q { font-size: var(--text-xs); color: var(--ink-3); font-weight: 600; }
.snap-a { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-weight: 700; }
.snap-r { font-size: var(--text-sm); color: var(--ink-2); }
.state { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.strength { background: var(--strength-bg); color: var(--strength-ink); }
.state.gap { background: var(--gap-bg); color: var(--gap-ink); }
.card p.summary-strong { font-weight: 700; color: var(--ink); font-size: var(--text-md); }
.measures { margin: 0; padding-left: 1.2em; color: var(--ink-2); font-size: var(--text-sm); display: grid; gap: 4px; }

/* Collapsible panels */
details.fold { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
details.fold + details.fold { margin-top: var(--space-3); }
details.fold > summary {
  cursor: pointer; padding: var(--space-4) var(--space-5); font-weight: 800; font-size: var(--text-lg);
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "+"; font-size: 1.6rem; line-height: 1; color: var(--accent); font-weight: 600; }
details.fold[open] > summary::after { content: "\2212"; }
details.fold > summary .sum-sub { display: block; font-weight: 400; font-size: var(--text-sm); color: var(--ink-3); }
.fold-body { padding: 0 var(--space-5) var(--space-5); display: grid; gap: var(--space-5); }
.adjust-groups { display: grid; gap: var(--space-5); }
@media (min-width: 820px) { .adjust-groups { grid-template-columns: 1fr 1fr; gap: var(--space-5) var(--space-6); } }
.adjust-group { display: grid; gap: var(--space-3); align-content: start; }
.adjust-group h3 { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.adjust-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 4px var(--space-3); align-items: center; }
.adjust-row label { font-size: var(--text-sm); font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.adjust-row .input-wrap { max-width: none; }
.adjust-row .input-wrap input { padding: 8px 10px; font-size: var(--text-sm); text-align: right; }
.adjust-row .input-wrap .affix { padding: 0 8px; font-size: var(--text-xs); }
.adjust-row .error { grid-column: 1 / -1; }
.live-total {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2;
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-items: baseline;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-size: var(--text-sm);
  box-shadow: 0 0 0 4px var(--surface);
}
.live-total b { font-size: var(--text-md); font-weight: 800; margin-left: 4px; }
.table-wrap { overflow-x: auto; margin-top: var(--space-3); }
table.sens { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 460px; }
table.sens th, table.sens td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.sens th:first-child, table.sens td:first-child { text-align: left; }
table.sens thead th { font-size: 0.75rem; color: var(--ink-3); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
table.sens tbody th { font-weight: 600; }
table.sens td.base { font-weight: 800; }
.method { display: grid; gap: var(--space-5); }
@media (min-width: 900px) { .method { grid-template-columns: 1fr 1fr; gap: var(--space-5) var(--space-6); } }
.method h3 { font-size: var(--text-md); margin-bottom: var(--space-2); }
.method p, .method li { color: var(--ink-2); font-size: var(--text-sm); }
.method p + p, .method ul + p { margin-top: var(--space-2); }
.method ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.method b { color: var(--ink); }

/* Where to look first */
.looks { display: grid; gap: var(--space-4); grid-template-columns: 1fr; margin: 0; padding: 0; list-style: none; }
@media (min-width: 900px) { .looks { grid-template-columns: repeat(3, 1fr); } }
.look { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-5); display: grid; gap: var(--space-3); align-content: start; }
.look h3 { font-size: var(--text-lg); line-height: 1.2; letter-spacing: -0.01em; }
.look .why { font-size: var(--text-sm); color: var(--ink-3); }
.look .how { font-size: var(--text-sm); color: var(--ink-2); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.look .how b { color: var(--ink); }

/* Investigate with AI */
.investigate { background: var(--surface); border: 1px solid var(--ink); border-radius: var(--radius-sm); padding: var(--space-5); display: grid; gap: var(--space-5); }
@media (min-width: 820px) { .investigate { padding: var(--space-6); } }
.investigate .section-head { margin-bottom: 0; }
.select {
  width: 100%; max-width: 580px; background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 11px 12px; font-size: var(--text-md);
}
.select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--select-bg); }
.status { font-size: var(--text-sm); font-weight: 700; color: var(--strength-ink); }
.status:empty { display: none; }
.status.bad { color: var(--error); }
.prompt-box {
  width: 100%; min-height: 300px; resize: vertical; background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: var(--space-3); font-size: 0.875rem; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
details.peek > summary { cursor: pointer; font-weight: 700; color: var(--link); padding: 4px 0; }
details.peek[open] > summary { margin-bottom: var(--space-3); }
.howto { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; color: var(--ink-2); }
.howto b { color: var(--ink); }

/* Citations and published figures */
.hint.context { color: var(--ink-2); }
.cite-row { white-space: nowrap; }
.cite-out { font-weight: 600; }
.cite { font-size: 0.75em; font-weight: 700; vertical-align: super; line-height: 0; margin-left: 2px; text-decoration: none; }
.cite:hover { text-decoration: underline; }
.compare { display: grid; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-4); }
.compare-title { font-weight: 700; color: var(--ink) !important; font-size: var(--text-sm); }
.compare .bar-fill { background: var(--line-strong); }
.compare .bar-row.you .bar-fill { background: var(--series-turnover); }
.compare .bar-row.you .bar-name { font-weight: 800; }
.sources { display: grid; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-6); }
.sources > .hint { max-width: 70ch; }
.sources h2 { font-size: var(--text-lg); }
.source-list { margin: 0; padding-left: 1.4em; display: grid; gap: var(--space-4); font-size: var(--text-sm); max-width: 84ch; }
.source-list li { scroll-margin-top: 80px; }
.source-list li:target { background: var(--select-bg); outline: 6px solid var(--select-bg); border-radius: 2px; }
.src-cite { color: var(--ink); }
.src-find { color: var(--ink-2); margin-top: 2px; }
.src-use { color: var(--ink-3); margin-top: 2px; }

/* Keep and share */
.share { display: grid; gap: var(--space-4); }
.share .section-head { margin-bottom: 0; }
.link-banner {
  background: var(--surface-2); color: var(--ink); border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
}
.check { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; max-width: 62ch; font-weight: 700; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--dark); flex: none; }
.check .hint { display: block; font-weight: 400; margin-top: 2px; }
.selectable { user-select: all; font-weight: 600; color: var(--ink); }

/* CTA */
.cta { border-top: 1px solid var(--ink); padding-top: var(--space-6); display: grid; gap: var(--space-4); justify-items: start; }
.cta h2 { font-size: var(--text-xl); letter-spacing: -0.02em; }
.cta p { color: var(--ink-2); max-width: 60ch; }
.end-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }

.appfoot { max-width: var(--wide); margin: var(--space-7) auto 0; padding-top: var(--space-4); border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); justify-content: space-between; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Printed / PDF report ----------
   The report only appears when printing or saving as PDF from the results.
   It uses fixed ink-on-white colors so it prints the same in any theme. */
.print-only { display: none; }
@media print {
  @page { margin: 14mm 14mm 16mm; }
  .fullscreen-link, .step-nav, .jump, .investigate .btn-row, .end-actions { display: none !important; }
  body { background: #fff; }
  body.has-report .app { display: none !important; }
  body.has-report .print-only { display: block !important; }

  .rp { color: #1e1e1b; font-family: var(--font-sans); font-size: 10pt; line-height: 1.4; }
  .rp p { margin: 0 0 3pt; }
  .rp h1 { font-size: 17pt; margin: 8pt 0 4pt; letter-spacing: -0.01em; }
  .rp h2 { font-size: 11.5pt; margin: 0 0 4pt; }
  .rp a { color: #b0301a; }
  .rp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12pt; border-bottom: 1.5pt solid #1e1e1b; padding-bottom: 4pt; }
  .rp-brand { font-weight: 900; text-transform: uppercase; color: #c23519; font-size: 12pt; }
  .rp-meta { font-size: 9pt; color: #4f4e48; }
  .rp-flag { font-weight: 700; color: #6b4500; }
  .rp-caveat { color: #4f4e48; font-size: 9pt; margin-bottom: 8pt; }
  .rp-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6pt; margin: 8pt 0 12pt; }
  .rp-three > div { border: 1pt solid #b3afa3; padding: 6pt 8pt; display: grid; gap: 2pt; align-content: start; }
  .rp-three > div:last-child { border: 1.5pt solid #1e1e1b; }
  .rp-k { font-size: 7.5pt; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #4f4e48; }
  .rp-v { font-size: 16pt; font-weight: 800; line-height: 1.1; }
  .rp-s { font-size: 8.5pt; color: #4f4e48; }
  .rp-sec, .rp-two, .rp-next { margin-bottom: 10pt; break-inside: avoid; }
  .rp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14pt; }
  .rp-table { width: 100%; border-collapse: collapse; font-size: 9pt; margin: 2pt 0 4pt; }
  .rp-table th, .rp-table td { padding: 2.5pt 4pt; border-bottom: 0.5pt solid #dcd9ce; text-align: right; font-weight: 400; }
  .rp-table th:first-child { text-align: left; }
  .rp-table thead th { font-size: 7.5pt; text-transform: uppercase; letter-spacing: 0.06em; color: #4f4e48; font-weight: 700; }
  .rp-total th, .rp-total td { font-weight: 700 !important; border-bottom: 0 !important; }
  .rp-narrow { width: 70%; }
  .rp-formula, .rp-note { font-size: 8.5pt; color: #4f4e48; }
  .rp ul, .rp ol { margin: 0 0 4pt; padding-left: 14pt; }
  .rp li { margin-bottom: 2pt; }
  .rp-looks li { margin-bottom: 5pt; }
  .rp-small p { font-size: 8.5pt; color: #4f4e48; }
  .rp-next { border-top: 1pt solid #1e1e1b; padding-top: 6pt; }
  .rp-foot { font-size: 8pt; color: #605f58; margin-top: 4pt; }
  .rp-sources li { font-size: 8pt; margin-bottom: 1.5pt; }
  .rp-sources a { word-break: break-all; }
  .rp-appendix { break-before: page; }
  .rp-appendix pre { white-space: pre-wrap; word-break: break-word; font-size: 8.5pt; font-family: ui-monospace, Menlo, Consolas, monospace; line-height: 1.35; margin: 4pt 0 0; }
}
