/* ==========================================================================
   Civic Navigator — stylesheet

   Theme tokens are declared three times: once for light, then for OS-dark, then
   for an explicit [data-theme] stamp. Dark is a *selected* set of values, not an
   automatic inversion — each token is chosen against the dark surface.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #f2f5f8;
  --bg-accent: #eaf0f6;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --surface-3: #eef3f7;

  --ink: #16202b;
  --ink-soft: #55697a;
  --ink-muted: #7d8fa0;

  --line: #dde4ea;
  --line-soft: #ebf0f4;

  --accent: #1f5f8b;
  --accent-hover: #17486a;
  --accent-ink: #1f5f8b;
  --accent-soft: #e9f2f8;
  --on-accent: #ffffff;

  /* The masthead is a branded band, not a surface — it needs its own pair so
     dark mode can go deep-blue instead of inheriting the lightened accent. */
  --mast-from: #1f5f8b;
  --mast-to: #17486a;

  /* Status palette — fixed hues, never themed. Always paired with an icon and
     a text label: amber is sub-3:1 on a light surface by design, so colour is
     never the only channel carrying urgency. */
  --st-good: #0ca30c;
  --st-warn: #fab219;
  --st-crit: #d03b3b;

  /* Readable ink in each status family. Text wears an ink token, never the
     status hex — the coloured mark beside it carries the identity. */
  --ink-good: #006300;
  --ink-warn: #8a5a00;
  --ink-crit: #b3261e;

  --wash-good: #e9f5ee;
  --wash-warn: #fdf6e8;
  --wash-crit: #fdecea;
  --edge-good: #bcdfca;
  --edge-warn: #e8cf9a;
  --edge-crit: #f2c4c0;

  --mark-bg: #fff0c2;
  --mark-ink: #6b4b00;
  --mark-edge: #e6cf92;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 32, 43, 0.04), 0 1px 3px rgba(16, 32, 43, 0.06);
  --shadow-2: 0 2px 4px rgba(16, 32, 43, 0.04), 0 8px 24px rgba(16, 32, 43, 0.08);
  --ring: 0 0 0 3px rgba(31, 95, 139, 0.28);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- dark: OS preference (yields to an explicit light stamp) --------------- */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;

    --bg: #0d1218;
    --bg-accent: #101822;
    --surface: #161d24;
    --surface-2: #1b232c;
    --surface-3: #212b35;

    --ink: #eef3f7;
    --ink-soft: #a4b3c0;
    --ink-muted: #7d8c99;

    --line: #27323c;
    --line-soft: #1e2731;

    --accent: #3d8ec4;
    --accent-hover: #55a3d6;
    --accent-ink: #7cbde8;
    --accent-soft: #15293a;
    --on-accent: #06121c;

    --mast-from: #17384c;
    --mast-to: #0f2634;

    --ink-good: #3ec93e;
    --ink-warn: #f2c257;
    --ink-crit: #f08a8a;

    --wash-good: #10251a;
    --wash-warn: #2a2110;
    --wash-crit: #2a1616;
    --edge-good: #1f4a30;
    --edge-warn: #52411c;
    --edge-crit: #532727;

    --mark-bg: #3a2e0c;
    --mark-ink: #f5d98a;
    --mark-edge: #5c4a18;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
    --ring: 0 0 0 3px rgba(61, 142, 196, 0.4);
  }
}

/* --- dark: explicit toggle (wins over the OS both ways) ------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1218;
  --bg-accent: #101822;
  --surface: #161d24;
  --surface-2: #1b232c;
  --surface-3: #212b35;

  --ink: #eef3f7;
  --ink-soft: #a4b3c0;
  --ink-muted: #7d8c99;

  --line: #27323c;
  --line-soft: #1e2731;

  --accent: #3d8ec4;
  --accent-hover: #55a3d6;
  --accent-ink: #7cbde8;
  --accent-soft: #15293a;
  --on-accent: #06121c;

  --mast-from: #17384c;
  --mast-to: #0f2634;

  --ink-good: #3ec93e;
  --ink-warn: #f2c257;
  --ink-crit: #f08a8a;

  --wash-good: #10251a;
  --wash-warn: #2a2110;
  --wash-crit: #2a1616;
  --edge-good: #1f4a30;
  --edge-warn: #52411c;
  --edge-crit: #532727;

  --mark-bg: #3a2e0c;
  --mark-ink: #f5d98a;
  --mark-edge: #5c4a18;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(61, 142, 196, 0.4);
}

* {
  box-sizing: border-box;
}

/* Author `display` rules (e.g. .loading) outrank the UA [hidden] rule, so
   restate it here — otherwise hidden panels render on first paint. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- masthead ---------- */

.masthead {
  background: linear-gradient(150deg, var(--mast-from) 0%, var(--mast-to) 100%);
  color: #fff;
  padding: 26px 0 30px;
}

.masthead-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke: #fff;
}

.masthead h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.tagline {
  margin: 14px 0 0;
  max-width: 58ch;
  color: #d9e8f2;
  font-size: 0.95rem;
}

/* theme toggle */

.theme-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 7px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.24);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: var(--shadow-1);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.08rem;
  letter-spacing: -0.005em;
}

.panel-note {
  margin: 0 0 18px;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

main {
  padding-bottom: 8px;
}

/* ---------- examples ---------- */

.examples {
  margin: 0 0 22px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.examples-label {
  margin: 0 0 9px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 6px 13px;
  color: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.chip:active {
  transform: translateY(1px);
}

/* ---------- form ---------- */

.field {
  margin-bottom: 18px;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  color: inherit;
  background: var(--surface);
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.field.invalid input[type="text"],
.field.invalid textarea {
  border-color: var(--st-crit);
}

.field.invalid input[type="text"]:focus,
.field.invalid textarea:focus {
  box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.24);
}

.hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 0 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-crit);
}

.field-error svg {
  width: 14px;
  height: 14px;
  flex: none;
  stroke: currentColor;
}

/* live character counter */

.counter {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  flex: none;
}

.counter.short {
  color: var(--ink-warn);
}

.counter.near {
  color: var(--ink-warn);
  font-weight: 600;
}

.counter.over {
  color: var(--ink-crit);
  font-weight: 600;
}

.meter-track {
  height: 3px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.meter-fill.short {
  background: var(--st-warn);
}

.meter-fill.near {
  background: var(--st-warn);
}

/* actions row */

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 11px 20px;
  background: var(--accent);
  color: var(--on-accent);
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-1);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  flex: none;
}

.btn-secondary,
.btn-ghost {
  background: var(--surface);
  color: var(--accent-ink);
  border-color: var(--line);
  padding: 9px 16px;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-secondary svg,
.btn-ghost svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex: none;
}

.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-ghost {
  color: var(--ink-soft);
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--ink);
}

.kbd-hint {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

kbd {
  font: inherit;
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--wash-crit);
  color: var(--ink-crit);
  border: 1px solid var(--edge-crit);
  font-size: 0.89rem;
}

.form-error svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
  stroke: currentColor;
}

/* ---------- loading ---------- */

.loading-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.spinner {
  width: 20px;
  height: 20px;
  flex: none;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.98rem;
}

.elapsed {
  margin-left: auto;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  flex: none;
}

/* Indeterminate — the request is a single non-streaming call, so there is no
   real percentage to report. A travelling sheen says "working" without
   implying progress we cannot measure. */
.progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-indeterminate {
  height: 100%;
  width: 38%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: slide 1.5s ease-in-out infinite;
}

.stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.stage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.89rem;
  color: var(--ink-muted);
  transition: color 0.3s ease;
}

.stage-dot {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.stage-dot svg {
  width: 9px;
  height: 9px;
  stroke: var(--on-accent);
  stroke-width: 3.5;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stage.active {
  color: var(--ink);
  font-weight: 600;
}

.stage.active .stage-dot {
  border-color: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.stage.done {
  color: var(--ink-soft);
}

.stage.done .stage-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.stage.done .stage-dot svg {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(370%);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(31, 95, 139, 0.35);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(31, 95, 139, 0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.reveal {
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* ---------- results ---------- */

.result-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0 0;
}

.result-bar h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

/* Programmatic focus target: focused on render so screen readers land on the
   result. Not keyboard-reachable, so it needs no visible ring. */
.result-bar h2:focus {
  outline: none;
}

.result-bar .spacer {
  margin-left: auto;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: var(--surface-2);
}

.stat .k {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.stat .k svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  flex: none;
}

.stat .v {
  font-weight: 600;
  line-height: 1.35;
}

/* urgency — shape + label + colour, so colour is never the only channel */

.urgency-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.urgency-row svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.urgency-label {
  font-weight: 700;
}

.urgency-high .urgency-row svg {
  stroke: var(--st-crit);
}
.urgency-high .urgency-label {
  color: var(--ink-crit);
}
.urgency-medium .urgency-row svg {
  stroke: var(--st-warn);
}
.urgency-medium .urgency-label {
  color: var(--ink-warn);
}
.urgency-low .urgency-row svg {
  stroke: var(--st-good);
}
.urgency-low .urgency-label {
  color: var(--ink-good);
}

/* three-segment ordinal indicator */
.urgency-steps {
  display: flex;
  gap: 3px;
  margin-top: 9px;
}

.urgency-steps span {
  height: 4px;
  flex: 1;
  border-radius: 999px;
  background: var(--surface-3);
}

.urgency-high .urgency-steps span.on {
  background: var(--st-crit);
}
.urgency-medium .urgency-steps span.on {
  background: var(--st-warn);
}
.urgency-low .urgency-steps span.on {
  background: var(--st-good);
}

.reason {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* readiness callout — the honesty signal */

.readiness {
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
  border: 1px solid;
  box-shadow: var(--shadow-1);
}

.readiness.ok {
  background: var(--wash-good);
  border-color: var(--edge-good);
}

.readiness.warn {
  background: var(--wash-warn);
  border-color: var(--edge-warn);
}

.readiness-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.readiness-head svg {
  width: 19px;
  height: 19px;
  flex: none;
}

.readiness h3 {
  margin: 0;
  font-size: 1rem;
}

.readiness.warn svg {
  stroke: var(--st-warn);
}

.readiness.warn h3 {
  color: var(--ink-warn);
}

.readiness.ok svg {
  stroke: var(--st-good);
}

.readiness.ok h3 {
  color: var(--ink-good);
}

.readiness p {
  margin: 0 0 12px;
  font-size: 0.91rem;
}

.readiness ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.readiness li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 0.9rem;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.readiness li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--st-warn);
}

.readiness.ok li::before {
  background: var(--st-good);
}

/* draft */

.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.draft-head h2 {
  margin: 0;
}

.provisional {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-warn);
  background: var(--wash-warn);
  border: 1px solid var(--edge-warn);
  border-radius: 999px;
  padding: 3px 11px;
}

.panel.provisional-draft {
  border-style: dashed;
  border-color: var(--edge-warn);
}

/* placeholder progress */

.fill-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 13px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  background: var(--wash-warn);
  border: 1px solid var(--edge-warn);
  color: var(--ink-warn);
  font-weight: 500;
}

.fill-status svg {
  width: 15px;
  height: 15px;
  flex: none;
  stroke: currentColor;
}

.fill-status.complete {
  background: var(--wash-good);
  border-color: var(--edge-good);
  color: var(--ink-good);
}

.letter {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.75;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin: 0 0 14px;
  overflow-wrap: break-word;
}

/* Placeholders the model deliberately left blank become real inputs, so the
   citizen fills the letter in place instead of hunting through it in an editor.
   Selector is `.letter input.ph` so it outranks the global
   `input[type="text"]` rule, which would otherwise force these to full width. */
.letter input.ph {
  display: inline;
  width: auto;
  font: inherit;
  font-family: var(--mono);
  font-size: inherit;
  font-weight: 600;
  line-height: inherit;
  color: var(--mark-ink);
  background: var(--mark-bg);
  border: 1px solid var(--mark-edge);
  border-radius: 4px;
  padding: 0 4px;
  min-width: 4ch;
  vertical-align: baseline;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.letter input.ph::placeholder {
  color: var(--mark-ink);
  opacity: 0.72;
  font-weight: 600;
}

.letter input.ph:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.letter input.ph.filled {
  background: var(--wash-good);
  border-color: var(--edge-good);
  color: var(--ink-good);
}

.draft-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* steps */

ol.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 11px;
}

ol.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.92rem;
}

ol.steps li::before {
  content: counter(step);
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-ink);
  font-weight: 500;
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

.links svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex: none;
}

details.raw {
  margin: 20px 0 0;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

details.raw summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.raw summary::-webkit-details-marker {
  display: none;
}

details.raw summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

details.raw[open] summary::before {
  transform: rotate(90deg);
}

details.raw pre {
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.76rem;
  line-height: 1.6;
  margin: 14px 0 0;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 17px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.87rem;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: rise 0.25s ease both;
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: none;
  stroke: currentColor;
}

.toast.leaving {
  animation: fade 0.25s ease both;
}

@keyframes fade {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- footer ---------- */

.footer {
  padding: 14px 20px 44px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.footer p {
  max-width: 64ch;
  margin: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .masthead h1 {
    font-size: 1.3rem;
  }

  .panel {
    padding: 18px;
  }

  .theme-toggle span {
    display: none;
  }

  .theme-toggle {
    padding: 8px;
  }

  .kbd-hint {
    display: none;
  }

  .form-actions button {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ---------- motion & contrast preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .spinner {
    animation: spin 2.4s linear infinite !important;
  }

  .progress-indeterminate {
    width: 100%;
    animation: none !important;
    opacity: 0.5;
  }
}

@media (prefers-contrast: more) {
  .panel,
  .stat,
  .letter {
    border-color: var(--ink-soft);
  }
}

/* ---------- print: the letter, nothing else ---------- */

@media print {
  .masthead,
  .examples,
  #complaint-form,
  #loading,
  .result-bar,
  .draft-actions,
  details.raw,
  .footer,
  .toasts,
  .fill-status {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .panel,
  .readiness {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0 0 18px;
  }

  .letter {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 11pt;
  }

  .letter input.ph {
    background: transparent;
    border: none;
    border-bottom: 1px solid #000;
    border-radius: 0;
    color: #000;
  }
}
