  /* Ledger: a private notebook that keeps its own accounts. Self-hosted type
     so a person's browser never talks to a font host. */
  @font-face { font-family: "Fraunces"; src: url(/fonts/fraunces-normal-400-700.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
  @font-face { font-family: "Fraunces"; src: url(/fonts/fraunces-italic-400-700.woff2) format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }
  @font-face { font-family: "Source Sans 3"; src: url(/fonts/source-sans-3-normal-400-700.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
  @font-face { font-family: "Source Sans 3"; src: url(/fonts/source-sans-3-italic-400-700.woff2) format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }
  @font-face { font-family: "IBM Plex Mono"; src: url(/fonts/ibm-plex-mono-normal-400.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
  @font-face { font-family: "IBM Plex Mono"; src: url(/fonts/ibm-plex-mono-normal-500.woff2) format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

  :root {
    --paper: #f5f4ef; --card: #fffefa; --ink: #24292e; --muted: #6b7078; --line: #dedbd2; --rule: #eceae2;
    --accent: #2b4c7e; --accent-soft: #e4eaf3; --done: #6b8f71; --done-soft: #e5eee7;
    --warn: #b7791f; --warn-soft: #f7efdf; --fail: #a54a3a; --fail-soft: #f3e3df;
    --code: #eeece4; --user: #ebe9e1; --shadow: 0 6px 16px rgba(36, 41, 46, 0.08);
    --display: "Fraunces", Georgia, "Times New Roman", serif;
    --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #14171b; --card: #1b1f25; --ink: #e6e3da; --muted: #9a9e9b; --line: #2b3038; --rule: #22272e;
      --accent: #8eaad8; --accent-soft: #1f2a3c; --done: #8fb59a; --done-soft: #1e2a22;
      --warn: #d6a24a; --warn-soft: #332a18; --fail: #d6806b; --fail-soft: #35211d;
      --code: #232830; --user: #242930; --shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    }
  }
  :root[data-theme="dark"] {
    --paper: #14171b; --card: #1b1f25; --ink: #e6e3da; --muted: #9a9e9b; --line: #2b3038; --rule: #22272e;
    --accent: #8eaad8; --accent-soft: #1f2a3c; --done: #8fb59a; --done-soft: #1e2a22;
    --warn: #d6a24a; --warn-soft: #332a18; --fail: #d6806b; --fail-soft: #35211d;
    --code: #232830; --user: #242930; --shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  }

  * { box-sizing: border-box; }
  form { margin: 0; }
  html, body { height: 100%; }
  /* 100dvh: on a phone the browser's own toolbars eat into 100vh, which would
     hide the composer behind them. */
  body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--body); display: flex; flex-direction: column; -webkit-text-size-adjust: 100%; }
  h1, h2, h3 { margin: 0; }
  h1 { font: 600 1.25rem/1 var(--display); letter-spacing: -0.01em; }
  h2 { font: 600 1.15rem/1.25 var(--display); }
  h3 { font: 600 0.72rem/1.4 var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
  a { color: var(--accent); }
  .mono, code, pre { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  code { background: var(--code); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; word-break: break-all; }
  pre { background: var(--code); padding: 0.7rem 0.9rem; border-radius: 6px; overflow-x: auto; font-size: 0.85em; margin: 0.4rem 0; }
  pre code { background: transparent; padding: 0; word-break: normal; }
  button { font: inherit; font-weight: 600; border: none; border-radius: 6px; cursor: pointer; padding: 0.5rem 0.9rem; background: var(--accent); color: #fff; margin-top: 0.8rem; }
  button:disabled { opacity: 0.5; cursor: default; }
  button.quiet { background: transparent; color: var(--muted); font-weight: 500; padding: 0.2rem 0.4rem; }
  button.outline { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
  button.danger { background: transparent; color: var(--fail); font-weight: 500; padding: 0.2rem 0.4rem; }
  button.solid-danger { background: var(--fail); color: #fff; }
  button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.6rem 0 0.2rem; }
  input, select, textarea { width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; }
  input[type="checkbox"], input[type="radio"] { width: auto; }
  textarea { resize: vertical; }
  .row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
  .row.spread { justify-content: space-between; }
  .row > h2 { margin: 0; }
  .spacer { flex: 1; }
  .muted { color: var(--muted); font-size: 0.85rem; }
  .error { color: var(--fail); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }
  .hidden { display: none !important; }
  .notice { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; padding: 0.7rem 0.9rem; margin: 0.8rem 1rem; font-size: 0.9rem; }
  .notice button { margin-top: 0; }
  .banner { border: 1px solid var(--line); background: var(--accent-soft); border-radius: 6px; padding: 0.6rem 0.9rem; margin: 0.8rem 1.2rem 0; font-size: 0.9rem; }
  .banner.warn { background: var(--warn-soft); border-color: transparent; }
  .banner button { margin-top: 0; }
  .pill { display: inline-block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; padding: 0.1rem 0.5rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
  .pill.warn { background: var(--fail-soft); color: var(--fail); }
  table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
  th { text-align: left; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.3rem 0.5rem 0.3rem 0; border-bottom: 1px solid var(--line); font-weight: 600; }
  td { padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
  td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  .wrap { overflow-x: auto; }

  /* AP-1238: every window over the page (ui/app/dialog.js): its title and ✕
     on top, what it holds scrolling between, the way out (Cancel, Save) at
     the foot. `large` takes the screen's height, for an editor or a file.
     A dialog's own rules, further down, change only what is its own: a
     width, a gap. On a phone every one takes the whole screen (below). */
  .dialog { width: min(40rem, calc(100vw - 2rem)); max-width: none; max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
  .dialog[open] { display: flex; flex-direction: column; }
  .dialog.large { width: min(64rem, calc(100vw - 2rem)); height: calc(100dvh - 2rem); }
  .dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
  .dialog button { margin: 0; flex: none; }
  .dialog-head { flex: none; display: flex; align-items: center; gap: 0.5rem; padding: 0.8rem 1.1rem; border-bottom: 1px solid var(--line); }
  .dialog-head h2 { flex: 1; margin: 0; }
  .dialog-head button, .dialog-foot button, .dialog-row button { white-space: nowrap; }
  .dialog-notice { flex: none; margin: 0.7rem 1.1rem 0; }
  .dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0.9rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: 0.8rem; font-size: 0.92rem; }
  .dialog-body > p { margin: 0; }
  .dialog-foot { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; padding: 0.7rem 1.1rem; border-top: 1px solid var(--line); }
  /* A foot with nothing showing in it is not drawn. */
  .dialog-foot:not(:has(> :not(.hidden))) { display: none; }
  /* What sits at the foot's left, apart from the way out: a file's name, another way to pay. */
  .dialog-foot-start { margin-right: auto; }
  .dialog-foot > span { color: var(--muted); font-size: 0.8rem; }
  .dialog-section { display: grid; gap: 0.55rem; padding-top: 0.9rem; border-top: 1px solid var(--rule); }
  .dialog-section:first-child, .dialog-body > .pj-url + .dialog-section { padding-top: 0; border-top: none; }
  .dialog-section h3 { margin: 0; }
  .dialog-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  /* A label beside its field, and what the field means under it. */
  .dialog-form { display: grid; grid-template-columns: minmax(6.5rem, auto) minmax(0, 1fr); gap: 0.75rem 1rem; align-items: start; }
  .dialog-form > label { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--ink); }
  .dialog-field { display: grid; gap: 0.3rem; min-width: 0; }
  .dialog-field > label.pj-inline { margin: 0.45rem 0 0; font-size: 0.9rem; color: var(--ink); }
  .dialog-form input[type="time"], .dialog-form input[type="number"] { flex: none; width: 9rem; }
  .dialog .levels label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
  /* A long text edited whole (the brief, the recipe), in a large dialog. */
  .dialog-editor { flex: 1 1 auto; min-height: 14rem; resize: none; font: 0.84rem/1.6 var(--mono); }

  /* header */
  .top { display: flex; align-items: center; gap: 1.2rem; padding: 0.6rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--card); flex: 0 0 auto; }
  .brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--ink); }
  .brand svg { width: 26px; height: 26px; }
  .top nav { display: flex; gap: 0.15rem; }
  .navlink { background: transparent; color: var(--muted); margin: 0; padding: 0.3rem 0.65rem; font-weight: 500; border-radius: 6px; }
  .navlink.active { background: var(--paper); color: var(--ink); }
  a.navlink { text-decoration: none; font-size: 15px; line-height: 1.55; }
  .who { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
  .top button { margin-top: 0; }   /* the app's button margin set Log out below the links */

  /* cards and pages */
  main.narrow { max-width: 46rem; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 5rem; overflow: auto; }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
  .learning { border-top: 1px solid var(--rule); padding: 0.7rem 0; overflow-wrap: break-word; }   /* "Learned from" is an address */
  .learning:first-child { border-top: 0; }
  #credentials-list .warn { color: var(--fail); font-size: 0.85rem; }
  #credentials-list .row { margin-top: 0.4rem; }
  .learning .lesson { margin-bottom: 0.2rem; }
  .learning .tag { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; margin-right: 0.35rem; color: var(--muted); }
  .learning .tag.on { border-color: var(--accent); color: var(--accent); }
  .learning .tag.off { opacity: 0.7; text-decoration: line-through; }
  .learning textarea { width: 100%; min-height: 3.5rem; margin: 0.3rem 0; }
  .learning .row { gap: 0.4rem; flex-wrap: wrap; }
  .intro { margin: 0 0 0.6rem; }
  .legal { margin: 1rem 0 0; font-size: 0.82rem; }
  #packs button { margin-top: 0.4rem; }
  .credit-plus { color: var(--done); }
  .credit-minus { color: var(--muted); }
  /* Settings sections that hold long lists fold, closed on load, and their
     lists scroll inside a pane of fixed height. The summary line says what
     is inside while closed. */
  details.fold > summary { display: flex; align-items: center; gap: 0.6rem; margin: -1.1rem -1.25rem; padding: 1.1rem 1.25rem; cursor: pointer; list-style: none; }
  details.fold > summary::-webkit-details-marker { display: none; }
  details.fold > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
  details.fold[open] > summary::before { transform: rotate(90deg); }
  details.fold[open] > summary { margin-bottom: 0.2rem; }
  details.fold > summary h2 { margin: 0; }
  .fold-note { margin-left: auto; text-align: right; }
  .scroll-pane { max-height: 24rem; overflow: auto; overscroll-behavior: contain; }
  .scroll-pane thead th { position: sticky; top: 0; z-index: 1; background: var(--card); }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  @media (prefers-reduced-motion: reduce) { details.fold > summary::before { transition: none; } }

  /* Settings → Models (AP-1003, AP-1007, AP-1059): a card per job, the list as chips, and the picker a card opens. */
  #model-choice h3 { margin-top: 1rem; }
  .subfold { margin-top: 0.6rem; }
  .subfold > summary { cursor: pointer; font-size: 0.9rem; }
  #model-providers { margin-top: 0.4rem; }
  .tradeoffs { list-style: none; margin: 0.3rem 0 0; padding: 0; font-size: 0.85rem; }
  .tradeoffs li { padding-left: 1.1rem; text-indent: -1.1rem; }
  .tradeoffs li::before { display: inline-block; width: 1.1rem; text-indent: 0; font-weight: 600; }
  .tradeoffs li.pro::before { content: "+"; color: var(--done); }
  .tradeoffs li.con::before { content: "−"; color: var(--fail); }
  .model-job { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
  .model-job:first-child { border-top: 0; }
  .model-job-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
  .model-job-head b { font-size: 0.95rem; }
  .model-job-head button { margin-top: 0; padding: 0.25rem 0.7rem; font-size: 0.85rem; font-weight: 500; }
  .model-job-pick { margin-top: 0.4rem; font-weight: 600; }
  .model-job .model-facts { margin: 0.15rem 0 0.25rem; }
  .model-job > button.quiet { margin-top: 0.2rem; padding-left: 0; }
  :is(.model-job, .model-list-item, .model-option) .tag { display: inline-block; font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 0 0.4rem; margin-left: 0.4rem; vertical-align: 0.1em; }
  :is(.model-job, .model-list-item, .model-option) .tag.new { border-color: var(--done); color: var(--done); }
  .model-scores { display: flex; flex-wrap: wrap; gap: 0.3rem; font-size: 0.75rem; }
  .model-scores:empty { display: none; }
  .model-scores span { border: 1px solid var(--line); border-radius: 4px; padding: 0 0.35rem; color: var(--muted); }
  .model-scores span.on { border-color: var(--accent); color: var(--accent); }
  .model-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0 0.3rem; }
  /* A chip too wide for a phone wraps between its parts, never inside a tag. */
  .model-list-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.35rem; max-width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.85rem; }
  .model-list-item .tag { margin-left: 0; }
  .model-list-item .tag, .model-list-item .muted { white-space: nowrap; }
  .model-list-item button.quiet { margin: 0 -0.4rem 0 0; padding: 0 0.35rem; font-size: 1rem; line-height: 1.2; }
  #model-list-add { margin-top: 0.3rem; padding: 0.3rem 0.8rem; font-size: 0.85rem; font-weight: 500; }
  /* The list scrolls; what chooses among it stays above. */
  .model-picker { width: min(46rem, calc(100vw - 2rem)); }
  .model-picker .dialog-body { gap: 0.4rem; }
  .model-picker .dialog-body > p { font-size: 0.85rem; }
  .model-picker-tools { display: grid; grid-template-columns: minmax(10rem, 1fr) auto auto auto; gap: 0.4rem; }
  .model-picker-tools select { width: auto; }
  .model-picker-checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.85rem; }
  .model-picker-checks label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; color: var(--ink); }
  .model-picker-rows { margin: 0; padding: 0.4rem 0.2rem; flex: 1 1 auto; min-height: 8rem; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); align-content: start; }
  .model-picker-rows > p.muted { grid-column: 1 / -1; padding: 0.8rem 0.4rem; }
  #model-picker-ours .model-option { border: 1px solid var(--line); border-radius: 8px; }
  .model-option { display: block; width: 100%; margin: 0; padding: 0.55rem 0.5rem; border-radius: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); font-weight: 400; text-align: left; }
  .model-option:hover { background: var(--accent-soft); }
  .model-option[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .model-option > span { display: block; }
  .model-option > .model-scores { display: flex; margin-top: 0.2rem; }
  .model-option > .model-scores:empty { display: none; }
  .model-option-name { font-weight: 600; }
  .model-option > .muted { font-size: 0.8rem; margin-top: 0.1rem; }
  .model-picker-source { font-size: 0.75rem !important; }
  @media (max-width: 640px) {
    .model-picker-tools { grid-template-columns: 1fr 1fr; }
    .model-picker-tools input { grid-column: 1 / -1; }
    .model-picker-tools select { width: 100%; }
  }
  .levels { display: grid; gap: 0.4rem; }
  .levels label { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; margin: 0; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 0.95rem; cursor: pointer; }
  .levels label input { margin-top: 0.3rem; }
  .levels label span { display: block; color: var(--muted); font-size: 0.85rem; }
  .levels label b { font-weight: 600; }

  /* workspace: rail | stage | inspector */
  main.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr) 320px; }
  /* Grid and flex items take their content's min-content width unless told
     otherwise. The rail's session titles are `white-space: nowrap`, so without
     this a long objective widened the whole layout — on a phone the page came
     out 2523px wide and the browser rendered it zoomed out. */
  .rail, .stage, .inspector, .session-list, .pane, .thread { min-width: 0; }
  /* A level folds away what there is to read, never a control (AP-1008).
     Simple keeps the inspector's Results and Project tabs; the plan, the
     activity and the details are Standard's. The inspector stays on screen
     even when empty: its own placeholder says what it is for, and a panel
     that appeared mid-run would shift the layout under the reader. */
  body[data-level="simple"] .needs-standard { display: none !important; }
  body:not([data-level="expert"]) .needs-expert { display: none !important; }
  .rail { border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
  .rail > button { margin: 0.8rem; }
  .rail-actions { display: grid; gap: 0.4rem; margin: 0.8rem; }
  .rail-actions .row { gap: 0.3rem; }
  .rail-actions input { font-size: 0.9rem; }
  #rail-search { margin: 0 0.8rem 0.5rem; width: calc(100% - 1.6rem); font-size: 0.88rem; }
  .rail > .rail-actions > button { margin: 0; }
  .session-list { overflow: auto; flex: 1; padding: 0 0.5rem 1rem; }
  .rail-group { display: block; padding: 0.7rem 0.65rem 0.25rem; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  /* The rail (AP-1008). A session is one line: its state as a dot, its
     title, and when (or its state, when that is not Done). A project is a
     folder: a chevron, a mark, its name and a count, then one line of what
     needs saying. An open project's sessions hang from it on a guide line. */
  .session-list > .muted, .rail-children > .muted { padding: 0.4rem 0.6rem; }
  .session-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 0.5rem; width: 100%; text-align: left; background: transparent; color: var(--ink); font-weight: 400; margin: 0 0 0.1rem; padding: 0.4rem 0.6rem; border-radius: 6px; }
  .session-item:hover, .session-item.active { background: var(--paper); }
  .session-item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
  .session-item .when { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
  .session-item .when.running { color: var(--accent); }
  .session-item .when.awaiting_user_input, .session-item .when.stopped { color: var(--warn); }
  .session-item .when.failed { color: var(--fail); }
  .project-item { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "chev mark title count" ". . meta meta"; gap: 0 0.45rem; padding: 0.45rem 0.6rem 0.45rem 0.45rem; margin-top: 0.15rem; }
  /* The chevron is drawn by ::before, so the span round it is a target of its
     own: a click there folds or unfolds the project (2026-10-13), where the
     rest of the row opens it. */
  .project-item .chev { grid-area: chev; }
  .session-item .chev { display: grid; place-items: center; width: 1.1rem; height: 1.3rem; margin: 0 -0.2rem 0 -0.25rem; border-radius: 4px; }
  .session-item .chev::before { content: ""; width: 0.4rem; height: 0.4rem; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.12s; }
  .session-item.open .chev::before { transform: translateY(-0.1rem) rotate(45deg); }
  .project-item .chev:hover { background: var(--rule); }
  .project-item .pmark { grid-area: mark; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
  .project-item .pmark svg { width: 0.8rem; height: 0.8rem; }
  .project-item .title { grid-area: title; font-weight: 600; }
  .project-item .count { grid-area: count; }
  .project-item .count, .refresh-fold .count, .archived-fold .count { min-width: 1.4rem; padding: 0 0.4rem; border-radius: 99px; background: var(--rule); color: var(--muted); font-size: 0.72rem; line-height: 1.5; text-align: center; }
  /* A project's refreshes, folded under one row below the person's sessions (2026-10-13). */
  .refresh-fold { grid-template-columns: auto minmax(0, 1fr) auto auto; color: var(--muted); }
  /* AP-1132: archived sessions, folded under one row at the bottom of the rail; each with Unarchive. */
  .archived-fold { grid-template-columns: auto minmax(0, 1fr) auto; margin-top: 0.6rem; color: var(--muted); }
  .archived-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.3rem; }
  .archived-item > .quiet { font-size: 0.75rem; padding: 0.2rem 0.45rem; white-space: nowrap; }
  .project-item .meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 0.05rem 0.6rem; margin-top: 0.15rem; font-size: 0.75rem; color: var(--muted); }
  .project-item .state { display: inline-flex; align-items: center; gap: 0.3rem; }
  .project-item .live { color: var(--accent); }
  .project-item .gone { color: var(--fail); }
  .rail-children { margin: 0.1rem 0 0.45rem 0.8rem; padding-left: 0.3rem; border-left: 1px solid var(--line); }
  @media (prefers-reduced-motion: reduce) { .session-item .chev::before { transition: none; } }
  /* AP-222: a scheduled project says so where you scan (the rail) as well as
     where you act (the pane). Colour carries the state: due/refreshing reads
     as active, paused as a problem, the plain cadence as neither. */
  .sched { display: inline-flex; align-items: center; gap: 0.25rem; }
  .sched.soon { color: var(--accent); }
  .sched.now { color: var(--accent); font-weight: 600; }
  .sched.paused { color: var(--warn); }
  .check-found { margin: 0.3rem 0 0; padding-left: 1.2rem; }
  .check-found li { margin: 0.15rem 0; }
  .schedule-status { border-left: 3px solid var(--line); padding: 0.5rem 0 0.5rem 0.7rem; margin: 0.6rem 0; }
  .schedule-status .sched { font-size: 0.95rem; }
  .schedule-status .sched.now, .schedule-status .sched.soon { border-color: var(--accent); }
  .schedule-status .muted { display: block; margin-top: 0.15rem; }
  .session-item.new-in-project { display: block; color: var(--accent); font-weight: 500; font-size: 0.85rem; padding-top: 0.3rem; padding-bottom: 0.3rem; }
  /* The composer bar holds every control at every level (AP-1008), so the
     two chips whose text is a name are capped, and Send and its menu keep
     the right edge together when the bar wraps. */
  .project-chip { display: inline-flex; align-items: center; gap: 0.3rem; max-width: 14rem; background: var(--paper); border: 1px solid var(--line); }
  .project-chip:hover { border-color: var(--accent); color: var(--accent); }
  .project-chip svg { flex: none; width: 0.8rem; height: 0.8rem; color: var(--accent); }
  .project-chip span, #model-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #model-chip { max-width: 12rem; }
  .send-group { display: flex; align-items: center; gap: 0.6rem; margin-left: auto; }
  /* The project pane (inspector → Project): foldable sections, small
     controls, nothing wider than the 320px column. Its buttons drop the
     app's roomy default — a sidebar of full-size buttons, wrapping, was what
     made the pane hard to read. */
  #pane-project { gap: 0; }
  #pane-project button { margin: 0; padding: 0.3rem 0.65rem; font-size: 0.82rem; }
  #pane-project button.quiet, #pane-project button.danger { padding: 0.2rem 0.3rem; }
  #pane-project input, #pane-project select, #pane-project textarea { padding: 0.32rem 0.5rem; }
  .pj-head { display: grid; gap: 0.15rem; padding-bottom: 0.55rem; }
  #pane-project .pj-name { font: 600 1.1rem/1.3 var(--display); border-color: transparent; background: transparent; padding: 0.15rem 0.35rem; margin-left: -0.35rem; width: calc(100% + 0.35rem); }
  #pane-project .pj-name:hover, #pane-project .pj-name:focus { border-color: var(--line); background: var(--paper); }
  .pj-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.75rem; color: var(--muted); font-size: 0.8rem; }
  .pj-working { display: grid; gap: 0.1rem; color: var(--muted); font-size: 0.8rem; }
  .pj-working .dot { margin-right: 0.35rem; }
  .pj-section { border-top: 1px solid var(--rule); padding: 0.45rem 0 0.75rem; }
  .pj-section > summary { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; list-style: none; padding: 0.2rem 0; }
  .pj-section > summary::-webkit-details-marker { display: none; }
  /* A chevron drawn with two borders: › folded, ⌄ open. */
  .pj-section > summary::before { content: ""; flex: none; width: 0.4rem; height: 0.4rem; margin: 0 0.15rem; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.12s; }
  .pj-section[open] > summary::before { transform: translateY(-0.1rem) rotate(45deg); }
  .pj-section > summary h3 { flex: 1; }
  .pj-section > summary .sched { font-size: 0.75rem; }
  .pj-section[open] > summary { margin-bottom: 0.45rem; }
  .pj-section > :not(summary) + :not(summary) { margin-top: 0.55rem; }
  .pj-section .schedule-status { margin: 0; }
  /* AP-1237: the first lines of the brief or the recipe, which are edited in the project dialog. */
  .pj-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.82rem; color: var(--muted); border-left: 2px solid var(--rule); padding-left: 0.6rem; }
  .pj-preview.mono { font-size: 0.76rem; line-height: 1.5; }
  /* AP-1237: each of the recipe's questions, with what it has for an answer. */
  .pj-answers { display: grid; margin: 0; }
  .pj-answers dt { color: var(--muted); font-size: 0.78rem; }
  .pj-answers dd { margin: 0 0 0.35rem; overflow-wrap: anywhere; }
  .pj-note { color: var(--muted); font-size: 0.75rem; }
  .pj-note.warn { color: var(--fail); }
  #site-tags label { font-size: 0.8rem; }
  .pj-pill { font-size: 0.72rem; font-weight: 600; line-height: 1.5; padding: 0 0.5rem; border-radius: 999px; background: var(--rule); color: var(--muted); }
  .pj-pill.live { background: var(--done-soft); color: var(--done); }
  .pj-pill.fail { background: var(--fail-soft); color: var(--fail); }
  .pj-status { display: grid; gap: 0.2rem; }
  .site-list { margin: 0.2rem 0 0; padding-left: 1.2rem; }
  .pj-url { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
  .pj-warn { color: var(--fail); font-size: 0.82rem; }
  .pj-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: 0.35rem; }
  .pj-form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.35rem 0.6rem; align-items: center; }
  .pj-form label { margin: 0; font-size: 0.8rem; }
  .pj-label { margin: 0.3rem 0 0; font-size: 0.8rem; }
  /* Settings → Site address: the name and the domain it sits under, on one
     line. The address and slot rows wrap, as any row does, on a phone. */
  #site-address .row { gap: 0.3rem; }
  #site-address-form .row { flex-wrap: nowrap; }
  #site-address-form .row input { flex: 1 1 auto; min-width: 0; width: auto; }
  #site-address-form .row .muted { white-space: nowrap; }
  .pj-inline { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
  .pj-inline input { flex: 1 1 auto; min-width: 0; }
  .pj-inline input[type="checkbox"] { flex: none; }
  .pj-inline .muted { font-size: 0.78rem; }
  .pj-row-end { display: flex; justify-content: flex-end; gap: 0.4rem; }
  .pj-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.3rem; color: var(--muted); font-size: 0.8rem; }
  .pj-files { display: grid; }
  #pane-project .pj-file { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; width: 100%; padding: 0.22rem 0.3rem; text-align: left; background: transparent; color: var(--ink); font-weight: 400; border-radius: 4px; }
  .pj-file:hover { background: var(--paper); }
  /* AP-808: one of the page's forms: its id, then who may send it and what it starts. */
  .pj-forms { display: grid; gap: 0.2rem; }
  .pj-form-row { display: grid; gap: 0.05rem; padding: 0.15rem 0.3rem; }
  .pj-form-row .name { font-family: var(--mono); font-size: 0.78rem; }
  /* AP-805: the project's own mail address, under Your files. */
  .pj-mail { display: grid; gap: 0.35rem; border-top: 1px solid var(--rule); padding-top: 0.55rem; }
  /* AP-805: one of the person's own files, with Remove beside it. */
  .pj-upload { display: flex; align-items: baseline; gap: 0.3rem; }
  #pane-project .pj-upload .pj-file { flex: 1 1 auto; width: auto; min-width: 0; }
  .pj-upload > .quiet { flex: none; margin-top: 0; font-size: 0.78rem; }
  /* AP-1414: one fact the project remembers, with its Forget button. */
  .pj-fact { display: flex; align-items: baseline; gap: 0.4rem; padding: 0.2rem 0; }
  .pj-fact > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
  .pj-fact > .quiet { flex: none; margin-top: 0; font-size: 0.78rem; }
  /* AP-994: what was read of the file, under its name. */
  .pj-read { padding: 0 0.3rem 0.3rem; font-size: 0.76rem; overflow-wrap: anywhere; }
  .pj-file .name { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
  .pj-file .pj-dl { color: var(--muted); }
  .pj-file:hover .pj-dl, .pj-file:focus-visible .pj-dl { color: var(--accent); }
  .pj-footer { border-top: 1px solid var(--rule); padding-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: space-between; }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
  .dot.running { background: var(--accent); animation: pulse 1.4s infinite; }
  .dot.completed { background: var(--done); }
  .dot.failed { background: var(--fail); }
  .dot.stopped { background: var(--warn); }
  .dot.awaiting_user_input { background: var(--warn); }
  @keyframes pulse { 50% { opacity: 0.3; } }
  @media (prefers-reduced-motion: reduce) { .dot.running, .working i, .now-line::before { animation: none; } }

  .stage { display: flex; flex-direction: column; min-height: 0; position: relative; }
  .thread { flex: 1; overflow: auto; padding: 1.2rem 1.4rem; }
  /* A long list of suggestions scrolls here, so the composer stays on screen.
     Centred by auto margins on the first and last child, which drop to 0 when
     it overflows; grid's place-content: center would cut off the top. */
  .empty { flex: 1 1 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 0.5rem; text-align: center; padding: 2rem; color: var(--muted); }
  .empty > :first-child { margin-top: auto; }
  .empty > :last-child { margin-bottom: auto; }
  .empty h2 { font-size: 1.6rem; color: var(--ink); }
  .empty .examples { display: grid; gap: 0.4rem; max-width: 34rem; margin: 0.8rem auto 0; }
  /* anywhere, not break-word: the centred grid sizes itself to the longest
     word, and an address as a session's title pushed it off both edges. */
  .empty .examples button, .empty .session-link { overflow-wrap: anywhere; }
  .empty .examples button { margin: 0; text-align: left; font-size: 0.9rem; white-space: normal; line-height: 1.35; display: grid; gap: 0.1rem; }
  .empty .examples button .muted, .empty .session-link .muted { font-size: 0.78rem; }
  /* AP-1193: the groups above the examples: waiting on you, pick up where you left off. */
  .empty .empty-group { display: grid; gap: 0.4rem; max-width: 34rem; margin: 0.8rem auto 0; text-align: left; }
  .empty .empty-group h3 { margin: 0; font-size: 0.95rem; color: var(--ink); }
  .empty .session-link { margin: 0; text-align: left; white-space: normal; display: grid; gap: 0.1rem; }
  .empty .session-link .title { font-weight: 600; }
  /* An address longer than the line breaks where it must, not past the edge. */
  .msg { max-width: 46rem; margin: 0 auto 1rem; overflow-wrap: break-word; }
  .msg-user { background: var(--user); border-radius: 10px 10px 2px 10px; padding: 0.6rem 0.9rem; margin-left: auto; margin-right: 0; width: fit-content; max-width: min(46rem, 100%); }
  .msg-user .text { white-space: pre-wrap; }
  .msg-user .actions { display: flex; gap: 0.3rem; justify-content: flex-end; }
  .msg-user .actions button { margin-top: 0.2rem; font-size: 0.78rem; }
  .msg-user textarea { margin-top: 0.4rem; min-width: 22rem; }
  /* AP-1123: a message written while a turn runs, waiting to be read, then read. */
  .msg-user.note.waiting { border: 1px dashed var(--line); background: transparent; }
  .msg-user .note-foot { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; margin-top: 0.25rem; }
  .msg-user .note-state { font-size: 0.78rem; color: var(--muted); }
  .msg-user .note-foot button { margin: 0; font-size: 0.78rem; }
  .msg-user > button { margin-top: 0.4rem; margin-right: 0.4rem; }
  .msg-answer { padding: 0.2rem 0.2rem 0.4rem; }
  /* AP-990: Copy under an answer, faint until the answer is pointed at. */
  .msg-answer > .actions { display: flex; justify-content: flex-end; opacity: 0.55; }
  .msg-answer:hover > .actions, .msg-answer:focus-within > .actions { opacity: 1; }
  .msg-answer > .actions button { margin: 0; font-size: 0.78rem; }
  .md img { display: block; max-width: 100%; max-height: 24rem; border-radius: 4px; margin: 0.4rem 0; }
  /* AP-988: the pages a turn read, under its answer. */
  .msg-sources { margin-top: 0.6rem; padding-top: 0.45rem; border-top: 1px solid var(--rule); font-size: 0.82rem; color: var(--muted); }
  .msg-sources .label { font-weight: 600; }
  .msg-sources ol { margin: 0.2rem 0 0; padding-left: 1.3rem; }
  .msg-sources li { overflow-wrap: anywhere; }
  .md p { margin: 0.35rem 0 0.7rem; }
  .md h1, .md h2, .md h3, .md h4 { font: 600 1.05rem/1.3 var(--display); margin: 0.9rem 0 0.35rem; color: var(--ink); text-transform: none; letter-spacing: 0; }
  .md h1 { font-size: 1.25rem; } .md h4 { font-size: 0.98rem; }
  .md ul, .md ol { margin: 0.3rem 0 0.7rem 1.3rem; padding: 0; }
  .md li { margin: 0.15rem 0; }
  .md blockquote { margin: 0.5rem 0; padding: 0.2rem 0.9rem; border-left: 3px solid var(--line); color: var(--muted); }
  .md hr { border: none; border-top: 1px solid var(--line); margin: 0.9rem 0; }
  .md .table-wrap { overflow-x: auto; margin: 0.4rem 0 0.8rem; }
  .md table { width: auto; min-width: 50%; }
  .md th, .md td { padding: 0.3rem 0.8rem 0.3rem 0; }

  /* the turn: what Brenian did for one message */
  .turn { border: 1px solid var(--line); border-radius: 6px; background: var(--card); padding: 0.75rem 0.95rem; display: grid; gap: 0.6rem; }
  .turn-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
  .turn-head b { font: 600 1rem/1.3 var(--display); }
  .turn-head .state { color: var(--muted); font-size: 0.85rem; }
  .turn-head i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); margin-right: 0.45rem; vertical-align: 1px; }
  .working .turn-head i { animation: pulse 1.4s infinite; }
  /* AP-1063: what it is doing now stays in sight while the timeline scrolls under it */
  .turn.working .turn-head { position: sticky; top: -1.2rem; z-index: 1; background: var(--card); padding: 0.3rem 0; margin: -0.3rem 0; }
  .turn.done .turn-head i { background: var(--done); box-shadow: none; }
  .turn.stopped .turn-head i { background: var(--warn); box-shadow: none; }
  .turn.failed .turn-head i { background: var(--fail); box-shadow: none; }
  .plan { display: grid; gap: 0.35rem; }
  .plan .plan-line { display: flex; gap: 0.6rem; align-items: baseline; font-size: 0.88rem; }
  .plan .plan-line b { font-weight: 600; }
  .plan .plan-line span { color: var(--muted); }
  .plan .plan-line button { margin: 0 0 0 auto; font-size: 0.78rem; }
  .meter { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
  .meter > i { display: block; height: 100%; width: 0; background: var(--done); transition: width 0.3s ease; }
  .steps { list-style: none; margin: 0.15rem 0 0; padding: 0; display: grid; gap: 0.2rem; }
  .steps li { display: grid; grid-template-columns: 1.1em 1fr auto; gap: 0.5rem; align-items: baseline; font-size: 0.88rem; }
  .steps li i { font-style: normal; font-family: var(--mono); color: var(--muted); }
  .steps li.done i { color: var(--done); }
  .steps li.now { font-weight: 600; } .steps li.now i { color: var(--accent); }
  .steps li.failed i { color: var(--fail); }
  .steps li small { color: var(--muted); font-size: 0.78rem; }
  .steps li.failed small { color: var(--fail); }
  .steps .detail { display: block; padding-left: 1.6em; font-size: 0.78rem; color: var(--muted); }
  .steps .detail summary { cursor: pointer; color: var(--fail); }
  .steps .detail pre { margin: 0.2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.74rem; }
  .steps .phase { display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 0.3rem; }
  .activity { display: grid; gap: 0.3rem; }
  .activity .sum { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; font-size: 0.88rem; }
  .activity .sum button { margin: 0; font-size: 0.78rem; }
  .timeline { display: grid; gap: 0.15rem; font-size: 0.82rem; color: var(--muted); }
  .timeline .row-t { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: baseline; }
  .timeline .row-t .at { font-family: var(--mono); font-size: 0.74rem; }
  .timeline .row-t .what { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .timeline .row-t .what.thought { color: var(--muted); font-style: italic; white-space: normal; }
  .timeline .row-t .dur { font-family: var(--mono); font-size: 0.74rem; white-space: nowrap; }
  .timeline .row-t.error .what { color: var(--fail); white-space: normal; }
  .timeline details { margin: 0 0 0.3rem 3.8rem; }
  .timeline summary { cursor: pointer; font-size: 0.75rem; }
  .timeline pre { max-height: 14rem; overflow: auto; font-size: 0.75rem; white-space: pre-wrap; word-break: break-word; }
  .timeline .meta-row { display: flex; gap: 0.7rem; flex-wrap: wrap; font-family: var(--mono); font-size: 0.72rem; margin-left: 3.8rem; }
  .subagent { margin-left: 3.8rem; border-left: 2px solid var(--accent); padding: 0.1rem 0.6rem; color: var(--ink); }
  .subagent .summary { white-space: pre-wrap; }
  .results { display: grid; gap: 0.4rem; }
  .results .head { display: flex; gap: 0.6rem; align-items: baseline; }
  .results .head b { font: 600 0.95rem/1.3 var(--display); }
  .results .head span { color: var(--muted); font-size: 0.82rem; }
  .file { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; padding: 0.35rem 0; border-top: 1px solid var(--rule); font-size: 0.9rem; }
  .file .name { font-family: var(--mono); font-size: 0.82rem; overflow-wrap: anywhere; }
  .file small { display: block; color: var(--muted); font-size: 0.78rem; font-family: var(--body); }
  .file button { margin: 0; padding: 0.15rem 0.5rem; font-size: 0.78rem; }
  .file img { max-width: 100%; max-height: 16rem; border-radius: 4px; display: block; margin-top: 0.3rem; grid-column: 1 / -1; }
  .file .actions { display: flex; gap: 0.35rem; }
  /* The preview covers the screen and scales the picture to fit it, keeping
     its shape. A click anywhere closes it, except on Back and Next, which sit
     top left, opposite Close, in the band the top padding keeps clear. */
  .image-preview { box-sizing: border-box; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 3rem 1rem 1rem; border: none; background: transparent; cursor: zoom-out; }
  .image-preview::backdrop { background: rgba(0, 0, 0, 0.85); }
  .image-preview-picture { height: 100%; }
  #image-preview-img { display: block; width: 100%; height: 100%; object-fit: contain; }
  #image-preview-close { position: absolute; top: 0.6rem; right: 0.8rem; margin: 0; }
  .image-preview-nav { position: absolute; top: 0.6rem; left: 0.8rem; display: flex; align-items: center; gap: 0.5rem; color: #fff; cursor: default; }
  .image-preview-nav button { margin: 0; }
  /* A flagged picture fits the screen too, its Show bar beneath it. */
  .image-preview .pic-flag { height: 100%; display: flex; flex-direction: column; }
  .image-preview .pic-flag img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
  .image-preview .pic-flag-bar, .image-preview-picture > .muted { color: #ddd; }
  .image-preview .pic-held, .image-preview-picture > .muted { max-width: 22rem; margin: 2rem auto 0; }
  /* AP-1041: the file viewer. The file's name and what can be done with it
     stay on top; the file scrolls below, both ways when its lines are long. */
  .file-view { overflow: hidden; }
  .file-view .dialog-head { gap: 0.4rem; padding: 0.55rem 0.9rem; }
  .file-view .dialog-head button { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
  .fv-title { flex: 1; min-width: 0; display: grid; }
  .fv-title b { font: 500 0.88rem/1.4 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fv-title small { color: var(--muted); font-size: 0.78rem; }
  .fv-notice { flex: none; padding: 0.4rem 0.9rem; background: var(--warn-soft); font-size: 0.85rem; }
  .fv-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
  .fv-body > .muted { padding: 1rem; }
  .fv-doc { max-width: 46rem; margin: 0 auto; padding: 1rem 1.4rem 2.5rem; overflow-wrap: break-word; }
  .fv-text, .fv-code pre { margin: 0; padding: 0.8rem 1rem; border-radius: 0; background: transparent; font-size: 0.8rem; line-height: 1.6; overflow: visible; }
  .fv-text { white-space: pre-wrap; overflow-wrap: anywhere; }
  /* As wide as its longest line, so the viewer scrolls sideways as one and the
     line numbers stay at its left edge. */
  .fv-code { display: grid; grid-template-columns: auto 1fr; width: max-content; min-width: 100%; min-height: 100%; }
  .fv-code .fv-gutter { position: sticky; left: 0; padding-right: 0.7rem; text-align: right; color: var(--muted); background: var(--card); border-right: 1px solid var(--rule); user-select: none; -webkit-user-select: none; }
  .fv-table { padding: 0.4rem 1rem 2rem; width: max-content; min-width: 100%; }
  .fv-table .muted { padding: 0.4rem 0; }
  .fv-table table { width: auto; font-size: 0.82rem; }
  /* A column's name is the file's own data: shown as written, not as a label. */
  .fv-table th { position: sticky; top: 0; background: var(--card); padding-right: 1.2rem; white-space: nowrap; font-size: inherit; text-transform: none; letter-spacing: 0; color: var(--ink); }
  .fv-table td { padding-right: 1.2rem; max-width: 28rem; overflow-wrap: anywhere; }
  .fv-image { display: grid; place-items: center; min-height: 100%; padding: 1rem; }
  .fv-image img { display: block; max-width: 100%; max-height: calc(100dvh - 9rem); }
  /* AP-1066: a flagged picture is blurred until shown; one held back is a
     placeholder, since its bytes never reached the page. */
  img.blurred { filter: blur(24px) saturate(0.6); }
  .pic-flag { grid-column: 1 / -1; overflow: hidden; }
  .pic-flag img { transition: filter 0.15s; }
  .file .pic-flag img { margin-top: 0.3rem; }
  .pic-flag-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.35rem; font-size: 0.78rem; color: var(--muted); }
  .pic-flag-bar button { margin: 0; padding: 0.15rem 0.7rem; font-size: 0.8rem; }
  .pic-held { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.3rem; padding: 0.7rem 0.8rem; border: 1px dashed var(--line); border-radius: 6px; background: var(--paper); color: var(--muted); font-size: 0.8rem; text-align: left; }
  .pic-held b { color: var(--ink); font-weight: 600; }
  .pic-tap { color: var(--muted); font-size: 0.75rem; }
  .fv-pdf { display: block; width: 100%; height: 100%; border: 0; }
  /* 2026-10-14: a video or a sound in the browser's own player, and a 3D
     model turned around in a canvas that takes what the dialog leaves. */
  .fv-media { display: grid; place-items: center; min-height: 100%; padding: 1rem; }
  .fv-video { display: block; max-width: 100%; max-height: calc(100dvh - 9rem); background: #000; border-radius: 4px; }
  .fv-audio { width: min(36rem, 100%); }
  .glb-view { display: flex; flex-direction: column; height: 100%; min-height: 20rem; }
  .glb-view canvas { flex: 1; min-height: 0; width: 100%; display: block; touch-action: none; cursor: grab; }
  .glb-view canvas:active { cursor: grabbing; }
  .glb-view small { padding: 0.35rem 0.9rem; color: var(--muted); font-size: 0.75rem; }
  /* AP-1025: buying credits in the app. Stripe's embedded Checkout sits in .buy-slot. */
  .buy { width: min(32rem, calc(100vw - 2rem)); }
  .buy .buy-slot:empty, #buy-error:empty { display: none; }
  .working-files { color: var(--muted); font-size: 0.82rem; padding-top: 0.3rem; border-top: 1px solid var(--rule); }
  .working-files button { margin: 0; font-size: 0.78rem; }
  .working-files ul { list-style: none; margin: 0.3rem 0 0; padding: 0; font-family: var(--mono); font-size: 0.76rem; display: grid; gap: 0.1rem; overflow-wrap: anywhere; }
  .working-files li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
  .working-files li .actions { display: flex; gap: 0.3rem; flex: none; }
  .working-files li button { padding: 0.05rem 0.4rem; font-size: 0.74rem; }
  /* A project's site, where the person is looking (AP-1008): atop Results,
     and at the end of a stopped project session's thread. The edge says
     where it stands: live, not yet published, taken down. */
  #results-site:empty { display: none; }
  .site-card { display: grid; gap: 0.25rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; background: var(--card); padding: 0.65rem 0.8rem; font-size: 0.88rem; }
  .site-card.live { border-left-color: var(--done); }
  .site-card.fail { border-left-color: var(--fail); }
  .site-card-head { display: flex; align-items: center; gap: 0.5rem; }
  .site-card-head b { font: 600 0.95rem/1.3 var(--display); }
  .site-card .sched { font-size: 0.85rem; }
  .site-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.3rem; }
  .site-card-actions button { margin: 0; padding: 0.3rem 0.7rem; font-size: 0.82rem; }
  .site-card-actions button.quiet { margin-left: auto; padding: 0.2rem 0.3rem; }
  /* AP-1046: the Run again card sits under the site card; a result's earlier copies follow it on its row. */
  #results-site .site-card + .site-card { margin-top: 0.5rem; }
  .run-again .pj-files { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem; }
  .run-again .pj-file { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.2rem 0.3rem; background: transparent; color: var(--ink); font-weight: 400; text-align: left; }
  .run-again .pj-files .quiet { padding: 0.1rem 0.3rem; font-size: 0.78rem; }
  /* The tray is narrow: each question over its answer, the answer full width. */
  .run-again .dialog-form { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .run-again .dialog-form > label { margin: 0.3rem 0 0; font-size: 0.85rem; }
  .run-again .dialog-form input, .run-again .dialog-form select { width: 100%; box-sizing: border-box; }
  .run-again details .mono { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
  .rate { display: flex; align-items: center; gap: 0.5rem; }
  /* Edit and Retry are there at every level (AP-1008). Where there is a
     pointer they show on the message it is over, so a long conversation is
     not ruled with them; on a touch screen they stay. */
  @media (hover: hover) {
    .msg-user .actions { opacity: 0; transition: opacity 0.12s; }
    .msg-user:hover .actions, .msg-user:focus-within .actions { opacity: 1; }
  }
  .made, .looked { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 0.5rem; }
  .made button, .looked button { margin: 0; padding: 0; font-size: 0.85rem; color: var(--accent); font-weight: 600; }
  /* The View tab (AP-1105): one picture the agent looked at, large, with its
     question, and the session's strip of them below. */
  .view-now { margin: 0; display: grid; gap: 0.4rem; }
  .view-picture img { display: block; width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); cursor: zoom-in; }
  .view-now figcaption { font-size: 0.85rem; }
  .view-now figcaption small { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.75rem; font-family: var(--mono); overflow-wrap: anywhere; }
  .view-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.8rem; }
  .view-bar button { margin: 0; padding: 0.15rem 0.6rem; font-size: 0.8rem; }
  .view-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr)); gap: 0.35rem; }
  .view-thumb { margin: 0; padding: 0; aspect-ratio: 4 / 3; overflow: hidden; display: grid; place-items: center; background: var(--paper); border: 2px solid var(--line); border-radius: 4px; font-size: 0.7rem; }
  .view-thumb.on { border-color: var(--accent); }
  .view-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
  .stop-banner { border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 6px 6px 0; padding: 0.6rem 0.9rem; display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
  .stop-banner.failed { border-left-color: var(--fail); background: var(--fail-soft); }
  /* AP-1130: what is left to do is a next step, not a warning. */
  .stop-banner.next-banner { border-left-color: var(--accent); background: var(--accent-soft); }
  .stop-banner b { font-weight: 600; }
  .stop-banner button { margin: 0 0 0 auto; }
  .draft { color: var(--muted); font-style: italic; white-space: pre-wrap; }
  .step-error { color: var(--fail); }
  .question { max-width: 46rem; margin: 0 auto 0.8rem; border: 1px solid var(--accent); border-radius: 6px; padding: 0.8rem 1rem; background: var(--card); }
  /* AP-1332: a call's draft above the message box, and Talk's "this call is about". */
  .call-drafts { max-width: 46rem; margin: 0 auto 0.8rem; display: flex; flex-direction: column; gap: 0.6rem; }
  .call-draft { border: 1px solid var(--accent); border-radius: 6px; padding: 0.8rem 1rem; background: var(--card); }
  .call-draft p { margin: 0.3rem 0 0.6rem; white-space: pre-wrap; }
  .talk-about { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; padding: 0.6rem 0.9rem; margin: 0.4rem 0 0.8rem; }
  .question .row button { margin-top: 0.4rem; }
  .question .row button.pictured { display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; padding: 0.4rem; width: 15rem; max-width: 100%; }
  .question .row button.pictured img { display: block; width: 100%; max-height: 13rem; object-fit: contain; border-radius: 4px; background: var(--rule); min-height: 4rem; }
  .jump { position: absolute; right: 1.4rem; background: var(--card); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 0.3rem 0.7rem; font-size: 0.8rem; margin: 0; z-index: 2; }

  /* composer */
  .composer { flex: 0 0 auto; padding: 0.7rem 1.4rem 1rem; border-top: 1px solid var(--line); background: var(--card); }
  .composer .inner { max-width: 46rem; margin: 0 auto; display: grid; gap: 0.45rem; }
  .composer textarea { min-height: 3.2rem; }
  /* AP-989: the files that go with the next message. */
  .attachments { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .attachment { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 0.1rem 0.15rem 0.1rem 0.5rem; font-size: 0.8rem; }
  .attachment .name { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
  .attachment .state { color: var(--muted); }
  .attachment.failed { border-color: var(--fail); }
  .attachment.failed .state { color: var(--fail); }
  .attachment button { margin-top: 0; padding: 0 0.4rem; font-size: 1rem; line-height: 1.4; }
  .composer-bar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; position: relative; }
  .composer-bar button { margin-top: 0; }
  .chip { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 99px; padding: 0.15rem 0.7rem; font-size: 0.8rem; font-weight: 500; }
  .chip.on { border-color: var(--accent); color: var(--accent); }
  .popover { position: absolute; bottom: 2.4rem; left: 0; width: 22rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.9rem 0.9rem; box-shadow: var(--shadow); z-index: 3; }
  .popover.menu { left: auto; right: 0; width: 15rem; padding: 0.4rem; display: grid; }
  /* The composer bar wraps on a narrow pane; a popover anchored to its bottom
     edge then covered the chips of the first row. Anchor to its top edge. */
  .composer-bar > .popover { bottom: calc(100% + 0.4rem); }
  .limit-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
  .limit-row input { width: 5.5rem; margin: 0; }
  .limit-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--ink); margin: 0.7rem 0 0.2rem; }
  .limit-check input { margin: 0; }
  .turn .estimate-offer { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; font-size: 0.9rem; border-left: 3px solid var(--accent); padding: 0.4rem 0.7rem; margin: 0.3rem 0 0.5rem; }
  .turn .estimate-offer button { margin: 0 0 0 auto; }
  .turn .estimate-line { font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0.4rem; }
  .turn .go-meter { font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0.4rem; }
  .stop-banner .progress { display: block; color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0; }
  .popover.menu button { margin: 0; text-align: left; background: transparent; color: var(--ink); font-weight: 500; padding: 0.4rem 0.6rem; border-radius: 4px; }
  .popover.menu button:hover { background: var(--paper); }
  .popover.menu button.danger { color: var(--fail); }
  .cost { display: flex; gap: 0.5rem; align-items: center; font-size: 0.8rem; color: var(--muted); }
  .cost a { color: var(--ink); font-weight: 600; font-family: var(--mono); font-size: 0.78rem; text-decoration: none; border-bottom: 1px dotted var(--muted); }
  .cost a:hover { color: var(--accent); border-bottom-color: currentColor; }
  .usage-session { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
  .usage-session:last-child { border-bottom: 0; }
  .usage-session.current { background: var(--accent-soft); margin: 0 -0.6rem; padding: 0.7rem 0.6rem; border-radius: 6px; }
  .usage-session .head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
  .usage-session .head a { font-weight: 600; color: var(--ink); text-decoration: none; }
  .usage-session .head a:hover { text-decoration: underline; }
  .usage-session .head .spend { margin-left: auto; font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }
  .usage-session table { margin-top: 0.4rem; }
  /* A project's total, and its sessions hanging from it on a guide line, as in the rail. */
  .usage-project { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
  .usage-project:last-child { border-bottom: 0; }
  .usage-project > .head { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
  .usage-project > .head a, .usage-project > .head .gone { font-weight: 700; color: var(--ink); text-decoration: none; }
  .usage-project > .head a:hover { text-decoration: underline; }
  .usage-project > .head .pmark { display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
  .usage-project > .head .pmark svg { width: 0.8rem; height: 0.8rem; }
  .usage-project > .head .spend { margin-left: auto; font-family: var(--mono); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
  .usage-project > .sessions { margin: 0.3rem 0 0 0.6rem; padding-left: 0.9rem; border-left: 1px solid var(--line); }
  .cost .bar { flex: 0 0 4rem; height: 5px; border-radius: 3px; background: var(--rule); overflow: hidden; }
  .cost .bar i { display: block; height: 100%; width: 0; background: var(--done); }
  /* AP-1038: low and gone, on the session's bar, the chip, and the strip over the composer. */
  .cost .bar i.warn { background: var(--warn); }
  .cost .bar i.over { background: var(--fail); }
  .refill-chip { margin: 0; }
  .popover.refill { left: auto; right: 0; width: min(19rem, calc(100vw - 2rem)); }
  .refill .refill-head { margin-top: 0.4rem; font-size: 1rem; }
  .refill .refill-packs { display: grid; gap: 0.4rem; margin: 0.6rem 0 0.4rem; }
  .refill .refill-packs button { margin: 0; display: flex; justify-content: space-between; gap: 1rem; }
  .refill a { font-size: 0.85rem; }
  .low-credits { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 0.35rem 0.6rem; border-radius: 4px; margin: 0.3rem 0; }
  .low-credits.over { border-left-color: var(--fail); background: var(--fail-soft); }
  .low-credits button { margin: 0 0 0 auto; padding: 0.2rem 0.7rem; }
  .chip.warn { border-color: var(--warn); color: var(--warn); }
  .chip.over { border-color: var(--fail); color: var(--fail); }
  .model-facts { font-size: 0.78rem; margin: 0.25rem 0 0.6rem; line-height: 1.4; }
  /* AP-1065: the Model menu. Each model is its own panel. Thinking is a row of
     levels inside the chat model's panel, set off by the accent rule, because
     it is that model's setting and not a model of its own. */
  .popover.model-menu { width: min(26rem, calc(100vw - 2rem)); display: grid; gap: 0.6rem; padding: 0.7rem; }
  .model-menu .pick { border: 1px solid var(--line); border-radius: 6px; padding: 0.55rem 0.65rem 0.6rem; }
  .model-menu .pick-title { display: block; margin: 0 0 0.3rem; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .model-menu .pick label:not(.pick-title) { margin-top: 0.4rem; }
  .model-menu .pick select { font-weight: 600; }
  .popover.model-menu { max-height: min(80dvh, 44rem); overflow-y: auto; overscroll-behavior: contain; }
  .model-menu .model-cards { grid-template-columns: 1fr; gap: 0.35rem; }
  .model-menu .mg-plain { text-align: left; font-weight: 500; cursor: pointer; margin: 0; background: var(--card); color: var(--ink); }
  .model-menu .mg-plain:hover, .model-menu .mg-card.compact:hover { border-color: var(--accent); }
  .model-menu .model-facts { margin: 0.3rem 0 0; }
  .model-menu .thinking { margin-top: 0.55rem; padding: 0.45rem 0.55rem 0.55rem; border-left: 3px solid var(--accent); border-radius: 0 4px 4px 0; background: var(--accent-soft); }
  .model-menu .thinking-title { font-size: 0.78rem; font-weight: 600; margin-bottom: 0.35rem; }
  .model-menu #model-note { margin: 0; }
  .segmented { display: flex; flex-wrap: wrap; gap: 0.3rem; }
  .composer-bar .segmented button { margin: 0; padding: 0.15rem 0.55rem; border: 1px solid var(--line); border-radius: 99px; background: var(--card); color: var(--ink); font-size: 0.78rem; font-weight: 500; }
  .composer-bar .segmented button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--card); font-weight: 600; }
  .space { min-width: 18rem; font-size: 0.85rem; }
  .space .space-bar { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; margin: 0.4rem 0; }
  .space .space-bar i { display: block; height: 100%; background: var(--done); }
  .space .space-bar i.warn { background: var(--warn); }
  .space .space-bar i.over { background: var(--fail); }
  .space .space-row { display: flex; gap: 0.5rem; align-items: center; padding: 0.2rem 0; }
  .space .space-row .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .space .muted { margin-top: 0.4rem; }
  .space .muted.warn { color: var(--warn); }
  .composer .send { padding: 0.45rem 1.1rem; }

  /* inspector */
  /* tabs, the "now" line (empty, so no height, when nothing is running), the open pane */
  /* One column, never wider than the panel: a grid column sizes itself to
     its content's min-content width, and the tab row (six tabs on a project
     session, since the View tab) is wider than 320px at the old padding,
     which pushed every pane 44px past the right edge of the screen. */
  .inspector { border-left: 1px solid var(--line); background: var(--card); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; min-height: 0; }
  .now-line:not(:empty) { padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
  .now-line:not(:empty)::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 0.5rem; vertical-align: 1px; animation: pulse 1.4s infinite; }
  /* Six tabs fit 320px at this size; should they not (a narrower drawer),
     the row scrolls sideways and the close button stays pinned at its end. */
  .tabs { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { margin: 0; flex: 0 0 auto; background: transparent; color: var(--muted); font-weight: 500; border-radius: 0; padding: 0.6rem 0.5rem; font-size: 0.8rem; border-bottom: 2px solid transparent; }
  .tabs .mobile-only { position: sticky; right: 0; background: var(--card); }
  .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
  .pane { padding: 0.8rem 0.9rem; overflow: auto; display: grid; gap: 0.7rem; align-content: start; font-size: 0.88rem; }
  .pane .steps li { font-size: 0.85rem; }
  .facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; font-size: 0.85rem; margin: 0; }
  .facts dt { color: var(--muted); }
  .facts dd { margin: 0; font-family: var(--mono); font-size: 0.8rem; }
  .stars { display: inline-flex; align-items: center; gap: 0.25rem; }
  .stars button { background: transparent; color: var(--line); font-size: 1.15rem; padding: 0 0.05rem; margin: 0; line-height: 1; }
  .stars button.on { color: var(--warn); }
  .timeline-all { display: grid; gap: 0.5rem; }
  .timeline-all .t { display: grid; gap: 0.15rem; cursor: pointer; }
  .timeline-all .t b { font-weight: 600; font-size: 0.85rem; }
  .timeline-all .t span { color: var(--muted); font-size: 0.82rem; }

  /* ── narrow screens ───────────────────────────────────────────────────
     The desktop layout is rail | stage | inspector. Three panes do not fit a
     phone, and stacking them makes the thread — the thing you came for —
     unreadable. So the stage keeps the screen and the other two become
     drawers over it, each with a scrim and a close button. */
  .scrim { position: fixed; inset: 0; background: rgba(20, 23, 27, 0.45); z-index: 15; border: none; padding: 0; margin: 0; }
  .mobile-only, .phone-only { display: none; }   /* mobile-only: ≤1024 (inspector is a drawer). phone-only: ≤760 (rail too). */
  #rail-close, #inspector-close { margin: 0; }

  @media (max-width: 1024px) {
    /* Tablet: two panes. The inspector slides in from the right. */
    main.workspace { grid-template-columns: 236px minmax(0, 1fr); }
    .inspector { position: fixed; top: 0; right: 0; bottom: 0; width: min(92vw, 380px); z-index: 20;
      transform: translateX(101%); transition: transform 0.18s ease-out; box-shadow: var(--shadow); border-left: 1px solid var(--line); }
    body.inspector-open .inspector { transform: none; }
    body:not(.inspector-open) .inspector { pointer-events: none; }
    .mobile-only { display: inline-flex; }
  }

  @media (max-width: 760px) {
    /* A scrolled table keeps its natural column widths instead of squeezing
       them into slivers; a narrow one still fills the width. */
    .wrap table { min-width: max-content; }

    /* Phone: one pane. Both side panels are drawers; nothing is fixed-width. */
    main.workspace { grid-template-columns: minmax(0, 1fr); }
    .rail { position: fixed; top: 0; left: 0; bottom: 0; width: min(84vw, 320px); z-index: 20;
      transform: translateX(-101%); transition: transform 0.18s ease-out; box-shadow: var(--shadow); border-right: 1px solid var(--line); }
    body.rail-open .rail { transform: none; }
    body:not(.rail-open) .rail { pointer-events: none; }
    .inspector { width: min(94vw, 420px); }
    .phone-only { display: inline-flex; }

    /* Header: the address is the first thing to go; the toggles matter more. */
    .top { gap: 0.5rem; padding: 0.5rem 0.7rem; padding-left: calc(0.7rem + env(safe-area-inset-left)); padding-right: calc(0.7rem + env(safe-area-inset-right)); }
    .top h1 { font-size: 1.1rem; }
    .brand svg { width: 22px; height: 22px; }
    /* Six links and Log out do not fit the narrowest phones (an admin has
       one more): the links scroll sideways, as the inspector's tabs do, and
       Log out keeps one line. */
    .top nav { gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
    .top nav::-webkit-scrollbar { display: none; }
    .navlink, a.navlink { padding: 0.3rem 0.45rem; font-size: 0.9rem; white-space: nowrap; }
    #who { display: none; }
    .who { gap: 0.3rem; flex: none; }
    #logout { white-space: nowrap; }

    /* Reading and typing */
    .thread { padding: 0.9rem 0.8rem calc(0.9rem + env(safe-area-inset-bottom)); }
    .turn.working .turn-head { top: -0.9rem; }   /* flush with the thread's top, as -1.2rem is above */
    .msg { margin-bottom: 0.8rem; }
    .msg-user textarea { min-width: 0; }
    .empty { padding: 1.5rem 1rem; }
    .empty h2 { font-size: 1.3rem; }
    .banner, .notice { margin-left: 0.7rem; margin-right: 0.7rem; }
    .composer { padding: 0.6rem 0.7rem calc(0.7rem + env(safe-area-inset-bottom)); }
    .composer textarea { min-height: 2.8rem; }
    /* The session's cost, its bar and the credits chip: each keeps one line.
       With the cost shown the three take a line of their own, and the chip
       moves under the cost, to the right, when they do not fit. */
    .cost a, .refill-chip { white-space: nowrap; }
    .cost:has(> #session-cost:not(.hidden)) { flex: 1 1 100%; flex-wrap: wrap; }
    .cost .bar { flex: 1 1 2rem; max-width: 4rem; }
    .refill-chip { margin-left: auto; }
    /* 16px keeps iOS Safari from zooming the page when a field takes focus. */
    input, select, textarea { font-size: 16px; }
    .popover { width: min(92vw, 22rem); }
    .popover.menu { width: min(80vw, 15rem); }
    .jump { right: 0.8rem; }
    .question { margin-left: 0.2rem; margin-right: 0.2rem; }
    /* Every dialog takes the whole screen, each label above its field. */
    .dialog, .dialog.large { width: 100vw; height: 100dvh; max-height: none; border: none; border-radius: 0; }
    .dialog-head, .dialog-body, .dialog-foot { padding-left: 0.9rem; padding-right: 0.9rem; }
    .dialog-notice { margin-left: 0.9rem; margin-right: 0.9rem; }
    .dialog-foot { padding-bottom: calc(0.7rem + env(safe-area-inset-bottom)); }
    .dialog-form { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
    .dialog-form > label { margin-top: 0.6rem; }
    .file-view .dialog-head { flex-wrap: wrap; }
    .fv-title { flex-basis: 100%; }
    #file-view-close { margin-left: auto; }
    .fv-doc { padding: 0.8rem 0.9rem 2rem; }

    /* Thumbs, not cursors */
    .session-item { padding: 0.6rem 0.65rem; }
    .stop-banner button { margin-left: 0; }
    .results .head { flex-wrap: wrap; }
    .tabs button { padding: 0.7rem 0.6rem; }
    .stars button { font-size: 1.4rem; padding: 0 0.15rem; }
    .msg-user .actions button { padding: 0.3rem 0.5rem; }

    /* Wide content scrolls inside itself instead of widening the page */
    .facts { grid-template-columns: auto minmax(0, 1fr); }
    .timeline .row-t { grid-template-columns: 2.8rem minmax(0, 1fr) auto; gap: 0.4rem; }
    .timeline details, .timeline .meta-row, .subagent { margin-left: 1rem; }
    main.narrow { padding: 1.2rem 0.8rem 4rem; padding-left: calc(0.8rem + env(safe-area-inset-left)); padding-right: calc(0.8rem + env(safe-area-inset-right)); }
    .card { padding: 0.9rem 0.9rem; }
    details.fold > summary { margin: -0.9rem; padding: 0.9rem; }   /* the whole card's top is the target, as above */
    /* A model chip that wraps reads as a box, its × at the right. */
    .model-list-item { border-radius: 0.9rem; }
    .model-list-item button.quiet { margin-left: auto; }
  }

  @media (max-width: 400px) {
    /* The narrowest phones: the brand word gives way to the mark. */
    .top h1 { display: none; }
    .brand { min-width: 24px; min-height: 24px; }   /* the mark alone is still a 24px target */
    .navlink, a.navlink { padding: 0.3rem 0.3rem; font-size: 0.86rem; }
  }
  @media (max-width: 440px) {
    /* So a person's links and Log out fit whole, the brand word beside them
       down to 400px, the mark alone below. */
    .top { gap: 0.2rem; }
    #logout { padding: 0.2rem 0.25rem; }
  }

  /* -- Talk: the live call's state bars and transcripts (AP-1243) ------------
     The three bars are the call's face: breathing = listening, jumping green
     = hearing you, amber trickle = thinking, blue wave = speaking. Derived
     client-side from audio levels (talk.js), so they move with the sound. */

  .talk-lines { max-height: 16rem; overflow-y: auto; border-top: 1px solid var(--rule); margin-top: 0.5rem; padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; }
  .talk-lines:empty { display: none; }
  .talk-line { display: flex; gap: 0.5rem; font-size: 0.92rem; }
  .talk-line b { flex: 0 0 2.4rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding-top: 0.2rem; }
  .talk-line.user b { color: var(--accent); }
  /* AP-1388: a caller line from another voice, by the caller's voiceprint. */
  .talk-line.other b { color: var(--muted); }
  .talk-line.other span { color: var(--muted); font-style: italic; }
  .talk-line.bot b { color: var(--done); }
  /* An admin's call past the recipe check: what it would have refused. */
  .talk-line.policy { color: var(--muted); font-size: 0.82rem; border-left: 3px solid var(--accent); padding-left: 0.5rem; }

  .talk-past-call summary { cursor: pointer; }
  .talk-past-call summary::-webkit-details-marker { display: none; }
  .talk-past-call summary > span:first-child::before { content: "▸  "; color: var(--muted); }
  .talk-past-call[open] summary > span:first-child::before { content: "▾  "; }
  .talk-past-call .talk-lines { max-height: 12rem; margin-bottom: 0.6rem; }

  /* AP-1245: a bot line the caller cut off. */
  .talk-line.cut span { opacity: 0.75; }
  .talk-cut { font-style: normal; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--warn); white-space: nowrap; align-self: center; }

  /* AP-1270: the call's inner streams — stacked lanes on one time axis. */
  .talk-flow { margin-top: 0.8rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0; background: var(--code); }
  /* min-width: max-content — the row must be as wide as its track, or the
     sticky lane label runs out of row to stick in and scrolls off. */
  .talk-flow-lane { display: flex; align-items: center; height: 1.6rem; min-width: max-content; }
  .talk-flow-lane b { position: sticky; left: 0; z-index: 1; flex: 0 0 4.2rem; padding-left: 0.6rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--code); }
  .talk-flow-track { position: relative; height: 100%; min-width: 100%; }
  .talk-flow-span { position: absolute; top: 0.35rem; height: 0.9rem; min-width: 4px; border-radius: 4px; background: var(--accent-soft); border: 1px solid var(--accent); opacity: 0.9; }
  .talk-flow-tick { position: absolute; top: 0.25rem; max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-style: normal; font-size: 0.62rem; line-height: 1.1rem; padding: 0 0.3rem; border-left: 2px solid var(--accent); background: var(--card); color: var(--ink); border-radius: 0 4px 4px 0; }
  .talk-flow-lane:last-child .talk-flow-tick { border-left-color: var(--warn); color: var(--warn); }
  .talk-flow-tick, .talk-flow-span { animation: flow-in 0.3s ease-out; }
  @keyframes flow-in { from { opacity: 0; } to { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .talk-flow-tick, .talk-flow-span { animation: none !important; } }
  .talk-flow-note { font-size: 0.72rem; margin: 0.6rem 0 0.2rem; }

  /* AP-1277: the tone lane — a small line graph of pitch/energy/pace. */
  .talk-flow-plot { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
  .talk-flow-plot polyline { fill: none; stroke-width: 1.5; opacity: 0.85; }
  .talk-tone-pitch { stroke: var(--accent); }
  .talk-tone-energy { stroke: var(--done); }
  .talk-tone-pace { stroke: var(--warn); }
  .talk-tone-range { stroke: var(--fail); }
  .talk-tone-pauses { stroke: var(--muted); stroke-dasharray: 3 2; }
  .talk-flow-dot { position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--ink); opacity: 0.35; }
  .talk-flow-dot:hover { opacity: 0.9; }

  /* AP-1278: the post-call review inside a past call's fold. */
  .talk-review { margin: 0.8rem 0 0.4rem; padding: 0.7rem 0.9rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
  .talk-review b { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .talk-review p { margin: 0.4rem 0 0; font-size: 0.86rem; }
  /* AP-1313: one remembered note per row. */
  .talk-memory { padding: 0.5rem 0; border-top: 1px solid var(--line); }
  .talk-memory:first-child { border-top: none; }
  .talk-memory p { margin: 0.25rem 0 0; font-size: 0.86rem; }

  /* AP-1279: legibility — taller tone lane, staggered hover-expanding ticks. */
  .talk-flow-lane.tall { height: 3rem; }
  .talk-flow-tick { font-size: 0.6rem; line-height: 0.85rem; top: 0.15rem; }
  .talk-flow-tick.low { top: 1.1rem; }
  .talk-flow-tick:hover { z-index: 3; max-width: none; overflow: visible; }
  .talk-flow-plot polyline { stroke-width: 2; }
  .talk-flow-dot { width: 8px; height: 8px; margin-top: 0; opacity: 0.9; background: var(--card); border: 2px solid var(--ink); }
  .talk-flow-dot.talk-tone-pitch { border-color: var(--accent); }
  .talk-flow-dot.talk-tone-energy { border-color: var(--done); }
  .talk-flow-dot.talk-tone-pace { border-color: var(--warn); }
  .talk-flow-dot.talk-tone-range { border-color: var(--fail); }
  .talk-flow-dot.talk-tone-pauses { border-color: var(--muted); }

  /* AP-1280: the Talk dashboard — call setup and recipe cards. */
  .talk-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
  @media (max-width: 640px) { .talk-setup { grid-template-columns: 1fr; } }
  .talk-setup > div { display: flex; flex-direction: column; justify-content: flex-end; }
  .talk-setup select { width: 100%; }
  #talk-voice-row { display: flex; gap: 0.5rem; align-items: center; }
  #talk-voice-row select { flex: 1; }
  #talk-voice-row button { margin-top: 0; white-space: nowrap; }
  .talk-recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.8rem; margin-top: 1rem; }
  .talk-recipe { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
  .talk-recipe-preview { color: var(--muted); font-size: 0.8rem; line-height: 1.35; max-height: 3.9em; overflow: hidden; flex: 1; }
  .talk-recipe-actions { margin-top: 0.2rem; align-items: center; }
  .talk-recipe-actions button { margin-top: 0; }

  /* AP-1280: the live call takes the screen. */
  .talk-call { position: fixed; inset: 0; height: 100dvh; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem clamp(1rem, 4vw, 2.5rem) 1.2rem; background: var(--paper); overflow-y: auto; }
  .talk-call-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
  .talk-call-head h2 { margin: 0; }
  .talk-call-head button { margin-top: 0; }
  .talk-call-stage { text-align: center; padding: 1.2rem 0 0.4rem; }
  .talk-call-lines { flex: 1; min-height: 7rem; max-height: none; max-width: 46rem; width: 100%; margin: 0.5rem auto 0; border-top: none; }
  .talk-call-foot { display: flex; align-items: center; gap: 1rem; max-width: 46rem; width: 100%; margin: 0 auto; }

  /* AP-1280: the presence orb — the call's turn-taking cue. */
  .talk-orb { position: relative; width: 7.5rem; height: 7.5rem; margin: 0 auto; }
  .talk-orb i { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
  .talk-orb .core { background: radial-gradient(circle at 35% 30%, var(--accent-soft) 0%, var(--accent) 85%); transform: scale(calc(0.62 + var(--orb-level, 0) * 0.22)); transition: transform 0.12s ease-out, filter 0.5s; }
  .talk-orb .ring { border: 2px solid var(--accent); opacity: 0; transform: scale(0.95); }
  .talk-orb.connecting .core, .talk-orb.ringing .core { filter: grayscale(1) opacity(0.5); animation: orb-breathe 2s ease-in-out infinite; }
  .talk-orb.listening .core { animation: orb-breathe 3.4s ease-in-out infinite; }
  .talk-orb.listening .r1 { opacity: 0.3; transform: scale(1); transition: opacity 0.6s; }
  .talk-orb.hearing .core { background: radial-gradient(circle at 35% 30%, var(--done-soft) 0%, var(--done) 85%); }
  .talk-orb.hearing .r1 { border-color: var(--done); opacity: 0.55; transform: scale(calc(0.98 + var(--orb-level, 0) * 0.16)); transition: transform 0.1s ease-out; }
  .talk-orb.thinking .core { background: radial-gradient(circle at 35% 30%, var(--warn-soft) 0%, var(--warn) 85%); animation: orb-think 1.5s ease-in-out infinite; }
  .talk-orb.thinking .r1 { border-style: dashed; border-color: var(--warn); opacity: 0.6; transform: scale(1.02); animation: orb-spin 7s linear infinite; }
  .talk-orb.speaking .r1, .talk-orb.speaking .r2 { animation: orb-ripple 1.9s ease-out infinite; }
  .talk-orb.speaking .r2 { animation-delay: 0.95s; }
  .talk-orb.yourturn .core { background: radial-gradient(circle at 35% 30%, var(--done-soft) 0%, var(--done) 85%); }
  .talk-orb.yourturn .r1 { border-color: var(--done); animation: orb-ripple 0.9s ease-out 2; }
  .talk-orb-word { margin-top: 0.9rem; font-weight: 600; font-size: 0.95rem; transition: color 0.4s ease; }
  .talk-orb-word[data-state="thinking"] { color: var(--warn); }
  .talk-orb-word[data-state="hearing"], .talk-orb-word[data-state="yourturn"] { color: var(--done); }
  .talk-orb-word[data-state="speaking"] { color: var(--accent); }
  .talk-orb-word[data-state="listening"], .talk-orb-word[data-state="connecting"], .talk-orb-word[data-state="ringing"] { color: var(--muted); }
  @keyframes orb-breathe { 50% { transform: scale(0.7); } }
  @keyframes orb-think { 50% { transform: scale(0.58); } }
  @keyframes orb-spin { to { transform: scale(1.02) rotate(360deg); } }
  @keyframes orb-ripple { from { opacity: 0.6; transform: scale(0.72); } to { opacity: 0; transform: scale(1.18); } }
  @media (prefers-reduced-motion: reduce) { .talk-orb i { animation: none !important; } }

  /* AP-1280: the You lane splits — VAD spans on top, word chips below. */
  .talk-flow-span { z-index: 0; }
  .talk-flow-tick { z-index: 1; }
  .talk-flow-lane.tall .talk-flow-tick { top: 1.45rem; }
  .talk-flow-lane.tall .talk-flow-tick.low { top: 2.25rem; }

/* AP-995, DEC-67: Save as PDF from the viewer prints the rendered document
   and nothing else, flowing over as many pages as it needs. */
@media print {
  body.printing-file > *:not(#file-view) { display: none !important; }
  body.printing-file #file-view { position: absolute !important; inset: 0 auto auto 0; width: 100%; max-width: none; height: auto; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible; background: #fff; color: #000; }
  body.printing-file #file-view::backdrop { display: none; }
  body.printing-file #file-view .dialog-head, body.printing-file #file-view-notice { display: none !important; }
  body.printing-file #file-view-body { overflow: visible !important; max-height: none !important; height: auto !important; padding: 0; }
}
