/* Living Ledger — Resolution Portal Stylesheet
 * Cohesion Principles (binding):
 *   1. Document Static; Record Alive
 *   2. Mono = System; Serif = Human
 *   3. Restraint is the Only Embellishment
 *   4. Interface is an Instrument, Not a Conversation
 *   5. Visual Continuity of Evidence (screen ≡ PDF)
 */

@import url("./living-ledger/tokens.css");
@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400..700;1,8..60,400..700&family=Fraunces:ital,opsz,wght@0,9..144,300..700;1,9..144,300..700&family=JetBrains+Mono:wght@400;500&display=swap");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  /* Subtle paper grain — Restraint principle: pattern at 2.5% opacity max */
  background-image:
    radial-gradient(rgba(21,19,13,0.022) 1px, transparent 1px),
    radial-gradient(rgba(21,19,13,0.012) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 1px;
  /* Reserve space for sticky footer */
  padding-bottom: 64px;
}

::selection { background: var(--ink); color: var(--paper); }

/* ===================== Alert strip (deadline thresholds) ===================== */
/* Single-line mono strip that appears between status bar and content at warn/urgent/expired.
   No popup, no flash, no audio — just a sustained visible state per cohesion principle 3. */
.alert-strip {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 10px var(--gutter);
  font-family: var(--mono-system);
  font-size: var(--fs-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: var(--rule-w) solid var(--rule);
  background: var(--paper-shade);
  color: var(--ink);
}
.alert-strip[hidden] { display: none; }
.alert-strip__label {
  color: var(--ink-mute);
  font-size: var(--fs-mono-sm);
}

/* Warn: <24 hours remaining */
body[data-urgency="warn"] .alert-strip {
  background: var(--paper-shade);
  color: var(--oxblood-text);
}
body[data-urgency="warn"] .alert-strip__label { color: var(--oxblood-text); }

/* Urgent: <1 hour remaining */
body[data-urgency="urgent"] .alert-strip {
  background: var(--oxblood);
  color: var(--paper);
  border-bottom-color: var(--oxblood);
}
body[data-urgency="urgent"] .alert-strip__label { color: var(--paper); opacity: 0.85; }

/* Expired: deadline passed; portal locks read-only */
body[data-state="expired"] .alert-strip {
  background: var(--ink);
  color: var(--paper);
  border-bottom-color: var(--ink);
}
body[data-state="expired"] .alert-strip__label { color: var(--paper); opacity: 0.85; }

/* ===================== Top status bar (mobile-first) ===================== */
/* Per qwen-397b: telemetry on mobile = top status bar like iOS battery indicator.
   On desktop it's the bottom footer; on mobile it's the top strip.
   Two-row layout on narrow screens to avoid cramped one-line truncation. */
.status-bar {
  position: sticky; top: 0; z-index: 60;
  background: var(--footer-bg); color: var(--footer-fg);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "state case"
    "remaining remaining";
  align-items: center;
  column-gap: var(--space-3); row-gap: 2px;
  padding: 8px var(--gutter);
  font-family: var(--mono-system);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: var(--rule-w) solid var(--footer-rule);
}
.status-bar .left   { grid-area: state; text-align: left; }
.status-bar .center { grid-area: case; text-align: right; color: var(--paper); }
.status-bar .right  { grid-area: remaining; text-align: left; padding-top: 2px; border-top: 1px solid var(--footer-rule); }
.status-bar .countdown { color: var(--paper); font-variant-numeric: tabular-nums; }
.status-bar .countdown--urgent { color: var(--oxblood); }

/* ===================== The Note (one continuous letter) ===================== */
.note {
  max-width: var(--content-max);
  margin: var(--space-7) auto var(--space-4);
  padding: 0 var(--gutter);
}

.note > p {
  margin: 0 0 var(--space-4);
}

.note h2 {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-section);
  letter-spacing: -0.01em;
  color: var(--oxblood);
  margin: var(--space-7) 0 var(--space-3);
  text-transform: none;
}

/* Section number sits on its own line ABOVE the title — clean stacked treatment.
   Avoids the cramped inline rendering where the small mono bumped the italic title. */
.note h2 .num {
  display: block;
  font-family: var(--mono-system);
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin: 0 0 6px;
}

.note strong, .note b {
  font-weight: 600;
  color: var(--ink);
}

.note em {
  font-style: italic;
}

.note code, .note .statute {
  font-family: var(--mono-system);
  font-size: 0.92em;
  background: var(--paper-shade);
  padding: 0 4px;
  border-radius: 1px;
  color: var(--ink);
}

.note .sign {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 22px;
  color: var(--oxblood-text);
  margin: var(--space-7) 0 var(--space-5);
}

/* ===================== Docket (document record below the note) ===================== */
.docket {
  max-width: var(--content-max);
  margin: var(--space-5) auto var(--space-7);
  padding: var(--space-4) var(--gutter);
  border-top: var(--rule-w) solid var(--ink);
  border-bottom: var(--rule-w) solid var(--rule);
  background: transparent;
}

.docket__heading {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: var(--rule-w) solid var(--rule);
}

/* The docket reuses .memo-row markup but is now styled as a footer record block */
.docket .memo-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--space-3);
  padding: 4px 0;
  align-items: baseline;
  font-family: var(--mono-system);
  font-size: var(--fs-mono);
}
.docket .memo-row .k {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--fs-mono-sm);
  color: var(--ink-mute);
}
.docket .memo-row .v {
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  letter-spacing: 0;
  text-transform: none;
}
@media (max-width: 600px) {
  .docket .memo-row {
    grid-template-columns: 110px 1fr;
  }
}

.docket__notice {
  font-family: var(--mono-system);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: var(--ink-mute);
  margin: var(--space-4) 0 0;
  padding-top: var(--space-3);
  border-top: var(--rule-w) solid var(--rule);
  font-style: italic;
}

/* ===================== Letterhead (cover) ===================== */
.letterhead {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-7) var(--gutter) var(--space-5);
}

/* Memo-style addressing block — formal correspondence framing */
.memo {
  font-family: var(--mono-system);
  font-size: var(--fs-mono);
  letter-spacing: 0.05em;
  color: var(--ink);
  border-top: var(--rule-w) solid var(--ink);
  border-bottom: var(--rule-w) solid var(--rule);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-7);
}

.memo-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--space-3);
  padding: 4px 0;
  align-items: baseline;
}

.memo-row .k {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--fs-mono-sm);
  color: var(--ink-mute);
}

.memo-row .v {
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  letter-spacing: 0;
  text-transform: none;
}

h1.title {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-display-1);
  line-height: var(--lh-display);
  letter-spacing: -0.02em;
  color: var(--oxblood); /* OXBLOOD USE 1 — display headers only */
  margin: 0 0 var(--space-3);
  font-variation-settings: "opsz" 144, "SOFT" 60;
}

.subtitle {
  font-family: var(--serif-body);
  font-style: italic;
  font-size: 21px;
  line-height: 1.4;
  color: var(--ink-soft);
  margin: 0 0 var(--space-5);
  max-width: 50ch;
}

.subtitle .amp,
h1 .amp {
  font-style: italic;
  font-family: var(--serif-display);
  color: var(--oxblood);
  margin: 0 0.05em;
}

.lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink); /* upgraded from --ink-soft for AAA contrast */
  max-width: 58ch;
  margin: 0 0 var(--space-6);
  text-wrap: pretty;
  border-top: var(--rule-w) solid var(--rule);
  padding-top: var(--space-4);
}

/* ===================== Letter body ===================== */
.letter {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-7);
}

.letter h2 {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-section);
  letter-spacing: -0.01em;
  color: var(--oxblood); /* OXBLOOD USE 1 cont. — section headers */
  margin: var(--space-7) 0 var(--space-3);
  text-transform: none;
}

.letter h2 .num {
  font-family: var(--mono-system);
  font-style: normal;
  font-size: 0.55em;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  display: inline-block;
  margin-right: var(--space-3);
  vertical-align: middle;
}

.letter p {
  margin: 0 0 var(--space-4);
}

.letter p + p { margin-top: 0; }

.letter strong, .letter b {
  font-weight: 600;
  color: var(--ink);
}

.letter em {
  font-style: italic;
}

/* Statute citations get mono treatment — Cohesion Principle 2:
   Mono = System (statutes are code-of-law) */
.letter code, .statute {
  font-family: var(--mono-system);
  font-size: 0.92em;
  background: var(--paper-shade);
  padding: 0 4px;
  border-radius: 1px;
  color: var(--ink);
}

/* ===================== Prohibition list (under §03) ===================== */
.prohibition-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 2px solid var(--rule-strong);
  padding-left: var(--space-4);
  font-size: var(--fs-body-sm);
}
.prohibition-list li::before {
  content: "—  ";
  color: var(--ink-mute);
  font-family: var(--mono-system);
}

/* ===================== Penalty list (under §05) ===================== */
.penalty-list {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-left: 2px solid var(--rule-strong);
  padding-left: var(--space-4);
}
.penalty-list li {
  font-size: var(--fs-body-sm);
  color: var(--ink);
  line-height: 1.55;
}
.penalty-list strong {
  color: var(--oxblood-text);
  font-weight: 600;
}

/* ===================== Post links (clickable URLs to the actual posts) ===================== */
/* Per Living Ledger restraint: no blue/rainbow link colors. Ink with single
   underline. Mono URL fragment styled like statute. Small ↗ icon signals
   external nav. */
.post-list {
  list-style: none;
  padding: 0 0 0 var(--space-4);
  margin: var(--space-3) 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 2px solid var(--rule-strong);
}

.post-list li {
  font-size: var(--fs-body-sm);
  line-height: 1.55;
  color: var(--ink);
}

.post-list strong {
  color: var(--oxblood-text);
  font-weight: 600;
}

.post-list--inline {
  margin: var(--space-2) 0 0;
  padding-left: 0;
}

.post-link {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-3);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.post-link__platform {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  min-width: 70px;
}

.post-link__action {
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.post-link:hover .post-link__action,
.post-link:focus-visible .post-link__action {
  color: var(--oxblood-text);
  border-bottom-color: var(--oxblood-text);
}

.post-link:focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 4px;
}

.post-link__icon {
  font-family: var(--mono-system);
  font-size: 0.85em;
  color: var(--ink-mute);
  letter-spacing: 0;
}

.post-link:hover .post-link__icon,
.post-link:focus-visible .post-link__icon {
  color: var(--oxblood-text);
}

/* ===================== Gloss triggers (click-to-expand) ===================== */
/* Inline button styled to look like an interactive term. Restraint:
   no shadows, no borders — just an underline + small ⓘ marker. */
.gloss-trigger {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: help;
  text-align: left;
  border-bottom: 1px dotted var(--ink-mute);
  position: relative;
}
.gloss-trigger:focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 2px;
}
.gloss-trigger::after {
  content: " ⓘ";
  font-size: 0.78em;
  color: var(--ink-mute);
  vertical-align: super;
  margin-left: 1px;
}
.gloss-trigger[aria-expanded="true"]::after {
  content: " ⊖";
  color: var(--oxblood-text);
}
.gloss-trigger[aria-expanded="true"] {
  border-bottom-color: var(--oxblood-text);
}

/* Glossary container holds the panels in document flow */
.glossary {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.gloss-panel {
  border-left: 2px solid var(--rule-strong);
  background: var(--paper-shade);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-3);
  font-family: var(--serif-body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  /* Mobile: cap panel height so it doesn't push the rest off-screen */
  max-height: 60vh;
  overflow-y: auto;
}
.gloss-panel[hidden] { display: none; }

.gloss-panel__tag {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: block;
  margin-bottom: var(--space-2);
  padding-bottom: 4px;
  border-bottom: var(--rule-w) solid var(--rule);
}

.gloss-panel p {
  margin: 0;
  color: var(--ink-soft);
}

/* ===================== Options block (action high in document) ===================== */
.options {
  max-width: var(--content-max);
  margin: var(--space-6) auto var(--space-6);
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 720px) {
  .options { grid-template-columns: 1fr 1fr; gap: var(--space-5); }
}

.option {
  border: var(--rule-w) solid var(--ink);
  background: var(--paper);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.option .label {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.option h3 {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-display-2);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}

.option p { margin: 0; color: var(--ink-soft); font-size: var(--fs-body-sm); }

.option-steps {
  margin: 0 0 var(--space-3);
  padding-left: 22px;
  font-size: var(--fs-body-sm);
  color: var(--ink-soft);
}

.option-steps li {
  margin-bottom: var(--space-2);
  line-height: 1.5;
}

.option-warn {
  font-size: 13px;
  color: var(--ink-soft);
  border-top: var(--rule-w) solid var(--rule);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  line-height: 1.5;
}

/* ===================== Option-flow (action guide revealed on selection) ===================== */
.option-flow {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 2px solid var(--ink);
}
.option-flow[hidden] { display: none; }

.option-flow__heading {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 var(--space-4);
}

.flow-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.flow-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: var(--rule-w) solid var(--rule);
}
.flow-step:last-child { border-bottom: 0; }

.flow-step__mark {
  font-family: var(--mono-system);
  font-size: 16px;
  color: var(--ink-mute);
  line-height: 1.2;
}
.flow-step[data-status="done"] .flow-step__mark {
  content: "✓";
  color: var(--oxblood-text);
  font-weight: 600;
}
.flow-step[data-status="done"] .flow-step__mark::before { content: "✓"; }
.flow-step[data-status="done"] .flow-step__mark { font-size: 0; }
.flow-step[data-status="done"] .flow-step__mark::before { font-size: 16px; }

.flow-step__body h4 {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 var(--space-2);
}

.flow-step__body p {
  font-size: var(--fs-body-sm);
  color: var(--ink-soft);
  margin: 0 0 var(--space-3);
  line-height: 1.55;
}

.flow-step__body .post-link {
  display: inline-flex;
  margin-bottom: var(--space-3);
}

.flow-step__body code {
  font-family: var(--mono-system);
  background: var(--paper-shade);
  padding: 0 4px;
  font-size: 0.9em;
}

/* Verification log textarea */
.verlog-input {
  width: 100%;
  font-family: var(--mono-system);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  border: var(--rule-w) solid var(--rule);
  padding: var(--space-3);
  resize: vertical;
  border-radius: 0;
  margin-bottom: var(--space-3);
}

.verlog-uploads {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--paper-shade);
  border-left: 2px solid var(--rule-strong);
}
.upload-label {
  display: block;
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: var(--space-2);
}
.upload-hint {
  letter-spacing: 0;
  text-transform: none;
  font-style: italic;
}
.verlog-uploads input[type="file"] {
  display: block;
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
}
.upload-stub-note {
  font-family: var(--mono-system);
  font-size: 11px;
  color: var(--ink-mute);
  font-style: italic;
  margin: var(--space-2) 0 0;
}

/* Declaration block */
.declaration-text {
  background: var(--paper);
  border: var(--rule-w) solid var(--rule);
  padding: var(--space-3) var(--space-4);
  font-family: var(--serif-body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 var(--space-3);
}

.acknowledge {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--fs-body-sm);
  color: var(--ink);
  margin-bottom: var(--space-2);
  cursor: pointer;
}
.acknowledge input[type="checkbox"] {
  margin-top: 4px;
  flex-shrink: 0;
}

.signfield {
  display: block;
  margin: var(--space-3) 0 var(--space-2);
}
.signfield__label {
  display: block;
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: var(--space-2);
}
.signfield__input {
  width: 100%;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 22px;
  color: var(--oxblood-text);
  background: var(--paper);
  border: 0;
  border-bottom: 2px solid var(--ink);
  padding: var(--space-2) var(--space-3);
  outline: none;
}
.signfield__input:focus { border-bottom-color: var(--oxblood); }
.signfield__hint {
  font-size: 12px;
  color: var(--ink-mute);
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}

.option .cta {
  margin-top: auto;
  align-self: flex-start;
  background: var(--ink);
  color: var(--paper);
  border: var(--rule-w) solid var(--ink);
  /* WCAG 2.5.5 target size minimum: 44×44 (use min-height to keep visual size and ensure tap target) */
  min-height: 44px;
  padding: 10px 18px;
  font-family: var(--mono-system);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  /* Restraint: no rounded corners */
  border-radius: 0;
}

/* Ensure all small CTAs meet touch-target minimum on mobile */
.cta--small {
  min-height: 44px;
}
.option .cta:hover, .option .cta:focus-visible {
  /* OXBLOOD USE 3 — Sign button active state, ink → blood on hover */
  background: var(--oxblood);
  border-color: var(--oxblood);
  outline: none;
}

/* ===================== Document Status (live ledger panel) ===================== */
.docstatus {
  max-width: var(--content-max);
  margin: var(--space-7) auto var(--space-6);
  padding: var(--space-5) var(--gutter);
  border-top: var(--rule-w) solid var(--ink);
  border-bottom: var(--rule-w) solid var(--ink);
  background: var(--paper-shade);
}

.docstatus__heading {
  font-family: var(--mono-system);
  font-size: var(--fs-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 var(--space-4);
  font-weight: 500;
}

.docstatus__group-label {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: var(--space-4) 0 var(--space-2);
}
.docstatus__group-label:first-of-type { margin-top: 0; }

.docstatus__list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.docstatus__list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: baseline;
  gap: var(--space-3);
  padding: 4px 0;
  border-bottom: var(--rule-w) solid var(--rule);
}
.docstatus__list li:last-child { border-bottom: 0; }

.docstatus__mark {
  font-family: var(--mono-system);
  font-size: var(--fs-mono);
  text-align: center;
  color: var(--ink-mute);
}
.docstatus__list li[data-status="done"] .docstatus__mark {
  color: var(--oxblood-text);
  font-weight: 600;
}

.docstatus__what {
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  color: var(--ink);
}
.docstatus__list li[data-status="done"] .docstatus__what {
  color: var(--ink);
}
.docstatus__list li[data-status="pending"] .docstatus__what {
  color: var(--ink-soft);
}

.docstatus__when {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  text-align: right;
  white-space: nowrap;
}
.docstatus__when em {
  font-style: italic;
  color: var(--ink-mute);
}

.docstatus__list--pending-auto li {
  border-bottom-style: dashed;
}

@media (max-width: 600px) {
  .docstatus__list li {
    grid-template-columns: 20px 1fr;
    grid-template-rows: auto auto;
  }
  .docstatus__when {
    grid-column: 2;
    text-align: left;
  }
}

/* ===================== Clerk's Note — right-side marginalia on desktop ===================== */
/* Mobile: stays inline at the bottom (no sidebar room).
   Desktop: sticky right-side module so it's always reachable while reading. */
.clerks-note {
  max-width: var(--content-max);
  margin: var(--space-7) auto;
  padding: 0 var(--gutter);
}

.clerks-note__frame {
  border: var(--rule-w) solid var(--rule-strong);
  padding: var(--space-4) var(--space-5);
  background: var(--paper);
}

/* Desktop: pin to right margin, follow scroll. Lower breakpoint so more devices get it. */
@media (min-width: 1024px) {
  body {
    /* Make room for the right rail */
    padding-right: 340px;
  }
  .clerks-note {
    position: fixed;
    top: 64px;
    right: 16px;
    bottom: 72px;
    width: 300px;
    max-width: 300px;
    margin: 0;
    padding: 0;
    z-index: 40;
    overflow: hidden;
  }
  .clerks-note__frame {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  /* Sticky bottom footer leaves room for the right rail */
  .ledger-footer {
    right: 340px;
  }
  /* Stack options to 1 column when the sidebar reduces available width.
     Two stacked cards with full-width Fraunces italic read better than
     two squeezed cards with vertical word-wrapping. */
  .options { grid-template-columns: 1fr; }
}

@media (min-width: 1280px) {
  body {
    padding-right: 380px;
  }
  .clerks-note {
    width: 340px;
    max-width: 340px;
    right: 24px;
    top: 80px;
    bottom: 80px;
  }
  .ledger-footer {
    right: 380px;
  }
}

@media (min-width: 1500px) {
  body {
    padding-right: 380px;
  }
  .clerks-note {
    width: 380px;
    max-width: 380px;
  }
  .ledger-footer {
    right: 380px;
  }
  /* Widen the note at ultra-wide to reduce dead horizontal space.
     720px content max is reading-optimal, but at 1920px viewport with sidebar
     the empty gutters get visually awkward. 880px is still within readable line-length. */
  .note { max-width: 880px; }
  /* Options always 1-column when sidebar active — the selected option's
     action flow needs full column width to render forms cleanly. */
  .options { grid-template-columns: 1fr; }
}

/* When an option is selected, force 1-column even on widths where 2-col would have fit.
   The action flow with declaration text + signature field needs the full available width. */
.options.options--selected { grid-template-columns: 1fr; }
.options.options--selected .option[data-option-state="unselected"] {
  display: none;
}

.clerks-note__label {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 var(--space-3);
  border-bottom: var(--rule-w) solid var(--rule);
  padding-bottom: var(--space-2);
}

.clerks-note__intro {
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  color: var(--ink-soft);
  margin: 0 0 var(--space-4);
  font-style: italic;
}

.clerks-note__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.clerks-note__form textarea {
  width: 100%;
  font-family: var(--serif-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  border: var(--rule-w) solid var(--rule);
  padding: var(--space-3);
  resize: vertical;
  outline: none;
  border-radius: 0;
  transition: border-color var(--t-fast) var(--ease);
}
.clerks-note__form textarea:focus {
  border-color: var(--ink);
}

.clerks-note__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.clerks-note__hint {
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.cta--small {
  padding: 8px 14px;
  font-size: 10.5px;
}

.clerks-note__transcript {
  font-family: var(--serif-body);
  font-size: var(--fs-body-sm);
  color: var(--ink);
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.clerks-note__transcript:empty { display: none; }

.qa {
  border-top: var(--rule-w) solid var(--rule);
  padding-top: var(--space-3);
}

.qa .q {
  font-style: italic;
  color: var(--ink-mute);
  margin: 0 0 var(--space-2);
}
.qa .q::before {
  content: "Q ";
  font-family: var(--mono-system);
  font-style: normal;
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-right: var(--space-2);
}

.qa .a {
  margin: 0;
}
.qa .a::before {
  content: "A ";
  font-family: var(--mono-system);
  font-style: normal;
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-right: var(--space-2);
}

.qa.qa--blocked .a {
  color: var(--oxblood-text);
}

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

/* ===================== Footer ===================== */
/* Sticky footer = the inverted "base" of the document.
   Cohesion principle 1: document static, record alive — countdown lives here. */
.ledger-footer {
  position: fixed;
  inset: auto 0 0 0;
  background: var(--footer-bg);
  color: var(--footer-fg);
  border-top: var(--rule-w) solid var(--footer-rule);
  font-family: var(--mono-system);
  font-size: var(--fs-mono-sm);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  z-index: 50;
}

.ledger-footer__inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-3);
  padding: 12px var(--gutter);
  align-items: center;
}

.ledger-footer .left  { text-align: left; }
.ledger-footer .ctr   { text-align: center; }
.ledger-footer .right { text-align: right; }

.ledger-footer .countdown {
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}
.ledger-footer .countdown--urgent {
  /* OXBLOOD USE 2 — countdown when <24h or expired */
  color: var(--oxblood);
}

.ledger-footer .case-id {
  color: var(--ink-mute);
}
.ledger-footer .case-id b {
  color: var(--paper);
  font-weight: 500;
}

/* ===================== Hide footer on small screens (top status bar carries) ===================== */
@media (max-width: 720px) {
  .ledger-footer { display: none; }
  body { padding-bottom: 0; }
}
@media (min-width: 721px) {
  .status-bar { display: none; }
}

/* ===================== Expired state ===================== */
body[data-state="expired"] {
  pointer-events: none;
  user-select: text; /* still readable as evidence */
}
body[data-state="expired"]::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(21,19,13,0.06) 1px, transparent 1px);
  background-size: 4px 4px;
  pointer-events: none;
  z-index: 1;
}
body[data-state="expired"] .ledger-footer {
  background: var(--oxblood);
}

/* ===================== Sign-stamp animation ===================== */
/* Cohesion principle 1: the only animation is functional state change.
   Printing-press progress + hard stamp scale-down. */
@keyframes stamp {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.signed--stamp { animation: stamp var(--t-stamp) var(--ease) 1; }

/* ===================== Tiled background watermark =====================
   Diagonal repeating recipient identifier across the entire page background.
   Subtle enough to not interfere with reading; visible in screenshots. */
.watermark {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  user-select: none;
  font-family: var(--mono-system);
  font-size: 11px;
  color: var(--ink);
  opacity: 0.045;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  white-space: nowrap;
  /* The text repeats; the JS fills the element with N rows of N copies, rotated -22deg. */
}
.watermark__row {
  display: block;
  transform: rotate(-22deg);
  transform-origin: 0 0;
  margin: 24px 0;
}
@media print {
  .watermark { opacity: 0.08; }
}

/* ===================== Confidentiality clause (in §06) ===================== */
.confidentiality {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 2px solid var(--oxblood);
  background: rgba(90, 26, 18, 0.03);
  font-family: var(--mono-system);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--oxblood-text-aaa, var(--ink));
  letter-spacing: 0.01em;
}

/* ===================== Print-only metadata =====================
   Hidden on screen; injects a header on every printed page so PDF exports
   carry the authenticated-session info. */
.print-only-meta {
  display: none;
}
@media print {
  .print-only-meta {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 18px;
    background: #fff;
    border-bottom: 1px solid var(--rule);
    font-family: var(--mono-system);
    font-size: 9px;
    color: var(--ink);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    z-index: 9999;
  }
  .viewer-orb { display: none; }  /* orb is replaced by the print header */
}

/* ===================== Viewer orb (floating recipient watermark) =====================
   Tiny fixed-position pill in the bottom-right that names the authenticated viewer.
   Doubles as anti-screenshot signal: any capture includes the viewer's name in-frame. */
.viewer-orb {
  position: fixed;
  bottom: calc(var(--space-3) + 56px); /* sit above the sticky footer on desktop */
  right: var(--space-3);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  background: rgba(244, 241, 233, 0.92); /* paper, slightly translucent */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono-system);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(21, 19, 13, 0.06), 0 0 0 1px rgba(90, 26, 18, 0.04);
  pointer-events: none; /* never blocks interaction */
  transition: opacity 0.4s ease;
}
.viewer-orb__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--oxblood);
  box-shadow: 0 0 0 2px rgba(90, 26, 18, 0.18);
  animation: viewer-orb-pulse 2.4s ease-in-out infinite;
}
.viewer-orb__label {
  font-weight: 500;
}
@keyframes viewer-orb-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 2px rgba(90, 26, 18, 0.18); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(90, 26, 18, 0.10); }
}
/* On mobile, sit above the mobile status bar at the bottom */
@media (max-width: 720px) {
  .viewer-orb {
    bottom: calc(var(--space-3) + 8px);
    right: var(--space-3);
  }
}
/* Reduced motion — kill the pulse */
@media (prefers-reduced-motion: reduce) {
  .viewer-orb__dot { animation: none; }
}

/* ===================== Accessibility ===================== */
:focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  position: fixed;
  top: var(--space-3); left: var(--space-3);
  background: var(--ink); color: var(--paper);
  padding: var(--space-2) var(--space-3);
  font-family: var(--mono-system); font-size: 12px;
  z-index: 100;
}
