/* Stillwell Commons: the owner's web app. Domain II (Scientific & Strategic), Night Court by
   default. Every colour, size and duration comes from the brand tokens (../brand/tokens.css);
   nothing here hard-codes a hex value except through those variables. */

/* ── Night Court is the default; the parchment mode is the owner's choice (theme.js). The
   brand's night block applies to [data-mode="night"], set on <html> by the server. ── */
html { color-scheme: dark; }
html[data-mode="parchment"] { color-scheme: light; }

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

/* hidden means hidden, whatever display a class gives the element */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--color-fg);
  background: var(--color-bg);
  font-feature-settings: "liga" 1, "onum" 1;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--color-link); text-underline-offset: 0.18em; }
a:hover { color: var(--color-link-hover); }

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

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

.skip-link {
  position: absolute; left: var(--sp-3); top: -100px; z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-surface-raised); color: var(--color-fg);
  border: 1px solid var(--color-gilt); border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--sp-3); }

/* ── Type ─────────────────────────────────────────────────────────── */

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  font-weight: 600;
  line-height: var(--lh-snug);
  margin: 0 0 var(--sp-4);
}
h1 { font-size: var(--fs-xl); color: var(--color-fg); }
h2 { font-size: var(--fs-lg); font-weight: 500; }
h3 { font-size: var(--fs-md); font-weight: 500; }

p { margin: 0 0 var(--sp-4); max-width: 72ch; }

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-xwide);
  text-transform: uppercase;
  color: var(--color-gilt);
  margin: 0 0 var(--sp-2);
}

.muted { color: var(--color-fg-muted); }
.subtle { color: var(--color-fg-muted); font-size: var(--fs-sm); }
.latin { font-family: var(--font-editorial); font-style: italic; letter-spacing: var(--ls-wide); }

code, pre, .mono, kbd, textarea.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  /* JetBrains Mono would join "--" or "<=" into one glyph: code is shown as typed */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
code, kbd {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-1);
  overflow-wrap: anywhere;
}
.chip { white-space: nowrap; display: inline-block; margin: 0 var(--sp-1) var(--sp-1) 0; }
pre {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  overflow: auto;
  max-height: 24rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.rule-gilt {
  border: 0; height: 1px; margin: var(--sp-5) 0;
  background: linear-gradient(90deg, transparent, var(--color-gilt) 18%, var(--color-gilt) 82%, transparent);
}

.hs-gi { width: 28px; height: 28px; flex-shrink: 0; display: block; fill: currentColor; }
.hs-gi-sm { width: 18px; height: 18px; display: inline-block; vertical-align: middle; fill: currentColor; }
.glyph-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── Layout ───────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top top" "side main" "side foot";
  min-height: 100vh;
}
.shell--bare { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main" "foot"; }

.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--color-gilt); text-decoration: none;
}
.brand:hover { color: var(--color-gilt); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: var(--ls-xwide);
  text-transform: uppercase;
  color: var(--color-fg);
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }

.sidebar {
  grid-area: side;
  background: var(--color-bg-alt);
  border-right: 1px solid var(--color-border);
  padding: var(--sp-5) var(--sp-3);
}
.nav-section + .nav-section { margin-top: var(--sp-5); }
.nav-title {
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-xwide); text-transform: uppercase;
  color: var(--color-fg-muted);
  margin: 0 0 var(--sp-2) var(--sp-3);
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--color-fg-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background var(--dur-quick) var(--ease-courtly), color var(--dur-quick) var(--ease-courtly);
}
.nav-list a:hover { background: var(--color-surface); color: var(--color-fg); }
.nav-list a[aria-current="page"] {
  color: var(--color-fg);
  background: var(--color-surface);
  border-left-color: var(--color-gilt);
}

.menu { display: none; }

main {
  grid-area: main;
  padding: var(--sp-6) var(--sp-6) var(--sp-7);
  max-width: 76rem;
  width: 100%;
}
.shell--bare main { margin: 0 auto; max-width: 34rem; padding-top: var(--sp-8); }

.footer {
  grid-area: foot;
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--color-border);
  display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); align-items: baseline;
  color: var(--color-fg-muted); font-size: var(--fs-sm);
}
.footer .latin { color: var(--color-gilt); font-size: var(--fs-md); }

/* Phones: the navigation folds into a menu (a <details>, so it works without script). */
@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main" "foot"; }
  .sidebar { display: none; }
  .menu { display: block; position: relative; }
  .menu > summary {
    list-style: none; cursor: pointer;
    font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
    letter-spacing: var(--ls-xwide); text-transform: uppercase;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
    color: var(--color-fg);
    min-height: 44px; display: flex; align-items: center;
  }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu[open] > .menu-panel {
    position: absolute; right: 0; top: calc(100% + var(--sp-2));
    width: min(18rem, 86vw);
    max-height: 75vh; overflow: auto;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--sp-4) var(--sp-3);
  }
  .nav-list a { min-height: 44px; display: flex; align-items: center; }
  main { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .topbar { padding: var(--sp-2) var(--sp-4); }
  .footer { padding: var(--sp-4); }
  .hide-narrow { display: none; }
}

/* ── Page header ──────────────────────────────────────────────────── */

.page-head { margin-bottom: var(--sp-5); }
.page-head h1 { margin-bottom: var(--sp-2); }
.page-head .lede { color: var(--color-fg-muted); margin: 0; }
.page-head-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; justify-content: space-between; }
.breadcrumbs { font-size: var(--fs-sm); margin-bottom: var(--sp-2); color: var(--color-fg-muted); }
.breadcrumbs a { color: var(--color-fg-muted); }

/* ── Cards, grids, stats ──────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-vellum);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
  min-width: 0;
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.card-head h2 { margin: 0; }
.card--gilt { box-shadow: var(--shadow-gilt); }
.card--danger { border-color: var(--color-flame); }
.card--warn { border-color: var(--color-warn); border-left-width: 4px; }

.grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + section, .grid + .grid { margin-top: var(--sp-5); }
.stack > * + * { margin-top: var(--sp-4); }

.stats { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); margin-bottom: var(--sp-5); }
.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--sp-4); }
.stat-label { font-family: var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--ls-xwide); text-transform: uppercase; color: var(--color-fg-muted); }
.stat-value { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--color-fg); line-height: var(--lh-snug); }

.meter { margin: var(--sp-2) 0 var(--sp-4); height: 8px; border-radius: var(--radius-pill); background: var(--color-bg-alt); border: 1px solid var(--color-border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--color-gilt); }
.meter--warn > span { background: var(--color-warn); }
.meter--over > span { background: var(--color-flame); }
/* widths in steps of 5 %, chosen by the template (no inline style under the CSP) */
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ── Tables ───────────────────────────────────────────────────────── */

.table-wrap { position: relative; overflow-x: auto; margin: 0 calc(-1 * var(--sp-2)); padding: 0 var(--sp-2); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--color-border); vertical-align: top; }
th {
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg-muted);
  white-space: nowrap;
}
tbody tr:hover { background: color-mix(in srgb, var(--color-surface-raised) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
.wrap-anywhere { overflow-wrap: anywhere; }
/* A long name on one line, cut with an ellipsis; the whole name is in the title (and on the
   thing's own page). */
.truncate { display: block; max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Phones: a table becomes a stack of cards, one per row, each cell captioned with its column
   (data-label, filled from the table head by app.js), the row's actions in full view. Nothing
   scrolls sideways. */
@media (max-width: 40rem) {
  .table-wrap { overflow: visible; margin: 0; padding: 0; --caption: 7rem; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  /* display: block, or overflow does not apply and the hidden header still widens the page */
  .table-wrap thead { display: block; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-wrap tr {
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    padding: var(--sp-3); margin-bottom: var(--sp-3);
  }
  .table-wrap tbody tr:hover { background: var(--color-surface-raised); }
  /* the caption sits in a left column; everything in the cell flows in the right one, wrapping
     long words (ids, addresses) rather than pushing the card wider */
  .table-wrap td {
    border: 0; padding: var(--sp-1) 0 var(--sp-1) calc(var(--caption) + var(--sp-3));
    display: flow-root; /* holds the floated caption, however many lines it takes */
    text-align: left; white-space: normal; overflow-wrap: anywhere;
  }
  .table-wrap td::before {
    content: attr(data-label);
    float: left; width: var(--caption); margin-left: calc(-1 * (var(--caption) + var(--sp-3)));
    font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
    letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg-muted);
    padding-top: 0.2em; overflow-wrap: normal;
  }
  .table-wrap td:not([data-label]), .table-wrap td[data-label=""] { padding-left: 0; }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td.actions { padding-top: var(--sp-2); }
  .table-wrap td.actions .actions-row, .table-wrap td.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
  .table-wrap td.num { text-align: left; }
  .truncate { max-width: 100%; }
}

dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-2) var(--sp-4); margin: 0; }
dl.facts dt { color: var(--color-fg-muted); font-size: var(--fs-sm); font-family: var(--font-display); letter-spacing: var(--ls-wide); text-transform: uppercase; padding-top: 0.2em; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 34rem) { dl.facts { grid-template-columns: minmax(0, 1fr); } dl.facts dd { margin-bottom: var(--sp-2); } }

/* ── Pills ────────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  padding: 0.1em 0.7em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong);
  color: var(--color-fg-muted);
  white-space: nowrap;
}
.pill--ok { border-color: var(--color-success); color: var(--color-fg); background: color-mix(in srgb, var(--color-success) 35%, transparent); }
.pill--warn { border-color: var(--color-warn); color: var(--color-fg); background: color-mix(in srgb, var(--color-warn) 35%, transparent); }
.pill--bad { border-color: var(--color-flame); color: var(--color-fg); background: color-mix(in srgb, var(--color-flame) 35%, transparent); }
.pill--gilt { border-color: var(--color-gilt); color: var(--color-gilt); }

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

form { margin: 0; }
.field { margin-bottom: var(--sp-4); }
.field label, .label {
  display: block;
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  color: var(--color-fg-muted);
  margin-bottom: var(--sp-1);
}
.field .hint { font-size: var(--fs-sm); color: var(--color-fg-muted); margin-top: var(--sp-1); }
input[type="text"], input[type="search"], input[type="url"], input[type="number"], input[type="datetime-local"],
input[type="password"], input:not([type]), select, textarea {
  width: 100%;
  font: inherit; font-size: var(--fs-base);
  color: var(--color-fg);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  min-height: 44px;
}
textarea { min-height: 6rem; resize: vertical; }
input[type="file"] { font: inherit; font-size: var(--fs-base); color: var(--color-fg-muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  color: var(--color-fg); background: transparent;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-4); min-height: 44px; margin-right: var(--sp-3);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--color-gilt); background: var(--color-surface-raised); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--color-gilt); outline-offset: 1px; }
.check { display: flex; gap: var(--sp-2); align-items: flex-start; margin-bottom: var(--sp-2); }
.check input { margin-top: 0.35em; width: 1.1em; height: 1.1em; accent-color: var(--hs-imperial-gold); flex-shrink: 0; }
.check label { font-family: var(--font-serif); font-size: var(--fs-base); text-transform: none; letter-spacing: 0; color: var(--color-fg); margin: 0; }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); margin: 0 0 var(--sp-4); min-width: 0; }
legend { font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600; letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg-muted); padding: 0 var(--sp-2); }
.form-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-start; }
.field--action { flex: 0 0 auto !important; }
.field--action::before {
  content: ""; display: block;
  height: calc(var(--fs-xs) * var(--lh-normal) + var(--sp-1));
}
.field--action .check { min-height: 44px; align-items: center; margin: 0; }
.field--action .check input { margin-top: 0; }
.form-row > .field { flex: 1 1 12rem; }
.inline-form { display: inline; }

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

.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  color: var(--color-fg);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-4);
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-quick) var(--ease-courtly), border-color var(--dur-quick) var(--ease-courtly);
}
.button:hover, button:hover { background: var(--color-surface-raised); color: var(--color-fg); border-color: var(--color-gilt); }
.button--primary { background: var(--hs-royal-purple); border-color: var(--color-gilt); color: var(--hs-ivory); }
.button--primary:hover { background: var(--hs-purple-deep); color: var(--hs-ivory); }
.button--danger { border-color: var(--color-flame); color: var(--color-fg); }
.button--danger:hover { background: var(--hs-aldebaran-red); color: var(--hs-ivory); border-color: var(--hs-aldebaran-red); }
.button--small { min-height: 36px; padding: var(--sp-1) var(--sp-3); }
.button--quiet { border-color: transparent; }
button[disabled], .button[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.actions-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ── Notices ──────────────────────────────────────────────────────── */

.notice {
  border: 1px solid var(--color-border-strong);
  border-left: 4px solid var(--color-gilt);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}
.notice--error { border-left-color: var(--color-flame); }
.notice--ok { border-left-color: var(--color-success); }
.notice--warn { border-left-color: var(--color-warn); }
.notice > :last-child { margin-bottom: 0; }
.notice strong { font-family: var(--font-display); font-size: var(--fs-sm); letter-spacing: var(--ls-wide); text-transform: uppercase; }
.toast-region { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 50; display: grid; gap: var(--sp-2); max-width: min(28rem, calc(100vw - 2 * var(--sp-4))); }
.toast-region .notice { margin: 0; box-shadow: var(--shadow-card); }

.secret-once {
  border: 1px solid var(--color-gilt); box-shadow: var(--shadow-gilt);
  border-radius: var(--radius-lg); padding: var(--sp-4); background: var(--color-surface-raised);
}
.secret-once code { display: block; padding: var(--sp-3); font-size: var(--fs-base); user-select: all; }

.empty { color: var(--color-fg-muted); font-style: italic; margin: var(--sp-2) 0; }

/* ── Lists of things (inbox, messages, events) ────────────────────── */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: var(--sp-3) 0; border-bottom: 1px solid var(--color-border); }
.list > li:last-child { border-bottom: 0; }
.item-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; justify-content: space-between; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-body { margin-top: var(--sp-1); white-space: pre-wrap; overflow-wrap: anywhere; }

.request, .list > li.request {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--color-surface-raised);
}
.request--urgent { border-color: var(--color-flame); box-shadow: var(--shadow-seal); }

.message { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface-raised); margin-bottom: var(--sp-3); }
.message--owner { border-color: var(--color-gilt); }
.message-meta { font-size: var(--fs-sm); color: var(--color-fg-muted); display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.live-dot { display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--color-fg-muted); margin-right: var(--sp-1); vertical-align: middle; }
.live-dot--on { background: var(--color-success); }
.live-dot--off { background: var(--color-flame); }

/* ── Talk ─────────────────────────────────────────────────────────── */

.call {
  border: 1px solid var(--color-gilt);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-gilt);
  background: var(--color-surface);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.call-state { font-family: var(--font-display); letter-spacing: var(--ls-xwide); text-transform: uppercase; font-size: var(--fs-sm); color: var(--color-gilt); }
.call-controls { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-4) 0; }
.call-controls button { min-width: 8rem; min-height: 52px; }
.transcript { max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--color-border); padding-top: var(--sp-3); }
.line { margin: 0 0 var(--sp-2); overflow-wrap: anywhere; }
.line-speaker { font-family: var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg-muted); margin-right: var(--sp-2); }
.line--owner .line-speaker { color: var(--color-gilt); }
.line--partial { color: var(--color-fg-muted); font-style: italic; }
.line--note { color: var(--color-fg-muted); font-style: italic; }

/* ── Upload progress ──────────────────────────────────────────────── */

progress { width: 100%; height: 8px; accent-color: var(--hs-imperial-gold); }

/* ── Motion ───────────────────────────────────────────────────────── */

.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity var(--dur-measured) var(--ease-courtly); }
.htmx-swapping { opacity: 0.6; transition: opacity var(--dur-quick) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .footer, .menu, .toast-region { display: none !important; }
  .shell { display: block; }
}

/* Parchment: Imperial Gold fails small-text contrast on parchment (the brand reserves it for
   rules and large accents there), so small gilt text takes the royal purple instead. */
html[data-mode="parchment"] .eyebrow,
html[data-mode="parchment"] .latin,
html[data-mode="parchment"] .pill--gilt,
html[data-mode="parchment"] .call-state,
html[data-mode="parchment"] .footer .latin { color: var(--color-accent); }
html[data-mode="parchment"] .pill--gilt { border-color: var(--color-accent); }

summary.button { list-style: none; width: max-content; }
summary.button::-webkit-details-marker { display: none; }
details[open] > summary.button { margin-bottom: var(--sp-4); }

/* Text chosen by agents or applications is isolated: right-to-left text cannot reorder what is
   around it (control characters are already shown as markers by the server, comm/web/text.py). */
bdi, .name, .quote, .item-title, td, dd, .lede { unicode-bidi: isolate; }
.item-body, .line-words, .event-text .quote, pre { unicode-bidi: plaintext; }

/* Live status and a row of pills in a page head. */
.pill-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.pill--live[hidden] { display: none; }

/* Home: recent events, one line each, details on demand. */
.events { list-style: none; margin: 0; padding: 0; }
.event {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--sp-3);
  align-items: baseline;
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--color-border);
}
.event:last-child { border-bottom: 0; }
.event-text { margin: 0; max-width: none; overflow-wrap: anywhere; }
.event-when { white-space: nowrap; }
.event-details { grid-column: 1 / -1; }
.event-details > summary { font-size: var(--fs-sm); color: var(--color-fg-muted); cursor: pointer; width: max-content; }
.event-details[open] > summary { margin-bottom: var(--sp-2); }
.pill--count { margin-left: var(--sp-1); }
@media (max-width: 40rem) { .event { grid-template-columns: minmax(0, 1fr); } }

/* A compact row of one input and its buttons (meter prices, passkeys). */
.row-end { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-start; }
.row-end > form.form-row { flex: 1 1 18rem; }
.input-narrow { max-width: 10rem; }

/* Footer motto: Latin in small capitals, an em dash, the English. */
.footer .motto { margin: 0; }
.motto { display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); align-items: baseline; }
.motto .latin { font-variant: small-caps; }
.motto-dash { color: var(--color-gilt); }

/* Transcript card on the Talk page and the saved conversation. */
.transcript-card .card-head p { margin: 0; }
.transcript--saved { max-height: none; border-top: 0; padding-top: 0; }
.pager { margin-bottom: var(--sp-3); }

/* Module settings: titled sections, one block per setting. */
.settings-group { border-top: 1px solid var(--color-border); padding: var(--sp-3) 0; }
.settings-group > summary {
  cursor: pointer; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: baseline;
  min-height: 44px; align-content: center;
}
.settings-group-title {
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg);
}
.setting { padding: var(--sp-3) 0 var(--sp-3) var(--sp-4); border-left: 2px solid var(--color-border); margin: var(--sp-2) 0 var(--sp-2) var(--sp-2); }
.setting-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; }
.setting-label { font-weight: 600; font-size: var(--fs-md); }
.setting .hint { font-size: var(--fs-sm); color: var(--color-fg-muted); margin: var(--sp-1) 0; }
.setting-now { margin: var(--sp-1) 0 var(--sp-2); font-size: var(--fs-sm); }
.setting-key { margin-left: var(--sp-2); font-size: var(--fs-xs); }
.setting-edit { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.setting-edit > .check { margin: 0; min-height: 44px; align-items: center; }
.setting-edit > .check input { margin-top: 0; }
.setting-edit > input, .setting-edit > select { flex: 1 1 16rem; max-width: 32rem; }
.settings-save { position: sticky; bottom: 0; padding: var(--sp-3) 0; background: var(--color-surface); border-top: 1px solid var(--color-border); }

/* A request's spoken code: large enough to read off the screen while on the phone. */
.request-code { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); margin: var(--sp-2) 0; }
.request-code-label { font-family: var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-fg-muted); }
.request-code-words { font-family: var(--font-display); font-size: var(--fs-lg); letter-spacing: var(--ls-wide); color: var(--color-gilt); }

/* The agents' guide, to be read and copied whole. */
pre.guide { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow-y: auto; }

/* Reasons listed in a table cell (the set-up review). */
.reasons { margin: 0; padding-left: 1.1em; }
.reasons li { margin: 0; }
