/* Shell and components per DESIGN.md. Colors, spacing, and radii come only from tokens. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 Overpass, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--service); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
h1, h2, h3 { text-wrap: balance; line-height: 1.15; margin: var(--s6) 0 var(--s3); }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
.mono, code, .data { font-family: "Overpass Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .875rem; font-weight: 500; font-variant-numeric: tabular-nums slashed-zero; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--s4); top: var(--s2); background: var(--panel); padding: var(--s2) var(--s3); z-index: 10; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 var(--s4); }

/* Top rail */
.rail { background: var(--guide); color: var(--legend-white); min-height: 56px; }
.rail .wrap { display: flex; align-items: center; gap: var(--s4); min-height: 56px; flex-wrap: wrap; }
.wordmark { color: var(--legend-white); font-weight: 800; font-size: 1.25rem; text-decoration: none; }
.rail nav ul { display: flex; gap: var(--s3); list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.menu-button { display: none; background: transparent; color: var(--legend-white); border: 1px solid var(--legend-white); border-radius: var(--r-field); font: 600 .875rem/1 inherit; padding: var(--s2) var(--s3); min-height: 44px; cursor: pointer; }
/* Below 768 px the sections fold into a menu; without script the list simply stays open. */
@media (max-width: 767px) {
  [data-js] .menu-button { display: inline-block; }
  [data-js] .rail nav ul { display: none; }
  [data-js] .rail nav.open ul { display: flex; flex-direction: column; width: 100%; padding-bottom: var(--s2); }
  [data-js] .rail nav.open { flex-basis: 100%; order: 3; }
}
.rail nav a { color: var(--legend-white); font-weight: 600; font-size: .875rem; text-decoration: none; padding: var(--s2) var(--s1); display: inline-block; min-height: 24px; }
.rail nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.rail a:focus-visible, .rail button:focus-visible { outline-color: var(--legend-white); }
.theme-toggle {
  margin-left: auto; background: transparent; color: var(--legend-white); border: 1px solid var(--legend-white);
  border-radius: var(--r-field); font: 600 .875rem/1 inherit; padding: var(--s2) var(--s3); min-height: 44px; cursor: pointer;
}

/* Command bar */
.command { background: var(--panel); border-bottom: 1px solid var(--line); }
.command .wrap { padding-top: var(--s3); padding-bottom: var(--s3); position: relative; }
.command label { display: block; font-size: .875rem; font-weight: 600; color: var(--muted); margin-bottom: var(--s1); }
.command input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--field-border); border-radius: var(--r-field);
  background: var(--panel); color: var(--ink);
}
.command-results {
  position: absolute; left: var(--s4); right: var(--s4); z-index: 5; margin: var(--s1) 0 0; padding: var(--s1) 0; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-field); box-shadow: 0 8px 24px var(--shadow);
}
.command-results[hidden] { display: none; }
.command-results li a { display: block; padding: var(--s2) var(--s3); color: var(--ink); text-decoration: none; }
.command-results li[aria-selected="true"] a, .command-results li a:hover { background: var(--panel-hover); }
.command-results .hint { color: var(--muted); }

/* Page */
main { padding-bottom: var(--s7); }
.tool-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.tool-head h1 { margin-bottom: var(--s2); }
.purpose { margin-top: 0; max-width: 72ch; }
.chip {
  display: inline-flex; align-items: center; gap: var(--s1); border-radius: var(--r-pill); padding: 4px 10px;
  font-size: .875rem; font-weight: 600; border: 1px solid var(--field-border); color: var(--ink); background: var(--panel);
}
.glyph { width: 16px; height: 16px; flex: none; }

/* Answer sign */
.answer { margin: var(--s4) 0 var(--s5); }
.sign {
  background: var(--guide); color: var(--legend-white); border-radius: var(--r-sign); padding: 24px 28px;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--legend-white) 30%, transparent); position: relative;
}
.sign .label { font-size: 1.25rem; font-weight: 700; margin: 0 0 var(--s2); }
.sign .number { font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; margin: 0; }
.sign .unit { font-size: .875rem; font-weight: 600; margin-left: var(--s2); }
.sign .sentence { margin: var(--s3) 0 var(--s5); max-width: 60ch; }
.sign .source-tab {
  position: absolute; right: var(--s4); bottom: var(--s3); background: var(--legend-white); color: var(--legend-black);
  border-radius: var(--r-field); padding: 4px 8px;
}
@media (min-width: 768px) { .sign .number { font-size: 4rem; } }
.sign.updating .number { opacity: .6; }
.stamp { margin: var(--s2) 0; }
.stamp .glyph { vertical-align: -2px; margin-right: var(--s1); }
.stamp .ok { color: var(--ok); }
.stamp .diamond { color: var(--work-zone-text); }
.strip {
  background: var(--work-zone); color: var(--legend-black); padding: 8px 16px; font-size: .875rem; font-weight: 600;
  display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap;
}
.strip a { color: var(--legend-black); }
.answer-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.button {
  min-height: 44px; padding: 12px 18px; border-radius: var(--r-field); font: 600 .875rem/1 inherit; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--field-border);
}
.button:hover { background: var(--panel-hover); }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
.button:active { background: var(--panel-active); }
.errors { color: var(--stop); }

/* Inputs */
.inputs { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin: var(--s4) 0; }
.field label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: var(--s1); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--field-border); border-radius: var(--r-field);
  background: var(--panel); color: var(--ink); font-family: "Overpass Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .875rem;
}
.field .unit-hint { color: var(--muted); font-size: .875rem; }
.field .error { color: var(--stop); font-size: .875rem; margin: var(--s1) 0 0; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--stop); }
.field textarea { min-height: 7rem; resize: vertical; }
.field.wide { grid-column: 1 / -1; }
.button.link { min-height: 44px; border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; font: inherit; font-size: .875rem; text-align: left; cursor: pointer; }
.bill-month { margin: var(--s2) 0; }
fieldset[data-conditions] { border: 1px solid var(--line); border-radius: var(--r-field); padding: var(--s3); margin: var(--s3) 0; }
label.check { display: flex; gap: var(--s2); align-items: center; min-height: 44px; }
.bill-month table { margin-top: var(--s2); }
.picker-row { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); align-items: end; }

/* Regulatory panels: work, sources, limits */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-field); padding: var(--s4); margin: var(--s4) 0; }
details.panel > summary { cursor: pointer; font-weight: 700; min-height: 24px; }
.summary-heading { display: inline; font-size: 1rem; margin: 0; }
.panel h3 { font-size: 1rem; margin: var(--s4) 0 var(--s2); }
/* Form controls in a panel (the lookup's ZIP and county forms) stack and never outgrow it, whatever the option text. */
form.panel label { display: block; margin-top: var(--s2); }
form.panel input, form.panel select { display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--field-border); border-radius: var(--r-field); background: var(--panel); color: var(--ink); padding: 0 var(--s2); }
form.panel .button { margin-top: var(--s3); }
.panel > h2:first-child { margin-top: 0; }
.panel ol, .panel ul { padding-left: var(--s5); }
.handoff {
  display: inline-flex; gap: var(--s2); align-items: center; background: var(--service-field); color: var(--legend-white);
  border-radius: var(--r-field); padding: 10px 14px; font-weight: 600; font-size: .875rem; text-decoration: none; min-height: 44px;
}
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: var(--s2); border-bottom: 1px solid var(--line); vertical-align: top; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tool-list { list-style: none; padding: 0; display: grid; gap: var(--s3); }
.tool-cell { background: var(--panel); border-left: 4px solid var(--guide); border-radius: var(--r-field); padding: var(--s4); }
.tool-cell a { font-weight: 700; font-size: 1.25rem; }
/* On phones a home lane is two columns of names and what each needs, so both lanes and up to five cells each fit the first screen. */
@media (max-width: 767px) {
  .lane .tool-list { grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .lane .tool-cell { padding: var(--s2); }
  .lane .tool-cell .question, .lane .tool-cell .as-of { display: none; }
  .lane .tool-cell .work-zone { display: inline-block; padding: 0 var(--s1); margin: 0 var(--s1) 0 0; font-size: .75rem; }
  .lane .tool-cell a { font-size: 1rem; }
  .lane .tool-cell .unit-hint { margin: var(--s1) 0 0; font-size: .75rem; }
}

footer { border-top: 1px solid var(--line); padding: var(--s5) 0; color: var(--muted); font-size: .875rem; }
footer ul { list-style: none; padding: 0; display: flex; gap: var(--s3); flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (forced-colors: active) {
  .sign, .strip, .handoff { border: 2px solid CanvasText; }
}
@media print {
  .rail, .command, .theme-toggle, .answer-actions, .report-actions { display: none; }
  /* With a report made, only the report prints: one page from the browser's own "Save as PDF". */
  body:has([data-report-view]:not([hidden])) main [data-workbench] > :not([data-report-view]),
  body:has([data-report-view]:not([hidden])) .drag-overlay, body:has([data-report-view]:not([hidden])) footer { display: none; }
  .report-view { border: 0; padding: 0; font-size: .8rem; }
  a[href^="http"]::after { content: " (" attr(href) ")"; }
}

/* Charts (DESIGN.md Charts): series colors by role, references muted and dashed. */
.chart { margin: var(--s4) 0; }
.chart svg { width: 100%; height: auto; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-field); }
.chart figcaption { color: var(--muted); font-size: .875rem; margin-top: var(--s2); }
.chart-grid line { stroke: var(--line); stroke-width: 1; }
.chart-axis text { fill: var(--muted); font: 500 11px "Overpass Mono", ui-monospace, Menlo, Consolas, monospace; }
.series { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.series-measured { stroke: var(--series-measured); }
.series-whatif { stroke: var(--series-whatif); }
.series-compare { stroke: var(--service); stroke-dasharray: 6 4; }
.heatmap svg { height: auto; }
.heat-0 { fill: var(--heat-0); } .heat-1 { fill: var(--heat-1); } .heat-2 { fill: var(--heat-2); }
.heat-3 { fill: var(--heat-3); } .heat-4 { fill: var(--heat-4); } .heat-5 { fill: var(--heat-5); }
.chart-highlight circle { fill: var(--series-measured); stroke: var(--panel); stroke-width: 2; }
.chart-highlight text { fill: var(--ink); font: 600 12px Overpass, system-ui, sans-serif; }
caption { text-align: left; color: var(--muted); font-size: .875rem; padding: var(--s2) 0; }

/* File workbench */
.dropzone { border: 2px dashed var(--field-border); border-radius: var(--r-field); padding: var(--s4); margin: var(--s4) 0; background: var(--panel); }
.dropzone p { margin: var(--s1) 0; }
.drag-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: color-mix(in srgb, var(--guide) 92%, transparent); color: var(--legend-white); font-size: 1.75rem; font-weight: 800; }
.drag-overlay[hidden] { display: none; }
.progress { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.progress[hidden], .errors[hidden] { display: none; }
.progress progress { flex: 1 1 200px; accent-color: var(--guide); }
.facts { display: flex; gap: var(--s5); flex-wrap: wrap; margin: var(--s3) 0; }
.facts dt { color: var(--muted); font-family: Overpass, system-ui, sans-serif; font-weight: 600; }
.facts dd { margin: 0; font-size: 1.125rem; }
.receipt div { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
@media (max-width: 480px) { .receipt div { grid-template-columns: 1fr; gap: var(--s1); } }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; }
/* Grid cells may shrink below their content, so a long option or file name wraps instead of widening the page. */
.receipt div > * { min-width: 0; }
.receipt-choice { display: flex; flex-direction: column; gap: var(--s1); }
.receipt-choice select { min-height: 44px; width: 100%; max-width: 100%; border: 1px solid var(--field-border); border-radius: var(--r-field); background: var(--panel); color: var(--ink); padding: 0 var(--s2); }
.receipt-privacy { color: var(--ok); font-weight: 600; display: flex; gap: var(--s2); align-items: center; }

/* Report dialog */
dialog.report { max-width: min(40rem, calc(100vw - 2 * var(--s4))); border: 1px solid var(--line); border-radius: var(--r-field); background: var(--panel); color: var(--ink); box-shadow: 0 8px 24px var(--shadow); padding: var(--s5); }
dialog.report::backdrop { background: color-mix(in srgb, var(--ink) 40%, transparent); }
dialog.report textarea { width: 100%; border: 1px solid var(--field-border); border-radius: var(--r-field); background: var(--panel); color: var(--ink); padding: var(--s2); font: inherit; }
.report-preview { background: var(--raise); padding: var(--s3); border-radius: var(--r-field); overflow-x: auto; white-space: pre-wrap; max-height: 16rem; }
.field-block { display: block; font-weight: 600; margin-bottom: var(--s1); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Source stamp and warning chip */
.source-stamp { color: var(--muted); }
.warning-chip { display: inline-flex; align-items: center; gap: var(--s1); background: var(--warning); color: var(--legend-black); border-radius: var(--r-pill); padding: 4px 10px; font-weight: 600; font-family: Overpass, system-ui, sans-serif; }
.warning-chip[hidden] { display: none; }
blockquote { border-left: 4px solid var(--line); margin: var(--s3) 0; padding: var(--s2) var(--s4); }

[data-health-row].stalled { color: var(--warning-text); font-weight: 700; }

/* Grid pulse: hidden below 768 px (DESIGN.md Layout) and absent until a snapshot exists. */
.pulse { display: none; margin: 0 0 0 auto; align-items: center; gap: var(--s2); color: var(--legend-white); font-size: .75rem; }
@media (min-width: 768px) { .pulse { display: flex; } .pulse + .theme-toggle { margin-left: var(--s3); } }

.cell-section { color: var(--muted); font-size: .875rem; font-weight: 600; margin: 0 0 var(--s1); }

/* Home: the tagline as a modest heading, and lanes close enough that both start on a phone's first screen. */
.home-title { font-size: 1.25rem; line-height: 1.3; margin: var(--s4) 0 var(--s2); }
.lane h2 { margin: var(--s4) 0 var(--s2); }
