/*
 * Common Ground
 *
 * The page is an instrument, not a landing page. The first view is the live
 * decision: the exact fixed budget, what is currently unmet, and the control
 * that asks the agent for a feasible compromise.
 *
 * Rules this sheet holds itself to:
 *   - Nothing functional renders below 12px, at any viewport.
 *   - Every interactive target is at least 44x44 on touch.
 *   - Display tracking never goes below -0.02em; letters keep their shapes.
 *   - Motion is state-bound only. Nothing animates because it is pretty, and
 *     everything stops under prefers-reduced-motion.
 *   - Exact figures live in DOM text, never in a background or a pseudo-element.
 */

:root {
  color-scheme: dark;

  --ink: #f3f3e9;
  --muted: #bfd1cb;          /* raised for AA on every surface below */
  --muted-soft: #9fb8b0;     /* decorative only, never load-bearing text */
  --line: rgba(169, 225, 207, 0.2);
  --line-strong: rgba(169, 225, 207, 0.38);
  --surface: rgba(9, 42, 36, 0.82);
  --surface-strong: #10342d;
  --surface-deep: #061918;
  --well: #071f1c;

  --lime: #8be3b9;
  --lime-dark: #123b31;
  --orange: #f2b36f;
  --red: #ff8174;
  --blue: #82d0f5;
  --violet: #bea9f8;

  --radius: 18px;
  --radius-sm: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  --display: Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* Type ramp. 12 is the floor and it is never crossed. */
  --t-micro: 12px;
  --t-small: 13px;
  --t-body: 15px;
  --t-lead: 17px;
  --t-h3: 22px;
  --t-h2: 30px;
  --t-figure: clamp(34px, 5.6vw, 60px);

  font-family: var(--sans);
  background: var(--surface-deep);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  /* Do not hide horizontal overflow at the document boundary: that clipped the
     skip link and masked layout bugs. The wide table keeps its own scroller;
     the narrow header below wraps its status instead of widening the page. */
  font-size: var(--t-body);
  line-height: 1.55;
  background:
    radial-gradient(ellipse at 12% -8%, rgba(50, 194, 151, 0.2), transparent 38rem),
    radial-gradient(ellipse at 88% 3%, rgba(63, 151, 184, 0.13), transparent 34rem),
    linear-gradient(158deg, #051714 0%, #092822 48%, #061715 100%);
  background-attachment: fixed;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }

.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;
}

.skip-link {
  position: fixed; top: -4rem; left: 1rem; z-index: 20;
  min-height: 44px; display: inline-flex; align-items: center;
  padding: 0.75rem 1rem; border-radius: 0 0 10px 10px;
  background: var(--lime); color: #0a160e; font-weight: 700;
}
.skip-link:focus { top: 0; }

/* ---------- header ---------- */

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 72px; gap: 1rem; border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 0.7rem;
  min-height: 44px; text-decoration: none;
  font-family: var(--display); font-size: var(--t-lead);
  font-weight: 700; letter-spacing: -0.015em;
}
.brand-mark {
  display: inline-grid; grid-template-columns: repeat(3, 5px); gap: 3px;
  align-items: end; width: 28px; height: 27px; padding: 5px;
  border: 1px solid rgba(139, 227, 185, 0.58); border-radius: 9px 9px 3px 3px;
}
.brand-mark i { display: block; background: var(--lime); border-radius: 3px 3px 2px 2px; }
.brand-mark i:nth-child(1) { height: 8px; opacity: 0.6; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; opacity: 0.8; }

.header-meta { display: flex; align-items: center; gap: 0.75rem; }

.step-label, .kicker {
  letter-spacing: 0.1em; text-transform: uppercase;
  font-family: var(--mono); font-size: var(--t-micro); color: var(--muted);
}
.kicker { margin: 0 0 0.6rem; color: var(--lime); }

.status-chip, .state-label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 28px; padding: 0.3rem 0.65rem;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); font-size: var(--t-micro); font-family: var(--mono);
  white-space: nowrap;
}
.status-chip::before, .state-label::before {
  content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor;
}
.status-chip.ready { color: var(--lime); border-color: rgba(139, 227, 185, 0.48); }
.status-chip.pending { color: var(--orange); }
.status-chip.unavailable { color: var(--muted); }

/* ---------- headings ---------- */

h1, h2, h3, p { margin-top: 0; }
h2 {
  font-family: var(--display); font-size: var(--t-h2);
  line-height: 1.1; letter-spacing: -0.02em; font-weight: 500;
  margin-bottom: 0.7rem;
}
h3 { font-family: var(--display); font-size: var(--t-h3); line-height: 1.15; letter-spacing: -0.015em; font-weight: 500; }

/* ---------- the ledger: first view ---------- */

/* Civic ledger field.
   One scenic raster, used as depth behind the instrument and nothing else.
   It sits under a heavy dark wash so every figure above it keeps its measured
   contrast, and it is decorative: no value, label or state is carried by it. */
.studio {
  padding: clamp(1.75rem, 4vw, 3rem) 0 3rem;
  background-image:
    linear-gradient(180deg, rgba(6,25,24,0.46) 0%, rgba(6,25,24,0.82) 52%, var(--surface-deep) 100%),
    url("assets/civic-ledger-field.png");
  /* The section is far taller than the image. `cover` therefore scaled it up
     ~3x and showed only its near-black top corner. Sizing to the container
     width instead shows the actual contour band, and the gradient above it
     fades the field out before the content that needs contrast. */
  background-size: cover, 100% auto;
  background-position: center top, center top;
  background-repeat: no-repeat, no-repeat;
}

.ledger-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem 2.5rem; align-items: end; margin-bottom: 1.4rem;
}
.ledger-caption { margin: 0 0 0.3rem; color: var(--muted); font-size: var(--t-small); }
.ledger-total {
  display: block; font-family: var(--display); font-size: var(--t-figure);
  line-height: 1.02; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.state-message { margin: 0.7rem 0 0; max-width: 54ch; color: var(--muted); font-size: var(--t-small); line-height: 1.5; }

.readouts { display: flex; flex-wrap: wrap; gap: 1.6rem; margin: 0; }
.readouts div { display: flex; flex-direction: column; gap: 0.3rem; }
.readouts dt { font-family: var(--mono); font-size: var(--t-micro); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.readouts dd { margin: 0; font-family: var(--mono); font-size: var(--t-lead); font-variant-numeric: tabular-nums; }

/* One coherent ledger field: the meter and the commitment split read as a
   single object, because they describe one number. */
.ledger-field {
  padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.meter-label {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-bottom: 0.6rem; color: var(--muted); font-size: var(--t-small);
}
.meter-label output { color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.meter {
  height: 14px; overflow: hidden; border-radius: 999px;
  background: rgba(3, 11, 7, 0.65); box-shadow: inset 0 1px 3px rgba(0,0,0,0.45);
}
/* State-bound: width changes only because the total changed. */
.meter span {
  display: block; width: 100%; height: 100%; border-radius: inherit;
  transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, var(--lime), #72cfe0);
  transition: transform 360ms ease, background 300ms ease;
}
.meter.over span { background: linear-gradient(90deg, var(--orange), var(--red)); }

.commitment-field { display: flex; gap: 2px; height: 26px; margin-top: 0.75rem; border-radius: 6px; overflow: hidden; }
.commitment-field i { display: block; height: 100%; }
.commitment-field i:nth-child(1) { background: var(--lime); }
.commitment-field i:nth-child(2) { background: var(--blue); }
.commitment-field i:nth-child(3) { background: var(--violet); }
.commitment-field i:nth-child(4) { background: var(--orange); }
.commitment-field i:nth-child(5) { background: #7fd6a6; }

.ledger-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.2rem 0 1.6rem; }
.opening-handoff { margin-bottom: 1.6rem; }

/* ---------- buttons: 44px minimum, everywhere ---------- */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.7rem 1.15rem;
  border: 1px solid transparent; border-radius: 999px;
  text-decoration: none; font-size: var(--t-small); font-weight: 700; line-height: 1.2;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { background: var(--lime); color: #071a16; }
.button-primary:hover:not(:disabled) { background: #a5f0cd; }
.button-secondary { border-color: rgba(139, 227, 185, 0.68); background: transparent; color: var(--lime); }
.button-secondary:hover:not(:disabled) { background: rgba(139, 227, 185, 0.11); }
.button-quiet { border-color: var(--line-strong); color: var(--ink); }
.button-quiet:hover:not(:disabled) { background: rgba(255,255,255,0.05); }
.button-warn { border-color: rgba(242, 179, 111, 0.68); color: #f8c997; background: rgba(242, 179, 111, 0.07); }
.button-warn:hover:not(:disabled) { background: rgba(242, 179, 111, 0.15); }

/* ---------- decision record ---------- */

.decision-record {
  padding: 20px; margin-bottom: 1.6rem;
  border: 1px solid rgba(242, 179, 111, 0.48); border-radius: var(--radius);
  background: rgba(242, 179, 111, 0.08);
}
.decision-record.accepted { border-color: rgba(139, 227, 185, 0.48); background: rgba(139, 227, 185, 0.08); }
.decision-record h2 { margin: 0 0 0.5rem; }
.decision-record p { margin: 0; font-size: var(--t-small); line-height: 1.55; color: var(--ink); }
.decision-revision { margin-top: 0.5rem !important; font-family: var(--mono); font-size: var(--t-micro); color: var(--muted); }

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

.panel, .allocation-panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(15, 57, 48, 0.9), rgba(7, 30, 27, 0.82));
  padding: 24px;
}
.panel-topline {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem; color: var(--muted); font-size: var(--t-micro);
}
.panel-topline .step-label { color: var(--lime); }
.panel h2 { margin-bottom: 0.75rem; }
.panel-footnote { margin: 1.1rem 0 0; color: var(--muted); font-size: var(--t-small); }

.floor-panel { margin-bottom: 1rem; }
.floor-list { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.floor-item { padding: 0.85rem 0.95rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(2, 12, 7, 0.22); }
.floor-title { display: flex; justify-content: space-between; gap: 0.7rem; align-items: baseline; flex-wrap: wrap; }
.floor-title strong { font-size: var(--t-small); }
.floor-title output { color: var(--blue); font-family: var(--mono); font-size: var(--t-micro); font-variant-numeric: tabular-nums; }
.floor-item.failed .floor-title output { color: var(--orange); }
.floor-detail { margin: 0.45rem 0 0; color: var(--muted); font-size: var(--t-micro); line-height: 1.45; }
.floor-state { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.6rem; font-family: var(--mono); font-size: var(--t-micro); color: var(--lime); }
.floor-state::before { content: "✓"; font-weight: 800; }
.floor-item.failed .floor-state { color: var(--orange); }
.floor-item.failed .floor-state::before { content: "!"; }

/* ---------- allocation table ---------- */

.allocation-panel { margin-top: 1rem; }
.allocation-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 340px); gap: 1.2rem; align-items: end; margin-bottom: 1.2rem; }
.allocation-heading h2 { margin: 0; }
.allocation-heading p { margin: 0; color: var(--muted); font-size: var(--t-small); line-height: 1.5; }

.table-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); padding: 12px; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th, td { padding: 0.85rem 0.95rem; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(225, 244, 218, 0.09); }
tbody tr:last-child td { border-bottom: 0; }
th {
  color: var(--muted); font-family: var(--mono); font-size: var(--t-micro);
  font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  background: rgba(4, 14, 9, 0.35);
}
td { color: var(--ink); font-size: var(--t-small); line-height: 1.45; }
.proposal-code { display: block; margin-bottom: 0.3rem; color: var(--lime); font-family: var(--mono); font-size: var(--t-micro); letter-spacing: 0.07em; }
.proposal-name { font-weight: 700; }
.proposal-description { display: block; max-width: 34ch; color: var(--muted); font-size: var(--t-micro); }
.reference { color: var(--muted); font-family: var(--mono); font-size: var(--t-micro); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 44px steppers and a 44px field: this is a money control on a phone. */
.allocation-control { display: flex; align-items: center; gap: 0.4rem; }
.allocation-control button {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: rgba(255,255,255,0.03); color: var(--ink); font-size: var(--t-lead);
}
.allocation-control button:hover { border-color: rgba(139,227,185,0.62); color: var(--lime); }
.allocation-control input {
  width: 118px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--well); color: var(--ink); text-align: right;
  padding: 0.4rem 0.55rem; font-family: var(--mono); font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}
.allocation-control input[aria-invalid="true"] { border-color: var(--orange); color: #ffd6ae; }
.form-feedback { min-height: 1.4rem; margin: 0.85rem 0 0; color: var(--orange); font-size: var(--t-small); }
.form-feedback.ok { color: var(--lime); }

/* ---------- architecture strip ---------- */

.architecture { padding: 2rem 0 1rem; }
.architecture h2 { margin-bottom: 1rem; }
.arch-steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.8rem; margin: 0; padding: 0; list-style: none; counter-reset: none;
}
.arch-steps li {
  display: grid; gap: 0.35rem; align-content: start;
  padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(4, 14, 9, 0.3);
}
.arch-n { font-family: var(--mono); font-size: var(--t-micro); color: var(--lime); }
.arch-steps strong { font-size: var(--t-small); color: var(--ink); }
.arch-steps span:not(.arch-n) { font-size: var(--t-micro); color: var(--muted); line-height: 1.5; }
.arch-steps code { color: var(--blue); font-family: var(--mono); font-size: var(--t-micro); }

/* ---------- collaboration ---------- */

.collaboration-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1.5rem; }
.compromise-panel p { max-width: 56ch; color: var(--muted); font-size: var(--t-small); line-height: 1.55; }
.compromise-summary {
  margin-top: 1.1rem; padding: 0.95rem;
  border: 1px solid rgba(139, 227, 185, 0.28); border-radius: var(--radius-sm);
  background: rgba(139,227,185,0.07);
}
.compromise-summary p { margin-bottom: 0.5rem; color: var(--ink); font-size: var(--t-small); }
.compromise-summary ul {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.4rem 1rem; margin: 0.7rem 0 0; padding: 0; list-style: none;
  color: var(--ink); font-family: var(--mono); font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
}
.compromise-summary li { display: flex; justify-content: space-between; gap: 0.5rem; }
.delta-positive { color: var(--lime); }
.delta-negative { color: var(--orange); }

/* ---------- protect a commitment ----------
 *
 * Same ledger language as the decision record: a bordered well, exact figures
 * as DOM text, and colour carrying one meaning only. Blue is "priced, pending
 * a person"; orange is "no allocation does this"; lime stays reserved for
 * something a human actually accepted.
 */

.protect-copy { margin: 0 0 1.1rem; color: var(--muted); font-size: var(--t-small); line-height: 1.6; }

.protect-controls {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.9rem; margin-bottom: 1rem;
}
.protect-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.protect-field label { font-size: var(--t-micro); color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.protect-field select,
.protect-field input {
  min-height: 44px; width: 100%; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--well); color: var(--ink);
  font-family: var(--mono); font-size: var(--t-small);
}
.protect-field select:focus-visible,
.protect-field input:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.protect-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.protect-result {
  margin-top: 1.1rem; padding: 18px;
  border: 1px solid rgba(151, 219, 255, 0.45); border-radius: var(--radius);
  background: rgba(151, 219, 255, 0.07);
}
.protect-result.refused { border-color: rgba(242, 179, 111, 0.48); background: rgba(242, 179, 111, 0.08); }
.protect-result p { margin: 0 0 0.6rem; font-size: var(--t-small); line-height: 1.55; color: var(--ink); }
.protect-result .step-label { display: block; margin: 1rem 0 0.45rem; }
.protect-verdict { font-size: var(--t-body); line-height: 1.5; }
.protect-proof { font-family: var(--mono); font-size: var(--t-micro); color: var(--muted); }
.protect-note { margin-bottom: 0 !important; font-size: var(--t-micro); color: var(--muted); }

.protect-losers, .protect-floors { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.4rem; }
.protect-losers li, .protect-floors li {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(2, 12, 7, 0.22); font-size: var(--t-small);
}
.protect-losers li strong, .protect-floors li strong { font-family: var(--mono); font-size: var(--t-small); }
.protect-floors li.met strong { color: var(--lime); }
.protect-floors li.failed strong { color: var(--orange); }
.protect-floors li em { flex-basis: 100%; font-style: normal; font-size: var(--t-micro); color: var(--muted); }

.decision-record.pending { border-color: rgba(151, 219, 255, 0.45); background: rgba(151, 219, 255, 0.07); }
.compromise-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.3rem; }

.activity-log { display: grid; gap: 0.7rem; max-height: 300px; overflow: auto; margin: 1.1rem 0 0; padding: 0; list-style: none; }
.activity-log li {
  display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.7rem;
  padding-bottom: 0.7rem; border-bottom: 1px solid rgba(225, 244, 218, 0.1);
}
.activity-log li:last-child { border-bottom: 0; }
.log-index {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem;
  border: 1px solid rgba(139, 227, 185, 0.38); border-radius: 8px;
  color: var(--lime); font-family: var(--mono); font-size: var(--t-micro);
}
.log-copy strong { display: block; color: var(--ink); font-size: var(--t-small); }
.log-copy span { display: block; margin-top: 0.25rem; color: var(--muted); font-size: var(--t-micro); line-height: 1.5; }
.log-copy code { color: var(--blue); font-family: var(--mono); font-size: var(--t-micro); }

/* ---------- tools ---------- */

.tools-section { padding: 2.5rem 0 3.5rem; }
.section-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 330px); gap: 2rem; align-items: end; margin-bottom: 1.4rem; }
.section-caption { margin: 0; color: var(--muted); font-size: var(--t-small); line-height: 1.55; }
.tools-heading code { color: var(--blue); font-size: var(--t-micro); }
.tool-catalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 0.8rem; }
.tool-card {
  display: flex; flex-direction: column; min-height: 170px; padding: 1.1rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(10, 27, 18, 0.75);
}
.tool-card header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem; align-items: start; }
.tool-card code { color: var(--lime); font-family: var(--mono); font-size: var(--t-small); line-height: 1.35; word-break: normal; overflow-wrap: anywhere; }
.tool-mode {
  flex: 0 0 auto; padding: 0.25rem 0.5rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--muted); font-family: var(--mono); font-size: var(--t-micro); text-transform: uppercase;
}
.tool-card p { margin: 0.8rem 0; color: var(--muted); font-size: var(--t-micro); line-height: 1.5; }
.tool-schema { margin-top: auto; color: var(--muted); font-family: var(--mono); font-size: var(--t-micro); line-height: 1.5; }

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

.closing-note {
  max-width: 720px; margin-bottom: 3.5rem; padding: 1.15rem 0 0 1.15rem;
  border-left: 1px solid rgba(139, 227, 185, 0.64);
  color: var(--muted); font-size: var(--t-small); line-height: 1.55;
}
.closing-note strong { color: var(--ink); }

.site-footer {
  display: flex; justify-content: space-between; gap: 1.4rem;
  padding: 1.7rem 0 2.3rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: var(--t-micro); line-height: 1.5;
}
.site-footer span:last-child { max-width: 40ch; text-align: right; }

/* ---------- state-bound change signal ----------
   Fires only when a value actually changed, applied by app.js. Nothing here
   animates on its own. */
.changed { animation: settle 620ms ease-out; }
@keyframes settle {
  0% { color: var(--lime); }
  100% { color: inherit; }
}

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

@media (max-width: 900px) {
  .ledger-head { grid-template-columns: 1fr; align-items: start; }
  .section-heading, .allocation-heading { grid-template-columns: 1fr; }
  .collaboration-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 28px, 1180px); }
  .site-header { min-height: 64px; flex-wrap: wrap; padding-block: 0.65rem; }
  .brand { min-width: 0; }
  .header-meta { min-width: 0; max-width: 100%; }
  .status-chip {
    max-width: 100%; white-space: normal; text-align: center;
    overflow-wrap: anywhere;
  }
  .readouts { gap: 1.1rem 1.6rem; }
  .site-footer { flex-direction: column; }
  .site-footer span:last-child { text-align: left; max-width: none; }
  .button { width: 100%; }
  .ledger-actions, .compromise-actions, .protect-actions { align-items: stretch; }
  .protect-controls { grid-template-columns: 1fr; }
  .allocation-control input { width: 100%; min-width: 96px; }
}

@media (max-width: 420px) {
  .site-header { align-items: stretch; }
  .header-meta { width: 100%; }
  .status-chip { width: 100%; justify-content: center; }
}

/* ---------- commitment cards on a phone ---------- */

/*
  The 44px steppers above were already built for a phone, but `table` carried a
  780px floor, so at 390px the "Your allocation" column sat off-screen inside
  .table-scroll and the primary control of the product was unreachable without
  horizontally scrolling a nested container. Stacking each row into a card
  finishes the work the 620px rules had already started.

  Dropping table display semantics costs no information here: every input keeps
  its own aria-label ("Allocation for Night Routes in dollars") and an
  aria-describedby pointing at the row's description, so the two cells whose
  meaning came only from the header row get visible ::before labels instead.
*/
@media (max-width: 620px) {
  .table-scroll { overflow-x: visible; padding: 0; border: 0; }
  table { min-width: 0; }
  thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }
  tbody tr {
    display: block; padding: 0.95rem; margin-bottom: 0.8rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
  }
  tbody tr:last-child { margin-bottom: 0; }
  tbody td { display: block; padding: 0.45rem 0; border-bottom: 0; }
  tbody td:first-child { padding-top: 0; }
  tbody td:last-child { padding-bottom: 0; }
  .proposal-description { max-width: none; }
  tbody td:nth-child(3)::before,
  tbody td:nth-child(4)::before {
    display: block; margin-bottom: 0.4rem;
    color: var(--muted); font-family: var(--mono); font-size: var(--t-micro);
    font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  }
  tbody td:nth-child(3)::before { content: "Your allocation"; }
  tbody td:nth-child(4)::before { content: "Human starting point"; }
}

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

@media (prefers-contrast: more) {
  :root { --line: rgba(245,255,240,0.55); --line-strong: rgba(245,255,240,0.7); --muted: #e2eddf; }
  .panel, .allocation-panel, .tool-card, .arch-steps li { background: #082a24; }
  .button-secondary, .button-quiet { border-color: #f0f8ed; }
}
