/* Termn app — calm, high-contrast, readable at arm's length.
   Type is large by default, targets are 44px, color never carries meaning alone.

   Tokens live in tokens.css (the brand's single source of truth); this file
   aliases them and applies them to the operational workspace. The component
   contract is spec/16-design-system.md; identity canon is spec/13-brand.md.
   Change tokens there first — a hex literal in this file is a review flag.

   Contents:
     1. tokens & base        5. forms & controls      9. contact book & dialog
     2. shell chrome         6. status & notices     10. participant / centred
     3. layout primitives    7. checklist & steps    11. utilities (rhythm-locked)
     4. buttons              8. tables & data        12. responsive
*/

@import url("tokens.css");

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/source-serif-4-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/source-serif-4-700.woff2") format("woff2");
}

/* --- 1. tokens & base ------------------------------------------------------ */

:root {
  --paper: var(--t-paper);
  --surface: var(--t-surface);
  --surface-rest: var(--t-surface-rest);
  --ink: var(--t-ink);
  --ink-soft: var(--t-ink-soft);
  --ink-faint: var(--t-ink-faint);
  --line: var(--t-line);
  --line-strong: var(--t-line-strong);
  --hairline: var(--t-hairline);

  --elder-deep: var(--t-elder-deep);
  --elder: var(--t-elder);
  --elder-soft: var(--t-elder-soft);
  --elder-lift: var(--t-elder-lift);
  --green: var(--t-success);
  --green-soft: var(--t-success-soft);
  --green-line: var(--t-success-line);
  --amber: var(--t-attention);
  --amber-soft: var(--t-attention-soft);
  --amber-line: var(--t-attention-line);
  --red: var(--t-failure);
  --red-soft: var(--t-failure-soft);
  --red-line: var(--t-failure-line);
  --contact: var(--t-contact);
  --contact-soft: var(--t-contact-soft);
  --contact-line: var(--t-contact-line);
  --entity: var(--t-entity);
  --entity-soft: var(--t-entity-soft);
  --entity-line: var(--t-entity-line);
  --account: var(--t-account);
  --account-soft: var(--t-account-soft);
  --account-line: var(--t-account-line);
  --document: var(--t-document);
  --document-soft: var(--t-document-soft);
  --document-line: var(--t-document-line);

  --radius: var(--t-radius);
  --radius-control: var(--t-radius-control);
  --radius-s: var(--t-radius-s);
  --shadow: var(--t-shadow);
  --font: var(--t-sans);
  --serif: var(--t-serif);
  --mono: var(--t-mono);
  --script: var(--t-script);
}

* { box-sizing: border-box; }

/* The hidden attribute always wins, even over an explicit display rule. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

a { color: var(--elder); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
small, .small { font-size: .875rem; color: var(--ink-soft); }

/* One focus signature everywhere: elder ring + soft halo (tokens.css). */
:focus-visible {
  outline: var(--t-focus-ring);
  outline-offset: 2px;
  box-shadow: var(--t-focus-halo);
}

/* Words that are only true on one side of the enhancement line — a button whose job
   changes once termn.js is running, say. Both are in the markup; the class on <html>
   picks. Default to the no-JS wording so the page is right before any script runs
   and stays right if none ever does. */
.when-js { display: none; }
html.js .when-js { display: inline; }
html.js .when-no-js { display: none; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); color: var(--elder); padding: 12px 16px;
  border: 2px solid var(--elder); border-radius: 0 0 var(--radius) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* --- 2. shell chrome ------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

/* The rail is shell, not signal: the one dark field, and it stays quiet.
   The current decision on the work surface is the only bright thing. */
.rail {
  width: 232px; flex: 0 0 232px; background: var(--elder-deep); color: var(--t-on-dark-soft);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 2px;
}

/* The wordmark signature: serif Term + bold lifted-blue n + one continuous
   rule under the whole word — and under nothing else. */
.rail .wordmark {
  margin: 4px 10px 20px; padding: 0 0 3px; width: max-content;
  font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--t-on-dark);
  border-bottom: 2px solid var(--elder-lift);
}
.rail .wordmark span { color: var(--elder-lift); font-weight: 700; }

.rail a {
  display: block; padding: 11px 12px; border-radius: var(--radius-control);
  color: var(--t-on-dark-soft); text-decoration: none; font-size: 1rem; min-height: 44px;
}
.rail a:hover { background: rgba(255, 254, 253, .07); color: var(--t-on-dark); }
.rail a.current {
  background: rgba(255, 254, 253, .12); color: var(--t-on-dark); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--elder-lift);
}
.rail a:focus-visible { outline-color: var(--elder-lift); box-shadow: none; }

/* The menu wrapper exists for the phone fold; on desktop its children lay out
   as if it weren't there. */
.rail-menu { display: contents; }
.rail-toggle { display: none; }

/* A labelled group of destinations; the label is read, not shouted. */
.rail-group { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.rail-label {
  font-size: .78rem; color: var(--t-on-dark-muted);
  padding: 0 12px 6px; letter-spacing: .01em;
}

.rail .rail-foot {
  margin-top: auto; font-size: .875rem; color: var(--t-on-dark-muted); padding: 10px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
}
.rail .rail-foot a { display: inline; padding: 0; min-height: 0; color: var(--t-on-dark-soft); }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
  min-height: 64px;
}
.topbar .org { font-weight: 600; }

/* The organization switcher is chrome: compact, quiet, honest. */
.org-switch { display: inline-flex; align-items: center; gap: 8px; }
.org-switch select {
  min-height: 36px; width: auto; padding: 6px 32px 6px 10px;
  font-size: .875rem; background-position: right 8px center;
}
.org-switch .btn { min-height: 36px; padding: 6px 12px; font-size: .875rem; }

.content { padding: 28px; max-width: 1080px; }
.content.narrow { max-width: 720px; }

.page-head { margin-bottom: 24px; }
.page-head p { color: var(--ink-soft); margin: 0; max-width: 64ch; }

/* --- 3. layout primitives -------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
}
.card.tight { padding: 16px 18px; }
.card h2 { margin-bottom: .3em; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
/* A head's action box reaches well below the title's baseline; whatever
   follows keeps clear of it instead of being grazed. */
.card-head:not(:last-child) { margin-bottom: 10px; }

.row {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px;
}
.row:hover { border-color: var(--line-strong); }
.row .row-main { min-width: 0; flex: 1; }
.row .row-title { font-weight: 600; margin-bottom: 2px; }
.row .row-meta { color: var(--ink-soft); font-size: .94rem; }
.row .row-side { flex: 0 0 auto; text-align: right; }
.row.top { align-items: flex-start; }

/* A whole row can be the link; the words inside keep their own color. */
a.row { text-decoration: none; color: inherit; }
a.row:hover .row-title { text-decoration: underline; text-underline-offset: 2px; }

/* The Elder anchor: the one current thing in view. One per viewport. */
.row.current, .card.current {
  border-color: var(--elder);
  box-shadow: 0 0 0 3px var(--elder-soft);
}

.stack > * + * { margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.split { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.split > .split-main { flex: 1 1 460px; min-width: 0; }
.split > .split-side { flex: 0 1 320px; }

/* Words that sit on one reading line: a value and its label, a name and its meta. */
.baseline-row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }

/* A framed exhibit: QR codes, small images — presented, not decorated. */
.framed {
  display: inline-block; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 8px;
}

/* --- 4. buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 18px;
  border-radius: var(--radius-control); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-faint); background: var(--surface-rest); }
.btn:active { background: var(--t-band-deep); }
.btn.primary { background: var(--elder); border-color: var(--elder); color: var(--t-on-dark); }
.btn.primary:hover { background: var(--elder-deep); border-color: var(--elder-deep); }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--elder); padding-left: 4px; padding-right: 4px; }
/* Small buttons keep the 44px target, so the height floor — not the declared
   padding — sets their vertical inset (~10px). The sides are widened to match
   so the label is not pinched against the border. */
.btn.small { min-height: 44px; padding: 10px 16px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] {
  cursor: not-allowed; background: var(--t-band-deep); color: var(--ink-faint); border-color: var(--line-strong);
}
/* A submitting button holds its ground; the label says what is happening. */
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
/* Beside other things — a heading, a row's text, its neighbors in a row of
   buttons — a button never breaks its label mid-phrase; the layout folds
   around it instead. Alone in the flow it may still wrap rather than
   overflow, since some labels carry a name of any length. */
.card-head .btn, .btn-row .btn, .row .row-side .btn, .field-row .btn { white-space: nowrap; }

/* --- 5. forms & controls --------------------------------------------------- */

.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; }
/* The heading over a group of controls no single one of them owns — a set of radios,
   a set of tickboxes. A <label> here would claim to name one input and name none of
   them; the group carries role="radiogroup" and points at this with aria-labelledby.
   Reads identically to .field label on purpose. */
.field .group-label { display: block; font-weight: 600; margin-bottom: 5px; }
/* Two label notes, one voice: "— optional", and "— required for a wire or ACH"
   for a field the form requires under a condition it can see. Both are
   qualifiers on the label, so both read quietly. */
.field label .optional, .field label .requirement {
  font-weight: 400; color: var(--ink-faint); font-size: .875rem;
}
.field .help { color: var(--ink-soft); font-size: .875rem; margin: -1px 0 7px; }

.field-input, input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="month"],
input[type="tel"], input[type="url"], input[type="search"], input[type="password"],
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  background-color: var(--surface); color: var(--ink);
  color-scheme: light; /* native popups (calendar, option list) stay light */
}
::placeholder { color: var(--ink-faint); opacity: 1; }
textarea { min-height: 90px; line-height: 1.5; }

/* A control under the pointer says so, the same way a button does. The
   readonly/disabled rules below re-assert their quieter border. */
.field-input:hover, input:hover, select:hover, textarea:hover { border-color: var(--ink-faint); }

/* Selects carry their own chevron (tokens.css) so every browser draws the
   same control on every surface. */
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 40px;
  background-image: var(--t-chevron);
  background-repeat: no-repeat; background-position: right 14px center;
}
select[multiple], select[size]:not([size="1"]) { background-image: none; padding-right: 12px; }

/* Date fields carry the calendar glyph the same way. The picker itself stays
   native; the webkit trigger is restyled to our glyph, and elsewhere the glyph
   is painted by the browser in the same seat. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  width: 15px; height: 16px; padding: 0; margin-left: 8px;
  background: var(--t-glyph-calendar) center / contain no-repeat;
  cursor: pointer; opacity: .9;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator { opacity: 1; }
/* iOS renders the value centered in a shrunken well; hold the reading line. */
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left; min-height: 1.3em;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--elder); }

input[readonly], textarea[readonly] {
  background-color: var(--t-band); color: var(--ink-soft); border-color: var(--line-strong);
}
input[disabled], select[disabled], textarea[disabled] {
  background-color: var(--t-band-deep); color: var(--ink-faint); border-color: var(--line-strong);
  cursor: not-allowed;
}
select[disabled] { background-image: var(--t-chevron-faint); }
input[disabled]::-webkit-calendar-picker-indicator {
  background-image: var(--t-glyph-calendar-faint); cursor: not-allowed;
}

/* An invalid control shows the boundary at the control, and the error text
   below it names the recovery. */
.field.invalid input, .field.invalid select, .field.invalid textarea,
[aria-invalid="true"] {
  border-color: var(--red);
}
.field .errors { color: var(--red); font-size: .94rem; font-weight: 500; margin-top: 6px; }

.checkline { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px;
             min-height: 44px; padding: 8px 0; }
.checkline input { margin-top: 2px; width: 24px; height: 24px; flex: 0 0 auto; }
.checkline label { font-weight: 500; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 20px; }
legend { font-weight: 600; padding: 0 8px; }

/* An input and its verb on one line: a code and Apply, a search and Go. */
.field-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-row .field { flex: 1 1 220px; margin-bottom: 0; }
.field-row > input, .field-row > .field-input, .field-row > select {
  flex: 1 1 220px; width: auto; min-width: 200px;
}
.field-row .btn { flex: 0 0 auto; }
/* A field after the row starts its own line at the same distance the fields
   keep from one another — the row itself carries no bottom margin. */
.field-row + .field { margin-top: 20px; }

/* Narrow inputs for values with a known shape: codes, amounts, dates. */
.input-narrow { max-width: 240px; }

/* An amount has a known shape too, so it takes the narrow width and lining
   figures — 12,000.00 sits under 9,000.00 digit for digit. It is a text box on
   purpose (apps/portal/forms.MoneyInput): a number input refuses "$12,000". */
.input-money { max-width: 240px; font-variant-numeric: tabular-nums; }

/* Protected values redisplay masked, in mono, and never in full. */
.masked { font-family: var(--mono); font-size: .95em; letter-spacing: .08em; }

/* The quiet "or" between two honest paths (sign-in link vs. Google). */
.or-sep {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-faint); font-size: .875rem; margin: 18px 0 10px;
}
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

/* Continue with Google — the one third-party mark the product carries (spec/16
   § Record identity). Google's sign-in branding guidelines fix the mark, the
   colors, the wording and the mark's clear space, so this block states its
   hexes and pixels literally instead of reaching for our tokens: dressing
   someone else's trademark in the Termn palette is the misuse those guidelines
   exist to stop, and a token that moved would move the trademark with it.
   Ours are only what the guidelines leave open — the 44px target floor (above
   Google's 40px minimum), the full width beside the sign-in-link button above
   it, and the focus ring, which stays the one signature everywhere. */
.google-btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center;
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid #747775; border-radius: var(--radius-s);
  background: #fff; color: #1f1f1f;
  font-family: var(--font); font-size: 14px; font-weight: 500; letter-spacing: .25px;
  text-decoration: none; cursor: pointer;
  transition: box-shadow .218s;
}
/* The mark keeps its own proportions and its 12px of clear space, and never
   shrinks with the label. */
.google-btn img { flex: 0 0 auto; width: 20px; height: 20px; margin-right: 12px; }
/* Google centers the label in the space beside the mark, not in the button. */
.google-btn span { flex: 1 1 auto; text-align: center; }
.google-btn:hover {
  box-shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
}
/* Hover and press are a scrim over the button — 8% then 12% — not a new fill,
   so the white and the border stay the ones the guidelines name. */
.google-btn::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: #303030; opacity: 0; transition: opacity .218s;
}
.google-btn:hover::after { opacity: .08; }
.google-btn:active::after { opacity: .12; }

/* --- 6. status & notices --------------------------------------------------- */

/* Tags are flat and dense like the rest of the workspace — radius 4, not pills.
   A tag never appears without a sentence nearby saying the same thing. */
.tag {
  display: inline-block; padding: 3px 8px; border-radius: var(--radius-s); font-size: .78rem;
  font-weight: 600; border: 1px solid var(--line-strong); color: var(--ink-soft);
  background: var(--t-band);
}
.tag.done { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.tag.attention { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.tag.problem { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.tag.current { background: var(--elder-soft); color: var(--elder); border-color: var(--t-elder-soft-line); }

.notice {
  border: 1px solid var(--line-strong); border-left: 4px solid var(--ink-faint);
  background: var(--t-band); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.notice.info { border-left-color: var(--elder); background: var(--elder-soft); }
.notice.good { border-left-color: var(--green); background: var(--green-soft); }
.notice.warn { border-left-color: var(--amber); background: var(--amber-soft); }
.notice.bad  { border-left-color: var(--red); background: var(--red-soft); }
.notice p:last-child { margin-bottom: 0; }

/* Nota — the one next-action pointer. One per view; it spends the view's
   single Elder allowance. */
.nota { display: inline-flex; align-items: center; gap: 8px; color: var(--elder); font-weight: 600; }
.nota .manicule { font-size: 1.15rem; }
/* Nota beside its target: pointer and action share a line, the hand adjacent
   to the button it points at. */
.nota-beside { display: inline-flex; align-items: center; gap: 10px; }
.nota-beside .nota { white-space: nowrap; }

/* --- 7. checklist & steps -------------------------------------------------- */

.checklist { counter-reset: step; }
.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 12px;
}
.step.current { border-color: var(--elder); box-shadow: 0 0 0 3px var(--elder-soft); }
.step.done { background: var(--surface-rest); }
.step-head { display: flex; gap: 14px; align-items: baseline; justify-content: space-between; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--hairline); color: var(--ink-soft);
  font-size: .875rem; font-weight: 700; flex: 0 0 auto;
}
.step.done .step-num { background: var(--green-soft); color: var(--green); }
.step.current .step-num { background: var(--elder); color: var(--t-on-dark); }
.step-title { font-weight: 600; font-size: 1.05rem; }
.gate { padding: 10px 0 10px 42px; border-top: 1px solid var(--hairline); }
.gate:first-of-type { border-top: none; }
.gate-line { display: flex; gap: 10px; align-items: baseline; }
.gate-mark { flex: 0 0 auto; width: 18px; color: var(--ink-faint); font-weight: 700; }
.gate-mark.done { color: var(--green); }
.gate-body { flex: 1; min-width: 0; }
.gate-note { color: var(--ink-soft); font-size: .94rem; }

/* --- 8. tables & data ------------------------------------------------------ */

table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top;
}
/* Sentence case, like everything else — headers are read, not shouted. */
table.data th { font-size: .875rem; font-weight: 600; color: var(--ink-faint); }
table.data tr:last-child td { border-bottom: none; }
table.data th.col-40, table.data td.col-40 { width: 40%; }
.wrap-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.wrap-scroll:focus-visible { outline: var(--t-focus-ring); outline-offset: 2px; }

.mono { font-family: var(--mono); font-size: .95em; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.big { font-size: 1.3rem; }
.break-all { word-break: break-all; }

/* A figure the page is really about: a balance, a total, a count. */
.stat { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat.large { font-size: 2rem; }

/* Tall enough to read a page of a document, but it must survive 400% zoom on a
   phone, so it's viewport-relative rather than a fixed 600px. */
.doc-preview {
  /* True white: this is the document's own paper, not a brand surface. */
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 0;
  overflow: auto;
}
.doc-preview iframe {
  width: 100%; height: min(75vh, 720px); min-height: 320px; border: 0; display: block;
}

/* --- document viewer: the sheet on its desk, and the places-to-sign rail ----
   The document renders inside the iframe as a white sheet (documents.PREVIEW_CSS);
   out here live the rail of gold flags — one per place the current signer's name
   lands — and the head that names the exact file. Gold = the watchful pause: a
   place still waiting for a name. A visited flag goes quiet, not green; "seen"
   is not a durable fact. */

/* The pack: an agreement's documents in reading order. Signed ones go quiet and
   stay openable — a signature is a record you can return to, not a closed door.
   The open one carries the same left seam a current step carries elsewhere. */
.pack-list { list-style: none; margin: 0; padding: 0; }
.pack-item {
  display: flex; gap: 12px; align-items: baseline; justify-content: space-between;
  padding: 10px 12px; border-top: 1px solid var(--hairline);
  border-left: 3px solid transparent;
}
.pack-item:first-child { border-top: 0; }
.pack-item.open { border-left-color: var(--amber); background: var(--t-band); }
.pack-item > .small { flex: 0 0 auto; }

.doc-viewer-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.doc-stage { display: flex; gap: 16px; align-items: stretch; }
.doc-paper {
  flex: 1; min-width: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--t-band-deep);
}
.doc-paper iframe {
  width: 100%; height: min(78vh, 860px); min-height: 360px; border: 0; display: block;
}

/* Phones get no scroll-inside-scroll: a rendered document expands to its full
   height (termn.js measures it) and reads with the page, while a PDF embed —
   which can't expand — shrinks to a glance and hands off to this full-screen
   doorway. Hidden on wide screens, where the reading pane does the job. */
.doc-open-mobile { display: none; margin-top: 8px; }

.doc-rail {
  flex: 0 0 190px; align-self: flex-start;
  display: flex; flex-direction: column; gap: 10px;
}
.doc-rail-title { font-weight: 600; font-size: .94rem; }
.doc-rail > .small { margin: 0; }
.spot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.spot-link {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px;
  padding: 8px 12px; text-align: left; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--amber-soft); color: var(--amber);
  border: 1px solid var(--amber-line); border-left: 3px solid var(--amber);
  border-radius: var(--radius-control);
}
.spot-link:hover { border-color: var(--amber); }
.spot-link .spot-label { flex: 1; min-width: 0; }
.spot-link .spot-state { font-size: .875rem; font-weight: 400; }
.spot-link.seen {
  background: var(--surface-rest); color: var(--ink-soft);
  border-color: var(--line); border-left-color: var(--line-strong);
}

/* The mark a typed name becomes, previewed before anything is signed. */
.sig-preview {
  margin: 4px 0 16px; padding: 12px 16px;
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-control);
}
.sig-preview-mark {
  font-family: var(--script);
  font-size: 1.5rem; line-height: 1.3; padding-bottom: 4px;
  border-bottom: 1px solid var(--ink); overflow-wrap: anywhere;
}
.sig-preview-meta { font-size: .875rem; color: var(--ink-soft); margin-top: 6px; }
.sig-preview-initials {
  font-family: var(--script); color: var(--ink);
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: .94rem; }
.timeline li:last-child { border-bottom: none; }
.timeline .when { color: var(--ink-faint); font-size: .875rem; }

/* Quiet fact lists: label/value pairs separated by hairlines. */
.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li { padding: 8px 0; border-top: 1px solid var(--hairline); font-size: .94rem; }
.fact-list li:first-child { border-top: 0; }
.fact-list .small { display: block; }

/* --- 9. contact book & dialog ---------------------------------------------- */

/* Record-identity wells: a small square of the record's own material, beside
   its name. A well answers "what kind of record is this" — never "what is
   true now"; status stays in words and tags. Each shape pairs hue with a
   face so color never speaks alone:
     person   — plum, sans initials
     entity   — umber, serif initials (the legal-document face)
     account  — petrol, the bank glyph
     document — graphite, the page glyph (folders: the folder glyph) */
.well, .contact-well {
  flex: 0 0 auto; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control);
  background: var(--contact-soft); color: var(--contact);
  border: 1px solid var(--contact-line);
  font-size: .875rem; font-weight: 600; letter-spacing: .02em;
}
.well.entity {
  background: var(--entity-soft); color: var(--entity); border-color: var(--entity-line);
  font-family: var(--serif); font-weight: 600; border-radius: var(--radius-s);
}
.well.account {
  background: var(--account-soft); color: var(--account); border-color: var(--account-line);
  border-radius: var(--radius-s);
}
.well.document {
  background: var(--document-soft); color: var(--document); border-color: var(--document-line);
  border-radius: var(--radius-s);
}
.well.account svg, .well.document svg { width: 18px; height: 18px; display: block; }
.well.large, .contact-well.large { width: 52px; height: 52px; font-size: 1.15rem; }
.well.large svg { width: 24px; height: 24px; }
.row .well, .row .contact-well { margin-top: 2px; }
.row-with-well { display: flex; gap: 14px; align-items: flex-start; min-width: 0; flex: 1; }

/* Record-seam panels: a picker or card carries its record's hue on the left
   edge — the same seam the picker fieldsets use. */
.picker.entity, .picker-card.entity { border-left-color: var(--entity); }
.picker.account, .picker-card.account { border-left-color: var(--account); }

.contact-facts { list-style: none; margin: 0; padding: 0; }
.contact-facts li { padding: 8px 0; border-top: 1px solid var(--hairline); font-size: .94rem; }
.contact-facts li:first-child { border-top: 0; }
.contact-facts .small { display: block; }

fieldset.picker {
  border: 1px solid var(--line);
  border-left: 3px solid var(--contact);
  border-radius: var(--radius);
  padding: 16px 18px 4px;
  margin: 0 0 20px;
  background: var(--surface-rest);
}
fieldset.picker legend { font-weight: 600; padding: 0 8px; font-size: 1.05rem; }
.picker-or {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-faint); font-size: .875rem; margin: 2px 0 16px;
}
.picker-or::before, .picker-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.picker-heading { font-size: 1rem; margin: 0 0 2px; }

/* The chosen-contact card (termn.js): the picker collapsed into a decision made. */
.picker-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--contact);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  margin: 10px 0 4px;
}
.picker-card strong { font-weight: 600; }
.picker-card-actions { display: inline-flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* The control a picker collapses into: one doorway that opens the book. */
.book-open {
  display: block; width: 100%; min-height: 48px; margin: 4px 0;
  padding: 12px 14px; text-align: left;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--elder);
  font: inherit; font-weight: 600; cursor: pointer;
}
.book-open:hover { border-color: var(--elder); background: var(--elder-soft); }

dialog.book {
  width: min(620px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  padding: 0; margin: auto;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
dialog.book[open] { display: flex; flex-direction: column; }
dialog.book::backdrop { background: rgba(15, 14, 13, .45); }

.book-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.book-head h2 { margin: 0; font-size: 1.15rem; }
.book-body { padding: 16px 18px; overflow: auto; }

.book-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.book-toolbar [data-book-search] { flex: 1; min-width: 200px; }

.book-rows { list-style: none; margin: 0; padding: 0; }
.book-row { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--hairline); }
.book-row:first-child { border-top: 0; }
.book-row.waiting { color: var(--ink-faint); padding: 12px 10px; }
.book-row.waiting .well { opacity: .65; }
.book-pick {
  flex: 1; display: flex; align-items: center; gap: 12px; min-height: 52px;
  padding: 10px; text-align: left;
  background: none; border: 0; border-radius: var(--radius-control);
  font: inherit; color: inherit; cursor: pointer;
}
.book-pick:hover { background: var(--elder-soft); }
.book-pick-text { display: flex; flex-direction: column; min-width: 0; }
.book-pick-text .row-title { font-weight: 600; }
.book-pick-text .row-meta { color: var(--ink-soft); font-size: .94rem; }
.book-row.waiting .row-meta { color: inherit; }
.book-empty { padding: 14px 4px; color: var(--ink-soft); }
.book-loading { color: var(--ink-faint); margin: 8px 0; }
.book-form-title { margin-bottom: 4px; }

/* --- 10. participant / centred pages --------------------------------------- */

.centered { max-width: 680px; margin: 0 auto; padding: 40px 20px 80px; }
.centered.narrow { max-width: 480px; }
.centered.wide { max-width: 820px; }

/* The head of a plain page: the wordmark keeps its own rule; session meta
   sits beside it, outside the underline. */
.plain-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  flex-wrap: wrap; margin-bottom: 26px;
}
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 1.15rem;
  width: max-content; padding-bottom: 2px; border-bottom: 2px solid var(--elder);
}
.brand span { color: var(--elder); font-weight: 700; }
.centered > .brand { margin-bottom: 26px; }
.plain-head .session { font-size: .875rem; color: var(--ink-soft); font-weight: 400; }

.from-org { color: var(--ink-soft); margin-bottom: 22px; }

.secure-note {
  font-size: .875rem; color: var(--ink-soft); border-top: 1px solid var(--line);
  padding-top: 14px; margin-top: 26px;
}

/* The signing box sits directly under the document, where a reader ends up.
   With JavaScript, termn.js lifts it into a dialog; inside one it sheds its own
   frame — the dialog is the room. */
.sign-here {
  margin-top: 18px; padding: 18px; border-radius: var(--radius);
  border: 2px solid var(--elder); background: var(--elder-soft);
}
.sign-here h3 { margin: 0 0 6px; }
.book-body .sign-here { margin-top: 0; padding: 0; border: 0; background: transparent; }

/* --- the doorway: sign in, set up, and the pages between -------------------- */
/* The threshold between the site and the workspace, and the one app-served
   surface that wears the marketing dress (spec/16 § The doorway): the navy
   Elder field with its violet seam and gold glint, the wordmark at display
   size, the serif statement voice. The paper side stays app dress — same
   controls, same targets — because the first thing someone sees of the product
   should be the product. */

.door { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); min-height: 100vh; }

/* The page's one dark field, built to the marketing bookend recipe: two soft
   lights over elder-deep, violet high and elder low. Both are alpha forms of
   --t-elder-violet and --t-elder. */
.door-side {
  position: relative; padding: 60px 48px 48px;
  display: flex; flex-direction: column; gap: 22px;
  background:
    radial-gradient(760px 420px at 82% 6%, rgba(75, 58, 96, .38), transparent 62%),
    radial-gradient(720px 440px at 4% 98%, rgba(43, 74, 120, .5), transparent 66%),
    var(--elder-deep);
  color: var(--t-on-dark-soft);
}
/* The Elder frame: the violet seam above, the gold glint down the seam this
   field shares with the paper. */
.door-side::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--t-elder-violet) 25%,
                              var(--t-elder-violet) 60%, transparent 92%);
}
.door-side::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 2px;
  background: linear-gradient(180deg, transparent 6%, var(--t-gold-glint) 42%,
                              var(--t-gold-glint) 64%, transparent 96%);
}
.door-side :focus-visible { outline-color: var(--elder-lift); box-shadow: none; }

/* The signature at door scale: serif Term, lifted-blue n, one continuous rule
   under the whole word. The rule is drawn rather than a border so it can ink in
   once on load — the single motion the brand allows it, and nowhere else. */
.door-wordmark {
  position: relative; align-self: flex-start; width: max-content;
  font-family: var(--serif); font-weight: 600; font-size: 1.85rem; line-height: 1.05;
  color: var(--t-on-dark); text-decoration: none; padding-bottom: 5px;
}
.door-wordmark span { color: var(--elder-lift); font-weight: 700; }
.door-wordmark::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--elder-lift); transform-origin: left;
  animation: door-rule-in 640ms cubic-bezier(.25, .6, .3, 1) both;
}
@keyframes door-rule-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.door-statement {
  margin: 6px 0 0; max-width: 13em;
  font-family: var(--serif); font-weight: 600; letter-spacing: -.01em;
  font-size: clamp(1.7rem, 2.7vw, 2.3rem); line-height: 1.12;
  color: var(--t-on-dark); text-wrap: balance;
}

/* Agree, move, prove — the three planes, stated once. The gold rule is the
   working accent doing its job on navy; it carries no status. */
.door-spine {
  list-style: none; margin: 4px 0 0; padding: 0; max-width: 34ch;
  display: flex; flex-direction: column; gap: 16px;
}
.door-spine li { position: relative; padding-left: 34px; font-size: .94rem; color: var(--t-on-dark-muted); }
.door-spine li::before {
  content: ""; position: absolute; left: 0; top: .66em; width: 22px; height: 2px;
  border-radius: 1px; background: var(--t-gold-glint);
}
.door-spine b { display: block; color: var(--t-on-dark); font-weight: 600; }

/* The boundary states itself unprompted wherever money movement is described. */
.door-boundary {
  margin: auto 0 0; padding-top: 24px; max-width: 40ch;
  border-top: 1px solid var(--t-on-dark-line);
  font-size: .875rem; color: var(--t-on-dark-muted);
}

.door-main {
  display: flex; flex-direction: column; justify-content: center;
  padding: 56px 40px 64px; background: var(--paper);
}
.door-body { width: 100%; max-width: 460px; margin: 0 auto; }
/* Signed in as the wrong address is the common mistake on this side, so the
   session says who it is and where the door out is, above everything. */
.door-session {
  font-size: .875rem; color: var(--ink-soft); margin: 0 0 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--hairline);
}
/* The form is the thing being presented, so it is this page's one shadowed
   surface, and its heading answers the statement in the same face. */
.door-body .card { box-shadow: var(--shadow); border-color: var(--hairline); padding: 24px 26px 20px; }
.door-body h1 { font-family: var(--serif); }
.door-body .secure-note { margin-top: 20px; }

/* --- landing (public pages served from the app) ---------------------------- */

.hero { padding: 64px 0 36px; }
.hero h1 { font-size: 2.6rem; max-width: 16ch; }
.hero p.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 54ch; }
.price-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--surface); }
.price-card .price { font-size: 2rem; font-weight: 700; }
.price-card ul { margin: 12px 0 0; padding-left: 20px; }
.price-card li { margin-bottom: 6px; }

/* --- 11. utilities (rhythm-locked) ----------------------------------------- */
/* The only sanctioned replacement for an inline style. Steps follow the brand
   rhythm 4/8/16/24/40; if a gap wants another number, the component is wrong. */

.mt-0  { margin-top: 0 !important; }
.mt-4  { margin-top: 4px !important; }
.mt-8  { margin-top: 8px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-24 { margin-top: 24px !important; }
.mt-40 { margin-top: 40px !important; }
.mb-0  { margin-bottom: 0 !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-24 { margin-bottom: 24px !important; }
.center { text-align: center; }
.list-compact { margin: 0; padding-left: 18px; }
.plain { font-weight: 400; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; min-width: 0; }
.max-s  { max-width: 480px; }
.max-m  { max-width: 560px; }
.max-l  { max-width: 680px; }
.max-xl { max-width: 820px; }

/* --- 12. responsive -------------------------------------------------------- */

/* The doorway folds earlier than the shell: two columns need room for the
   statement and a full-width form beside it. Folded, the navy field becomes a
   band — wordmark, statement, and the three planes as three words, since the
   form is what the page is for and it should be reachable without a scroll. */
@media (max-width: 940px) {
  .door { grid-template-columns: 1fr; min-height: 0; }
  .door-side { padding: 26px 24px 22px; gap: 13px; }
  .door-side::after {
    top: auto; right: 0; bottom: 0; left: 0; width: auto; height: 2px;
    background: linear-gradient(90deg, transparent 8%, var(--t-gold-glint) 42%,
                                var(--t-gold-glint) 70%, transparent 96%);
  }
  .door-wordmark { font-size: 1.3rem; }
  .door-statement { font-size: 1.3rem; max-width: 22ch; }
  .door-spine { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; max-width: none; }
  .door-spine li { padding-left: 28px; }
  .door-spine li span { display: none; }
  .door-boundary { margin-top: 0; padding-top: 14px; max-width: none; }
  .door-main { padding: 28px 20px 56px; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  /* On phones the rail is one line of chrome: wordmark left, Menu right, and
     the destinations fold behind the button (termn.js). Without JavaScript
     the same markup lays out as a scrollable strip — navigation never dies. */
  .rail {
    width: 100%; flex: none; flex-direction: row; align-items: center;
    gap: 4px; padding: 8px 10px;
  }
  /* The signature keeps its rule, stopped at the n. */
  .rail .wordmark { margin: 0 12px 0 2px; padding: 0 0 2px; width: max-content; flex: 0 0 auto; }
  .topbar { padding: 10px 18px; min-height: 52px; }
  .content { padding: 18px; }

  /* --- no JavaScript: the scrollable strip --- */
  html:not(.js) .rail {
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  html:not(.js) .rail::-webkit-scrollbar { display: none; }
  html:not(.js) .rail a { flex: 0 0 auto; white-space: nowrap; padding: 10px 12px; }
  html:not(.js) .rail-group { margin-top: 0; display: contents; }
  html:not(.js) .rail-label { display: none; }
  html:not(.js) .rail a.current { box-shadow: inset 0 -2px 0 var(--elder-lift); }
  html:not(.js) .rail .rail-foot {
    margin: 0 0 0 auto; padding: 0 2px 0 10px;
    flex-direction: row; align-items: center; gap: 12px;
  }
  html:not(.js) .rail .rail-foot .rail-user { display: none; }
  html:not(.js) .rail .rail-foot a { white-space: nowrap; padding: 10px 0; }

  /* --- with JavaScript: the menu fold --- */
  html.js .rail { flex-wrap: wrap; justify-content: space-between; }
  html.js .rail-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 10px 12px; margin: 0;
    border: 0; border-radius: var(--radius-control);
    background: none; color: var(--t-on-dark-soft);
    font: inherit; font-size: .94rem; font-weight: 500; cursor: pointer;
  }
  html.js .rail-toggle:hover { background: rgba(255, 254, 253, .07); color: var(--t-on-dark); }
  html.js .rail-toggle[aria-expanded="true"] { background: rgba(255, 254, 253, .12); color: var(--t-on-dark); }
  html.js .rail-toggle:focus-visible { outline-color: var(--elder-lift); box-shadow: none; }
  html.js .rail-menu { display: none; }
  html.js .rail[data-open] .rail-menu {
    display: flex; flex-direction: column; gap: 2px;
    flex: 0 0 100%; padding: 10px 2px 6px;
    border-top: 1px solid var(--t-on-dark-line); margin-top: 8px;
  }
  html.js .rail[data-open] .rail-group { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
  html.js .rail[data-open] .rail-label { display: block; }
  html.js .rail[data-open] .rail-foot {
    margin-top: 14px; padding: 12px 12px 2px;
    border-top: 1px solid var(--t-on-dark-line);
  }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  /* The places rail folds into a row of flags above the sheet. */
  .doc-stage { flex-direction: column; }
  .doc-rail { flex-basis: auto; width: 100%; }
  .spot-list { flex-direction: row; flex-wrap: wrap; }
  .spot-list li { flex: 1 1 140px; }
  /* A PDF embed becomes a glance, not a scroll trap; the full-screen button
     appears beside it. A rendered document instead grows to its full height
     (inline style from termn.js) so the page is the only thing that scrolls. */
  .doc-paper iframe { height: 320px; min-height: 0; }
  .doc-open-mobile { display: inline-flex; }
}

@media (max-width: 560px) {
  /* A screen's one action drops under its title rather than being squeezed
     into a sliver beside it. */
  .card-head { flex-wrap: wrap; }
  .page-head .card-head { flex-direction: column; align-items: stretch; gap: 4px; }
  .page-head .card-head .btn { width: 100%; }

  /* A row's action drops below its text rather than being squeezed into a
     sliver of it. Participants read these on phones more than anyone reads
     the rest. */
  .row { flex-direction: column; gap: 12px; }
  .row .row-side { text-align: left; width: 100%; }
  .row .row-side .btn { width: 100%; }
  /* A destructive action never stretches to become the widest thing in the row. */
  .row .row-side .btn.danger { width: auto; }
  /* Not enough room for the label — the hand alone points at the button. */
  .row .row-side .nota-beside { display: flex; width: 100%; align-items: center; }
  .row .row-side .nota-beside .nota-label { display: none; }
  .row .row-side .nota-beside form { flex: 1; }

  /* Wide label/value tables become stacked pairs where columns don't fit. */
  table.stacked, table.stacked tbody, table.stacked tr, table.stacked th, table.stacked td {
    display: block; width: 100%;
  }
  table.stacked th { border: none; padding-bottom: 0; background: none; }
  table.stacked td { border: none; padding-top: 2px; padding-bottom: 12px; word-break: break-word; }
  table.stacked tr { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
