/* Flow — shared design system. Warm cream by day, charcoal by night.
   Status colors (good/warning/critical) are reserved for real states —
   MEASURED vs MODELED is conveyed by weight, not hue, on purpose. */

/* Text tokens clear WCAG AA (4.5:1) on every surface they sit on, light and dark —
   axe-checked 2026-10-05; the old muted grey read 3.5:1, faint outdoors. */
:root {
  color-scheme: light;
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ede0;
  --text: #17140f;
  --text-2: #52514e;
  --muted: #6c6357;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: #e7dfcf;

  --good: #077607;
  --good-soft: #e4f3e0;
  --warning: #875f00;
  --warning-soft: #fbf0d9;
  --critical: #b92e2e;
  --critical-soft: #f8e3e1;
  --discover: #4a3aa7;
  --discover-soft: #ece8f8;

  --seq-100: #cde2fb;
  --seq-300: #6da7ec;
  --seq-500: #256abf;

  --shadow: 0 1px 2px rgba(23, 20, 15, 0.04), 0 8px 24px rgba(23, 20, 15, 0.05);
  --radius: 16px;
  --radius-sm: 10px;

  --font-serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #171310;
    --surface: #211c16;
    --surface-2: #2a241c;
    --text: #f3ecdf;
    --text-2: #c3baa9;
    --muted: #9b917f;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: #3a3226;

    --good: #13ad13;
    --good-soft: #1c2b19;
    --warning: #d99a1f;
    --warning-soft: #332715;
    --critical: #e66767;
    --critical-soft: #341e1d;
    --discover: #9085e9;
    --discover-soft: #2a2440;

    --seq-100: #184f95;
    --seq-300: #2a78d6;
    --seq-500: #86b6ef;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.28);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171310;
  --surface: #211c16;
  --surface-2: #2a241c;
  --text: #f3ecdf;
  --text-2: #c3baa9;
  --muted: #9b917f;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: #3a3226;

  --good: #13ad13;
  --good-soft: #1c2b19;
  --warning: #d99a1f;
  --warning-soft: #332715;
  --critical: #e66767;
  --critical-soft: #341e1d;
  --discover: #9085e9;
  --discover-soft: #2a2440;

  --seq-100: #184f95;
  --seq-300: #2a78d6;
  --seq-500: #86b6ef;
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 28px;
}
.wordmark {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-link {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
@media (hover: hover) { .topbar-link:hover { color: var(--text); } }

/* ------------------------------------------------------------------ type */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.3; }
p { margin: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { color: var(--text-2); font-size: 15px; margin-top: 6px; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
}
/* basis: measured is solid/certain, modeled is an outline — weight, not hue */
.badge-measured { background: var(--text); color: var(--bg); }
.badge-modeled {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}
/* mode: mock MUST read amber; live is quiet */
.badge-mock { background: var(--warning-soft); color: var(--warning); }
.badge-live { background: transparent; color: var(--text-2); border: 1px solid var(--border-strong); }

.badge-source {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status-confirmed { color: var(--good); }
.status-confirmed .dot { background: var(--good); }
.status-rejected { color: var(--text-2); }
.status-rejected .dot { background: var(--muted); }
.status-insufficient { color: var(--warning); }
.status-insufficient .dot { background: var(--warning); }
.status-discovered { color: var(--discover); }
.status-discovered .dot { background: var(--discover); }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 14px; }
.card-accent { border-left: 3px solid var(--border-strong); }
.card-accent.confirmed { border-left-color: var(--good); }
.card-accent.rejected { border-left-color: var(--muted); }
.card-accent.discovered { border-left-color: var(--discover); }
.card-accent.insufficient { border-left-color: var(--warning); }
.card-ghost {
  background: transparent;
  border: 1px dashed var(--border-strong);
  box-shadow: none;
  color: var(--text-2);
}
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------ hero */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.hero h1 { margin-top: 8px; }
.hero .lede { margin-top: 10px; font-size: 16px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--text); color: var(--bg); }
@media (hover: hover) { .btn-primary:hover { opacity: 0.88; } }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
@media (hover: hover) { .btn-ghost:hover { color: var(--text); border-color: var(--muted); } }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------------ chip */
.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
@media (hover: hover) { .chip:hover { border-color: var(--muted); } }
.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--surface-2);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- quiz */
.wrap-quiz { max-width: 560px; }
.step-nav { margin: 26px 0 8px; }
.progress { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.progress li { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.progress li i {
  display: block; height: 4px; border-radius: 999px; background: var(--border-strong);
  transition: background 0.3s ease;
}
.progress li.done i, .progress li.active i { background: var(--text); }
.progress li span {
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; transition: color 0.2s ease, font-weight 0.2s ease;
}
.progress li.active span { color: var(--text); font-weight: 700; }
.progress li.done span { color: var(--text-2); }

.step-index {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  font-size: 13px; font-weight: 700; font-family: var(--font-sans);
  margin-bottom: 16px;
}
.step { display: none; padding: 34px 0 4px; }
.step.active { display: block; }
.step.active.dir-fwd { animation: slide-in-fwd 0.34s cubic-bezier(0.2, 0.8, 0.2, 1); }
.step.active.dir-back { animation: slide-in-back 0.34s cubic-bezier(0.2, 0.8, 0.2, 1); }
.step h2 { font-size: 25px; margin-bottom: 6px; }
@keyframes slide-in-fwd {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes slide-in-back {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: none; }
}

.substep {
  max-height: 0; opacity: 0; overflow: hidden; margin-top: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.35s ease;
}
.substep.visible { max-height: 160px; opacity: 1; margin-top: 24px; }

.chip-count { font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 16px; }

.step-actions {
  display: flex; gap: 10px; margin-top: 34px;
  position: sticky; bottom: 0; padding: 18px 0 6px;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}
.step-actions .btn { flex: 1; }
.field-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.field-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* --------------------------------------------------------------- signals */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat-tile .stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-tile .stat-value { font-family: var(--font-serif); font-size: 24px; }
.stat-tile .stat-value .unit { font-family: var(--font-sans); font-size: 13px; color: var(--muted); margin-left: 3px; }
.stat-tile .badge { margin-top: 8px; }

/* ----------------------------------------------------------------- meter */
.meter-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.meter-row:first-of-type { margin-top: 0; }
.meter-label { flex: 0 0 118px; font-size: 13px; color: var(--text-2); }
.meter-label.lead { color: var(--text); font-weight: 700; }
.meter-track {
  flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 999px; background: var(--seq-300); }
.meter-fill.lead { background: var(--seq-500); }

/* mini contrast bar: side_a vs side_b days, two segments, 2px surface gap */
.contrast-bar { display: flex; height: 6px; gap: 2px; border-radius: 999px; overflow: hidden; width: 100%; }
.contrast-bar span { display: block; height: 100%; border-radius: 999px; }
.contrast-bar .side-a { background: var(--seq-500); }
.contrast-bar .side-b { background: var(--border-strong); }

/* ------------------------------------------------------------------ gate */
.gate-list { display: flex; flex-direction: column; gap: 10px; }
.gate {
  display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px;
}
.gate-icon {
  width: 18px; height: 18px; border-radius: 50%; flex: none; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
}
.gate-icon.pass { background: var(--good); }
.gate-icon.fail { background: var(--critical); }
.gate-name { font-weight: 600; color: var(--text); }
.gate-note { color: var(--muted); }

/* --------------------------------------------------------------- runners */
details.runners { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 16px; }
details.runners summary {
  cursor: pointer; padding: 12px 0; font-size: 14px; font-weight: 600; color: var(--text-2);
  list-style: none;
}
details.runners summary::-webkit-details-marker { display: none; }
details.runners summary::before { content: "▸ "; color: var(--muted); }
details.runners[open] summary::before { content: "▾ "; }
.runner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}

/* --------------------------------------------------------------- thesis */
.thesis-item {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.thesis-item:first-child { border-top: none; padding-top: 0; }
.thesis-claim { font-size: 14.5px; margin-top: 4px; }
.thesis-verdict { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.thesis-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- misc */
.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.center { text-align: center; }
.skeleton {
  color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center;
}
.error-banner {
  background: var(--critical-soft); color: var(--critical); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13.5px; margin-bottom: 16px;
}
footer.note {
  margin-top: 28px; font-size: 12.5px; color: var(--muted); text-align: center;
}
a { color: inherit; }

/* ---------------------------------------------------------------- tabbar */
/* Installed-app navigation. Fixed to the bottom, clears the iPhone home bar. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); text-decoration: none;
}
.tabbar a .glyph { font-size: 18px; line-height: 1.1; }
.tabbar a.active { color: var(--text); }
.tabbar a:active { background: var(--surface-2); }
body.has-tabbar .wrap { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }

/* ------------------------------------------------------------------- log */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field input {
  width: 100%; font: inherit; font-family: var(--font-serif); font-size: 22px;
  padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field input:focus { outline: 2px solid var(--seq-300); outline-offset: 1px; }
.field input[type="date"] { font-family: var(--font-sans); font-size: 15px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.choice-row { display: flex; gap: 10px; }
.choice-row .btn { flex: 1; }
.form-status { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.form-status.ok { color: var(--good); }
.form-status.err { color: var(--critical); }

/* installed-app chrome: hide the browser-only hints */
@media (display-mode: standalone) {
  .hide-standalone { display: none !important; }
}

/* for screen readers only: a heading the eye gets from the layout */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* a card title that is an h2 in the outline but reads at h3 size */
.h3 { font-size: 17px; line-height: 1.3; }
/* headings that take focus when a setup step changes: no ring around a heading */
[tabindex="-1"]:focus { outline: none; }

/* iPhone (2026-10-07; "some of the ui has some weird behavior on mobile"):
   a quick second tap on the check-in dots zoomed the page — manipulation keeps pinch-zoom, drops double-tap;
   a field under 16px makes Safari zoom in on focus and stay there — no field is smaller on a touch screen;
   and the fixed tab bar rode up over the keyboard while typing. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
@media (pointer: coarse) {
  input, select, textarea { font-size: max(16px, 1em) !important; }
  body:has(input:focus, textarea:focus, select:focus) .tabbar { display: none; }
}
