/* Themes: five palettes, each with a dark and a light mode, selected with
   data-theme / data-mode on <html> (see src/theme.ts). Midnight dark is the
   default. "Film" tokens colour the always-dark lightbox-style panels. */
:root {
  --radius-s: 4px;
  --radius-m: 8px;
  --font: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
:root, :root[data-theme="midnight"][data-mode="dark"] {
  --bg: #0d1726;
  --panel: #13213a;
  --panel-2: #1a2b48;
  --rule: #253a5c;
  --text: #dbe5f3;
  --muted: #8ea2c0;
  --accent: #5aa2ff;
  --accent-ink: #05111f;
  --accent-soft: rgba(90, 162, 255, 0.16);
  --ok: #4fbf8f;
  --bad: #ef6b5e;
  --film: #08101c;
  --film-panel: #14223a;
  --film-rule: #22344f;
  --film-text: #d6e1f0;
  --film-muted: #8496b3;
  --focus: #9cc8ff;
  color-scheme: dark;
}
:root[data-theme="midnight"][data-mode="light"] {
  --bg: #edf2f9;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --rule: #d3dceb;
  --text: #15233a;
  --muted: #566a88;
  --accent: #1d64c9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 100, 201, 0.12);
  --ok: #237a52;
  --bad: #c0392f;
  --film: #0f1a2b;
  --film-panel: #182640;
  --film-rule: #2a3c5a;
  --film-text: #dbe5f3;
  --film-muted: #8ea2c0;
  --focus: #1d64c9;
  color-scheme: light;
}
:root[data-theme="slate"][data-mode="dark"] {
  --bg: #18212b;
  --panel: #212d3a;
  --panel-2: #283646;
  --rule: #2f3e4f;
  --text: #dce4ec;
  --muted: #8b9bae;
  --accent: #e9b44c;
  --accent-ink: #1d1606;
  --accent-soft: rgba(233, 180, 76, 0.14);
  --ok: #5db88c;
  --bad: #e0675a;
  --film: #0f161e;
  --film-panel: #283646;
  --film-rule: #2f3e4f;
  --film-text: #dce4ec;
  --film-muted: #8b9bae;
  --focus: #7cc4ff;
  color-scheme: dark;
}
:root[data-theme="slate"][data-mode="light"] {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f5f7f9;
  --rule: #d5dce3;
  --text: #1c2733;
  --muted: #5b6b7d;
  --accent: #b97a0c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(185, 122, 12, 0.12);
  --ok: #2d8a5e;
  --bad: #c2463a;
  --film: #1a232d;
  --film-panel: #283646;
  --film-rule: #33445a;
  --film-text: #dce4ec;
  --film-muted: #8b9bae;
  --focus: #1f6fb5;
  color-scheme: light;
}
:root[data-theme="graphite"][data-mode="dark"] {
  --bg: #161718;
  --panel: #1f2022;
  --panel-2: #27292c;
  --rule: #34373b;
  --text: #e3e4e6;
  --muted: #979ba1;
  --accent: #3cc4d6;
  --accent-ink: #04191c;
  --accent-soft: rgba(60, 196, 214, 0.15);
  --ok: #5dbb84;
  --bad: #e8695d;
  --film: #0c0d0e;
  --film-panel: #222326;
  --film-rule: #323438;
  --film-text: #dedfe1;
  --film-muted: #8d9196;
  --focus: #7fe3f0;
  color-scheme: dark;
}
:root[data-theme="graphite"][data-mode="light"] {
  --bg: #f2f2f3;
  --panel: #ffffff;
  --panel-2: #f7f7f8;
  --rule: #dadbdd;
  --text: #1c1d1f;
  --muted: #62666b;
  --accent: #0e8797;
  --accent-ink: #ffffff;
  --accent-soft: rgba(14, 135, 151, 0.12);
  --ok: #2b7d51;
  --bad: #c2412f;
  --film: #18191b;
  --film-panel: #26282b;
  --film-rule: #36393d;
  --film-text: #e3e4e6;
  --film-muted: #979ba1;
  --focus: #0e8797;
  color-scheme: light;
}
:root[data-theme="evergreen"][data-mode="dark"] {
  --bg: #0f1a17;
  --panel: #152420;
  --panel-2: #1c2f29;
  --rule: #284239;
  --text: #dbe9e3;
  --muted: #8eab9f;
  --accent: #4fd1a1;
  --accent-ink: #04170f;
  --accent-soft: rgba(79, 209, 161, 0.15);
  --ok: #7ccf72;
  --bad: #ef6f60;
  --film: #08110e;
  --film-panel: #152621;
  --film-rule: #243a33;
  --film-text: #d6e6df;
  --film-muted: #87a397;
  --focus: #93ead0;
  color-scheme: dark;
}
:root[data-theme="evergreen"][data-mode="light"] {
  --bg: #eef5f2;
  --panel: #ffffff;
  --panel-2: #f5faf8;
  --rule: #d0e1d9;
  --text: #13261f;
  --muted: #557063;
  --accent: #137a56;
  --accent-ink: #ffffff;
  --accent-soft: rgba(19, 122, 86, 0.12);
  --ok: #2f7d3c;
  --bad: #c03a2f;
  --film: #10201b;
  --film-panel: #1a2e28;
  --film-rule: #2a453c;
  --film-text: #dbe9e3;
  --film-muted: #8eab9f;
  --focus: #137a56;
  color-scheme: light;
}
:root[data-theme="plum"][data-mode="dark"] {
  --bg: #1a1424;
  --panel: #231b31;
  --panel-2: #2c223d;
  --rule: #3b2e52;
  --text: #e8e0f2;
  --muted: #a596ba;
  --accent: #c08cff;
  --accent-ink: #1a0d2b;
  --accent-soft: rgba(192, 140, 255, 0.16);
  --ok: #5fc49a;
  --bad: #f0707a;
  --film: #0f0b16;
  --film-panel: #241c33;
  --film-rule: #382c4e;
  --film-text: #e3dbee;
  --film-muted: #9c8eb2;
  --focus: #d9b8ff;
  color-scheme: dark;
}
:root[data-theme="plum"][data-mode="light"] {
  --bg: #f5f1fa;
  --panel: #ffffff;
  --panel-2: #faf7fd;
  --rule: #e0d6ec;
  --text: #24183a;
  --muted: #6c5d84;
  --accent: #7b3fc4;
  --accent-ink: #ffffff;
  --accent-soft: rgba(123, 63, 196, 0.12);
  --ok: #2a7d57;
  --bad: #c13b4a;
  --film: #1a1326;
  --film-panel: #2a2140;
  --film-rule: #3d3058;
  --film-text: #e8e0f2;
  --film-muted: #a596ba;
  --focus: #7b3fc4;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
.tab { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: 0.45rem 0.6rem;
  min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type='checkbox'] { accent-color: var(--accent); width: 1rem; height: 1rem; padding: 0; }

button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: 0.55; }
.btn, .btn-primary, .btn-ghost, .btn-link {
  border-radius: var(--radius-s);
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  background: none;
  white-space: nowrap;
}
.btn { border-color: var(--rule); background: var(--panel-2); }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.btn-ghost.danger:hover:not(:disabled) { color: var(--bad); }
.btn-link { padding: 0.1rem 0.3rem; color: var(--accent); }
.btn-link:hover { text-decoration: underline; }
.block { width: 100%; }

/* ------------------------------------------------------------------ shell */
.boot { min-height: 100vh; }
.shell { display: grid; grid-template-columns: 15rem 1fr; min-height: 100vh; }
.rail {
  background: var(--panel);
  border-right: 1px solid var(--rule);
  padding: 1.1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-s);
  color: var(--text);
  text-decoration: none;
}
.rail a:hover { background: var(--panel-2); }
.rail a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.rail-group { color: var(--muted); font-size: 0.82rem; margin: 1.1rem 0.65rem 0.25rem; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.15rem; border-top: 1px solid var(--rule); padding-top: 0.75rem; }
.rail-foot .btn-ghost { text-align: left; padding-left: 0.65rem; }
.rail-viewer { border: 1px solid var(--rule); text-align: center; margin-bottom: 0.4rem; }

.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.05rem; padding: 0 0.65rem 1rem; }
.brand-lg { font-size: 1.35rem; padding: 0 0 1rem; }
/* A tiny lightbox: four panes, one lit. */
.brand-mark {
  width: 1.15rem; height: 1.15rem; flex: none;
  display: inline-block;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 46% 46% no-repeat,
    linear-gradient(var(--rule), var(--rule)) 100% 0 / 46% 46% no-repeat,
    linear-gradient(var(--rule), var(--rule)) 0 100% / 46% 46% no-repeat,
    linear-gradient(var(--rule), var(--rule)) 100% 100% / 46% 46% no-repeat;
  border-radius: 2px;
}

.main { padding: 1.75rem 2rem 4rem; min-width: 0; }
.page { max-width: 82rem; }
.page-narrow { max-width: 34rem; }
.page-head { display: flex; align-items: center; gap: 1rem; justify-content: space-between; flex-wrap: wrap; margin-bottom: 0.5rem; }
.page-head h1 { margin: 0; }
.lede { color: var(--muted); max-width: 70ch; }
.notice { color: var(--muted); }
.count { color: var(--muted); margin: 1.25rem 0 0.5rem; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(24rem, 100%); display: flex; flex-direction: column; gap: 0.9rem; }
.login-lede { color: var(--muted); }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; border: 0; padding: 0; margin: 0; }
.field-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form h2 { margin-top: 0.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.9rem 1rem; align-items: start; }
.form-grid .field-wide, .form-grid > .field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.spacer { flex: 1; }
.form-error { color: var(--bad); margin: 0.5rem 0; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.checks { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0.25rem 0 0.5rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-grid > .check { align-self: end; padding-bottom: 0.5rem; }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--panel-2); border: 0; border-right: 1px solid var(--rule); padding: 0.42rem 0.75rem; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* ------------------------------------------------------------------ search */
.node-picker { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0 1rem; }
.node-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m);
  padding: 0.5rem 0.8rem;
}
.node-chip:hover { border-color: var(--muted); }
.node-chip.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.node-chip-name { font-weight: 700; }
.node-chip-kind { color: var(--muted); font-size: 0.82rem; }

.query {
  display: grid;
  grid-template-columns: repeat(4, minmax(8rem, 1fr)) minmax(10rem, max-content);
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  padding: 0.9rem;
}
.query-row { grid-column: 1 / -1; border: 0; padding: 0; margin: 0.25rem 0 0; min-width: 0; }
.query-row > legend { padding: 0; margin-bottom: 0.35rem; }
.query .dates { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; color: var(--muted); }
.date-range { display: inline-flex; align-items: center; gap: 0.5rem; }
.date-summary { font-size: 0.9rem; }
.mod-checks { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mod-check {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; user-select: none;
  border: 1px solid var(--rule); background: var(--panel-2); border-radius: var(--radius-s);
  padding: 0.3rem 0.6rem; font-weight: 700; font-size: 0.88rem;
}
.mod-check:hover { border-color: var(--muted); }
.mod-check.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.mod-check input { width: 0.9rem; height: 0.9rem; }
.query > .btn-primary { grid-column: 5; max-width: 20rem; overflow: hidden; text-overflow: ellipsis; }
.query-compact { grid-template-columns: 1fr auto; max-width: 40rem; margin: 1rem 0; }

.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; opacity: 0.6; }
.dot-ok { background: var(--ok); opacity: 1; }
.dot-bad { background: var(--bad); opacity: 1; }

.mods { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }
.mod {
  display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 0.05rem 0.4rem;
  border-radius: 3px; background: var(--panel-2); border: 1px solid var(--rule); color: var(--text);
}
.badge { font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: 3px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--rule); }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; }
.grid th { text-align: left; font-weight: 500; font-size: 0.85rem; color: var(--muted); padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); background: var(--panel-2); }
.grid td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions > * + * { margin-left: 0.25rem; }
.grid .sub { display: block; color: var(--muted); font-size: 0.85rem; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { cursor: pointer; }
.row:hover td { background: var(--panel-2); }
.row-open td { background: var(--accent-soft); }
.row-open td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.detail > td { background: var(--film); padding: 0; }

.study-detail { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.25rem; padding: 1rem 1.25rem 1.25rem; color: var(--film-text); }
.series-list { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.series { display: grid; grid-template-columns: auto 2.5rem auto 1fr auto; align-items: center; gap: 0.65rem; padding: 0.35rem 0.5rem; border-radius: var(--radius-s); cursor: pointer; }
.series:hover { background: rgba(255, 255, 255, 0.06); }
.series .mod { background: transparent; border-color: var(--film-rule); color: var(--film-text); }
.series-no { color: var(--film-muted); text-align: right; }
.series-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-count { color: var(--film-muted); font-size: 0.85rem; }
.study-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: stretch; }
.study-actions .field-label { color: var(--film-muted); display: block; margin-bottom: 0.3rem; }
.study-actions .seg button { background: var(--film-panel); color: var(--film-text); border-color: var(--film-rule); }
.study-actions .seg button.on { background: var(--accent); color: var(--accent-ink); }
.study-actions .btn { background: var(--film-panel); color: var(--film-text); border-color: var(--film-rule); }
.study-detail .muted { color: var(--film-muted); }

.progress { display: flex; flex-direction: column; gap: 0.3rem; min-width: 11rem; }
.progress-bar { height: 0.4rem; background: var(--rule); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--accent); transition: width 0.4s ease; }
.progress-completed .progress-bar span { background: var(--ok); }
.progress-failed .progress-bar span, .progress-partial .progress-bar span { background: var(--bad); }
.progress-cancelled .progress-bar span { background: var(--muted); }
.progress-label { font-size: 0.85rem; }
.progress-msg { font-size: 0.8rem; color: var(--bad); max-width: 46ch; overflow-wrap: anywhere; }
.progress-cell { width: 30%; }

.empty { border: 1px dashed var(--rule); border-radius: var(--radius-m); padding: 2rem; margin-top: 1.25rem; max-width: 46rem; }
.empty-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 0.35rem; }
.empty-body { color: var(--muted); }
.empty-body p { margin: 0; }

/* ------------------------------------------------------------------ nodes */
.node-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.node-card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.node-card.disabled { opacity: 0.65; }
.node-card header { display: flex; align-items: center; gap: 0.55rem; }
.node-kind { color: var(--muted); font-size: 0.82rem; margin-left: auto; }
.node-addr { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.node-meta { margin: 0; color: var(--muted); font-size: 0.88rem; }
.node-card footer { display: flex; gap: 0.35rem; margin-top: auto; padding-top: 0.5rem; }
.check > input[type='radio'], .check > input[type='checkbox'] { flex: none; }
.setup-steps { margin: 0.25rem 0 0.75rem 1.25rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.steps { list-style: none; margin: 0.25rem 0; padding: 0.55rem 0.7rem; background: var(--panel-2); border-radius: var(--radius-s); display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; }
.steps li { display: grid; grid-template-columns: 1rem 9.5rem 1fr; gap: 0.4rem; }
.steps .ok .step-mark { color: var(--ok); }
.steps .bad .step-mark, .steps .bad .step-detail { color: var(--bad); }
.step-detail { color: var(--muted); overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ modal / toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 17, 0.6); display: grid; place-items: start center; padding: 6vh 1rem; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); width: min(32rem, 100%); padding: 1.25rem 1.4rem 1.4rem; }
.modal-wide { width: min(58rem, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 30; }
.toast { background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--ok); padding: 0.65rem 0.9rem; border-radius: var(--radius-s); max-width: 26rem; }
.toast-error { border-left-color: var(--bad); }
.code { background: var(--film); color: var(--film-text); padding: 1rem; border-radius: var(--radius-s); overflow: auto; max-height: 65vh; font-size: 0.8rem; }

/* ------------------------------------------------------------------ hanging protocols */
.page-split { display: grid; grid-template-columns: 18rem minmax(0, 1fr); gap: 2rem; max-width: 96rem; }
.hp-list .lede { font-size: 0.92rem; }
.hp-group { margin-top: 1.25rem; }
.hp-group-mod { font-weight: 700; color: var(--accent); margin: 0 0 0.35rem; }
.hp-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.hp-item { width: 100%; display: flex; align-items: center; gap: 0.6rem; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius-s); padding: 0.4rem 0.5rem; }
.hp-item:hover { background: var(--panel); }
.hp-item.on { background: var(--panel); border-color: var(--accent); }
.hp-item.off .hp-item-name { color: var(--muted); }
.hp-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-prio { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.mini { display: inline-grid; gap: 2px; width: 1.6rem; height: 1.2rem; flex: none; }
.mini span { background: var(--muted); opacity: 0.55; border-radius: 1px; }
.mini-big { width: 4.5rem; height: 3.3rem; gap: 3px; }
.mini-big span { background: var(--film); opacity: 1; box-shadow: inset 0 0 0 1px var(--rule); }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 0.75rem; }
.template { display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; background: var(--panel-2); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0.9rem; text-align: left; }
.template:hover { border-color: var(--accent); }
.template-name { font-weight: 700; }
.template-mod { color: var(--muted); font-size: 0.85rem; }

.hp-editor { display: flex; flex-direction: column; gap: 1.25rem; }
.hp-meta { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 1rem; align-items: start; }
.hp-meta > .check { padding-top: 1.7rem; }

/* The lightbox: the protocol as it will hang, panes lit like a film viewer. */
.hp-stage { background: var(--film); border-radius: var(--radius-m); padding: 0.9rem; }
.hp-stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; color: var(--film-text); }
.hp-stage .field-label { color: var(--film-muted); }
.sync { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.layout-picker { display: flex; align-items: center; gap: 0.75rem; }
.layout-cells { display: grid; grid-template-columns: repeat(4, 0.95rem); gap: 3px; }
.layout-cells button { width: 0.95rem; height: 0.95rem; padding: 0; border: 1px solid var(--film-rule); background: var(--film-panel); border-radius: 2px; }
.layout-cells button.in { background: var(--accent); border-color: var(--accent); }
.layout-label { color: var(--film-text); font-weight: 700; min-width: 3rem; }
.lightbox { display: grid; gap: 6px; min-height: 19rem; }
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 0.1rem;
  text-align: left;
  border: 1px solid var(--film-rule);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
  color: var(--film-text);
  background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--film-panel) 70%, #ffffff 12%) 0%, var(--film-panel) 70%);
  overflow: hidden;
  min-height: 7.5rem;
}
.tile:hover { border-color: var(--film-muted); }
.tile.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  /* A lit lightbox pane, tinted with the theme accent. */
  background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--accent) 35%, #ffffff) 0%, color-mix(in srgb, var(--accent) 80%, #ffffff) 55%, color-mix(in srgb, var(--accent) 75%, #000000) 100%);
  color: #10141a;
}
.tile.inverted:not(.on) { background: radial-gradient(120% 90% at 50% 40%, #cfd6dd 0%, #8d99a5 70%); color: #10171e; }
.tile-title { font-weight: 700; font-size: 1rem; }
.tile-line { font-size: 0.82rem; opacity: 0.85; }
.tile-plane { position: absolute; top: 0.7rem; right: 0.8rem; width: 2rem; height: 2rem; border: 1.5px solid currentColor; border-radius: 50%; opacity: 0.55; }
.plane-axial { border-radius: 50%; transform: scaleY(0.35); }
.plane-sagittal { transform: scaleX(0.35); }
.plane-coronal { border-radius: 4px; transform: scaleY(0.8); }

.hp-inspector { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.1rem 1.2rem; }
.hp-inspector h2 { margin-bottom: 0.9rem; }
.hp-advanced { margin-top: 1.2rem; border-top: 1px solid var(--rule); padding-top: 0.9rem; }
.hp-advanced summary { cursor: pointer; color: var(--muted); margin-bottom: 0.75rem; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.6rem; }
  .rail ul { display: flex; flex-wrap: wrap; }
  .rail-group { display: none; }
  .rail-foot { margin: 0; border: 0; padding: 0; flex-direction: row; flex-wrap: wrap; }
  .brand { padding: 0 0.5rem; }
  .main { padding: 1.25rem 1rem 3rem; }
  .query { grid-template-columns: 1fr 1fr; }
  .query > .btn-primary { grid-column: 1 / -1; }
  .study-detail { grid-template-columns: 1fr; }
  .page-split { grid-template-columns: 1fr; }
  .hp-meta { grid-template-columns: 1fr 1fr; }
  table.grid { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* layout fixes */
.field > .seg { align-self: flex-start; }
.seg-grid { display: grid; grid-template-columns: repeat(2, 1fr); align-self: stretch !important; }
.seg-grid button { border-bottom: 1px solid var(--rule); }
.seg-grid button:nth-child(2n) { border-right: 0; }
.seg-grid button:nth-last-child(-n + 2) { border-bottom: 0; }
.hp-list .btn-primary.block { margin: 0.25rem 0 1rem; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .page-split > *, .main { min-width: 0; }
  .rail { width: 100%; }
}

/* ------------------------------------------------------------------ 1.1 additions */
.small { font-size: 0.85rem; }
.small-print { font-size: 0.88rem; margin-top: 1rem; }
.warn-text { color: var(--bad); font-size: 0.9rem; }
code { font-size: 0.9em; background: var(--panel-2); border: 1px solid var(--rule); border-radius: 3px; padding: 0.05rem 0.3rem; }

.chips, .found { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
.chip { display: inline-block; font-size: 0.78rem; padding: 0.08rem 0.45rem; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--rule); color: var(--text); white-space: nowrap; }
.chip-local { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* Multi-select node chips get a checkbox mark. */
.node-check { width: 0.95rem; height: 0.95rem; border: 1.5px solid var(--muted); border-radius: 3px; flex: none; position: relative; }
.node-check.on { background: var(--accent); border-color: var(--accent); }
.node-check.on::after { content: ''; position: absolute; left: 0.27rem; top: 0.06rem; width: 0.25rem; height: 0.5rem; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.node-company { margin: 0; font-weight: 700; font-size: 0.9rem; }

.detail-nodes { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.6rem; }
.detail-nodes .field-label { color: var(--film-muted); }
.detail-nodes .seg button { background: var(--film-panel); color: var(--film-text); border-color: var(--film-rule); }
.detail-nodes .seg button.on { background: var(--accent); color: var(--accent-ink); }
.row td.actions .btn { padding: 0.25rem 0.75rem; }

/* Rail: badge, mode toggle */
.rail a { display: flex; align-items: center; gap: 0.5rem; }
.nav-badge { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 0.75rem; font-weight: 700; min-width: 1.3rem; text-align: center; padding: 0 0.35rem; line-height: 1.3rem; }
.rail-user { display: flex; align-items: center; gap: 0.25rem; }
.rail-user > a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-toggle { padding: 0.35rem 0.5rem; }
.mode-icon { display: block; width: 1rem; height: 1rem; border-radius: 50%; }
/* moon: a crescent; sun: a filled disc with a ring */
.mode-icon-dark { box-shadow: inset -0.3rem -0.15rem 0 0 currentColor; transform: rotate(-20deg); }
.mode-icon-light { background: currentColor; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px currentColor; transform: scale(0.65); }

/* Update notification */
.update-banner { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-m); padding: 0.6rem 0.9rem; margin: -0.5rem 0 1.25rem; max-width: 82rem; }
.update-banner > span:nth-child(2) { flex: 1; min-width: 12rem; }
.update-banner .btn-primary, .update-banner .btn { text-decoration: none; }
.update-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--accent); flex: none; display: inline-block; }
.update-dot-busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
a.btn-primary, a.btn, a.btn-ghost { display: inline-block; text-decoration: none; }
a.btn-primary { color: var(--accent-ink); }
a.btn { color: var(--text); }

.notice-box { border: 1px solid var(--rule); background: var(--panel); border-radius: var(--radius-m); padding: 0.8rem 1rem; margin: 1rem 0; max-width: 60rem; }
.notice-box.warn { border-color: var(--bad); }
.update-status { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0.9rem 1.1rem; margin: 1rem 0; max-width: 60rem; }
.update-status.update-failed, .update-status.update-rolled_back { border-color: var(--bad); }
.update-status.update-succeeded { border-color: var(--ok); }
.update-status-head { display: flex; align-items: center; gap: 0.55rem; }
.update-step { margin: 0.4rem 0; }
.update-log { margin-top: 0.5rem; max-height: 22rem; white-space: pre-wrap; }
.update-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; max-width: 60rem; }
.update-card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; }
.update-card header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.update-notes { white-space: pre-wrap; line-height: 1.5; }
.update-card footer { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* Account: appearance */
.account-block { margin-top: 1.75rem; }
.account-block h2 { margin-bottom: 0.35rem; }
.mode-seg { margin: 0.5rem 0 1rem; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 0.75rem; max-width: 64rem; }
.theme-card { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0.7rem; }
.theme-card:hover { border-color: var(--muted); }
.theme-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-swatch { display: grid; grid-template-columns: 1fr 3fr; gap: 4px; height: 4.2rem; border-radius: var(--radius-s); padding: 5px; border: 1px solid rgba(127, 127, 127, 0.25); }
.theme-swatch-rail { border-radius: 2px; }
.theme-swatch-panel { border-radius: 2px; display: flex; align-items: flex-end; padding: 6px; }
.theme-swatch-panel > span { width: 45%; height: 0.55rem; border-radius: 2px; }
.theme-name { font-weight: 700; }
.theme-blurb { color: var(--muted); font-size: 0.85rem; }

/* Opening a study (its own tab) */
.opening { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.opening-card { width: min(30rem, 100%); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.opening-card .brand { padding: 0; }
.opening-study { margin: 0; }
.opening-step { margin: 0; }

/* ------------------------------------------------------------------ 1.2.0: monitors */
.monitor-map { position: relative; width: 100%; max-width: 46rem; max-height: 22rem; min-height: 9rem; margin: 0.9rem 0; background: var(--panel-2); border: 1px solid var(--rule); border-radius: var(--radius-m); box-sizing: border-box; }
.monitor { position: absolute; box-sizing: border-box; border: 3px solid var(--panel); background: var(--film-panel); color: var(--film-text); border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; padding: 0.2rem; overflow: hidden; }
.monitor:hover { background: var(--film-rule); }
.monitor.on { outline: 3px solid var(--accent); outline-offset: -3px; }
.monitor-num { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.monitor-role { font-size: 0.78rem; color: var(--film-muted); text-align: center; }
.monitor-worklist .monitor-role, .monitor-viewer .monitor-role { color: var(--film-text); font-weight: 700; }
.monitor-viewer { background: #05080d; }
.monitor-none { opacity: 0.55; }
.monitor-split { padding: 0; background: var(--panel); }
.monitor-zone { position: absolute; top: 0; bottom: 0; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; background: var(--film-panel); }
.monitor-zone + .monitor-zone { border-left: 2px dashed var(--film-muted); }
.monitor-zone.monitor-viewer { background: #05080d; }
.monitor-zone.monitor-none { opacity: 0.55; }
.monitor-split.monitor-none, .monitor-split { opacity: 1; }
.role-chooser { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; flex-basis: 100%; }
.role-chooser > .field-label { min-width: 6rem; }
.monitor-inspector { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.4rem; margin-bottom: 0.6rem; }
.monitor-inspector h3 { margin: 0; font-size: 1rem; }
.monitor-inspector p { margin: 0.15rem 0 0; }
.monitor-inspector .field { min-width: 14rem; }
.monitor-blank { min-height: 100vh; background: #000; color: #7d838c; display: grid; place-items: center; text-align: center; font-size: 0.95rem; }
.monitor-blank .strong { color: #b9bec6; }
.opening-card .brand .badge { margin-left: auto; }

.hp-monitors { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.5rem; }
.hp-mon { display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.75rem; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--panel-2); text-align: left; }
.hp-mon.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hp-mon > span { display: flex; flex-direction: column; font-weight: 700; }
.hp-mon-study { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.hp-mon-add { align-self: center; }
.hp-mon-field { min-width: 15rem; }
.hp-mon-field select { background: var(--film-panel); color: var(--film-text); border-color: var(--film-rule); }
.hp-mon-note { margin: 0 0 0.6rem; font-size: 0.85rem; color: var(--film-muted); }
.hp-mon-actions { margin: 0 0 0.6rem; }
.lightbox[style*="aspect-ratio"] { min-height: 0; }
.lightbox-empty { display: grid; place-items: center; border: 1px dashed var(--film-rule); border-radius: 3px; min-height: 12rem; }
.template-mons { display: flex; gap: 0.35rem; }
.check-list { display: flex; flex-direction: column; gap: 0.45rem; align-items: flex-start; }
.hp-mon .mini span { background: var(--accent); opacity: 0.6; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; text-transform: inherit; letter-spacing: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort.on { color: var(--accent); }
.th-arrow { font-size: 0.7em; opacity: 0.45; }
.th-sort.on .th-arrow { opacity: 1; }
th.num .th-sort { flex-direction: row-reverse; }

/* 1.3.0: passkeys and HTTPS */
.note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 0.55rem 0.8rem; border-radius: 3px; max-width: 70ch; }
.note.bad { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.note.ok { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.inline-form input { flex: 1 1 14rem; max-width: 22rem; }
.login-or { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.85rem; }
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--rule); }
.login-hint { color: var(--muted); font-size: 0.85rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0.75rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tls-log { background: var(--panel-2); border: 1px solid var(--rule); border-radius: 4px; padding: 0.6rem 0.8rem; max-height: 16rem; overflow: auto; font-size: 0.8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.host-list { display: flex; flex-direction: column; gap: 0.4rem; max-width: 26rem; }
.host-list .host-row { display: flex; gap: 0.4rem; }
.host-list .host-row input { flex: 1; min-width: 0; }

/* 1.4.0: security, audit, idle sign-out */
.nav-badge-alert { background: var(--bad); color: #fff; }
.inline-badge { display: inline-block; margin-left: 0.6rem; vertical-align: middle; font-size: 0.75rem; }
.rail-note { font-size: 0.78rem; line-height: 1.35; }
.idle-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 1000; padding: 1rem; }
.idle-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 1.25rem 1.5rem; max-width: 26rem; display: flex; flex-direction: column; gap: 0.8rem; }
.idle-card h2 { margin: 0; }
.enroll-card { width: min(34rem, 100%); }
.enroll-title { font-size: 1.3rem; margin: 0; }
.plain-list { list-style: none; padding: 0; margin: 0.25rem 0; display: flex; flex-direction: column; gap: 0.35rem; }
.audit-filters { margin: 1rem 0; align-items: end; }
.audit-table td { vertical-align: top; }
.audit-table .uid { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.bad-row td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.outcome-badge { margin-left: 0.4rem; font-size: 0.72rem; padding: 0 0.35rem; border-radius: 3px; background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.muted-row td { color: var(--muted); }
.strong-row td { font-weight: 600; }
textarea { font: inherit; }
.users-table .actions { white-space: normal; width: 1%; min-width: 16rem; }
.users-table .actions > * { margin: 0.1rem 0 0.1rem 0.25rem; }

/* ------------------------------------------------------------------ reporting (1.5.0) */
.btn-small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.ok-text { color: var(--ok); font-size: 0.9rem; }
.sub-h { font-size: 0.95rem; margin: 1.1rem 0 0.2rem; }
.spacer { flex: 1; }
.tabs { margin: 0.4rem 0 1rem; }

/* Report status chips: worklists, report lists, report screen. */
.report-chip { font-weight: 700; }
.report-draft { border-color: var(--muted); color: var(--muted); }
.report-transcription { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.report-transcribed { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.report-signed { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }

/* The report screen fills the window: header, editor + side panels, action bar. */
.report-screen { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.report-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.6rem; padding: 0.7rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; }
.report-patient h1 { font-size: 1.3rem; margin: 0; line-height: 1.2; }
.report-exam { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.report-facts { display: inline-flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; color: var(--muted); font-size: 0.9rem; align-items: center; }
.report-state { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.report-error { margin: 2rem 1.25rem; }
.report-body { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1.25rem; padding: 1rem 1.25rem; align-items: start; }
.report-main { min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.report-main .notice { margin: 0; padding: 0.55rem 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--panel); }
.editor-wrap { display: flex; flex-direction: column; gap: 0.4rem; }
.editor-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.editor-tools .field-label { margin-right: 0.4rem; }
.save-state { font-size: 0.85rem; }
.report-editor { width: 100%; box-sizing: border-box; min-height: calc(100vh - 15rem); resize: vertical; font: 400 1.05rem/1.6 var(--font); padding: 0.9rem 1rem; background: var(--panel); color: var(--text); border: 1px solid var(--rule); border-radius: var(--radius-m); tab-size: 4; }
.report-editor:focus { outline: 2px solid var(--focus); outline-offset: 0; }
.report-editor[readonly] { background: var(--panel-2); }
.report-editor-small { min-height: 9rem; font-size: 0.98rem; }
.editor-help { font-size: 0.82rem; margin: 0; }
.report-final { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1.1rem 1.3rem; }
.report-text { white-space: pre-wrap; word-wrap: break-word; font: 400 1.03rem/1.6 var(--font); margin: 0; color: var(--text); }
.report-sig { color: var(--muted); margin: 1rem 0 0; font-size: 0.92rem; }
.report-addendum { border-top: 1px solid var(--rule); margin-top: 1.1rem; padding-top: 0.9rem; }
.report-addendum h3 { font-size: 0.95rem; margin: 0 0 0.4rem; text-transform: uppercase; letter-spacing: 0.03em; }
.addendum-editor { border-top: 1px solid var(--rule); margin-top: 1.1rem; padding-top: 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; }
.report-side { display: flex; flex-direction: column; gap: 0.9rem; position: sticky; top: 4.6rem; max-height: calc(100vh - 9.5rem); overflow: auto; }
.side-block { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0.75rem 0.9rem; }
.side-block h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.5rem; }
.side-block p { margin: 0.2rem 0; font-size: 0.9rem; }
.report-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.7rem 1.25rem; background: var(--panel); border-top: 1px solid var(--rule); position: sticky; bottom: 0; z-index: 5; }
.report-actions .btn-primary { min-width: 7rem; }

/* Dictation */
.recorder { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.rec-btn { display: inline-flex; align-items: center; gap: 0.45rem; }
.rec-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--bad); display: inline-block; }
.rec-live { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; color: var(--bad); font-variant-numeric: tabular-nums; }
.rec-live .rec-dot { animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-live.paused { color: var(--muted); }
.rec-live.paused .rec-dot { animation: none; background: var(--muted); }
@keyframes rec-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .rec-live .rec-dot { animation: none; } }
.dict-player { width: 100%; margin: 0.2rem 0; }
.dict-rate { display: flex; align-items: center; gap: 0.4rem; }
.dict-rate select { width: auto; }
.dict-list { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.dict-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.15rem 0; }
.dict-list li.on .btn-link { font-weight: 700; }
.dict-list .tab { margin-left: auto; }

/* Documents */
.docs { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; width: 100%; }
.doc { display: flex; align-items: center; gap: 0.5rem; }
.doc-link { display: flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; min-width: 0; flex: 1; }
.doc-link:hover .doc-meta span:first-child { text-decoration: underline; }
.doc-thumb { width: 2.6rem; height: 3.3rem; object-fit: cover; border: 1px solid var(--rule); border-radius: 3px; background: #fff; }
.doc-pdf { width: 2.6rem; height: 3.3rem; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 3px; font-size: 0.75rem; font-weight: 700; color: var(--bad); background: var(--panel-2); }
.doc-meta { display: flex; flex-direction: column; font-size: 0.88rem; min-width: 0; }
.add-docs { display: flex; flex-direction: column; gap: 0.9rem; }
.drop { border: 2px dashed var(--rule); border-radius: var(--radius-m); padding: 1.4rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.drop p { margin: 0; color: var(--muted); }
.camera { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.camera-view { width: 100%; max-height: 22rem; background: #000; border-radius: var(--radius-m); transition: opacity 0.15s; }
.camera-view.flash { opacity: 0.35; }
.scanner { display: flex; flex-wrap: wrap; gap: 0.7rem 1rem; align-items: flex-end; }
.scanner .field { min-width: 11rem; }
.pages { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.page-thumb { margin: 0; width: 7rem; display: flex; flex-direction: column; gap: 0.2rem; }
.page-thumb img, .page-thumb .doc-pdf { width: 7rem; height: 9rem; object-fit: contain; background: #fff; border: 1px solid var(--rule); border-radius: 3px; }
.page-thumb figcaption { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }

/* Prior reports and activity */
.prior-reports { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.prior-head { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; width: 100%; text-align: left; background: none; border: 0; padding: 0.3rem 0; color: var(--text); cursor: pointer; }
.prior-head:hover .strong { text-decoration: underline; }
.prior-text { padding: 0.3rem 0 0.6rem; border-bottom: 1px solid var(--rule); }
.prior-text .report-text { font-size: 0.9rem; }
.deliveries { list-style: none; padding: 0; margin: 0 0 0.6rem; display: flex; flex-direction: column; gap: 0.45rem; }
.delivery { display: flex; flex-wrap: wrap; gap: 0.2rem 0.5rem; align-items: center; font-size: 0.88rem; }
.delivery-msg { flex-basis: 100%; font-size: 0.82rem; }
.delivery-chip-sent { border-color: var(--ok); color: var(--ok); }
.delivery-chip-failed { border-color: var(--bad); color: var(--bad); }
.delivery-chip-pending, .delivery-chip-sending { border-color: var(--accent); color: var(--accent); }
.history { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.2rem; }

/* Node editor: report routing; admin reporting page; account templates */
.routing { display: flex; flex-direction: column; gap: 0.45rem; border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0.75rem 0.9rem; }
.routing .field { max-width: 30rem; }
.routing-note { margin: 0; font-size: 0.88rem; }
.routing-sub { margin-top: 0.4rem; }
.routing-hl7 { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem 0.9rem; padding: 0.4rem 0 0.4rem 1.6rem; }
.scanner-row { display: grid; grid-template-columns: minmax(10rem, 14rem) minmax(14rem, 1fr) auto; gap: 0.5rem 1rem; align-items: start; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.scanner-row .form-actions { grid-column: 1 / -1; margin: 0; }
.template-editor { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.9rem; margin-top: 0.6rem; max-width: 60rem; }
.template-list { display: flex; flex-direction: column; gap: 0.2rem; }
.template-key { text-align: left; background: var(--panel-2); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 0.35rem 0.6rem; }
.template-key.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.template-add { display: flex; gap: 0.3rem; margin-top: 0.4rem; }
.template-add input { min-width: 0; }
.study-actions-sep { border-top: 1px solid var(--film-rule); margin: 0.2rem 0; }

@media (max-width: 960px) {
  .report-body { grid-template-columns: 1fr; }
  .report-side { position: static; max-height: none; }
  .report-editor { min-height: 50vh; }
  .template-editor { grid-template-columns: 1fr; }
  .scanner-row { grid-template-columns: 1fr; }
}

/* Toasts stay clear of the report screen's action bar. */
.report-screen ~ .toasts { bottom: 4.6rem; }

/* Long dialogs (adding several document pages) scroll inside the window. */
.modal { max-height: calc(100vh - 2.5rem); overflow-y: auto; box-sizing: border-box; }
.template-key.on .muted { color: inherit; opacity: 0.8; }
.scanner-row > .check { padding-top: 1.9rem; }

.btn-primary.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ------------------------------------------------------------------ devices (1.5.1) */
.devices .dev-card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1rem 1.2rem; margin: 0 0 1rem; max-width: 70rem; }
.devices .dev-card h2 { font-size: 1.02rem; margin: 0 0 0.6rem; }
.devices .dev-card p { margin: 0.35rem 0; }
.dev-dot { display: inline-block; width: 0.62rem; height: 0.62rem; border-radius: 50%; margin-right: 0.55rem; vertical-align: 0.05rem; background: var(--muted); }
.dev-ok { background: var(--ok); }
.dev-bad { background: var(--bad); }
.dev-wait { background: var(--muted); opacity: 0.6; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.6rem 1rem; margin: 0.6rem 0; }
.dev-install { margin: 0.6rem 0; }
.dev-install summary { cursor: pointer; font-weight: 600; }
.dev-install ol { padding-left: 1.3rem; }
.dev-install li { margin: 0.35rem 0; }
.dev-cmd { background: var(--panel-2); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 0.55rem 0.7rem; overflow-x: auto; margin: 0.4rem 0; font-size: 0.85rem; }
.dev-upload { margin-left: 0.8rem; cursor: pointer; }
.dev-label { width: 3.5in; max-width: 100%; height: 1.125in; box-sizing: border-box; background: #fff; color: #000; border-radius: 6px; padding: 0.4rem 0.8rem; display: flex; flex-direction: column; justify-content: center; font: 12px Arial, sans-serif; margin: 0.6rem 0 0.2rem; }
.dev-label strong { font-size: 14px; }
.sig-canvas { width: 100%; max-width: 500px; aspect-ratio: 5 / 1; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius-s); display: block; }

/* ------------------------------------------------------------------ 1.6.0 */
.btn.danger, .btn-primary.danger { border-color: var(--bad); }
.btn.danger { color: var(--bad); }
.btn-primary.danger { background: var(--bad); color: #fff; }
.page-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.section-title { margin: 2rem 0 0.6rem; font-size: 1.1rem; }
.grid th.pick, .grid td.pick { width: 2.2rem; padding-right: 0; }
.chip-bad { border-color: var(--bad); color: var(--bad); font-weight: 700; }
.chip-warn { border-color: var(--warn, #d99a1e); color: var(--warn, #d99a1e); font-weight: 700; }
.badge-bad { border-color: var(--bad); color: var(--bad); }
.badge-warn { border-color: var(--warn, #d99a1e); color: var(--warn, #d99a1e); }
.update-banner.banner-alert { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); }
.update-dot-alert { background: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
.node-chip-backup { color: var(--warn, #d99a1e); font-weight: 700; }
.node-roles { margin: 0; display: flex; gap: 0.3rem; flex-wrap: wrap; }
.node-backup { color: var(--muted); }
.backup-box { border: 1px dashed var(--rule); border-radius: var(--radius-m); padding: 0.75rem; gap: 0.6rem; }
.backup-box .form-grid { margin-top: 0.25rem; }
.endpoint { display: inline-flex; align-items: center; gap: 0.4rem; }
.monitor-grid td { vertical-align: top; }
.monitor-grid tr.disabled td { opacity: 0.55; }
.admin-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1.25rem; margin: 1.5rem 0; align-items: start; }
.card-form { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1rem 1.1rem; }
.card-form h2 { margin: 0; font-size: 1.05rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.test-to { max-width: 14rem; }
.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; max-width: 82rem; }
.alert-item { display: grid; grid-template-columns: 11rem 1fr; gap: 0.2rem 1rem; padding: 0.5rem 0.75rem; border: 1px solid var(--rule); border-left: 4px solid var(--muted); border-radius: var(--radius-s); background: var(--panel); }
.alert-item .sub { grid-column: 2; color: var(--muted); font-size: 0.85rem; }
.alert-item.alert-error { border-left-color: var(--bad); }
.alert-item.alert-warning { border-left-color: var(--warn, #d99a1e); }
.alert-item.alert-info { border-left-color: var(--ok); }
.alert-item.unread { box-shadow: inset 0 0 0 1px var(--accent); }

/* DICOM Send */
.send-dialog { min-width: min(30rem, 90vw); }
.send-dests { display: flex; flex-direction: column; gap: 0.4rem; }
.send-dest { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 0.3rem 0.6rem; padding: 0.55rem 0.7rem; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--panel-2); cursor: pointer; }
.send-dest.on { border-color: var(--accent); background: var(--accent-soft); }
.send-dest .sub { grid-column: 3 / -1; color: var(--muted); font-size: 0.85rem; }
.send-jobs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.send-jobs li { display: flex; flex-direction: column; gap: 0.25rem; }

/* Print window */
.print-screen { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }
.print-top { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; }
.print-top h1 { margin: 0; font-size: 1.15rem; }
.print-patient { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1rem; }
.print-msg { padding: 2rem 1.25rem; }
.print-body { display: grid; grid-template-columns: minmax(18rem, 22rem) 1fr; min-height: 0; }
.print-options { display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem 1.25rem; background: var(--panel); border-right: 1px solid var(--rule); overflow-y: auto; max-height: calc(100vh - 3.5rem); position: sticky; top: 3.5rem; }
.print-options .field select, .print-film input { width: 100%; }
.seg-wrap { flex-wrap: wrap; }
.print-series { display: flex; flex-direction: column; gap: 0.35rem; max-height: 12rem; overflow-y: auto; }
.print-series .check { align-items: baseline; }
.print-window { display: flex; gap: 0.75rem; margin-top: 0.3rem; }
.print-window input { width: 6rem; }
.print-film { display: grid; grid-template-columns: 1fr 6rem; gap: 0.75rem; }
.toggle-row { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.print-summary { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-m); padding: 0.7rem 0.9rem; }
.print-summary p { margin: 0; }
.print-pages { font-size: 1.25rem; }
.print-pages strong { font-size: 1.9rem; }
.print-go { padding: 0.7rem 1rem; font-size: 1.05rem; }
.print-preview { display: flex; flex-wrap: wrap; gap: 1.25rem; padding: 1.25rem; align-content: flex-start; }
.preview-page { margin: 0; display: flex; flex-direction: column; gap: 0.35rem; align-items: center; }
.preview-page .preview-grid { display: grid; gap: 2px; background: #fff; padding: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
.preview-page.portrait .preview-grid { width: 12.5rem; height: 16.2rem; }
.preview-page.landscape .preview-grid { width: 16.2rem; height: 12.5rem; }
.preview-cell { background: #000; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.preview-cell img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.print-sheets { display: none; }

@media print {
  html, body { background: #fff !important; }
  .print-screen.printing > :not(.print-sheets):not(style) { display: none !important; }
  .print-screen.printing { display: block; min-height: 0; background: #fff; }
  .print-sheets { display: block; color: #000; font-family: var(--font); }
  .toasts, .idle-overlay { display: none !important; }
  .sheet { height: 100vh; display: flex; flex-direction: column; break-after: page; page-break-after: always; overflow: hidden; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .sheet-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 9pt; padding-bottom: 2mm; border-bottom: 0.3mm solid #000; margin-bottom: 2mm; }
  .sheet-grid { flex: 1; display: grid; gap: 1mm; min-height: 0; }
  .sheet-cell { position: relative; background: #000; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; }
  .sheet-cell img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
  .sheet-label { position: absolute; left: 1mm; bottom: 0.5mm; color: #fff; font-size: 7pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 760px) {
  .print-body { grid-template-columns: 1fr; }
  .print-options { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); }
}
.monitor-grid code { white-space: normal; word-break: break-all; }

/* ------------------------------------------------------------------ phones (1.7.0) */
.m-shell { height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); background: var(--bg); overflow: hidden; }
.m-shell, .mv, .m-sheet { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.m-shell ::-webkit-scrollbar, .mv ::-webkit-scrollbar { width: 4px; height: 4px; }
.m-shell ::-webkit-scrollbar-track, .mv ::-webkit-scrollbar-track { background: transparent; }
.m-shell ::-webkit-scrollbar-thumb, .mv ::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }
.m-shell ::-webkit-scrollbar-thumb:hover, .mv ::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.m-body { overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.m-page-desktop { padding: 12px; overflow-x: auto; }
.m-page-desktop .page { padding: 0; }
.m-page { display: flex; flex-direction: column; min-height: 100%; }
.m-head { display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 10px; background: var(--panel); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 3; }
.m-head h1 { margin: 0; font-size: 22px; flex: 1; }
.m-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--panel-2); color: var(--text); flex: none; }
.m-searchbar { padding: 10px 16px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); }
.m-search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--rule); color: var(--muted); }
.m-search input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font: inherit; font-size: 16px; outline: none; padding: 0; }
.m-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.m-chip { flex: none; height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--rule); background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; }
.m-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.m-count { margin: 0; padding: 10px 16px 6px; font-size: 13px; color: var(--muted); }
.m-pad { padding: 0 16px; }
.m-list { padding: 0 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.m-empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.m-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--rule); color: var(--text); text-align: left; font: inherit; width: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.m-card:active { background: var(--panel-2); }
.m-card-top { display: flex; align-items: baseline; gap: 8px; }
.m-card-name { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card-time { font-size: 13px; color: var(--muted); }
.m-card-desc { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.m-card-id { font-size: 12px; color: var(--muted); }
.m-tabs { display: grid; background: var(--panel); border-top: 1px solid var(--rule); padding: 6px 4px max(10px, env(safe-area-inset-bottom)); }
.m-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; color: var(--muted); text-decoration: none; font-size: 12px; }
.m-tabs a.on { color: var(--accent); font-weight: 700; }
.m-sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(5, 10, 20, 0.55); display: flex; align-items: flex-end; }
.m-sheet { width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0; border-top: 1px solid var(--rule); padding-bottom: max(16px, env(safe-area-inset-bottom)); animation: m-up 0.18s ease-out; }
@keyframes m-up { from { transform: translateY(40px); opacity: 0.4; } }
.m-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--rule); margin: 10px auto 4px; }
.m-sheet-head { padding: 4px 18px 12px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; }
.m-sheet-head p { margin: 0; font-size: 15px; }
.m-sheet-title { display: flex; align-items: center; gap: 8px; }
.m-sheet-title h2 { margin: 0; font-size: 20px; flex: 1; }
.m-sheet-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.m-actions { padding: 14px 18px 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.m-actions button { min-height: 50px; border-radius: 12px; border: 1px solid var(--rule); background: var(--panel-2); color: var(--text); font: inherit; font-size: 15px; }
.m-actions .m-open { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px; }
.m-sheet-sub { margin: 12px 18px 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.m-series { list-style: none; margin: 0; padding: 0 18px; }
.m-series label { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--rule); }
.m-series input { width: 20px; height: 20px; }
.m-series-desc { flex: 1; min-width: 0; font-size: 15px; }
.m-note { margin: 0; padding: 10px 18px; font-size: 13px; color: var(--muted); }
.m-form { padding: 16px; display: flex; flex-direction: column; gap: 20px; flex: 1; }
.m-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.m-field input { height: 46px; font-size: 16px; }
.m-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.m-group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.m-group legend { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.m-grid3, .m-grid4 { display: grid; gap: 8px; }
.m-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.m-grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.m-tile { min-height: 44px; border-radius: 10px; border: 1px solid var(--rule); background: var(--panel); color: var(--text); font: inherit; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.m-tile.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.m-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--rule); background: var(--panel); }
.m-row > span:nth-of-type(1) { flex: 1; font-size: 16px; }
.m-row.on { border-color: var(--accent); }
.m-footer { position: sticky; bottom: 0; padding: 12px 0 4px; background: var(--bg); margin-top: auto; }
.m-big { width: 100%; height: 52px; font-size: 17px; border-radius: 12px; }
.m-menu { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.m-who { margin: 0 0 8px; color: var(--muted); }
.m-menu-item { display: flex; align-items: center; min-height: 52px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--rule); background: var(--panel); color: var(--text); font: inherit; font-size: 16px; text-decoration: none; text-align: left; }
.m-menu-item.danger { color: var(--bad); }

/* Quick viewer: always on black (the film tokens), whatever the theme. */
.mv { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr); user-select: none; -webkit-user-select: none; background: #000; color: var(--film-text); overflow: hidden; }
.mv-top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 10px 8px; background: var(--film); }
.mv-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 0; background: none; color: var(--film-text); }
.mv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mv-title span { font-size: 13px; color: var(--film-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-stage { position: relative; min-height: 0; overflow: hidden; }
.mv-canvas { position: absolute; inset: 0; touch-action: none; }
.mv-corner { position: absolute; top: 8px; font-size: 12px; line-height: 1.5; color: #e6e6e6; pointer-events: none; text-shadow: 0 0 3px #000; }
.mv-tl { left: 10px; }
.mv-tr { right: 14px; text-align: right; }
.mv-scroll { position: absolute; right: 4px; top: 56px; bottom: 56px; width: 4px; border-radius: 2px; background: var(--film-rule); pointer-events: none; }
.mv-scroll span { position: absolute; left: 0; right: 0; height: 22px; margin-top: -11px; border-radius: 2px; background: var(--accent); }
.mv-hint { position: absolute; left: 0; right: 0; bottom: 8px; margin: 0; text-align: center; font-size: 12px; color: var(--film-muted); pointer-events: none; }
.mv-msg { padding: 24px 16px; margin: 0; }
.mv-over { position: absolute; left: 0; right: 0; top: 40%; text-align: center; }
.mv-tray { background: var(--film); padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 6px; }
.mv-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.mv-chip { flex: none; height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--film-rule); background: var(--film-panel); color: var(--film-text); font: inherit; font-size: 14px; }
.mv-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mv-series { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; }
.mv-thumb { flex: none; width: 74px; height: 74px; border-radius: 10px; border: 1px solid var(--film-rule); background: var(--film-panel); color: var(--film-text); font: inherit; font-size: 11px; padding: 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; }
.mv-thumb.on { border: 2px solid var(--accent); }
.mv-thumb img { width: 100%; height: 48px; object-fit: contain; background: #000; border-radius: 6px; }
.mv-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--film); border-top: 1px solid var(--film-rule); padding: 4px 4px max(10px, env(safe-area-inset-bottom)); }
.mv-bar button { min-height: 52px; border: 0; background: none; color: var(--film-text); font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.mv-bar button.on { color: var(--accent); font-weight: 700; }

/* Thin scrollbars in the theme's colours, everywhere (1.7.0). */
html, body, * { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }
