/* public/stream/sections.css — shared layout + component classes for the
   Phase 1 web config sections (#sec-alerts / #sec-tips / #sec-loyalty /
   #sec-audio). Ported from the canonical mockup (mockups/omni-mock.css) and
   DESIGN-GUIDELINES §3.5/§3.2; tokens ONLY, no hardcoded color. Loaded once
   alongside control-surface.css. No page-local nav styling lives here. */

/* ── grid helpers (DESIGN-GUIDELINES responsive columns) ── */
.sec-grid { display: grid; gap: var(--space-4); align-items: start; }
/* Equal-height variant: cards in the same row stretch to match the tallest, so a
   multi-row dashboard (e.g. Home) has aligned rows with uniform gaps rather than
   ragged voids under shorter cards. The card content stays top-aligned. */
.sec-grid--even { align-items: stretch; }
.sec-grid--even > .card { display: flex; flex-direction: column; }
.sec-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.sec-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.sec-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .sec-grid.cols-2, .sec-grid.cols-3, .sec-grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .sec-grid.cols-2, .sec-grid.cols-3, .sec-grid.cols-4 { grid-template-columns: 1fr; } }

/* Section body: a flex column with token gaps. This base padding only applies to a
   .sec-body used OUTSIDE a .card (standalone); when it sits directly in a .card the
   card already pads, so the override below (.card > .sec-body) zeroes this to avoid
   a doubled inset. */
.sec-body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }

/* ── well + tile (DESIGN-GUIDELINES §3.2) ── */
.well { background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--space-3); }
.tile { display: flex; flex-direction: column; gap: var(--space-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
/* The benchmark control row reuses .between but must wrap on narrow screens so
   the Category / value / Compare controls stack instead of cramping onto one row
   (Web Interface Guidelines: no cramped controls). flex-wrap keeps width:100%
   inputs from compressing below a usable size under --bp-mobile. */
.between.wrap { flex-wrap: wrap; align-items: flex-end; }
.between.wrap > .field { flex: 1 1 160px; min-width: 0; }

/* ── row (label + control), reused from the mockup pattern ── */
.sec-row { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-2); border-bottom: 1px solid var(--border); }
.sec-row:last-child { border-bottom: 0; }
.sec-row .grow { flex: 1; min-width: 0; }
.sec-row .grow .t { font-weight: 600; display: block; }
.sec-row .grow .s { color: var(--text-dim); font-size: 11.5px; display: block; }
/* Row/list health cue (§3.3): the .dot status circle + its text label, so health
   is perceivable without color. The label inherits text color (not the severity
   color) — meaning lives in the word, severity color lives in the dot. */
.sec-health { display: inline-flex; align-items: center; gap: var(--space-1); flex: none; }
.sec-health-label { font-size: 11px; color: var(--text-dim); letter-spacing: .03em; }

/* ── form field + inputs (DESIGN-GUIDELINES §3.5) ── */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > .lbl { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
/* Form help is instructional CONTENT, not a decorative hint, so it uses the
   readable --text-dim token (~7.4:1 on --surface-inset) to meet WCAG 1.4.3 AA
   (4.5:1) — --text-faint (~3.4:1) failed for this 11px content text. */
.field > .help { font-size: 11px; color: var(--text-dim); }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px var(--space-3);
}
.textarea { min-height: 64px; resize: vertical; font-family: var(--font-mono); font-size: 12px; }
/* Compact inline input (e.g. the TikTok @username add in Connections) — fits in a
   flex action row instead of stretching full-width. */
.input--sm { width: auto; max-width: 12rem; padding: 5px 10px; font-size: 12px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--border-accent); }
.input[readonly] { color: var(--text-dim); }

/* ── toggle (track + knob), accessible role="switch" (DESIGN-GUIDELINES §3.5) ── */
.toggle {
  width: 40px; height: 22px; border-radius: var(--r-pill); background: var(--surface-2);
  border: 1px solid var(--border); position: relative; cursor: pointer; flex: none;
  transition: background var(--dur) var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text-dim);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); background: var(--text); }
.toggle[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* ── segmented control (binary/enum) (DESIGN-GUIDELINES §3.5) ── */
.seg { display: inline-flex; background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600;
  font-size: 11.5px; padding: 5px 12px; border-radius: var(--r-pill); cursor: pointer;
}
.seg button.on { background: var(--accent); color: var(--text); }

/* ── chips row (presets, socials) ── */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface-inset); font-size: 12px; }
.chip button { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font: inherit; padding: 0; line-height: 1; }
.chip button:hover { color: var(--danger); }

/* ── copy row (browser-source URL) ── */
.sec-copyrow { display: flex; gap: var(--space-2); }
.sec-copyrow .input { flex: 1; }

/* ── inline actions + notes ── */
.sec-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.sec-note { margin: 0; font-size: 12px; color: var(--text-dim); }
.sec-err { margin: 0; font-size: 12px; }
.sec-empty, .sec-loading { padding: var(--space-4); text-align: center; font-size: 12px; }

/* ── Home: next-step inline guidance + performance-card value rows ── */
.sec-stack { border-bottom: 1px solid var(--border); }
.sec-stack:last-child { border-bottom: 0; }
.sec-stack > .sec-row { border-bottom: 0; }
.sec-step-help { padding: 0 var(--space-2) 10px; line-height: 1.4; }
/* a right-aligned monetary / numeric value paired with a sec-row label */
.sec-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── variable legend (collapsible token reference in the bot commands tab) ── */
.sec-legend { margin: var(--space-2) 0; font-size: 12px; }
.sec-legend > summary { cursor: pointer; color: var(--text-dim); font-weight: 600; }
.sec-legend > summary:hover { color: var(--text); }
.sec-legend-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sec-legend-list li { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
/* Variable tokens are CASE-SENSITIVE literals ($user, $(count), …) — the global
   .badge uppercases, which would teach the wrong spelling on this discovery
   surface. Render legend tokens verbatim. */
.sec-legend-list .badge { text-transform: none; letter-spacing: 0; }

/* ── list of items (alerts/widgets/engagements) ── */
.sec-list { display: flex; flex-direction: column; gap: var(--space-2); }
.sec-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-inset); }
.sec-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.sec-item-title { font-weight: 600; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.sec-item-meta { font-size: 11px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sec-item-actions { flex: none; display: flex; gap: var(--space-2); }

/* ── Continuity: input-pool + failover-priority drag surface ──
   Two columns (pool ↔ ordered failover list); HTML5 drag-and-drop. Tokens only;
   wide content scrolls within each column (no body h-scroll). */
.cont-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--space-4); align-items: start; }
@media (max-width: 720px) { .cont-cols { grid-template-columns: 1fr; } }
.cont-col { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cont-col-head { font-family: var(--font-display); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 0; }
.cont-pool, .cont-priority { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-inset); min-height: var(--space-7, 3rem); }
.cont-pool-empty { padding: var(--space-3); text-align: center; font-size: 12px; }
/* Draggable input card (pool + inside a filled row). */
.cont-card { cursor: grab; user-select: none; align-items: center; }
.cont-card.is-dragging { opacity: .5; }
.cont-card:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
/* A filled failover row: the card + scene picker + ▲▼/Remove fallback controls. */
.cont-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.cont-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.cont-row-scene { gap: var(--space-2); }
.cont-row-actions { flex: none; }
/* An empty DRAFT row — a dotted "drag a device here" drop target. */
.cont-draft { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); border: 1px dashed var(--border-accent); border-radius: var(--r-sm); background: var(--accent-wash); text-align: center; }
.cont-draft-label { font-weight: 600; font-size: 12px; color: var(--text-dim); }
.cont-draft-hint { font-size: 11px; }
/* Liveness dot on an input card (mirrors the Devices UI). Server-resolved
   `online` (relay live-slot or fresh device); inline before the label. */
.cont-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-full, 50%); margin-right: var(--space-2); vertical-align: middle; }
.cont-dot.is-online { background: var(--ok, var(--accent)); }
.cont-dot.is-offline { background: var(--border); }
/* Honesty note shown when the failover list is empty (empty ≠ failover off). */
.cont-empty-note { padding: var(--space-2); font-size: 12px; }

/* Connection context on a destination card (desktop-overhaul §02 — the retired
   channel dropdown, folded into the cards): which connected account this dest
   streams as, or an honest not-connected state. .dim token = readable muted
   informational text (WCAG 1.4.3), not decorative .faint. */
.sec-item-conn { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.sec-item-conn--off { color: var(--warn); }
.sec-conn-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.sec-conn-link:hover, .sec-conn-link:focus { text-decoration: underline; }

/* ── Destination card: collapsed summary + click/keyboard-expand editor (P1) ──
   A destination card stacks vertically: an always-visible summary row (the
   expand toggle) over a hidden detail editor. The summary is the keyboard hit
   target (role=button, tabindex 0); the detail reveals ONLY via the
   click/Enter/Space toggle (which drives aria-expanded + [hidden]). The detail
   must NEVER open on hover — a hover-fold-out flapped the editor open as the
   pointer crossed the card. Hover is a purely visual chevron hint. */
.sec-item--dest { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.sec-item-summary { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; }
.sec-item-summary:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; border-radius: var(--r-sm); }
.sec-item-summary > .sec-item-main { flex: 1; min-width: 0; }
.sec-item-chevron { flex: none; color: var(--text-dim); font-size: 12px; line-height: 1.6; user-select: none; transition: transform var(--dur-fast) var(--ease); }
.sec-item-detail { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--border); }
.sec-item-detail[hidden] { display: none; }
/* Hover is a chevron-only hint (pointer devices); it NEVER unhides the editor —
   the click/Enter/Space toggle is the single source of truth for expansion. */
@media (hover: hover) {
  .sec-item--dest:hover .sec-item-chevron { transform: rotate(90deg); }
}
.sec-item--dest.is-expanded .sec-item-chevron { transform: none; }
/* Destination editor: identity fields stack one per row (cleaner than the old
   horizontal wrap). Auto (OAuth) sources show a read-only synced notice instead
   of editable Server URL / Stream key; the Enabled toggle sits in the footer. */
.sec-item-form { display: flex; flex-direction: column; gap: var(--space-3); }
.sec-item-synced { display: flex; align-items: center; gap: var(--space-2); }
.sec-item-enabled { display: inline-flex; align-items: center; gap: var(--space-1); margin-right: auto; font-size: 12px; cursor: pointer; }

/* ── Sources: editable per-device priority + routing (P22) ── */
.sec-priority-wrap { display: inline-flex; align-items: center; gap: 4px; }
.sec-priority { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: var(--r-sm); background: var(--accent-wash); color: var(--accent-2); font-family: var(--font-mono); font-size: 11px; font-weight: 700; }
.sec-priority.dim { background: transparent; color: var(--text-dim); }
.sec-pri-btn { padding: 2px 6px; font-size: 10px; line-height: 1; }
.sec-pri-btn:disabled { opacity: .4; cursor: not-allowed; }
.select--sm { padding: 4px 8px; font-size: 11.5px; }
/* Routing badge accent + online dot (used by the Sources device table). */
.badge--info { background: var(--accent-wash); color: var(--accent-2); border-color: var(--border-accent); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot--ok { background: var(--success, #2ecc71); }
.status-dot--off { background: var(--text-faint); }

/* ── sub-tab strip (engagement vs loyalty placeholder) ── */
/* Scrolls inside its own container so 5+ tabs never push the body wider than
   the viewport on narrow screens (Web Interface Guidelines: no horizontal body
   scroll). flex-wrap:nowrap keeps the strip one row; overflow-x:auto lets that
   row scroll locally. */
.subtabs { display: flex; flex-wrap: nowrap; gap: var(--space-2); margin-bottom: var(--space-4); border-bottom: 1px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.subtabs button { flex: none; }
.subtabs button { border: 0; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600; padding: 8px var(--space-3); border-bottom: 2px solid transparent; cursor: pointer; }
.subtabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ── spacing utilities (token-based; replace inline el.style.marginTop and
   stray inline style="margin-top:…" so markup carries no hardcoded spacing,
   DESIGN-GUIDELINES §3.9 anti-pattern). ── */
.sec-mt-4 { margin-top: var(--space-4); }

/* ── content-bearing meta text (WCAG 1.4.3): .dim is the readable muted token
   for meta that carries information. .faint is reserved for decorative/optional
   hints; content meta uses .dim against --surface-inset. ── */
.sec-mb-4 { margin-bottom: var(--space-4); }

/* ═══════════════════════════════════════════════════════════════════════
   Phase 3 — Revenue (#sec-revenue) + Analytics (#sec-analytics) sections.
   Tokens ONLY (omni-ui.css :root). Provenance/availability badges are the
   honesty surface: every money figure and every metric is badged.
   ═══════════════════════════════════════════════════════════════════════ */

/* card header strip (used by every section card; previously relied on default
   block flow — defined here so the head reads as a header with its own border). */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 0 0 var(--space-3) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
/* A .card already supplies the outer space-4 padding (shell.css). A .sec-body
   directly inside it must NOT add its own — that DOUBLED the inset (2× space-4):
   the header sat at 16px while the body sat at 32px, with an oversized bottom gap.
   Plain .card content (no .sec-body) stayed at 16px, so section cards read as
   over-padded and the plain ones as under-padded side by side. The card pads; the
   body only lays out (flex column + gap). The rule below re-adds a small top gap
   under the .card-head divider when a head precedes the body. */
.card > .sec-body { padding: 0; }
.card > .card-head { margin-bottom: 0; }
.card > .card-head + .sec-body { padding-top: var(--space-3); }

/* ── provenance badge (REAL / ESTIMATED / IMPORTED) — extends .badge ── */
.badge.prov { border: 1px solid var(--border); }
.prov--real { background: rgba(0, 179, 0, .14); color: var(--ok-soft); border-color: rgba(0, 179, 0, .3); }
.prov--estimated { background: rgba(255, 184, 77, .14); color: var(--warn); border-color: rgba(255, 184, 77, .3); }
.prov--imported { background: var(--accent-wash); color: var(--accent-2); border-color: var(--border-accent); }

/* ── payout reconciliation status — a PERSISTENT record label → .badge (§3.3
   reserves .pill for transient LIVE/CONNECTING/ERROR). Status-derived variant so
   received vs mismatch are visually differentiated, not colour-only: the text
   label (PENDING/RECEIVED/RECONCILED/MISMATCH) always carries the meaning. ── */
.badge.status { border: 1px solid var(--border); }
.status--ok { background: rgba(0, 179, 0, .14); color: var(--ok-soft); border-color: rgba(0, 179, 0, .3); }
.status--warn { background: rgba(255, 184, 77, .14); color: var(--warn); border-color: rgba(255, 184, 77, .3); }
.status--danger { background: rgba(255, 64, 64, .14); color: var(--danger); border-color: rgba(255, 64, 64, .3); }
.status--neutral { background: var(--surface-2); color: var(--text-dim); }

/* ── availability badge (Available / Estimated / N/A) — mockup avail-* set ── */
.availbadge { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; padding: 2px 7px; border-radius: var(--r-sm); white-space: nowrap; }
.avail-ok { background: rgba(0, 179, 0, .14); color: var(--ok-soft); }
.avail-est { background: rgba(255, 184, 77, .12); color: var(--warn); }
/* N/A is load-bearing honesty content ("no platform API"), not decoration, so it
   must meet WCAG 1.4.3 AA (4.5:1). This 9px bold badge is NOT WCAG "large text",
   so --text-faint (~3.4:1 on --surface) failed — same faint-on-surface mistake
   already fixed for .field > .help. Use --text-dim (~7:1 on --surface, also AA on
   --surface-inset where the legend rows sit in .well). Background is a token-based
   wash (--surface-2 over a tint) rather than a hardcoded hex. */
.avail-na { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }

/* ── legend (provenance / availability key rows) ── */
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--text-dim); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* ── per-currency subtotal blocks (multi-currency: one block per ISO currency,
   never summed across) — layout only, colours come from tokenized child classes */
.cur-totals { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.cur-block { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.cur-block:last-child { border-bottom: 0; }
.cur-block .cur-code { font-weight: 600; color: var(--text); min-width: 3.5em; }
.cur-block .cur-total { font-weight: 600; color: var(--text); }

/* ── platform dot ── */
.pdot { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; background: var(--surface-2); }
.pdot.twitch { background: var(--p-twitch); }
.pdot.youtube { background: var(--p-youtube); }
.pdot.kick { background: var(--p-kick); }
.pdot.tiktok { background: var(--p-tiktok); }
.pdot.billing { background: var(--accent); }
.inline { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ── data table (revenue breakdown / analytics metrics / payouts) ── */
/* Scrolls inside its own wrapper so a wide table never widens the page body
   on narrow viewports (Web Interface Guidelines: no horizontal body scroll). */
.sec-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Audio VOD-split checklist (opt-out): one checkbox per audio source against the
   VOD column. Buses are auto-populated from the live OBS sources — there is no
   manual add/remove (untick to drop a source from the VOD). */
.sec-checklist { display: flex; flex-direction: column; }
.sec-checkrow {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 10px var(--space-2); border-bottom: 1px solid var(--border); cursor: pointer;
}
.sec-checkrow:last-child { border-bottom: 0; }
.sec-checkrow > .grow { flex: 1; min-width: 0; }
.sec-checkrow > input[type="checkbox"] { flex: 0 0 auto; }
/* Per-destination "SRT soon" honesty marker on the matrix column headers: the
   destination columns are inert on the single-track RTMP relay. Muted, small,
   non-uppercase so it reads as a status note, not a teachable label. */
.sec-soon {
  display: inline-block; margin-left: var(--space-1); padding: 1px 6px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .02em; text-transform: none;
  color: var(--text-dim); background: var(--surface-inset);
  border: 1px solid var(--border); border-radius: var(--r-sm); vertical-align: middle;
  cursor: help;
}
/* Info note: the honest "what applies today" callout under the matrix intro. */
.sec-note--info {
  padding: var(--space-2) var(--space-3); border: 1px solid var(--border);
  border-left: 2px solid var(--accent); border-radius: var(--r-sm);
  background: var(--surface-inset);
}
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { text-align: left; padding: 8px var(--space-2); border-bottom: 1px solid var(--border); }
.table th { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }

/* ── stat (DESIGN-GUIDELINES §3.6: label + mono value for KPIs) ──
   The headline "Earnings this period" figure is PERSISTENT data, not a transient
   status, so it uses .stat (not .pill — §3.3 reserves .pill for LIVE/ERROR state).
   Value sized via the type scale (20px heading), not a hero gradient (§3.9). */
.stat { display: inline-flex; flex-direction: column; gap: 2px; }
.stat > .stat-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.stat > .stat-value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text); }
/* period-over-period delta (§3.9 trend context). Direction is colour-coded but
   the text ("+12% vs prior period") always carries the meaning (not colour-only). */
.stat > .stat-delta { font-size: 11.5px; font-weight: 600; }
.stat > .stat-delta.trend-up { color: var(--ok-soft); }
.stat > .stat-delta.trend-down { color: var(--danger); }

/* ── grid span (revenue/analytics focal card spans 2 of 3 cols) ── */
.sec-grid .span-2 { grid-column: span 2; }
@media (max-width: 980px) { .sec-grid .span-2 { grid-column: auto; } }

/* ── full-width action button ── */
.btn.block { width: 100%; justify-content: center; }

/* ── error region: cause + Retry affordance (DESIGN-GUIDELINES §5 error state).
   The error text and its Retry button sit on one row; Retry re-invokes the
   matching refresh fn. .sec-retry is a compact ghost button. ── */
.sec-errrow { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.sec-retry { border: 1px solid var(--border); background: var(--surface-inset); color: var(--text); font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-sm); cursor: pointer; }
.sec-retry:hover { border-color: var(--border-accent); }

/* ── inline link-style button ("why estimated?") ── */
.linkbtn { border: 0; background: transparent; padding: 0; font: inherit; color: var(--accent-2); cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: var(--accent-soft); }

/* ── lightweight modal (CSV import / "why estimated?") ── */
.sec-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: var(--space-4); background: rgba(0, 0, 0, .55); }
.sec-modal.hide { display: none; }
.sec-modal-box { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-accent); border-radius: var(--r); box-shadow: var(--shadow-card); padding: var(--space-4); }
.sec-modal-box .card-head { margin-bottom: var(--space-3); }
.sec-modal-box .card-head { display: flex; align-items: center; justify-content: space-between; }

/* ── Edit-Stream-Info modal fields (Quick action 'edit-info', F1) ── */
.si-field { display: block; margin-bottom: var(--space-3); }
.si-label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
.si-field .inp { width: 100%; box-sizing: border-box; }
.si-count { display: block; text-align: right; font-size: var(--fs-xs); margin-top: var(--space-1); }
.si-cat-current { margin-top: var(--space-1); font-size: var(--fs-sm); }
.si-cat-results { list-style: none; margin: var(--space-1) 0 0; padding: 0; max-height: 180px; overflow-y: auto; }
.si-cat-results:empty { display: none; }
.si-cat-result { padding: var(--space-2); border-radius: var(--r-sm); cursor: pointer; }
.si-cat-result:hover, .si-cat-result:focus { background: var(--surface-2); }
/* Cross-platform sync opt-in: checkbox + label on one row. */
.si-sync { display: flex; flex-direction: row; align-items: center; gap: var(--space-2); }
.si-sync .si-label { margin-bottom: 0; font-weight: 500; }
.si-status { list-style: none; margin: var(--space-3) 0 0; padding: 0; }
.si-status-row { display: flex; align-items: center; justify-content: space-between; padding: var(--space-1) 0; }
.si-status-row .si-status-name { font-weight: 600; }
.si-status-row.ok .si-status-val { color: var(--success, #2ecc71); }
.si-status-row.warn .si-status-val { color: var(--warn, #e0a82e); }
.sec-modal-box .sec-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }

/* ── visually-hidden utility (screen-reader-only) ──
   Used for <caption> on data tables so the table has an accessible name without
   a visible duplicate of the card <h2>. Token-spaced; no hardcoded clip magic
   beyond the standard 1px inset-rect pattern. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ── no-JavaScript fallback ──
   The app shell (sidebar + every section) is built by shell.js, so with JS
   disabled (or if shell.js fails to load) the page would otherwise render blank.
   This token-styled <noscript> message keeps the page from ever being silently
   empty and points to a static help/login route. */
.noscript-fallback {
  margin: var(--space-6) auto; max-width: 520px; padding: var(--space-6);
  background: var(--surface); border: 1px solid var(--border-accent);
  border-radius: var(--r); box-shadow: var(--shadow-card); text-align: center;
}
.noscript-fallback h1 { margin: 0 0 var(--space-3); font-size: 17px; }
.noscript-fallback p { margin: 0 0 var(--space-4); color: var(--text-dim); font-size: 13px; }
.noscript-fallback a { color: var(--accent-2); }

/* ═══════════════════════════════════════════════════════════════════════
   Phase 3 — Chat (#sec-chat). The merged multi-platform moderated feed
   (sec-chat.js). Tokens ONLY (no hardcoded color). Mirrors the .sec-*
   component vocabulary. The JS class names are the contract — do not rename.
   ═══════════════════════════════════════════════════════════════════════ */

/* The chat card is a vertical stack: filter toolbar → (connect prompt) → feed →
   composer → statusline. The feed is the only flexible region (it scrolls). */
.chat-card { display: flex; flex-direction: column; gap: var(--space-3); }

/* ── filter toolbar: per-platform toggle row ── */
.chat-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.chat-filter { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none; }
.chat-filter input { margin: 0; cursor: pointer; }
/* A filter that is OFF dims its own label so the toolbar reflects active state. */
.chat-filter:has(input:not(:checked)) { opacity: .55; }

/* ── connect-a-channel empty prompt (shown when no platforms connected) ── */
.chat-connect { padding: var(--space-3); border: 1px dashed var(--border-accent); border-radius: var(--r-sm); background: var(--accent-wash); color: var(--text-dim); font-size: 12px; }
.chat-connect a { color: var(--accent-2); }

/* ── merged feed: the scroll container. Caps its own height and scrolls
   internally so a long session never grows the page body. ── */
.chat-feed { display: flex; flex-direction: column; gap: var(--space-2); overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 52vh; min-height: 180px; padding-right: var(--space-1); }
.chat-feed:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; border-radius: var(--r-sm); }
.chat-empty { padding: var(--space-4); text-align: center; font-size: 12px; }

/* ── a single chat line: platform dot · body (author + text) · mod actions ── */
.chat-row { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--r-sm); }
.chat-row:hover, .chat-row:focus-within { background: var(--surface-inset); }
.chat-row .pdot { margin-top: 4px; }
.chat-body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; word-break: break-word; }
.chat-author { font-weight: 600; color: var(--text); margin-right: 6px; }
.chat-text { color: var(--text); }
.chat-deleted-label { margin-left: 6px; font-size: 11px; }

/* moderation actions — quiet until the row is hovered/focused, but always
   keyboard-reachable (kept in flow; revealed via opacity, not display). */
.chat-mod { flex: none; display: inline-flex; gap: var(--space-1); opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.chat-row:hover .chat-mod, .chat-row:focus-within .chat-mod { opacity: 1; }
.chat-mod-btn { width: 26px; height: 26px; font-size: 13px; }

/* ── composer (send box) + status line ── */
.chat-composer { display: flex; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); align-items: center; }
.chat-composer .grow { flex: 1; min-width: 0; }
/* the platform picker sizes to its content, not the full composer width */
.chat-composer select { flex: 0 0 auto; width: auto; }
.chat-statusline { margin: 0; font-size: 11.5px; min-height: 1em; }

/* ── interactive state styling (the headline filter + moderate value) ──
   A filtered-out platform's rows must actually disappear; a moderated row must
   visibly collapse; a system/event line must read distinctly from chat. ── */
.chat-row.filter-hidden { display: none; }
.chat-row.deleted { opacity: .55; }
.chat-row.deleted .chat-text { text-decoration: line-through; }
.chat-row.is-event { border-left: 2px solid var(--accent); background: var(--accent-wash); }
.chat-row.is-event .chat-author { color: var(--accent-2); }

/* ── Shared chat rich rendering (chat-render.js): badges, colored names, emotes. ──
   The full chat section enriches its .chat-row bodies in place; the compact My-chat
   card builds .chat-msg rows via buildMessageEl. Both reuse .msg-badges / .chat-emote. */
.chat-msg { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--r-sm); line-height: 1.4; }
.chat-msg:hover { background: var(--surface-inset); }
.chat-msg .pdot { margin-top: 4px; }
/* Local-time HH:MM stamp — muted, tabular, scales with the feed font-size (.82em) so the
   chat card's A−/A+ control sizes it along with the messages. */
.chat-msg .msg-time { flex: none; color: var(--text-faint); font-size: .82em; font-variant-numeric: tabular-nums; margin-top: 3px; white-space: nowrap; }
.chat-msg .msg-body { min-width: 0; }
.chat-msg .msg-author { font-weight: 700; }
.chat-msg .msg-author::after { content: ':'; color: var(--text-dim); font-weight: 400; margin-left: 1px; }
.chat-msg .msg-text { color: var(--text); word-break: break-word; }
/* Event lines (redeem/sub/cheer/raid) — accent-tinted, the description in accent. */
.chat-msg.is-event { border-left: 2px solid var(--accent); background: var(--accent-wash); padding-left: var(--space-2); }
.msg-event { color: var(--accent-2); word-break: break-word; }
/* Chat card head tools: the A−/A+ text-size buttons + Open-chat link. */
.chat-head-tools { display: inline-flex; align-items: center; gap: var(--space-1); }
.chat-head-tools [data-chat-font] { min-width: 2rem; padding-left: var(--space-2); padding-right: var(--space-2); font-variant-numeric: tabular-nums; }
/* badges + emotes (used by BOTH surfaces) */
.msg-badges { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; vertical-align: middle; }
.msg-badge { display: inline-flex; align-items: center; line-height: 0; }
.msg-badge svg { display: block; }
.chat-emote { display: inline-block; height: 1.5em; width: auto; vertical-align: middle; margin: -2px 1px; }

/* Right-click moderation context menu (chat-modmenu.js). */
.ctx-menu { position: fixed; z-index: 80; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-card); padding: 4px 0; min-width: 168px; }
.ctx-item { padding: 6px 14px; color: var(--text); cursor: pointer; white-space: nowrap; font-size: 12px; }
.ctx-item:hover { background: var(--surface-inset); }
.ctx-item-danger { color: var(--danger); }
.ctx-item-danger:hover { background: rgba(255, 64, 64, .15); }
.ctx-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Community → Admin liveops preview iframe (sec-community.js buildAdminRegion) ──
   Full-width, tall-enough preview of the standalone admin dashboard. Relative
   viewport height + token radius (never a hardcoded px); replaces the old inline
   style attribute. The primary affordance is the "Open Admin dashboard ↗" link
   above it — this iframe is the at-a-glance preview. */
.admin-embed { width: 100%; height: 70vh; border: 0; border-radius: var(--r-sm); margin-top: var(--space-3); }

/* ═══════════════════════════════════════════════════════════════════════
   P2 — Settings hub (#sec-settings, sec-settings.js). A tabbed container: the
   shared .subtabs strip drives the six WAI-ARIA tabs (its .subtabs button /
   .subtabs button.on rules already style + indicate the active tab), and each
   .settings-panel holds a lazily-rendered body. Tokens ONLY (no hardcoded
   hex/px); the embed/QR sizing mirrors .admin-embed. ═══════════════════════ */

/* Each tab's panel body. Panels are toggled hidden by OmniTabs (role=tabpanel);
   the [hidden] rule guarantees an inactive panel collapses even if a UA stylesheet
   would otherwise show it. */
.settings-panel { display: block; }
.settings-panel[hidden] { display: none; }

/* Stacked label-over-input form (change-email, 2FA disable/verify). Replaces the
   inline flex-direction:column style attribute with a token-spaced class. */
.settings-form { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-3); }

/* Billing preview iframe — mirrors .admin-embed (full width, relative viewport
   height, token radius; never a hardcoded px). The primary affordance is the
   "Open Billing ↗" link above it; this iframe is the at-a-glance preview. */
.settings-embed { width: 100%; height: 70vh; border: 0; border-radius: var(--r-sm); margin-top: var(--space-3); }

/* 2FA setup QR — capped to a sensible scan size via a relative max-width so it
   never overflows the well on narrow viewports. */
.settings-qr { display: block; width: 100%; max-width: 12rem; height: auto; border-radius: var(--r-sm); background: var(--surface); }

/* Appearance / overlay-theme editor (A2). A small section sub-heading + the live
   preview surface. The preview composites over a CHECKERBOARD so a transparent
   theme reads as transparent (matching an OBS browser source over video). Theme
   tokens are injected onto [data-preview] via element.style.setProperty at runtime
   (never inline CSS strings) — these rules only read the resulting custom props. */
.sec-subhead { font-size: var(--fs-card-title); font-weight: var(--fw-semibold); color: var(--text-dim); margin: var(--space-4) 0 var(--space-2); }
.theme-preview {
  --prev-bg: transparent;
  border-radius: var(--r-sm); padding: var(--space-5); min-height: 7rem;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--prev-bg);
  background-image:
    linear-gradient(45deg, var(--surface-inset) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-inset) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-inset) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-inset) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.theme-preview-alert {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, var(--r));
  padding: var(--space-4) var(--space-5); text-align: center; box-shadow: var(--shadow-card);
  max-width: 90%;
}
.theme-preview-msg { color: var(--text); font-family: var(--font-display); font-size: var(--fs-section); }
.theme-preview-msg [data-preview-accent] { color: var(--accent); font-weight: var(--fw-bold); }

/* ═══════════════════════════════════════════════════════════════════════
   IA §3 — Stream Manager cockpit (#sec-stream, sec-stream.js). The lean live
   cockpit: a full-width stat bar over a multi-panel grid (preview, quick
   actions, activity, my-chat, collaboration, destination health) + the bonding
   link-health panel. Tokens ONLY (no hardcoded hex/px colour, no inline style);
   every panel ships all four states with honest empty copy. ═══════════════ */

/* ── (1) STAT BAR — compact chips, full width, scrolls locally on narrow ── */
.stat-bar {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.stat-chip {
  display: flex; flex-direction: column; gap: var(--space-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--space-2) var(--space-4);
  min-width: 7rem; flex: 1 1 7rem;
}
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.stat-value { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--text); }
/* the live session chip gets the accent treatment so uptime reads as "on air" */
.stat-chip.is-live { border-color: var(--border-accent); }
.stat-chip.is-live .stat-value { color: var(--accent-soft); }
/* destination/bitrate severity tint on the value (paired with the chip border) */
.stat-chip.stat--ok .stat-value { color: var(--ok-soft); }
.stat-chip.stat--warn { border-color: rgba(255,184,77,.4); }
.stat-chip.stat--warn .stat-value { color: var(--warn); }
.stat-chip.stat--danger { border-color: rgba(255,64,64,.4); }
.stat-chip.stat--danger .stat-value { color: var(--danger); }
/* followers chip: a small session-gain line under the total + an (expandable)
   per-platform breakdown shown on the chip's title/hover. */
.stat-sub { font-size: 10.5px; font-weight: 600; color: var(--text-dim); }
.stat-sub.gain { color: var(--ok-soft); }
.stat-chip .stat-breakdown { font-size: 10px; color: var(--text-faint); line-height: 1.5; }
.stat-chip .stat-breakdown .miss { color: var(--warn); }

/* Cockpit grid (WIDE = two columns): column 1 is a 2-row stack — the Stream Preview
   (row 1) + .cockpit-rest (row 2: Activity / Dest health / Collaboration / Live settings
   / OBS settings / Bonding) — that scrolls with the page. My Chat is column 2, pinned
   STICKY and viewport-tall, SPANNING both rows, so the stat bar + quick actions + left
   cards scroll away behind it while the chat keeps the full height. Chat is 2nd in source
   order → on NARROW (one column) it stacks directly under the Stream Preview at ~50vh. */
.cockpit-grid {
  display: grid;
  /* Chat width is USER-ADJUSTABLE: the drag handle (wireCockpitChat) writes
     --cockpit-chat-w (px, clamped + persisted). 26rem is the pre-JS default. */
  grid-template-columns: minmax(0, 1fr) var(--cockpit-chat-w, 26rem);
  gap: var(--space-4);
  align-items: start;
}
.cockpit-grid > .cockpit-preview { grid-column: 1; grid-row: 1; min-width: 0; }
.cockpit-grid > .cockpit-rest {
  grid-column: 1; grid-row: 2; min-width: 0;
  display: flex; flex-direction: column; gap: var(--space-4);
}
.cockpit-grid > .cockpit-chat {
  grid-column: 2; grid-row: 1 / span 2;   /* span the preview row + the rest stack — no row inflation */
  position: sticky; top: var(--space-4);
  align-self: start;
  display: flex; flex-direction: column;
  /* Height is set by JS (wireCockpitChat) from the chat's CURRENT top to the viewport
     bottom, so the input is never cut off at scroll-top and it grows as it sticks. This
     calc is only the pre-JS fallback. */
  height: calc(100dvh - 56px - var(--space-4) * 2);
}
.cockpit-chat > .sec-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cockpit-chat .chat-feed.mini { flex: 1 1 auto; min-height: 0; max-height: none; } /* fill the tall card */

/* Drag handle on the chat's left edge (sits in the inter-column gap). Wide only. */
.cockpit-chat-resize {
  position: absolute; top: 0; bottom: 0; left: calc(-1 * var(--space-3));
  width: var(--space-4); cursor: col-resize; z-index: 3; touch-action: none;
}
.cockpit-chat-resize::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; transform: translateX(-50%);
  background: var(--border-accent); opacity: 0;
  transition: opacity var(--dur-fast, .12s) var(--ease, ease);
}
.cockpit-chat-resize:hover::before, .cockpit-chat-resize:focus-visible::before { opacity: 1; }
.cockpit-chat-resize:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -2px; border-radius: var(--r-sm); }

/* NARROW (one column): chat sits right under the preview (2nd in source order) at
   ~50vh, no longer sticky; the rest stacks below it. */
@media (max-width: 900px) {
  .cockpit-grid { grid-template-columns: 1fr; }
  .cockpit-grid > .cockpit-preview,
  .cockpit-grid > .cockpit-rest { grid-column: 1; grid-row: auto; }
  .cockpit-grid > .cockpit-chat {
    grid-column: 1; grid-row: auto; position: static; height: auto; top: auto;
  }
  .cockpit-chat .chat-feed.mini { flex: 0 1 auto; min-height: 8rem; max-height: 50vh; }
  .cockpit-chat-resize { display: none; } /* no width drag in single-column mode */
}

/* Quick Actions — a BARE button row right under the metrics (no card wrapper). It
   mirrors the stat bar EXACTLY: same flex layout, gap, and per-item flex basis, so
   each button lines up under each metric chip. The tiles keep their own border/bg so
   they read as buttons; the strip itself has no chrome. */
.qa-strip .qa-grid { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.qa-strip .qa-tile { flex: 1 1 7rem; min-width: 7rem; flex-direction: row; justify-content: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); }
.qa-strip .qa-icon { font-size: 14px; }

/* ── Quick-action TOAST (clip URL / marker / BRB / go-live feedback). Stacked
   bottom-right, token-driven, auto-dismiss. textContent only (XSS-safe). ── */
.sec-toast-wrap {
  position: fixed; right: var(--space-4); bottom: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 60; max-width: min(92vw, 24rem); pointer-events: none;
}
.sec-toast {
  pointer-events: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-accent);
  border-radius: var(--r-sm); padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-2, 0 4px 16px rgba(0,0,0,.4));
  font-size: 13px; color: var(--text); line-height: 1.4;
}
.sec-toast.ok { border-left-color: var(--ok-soft); }
.sec-toast.err { border-left-color: var(--danger); }
.sec-toast a { color: var(--accent-soft); word-break: break-all; }

/* ── (2) STREAM PREVIEW — desktop live frame (sampler over IPC), or an honest
   desktop-only placeholder on the web. Never a fake <video>. ── */
.preview-stage {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center;
  aspect-ratio: 16 / 9; width: 100%;
  background: var(--surface-inset); border: 1px solid var(--border);
  /* NO border-radius on the stage: it clips the live <video> child, and a ROUNDED
     clip forces Chromium to re-rasterize the playing video ON THE MAIN THREAD every
     frame (no hardware-overlay fast path) → app-wide input lag while a preview is
     shown. A square overflow:hidden clip is free. (Rounding can be restored later via
     a GPU-friendly route if desired.) */
  padding: var(--space-4);
}
/* The live program frame (vcam <video> / sampler). Fills the stage edge-to-edge.
   NO border-radius — same reason as the stage: a rounded <video> can't use the cheap
   video compositing path and repaints on the main thread every frame. */
.preview-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
  /* Promote the playing <video> to its OWN compositing layer so its per-frame
     updates don't re-rasterize the dense Stream-Manager card grid around it (the
     residual lag after the rounded-corner fix). Isolates the video's paint. */
  transform: translateZ(0);
  will-change: transform;
  contain: paint;
}
.preview-empty { max-width: 28rem; }
.preview-empty-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: var(--space-2); }
.preview-info { margin-top: var(--space-3); }
.preview-info .grow { flex: 1; min-width: 0; }
.preview-info .grow .t { font-weight: 600; display: block; }
.preview-info .grow .s { font-size: 11.5px; display: block; }

/* ── (6) COLLABORATION — inline guest-invite link row (P13) ── */
.collab-invite { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-2); }
.collab-invite .inp { flex: 1 1 auto; min-width: 0; }

/* ── (3) QUICK ACTIONS — roving-tabindex tile grid ── */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: var(--space-2); }
.qa-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); padding: var(--space-3) var(--space-2);
  background: var(--surface-inset); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font: inherit; cursor: pointer;
  text-align: center; transition: border-color var(--dur-fast) var(--ease);
}
.qa-tile:hover { border-color: var(--border-accent); }
.qa-tile:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.qa-tile[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.qa-tile.is-live { border-color: rgba(255,64,64,.5); }
.qa-tile.is-live .qa-icon { color: var(--danger); }
.qa-icon { font-size: 18px; line-height: 1; }
.qa-label { font-size: 12px; font-weight: 600; }
.qa-soon { font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); }

/* ── (4) ACTIVITY FEED — newest on top, scrolls internally ── */
.activity-feed { display: flex; flex-direction: column; gap: var(--space-1); overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 40vh; min-height: 8rem; }
.activity-row { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--r-sm); font-size: 13px; }
.activity-row .pdot { margin-top: 4px; }
.activity-body { flex: 1; min-width: 0; line-height: 1.4; word-break: break-word; }
.activity-label { font-weight: 600; }
.activity-time { flex: none; margin-left: var(--space-2); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 2px; }
.activity-actor { font-weight: 600; color: var(--accent-2); margin-left: 4px; }
.activity-detail { margin-left: 4px; font-size: 12px; }

/* ── (5) MY CHAT — compact variant of the chat feed ── */
.chat-feed.mini { max-height: 36vh; min-height: 8rem; }

/* ── responsive: the multi-column cockpit collapses to one column on mobile,
   the stat bar scrolls locally so the page body never scrolls horizontally ── */
@media (max-width: 560px) {
  .stat-bar { flex-wrap: nowrap; overflow-x: auto; }
  .stat-chip { flex: 0 0 auto; }
}

/* ═══════════════════════════════════════════════════════════════════════
   T5 — Topbar notification bell + drawer (notifications.js). A shell-chrome
   enhancer, not a section: it injects a bell button (with an unread badge)
   into the .topbar and an anchored popover drawer. Tokens ONLY (no hardcoded
   color). The .menu base (shell.css) supplies the floating-popover frame;
   these classes layer the bell badge + the row list on top. The JS class
   names are the contract — do not rename.
   ═══════════════════════════════════════════════════════════════════════ */

/* anchor: position:relative so the absolutely-positioned drawer pins to the
   bell, not the topbar (mirrors .chan-switch-anchor). */
.notif-anchor { position: relative; display: inline-flex; }

/* the bell button reuses .icon-btn; the badge floats on its top-right corner. */
.notif-bell { position: relative; }
.notif-bell-icon { line-height: 1; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1;
  color: var(--text); background: var(--danger);
  border-radius: var(--r-pill);
}
.notif-badge.hide { display: none; }

/* the drawer extends the shared .menu popover (frame + shadow come from there);
   the bell sits on the topbar's RIGHT, so right:0 (the .menu default) anchors
   it correctly — no left override needed. */
.notif-drawer { width: 320px; max-width: calc(100vw - var(--space-6)); }
.notif-head {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.notif-title { font-weight: 600; color: var(--text); font-size: 13px; }
.notif-mark { font-size: 11.5px; }

.notif-list {
  display: flex; flex-direction: column;
  max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--space-1);
}
.notif-list .sec-empty {
  padding: var(--space-3); margin: 0; font-size: 12.5px;
}

.notif-row {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.notif-row + .notif-row { border-top: 1px solid var(--border); }
.notif-row.is-unread { background: var(--accent-wash); }

/* category chip — small uppercase pill; color comes from tokens per bucket so
   meaning is carried by the WORD (the chip text) as well as the hue. */
.notif-cat {
  flex: none; margin-top: 1px;
  font-size: 9px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--r-pill);
  color: var(--text); background: var(--surface-inset);
}
.notif-cat--tip { background: var(--ok); }
.notif-cat--sub { background: var(--accent); }
.notif-cat--raid { background: var(--warn); color: var(--bg); }
.notif-cat--follow { background: var(--surface-2); color: var(--accent-2); }

.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.notif-line { line-height: 1.35; word-break: break-word; }
.notif-time { font-size: 11px; }

@media (max-width: 560px) {
  .notif-drawer { width: calc(100vw - var(--space-4)); }
}

/* ═══════════════════════════════════════════════════════════════════════
   S3-sections — mobile content reflow. ADDITIVE + mobile-scoped: every rule
   below sits inside @media(max-width:560px) or @media(hover:none) so the
   desktop layout is byte-unchanged. Uses the S1 foundation tokens
   (--touch-min 44px, --fs-title, --space-*). Touch-first: comfortable hit
   targets, no row crushing, primary actions reachable, hover-only affordances
   neutralised on touch. ═══════════════════════════════════════════════════ */
@media (max-width: 560px) {
  /* (1) Inputs — comfortable height + 16px font so iOS does not zoom on focus.
     16px is an intentional iOS-zoom guard, not a design token override. */
  .input, .select, .textarea, .cs-input { min-height: var(--touch-min); font-size: 16px; }
  .textarea { min-height: 88px; }

  /* (2) Row wrapping — stack controls instead of cramping them. */
  .between { flex-wrap: wrap; }
  .sec-copyrow, .cs-copyrow { flex-wrap: wrap; }
  .sec-copyrow .input, .cs-copyrow .cs-input { flex: 1 1 100%; }
  .sec-row { flex-wrap: wrap; }
  .sec-row .sec-health { margin-left: auto; }
  .preview-info { flex-wrap: wrap; }
  .preview-info .btn { width: 100%; }

  /* (3) Buttons — every tappable control clears the 44px minimum and centres
     its label/icon vertically once it is taller than its text line. */
  .btn, .btn--sm, .seg button, .sec-retry, .subtabs button, .notif-mark {
    min-height: var(--touch-min); display: inline-flex; align-items: center;
  }
  .icon-btn { width: var(--touch-min); height: var(--touch-min); }
  .chip button { min-width: var(--touch-min); min-height: var(--touch-min); }

  /* (4) Primary action reachability — stack the inline action row and let the
     primary CTA span full width so it is a thumb-sized target at the edge. */
  .sec-actions { flex-direction: column; }
  .sec-actions .btn--primary { width: 100%; justify-content: center; }

  /* (5) List rows — let the meta wrap and drop row actions onto their own line
     so they are full-size targets instead of pinched beside the title. */
  .sec-item { flex-wrap: wrap; }
  .sec-item-actions { flex: 1 1 100%; }
  .cs-row { flex-wrap: wrap; }
  .cs-row-actions { flex: 1 1 100%; }

  /* (6) Tables — keep a usable min width so the table scrolls inside its own
     overflow-x wrapper (.sec-tablewrap) instead of crushing columns and the
     body. */
  .sec-tablewrap > .table { min-width: 30rem; }

  /* (7) Toggle — enlarge the track + recompute the knob travel for touch. */
  .toggle { width: 48px; height: 28px; }
  .toggle::after { width: 22px; height: 22px; }
  .toggle.on::after { transform: translateX(20px); }

  /* (9) Tighter content gutter + fluid heading on small screens. */
  .content { padding: var(--space-4); }
  .page-header h1 { font-size: var(--fs-title); }
}

/* (8) Hover-only chat-mod actions are a critical touch bug: on a device with no
   hover the moderate buttons would never reveal. Pin them visible and give them
   a real target. The desktop hover-reveal is preserved by scoping it to
   @media(hover:hover). */
@media (hover: hover) {
  .chat-row .chat-mod { opacity: 0; }
  .chat-row:hover .chat-mod, .chat-row:focus-within .chat-mod { opacity: 1; }
}
@media (hover: none) {
  .chat-mod { opacity: 1; }
  .chat-mod-btn { min-width: var(--touch-min); min-height: var(--touch-min); }
}
/* Coarse-pointer safety net regardless of width: the shell switches to the
   touch layout (off-canvas drawer + tab-bar) at 860px, but the 560px content
   block above only sizes inputs/sub-buttons up to 560px — leaving the 561–860px
   touch band (large phones landscape, tablets in portrait) with 13px inputs
   (iOS zoom-on-focus) and sub-44px controls. Apply the touch floor to every
   coarse-pointer width so it tracks the shell breakpoint, not just <=560px. */
@media (hover: none) and (pointer: coarse) {
  .input, .select, .textarea, .cs-input { min-height: var(--touch-min); font-size: 16px; }
  .btn, .btn--sm, .seg button, .subtabs button, .sec-retry, .notif-mark, .chip button {
    min-height: var(--touch-min);
  }
}

/* ── Studio tab strip (DD-6: Scene Designer as a tab, not a modal) ──
   A simple [Live | Scene Designer] strip switching the two Studio panes. Tokens
   only. The Designer pane hosts the embedded scene-editor (.se-embedded). */
.studio-tabs {
  display: flex;
  gap: var(--space-1, 4px);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.studio-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  margin-bottom: -1px;
}
.studio-tab:hover { color: var(--text); }
.studio-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.studio-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.studio-pane { display: none; }
.studio-pane.is-active { display: block; }
/* Host for the embedded designer — give it room; the editor sizes itself. */
.studio-designer-host { display: block; width: 100%; }

/* ── Unified input list rows (Sources consolidation) ──────────────────────────
   One flat list row per input (NO card-in-card). unifiedRowHtml() emits these:
   a device row is a single .input-row (icon · name/meta · routing · rank · acts);
   an ingest row is .input-row.input-row--ingest with a .input-row-head plus an
   .input-eps endpoint sub-list. Layout uses flex so it reflows on narrow widths.
   The container is .input-list (data-unified-list): a token-gapped flex column so
   rows — and the empty-state/loading <p> children — stack with consistent spacing. */
.input-list { display: flex; flex-direction: column; gap: var(--space-2); }
.input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
}
.input-row--ingest { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.input-row-head { display: flex; align-items: center; gap: var(--space-3); }
.input-ico { font-size: 18px; flex: none; line-height: 1; }
.input-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.input-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.input-meta { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 11.5px; color: var(--text-dim); }
.input-goes { flex: none; }
.input-rank { flex: none; display: inline-flex; align-items: center; gap: var(--space-1); font-size: 12px; color: var(--text-dim); }
.input-actions { flex: none; display: inline-flex; align-items: center; gap: var(--space-1); }
/* Endpoint sub-list inside an ingest row. */
.input-eps { display: flex; flex-direction: column; gap: var(--space-1); padding-left: calc(18px + var(--space-3)); }
.input-ep { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; }
.input-ep-slot {
  flex: none; min-width: 1.4em; text-align: center; font-family: var(--font-mono);
  font-size: 11px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 4px;
}
.input-ep-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Status dot variants for the unified row (base .dot lives in shell.css). The
   meaning is in the row text; the dot color is a redundant cue, not the only one. */
.dot--on { background: var(--ok); box-shadow: 0 0 8px rgba(0,179,0,.6); }
.dot--off { background: var(--danger); }
.dot--unknown { background: var(--text-faint); }
@media (max-width: 560px) {
  .input-row { flex-wrap: wrap; }
  .input-goes, .input-rank, .input-actions { flex: 1 1 auto; }
}

/* ── Add-Device wizard (reuses .sec-modal / .sec-modal-box) ────────────────────
   wizardStep1Html() emits .wiz-step > .wiz-opts > .wiz-opt(label) each wrapping a
   radio + .wiz-opt-body(.wiz-opt-title/.wiz-opt-sub); wizardStep2EncoderHtml()
   emits a bare .wiz-step. Card-like option rows so the type picker reads clearly. */
.wiz-step { display: flex; flex-direction: column; gap: var(--space-3); }
.wiz-opts { display: flex; flex-direction: column; gap: var(--space-2); }
.wiz-opt {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer;
}
.wiz-opt input { margin-top: 3px; flex: none; }
.wiz-opt-body { display: flex; flex-direction: column; gap: 2px; }
.wiz-opt-title { font-weight: 600; }
.wiz-opt-sub { font-size: 12px; color: var(--text-dim); }
