/* ========== Dragonflight Design System — v4 "Reel / BMG" ==========
   Editorial / cinematic. Content floats on true cinema black; structure comes
   from hairline rules and generous space, not boxes. Montserrat runs headings,
   Nunito runs body and numerics (tabular figures keep columns aligned without
   a monospace face). One brand accent — BMG red — used sparingly. */
:root {
  /* ── Surfaces ──────────────────────────────────────────────────────────
     Cinema near-black. A shallow ladder — we lift with light and rules, not
     stacked gray boxes. Faint cool-neutral cast; barely-there warmth as it
     rises so raised chrome reads as "lit film" not "gray card". */
  --bg-0: #08090C;   /* the void — the room is dark */
  --bg-1: #0C0E12;   /* sidebar / chrome — a shade off the void */
  --bg-2: #111318;   /* panels — content plane */
  --bg-3: #181B22;   /* raised inputs / hover-fill */
  --bg-4: #22262F;   /* pop surfaces / active */

  --hover: rgba(255,255,255,0.028);
  --hover-strong: rgba(255,255,255,0.055);

  /* Hairlines. The workhorse of this system — most separation is a 1px rule. */
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --border-stronger: rgba(255,255,255,0.20);
  --rule: rgba(255,255,255,0.08);   /* editorial divider rules */

  /* ── Text ──────────────────────────────────────────────────────────────
     Warm-neutral ivory ramp (not clinical blue-white) — reads editorial, like
     ink on film. All pass WCAG AA on --bg-0. */
  --text-1: #F6F4EF;   /* headline ivory */
  --text-2: #B4B0A6;   /* body / secondary */
  --text-3: #86837B;   /* labels / tertiary (AA) */
  --text-4: #63615B;   /* faint / disabled */

  /* ── Accent — BMG brand red ───────────────────────────────────────────
     Red is the brand accent. Live/on-air keeps its OWN token (--live) so the
     two never collapse: an idle control uses --accent, and only a genuinely
     recording one turns --live. The record pip is blue while idle for exactly
     this reason — see .rec-dot in styles-rest.css. */
  --accent: #EC1313;
  --accent-hover: #FF2727;
  --accent-soft: rgba(236, 19, 19, 0.14);
  --accent-soft-2: rgba(236, 19, 19, 0.22);
  /* Rose-shifted, not a plain lighten — a lightened EC1313 lands almost on
     top of --live's FF3B30 and "SELECTED" would read as "LIVE". */
  --accent-text: #FF465C;
  /* Idle/armed signal colour: blue, so "ready to record" is unmistakably not
     "recording". Used by the record pip and armed states. */
  --idle-signal: #5B7CFA;

  /* ── Status ────────────────────────────────────────────────────────────
     Muted, filmic signal colours — present, never neon. */
  --success: #5FBF97;
  --success-soft: rgba(95, 191, 151, 0.12);
  --warning: #E6A93C;
  --warning-soft: rgba(230, 169, 60, 0.12);
  --danger: #E86A6A;
  --danger-soft: rgba(232, 106, 106, 0.12);
  --live: #FF3B30;             /* on-air red — never reassigned */
  --live-soft: rgba(255, 59, 48, 0.16);
  --purple: #A98BE0;
  --purple-soft: rgba(169, 139, 224, 0.12);
  --info: #6FA8DA;
  --info-soft: rgba(111, 168, 218, 0.12);

  /* Text ink for solid-accent surfaces (.btn.primary, .brand-mark). BMG red
     is dark/saturated in both themes (unlike the old blue), so both need
     light ink; dark-mode ink is the headline ivory (never pure #fff). */
  --btn-primary-text: #F6F4EF;
  --surface-2: rgba(255, 255, 255, 0.03);   /* orphan token used via var(--surface-2, hex) fallbacks — defined for real now */

  /* ── Radius ────────────────────────────────────────────────────────────
     Restrained. Editorial surfaces are nearly square; only media/pop get soft. */
  --r-xs: 3px;
  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 22px;

  /* Video/monitor surfaces stay black in BOTH themes — a light-mode player
     letterbox would blow out the operator's eye against the picture. */
  --media-bg: #000;

  /* ── Elevation ─────────────────────────────────────────────────────────
     Deep, soft, diffuse — cinema shadows. Content rises quietly. */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-raise: 0 4px 12px rgba(0,0,0,0.4),
                  0 1px 3px rgba(0,0,0,0.3);
  --shadow-pop: 0 12px 40px rgba(0,0,0,0.55),
                0 32px 80px rgba(0,0,0,0.45);
  --glow-accent: 0 0 0 1px var(--accent-soft-2);
  --glow-live: 0 0 0 1px var(--live-soft);

  /* ── Motion ────────────────────────────────────────────────────────────
     Cinematic ease — slow-in, confident settle. */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms;
  --t-med: 240ms;
  --t-slow: 420ms;

  /* ── Sizing ────────────────────────────────────────────────────────── */
  --sidebar-w: 244px;
  --row-h: 44px;
  --topbar-h: 60px;
  --gap: 16px;

  /* ── Type scale ──────────────────────────────────────────────────────────
     Canonical 7-step ladder. The UI had ~18 ad-hoc font sizes (every half-px
     from 8 → 15); these tokens are the sanctioned steps. New/edited code uses
     var(--fs-*); the values snap the old sprawl to the nearest rung.
       2xs micro-labels · xs dense meta · sm secondary · base body ·
       md emphasis · lg subhead · xl/2xl display */
  --fs-2xs: 10px;    /* uppercase eyebrows, chips, dense numerics */
  --fs-xs:  11px;    /* table sub-cells, captions */
  --fs-sm:  12px;    /* secondary text, compact controls */
  --fs-base:13px;    /* default body / control text */
  --fs-md:  14px;    /* emphasized body, list titles */
  --fs-lg:  16px;    /* panel / section headings */
  --fs-xl:  20px;    /* screen titles */
  --fs-2xl: 28px;    /* hero display */

  /* ── Spacing scale (4px base) ─────────────────────────────────────────── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;  --sp-10: 40px;

  /* ── Type families ───────────────────────────────────────────────────── */
  /* BMG brand guide: Montserrat for headings/subheadings, Nunito for body.
     No monospace face is specified; numerics keep column alignment via
     font-variant-numeric: tabular-nums (see .mono/.tabular) rather than a
     dedicated mono face. */
  --font-heading: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-sans: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* --font-serif intentionally aliases sans — display uses sans, not a serif */
  --font-serif: var(--font-sans);

  --tracking-eyebrow: 0.16em;   /* uppercase section eyebrows */
}

/* density tweak */
[data-density="compact"] {
  --row-h: 36px;
  --topbar-h: 48px;
  --gap: 12px;
}

/* ── Light theme ─────────────────────────────────────────────────────────
   Every surface in this app reads var(--bg-*) / var(--text-*) / var(--border*),
   so inverting the ramp here re-themes the whole UI without touching a single
   component. Accent + status hues are darkened slightly to hold WCAG AA
   contrast against a light ground (the dark-mode values are tuned for #08090C
   and go muddy on white).
   ponytail: token remap only — components that hardcode a hex (media letterbox,
   on-air red) intentionally stay as they are. */
[data-theme="light"] {
  --bg-0: #FFFFFF;   /* page ground */
  --bg-1: #F7F7F5;   /* sidebar / chrome */
  --bg-2: #FFFFFF;   /* panels — content plane */
  --bg-3: #F0F0ED;   /* raised inputs / hover-fill */
  --bg-4: #E4E4E0;   /* pop surfaces / active */

  --hover: rgba(0,0,0,0.035);
  --hover-strong: rgba(0,0,0,0.065);

  --border: rgba(0,0,0,0.16);
  --border-strong: rgba(0,0,0,0.42);
  --border-stronger: rgba(0,0,0,0.55);
  --rule: rgba(0,0,0,0.14);

  --text-1: #16171A;   /* headline ink */
  --text-2: #45474D;   /* body / secondary */
  --text-3: #6B6E75;   /* labels / tertiary (AA on white) */
  --text-4: #9095A0;   /* faint / disabled */

  /* Digital red (#c61010) on white: clears AA on its own (~6:1) and reads
     calmer at this density than the brighter black-background red. */
  --accent: #c61010;
  --accent-hover: #9E0D0D;
  --accent-soft: rgba(198, 16, 16, 0.10);
  --accent-soft-2: rgba(198, 16, 16, 0.18);
  --accent-text: #9E0D0D;
  /* Darker idle blue for AA on white (~5.2:1). */
  --idle-signal: #3B5BDB;

  --success: #1F8A5F;
  --success-soft: rgba(31, 138, 95, 0.12);
  --warning: #9A6510;
  --warning-soft: rgba(154, 101, 16, 0.14);
  --danger: #C13333;
  --danger-soft: rgba(193, 51, 51, 0.12);
  --live: #D8271C;             /* on-air red — still unmistakably red */
  --live-soft: rgba(216, 39, 28, 0.14);
  --purple: #6C4BC0;
  --purple-soft: rgba(108, 75, 192, 0.12);
  --info: #2A6C9E;
  --info-soft: rgba(42, 108, 158, 0.12);

  --btn-primary-text: #FFF8F7;   /* near-white, warm-red tinted — accent is a dark saturated red here */
  --surface-2: rgba(0, 0, 0, 0.03);

  /* Shadows: on white, deep cinema shadows read as smudges. */
  --shadow-card: 0 1px 2px rgba(16,17,20,0.07);
  --shadow-raise: 0 4px 12px rgba(16,17,20,0.09),
                  0 1px 3px rgba(16,17,20,0.06);
  --shadow-pop: 0 12px 40px rgba(16,17,20,0.16),
                0 32px 80px rgba(16,17,20,0.10);

  color-scheme: light;   /* native scrollbars/form controls follow */
}

[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11", "cv05";
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* Faint film-grain texture on the void — reads as cinema, not flat #000.
   Pure CSS (no asset): a low-opacity repeating noise via layered gradients. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background:
    radial-gradient(1400px 700px at 82% -8%, rgba(236,19,19,0.025), transparent 62%);
}

/* ── Editorial display typography ──────────────────────────────────────────
   The single strongest signal that this isn't a stock dark dashboard. Serif
   for headline moments; tight optical tracking; ivory ink. */
.display,
.editorial-h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.05;
  color: var(--text-1);
}
.editorial-h1 { font-size: clamp(26px, 3vw, 40px); }
.editorial-h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-1);
}
/* Uppercase tracked eyebrow — editorial section marker */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-3);
}
/* All numerics, timecodes, IDs read in mono with tabular figures */
.mono, .tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.app, .main, #root { position: relative; z-index: 1; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 99px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ========== Layout ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  background: var(--bg-0);
}
.app[data-sidebar="collapsed"] { --sidebar-w: 56px; }

/* ========== Sidebar (editorial rail) ========== */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 11px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text-1);
}
.brand-logo { width: 26px; height: 26px; object-fit: contain; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background:
    linear-gradient(150deg, var(--accent-hover) 0%, var(--accent) 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--btn-primary-text);
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px var(--accent-soft-2) inset,
    0 2px 8px rgba(0,0,0,0.4),
    0 0 16px var(--accent-soft);
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 14px;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-4);
  padding: 18px 12px 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  height: 34px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 450;
  letter-spacing: -0.008em;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  position: relative;
}
.nav-item:hover {
  background: var(--hover);
  color: var(--text-1);
}
/* Active = ivory text + a hairline accent bar at the left edge (editorial
   marginalia), not a filled pill. Quiet, confident. */
.nav-item.active {
  background: transparent;
  color: var(--text-1);
  font-weight: 500;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 18px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft-2);
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item.has-children > .nav-caret {
  margin-left: auto;
  opacity: 0.5;
  transition: transform 120ms;
}
.nav-item.has-children.open > .nav-caret { transform: rotate(90deg); }
.nav-icon {
  width: 16px; height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
}
.nav-item:hover .nav-icon { color: var(--text-2); }
.nav-children {
  margin: 2px 0 4px 22px;
  border-left: 1px solid var(--border-strong);
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-children .nav-item {
  height: 28px;
  font-size: 12.5px;
  font-weight: 450;
}
.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 99px;
  line-height: 1.5;
}
.nav-badge.dev,
.nav-badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}
.nav-badge.danger {
  color: #fff;
  background: var(--live);
  font-weight: 700;
}
.nav-badge.neutral {
  color: var(--text-2);
  background: var(--bg-3);
}
.nav-badge.live {
  color: var(--live);
  background: var(--live-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-badge.live::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 2px var(--live-soft);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }
.user-meta .user-name, .user-meta .user-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== Top bar ========== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
.crumb {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 13px;
  color: var(--text-3);
}
.crumb .sep { color: var(--text-4); opacity: 0.6; }
/* Current page reads as an editorial header, not just bold breadcrumb text */
.crumb .current {
  color: var(--text-1);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.topbar .spacer { flex: 1; }
.topbar-project-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  height: 28px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
}
.topbar-project-chip:hover { border-color: var(--accent-soft-2); background: var(--bg-3); }
.topbar-project-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.topbar-project-chip-x {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.topbar-project-chip-x:hover { background: var(--hover-strong); color: var(--text-1); }
.status-pip {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.status-pip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-pip.warn .dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* Impersonation session strip — always visible while session is swapped */
.impersonate-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--warning-soft);
  border-bottom: 1px solid var(--warning);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-weight: 550;
}
.impersonate-banner strong { color: var(--warning); }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-2);
  transition: background 80ms, color 80ms;
}
.icon-btn:hover { background: var(--hover); color: var(--text-1); }
.icon-btn svg { width: 16px; height: 16px; }

.search {
  position: relative;
  height: 32px;
  width: 280px;
  display: flex; align-items: center;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 12px 0 32px;
  color: var(--text-2);
  font-size: 12.5px;
  transition: border 80ms, background 80ms;
}
.search:focus-within {
  border-color: var(--accent);
  background: var(--bg-2);
}
.search input { flex: 1; outline: 0; border: 0; background: transparent; min-width: 0; }
.search .search-icon {
  position: absolute;
  left: 10px;
  width: 14px; height: 14px;
  color: var(--text-3);
}
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.2;
}

/* ========== Buttons ========== */
.btn {
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  font-weight: 550;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  color: var(--btn-primary-text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.28) inset,
              0 2px 8px var(--accent-soft-2);
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-hover));
  box-shadow: 0 1px 0 rgba(255,255,255,0.32) inset,
              0 3px 12px var(--accent-soft-2);
}
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text-1); }
.btn.subtle { background: var(--bg-3); color: var(--text-1); border-color: var(--border); }
.btn.subtle:hover { background: var(--bg-4); border-color: var(--border-strong); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,97,97,0.22); }
.btn.danger:hover { background: rgba(255,97,97,0.22); border-color: rgba(255,97,97,0.4); }
.btn svg { width: 14px; height: 14px; }
.btn.lg { height: 37px; padding: 0 17px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn.sm { height: 27px; padding: 0 11px; font-size: var(--fs-sm); }
.btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent-soft-2); outline-offset: 2px; }

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge.live { background: var(--live-soft); color: var(--live); }
.badge.live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 2px var(--live-soft); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.neutral { background: var(--bg-3); color: var(--text-2); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
/* Outline badge that sits on top of media (thumbnail corners) — needs a
   readable scrim + light text against arbitrary frame content. Replaces the
   ad-hoc inline rgba(0,0,0,0.4)/#fff overrides on home + ingest tiles. */
.badge.outline.on-media {
  background: rgba(8, 9, 12, 0.62);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text-1);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.badge.accent.on-media {
  background: var(--accent-soft-2);
  color: var(--accent-text);
  border: 1px solid transparent;
}

/* ========== Cards / Panels ========== */
.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.018), transparent 120px),
    var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.panel-header {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-body { padding: 16px; }

/* ========== Page chrome ========== */
.page {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.page-header {
  padding: 24px 28px 8px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.page-header h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-header .subtitle {
  color: var(--text-3);
  font-size: 13px;
}
.page-header .spacer { flex: 1; }
.page-body { padding: 16px 28px 40px; }

/* ========== Generic utility ========== */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.muted { color: var(--text-3); }
.subtle-text { color: var(--text-2); font-size: 12.5px; }
.mono { font-family: var(--font-mono); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 200ms ease both; }

[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-4);
  color: var(--text-1);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  border: 1px solid var(--border-strong);
}

/* ========== App version badge ========== */
.app-version {
  position: fixed;
  bottom: 8px;
  left: 0;
  width: var(--sidebar-w, 232px);
  text-align: center;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-4);  /* uses the now-AA-compliant token; no opacity reduction */
  pointer-events: none;
  user-select: none;
  z-index: 10;
}
