/* Same instrument-panel token language as the design mockup and the
   methodology page, kept in sync by hand across all three (no shared
   stylesheet import -- see site/build.py's comment on why). */

:root {
  --bg: #edece6;
  --surface: #f7f6f2;
  --surface-2: #eeece4;
  --text: #15181c;
  --text-soft: #565c63;
  --text-faint: #8a8f94;
  --rule: #cbc9c0;
  --rule-strong: #b3b0a5;
  --accent: #a87a2e;
  --accent-tint: #e9d6ac;
  --accent-ink: #5c4218;
  --steel: #3e6272;
  --steel-tint: #d9e4e7;
  --caution: #a85c34;
  --caution-tint: #f0dccb;
  --shadow: 0 1px 2px rgba(21,24,28,0.06), 0 6px 16px -8px rgba(21,24,28,0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1c2025;
    --surface-2: #21262c;
    --text: #ecebe5;
    --text-soft: #a9adb2;
    --text-faint: #767b81;
    --rule: #33383e;
    --rule-strong: #40464d;
    --accent: #d9a852;
    --accent-tint: #3a2e17;
    --accent-ink: #f0d9a8;
    --steel: #7fabbd;
    --steel-tint: #1f2f34;
    --caution: #d0895d;
    --caution-tint: #382418;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px -8px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: ui-serif, Charter, "Iowan Old Style", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.font-label { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; }
.font-mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace; font-variant-numeric: tabular-nums; }

.page { max-width: 460px; margin: 0 auto; padding: 20px 16px 64px; }

.masthead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20px; gap: 12px; }
.brand { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-weight: 700; font-size: 16px; }
.methodology-link { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 12.5px; color: var(--steel); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--steel) 40%, transparent); white-space: nowrap; }

.screen.hidden { display: none; }

/* ---- Tabs + forms ---- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 20px; padding: 3px; margin-bottom: 18px; }
.tab {
  flex: 1; font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 12.5px; font-weight: 600;
  padding: 9px 6px; border-radius: 16px; border: none; background: transparent; color: var(--text-soft); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.entry-form { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 18px; }
.entry-form.hidden { display: none; }
.field-label { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; color: var(--text-soft); margin: 10px 0 4px; }
.field-label:first-child { margin-top: 0; }
.optional-tag { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); }

input, select, textarea {
  font-family: inherit; font-size: 16px; padding: 11px 12px; border: 1.5px solid var(--rule-strong);
  border-radius: 5px; background: var(--surface); color: var(--text); width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--steel); outline-offset: 1px; }
select:disabled { opacity: 0.6; }

.btn-primary {
  margin-top: 16px; font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-weight: 700; font-size: 15px;
  padding: 13px; border: none; border-radius: 6px; background: var(--text); color: var(--surface); cursor: pointer;
}
.btn-primary:hover { opacity: 0.92; }

.link-btn {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 13px; color: var(--steel);
  background: none; border: none; padding: 10px 2px; cursor: pointer; text-align: left;
}

/* ---- Resolving ---- */
/* :not(.hidden) rather than a bare #screen-resolving rule -- an ID
   selector's specificity otherwise beats .screen.hidden's display:none
   and the "hidden" class gets applied but does nothing (caught live:
   the resolving spinner stayed visible, stacked above the rendered
   result, after resolution completed). */
#screen-resolving:not(.hidden) { display: flex; flex-direction: column; align-items: center; padding: 60px 0; gap: 14px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--rule); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.resolving-text { color: var(--text-soft); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---- Ambiguous / unresolved / declined ---- */
.section-title { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 19px; margin: 8px 0 4px; }
.section-sub { color: var(--text-soft); font-size: 14px; margin: 0 0 16px; }

.candidate-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.candidate-card {
  text-align: left; display: block; width: 100%; background: var(--surface); border: 1.5px solid var(--rule-strong);
  border-radius: 6px; padding: 13px 14px; cursor: pointer; font-family: inherit;
}
.candidate-card:hover { border-color: var(--accent); }
.candidate-card .cc-name { font-size: 15px; font-weight: 600; color: var(--text); }
.candidate-card .cc-variants { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ---- Result: phone card, hero, gauge (from the design mockup) ---- */
.phone { width: 100%; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.result-back { margin-bottom: 10px; }
.panel { padding: 20px 18px; }
.panel + .panel { border-top: 1px solid var(--rule); }

.vhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.vhead .name { font-size: 17px; font-weight: 500; text-wrap: balance; }
.vhead .meta { margin-top: 3px; font-size: 12.5px; color: var(--text-soft); }
.source-pill {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 700; padding: 3px 7px; border-radius: 2px; white-space: nowrap; align-self: flex-start;
  background: var(--steel-tint); color: var(--steel);
}
.source-pill.user { background: var(--accent-tint); color: var(--accent-ink); }

.hero { background: var(--surface); }
.hero-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.segment-tag { font-size: 12.5px; color: var(--text-soft); }
.segment-tag b { color: var(--text); font-weight: 600; }
.segment-tag.unmapped { color: var(--caution); }
.segment-tag.unmapped b { color: var(--caution); }

.prelim-badge {
  display: inline-flex; align-items: center; gap: 5px; font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--caution);
  background: var(--caution-tint); padding: 4px 9px; border-radius: 2px; margin-bottom: 10px;
}
.prelim-badge.hidden { display: none; }
.prelim-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--caution); }

.center-value { font-size: 42px; line-height: 1; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 8px; }
.center-value .unit { font-size: 17px; font-weight: 500; color: var(--text-soft); }
.center-caption { margin-top: 4px; font-size: 13px; color: var(--text-soft); }

.gauge { margin-top: 20px; }
.gauge-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--rule); overflow: hidden; }
.gauge-fill {
  position: absolute; top: -1px; bottom: -1px; border-radius: 5px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fill-color, var(--accent)) 55%, transparent), var(--fill-color, var(--accent)));
  transition: left 0.5s cubic-bezier(.4,0,.2,1), right 0.5s cubic-bezier(.4,0,.2,1);
}
.gauge-fill::after {
  content: ""; position: absolute; inset: 0; opacity: var(--hatch-opacity, 0);
  background: repeating-linear-gradient(135deg, rgba(0,0,0,0.35) 0px, rgba(0,0,0,0.35) 3px, transparent 3px, transparent 7px);
}
.gauge-center { position: absolute; top: -5px; width: 2px; height: 20px; background: var(--text); transform: translateX(-1px); transition: left 0.5s cubic-bezier(.4,0,.2,1); }
.gauge-labels { display: flex; justify-content: space-between; margin-top: 8px; }
.gauge-labels .lo, .gauge-labels .hi { font-size: 13px; font-weight: 600; }
.gauge-labels .lo-cap, .gauge-labels .hi-cap { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); display: block; margin-top: 2px; }
.gauge-labels .hi-block { text-align: right; }

.band-note { margin-top: 14px; font-size: 12.5px; line-height: 1.55; color: var(--text-soft); padding: 10px 12px; background: var(--surface-2); border-left: 2px solid var(--fill-color, var(--accent)); border-radius: 0 3px 3px 0; }
.band-note b { color: var(--text); }

/* ---- Sharpen module ---- */
.sharpen {
  background: color-mix(in srgb, var(--accent-tint) calc(var(--sharpen-intensity, 0.4) * 100%), var(--surface));
}
.sharpen.promoted { order: -3; }
.vhead { order: -4; }
.sharpen-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sharpen-head .eyebrow { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 11px; letter-spacing: 0.11em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); }
.sharpen p { margin: 2px 0 14px; font-size: 13.5px; color: var(--accent-ink); line-height: 1.5; }
#body-style-group.hidden, #powertrain-group.hidden { display: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip-group-label { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink); opacity: 0.75; margin-bottom: 7px; font-weight: 700; }
.chip {
  font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 13.5px; font-weight: 500; padding: 8px 14px;
  border-radius: 20px; border: 1.5px solid var(--rule-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

/* ---- Anchor affordance ---- */
.anchor-panel { background: var(--surface); }
.anchor-affordance {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: var(--surface-2);
  border: 1.5px dashed var(--rule-strong); border-radius: 6px; padding: 12px 14px; cursor: pointer; font-family: inherit;
}
.anchor-affordance span:first-child { font-weight: 600; font-size: 14.5px; color: var(--text); }
.anchor-affordance-sub { font-size: 12px; color: var(--text-soft); }
#anchor-form { margin-top: 12px; padding: 14px; }
.anchor-decline { font-size: 12.5px; color: var(--caution); margin-top: 10px; }
.anchor-decline.hidden { display: none; }

/* ---- Breakdown spec sheet ---- */
.breakdown-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.breakdown-head .eyebrow { font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; font-size: 11px; letter-spacing: 0.11em; text-transform: uppercase; font-weight: 600; color: var(--text-faint); }
.caret { font-size: 11px; color: var(--text-faint); }
.breakdown-intro { font-size: 13px; color: var(--text-soft); line-height: 1.55; margin: 12px 0 16px; }
.term-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-top: 1px solid var(--rule); }
.term-row:first-of-type { border-top: none; }
.term-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.term-value { font-size: 13.5px; font-weight: 600; text-align: right; white-space: nowrap; }
.term-value.zero { color: var(--text-faint); font-weight: 500; }
.term-value.pos { color: var(--caution); }
.term-reason { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-soft); line-height: 1.5; max-width: 54ch; }
.breakdown-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; margin-top: 4px; border-top: 1.5px solid var(--rule-strong); }
.breakdown-total .label { font-size: 12.5px; color: var(--text-soft); font-family: ui-sans-serif, "Helvetica Neue", Arial, sans-serif; text-transform: uppercase; letter-spacing: 0.05em; }
.breakdown-total .value { font-size: 15px; font-weight: 700; }

.footer-note { padding: 16px 18px 20px; font-size: 11.5px; color: var(--text-faint); line-height: 1.55; background: var(--surface-2); }
.footer-note a { color: var(--steel); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--steel) 40%, transparent); }

/* The result card is a flex column so .sharpen can reorder via `order`
   when promoted (u_total >= 0.50) -- the one deliberate discrete jump in
   an otherwise continuously-scaled treatment. */
#result-card { display: flex; flex-direction: column; }
