:root {
  color-scheme: light;
  --page: #f4f6f8; --surface: #fff; --raised: #f1f4f7; --line: #dce2e8; --line-strong: #aab6c2;
  --ink: #182332; --ink-soft: #485767; --ink-muted: #566574; --ink-faint: #7b8896;
  --brand: #0865a3; --brand-ink: #075e9e; --brand-soft: #e7f0f8; --focus: #d78214;
  --ok: #10683f; --ok-soft: #e3f3ea; --warn: #8a5300; --warn-soft: #fbf0dd;
  --bad: #a32828; --bad-soft: #fbe9e9; --info: #075e9e; --info-soft: #e7f0f8;
  --radius: 12px; --radius-sm: 6px; --pill: 999px;
  --shadow: 0 1px 2px rgb(16 30 45 / .06), 0 1px 3px rgb(16 30 45 / .04);
  --shadow-lift: 0 4px 12px rgb(16 30 45 / .08);
  font-family: system-ui, sans-serif; color: var(--ink); background: var(--page); line-height: 1.6;
}
/* Dark mode is scoped to the operator console; the viewer page stays light. */
@media (prefers-color-scheme: dark) {
  body.console {
    color-scheme: dark;
    --page: #0e1621; --surface: #16202c; --raised: #1d2937; --line: #26333f; --line-strong: #3c4c5c;
    --ink: #e9eef4; --ink-soft: #b3c0cd; --ink-muted: #93a2b1; --ink-faint: #7d8c9b;
    --brand: #2b87ce; --brand-ink: #7cc0f2; --brand-soft: #16303f; --focus: #f0a53c;
    --ok: #63d29b; --ok-soft: #12301f; --warn: #f0b661; --warn-soft: #33260f;
    --bad: #f08b8b; --bad-soft: #331919; --info: #7cc0f2; --info-soft: #16303f;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lift: 0 4px 14px rgb(0 0 0 / .45);
    background: var(--page); color: var(--ink);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
header { padding: 1rem max(1.25rem, calc((100vw - 1100px) / 2)); background: #111827; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
header a { color: #fff; }
.brand { font-size: 1.5rem; font-weight: 800; text-decoration: none; letter-spacing: -.04em; }
.brand span { margin-left: .8rem; color: #a4c9e9; font-size: .8rem; font-weight: 500; letter-spacing: normal; }
main { max-width: 1140px; margin: 2.5rem auto; padding: 0 1.25rem; }
main.reader { max-width: 680px; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.15; letter-spacing: -.035em; margin: .3rem 0 .75rem; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
p { margin: .7rem 0 1rem; }
a { color: var(--brand-ink); text-underline-offset: .2em; }
.eyebrow { text-transform: uppercase; color: var(--ink-soft); font-size: .75rem; font-weight: 700; letter-spacing: .13em; margin-bottom: .2rem; }
.intro { font-size: 1.05rem; color: var(--ink-soft); margin-bottom: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.muted, small { color: var(--ink-muted); font-size: .875rem; }
.composer { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.5rem; align-items: start; }
label { display: block; font-weight: 600; margin-bottom: .4rem; }
input, textarea, select { display: block; width: 100%; min-width: 0; font: inherit; font-size: max(1rem, 16px); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .7rem; margin-bottom: 1.2rem; color: inherit; background: var(--surface); }
input:hover, textarea:hover, select:hover { border-color: var(--brand); }
textarea { resize: vertical; }
button { border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: var(--radius-sm); padding: .6rem 1rem; min-height: 44px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button.secondary { background: var(--surface); color: var(--brand-ink); }
button.secondary:hover:not(:disabled) { background: var(--brand-soft); filter: none; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.2rem 0; }
.notification { display: flex; gap: .8rem; background: var(--raised); padding: 1rem; border-radius: 8px; overflow-wrap: anywhere; }
.notification img { flex-shrink: 0; }
.notification h2 { margin: .3rem 0; font-size: 1rem; }
.notification p { margin: .3rem 0 .8rem; }
.notification a { font-size: .8rem; }
.history { margin-top: 1.5rem; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; margin: 1rem 0; }
.filters > div { flex: 1 1 150px; min-width: 0; }
.filters input, .filters select { margin-bottom: 0; }
.saved-list > article { border-top: 1px solid var(--line); padding: 1rem 0; overflow-wrap: anywhere; }
.saved-list h3 { margin: 0; font-size: 1rem; }
.section-heading { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2, .section-heading h3 { margin: 0; }
.section-heading select { margin-bottom: 0; }
.section-heading label { margin-bottom: .2rem; font-weight: 400; }
.table-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.table-actions button { padding: .35rem .7rem; min-height: 36px; font-size: .85rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; z-index: 1; background: var(--raised); font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-muted); }
th, td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--raised); }
td:first-child { max-width: 320px; overflow-wrap: anywhere; }
td small { display: block; color: var(--ink-muted); }
[hidden] { display: none !important; }

/* Operator console */
.tabs { display: flex; width: fit-content; max-width: 100%; gap: .3rem; margin: 0 0 1.5rem; padding: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); overflow-x: auto; box-shadow: var(--shadow); }
.tabs button { flex: 0 0 auto; white-space: nowrap; padding: .6rem 1.5rem; background: transparent; border-color: transparent; color: var(--ink-soft); border-radius: var(--pill); font-weight: 600; }
.tabs button:hover:not([aria-selected=true]) { background: var(--raised); filter: none; color: var(--ink); }
.tabs button[aria-selected=true] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs .count { font-variant-numeric: tabular-nums; font-size: .8rem; opacity: .75; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); }
.stat dt { text-transform: uppercase; font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: var(--ink-muted); }
.stat dd { margin: .25rem 0 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat dd small { display: block; font-weight: 400; letter-spacing: normal; }
.pill { display: inline-block; padding: .1rem .55rem; text-transform: capitalize; border-radius: var(--pill); font-size: .75rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: var(--raised); color: var(--ink-soft); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--info-soft); color: var(--info); }
.id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; color: var(--ink-faint); white-space: nowrap; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.counter { font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--ink-faint); font-weight: 600; }
.counter.over { color: var(--warn); }
/* A plain note is just a caption; only ok/bad/busy earn a banner. */
.note { margin: 1.2rem 0 0; font-size: .9rem; color: var(--ink-muted); }
.note:empty { display: none; }
.note-ok, .note-bad, .note-busy { border: 1px solid var(--line); border-left: 4px solid var(--line-strong); background: var(--raised); border-radius: var(--radius-sm); padding: .7rem .9rem; }
.note-ok { border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.note-bad { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.note-busy { border-left-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.list-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: 1rem 0 .5rem; }
.list-meta .note { margin: 0; flex: 1 1 220px; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-muted); }

@media (max-width: 720px) {
  .composer { grid-template-columns: 1fr; }
  main { margin-top: 1.5rem; }
  header { flex-wrap: wrap; }
  .card { padding: 1.1rem; }
  .tabs { width: auto; border-radius: var(--radius); }
  .tabs button { flex: 1 1 auto; padding: .6rem .5rem; }
  .tabs .count { display: none; }
  /* Stacked rows read better than a five-column horizontal scroll on a phone. */
  .stack-mobile { border: 0; }
  .stack-mobile table, .stack-mobile tbody, .stack-mobile tr, .stack-mobile td { display: block; width: auto; }
  .stack-mobile thead { display: none; }
  .stack-mobile tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; margin-bottom: .6rem; }
  .stack-mobile td { max-width: none; border: 0; padding: .15rem 0; }
  .stack-mobile td::before { content: attr(data-label) ": "; color: var(--ink-muted); font-size: .8rem; }
  .stack-mobile td:not([data-label])::before { content: none; }
  .stack-mobile tbody tr:hover td { background: none; }
}
