/* EngramCTX PWA — phone-first, huge tap targets, theme-aware.
   Palette tokens intentionally match the interim server Ask UI. */
/* Cortex R&D brand palette. Light is the primary (brand red on white); dark is a
   derived Cortex-dark (ink background, brightened red for contrast). */
/* THEMES (2026-07-22): appearance mode (auto/light/dark) + palette presets, both
   per-device preferences picked in the Account sheet (KTL-themes style). A tiny
   inline script in index.html stamps html[data-mode] (auto resolved against the
   system) and html[data-palette] BEFORE first paint, so tokens need no media
   queries. Mode blocks own the NEUTRALS (bg/panel/text/fields); palette blocks
   own the BRAND wash (accent, tinted controls, top-bar stops). Danger/ok/warn
   stay semantic and identical everywhere. */
:root {
  --bg: #1a1d21; --panel: #23272d; --panel2: #2b3037; --edge: #363c44;
  --text: #e8eaed; --muted: #a0a6ae; --accent: #e23653; --accent-ink: #fff;
  --cite: #33272b; --danger: #e23653; --danger-bg: #3a1f24;
  --ok: #4caf82; --warn: #d0912f; --crit: #e23653;
  /* Type-into FIELDS (inputs/textareas) read as neutral "paper" — distinct from
     the tinted click-me controls (buttons/selects) that keep the brand wash. */
  --field-bg: #191c20; --field-edge: #4a515a;
  /* Elevated (floating) surfaces — lighter than panels so sheets visibly lift. */
  --float: #2f3640; --float-edge: #4d5560;
  /* Border of clickable controls (buttons/selects) — tinted per palette. */
  --ctrl-edge: #c65454;
  /* Top-bar gradient stops (dark → light, left → right; mode-independent). */
  --bar-a: #c3a2aa; --bar-b: #b9bfc7; --bar-c: #eef1f5;
  --hover-wash: rgba(226, 54, 83, .07);
  color-scheme: dark; /* native widgets (date pickers, scrollbars) follow the theme */
  --tap: 36px; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-mode='light'] {
  color-scheme: light;
  --bg: #f6f7f9; --panel: #ffffff; --panel2: #fbeef1; --edge: #e4e6ea;
  --text: #1f2329; --muted: #4a5159; --accent: #c8102e; --accent-ink: #fff;
  --cite: #fae9ec; --danger: #9b0c24; --danger-bg: #fae9ec;
  --ok: #2e7d32; --warn: #b26a00; --crit: #c8102e;
  --field-bg: #ffffff; --field-edge: #ccd1d7;
  --float: #ffffff; --float-edge: #d9dce1;
  --hover-wash: rgba(200, 16, 46, .05);
}
/* ---- Palette presets (Cortex red is the :root default above) ---- */
:root[data-palette='morbern'] { --logo-hi: #86bce6; --logo-lo: #2f6da3; --logo-line: #4f9cd9; --accent: #4f9cd9; --accent-ink: #fff; --cite: #263140; --panel2: #2a3542;
  --ctrl-edge: #3e6a95; --bar-a: #9fb2c4; --bar-b: #b9bfc7; --bar-c: #eef1f5; --hover-wash: rgba(79, 156, 217, .08); }
:root[data-mode='light'][data-palette='morbern'] { --logo-hi: #5f97c4; --logo-lo: #083d66; --logo-line: #0b5086; --accent: #0b5086; --accent-ink: #fff; --cite: #e3edf6;
  --panel2: #eaf2f9; --ctrl-edge: #5c88b4; --hover-wash: rgba(11, 80, 134, .05); }
:root[data-palette='forest'] { --logo-hi: #7fd0a8; --logo-lo: #2a7a55; --logo-line: #43a877; --accent: #43a877; --accent-ink: #fff; --cite: #253530; --panel2: #2a3931;
  --ctrl-edge: #3c7a5c; --bar-a: #a4bfae; --bar-b: #b9c3bd; --bar-c: #eef4f0; --hover-wash: rgba(67, 168, 119, .08); }
:root[data-mode='light'][data-palette='forest'] { --logo-hi: #58b385; --logo-lo: #115c36; --logo-line: #1a7f4b; --accent: #1a7f4b; --accent-ink: #fff; --cite: #e0f0e8;
  --panel2: #e9f5ee; --ctrl-edge: #57a87d; --hover-wash: rgba(26, 127, 75, .05); }
:root[data-palette='amber'] { --logo-hi: #e8b866; --logo-lo: #9c6c1e; --logo-line: #d0912f; --accent: #d0912f; --accent-ink: #241a06; --cite: #342d1f; --panel2: #383023;
  --ctrl-edge: #8a6f3a; --bar-a: #c2b193; --bar-b: #c8c2b3; --bar-c: #f4f0e7; --hover-wash: rgba(208, 145, 47, .08); }
:root[data-mode='light'][data-palette='amber'] { --logo-hi: #d19440; --logo-lo: #7a4a00; --logo-line: #a86300; --accent: #a86300; --accent-ink: #fff; --cite: #f7ecd6;
  --panel2: #faf2e0; --ctrl-edge: #c09a54; --hover-wash: rgba(168, 99, 0, .05); }
:root[data-palette='plum'] { --logo-hi: #c9a4e8; --logo-lo: #7a55a8; --logo-line: #a678d6; --accent: #a678d6; --accent-ink: #fff; --cite: #2d2836; --panel2: #322b3c;
  --ctrl-edge: #6f4e8a; --bar-a: #b3a2c3; --bar-b: #bdb9c7; --bar-c: #f0eef5; --hover-wash: rgba(166, 120, 214, .08); }
:root[data-mode='light'][data-palette='plum'] { --logo-hi: #a06cc4; --logo-lo: #5c2f7a; --logo-line: #7a3fa0; --accent: #7a3fa0; --accent-ink: #fff; --cite: #eee3f6;
  --panel2: #f3ecf9; --ctrl-edge: #a678c8; --hover-wash: rgba(122, 63, 160, .05); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The hidden attribute must always win — component rules that set display:flex/grid
   would otherwise keep a [hidden] element visible (e.g. the Ask history panel). */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; min-height: 100dvh;
  overscroll-behavior-y: none;
}

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; gap: 12px;
  border-bottom: 1px solid var(--edge);
  /* Black→white left-to-right: the wordmark sits on the dark end, the colour Cortex
     logo on the light end so ALL its colours (incl. the dark brain/R&D) read. */
  background: linear-gradient(90deg, var(--bar-a) 0%, var(--bar-a) 48%, var(--bar-b) 82%, var(--bar-c) 100%);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.02em; }
.brand .name { color: #fff; }               /* on the dark (left) end of the header */
.brand .name .ctx { color: var(--accent); }
.brand .ver { color: #000000; font-size: 12px; font-weight: 600; letter-spacing: 0; margin-top: 6px; }
/* Slogan: beside the version on desktop; on phones the brand row wraps and it
   sits on its own line below the logo (header grows naturally). */
.brand .slogan { color: #33272b; font-size: 11.5px; font-style: italic; font-weight: 500; margin: 6px 0 0 8px; white-space: nowrap; }
@media (max-width: 719px) {
  .brand { flex-wrap: wrap; }
  .brand .slogan { flex-basis: 100%; margin: 0 0 0 2px; white-space: normal; }
}
/* Repo/context line — moved out of the crowded header to a slim strip on the left. */
.subbar { padding: 5px 16px 6px; background: var(--bg); font-size: 11.5px; }
.subbar .repo { color: var(--muted); font-weight: 500; }
/* Official Cortex R&D logo as the brand mark — color on a light bar, white on a
   dark bar. Shown at every size (no longer hidden on phones). */
.cortex-logo { height: 22px; width: auto; display: block; flex: 0 0 auto; }
/* Show the COLOUR (red) Cortex logo on all themes — Norm: not the white one on dark. */
.cortex-logo.light-only { display: block; }
.cortex-logo.dark-only { display: none; }
/* EngramCTX product mark (the diamond, gradient "Shine") — sits after the title.
   Theme-aware colours keep the gradient vivid on both light and dark top bars. */
.logo-mark { height: 32px; width: auto; display: block; flex: 0 0 auto; }
.logo-mark .lm-line { stroke: var(--logo-line); }
.logo-mark .lm-fill { fill: url(#lm-g); }
.logo-mark .lm-top { stop-color: var(--logo-hi); }
.logo-mark .lm-bot { stop-color: var(--logo-lo); }
:root { --logo-hi: #FF7D92; --logo-lo: #C8102E; --logo-line: #E23653; }
:root[data-mode='light'] { --logo-hi: #F26A82; --logo-lo: #9B0C24; --logo-line: #C8102E; }
.brand .name { font-size: 17px; }
.topbar-meta { color: var(--muted); font-size: 12px; text-align: right; }

/* ---- Main scroll area ---- */
/* Content width is a per-device preference (Account → Display width). */
body[data-width='wide'] .view { max-width: 1100px; }
body[data-width='full'] .view { max-width: none; }
/* Admin is a dense management console (hundreds of orgs/users) — give it the
   monitor regardless of the reading-width preference. */
.view:has(> .admin-page) { max-width: min(97vw, 1900px); }
/* On wide/full layouts, big primary action buttons (Ask, Review, Publish) stay a
   normal, centered size instead of stretching across the whole screen. */
body[data-width='wide'] .view button.btn.block.lg,
body[data-width='full'] .view button.btn.block.lg { max-width: 260px; margin-left: auto; margin-right: auto; display: block; }
/* …and every other control keeps a comfortable intrinsic size, left-aligned with
   its label: text entry may use the width (that's the point of wide/full), but a
   dropdown, segmented picker, or button spanning a whole monitor reads as a
   banner, not a control. */
body[data-width='wide'] .view input[type=text],
body[data-width='wide'] .view input[type=email],
body[data-width='wide'] .view input[type=password],
body[data-width='full'] .view input[type=text],
body[data-width='full'] .view input[type=email],
body[data-width='full'] .view input[type=password] { max-width: 760px; }
body[data-width='wide'] .view select,
body[data-width='full'] .view select { max-width: 420px; }
body[data-width='wide'] .view .seg,
body[data-width='full'] .view .seg { max-width: 480px; }
body[data-width='wide'] .view button.btn.block:not(.lg),
body[data-width='full'] .view button.btn.block:not(.lg) { width: auto; min-width: 280px; }
body[data-width='wide'] .view .btn-row > .btn,
body[data-width='wide'] .view .cap-actions .btn,
body[data-width='full'] .view .btn-row > .btn,
body[data-width='full'] .view .cap-actions .btn { flex: 0 1 auto; min-width: 180px; }
/* Side-by-side field pairs (Domain | Type) stay adjacent instead of splitting
   to opposite ends of a wide monitor. */
body[data-width='wide'] .view .field-cols,
body[data-width='full'] .view .field-cols { max-width: 860px; }
.view {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px 24px;
  overflow-y: auto;
}

/* ---- Bottom mode switcher ---- */
/* Full-width footer bar, but the buttons cluster to the same 720px column as the
   content (each capped at 240px = 720/3) so they don't spread edge-to-edge on a
   wide screen; on a phone they flex to fill as before. */
.modes {
  display: flex; justify-content: center; border-top: 1px solid var(--edge); background: var(--panel);
  padding-bottom: var(--safe-b); position: sticky; bottom: 0; z-index: 5;
}
.mode {
  position: relative;
  flex: 1 1 0; max-width: 240px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 11px 4px; font: inherit; min-height: var(--tap);
}
/* Colour icons (no grayscale) read livelier than the old dulled-out set. */
.mode .mi { font-size: 25px; line-height: 1; opacity: .9; transition: opacity .12s, transform .12s; }
.mode .ml { font-size: 12px; font-weight: 700; letter-spacing: .01em; }
.mode:hover .mi { opacity: 1; transform: translateY(-1px); }
.mode[aria-selected="true"] { color: var(--accent); }
.mode[aria-selected="true"] .mi { opacity: 1; }
/* Always-visible red underline under the active mode. */
.mode[aria-selected="true"]::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%); bottom: 3px;
  width: 30px; height: 3px; border-radius: 3px; background: var(--accent);
}

/* ---- Generic building blocks ---- */
.card {
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px;
}
.card.err { border-color: var(--danger); background: var(--danger-bg); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
/* Prepared live-command card (IoT reboot/halt…): accent while awaiting the tap,
   then settles into its outcome state. */
.card.confirm { border-color: var(--accent); }
.card.confirm .fb-row { margin-top: 10px; }
.card.confirm.ok { border-color: var(--ok, #3a9d5d); }
.card.confirm.off { color: var(--muted); border-color: var(--edge); }
.btn.confirm-go { border-color: var(--accent); font-weight: 600; }
h2.title { font-size: 23px; margin: 2px 0 6px; letter-spacing: -0.02em; }
h2.title::after { content: ''; display: block; width: 46px; height: 3px; border-radius: 2px;
  background: var(--accent); margin-top: 5px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
/* Title + round action button (?, 🕘) row, with a clear gap before whatever follows. */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 14px; }
.help-btn { min-width: 34px; min-height: 34px; padding: 4px 10px; font-size: 16px; font-weight: 700; flex: 0 0 auto; }
/* div.field: same look for fields that hold buttons (a <label> would steal their clicks). */
label.field, div.field { display: block; margin: 0 0 10px; }
label.field > .lab, div.field > .lab { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
label.field > .hint, div.field > .hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
div.field > p.hint { font-size: 13px; margin: 6px 0 0; }

/* Inputs keep 16px font (below that iOS zooms on focus) — height comes down via padding. */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], textarea {
  width: 100%; padding: 7px 12px; font: inherit; color: var(--text);
  background: var(--field-bg); border: 2px solid var(--field-edge); border-radius: 10px;
}
select {
  width: 100%; padding: 7px 12px; font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--ctrl-edge); border-radius: 10px;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
textarea.big { min-height: 30vh; }
/* Auto-grown fields fit their content (JS sets height); page scrolls as one. */
textarea.grow { overflow-y: hidden; resize: none; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* ---- Buttons ---- */
button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--ctrl-edge); border-radius: 10px;
}
button.btn.block { width: 100%; }
button.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--ctrl-edge); font-weight: 600; }
button.btn.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); font-weight: 600; }
button.btn.lg { min-height: 46px; font-size: 15.5px; border-radius: 14px; }
button.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ---- Capture input picker ---- */
/* All capture methods on ONE row, whatever the count (3 without media, 4 with). */
.picker { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 0 0 16px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 4px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: var(--radius); color: var(--text); cursor: pointer; font: inherit; min-height: 84px;
}
.pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick .pi { font-size: 26px; }
.pick .pl { font-size: 13px; font-weight: 600; }

/* Recording UI */
.rec { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0 4px; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 38px; display: grid; place-items: center;
  box-shadow: 0 6px 22px rgba(79,156,247,.35);
}
.rec-btn.on { background: var(--danger); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(224,83,61,.45);} 50%{ box-shadow: 0 0 0 18px rgba(224,83,61,0);} }
.rec-time { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; letter-spacing: .04em; }
.rec-controls { display: flex; gap: 10px; }
.rec-controls .btn { min-width: 120px; }
.rec-hint { color: var(--muted); font-size: 13px; text-align: center; }

/* ---- Chips (tags / related / access) ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--cite); border: 1px solid var(--edge); border-radius: 999px; font-size: 14px;
}
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
.chip.pick-chip { cursor: pointer; }
/* Selected chips must read at a glance (Norm 2026-07-25: outline-only was too
   easy to miss) — filled accent + a leading ✓ on pickable ones. */
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .hint { color: rgba(255, 255, 255, .85); }
.chip.pick-chip.on::before { content: '✓'; font-weight: 700; }
.chip-input { flex: 1; min-width: 120px; border: 0; background: none; padding: 8px 4px; }
.chip-input:focus { outline: none; }

/* ---- Segmented control (importance / type) ---- */
.seg { display: flex; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 36px; background: var(--panel2); border: 0; border-left: 1px solid var(--edge);
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
/* info = neutral (it's the default, low-severity state) — not accent red, which
   reads as critical. warning = amber, critical = red. Warning uses the BRIGHT
   banner orange, not --warn (that amber read dull/dark as a selected button). */
.seg.imp button[aria-pressed="true"][data-v="info"] { background: var(--muted); color: var(--panel); }
.seg.imp button[aria-pressed="true"][data-v="warning"] { background: #ffa733; color: #241a06; }
.seg.imp button[aria-pressed="true"][data-v="critical"] { background: var(--crit); color: #fff; }

/* ---- Stage stepper ---- */
.steps { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.steps .s { display: inline-flex; align-items: center; gap: 5px; }
.steps .s.on { color: var(--accent); font-weight: 700; }
.steps .s .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor;
  display: grid; place-items: center; font-size: 11px; }
.steps .s.done .dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.steps .arr { color: var(--edge); }

/* ---- Lists (browse / staged) ---- */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--edge); }
.row:last-child { border-bottom: 0; }
.row .g { flex: 1; min-width: 0; }
.row .g .rt { font-weight: 650; }
.row .g .rd { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--cite); color: var(--muted); }
/* Importance = passive label, no pill/background (so it doesn't read as clickable),
   coloured by severity. */
.badge.info, .badge.warning, .badge.critical {
  background: none; padding: 0; text-transform: uppercase; letter-spacing: .05em; pointer-events: none;
}
.badge.info { color: var(--muted); }
.badge.warning { color: var(--warn); }
.badge.critical { color: var(--crit); }
/* Media count = filled accent pill so it stands out at a glance on a row. */
.badge.media { background: var(--panel2); color: var(--accent); white-space: nowrap; }
/* Browse attribution (created date + author) — compact right-side stack. */
.note-attr { color: var(--muted); font-size: 11px; line-height: 1.35; text-align: right;
  white-space: nowrap; flex: 0 0 auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .ei { font-size: 40px; opacity: .5; }
.browse-h { font-size: 13.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; margin: 18px 0 6px; }
.browse-controls { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
/* Magnifier floats to the left of the input — no box of its own. */
.browse-controls .si { color: var(--muted); font-size: 18px; flex: 0 0 auto; }
.msearch { flex: 1; min-height: 36px; }
.msort { width: auto; min-height: 36px; flex: 0 0 auto; }
/* Phones: the two selects starved the search box to a sliver (S23, 2026-08-05) —
   wrap to two lines: 🔎 + search full-width on top, the selects sharing line 2.
   The 60% basis guarantees the selects can never fit beside the search. */
@media (max-width: 640px) {
  .browse-controls { flex-wrap: wrap; }
  .browse-controls .si { order: 1; }
  .browse-controls .msearch { order: 2; flex: 1 1 60%; min-width: 0; }
  .browse-controls #mtopic { order: 3; flex: 1 1 45%; min-width: 0; }
  .browse-controls #msort { order: 4; flex: 1 1 45%; min-width: 0; }
}

/* Learn-from-fixes banner */
.learn { border-color: var(--accent); }
.learn-h { font-weight: 700; margin: 0 0 2px; }
.learn-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--edge); }
.learn-rule { font-size: 15px; }
.learn-rule b { font-weight: 700; }
.learn-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.learn-add { min-height: 38px; padding: 6px 16px; }
.learn-dismiss { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; }
.topic-lab { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--accent);
  text-transform: capitalize; margin: 0 0 4px; }

/* ---- Ask ---- */
.ask-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 14px; }
.hist-toggle { min-height: 40px; min-width: 46px; padding: 8px 12px; font-size: 18px; }
/* Active state must survive EMOJI buttons — text color doesn't tint emoji
   glyphs, so the accent border alone was invisible (Norm 2026-07-30). A washed
   accent fill + double border reads clearly in both themes. */
.hist-toggle.on { border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: inset 0 0 0 1px var(--accent); }
.histlist { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 8px; }
.hist-item { text-align: left; background: none; border: 0; color: var(--text); font: inherit;
  line-height: 1.3; padding: 4px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item:active, .hist-item:hover { background: var(--cite); }
.hist-row { display: flex; align-items: stretch; gap: 2px; border-radius: 8px; }
/* Whole-ROW hover highlight: hovering the 🗑 must light up exactly the entry it
   would delete (a lone per-button highlight made wrong-row deletes too easy).
   One UNIFORM strong wash across the full row — child buttons' own hover
   backgrounds are suppressed so nothing patches brighter than the rest. */
.hist-row:hover { background: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: inset 3px 0 0 var(--accent); }
.hist-row .hist-item:hover, .hist-row .hist-item:active,
.hist-row .hist-del:hover, .hist-row .hist-del:active { background: none; }
.hist-row .hist-item { flex: 1; min-width: 0; }
.hist-row .hist-ts { align-self: center; font-size: 11px; color: var(--muted); white-space: nowrap; padding-left: 6px; }
.hist-del { background: none; border: 0; cursor: pointer; padding: 0 10px; border-radius: 8px;
  font-size: 15px; opacity: .85; }
.hist-del:active, .hist-del:hover { opacity: 1; background: var(--danger-bg); }
.hist-clear { color: var(--danger); font-size: 13px; font-weight: 600; border-top: 1px solid var(--edge); border-radius: 0; }
.hist-clear:active, .hist-clear:hover { background: var(--danger-bg); }
.hist-empty { color: var(--muted); font-size: 13px; padding: 8px 12px; }
.asked { font-weight: 650; color: var(--text); margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--accent); }
/* 🔊 read-aloud — floats top-right of the answer card (visible, out of the text flow). */
.card.answer { position: relative; }
.speak-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--panel2); color: var(--text); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0; opacity: .92; z-index: 1; }
.speak-btn:hover { border-color: var(--accent); opacity: 1; }
.speak-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
/* 🎤 dictation — bottom-right inside the Ask textarea. */
.field { position: relative; }
.mic-btn { position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--panel2); color: var(--text); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0; opacity: .92; }
.mic-btn:hover { border-color: var(--accent); opacity: 1; }
.mic-btn.rec-on { border-color: var(--danger); background: var(--danger-bg); animation: micpulse 1.2s infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 30%, transparent); } }
.answer p { margin: 0 0 10px; } .answer > :last-child { margin-bottom: 0; }
.answer h4 { margin: 14px 0 6px; font-size: 15px; }
.answer ol, .answer ul { margin: 0 0 10px; padding-left: 22px; } .answer li { margin: 0 0 8px; }
.answer a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.answer a:active, .answer a:hover { border-bottom-color: var(--accent); }
/* Secondary "open in a new tab" affordance beside WIP links (main link reuses one tab). */
.answer a.newtab { font-size: 12px; margin-left: 3px; opacity: .55; border-bottom: none; }
.answer a.newtab:active, .answer a.newtab:hover { opacity: 1; }
.answer code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
  background: var(--cite); border: 1px solid var(--edge); border-radius: 5px; padding: 1px 5px; }
.answer pre.code { background: var(--cite); border: 1px solid var(--edge); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; white-space: pre; }
.answer pre.code code { background: none; border: 0; padding: 0; }
.tbl-wrap { overflow-x: auto; margin: 0 0 10px; }
.md-table { border-collapse: collapse; font-size: 13px; min-width: 60%; }
.md-table th, .md-table td { border: 1px solid var(--edge); padding: 6px 10px; text-align: left; white-space: nowrap; }
.md-table th { background: var(--cite); font-weight: 650; }
/* "Was this useful?" feedback block under a finished answer — thumbs row, then
   (after a 👎) the comment input and its buttons stacked on their own lines. */
.fb { margin: 8px 2px 0; color: var(--muted); font-size: 13px; display: grid; gap: 8px; justify-items: start; }
.fb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-btn { background: var(--panel2); border: 1px solid var(--edge); border-radius: 8px;
  padding: 4px 12px; font-size: 15px; cursor: pointer; }
.fb-btn:hover, .fb-btn:active { border-color: var(--accent); }
.fb-btn.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.fb input { width: 100%; }

/* "Process" (working notes between tool calls) — behind the 👁 toggle */
.think-bar { margin: 0 0 8px; }
.think-toggle { font-size: 12px; min-height: 32px; padding: 4px 10px; color: var(--muted); }
.card.think { opacity: .75; font-size: 13px; border-style: dashed; margin-bottom: 8px; }
.think-tool { margin-top: 8px; color: var(--muted); font-size: 12px; }

.sources { margin-top: 14px; }
.sources h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.src { display: inline-block; background: var(--cite); border: 1px solid var(--edge);
  border-radius: 8px; padding: 5px 10px; margin: 0 6px 6px 0; font-size: 13px; }
a.src-link { color: var(--text); text-decoration: none; cursor: pointer; }
a.src-link:hover, a.src-link:active { border-color: var(--accent); }
.vids video.vid { display: block; width: 100%; max-width: 640px; border-radius: 10px;
  border: 1px solid var(--edge); margin: 2px 0 10px; background: #000; }
button.vid-pill { font: inherit; color: var(--text); cursor: pointer; }
button.vid-pill:hover { border-color: var(--accent); }

/* ---- Ribbon / toast / spinner ---- */
.ribbon { padding: 8px 16px; font-size: 13px; text-align: center; font-weight: 600;
  background: var(--warn); color: #241a06; }
.ribbon.push { background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px; }
.ribbon .rbtn { background: rgba(255,255,255,.25); border: 0; color: inherit; font: inherit;
  font-weight: 700; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
/* Offline mode: network-only affordances (Ask/Admin tabs, Read-text) gray out as
   a group; capture + dictate + attach + queue stay fully usable. */
body.offline [data-net] { opacity: .4; pointer-events: none; filter: grayscale(1); }
/* The offline/no-internet banner must be unmissable AND readable: bright orange
   with near-black text in both themes (the theme --warn ambers are too dark),
   and a big status icon. */
.ribbon.off { font-size: 14.5px; padding: 12px 18px; line-height: 1.45;
  background: #ffa733; color: #241a06;
  display: flex; align-items: center; justify-content: center; gap: 10px; }
.ribbon.off .ribbon-ico { font-size: 26px; line-height: 1; flex: 0 0 auto; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(78px + var(--safe-b));
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 90; max-width: 90vw; text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.toast { transition: opacity 3s linear; }
.toast.fading { opacity: 0; }
.toast.err { background: var(--danger); color: #fff; }
/* Errors are FOREGROUND: the page (dialogs included) dims behind them until OK. */
.toast-back { position: fixed; inset: 0; z-index: 89; background: rgba(0, 0, 0, .55); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%; animation: r .7s linear infinite; vertical-align: -3px; }
@keyframes r { to { transform: rotate(360deg); } }
.center-load { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- Media attachments (Phase 2): kept-media strips, note gallery ---- */
.keep-toggle { display: flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: 14px; margin: 2px 0 10px; cursor: pointer; }
.keep-toggle input { width: 18px; height: 18px; }
/* Attach-media menu (Type mode). The header differentiates it from the capture
   tabs: these files are KEPT with the note, not read/transcribed. */
.att-sheet { border: 1px solid var(--edge); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.att-sheet-h { margin: 0 0 10px; font-size: 13px; color: var(--text); line-height: 1.4; }
.att-sheet-h .hint { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.att-choices { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.att-choices .btn { padding: 8px 6px; font-size: 13px; }
/* The choices are <label for=…> (native file-picker activation), so give them the
   ghost-button look button.btn selectors don't reach. */
.att-choices label.btn, .cap-grid label.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 8px 6px; font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; background: var(--panel2); color: var(--text);
  border: 1px solid var(--ctrl-edge); border-radius: 10px; text-align: center;
}
@media (max-width: 460px) { .att-choices { grid-template-columns: 1fr; } }
.kept-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.kept-item { position: relative; width: 96px; height: 96px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--edge); background: var(--panel2); }
.kept-item img, .kept-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.kept-x { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; }
.kept-pill { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,.6); color: #fff; padding: 2px 6px; border-radius: 999px; }
.note-media { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.note-fig { margin: 0; max-width: 100%; }
.note-media img, .note-media video { max-width: 100%; width: auto; max-height: 60vh;
  border-radius: 12px; border: 1px solid var(--edge); background: var(--panel2); display: block; }
.note-fig figcaption { color: var(--muted); font-size: 13px; margin-top: 6px; }
.note-media img[data-full] { cursor: zoom-in; }
.card.interview { border-color: var(--accent); }

/* Full-screen in-app media viewer (photos stay in the PWA, fit to screen) */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center; padding: 12px; }
.lb-media { max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lb-media img, .lb-media video { max-width: 100%; max-height: 100vh; width: auto; height: auto;
  object-fit: contain; border-radius: 8px; will-change: transform; }
.lb-media img { touch-action: none; }
.lb-x { position: fixed; top: calc(10px + var(--safe-t)); right: 14px; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 20px;
  cursor: pointer; display: grid; place-items: center; z-index: 51; }

/* Help / tips sheet (guidance kept off the main screen; opened by the ? button).
   Phones: bottom sheet (thumb reach). Wide screens: centered dialog, fully rounded
   so the end of the card is visible (bottom-pinned looked cropped on desktop). */
.sheet { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.62);
  display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 640px; max-height: 85dvh; overflow-y: auto;
  box-shadow: 0 22px 70px rgba(0,0,0,.55);
  background: var(--float); border: 1px solid var(--float-edge); border-radius: 16px 16px 0 0;
  padding: 16px 18px calc(20px + var(--safe-b)); }
@media (min-width: 720px) {
  .sheet { align-items: center; padding: 28px; }
  .sheet-card { border-radius: 16px; max-height: 80dvh; padding-bottom: 20px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 6px; }
.sheet-head h3 { margin: 0; font-size: 19px; letter-spacing: -0.01em; color: var(--accent); }
.sheet-x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.sheet-body { color: var(--text); font-size: 14px; line-height: 1.55; }
/* Sheets never scroll sideways — edge decorations (e.g. the trim time bubble at
   the far right) must not summon a horizontal scrollbar. clip ≠ hidden: no new
   scroll container is created. */
.sheet-card { overflow-x: clip; }
.sheet-body p { margin: 0 0 10px; }
.sheet-body p:last-child { margin-bottom: 0; }

/* ---- Account control (top bar) ---- */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.acct-btn { background: none; border: 0; line-height: 1; padding: 4px 8px; cursor: pointer; border-radius: 999px; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.acct-btn svg { width: 24px; height: 24px; display: block; }
.acct-btn:active { background: var(--panel2); }
/* Switched-account (impersonation) indicator — you're working as someone else. */
.acct-btn.impersonating { outline: 2px solid #e08600; outline-offset: 1px; background: #e0860022; }
.acct-name { font-size: 13px; font-weight: 600; color: var(--accent); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Switched sessions show both identities ("Norm ▸ Guy") — give the pair room. */
.impersonating .acct-name { max-width: 300px; }
@media (max-width: 480px) { .acct-name { display: none; } } /* phone: icon only */

/* ---- Auth (login / signup) — whole app behind this when signed out ---- */
.signed-out .modes, .signed-out .subbar, .signed-out #acct { display: none !important; }
.auth-wrap { display: flex; justify-content: center; padding: 12px 0 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-title { font-size: 22px; margin: 6px 0 2px; letter-spacing: -0.02em; }
.auth-form { margin-top: 14px; }
/* Comfortable, tappable login fields (a touch taller than the app default). */
.auth-form input { padding: 15px 16px; min-height: 52px; border-radius: 12px; }
.auth-form .field { margin-bottom: 16px; }
/* Social sign-in: each provider a full-width stacked button with its brand logo.
   (The .btn styles are scoped to <button>, so these <a>s are styled on their own.) */
a.social {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 52px; margin-top: 10px; padding: 12px 16px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--ctrl-edge);
  border-radius: 12px; font-weight: 600; text-decoration: none;
}
a.social:active { background: var(--cite); }
.social .prov-logo { width: 20px; height: 20px; flex: 0 0 auto; }
.auth-msg { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; margin: 2px 0 12px; }
.auth-msg.err { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
/* Status notice (e.g. "awaiting admin approval") — must not be missable: no quiet
   pill, just big bold dark-pink text. */
.auth-msg.info { background: none; border: 0; padding: 8px 0; text-align: center;
  font-size: 17px; font-weight: 700; color: #f48caf; }
:root[data-mode='light'] .auth-msg.info { color: #b0175a; }
.auth-or { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; border-top: 1px solid var(--edge); }
.auth-or span { padding: 0 10px; }
a.social { margin-top: 8px; text-align: center; }
.auth-toggle { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 18px; }
.auth-toggle a { color: var(--accent); font-weight: 600; }

/* Theme palette swatches (Account → Appearance) — KTL-presets style. */
.pal-row { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.pal-chip { width: 38px; height: 38px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--edge); }
.pal-chip.on { outline: 3px solid var(--text); outline-offset: 2px; }

/* Browse footer — "indexed for Ask" pill grid. */
.idx-foot { margin-top: 22px; text-align: center; }
.idx-title { color: var(--muted); font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.idx-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 720px; margin: 0 auto; }
.idx-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 999px;
  font-size: 12px; color: var(--text); }
.idx-pill .idx-n { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.idx-pill.zero { opacity: .45; }
.idx-pill.zero .idx-n { color: var(--muted); font-weight: 600; }
.idx-pill.live { border-color: var(--accent); color: var(--accent); font-weight: 650; }

/* Starter questions (Ask 💡) — inline card on phones; floats beside the content
   column on wide screens so the answer area stays clear. */
.starter { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 12px; margin-top: 14px; }
.starter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.starter-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 6px; }
.starter-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.starter-q { display: block; width: 100%; text-align: left; margin: 0 0 6px; padding: 8px 10px;
  background: var(--panel2); border: 1px solid var(--ctrl-edge); border-radius: 10px;
  color: var(--text); cursor: pointer; font: inherit; font-size: 13.5px; line-height: 1.35; }
.starter-q:hover { border-color: var(--accent); color: var(--accent); }
.starter-q:last-child { margin-bottom: 0; }
@media (min-width: 1200px) {
  .starter { position: fixed; right: 24px; top: 120px; width: 300px; margin-top: 0;
    box-shadow: var(--float, 0 12px 32px rgba(0,0,0,.18)); z-index: 4; }
}

/* Language picker (Account → Language) — Amazon-style radios, side by side. */
.lang-pick { display: flex; gap: 22px; margin-top: 4px; flex-wrap: wrap; }
.lang-opt { display: flex; align-items: center; gap: 10px; padding: 6px 4px; cursor: pointer; font-size: 14px; }
.lang-opt input[type=radio] { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; cursor: pointer; }
.lang-opt:has(input:checked) span { color: var(--accent); font-weight: 650; }

/* Pill-choice control (Account → Display width). Deliberately NOT `.seg`:
   that class is the capture importance/type control (joined, overflow:hidden)
   and sharing the name clipped these pills' corners ("cropped" buttons). */
.seg-pills { display: flex; gap: 6px; margin-top: 4px; }
.seg-pills button { flex: 1; padding: 8px 6px; font-size: 13px; color: var(--text); cursor: pointer;
  background: var(--panel2); border: 1px solid var(--edge); border-radius: 8px; }
.seg-pills button.on { border-color: var(--accent); color: var(--accent); font-weight: 650; }

/* ---- Admin ---- */
.admin-sec { margin: 0 0 14px; padding: 0 0 12px; border-bottom: 1px solid var(--edge); }
.admin-sec:last-child { border-bottom: 0; }
/* Account sheet: each setting group is its own framed card on an inset
   background (--bg reads as "recessed" against the sheet's --float in BOTH
   themes), with a titled header rule. The sheet had grown to nine stacked
   groups separated only by hairlines — Norm, 2026-07-30: "a bunch of stuff
   bundled together". */
.sheet .acct-sec {
  background: var(--bg); border: 1px solid var(--edge); border-radius: 12px;
  padding: 12px 14px 14px; margin: 0 0 14px;
}
.sheet .acct-sec > .lab {
  display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text); opacity: .92;
  padding: 0 0 7px; margin: 0 0 11px; border-bottom: 1px solid var(--edge);
}
/* The group's own hint sits quieter than its controls. */
.sheet .acct-sec > .hint { display: block; margin-top: 9px; }
/* Live app accounts: several apps live in ONE group, so each gets its own
   divider and header — three flat blocks read as one wall otherwise. */
.sheet .liveapp + .liveapp { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--edge); }
.sheet .liveapp-name { font-weight: 600; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; }
.sheet .liveapp-name .chip.on { background: var(--hover-wash); border-color: var(--accent); color: var(--accent);
  font-size: 11px; padding: 0 6px; border-radius: 999px; border-width: 1px; border-style: solid; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2);
  border: 1px solid var(--edge); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip-x { background: none; border: 0; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
/* Admin hub tabs (#admin/users, #admin/tenants, …) */
/* overflow-y must be explicit: overflow-x:auto alone computes overflow-y to auto
   too, and a 1-2px vertical overflow paints a stray mini-scrollbar on Windows. */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--edge); margin: 4px 0 14px; overflow-x: auto; overflow-y: hidden; }
.atab { border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px 10px; cursor: pointer; white-space: nowrap; position: relative; }
.atab.on { color: var(--ink); }
.atab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px;
  border-radius: 2px; background: var(--accent); }
/* Filter rows stay compact: a search box holds a few letters, not a sentence. */
.admin-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.admin-filters input[type="search"] { flex: 0 1 240px; }
.admin-filters select { flex: 0 1 190px; }
.admin-filters input[type="date"] { flex: 0 1 175px; width: auto; }
.chip.warn { background: #f5d789; color: #241a06; }
.tenant-card { margin: 0 0 10px; }
.tenant-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.tenant-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.tenant-row .lab { min-width: 120px; }
.tenant-row .t-name { flex: 0 1 220px; }
.t-logo-img { height: 24px; max-width: 90px; object-fit: contain; border-radius: 4px; }
/* Guidance under a form — verbose placeholders moved here (they cropped in the inputs). */
.form-hint { display: block; font-style: italic; color: var(--muted); font-size: 12.5px;
  line-height: 1.5; margin-top: 6px; }
/* Buttons that aren't actionable yet (missing/invalid fields, or mid-operation). */
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* Error toasts persist until dismissed — the OK button is the only way they close. */
.toast .toast-ok { margin-left: 12px; padding: 4px 16px; border: 1.5px solid currentColor;
  border-radius: 8px; background: none; color: inherit; font: inherit; font-weight: 700;
  cursor: pointer; vertical-align: middle; }
/* "Create the repo first" helper in the GitHub connect sheet (production mode). */
.gh-create { margin-top: 12px; }
.gh-cmd { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gh-cmd code { flex: 1; padding: 8px 10px; background: var(--cite);
  border: 1px solid var(--edge); border-radius: 8px; font-size: 13px; overflow-x: auto;
  white-space: nowrap; }
/* Connect sheet: fixed 1000px; the ? shows the field guide as a right pane inside
   it (never covering the form); the guide stacks below the form on narrow screens. */
.sheet-card.gh-card { max-width: 1000px; }
.gh-cols { display: flex; gap: 22px; align-items: flex-start; }
.gh-main { flex: 1 1 0; min-width: 0; }
.gh-side { flex: 0 0 360px; border-left: 1px solid var(--edge); padding-left: 18px;
  font-size: 13.5px; line-height: 1.55; }
.gh-side p { margin: 0 0 8px; }
@media (max-width: 900px) {
  .gh-cols { flex-direction: column; }
  .gh-side { flex: 1 1 auto; border-left: 0; padding-left: 0; border-top: 1px solid var(--edge); padding-top: 12px; }
}

/* Organization badge in the top bar (name + optional logo, set in Admin → Organizations) */
.org-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-weight: 600; font-size: 13px; margin-left: 2px; }
.org-badge img { height: 22px; max-width: 90px; object-fit: contain; border-radius: 4px; }
@media (max-width: 520px) { .org-badge { display: none; } }

.dom-add, .admin-new { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dom-add input { flex: 1; min-width: 150px; }
.admin-new input, .admin-new select { flex: 1; min-width: 130px; }
.user-row { padding: 12px 0; border-bottom: 1px solid var(--edge); }
.user-row:last-child { border-bottom: 0; }
.user-main { display: flex; flex-direction: column; }
.user-email { font-weight: 600; }
.user-name { color: var(--muted); font-size: 13px; }
.user-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: flex-end; }
/* Captioned control: tiny label above each select so row fields are identified. */
.uc { display: flex; flex-direction: column; gap: 3px; flex: 1 1 110px; min-width: 110px; }
.uc > span { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding-left: 2px; }
.uc select { width: 100%; }
.uc .chip { align-self: flex-start; }
/* Checkbox cell: the box belongs BESIDE its label, sized like a checkbox — the
   column layout stretched it full-width and it floated centred under the label,
   out of line with the text fields beside it (Norm, 2026-07-30). */
.uc.uc-check { flex-direction: row; align-items: center; gap: 8px; justify-content: flex-start; }
.uc.uc-check input[type="checkbox"] { width: 17px; height: 17px; flex: 0 0 auto; margin: 0; }
.uc.uc-check > span { margin: 0; }
.user-controls .u-del { flex: 0 0 auto; min-width: 46px; }
/* Desktop users grid (IoT-dashboard style): read-only rows, click (or ✎) opens the
   edit sheet; headers sort. Phones keep the stacked .user-row cards. */
.ugrid-wrap { overflow-x: auto; }
.ugrid { width: 100%; border-collapse: collapse; font-size: 14px; }
.ugrid th { text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--edge);
  cursor: pointer; user-select: none; white-space: nowrap; }
.ugrid td { padding: 10px; border-bottom: 1px solid var(--edge); }
.ugrid tbody tr { cursor: pointer; }
.ugrid tbody tr:hover { background: var(--hover-wash); }
/* Informational rows (incoming shares) — nothing happens on click, so no
   pointer affordance and no hover wash. */
.ugrid tbody tr.row-inert { cursor: default; }
.ugrid tbody tr.row-inert:hover { background: none; }
.ugrid .u-edit { color: var(--accent); font-size: 15px; }
/* Bulk selection (Users grid): checkbox column + the action bar above the grid. */
.ugrid .u-check { width: 34px; text-align: center; }
.ugrid input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); }
.bulkbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px;
  margin: 0 0 10px; background: var(--cite); border: 1px solid var(--accent); border-radius: 12px; }
.bulkbar .bulk-count { flex: 0 0 auto; font-size: 14px; }
.bulkbar .chips { flex: 1 1 260px; }
.bulkbar .bulk-actions { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; }
.bulkbar .btn { min-height: 40px; padding: 8px 14px; }
/* Usage stats view: overview tiles + pager row. */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-tile { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 12px 10px; text-align: center; }
.stat-tile .stat-v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); }
.stat-tile .stat-l { color: var(--muted); font-size: 12px; margin-top: 2px; }
/* Ask multi-turn: earlier exchanges of the conversation, collapsed above the
   current answer; the question line is the <summary>. */
.prior { margin: 0 0 8px; border-left: 3px solid var(--edge); padding: 4px 12px; }
.prior summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.prior[open] summary { color: var(--text); }
.prior .prior-a { margin-top: 6px; }
/* 🕘 panel: section header for the server-fed conversation archive. */
.hist-head { font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 6px 4px;
  border-top: 1px solid var(--edge); margin-top: 8px; }
/* Ask: photos from cited notes render under the answer (tap = full size). */
.ans-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ans-img { max-height: 160px; max-width: 240px; border-radius: 10px;
  border: 1px solid var(--edge); display: block; }
/* Capacity meter (Storage tab): fill = severity token (--sev: ok/warn/crit),
   track = same hue washed so the state tints the whole bar in both themes. */
.stat-tile .stat-m { height: 6px; border-radius: 3px; margin: 8px 6px 2px;
  background: color-mix(in srgb, var(--sev) 20%, transparent); }
.stat-tile .stat-m > i { display: block; height: 100%; width: var(--pct);
  min-width: 4px; background: var(--sev); border-radius: 3px; }
.uq-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.uq-pager .btn { min-height: 40px; padding: 8px 16px; }
/* Personal quota rows ("Your space"): desktop = label | meter | text in one line;
   phones put label + value on one line and drop the meter to its own full-width
   line — the three-column layout crammed the text into a sliver (S23, 2026-08-05). */
.ps-row { display: grid; grid-template-columns: 110px minmax(120px, 240px) 1fr; gap: 12px; align-items: center; }
@media (max-width: 640px) {
  .ps-row { grid-template-columns: auto 1fr; gap: 4px 12px; }
  .ps-row .ps-label { grid-row: 1; grid-column: 1; }
  .ps-row .ps-text { grid-row: 1; grid-column: 2; text-align: right; }
  .ps-row .ps-meter { grid-row: 2; grid-column: 1 / -1; }
}
/* Browse rows all navigate somewhere — say so with the cursor. */
#drafts .row, #propsWrap .row, #mlist .row { cursor: pointer; }
/* Brand block opens the About sheet. */
.brand { cursor: pointer; }
/* About sheet (brand click): centered, the product mark big, Cortex credit. */
.about { text-align: center; padding: 6px 0 2px; }
.about .logo-mark { height: 84px; margin: 0 auto 6px; }
.about .about-name { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.about .about-name .ctx { color: var(--accent); }
.about .about-ver { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.about .about-slogan { font-style: italic; color: var(--muted); margin: 0 0 14px; }
.about .about-line { margin: 4px 0; font-size: 14.5px; }
.about .about-cortex { display: inline-flex; align-items: center; gap: 9px; margin-top: 12px;
  color: var(--text); text-decoration: none; font-weight: 600; }
.about .about-cortex img { height: 30px; }
.about .about-cortex:hover { color: var(--accent); }
:root[data-mode='light'] .about-cortex .logo-dark { display: none; }
:root:not([data-mode='light']) .about-cortex .logo-light { display: none; }
/* Edit-user sheet: two-column field grid */
.usheet { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.usheet .uc { min-width: 0; }
/* An organization with zero users stands out — delete it or staff it, never unnoticed. */
.ugrid tr.org-empty td { background: color-mix(in srgb, var(--warn) 9%, transparent); }
@media (max-width: 480px) { .usheet { grid-template-columns: 1fr; } }
.user-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* In-app camera (getUserMedia) — capture photo/video with front/back switching */
.cam { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; }
.cam-video { width: 100%; height: 100%; object-fit: contain; }
.cam-top { position: absolute; top: calc(10px + var(--safe-t)); left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 14px; }
.cam-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(0,0,0,.5);
  color: #fff; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: calc(22px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cam-time { color: #fff; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px;
  background: rgba(0,0,0,.5); padding: 2px 12px; border-radius: 999px; }
.cam-hint { color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.cam-shutter { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff;
  background: #fff; cursor: pointer; transition: transform .1s; }
.cam-shutter.video { background: var(--accent); }
.cam-shutter.recording { background: var(--accent); border-radius: 18px; animation: pulse 1.3s ease-in-out infinite; }
.cam-shutter:active { transform: scale(.94); }

/* Screen capture: a small floating pill instead of a full-screen overlay — a
   full preview of a shared screen shows ITSELF (infinite mirror) and covers the
   very content being captured. The thumbnail keeps any recursion 200px small. */
.scr-bar { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(58px + var(--safe-b)); z-index: 60; display: flex; align-items: center; gap: 12px;
  background: rgba(20,20,24,.92); border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.scr-thumb { width: 200px; max-height: 120px; border-radius: 8px; background: #000; }
.scr-bar .cam-shutter { width: 52px; height: 52px; border-width: 3px; flex: none; }
.scr-bar .cam-shutter.recording { border-radius: 14px; }
.scr-hint { color: #fff; font-size: 12px; max-width: 200px; }

/* Review attachment manager: thumbnail + its own comment + remove, one row each */
.att-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--edge); }
.att-row:first-child { border-top: 0; }
.att-thumb { flex: 0 0 84px; width: 84px; height: 84px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--edge); background: var(--panel2); cursor: pointer; }
.att-thumb img, .att-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-doc { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: 26px; background: var(--card, #f4f4f5); cursor: pointer; }
.att-doc span { font-size: 11px; font-weight: 700; letter-spacing: .5px; color: var(--muted); }
.note-doc { display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px;
  border: 1px solid var(--line, #e5e7eb); border-radius: 12px; text-decoration: none; font-weight: 600; }
.att-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.att-body .att-cap { width: 100%; }
.att-del { align-self: flex-start; background: none; border: 0; color: var(--danger);
  font: inherit; font-size: 13px; cursor: pointer; padding: 2px 0; }
/* Capture methods — one flat grid (3-up desktop, 2-up phones), 2026-07-22. */
.cap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 8px; }
@media (max-width: 560px) { .cap-grid { grid-template-columns: 1fr 1fr; } }
body[data-width='wide'] .view .cap-grid,
body[data-width='full'] .view .cap-grid { max-width: 680px; }
/* Capture single-screen: action row, inline recorder, attachment read button */
.cap-actions { display: flex; gap: 10px; margin: 4px 0 10px; }
.cap-actions .btn { flex: 1; }
.rec.inline { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--panel);
  padding: 14px; margin-bottom: 10px; gap: 10px; }
.rec.inline .rec-btn { width: 52px; height: 52px; font-size: 20px; box-shadow: none; pointer-events: none; }
.kept-list { margin: 4px 0 10px; }
.kept-list .lab { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.att-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.att-read { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 2px 0; }
.att-read:disabled { color: var(--ok); cursor: default; }

/* ---- Video tools (trim / re-voice / merge) ---- */
.att-row.vid { align-items: center; }
.vid-pick { flex: 0 0 auto; display: flex; align-items: center; }
.vid-pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.att-trim, .att-voice, .att-undo, .att-move, .att-del, .lnk { background: none; border: 0; color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0; }
.att-move { color: var(--muted); font-size: 15px; padding: 2px 4px; }
.merge-bar { display: flex; gap: 8px; align-items: center; padding: 10px 0 2px; border-top: 1px solid var(--edge); }
.merge-bar .btn[disabled] { opacity: .5; }
.trim-video { width: 100%; max-height: 38vh; border-radius: 12px; background: #000; }
.trim-track { position: relative; height: 26px; margin: 26px 0 13px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); cursor: pointer;
  user-select: none; touch-action: none; }
.trim-track > div:not(.trim-tip) { border-radius: 6px; }
.trim-sel { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 30%, transparent); }
.trim-cut { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg,
  color-mix(in srgb, var(--err, #c33) 55%, transparent) 0 4px, transparent 4px 8px); }
.trim-sil { position: absolute; top: 16px; bottom: 0; background: repeating-linear-gradient(90deg,
  var(--muted) 0 3px, transparent 3px 6px); opacity: .8; }
.trim-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.trim-head::before, .trim-head::after { position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 9px; line-height: 1; color: var(--accent); }
.trim-head::before { content: '▼'; top: -12px; }
.trim-head::after { content: '▲'; bottom: -11px; }
.trim-times { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.trim-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.trim-row { display: flex; gap: 12px; align-items: center; padding: 5px 0; font-size: 13.5px;
  font-variant-numeric: tabular-nums; border-top: 1px solid var(--edge); }
.trim-row:first-child { border-top: 0; }
.trim-row.sil span:first-child { color: var(--muted); }
.rv-row { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--edge); }
.rv-row:first-child { border-top: 0; }
.rv-at { flex: 0 0 44px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 8px; }
.rv-txt { flex: 1; resize: vertical; min-height: 40px; }
/* Captions: smaller type on an opaque plate so they never drown what's on screen. */
video::cue { font-size: 0.78em; background: rgba(10, 10, 12, 0.85); color: #fff; }
.trim-ghost { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: .8; pointer-events: none; }
.trim-tip { position: absolute; bottom: 100%; transform: translateX(-50%); margin-bottom: 3px; padding: 1px 6px;
  font-size: 11.5px; border-radius: 6px; background: var(--fg); color: var(--bg); pointer-events: none;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Recording controls popped into a Document PiP mini-window. transform:none is
   load-bearing: the pill's page-centering translateX(-50%) would shove the bar
   half-off the mini-window (cropped thumbnail, "moves by itself"). */
.pip-body { margin: 0; background: #141418; height: 100vh; overflow: hidden; }
.scr-bar.in-pip { position: static; inset: auto; transform: none; box-shadow: none;
  width: 100%; height: 100%; box-sizing: border-box; border-radius: 0;
  justify-content: center; padding: 8px 10px; }
.scr-bar.in-pip .scr-thumb { flex: 1 1 auto; min-width: 0; width: auto; max-width: 45%;
  max-height: calc(100vh - 16px); object-fit: contain; }
.scr-bar.in-pip .scr-hint { max-width: 150px; }
.trim-final { color: var(--text); font-weight: 650; }
.trim-seglen { position: absolute; top: 50%; transform: translate(-50%, -50%); padding: 0 5px;
  font-size: 11px; line-height: 16px; border-radius: 5px; background: rgba(20,20,24,.75);
  color: #fff; cursor: default; user-select: none; font-variant-numeric: tabular-nums; }
/* ✂ Edit video: use the screen. Wide card, natural whole-sheet scrolling (the
   OVERLAY scrolls like a page — no inner scrollbars), shortcuts in a sidebar. */
.sheet.edit-wide { overflow-y: auto; align-items: flex-start; padding: 20px; }
.sheet.edit-wide .sheet-card { max-width: min(1160px, 96vw); max-height: none; overflow: visible;
  border-radius: 16px; }
.sheet.edit-wide .trim-video { max-height: 54vh; }
.edit-cols { display: flex; gap: 20px; align-items: flex-start; }
.edit-main { flex: 1 1 auto; min-width: 0; }
.edit-side { flex: 0 0 235px; border-left: 1px solid var(--edge); padding-left: 16px;
  font-size: 12.5px; color: var(--muted); display: grid; gap: 5px; align-content: start; }
.edit-side p { margin: 0 0 6px; }
.edit-key { display: flex; gap: 8px; align-items: baseline; }
.edit-key kbd { flex: 0 0 86px; text-align: center; background: color-mix(in srgb, var(--text) 8%, transparent);
  border: 1px solid var(--edge); border-radius: 5px; padding: 1px 4px;
  font: 11px/1.5 Consolas, ui-monospace, monospace; color: var(--text); white-space: nowrap; }
@media (max-width: 860px) { .edit-cols { flex-direction: column; }
  .edit-side { border-left: 0; padding-left: 0; margin-top: 18px; border-top: 1px solid var(--edge); padding-top: 14px; } }
.trim-pause { position: absolute; top: -4px; bottom: -4px; width: 0;
  border-left: 2px dashed #d9a13b; }

/* Admin → Live apps: Edit-app sheet — wide card (gh-card precedent), compact
   template buttons, auto-growing editors (capped, then they scroll). */
.sheet-card.ka-card { max-width: min(1000px, 96vw); }
button.btn.sm { min-height: 26px; padding: 2px 10px; font-size: 12px; border-radius: 8px; gap: 5px; }
.ka-lab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 7px; }
.ka-ta { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  resize: vertical; max-height: 55vh; }
.ka-ex { background: var(--panel2); border: 1px solid var(--edge); border-radius: 8px;
  padding: 8px 10px; margin: 2px 0 10px; font-size: 12px; line-height: 1.5; overflow-x: auto; }

/* Mermaid diagrams (```mermaid in a memory) — rendered by js/diagrams.js. The
   <pre> holds the source: visible only until render, or when the syntax is bad. */
.answer pre.mermaid { background: var(--cite); border: 1px solid var(--edge); border-radius: 8px;
  padding: 10px 12px; margin: 10px 0; overflow-x: auto;
  font: 12.5px/1.5 Consolas, ui-monospace, monospace; }
.answer pre.mermaid.mmd-err { border-left: 3px solid var(--danger); }
.mmd-box { margin: 10px 0; padding: 10px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 8px; overflow-x: auto; text-align: center; }
.mmd-box svg { max-width: 100%; height: auto; }
.mmd-box.mmd-click { cursor: zoom-in; }
/* Full-screen diagram viewer (rides the .lightbox base: fixed inset overlay). An
   OPAQUE app-background — diagram text is themed for it, not for the lightbox black. */
.mmd-view { background: var(--bg); z-index: 70; padding: 0; }
.mmd-view .mmd-canvas { position: absolute; inset: 0; display: grid; place-items: center;
  overflow: hidden; cursor: grab; touch-action: none; }
.mmd-view .mmd-canvas.grabbing { cursor: grabbing; }
/* Photos ride the same viewer as diagrams (fit / wheel-zoom / drag-pan).
   Centred by absolute positioning, NOT by the grid: a grid item TALLER than its
   container is start-aligned (browsers keep overflow reachable), which threw the
   fit() maths off by (1-scale)*height/2 — a portrait photo landed below the
   viewport and read as a black screen (Norm, 2026-07-30). The transform now
   carries its own -50%/-50% so the box centre is the container centre at ANY
   natural size; zoom/pan translations ride on top. */
.mmd-view .mmd-canvas svg,
.mmd-view .mmd-canvas img { position: absolute; left: 50%; top: 50%;
  transform-origin: center center; user-select: none; -webkit-user-drag: none; }
.mmd-bar { position: fixed; top: calc(10px + var(--safe-t)); right: 14px; display: flex;
  gap: 6px; z-index: 71; }
.mmd-bar button { min-width: 42px; min-height: 42px; border: 1px solid var(--ctrl-edge);
  border-radius: 10px; background: var(--panel); color: var(--text); font-size: 17px;
  cursor: pointer; }

/* Browse: pagination bar + last-read highlight. */
.mpager { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 10px 2px 0; }
.mpager select { min-height: 34px; }
.mpage-nav { display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  font-variant-numeric: tabular-nums; }
.row.row-last { background: var(--hover-wash); box-shadow: inset 3px 0 0 var(--accent);
  padding-left: 14px; } /* text clears the accent bar */
