/* Verifier copilot UI (T39: design A, "Document"). No build step, no web fonts: system stacks only (Inter first when
   it is installed, as in Terza). Tokens are Terza's (grey desk, white sheet, one hairline, near-black primary, colour
   only for state) with Apple's HIG on top: a fixed type scale, a 4 pt grid, 44 pt targets, a visible focus ring, dark
   mode. Three colour meanings only: green = verified, red = failed / void / untested, amber = needs you.
   The expert's own words (criterion, grading text, answers) are set in the serif; the copilot's prose is grey. */
:root {
  color-scheme: light;

  /* ---- families: system only, nothing from the network ---- */
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* Terza body font first */
  --font-display: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* The expert's verbatim words, and only those: Apple's serif (New York) through ui-serif, then book serifs. */
  --font-serif: ui-serif, "New York", "Iowan Old Style", Charter, "Source Serif Pro", Georgia, serif;
  /* Literal values a verifier compares (patterns, numbers, units, term lists). Never enums, never ids. */
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* ---- type scale (Terza): 14 px base; headings 16 / 20 / 24 at 600; labels and buttons 500. Roles in base.css ---- */
  --fs-title-1: 24px;  --lh-title-1: 32px;   /* page / document title (Terza H1 24) */
  --fs-title-2: 20px;  --lh-title-2: 28px;   /* section heading (Terza H2 20) */
  --fs-headline: 16px; --lh-headline: 24px;  /* card title, question (Terza heading-md, -0.5px) */
  --fs-body: 14px;     --lh-body: 22px;      /* copilot prose: the 14 px base with a reading line height */
  --fs-callout: 14px;  --lh-callout: 20px;   /* Terza's default: rows, controls, B's body */
  --fs-subhead: 13px;  --lh-subhead: 18px;   /* meta, provenance, field labels */
  --fs-footnote: 12px; --lh-footnote: 16px;  /* chips, timestamps, ids */
  /* serif sizes for the expert's words */
  --fs-expert-title: 24px; --lh-expert-title: 32px; /* the criterion as the pane's one title (A) */
  --fs-expert: 16px;       --lh-expert: 25px;       /* grading text, expert messages, quotes in prose */
  --fs-expert-row: 15px;   --lh-expert-row: 21px;   /* criterion text in a list row */

  /* ---- spacing: 4 pt grid ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --gutter: 24px;                 /* Terza page padding; 16px on phones */
  --measure: 68ch;

  /* ---- sizes ---- */
  --target: 44px;                 /* minimum hit area (HIG) */
  --control-h: 32px;              /* Terza's pill buttons; hit area extended to 44 */
  --input-h: 40px;                /* Terza inputs */
  --row-h: 40px;                  /* Terza list rows; the hit area is the whole row */
  --toolbar-h: 52px;              /* Terza detail bar is 48; +4 so 44 pt targets fit inside */
  --sidebar-w: 248px;             /* Terza */
  --sheet-w: 400px;               /* conversation side sheet = Terza's assistant panel width */
  --doc-w: 768px;                 /* Terza's form-page column */

  /* ---- radii: grow with the size of the thing (Terza) ---- */
  --r-xs: 4px;    /* inline code */
  --r-sm: 6px;    /* status chips */
  --r-md: 8px;    /* list rows, nav items */
  --r-lg: 12px;   /* inputs, inset boxes, ask items */
  --r-xl: 16px;   /* cards, the content sheet, dialogs, side sheet */
  --r-full: 9999px; /* buttons, tags, badges, search */

  /* ---- motion (Terza) ---- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-1: 150ms;   /* colour, background, border */
  --dur-2: 200ms;   /* disclosure chevrons, fades, result reveal */
  --dur-3: 300ms;   /* sheets, sidebar */

  /* ---- neutrals, light ---- */
  --chrome: #f8f8f8;          /* desk + sidebar (Terza surface-muted) */
  --surface: #ffffff;         /* the sheet, cards */
  --surface-2: #f8f8f8;       /* inset boxes inside a card (rubric, plan summary), hover */
  --surface-3: #f0f0f0;       /* tonal buttons, inputs, inline code, selected row in the sheet */
  --fill-strong: #e1e1e1;     /* the selected sidebar row (Terza active nav) */
  --separator: #e6e6e6;       /* the one hairline */
  --separator-strong: #cccccc;
  --label: #1e1e1e;
  --label-2: #595959;         /* 7.0:1 */
  --label-3: #6e6e6e;         /* 5.0:1: the floor for text that carries meaning */
  --label-4: #afafaf;         /* disabled, zero counts, placeholders */
  --primary: #1e1e1e;         /* near-black, Terza's only accent */
  --primary-hover: #404040;
  --on-primary: #f8f8f8;
  --link: #1e1e1e;            /* links are underlined primary text: no blue accent (Terza) */
  /* Terza's 2 px ring shape, darkened to 3:1 against the surface so keyboard focus stays visible */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px rgba(30, 30, 30, 0.6);
  --input-border: #8c8c8c;    /* 3.4:1 on white: the control's edge reads (WCAG 1.4.11) */

  /* ---- the three meanings (Terza status ramps). Text on tints stays --label; the hue goes to the glyph ---- */
  --green: #15803d;  --green-tint: #edfaf5; --green-bg: #dcf5eb; --green-border: #96e1c2; --green-solid: #15803d; --on-green: #ffffff;
  --red: #b91c1c;    --red-tint: #fdf1ef;   --red-bg: #fce6e3;   --red-border: #f4c2bc;   --red-solid: #dc3232;   --on-red: #ffffff;
  --amber: #b45309;  --amber-tint: #fdf6df; --amber-bg: #fbedbf; --amber-border: #f4d15f; --amber-solid: #f4d15f;

  /* ---- voices ---- */
  --expert-plate: #f8f8f8;    /* a barely tinted neutral; the serif carries the voice */
  --expert-rule: #cccccc;

  /* ---- depth: flat. Only floating things cast a shadow ---- */
  --shadow-pop: 0 6px 16px rgba(0, 0, 0, 0.04), 0 18px 40px rgba(0, 0, 0, 0.08);
  --shadow-raise: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05); /* B only: Apple depth for panes */
  --material: rgba(255, 255, 255, 0.8);          /* translucent sticky bars on the sheet */
  --material-chrome: rgba(248, 248, 248, 0.82);  /* on the desk */
  --backdrop: rgba(10, 10, 10, 0.4);
}
/* Dark: Terza's .dark set. The system decides unless the page forces a theme; keep both blocks equal. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --chrome: #1e1e1e; --surface: #161616; --surface-2: #1e1e1e; --surface-3: #262626; --fill-strong: #2c2c2c;
    --separator: #333333; --separator-strong: #404040;
    --label: #f8f8f8; --label-2: #c4c4c4; --label-3: #a3a3a3; --label-4: #595959;
    --primary: #f8f8f8; --primary-hover: #e8e8e8; --on-primary: #121212;
    --link: #f8f8f8; --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px rgba(248, 248, 248, 0.65); --input-border: #6b6b6b;
    --green: #50cd99; --green-tint: #17301f; --green-bg: #1f4733; --green-border: #3aa670; --green-solid: #246645; --on-green: #ffffff;
    --red: #f18071; --red-tint: #2c1715; --red-bg: #652a25; --red-border: #8c3d36; --red-solid: #c43a30; --on-red: #ffffff;
    --amber: #f4d15f; --amber-tint: #262112; --amber-bg: #4b3e1b; --amber-border: #9b7d31; --amber-solid: #d9b54a;
    --expert-plate: #1e1e1e; --expert-rule: #595959;
    --shadow-pop: 0 6px 16px rgba(0, 0, 0, 0.18), 0 18px 40px rgba(0, 0, 0, 0.28); --shadow-raise: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --material: rgba(22, 22, 22, 0.8); --material-chrome: rgba(30, 30, 30, 0.82); --backdrop: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --chrome: #1e1e1e; --surface: #161616; --surface-2: #1e1e1e; --surface-3: #262626; --fill-strong: #2c2c2c;
  --separator: #333333; --separator-strong: #404040;
  --label: #f8f8f8; --label-2: #c4c4c4; --label-3: #a3a3a3; --label-4: #595959;
  --primary: #f8f8f8; --primary-hover: #e8e8e8; --on-primary: #121212;
  --link: #f8f8f8; --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px rgba(248, 248, 248, 0.65); --input-border: #6b6b6b;
  --green: #50cd99; --green-tint: #17301f; --green-bg: #1f4733; --green-border: #3aa670; --green-solid: #246645; --on-green: #ffffff;
  --red: #f18071; --red-tint: #2c1715; --red-bg: #652a25; --red-border: #8c3d36; --red-solid: #c43a30; --on-red: #ffffff;
  --amber: #f4d15f; --amber-tint: #262112; --amber-bg: #4b3e1b; --amber-border: #9b7d31; --amber-solid: #d9b54a;
  --expert-plate: #1e1e1e; --expert-rule: #595959;
  --shadow-pop: 0 6px 16px rgba(0, 0, 0, 0.18), 0 18px 40px rgba(0, 0, 0, 0.28); --shadow-raise: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --material: rgba(22, 22, 22, 0.8); --material-chrome: rgba(30, 30, 30, 0.82); --backdrop: rgba(0, 0, 0, 0.6);
}
:root[data-theme="light"] { color-scheme: light; }
/* phones and touch: controls grow to the full 44 pt */
@media (max-width: 760px) { :root { --gutter: 16px; --control-h: 44px; --input-h: 44px; --row-h: 48px; } }
@media (pointer: coarse) { :root { --control-h: 44px; --input-h: 44px; } }
/* ================================================================================================================
   Base: four sizes (24 / 16 / 14 / 12), two weights (400 / 600), space before lines, one surface level in the sheet.
   ================================================================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding: 72px 0 112px; } /* focused controls clear the sticky bars */
body {
  margin: 0; min-height: 100vh; background: var(--chrome); color: var(--label);
  font: 400 var(--fs-callout)/var(--lh-callout) var(--font-sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); }
q { quotes: "\201C" "\201D" "\2018" "\2019"; }
code, .mono { font-family: var(--font-mono); font-size: var(--fs-footnote); }
code { padding: 1px 4px; border-radius: var(--r-xs); background: var(--surface-3); overflow-wrap: anywhere; }
[hidden] { display: none !important; }
/* Focus: Terza's ring shape at 3:1 against the surface, keyboard only. */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 12px; border-radius: var(--r-md);
  background: var(--surface); color: var(--label); box-shadow: inset 0 0 0 1px var(--separator);
}
.skip-link:focus { top: 8px; }
.h1 { font: 600 var(--fs-title-1)/var(--lh-title-1) var(--font-display); letter-spacing: -0.02em; }
.h2 { font: 600 var(--fs-headline)/var(--lh-headline) var(--font-display); letter-spacing: -0.01em; }
.serif { font-family: var(--font-serif); }
.copilot { color: var(--label-2); }
.muted { color: var(--label-3); }
.meta { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-3); }
.icon { width: 18px; height: 18px; flex: none; }
.phone-only { display: none !important; }
.noscript { padding: 24px; }
/* ================================================================================================================
   Controls
   ================================================================================================================ */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-h); padding: 0 14px;
  border: 0; border-radius: var(--r-full);
  background: transparent; color: var(--label); box-shadow: inset 0 0 0 1px var(--separator-strong);
  font-weight: 600; font-size: var(--fs-callout); line-height: var(--lh-callout); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
/* the hit area reaches 44 px even where the pill is 32 px tall */
.btn::after { content: ""; position: absolute; inset: 50% 0 auto; height: max(100%, var(--target)); transform: translateY(-50%); }
.btn:focus-visible { border-radius: var(--r-full); box-shadow: var(--focus-ring); }
.btn:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--label-3); }
.btn:disabled { cursor: not-allowed; color: var(--label-3); box-shadow: inset 0 0 0 1px var(--separator); }
.btn-primary, .btn-approve { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.btn-primary:hover:not(:disabled), .btn-approve:hover:not(:disabled) { background: var(--primary-hover); box-shadow: none; }
.btn-primary:disabled { background: var(--primary); color: var(--on-primary); opacity: 0.25; box-shadow: none; }
.btn-approve:disabled { background: transparent; color: var(--label-3); box-shadow: inset 0 0 0 1px var(--separator); }
.btn-ghost { box-shadow: none; color: var(--label-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--label); box-shadow: none; }
.btn-small { padding: 0 12px; }
.btn-icon { width: var(--control-h); padding: 0; box-shadow: none; color: var(--label-2); }
.btn-icon:hover:not(:disabled) { background: var(--surface-3); color: var(--label); box-shadow: none; }
.btn-round { width: 40px; min-height: 40px; padding: 0; }
.btn[aria-expanded="true"] { background: var(--surface-3); box-shadow: none; }
.link {
  display: inline-flex; align-items: center; min-height: var(--target); padding: 0 4px; border: 0; background: none;
  color: var(--label-2); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--separator-strong); text-underline-offset: 3px;
}
.link:hover { color: var(--label); text-decoration-color: currentColor; }
.input,
.field input[type="text"], .field textarea, .field select,
.fallback-form textarea, .quoted-box textarea,
.suggest-edit input[type="text"], .suggest-edit textarea, .suggest-edit select,
.banner input {
  display: block; width: 100%; min-height: var(--input-h); padding: 9px 14px;
  border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--label);
  box-shadow: inset 0 0 0 1px var(--input-border);
  font-size: var(--fs-callout); line-height: var(--lh-callout); resize: vertical;
}
.input::placeholder, textarea::placeholder, input::placeholder { color: var(--label-3); }
.input:hover:not(:disabled), .field input[type="text"]:hover, .field textarea:hover { box-shadow: inset 0 0 0 1px var(--label-2); }
.input:focus-visible, .field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible,
.fallback-form textarea:focus-visible, .quoted-box textarea:focus-visible,
.suggest-edit input:focus-visible, .suggest-edit textarea:focus-visible, .suggest-edit select:focus-visible,
.banner input:focus-visible {
  border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--label), var(--focus-ring);
}
/* the expert's own words are typed in the serif */
textarea.words, .fallback-form textarea, .quoted-box textarea { font-family: var(--font-serif); font-size: var(--fs-expert); line-height: 24px; }
.suggest-edit input[type="text"], .suggest-edit textarea { font-family: var(--font-mono); font-size: var(--fs-footnote); }
.field { display: grid; gap: 6px; }
.field label, .field > .label { font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: 600; color: var(--label-2); }
.field-help { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-3); }
.field-error { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--red); }
.field-error:empty { display: none; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-why { color: var(--label-2); }
/* one status signal: a word on a tint (Terza's status pill). Tones: neutral | needs | green | red; the T16 tone names
   map onto the same three meanings. Text on a tint stays --label. */
.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-footnote); font-weight: 600; line-height: var(--lh-footnote); white-space: nowrap;
  background: var(--surface-3); color: var(--label);
}
.tone-neutral, .tone-info, .tone-muted { background: var(--surface-3); color: var(--label); }
.tone-needs, .tone-attention, .tone-warning { background: var(--amber-bg); color: var(--label); }
.tone-green, .tone-success, .tone-approved { background: var(--green-bg); color: var(--label); }
.tone-red, .tone-danger { background: var(--red-bg); color: var(--label); }
/* a small secondary label (technical facts, the copilot's wording marker) */
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-xs);
  font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 400; white-space: nowrap;
  color: var(--label-2); box-shadow: inset 0 0 0 1px var(--separator);
}
.tag-prohibited { color: var(--red); box-shadow: inset 0 0 0 1px var(--red-border); }
.tag-nondet { color: var(--label); background: var(--amber-tint); box-shadow: inset 0 0 0 1px var(--amber-border); }
/* disclosures: one quiet summary, 44 px tall */
details > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--target);
  cursor: pointer; list-style: none; color: var(--label-2);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: ""; width: 6px; height: 6px; margin-left: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--dur-2) var(--ease);
}
details[open] > summary::after { transform: rotate(45deg); }
details > summary:hover { color: var(--label); }
details[open] > :not(summary) { margin-top: 8px; }
/* ================================================================================================================
   Layout A: grey desk, the criteria in a 248 px sidebar, one white sheet, the conversation as a side panel
   ================================================================================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app[data-chat="open"] { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--sheet-w); }
/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 8px 24px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar > * { flex: none; }
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 10px 12px; font: 600 var(--fs-headline)/var(--lh-headline) var(--font-display); }
.brand-mark { width: 16px; height: 16px; border-radius: var(--r-xs); background: var(--primary); }
.nav {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; padding: 0 10px; border: 0;
  border-radius: var(--r-md); background: transparent; color: var(--label-2); text-align: left; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease);
}
.nav, .crumb, .crit-row, .task-row { text-decoration: none; }
.nav:hover { background: var(--surface-3); color: var(--label); }
.nav[aria-current="page"] { background: var(--fill-strong); color: var(--label); }
.nav[aria-current="page"] .meta { color: var(--label-2); } /* --label-3 on the selected fill is 3.9:1 */
.nav:focus-visible { border-radius: var(--r-md); }
.nav .icon { width: 16px; height: 16px; }
.nav-back[aria-current="page"] .icon { display: none; } /* on the task list itself, it is the current page */
.task-nav { display: grid; gap: 0; padding: 8px 10px; margin-bottom: 8px; color: var(--label); }
.task-nav .task-title { font-weight: 600; overflow-wrap: anywhere; }
/* the criteria: Terza rows, no dividers, a fill on hover and when selected */
.crit-list { display: grid; gap: 2px; }
.crit-list .group { padding: 16px 10px 4px; font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-3); }
.crit-list .group:first-child { padding-top: 4px; }
.crit-row {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 4px; align-items: start;
  width: 100%; min-height: var(--row-h); padding: 10px; border: 0; border-radius: var(--r-md);
  background: transparent; text-align: left; cursor: pointer; transition: background-color var(--dur-1) var(--ease);
}
.crit-row:hover { background: var(--surface-3); }
.crit-row[aria-current="page"] { background: var(--fill-strong); }
.crit-row:focus-visible { border-radius: var(--r-md); }
.crit-text {
  font-family: var(--font-serif); font-size: var(--fs-callout); line-height: var(--lh-callout); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.crit-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--fs-footnote); color: var(--label-3); }
/* ---------- the sheet ---------- */
.sheet {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: calc(100vh - 24px);
  margin: 12px 12px 12px 0; background: var(--surface); border-radius: var(--r-xl);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.sheet:focus, .sheet:focus-visible { box-shadow: inset 0 0 0 1px var(--separator); border-radius: var(--r-xl); } /* a skip and focus target, not a control */
.toolbar { display: flex; align-items: center; gap: 12px; min-height: var(--toolbar-h); padding: 0 12px 0 20px; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; }
.crumb {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--target); max-width: 100%; padding: 0 4px;
  border: 0; background: none; color: var(--label-2); cursor: pointer;
}
.crumb:hover { color: var(--label); }
.crumb:focus-visible { border-radius: var(--r-md); }
.crumb span, .crumb-plain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-plain { color: var(--label-2); }
.tools { display: flex; align-items: center; gap: 8px; }
.viewer { color: var(--label-3); font-size: var(--fs-subhead); white-space: nowrap; }
.viewer:empty, .demo-slot:empty { display: none; }
.content { flex: 1; padding: 24px 24px 48px; }
.doc, .page { max-width: 720px; margin: 0 auto; }
.doc { display: grid; gap: 40px; }
.doc > :empty { display: none; }
.doc-body { display: grid; gap: 40px; }
/* the decision bar: sticky at the foot of the sheet, translucent */
.footbar {
  position: sticky; bottom: 0; z-index: 5; padding: 12px 24px; border-top: 1px solid var(--separator);
  border-radius: 0 0 var(--r-xl) var(--r-xl); background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.footbar:empty { display: none; }
.footbar > * { max-width: 720px; margin: 0 auto; }
/* ================================================================================================================
   Shared by the views: a document section (core.js card()), the empty state, the bulleted notes. The views' own
   styles are in view-*.css; sections are space and a heading, no boxes.
   ================================================================================================================ */
.card { display: grid; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-head h3 { font: 600 var(--fs-headline)/var(--lh-headline) var(--font-display); letter-spacing: -0.01em; }
.card-sub { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-3); }
.empty-state { display: grid; gap: 12px; justify-items: start; padding: 4px 0; }
.empty-state p { max-width: 64ch; }
.notes { display: grid; gap: 4px; }
.notes li { position: relative; padding-left: 14px; }
.notes li::before { content: "•"; position: absolute; left: 2px; }
/* ================================================================================================================
   Floating things: banners, toast, the demo menu (the publish dialog is in view-receipts.css)
   ================================================================================================================ */
.banner-area { display: grid; gap: 8px; padding: 0 24px; }
.banner-area:empty { display: none; }
.banner { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 16px; border-radius: var(--r-lg); }
.banner-mock { background: var(--amber-tint); }
.banner-error { background: var(--red-tint); }
.banner a { color: inherit; font-weight: 600; }
.banner form { display: flex; gap: 8px; align-items: center; }
.banner input { width: auto; min-width: 220px; }
.toast {
  position: fixed; z-index: 90; right: 36px; bottom: 88px; max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--r-lg); background: var(--surface); color: var(--label);
  box-shadow: inset 0 0 0 1px var(--separator), var(--shadow-pop);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red-tint); box-shadow: inset 0 0 0 1px var(--red-border), var(--shadow-pop); }
body.chat-open .toast { right: calc(var(--sheet-w) + 36px); }
.menu { position: relative; }
.menu > summary { min-height: var(--target); white-space: nowrap; }
.menu > summary::after { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; display: grid; gap: 2px; width: 260px; padding: 8px;
  border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--separator), var(--shadow-pop);
}
.menu-pop .meta { padding: 4px 8px 6px; }
.menu-item {
  display: flex; align-items: center; min-height: var(--target); padding: 0 10px; border-radius: var(--r-md);
  color: var(--label); text-decoration: none;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item:focus-visible { border-radius: var(--r-md); }
/* ================================================================================================================
   Widths: 1280 and up as above; 1024–1279 the same; 761–1023 a narrower sidebar and a floating conversation;
   760 and below one column (the criterion is its own page, sticky bars, the conversation a full-screen sheet).
   ================================================================================================================ */
@media (max-width: 1023px) {
  .app, .app[data-chat="open"] { grid-template-columns: 220px minmax(0, 1fr); }
  body.chat-open .toast { right: 36px; }
}
@media (max-width: 760px) {
  html { scroll-padding: 64px 0 180px; }
  .phone-only { display: revert !important; }
  .desk-only { display: none !important; }
  .publish-tool { display: none !important; } /* on a phone, Publish lives on the task page only */
  .app, .app[data-chat="open"] { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .sheet { margin: 0; min-height: 100vh; border-radius: 0; box-shadow: none; }
  .toolbar {
    position: sticky; top: 0; z-index: 10; gap: 4px; padding: 0 4px 0 8px; border-bottom: 1px solid var(--separator);
    background: var(--material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  }
  .viewer { display: none; }
  .content { padding: 20px 16px 32px; }
  .banner-area { padding: 12px 16px 0; }
  .doc, .doc-body { gap: 32px; }
  .footbar { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-radius: 0; }
  .toast, body.chat-open .toast { left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
