/* app.css — layout and components. Every colour, size, font and radius comes
   from design.css; change the look there. The markup is plain and semantic,
   so the Tailwind pass (`docs/operations.md`, weeks 11–12) changes classes
   and not structure. Phone breakpoint: 760px. */

/* ── Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Header, main, footer in a column at least as tall as the window, so the
     footer sits at the bottom of a short page instead of halfway up it. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img { max-width: 100%; }

a { color: var(--brand); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--brand-strong); }

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  line-height: var(--leading-tight);
  color: var(--brand);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: var(--text-3xl); margin: 0 0 var(--space-4); }
h2 { font-size: var(--text-2xl); margin: var(--space-7) 0 var(--space-4); }
h3 { font-size: var(--text-xl); margin: var(--space-5) 0 var(--space-2); }
p { margin: 0 0 var(--space-4); }

.lede { font-size: var(--text-lg); color: var(--muted); line-height: 1.6; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: var(--text-sm); }
.small { font-size: var(--text-xs); }
.center { text-align: center; }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--sky);
  margin: 0 0 var(--space-3);
}

/* ── Header ───────────────────────────────────────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-inner {
  max-width: var(--width-page);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

/* The pilot notice under the header (`sargasso/pilot.py`): one quiet line
   on every public page, gone once the pilot ends. */
.pilot-strip {
  background: var(--brand-soft);
  border-bottom: 1px solid var(--line);
}
.pilot-strip p {
  max-width: var(--width-page);
  margin: 0 auto;
  padding: var(--space-2) var(--gutter);
  font-size: var(--text-sm);
  color: var(--ink);
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
  margin: 0;
}
.wordmark:hover { color: var(--brand); }

.site-nav { display: flex; align-items: center; gap: var(--space-6); }
.site-nav a:not(.button), .menu nav a:not(.button) {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: border-color var(--transition), color var(--transition);
}
.site-nav a:not(.button):hover { color: var(--brand); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--sky); color: var(--brand); }

/* The phone menu: a <details>, so it opens without JavaScript. */
.menu { display: none; position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  width: var(--control-height);
  height: var(--control-height);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary span, .menu summary span::before, .menu summary span::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  position: relative;
  content: "";
  transition: transform var(--transition);
}
.menu summary span::before { position: absolute; top: -7px; }
.menu summary span::after { position: absolute; top: 7px; }
.menu[open] summary span { background: transparent; }
.menu[open] summary span::before { transform: translateY(7px) rotate(45deg); }
.menu[open] summary span::after { transform: translateY(-7px) rotate(-45deg); }
.menu nav {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  width: min(18rem, calc(100vw - 2 * var(--gutter)));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.menu nav a:not(.button) { font-size: var(--text-md); }
.menu nav a[aria-current="page"] { color: var(--brand); font-weight: var(--weight-strong); }
.menu nav .button { margin-top: var(--space-2); }

.console-nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-items: baseline; font-size: var(--text-sm); }

/* ── Buttons ──────────────────────────────────────────────────────── */

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--button-padding-x);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  line-height: 1;
  text-decoration: none;
  border-radius: var(--radius-pill);
  border: 2px solid var(--brand);
  background: var(--brand);
  color: var(--on-dark);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.button:hover, button:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-dark); }
.button:active, button:active { transform: translateY(1px); }

/* The public call to action, and the form's submit, are the action colour. */
a.button, form[action="/submit"] button[type="submit"] { background: var(--action); border-color: var(--action); }
a.button:hover, form[action="/submit"] button[type="submit"]:hover { background: var(--action-strong); border-color: var(--action-strong); }

form[action="/submit"] button[type="submit"] { min-height: 3.25rem; padding: 0 2.2rem; font-size: var(--text-md); }
.button.small { min-height: 2.5rem; padding: 0 1.1rem; }
.button.large { min-height: 3.25rem; padding: 0 1.8rem; font-size: var(--text-md); }
.button.ghost { background: transparent; border-color: currentColor; color: var(--on-dark); }
.button.ghost:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--on-dark); }

button.danger { background: var(--surface); color: var(--warn); border-color: var(--warn); }
button.danger:hover { background: var(--warn-soft); color: var(--warn); }
button.linkish {
  min-height: 0;
  background: none;
  border: none;
  color: var(--brand);
  padding: 0 var(--space-1);
  font-weight: 500;
  text-decoration: underline;
}
button.linkish:hover { background: none; color: var(--brand-strong); }
button.linkish.danger { color: var(--warn); }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.more { font-weight: var(--weight-strong); text-decoration: none; }
.more::after { content: " →"; }

/* ── Default page: one reading column (form, email landing pages, console) ── */

main { flex: 1 0 auto; width: 100%; max-width: var(--width-text); margin: 0 auto; padding: var(--space-8) var(--gutter) var(--space-9); }
body:has(.console-nav) main { max-width: var(--width-console); padding-top: var(--space-6); }
body:has(.console-nav) .bar-inner, body:has(.console-nav) .footer-inner { max-width: var(--width-console); }
body:has(.console-nav) main h1 { font-size: var(--text-2xl); }
body:has(.console-nav) main h2 { font-size: var(--text-xl); margin-top: var(--space-6); }

/* ── Public pages: full-width sections ────────────────────────────── */

main.site { max-width: none; padding: 0; }
.container { max-width: var(--width-page); margin: 0 auto; padding: 0 var(--gutter); }
.container.narrow { max-width: var(--width-text); }
/* Text at reading width, but on the page's left edge, under the page head. */
.container.prose > * { max-width: var(--width-text); }
.container.prose > h2:first-child { margin-top: 0; }
.section { padding: var(--section-y) 0; }
.section.tinted { background: var(--brand-soft); }
.section-head { max-width: var(--width-text); margin: 0 auto var(--space-7); text-align: center; }
.section-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--space-8); align-items: center; }
.split h2 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }

.page-head {
  padding: var(--space-8) 0 var(--space-7);
  background: linear-gradient(180deg, var(--brand-soft), var(--page));
}
.page-head .container > * { max-width: var(--width-text); }
.page-head + .section { padding-top: var(--space-4); }
.grid-2 + .center { margin-top: var(--space-6); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}
.panel h3:first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

.hero {
  position: relative;
  color: var(--on-dark);
  background:
    linear-gradient(90deg, rgba(6, 34, 44, 0) 15%, var(--photo-shade) 55%),
    var(--brand-strong) url("/static/img/hero.jpg") 30% center / cover no-repeat;
  min-height: min(38rem, 80vh);
  display: flex;
  align-items: center;
  padding: var(--space-9) 0;
}
.hero-inner { width: 100%; display: flex; justify-content: flex-end; }
.hero-copy { max-width: 34rem; }
.hero h1 { font-size: var(--text-hero); color: var(--on-dark); margin-bottom: var(--space-5); }
.hero .eyebrow { color: var(--sky-soft); }
.hero-lede { font-size: var(--text-lg); color: var(--on-dark); opacity: 0.92; margin-bottom: var(--space-6); }

ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 var(--space-6); }
ol.steps li {
  counter-increment: step;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
ol.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: var(--space-4);
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
}
ol.steps h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
ol.steps p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
/* An odd step out, the last, takes the whole row rather than sitting alone. */
ol.steps.grid-2 li:last-child:nth-child(odd) { grid-column: 1 / -1; }


.figure {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: 0 0 var(--space-7);
}


/* Logos in greyscale on the home page, in colour on hover. */
ul.logo-strip {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-6) var(--space-5);
  align-items: center;
}
ul.logo-strip img {
  display: block;
  margin: 0 auto;
  height: 44px;
  width: 100%;
  max-width: 9.5rem;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.7;
  mix-blend-mode: multiply; /* a logo's white box disappears into the page */
  transition: filter var(--transition), opacity var(--transition);
}
ul.logo-strip li:hover img { filter: none; opacity: 1; }

ul.logos {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-5);
}
ul.logos li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  transition: box-shadow var(--transition), transform var(--transition);
}
ul.logos li:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
ul.logos img { height: 64px; width: 100%; max-width: 12rem; object-fit: contain; margin-bottom: var(--space-2); }
.logo-name { font-weight: var(--weight-strong); line-height: 1.35; }
/* An organisation listed without a logo: its initial, so no card has a hole. */
.monogram {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
}
.logo-text { display: block; text-align: center; font-weight: var(--weight-strong); color: var(--muted); font-size: var(--text-sm); }
ul.logos .tag { border: none; background: none; padding: 0; line-height: 1.4; }

.sea {
  color: var(--on-dark);
  background:
    linear-gradient(var(--photo-shade), var(--photo-shade)),
    var(--brand-strong) url("/static/img/sea.jpg") center / cover no-repeat;
  padding: var(--space-9) 0;
}
.sea-inner { max-width: 42rem; text-align: center; }
.sea h2 { color: var(--on-dark); margin-top: 0; }
.sea p { font-size: var(--text-lg); opacity: 0.92; }


/* ── Forms ────────────────────────────────────────────────────────── */

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-5) var(--space-5);
  margin: 0 0 var(--space-5);
}
/* The legend as a heading inside the card, not a label on its border. */
legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-display);
  color: var(--brand);
}
legend + * { clear: both; }
fieldset > .help:first-of-type { margin-top: 0; }

label { display: block; margin: var(--space-4) 0 var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-strong); }
label.radio, label.check {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-md);
  font-weight: var(--weight-body);
  margin: var(--space-2) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
label.radio:has(input:checked), label.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
label.radio input, label.check input { width: auto; min-height: 0; margin: 0.3rem 0 0; accent-color: var(--brand); }

input, textarea, select {
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { line-height: var(--leading-body); resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}

form.inline { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
form.inline label { margin: 0; }
form.inline select, form.inline input { width: auto; }

.errors, .notice {
  border: 1px solid;
  border-left-width: 5px;
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}
.errors { border-color: var(--warn); background: var(--warn-soft); }
.errors h2 { margin-top: 0; font-size: var(--text-lg); color: var(--warn); }
.notice { border-color: var(--brand); background: var(--ok-soft); }
.warning { color: var(--warn); font-size: var(--text-sm); }
/* A field the browser check refused, and room above it for the sticky header
   when the check moves focus to it. */
[aria-invalid="true"] { border-color: var(--warn); }
input, textarea, select { scroll-margin-top: 7rem; }
.caveat { color: var(--muted); font-size: var(--text-sm); border-left: 3px solid var(--line); padding-left: var(--space-3); }

/* The honeypot: a human never sees it (`docs/security.md`). */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── Records, tables, messages (email landing pages and console) ──── */

.quote {
  border-left: 3px solid var(--sky);
  margin: 0 0 var(--space-4);
  padding: var(--space-1) 0 var(--space-1) var(--space-4);
  white-space: pre-wrap;
}

dl.record { display: grid; grid-template-columns: 12rem 1fr; gap: var(--space-2) var(--space-4); }
dl.record dt { color: var(--muted); }
dl.record dd { margin: 0; }
dl.record dd > ul { margin: 0; padding-left: var(--space-5); }
dl.record dd.quote { margin: 0; }

/* The actions on an access page: one row each, the buttons one width, what
   each does beside it, and the caveat under them all. */
.action-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-5);
}
.action-row {
  display: grid;
  grid-template-columns: 17rem 1fr;
  gap: var(--space-2) var(--space-5);
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
}
.action-row button { width: 100%; white-space: nowrap; }
.action-row .help { margin: 0; }
.action-list .caveat { margin: var(--space-4) 0 var(--space-3); }

dl.strip { display: flex; flex-wrap: wrap; gap: var(--space-5); padding: 0; }
dl.strip dt { color: var(--muted); font-size: var(--text-xs); }
dl.strip dd { margin: 0; font-weight: var(--weight-strong); }

table { width: 100%; border-collapse: collapse; margin: var(--space-2) 0 var(--space-6); font-size: var(--text-sm); }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
ul.tight { margin: 0; padding-left: var(--space-4); }
.actions-cell { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }

.tag, .flag {
  display: inline-block;
  font-size: var(--text-xs);
  line-height: 1.5;
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.6rem;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--page);
}
.flag { border-color: var(--flag); color: var(--flag); }

.message, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
.card h2 { margin-top: 0; }
.message header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-3); align-items: baseline; }
.message .from { overflow-wrap: anywhere; }
.message .tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-2) 0 0; }
.message .subject { font-weight: var(--weight-strong); margin: var(--space-2) 0 var(--space-1); }
.message .body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: var(--muted); margin: 0 0 var(--space-3); }
.message-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0 0; }
button.small { min-height: 2.25rem; padding: 0 var(--space-4); font-size: var(--text-sm); }
.disclosure { margin-top: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.disclosure summary { cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-strong); color: var(--brand); }
.stacked-form { display: grid; gap: var(--space-1); max-width: 30rem; margin-top: var(--space-2); }
.stacked-form label { margin: var(--space-2) 0 0; }
.stacked-form button { justify-self: start; margin-top: var(--space-3); }

code { background: var(--brand-soft); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.92em; }
.reference code { font-size: var(--text-md); }

/* ── Admin ────────────────────────────────────────────────────────── */

.console-nav a { color: var(--ink); text-decoration: none; font-weight: 500; padding: var(--space-2) 0; border-bottom: 2px solid transparent; }
.console-nav a:hover { color: var(--brand); }
.console-nav a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--sky); }
.console-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--on-dark);
  background: var(--brand);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
}
.console-nav .signout { margin-left: var(--space-3); }

.admin-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.admin-head h1 { margin: 0; }
.admin-section { margin-top: var(--space-7); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.section-title h2 { margin: 0; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-md); padding: var(--space-5); text-align: center; }

ul.stats {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.stat-label { font-size: var(--text-xs); font-weight: var(--weight-strong); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-display); color: var(--brand); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-note { font-size: var(--text-xs); color: var(--muted); }

.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.table-card table { margin: 0; }
.table-card th { background: var(--page); }
.table-card tr:last-child td { border-bottom: none; }
.table-card td, .table-card th { padding: var(--space-3) var(--space-4); }
.request-cell { min-width: 16rem; max-width: 24rem; }
.tag { white-space: nowrap; }
.request-cell .muted { margin-top: var(--space-1); }
ul.plain { list-style: none; padding: 0; }
ul.plain li { white-space: nowrap; }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.tag-list > div { flex-basis: 100%; }
.nowrap { white-space: nowrap; }
.actions-cell form.inline { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.actions-cell a, .actions-cell button { white-space: nowrap; }
.actions-cell button.linkish { padding-left: 0; }

.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.filters a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-sm);
}
.filters a:hover { border-color: var(--brand); }
.filters a[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--on-dark); }
.filters .count { font-size: var(--text-xs); font-weight: var(--weight-strong); opacity: 0.75; }

.stage { display: inline-block; white-space: nowrap; font-size: var(--text-xs); font-weight: var(--weight-strong); border-radius: var(--radius-pill); padding: 0.1rem 0.6rem; background: var(--page); color: var(--muted); border: 1px solid var(--line); }
.stage-waiting { background: var(--wait-soft); color: var(--wait); border-color: transparent; }
.stage-sent { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.stage-introduced { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.stage-not_sent { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.stage-replaced { background: var(--page); color: var(--muted); border-color: var(--line); }
.stage-silenced { background: var(--page); color: var(--ink); border-color: var(--ink); }
.stage-kept { background: var(--page); color: var(--brand); border-color: var(--line); }

.login { max-width: 28rem; }
.login label { margin-top: 0; }
.login button { margin-top: var(--space-4); }
.login .help { margin: var(--space-4) 0 0; }

/* The plan review page. */
.back { margin: 0 0 var(--space-2); font-size: var(--text-sm); }
.back a { text-decoration: none; }
ul.meta { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-size: var(--text-sm); }
ul.meta li { display: flex; align-items: center; gap: var(--space-2); }
ul.meta li > span:first-child { color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-strong); letter-spacing: 0.04em; text-transform: uppercase; }
.admin-section.first { margin-top: var(--space-5); }
.admin-section > h2 { margin-bottom: var(--space-3); }
.panel .quote { margin-top: 0; }
.panel dl.record { margin: var(--space-4) 0 0; }
.prose-cell { min-width: 20rem; }
.terms-cell { min-width: 12rem; max-width: 16rem; }

.decide { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); align-items: stretch; }
.decide-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.decide-card.approve { border-top: 4px solid var(--brand); }
.decide-card.deny { border-top: 4px solid var(--warn); }
.decide-card.silence { border-top: 4px solid var(--ink); }
@media (max-width: 1100px) {
  .decide { grid-template-columns: 1fr 1fr; }
  .decide-card.approve { grid-column: 1 / -1; }
}
.decide-card label { margin-top: var(--space-3); }
.decide-card h3 { margin: 0 0 var(--space-3); }
.decide-card .help { margin-top: 0; }
.decide-actions { margin-top: auto; padding-top: var(--space-4); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.field-row label { margin-top: 0; }
ul.plain-list { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { background: var(--brand); border-color: var(--brand); }
form[action="/submit"] button[type="submit"]:disabled:hover { background: var(--action); border-color: var(--action); }
.send-status { margin-top: var(--space-3); }
.send-status:empty { display: none; }

.rerun {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}
.rerun .help { margin: var(--space-1) 0 0; }
button.secondary, a.button.secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); flex-shrink: 0; }
button.secondary:hover, a.button.secondary:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* Friends: read-only cards, one opened for editing at a time. */
.friend { scroll-margin-top: calc(var(--header-height) + var(--space-4)); }
.friend-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.friend-head h2, body:has(.console-nav) main .friend-head h2 { margin: 0; font-size: var(--text-xl); }
.friend dl.record { grid-template-columns: 11rem 1fr; margin: 0; }
.friend-actions { margin: var(--space-4) 0 0; }
.friend-title { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.logo-thumb { height: 36px; width: auto; max-width: 110px; object-fit: contain; }
.logo-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4); }
.logo-preview { height: 64px; width: auto; max-width: 180px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2); background: var(--surface); }
.logo-field input[type="file"] { min-height: 0; padding: var(--space-2); }
.inline-check { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-body); margin-top: var(--space-2); }
.inline-check input { width: auto; min-height: 0; }
fieldset.subform { box-shadow: none; background: var(--page); margin: var(--space-4) 0 0; padding: var(--space-4); }
fieldset.subform legend { font-size: var(--text-md); margin-bottom: var(--space-2); }
.friend-form { max-width: none; }
.friend-form textarea { min-height: 7rem; }
.form-actions { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-3); }
.form-actions .cancel { font-weight: var(--weight-strong); }
.form-actions { flex-wrap: wrap; }
.form-actions .push-right { margin-left: auto; }
.form-actions button, .stacked-form .form-actions button { margin-top: 0; }
/* Links styled as buttons: the quiet one (Cancel) and the destructive one. */
a.button.danger { background: var(--surface); color: var(--warn); border-color: var(--warn); }
a.button.danger:hover { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.admin-head.spread { justify-content: space-between; flex-wrap: wrap; }
.friend.adding { border-top: 4px solid var(--brand); }
.confirm { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius-sm); padding: var(--space-4) var(--space-5); }
.confirm p { margin: 0 0 var(--space-3); }
.confirm .form-actions { margin-top: var(--space-4); }
.card .notice { margin-bottom: var(--space-3); padding: var(--space-2) var(--space-4); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Footer ───────────────────────────────────────────────────────── */

footer {
  background: var(--brand-strong);
  color: var(--on-dark-muted);
  font-size: var(--text-sm);
  padding: var(--space-8) 0 var(--space-7);
}
footer a { color: var(--on-dark); }
footer a:hover { color: var(--sky-soft); }
footer address { font-style: normal; }
footer h2 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--on-dark);
  margin: 0 0 var(--space-3);
}
footer .wordmark { color: var(--on-dark); margin-bottom: var(--space-2); }
.footer-inner {
  max-width: var(--width-page);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: var(--space-6);
}
.footer-inner p { margin: 0 0 var(--space-2); }
.footer-brand p:not(.wordmark) { max-width: 18rem; }
.powered { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-6); }
.footer-logos h2 { margin-bottom: var(--space-5); } /* room between the label and the first logo */
.powered img { height: 28px; width: auto; }
.powered img.smtf { width: 100%; max-width: 16rem; height: auto; } /* its wordmark is small text under the mark */
.powered img.supporter { height: 84px; } /* a stacked mark: taller to read at the same size */

/* ── Phone ────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  :root {
    --section-y: var(--space-8);
    --gutter: var(--space-4);
    --text-3xl: 2.25rem;
    --text-2xl: 1.75rem;
    --text-lg: 1.125rem;
  }
  .site-nav { display: none; }
  .menu { display: block; }
  body:has(.console-nav) .bar-inner { flex-wrap: wrap; padding-block: var(--space-3); }
  .split, .grid-2 { grid-template-columns: 1fr; gap: var(--space-6); }
  .hero {
    min-height: 0;
    padding: var(--space-8) 0;
    background:
      linear-gradient(var(--photo-shade), var(--photo-shade)),
      var(--brand-strong) url("/static/img/hero.jpg") 25% center / cover no-repeat;
  }
  .hero-inner { justify-content: flex-start; }
  .actions .button { flex: 1 1 auto; }
  .panel { padding: var(--space-5); }
  ul.logo-strip { grid-template-columns: repeat(3, 1fr); gap: var(--space-5) var(--space-4); }
  ul.logo-strip img { height: 30px; }
  dl.record { grid-template-columns: 1fr; }
  dl.record dd { margin-bottom: var(--space-3); }
  dl.record dd.quote { margin-bottom: var(--space-3); }
  .action-row { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-logos { grid-column: 1 / -1; } /* full width, so the logos stay legible */
  .decide, .field-row { grid-template-columns: 1fr; }

  /* The admin menu and the request filters: one row that scrolls sideways,
     instead of wrapping into ragged lines. */
  .console-nav, .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .console-nav::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
  .console-nav { width: 100%; gap: var(--space-5); padding-bottom: var(--space-1); padding-right: var(--space-6); }
  /* A fade at the right edge says the row carries on. */
  .console-nav, .filters { mask-image: linear-gradient(to right, #000 85%, transparent); }
  .console-nav > * { flex-shrink: 0; white-space: nowrap; }
  .console-nav .signout { margin-left: auto; }
  .filters { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .filters a { flex-shrink: 0; white-space: nowrap; }

  /* Tables marked .stack become one card per row, each cell labelled. */
  .table-card:has(table.stack) { background: none; border: none; box-shadow: none; overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
  }
  table.stack td, .table-card table.stack td {
    border: none;
    padding: var(--space-1) 0;
    min-width: 0;
    max-width: none;
  }
  table.stack td[data-label] {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: var(--space-3);
    align-items: baseline;
    justify-items: start;
  }
  table.stack td[data-label]::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-strong);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
  table.stack td:first-child { padding-bottom: var(--space-2); }
  table.stack td.row-actions { border-top: 1px solid var(--line); margin-top: var(--space-2); padding-top: var(--space-3); }
  table.stack td.row-actions .actions-cell { flex-direction: row; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
  table.stack td.row-actions .actions-cell form.inline { flex-direction: row; gap: var(--space-4); }
  table.stack ul.plain li { white-space: normal; }
  .stacked-form { max-width: none; }
  ul.stats { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .stat { padding: var(--space-3) var(--space-4); }
  .stat-value { font-size: var(--text-xl); }
  .section-title { flex-wrap: wrap; }
  .friend dl.record { grid-template-columns: 1fr; gap: 0; }
  .friend dl.record dt { font-size: var(--text-xs); font-weight: var(--weight-strong); letter-spacing: 0.04em; text-transform: uppercase; margin-top: var(--space-3); }
  .friend dl.record dd { margin: 0; overflow-wrap: anywhere; }
  /* The admin header is two rows tall here; land below it. */
  .friend { scroll-margin-top: 9.5rem; }
  .friend-title { flex-wrap: wrap; }
  .form-actions .push-right { margin-left: 0; }
  .friend-head .tag-list { width: 100%; }
  .logo-thumb { height: 28px; }
  .prose-cell { min-width: 15rem; }
  .rerun { flex-direction: column; align-items: flex-start; }
  .footer-brand { grid-column: 1 / -1; }
}
