/* © Lakshya Badjatya — Author */
/*
  FRIDAY HUD — styles for the "viewing space" cockpit.

  No build step, no framework, no network assets: one hand-written stylesheet.
  The shell is a slim left rail + one large main canvas that shows exactly one
  view at a time. The aesthetic is a calm, premium FRIDAY: a dark cyan/gold
  palette with crisp 1px borders, soft glows, generous whitespace and a single
  consistent spacing/type/radius system (the custom properties below are used
  EVERYWHERE — no scattered magic numbers). A light particle field and a brief
  arc-reactor boot are the only motion, and both are disabled under
  prefers-reduced-motion / on small screens.
*/

:root {
  /* palette — FRIDAY OS: deep-space black, hard cyan reactor glow.
     Warmed a touch — the old blue-black felt clinical at 2am, so the neutrals
     carry a hair less blue and the ink is a softer white. Subtle on purpose;
     the cyan still owns the room. */
  --bg: #05070c;
  --bg-2: #080c14;
  --surface: #0c111c;
  --surface-2: #101622;
  --surface-3: #152234;
  --ink: #e3ebf6;
  --ink-2: #aab8c9;
  --ink-dim: #5d738c;
  --cyan: #4fe3ff;
  --cyan-2: #2bb7d6;
  --cyan-soft: rgba(79, 227, 255, 0.42);
  --cyan-faint: rgba(79, 227, 255, 0.12);
  --cyan-rgb: 79, 227, 255; /* for runtime alpha compositing in fx */
  --gold: #ffce73;
  --gold-soft: rgba(255, 206, 115, 0.4);
  --danger: #ff6b78;
  --danger-soft: rgba(255, 107, 120, 0.4);
  --ok: #5fe6a6;
  --ok-soft: rgba(95, 230, 166, 0.4);
  --line: #18253c;
  --line-2: #243653;

  /* ---- FRIDAY OS effect tokens (consumed by the MAXIMAL FX section) ---- */
  --accent: var(--cyan);              /* semantic alias for the live accent */
  --accent-rgb: var(--cyan-rgb);
  --glow-strong: 0 0 18px rgba(var(--accent-rgb), 0.55), 0 0 42px rgba(var(--accent-rgb), 0.22);
  --glow-text: 0 0 10px rgba(var(--accent-rgb), 0.55);
  --scan: rgba(var(--accent-rgb), 0.05);   /* CRT scanline ink */
  --grid: rgba(var(--accent-rgb), 0.045);  /* engineering-grid ink */
  --bracket: var(--accent);                /* holo-frame corner brackets */
  --chamfer: 14px;                          /* machined-panel notch size */
  --chamfer-sm: 9px;
  --level: 0;                               /* audio-reactive reactor 0..1 (set by fx) */

  /* spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48 */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* type scale: 9 / 10 / 12 / 13 / 15 / 18 / 24 / 32
     (--t-00 / --t-0 are the micro-caption + tiny-tag steps used by chips,
     badges and table micro-labels — everything sits on the scale.) */
  --t-00: 9px;
  --t-0: 10px;
  --t-1: 12px;
  --t-2: 13px;
  --t-3: 15px;
  --t-4: 18px;
  --t-5: 24px;
  --t-6: 32px;

  /* radius scale — nudged up a touch so chips/buttons/cards feel friendlier.
     (The machined --chamfer panels keep their hard notch; this only softens
     the round-cornered bits.) */
  --r-1: 10px;
  --r-2: 14px;
  --r-3: 18px;
  --r-pill: 999px;

  --rail-w: 240px;
  --glow: 0 0 0 1px var(--cyan-faint), 0 8px 30px rgba(0, 0, 0, 0.45);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--cyan-soft);

  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* --- Theme variants -------------------------------------------------------- *
 * Applied via data-theme on <html> (hud.js persists the choice in
 * localStorage). The default — no attribute — is the cyan arc-reactor palette
 * in :root above; each variant only re-points the accent + (for "light") the
 * surface tokens, so every component re-skins through the existing var()s. */
[data-theme="amber"] {
  --cyan: #ffb347;
  --cyan-2: #d9852b;
  --cyan-soft: rgba(255, 179, 71, 0.42);
  --cyan-faint: rgba(255, 179, 71, 0.12);
  --cyan-rgb: 255, 179, 71;
  --gold: #4fe3ff;
  --gold-soft: rgba(79, 227, 255, 0.4);
}
[data-theme="crimson"] {
  --cyan: #ff3b52;
  --cyan-2: #d6213a;
  --cyan-soft: rgba(255, 59, 82, 0.45);
  --cyan-faint: rgba(255, 59, 82, 0.13);
  --cyan-rgb: 255, 59, 82;
  --gold: #4fe3ff;
}
[data-theme="emerald"] {
  --cyan: #43f0a0;
  --cyan-2: #1fb778;
  --cyan-soft: rgba(67, 240, 160, 0.42);
  --cyan-faint: rgba(67, 240, 160, 0.12);
  --cyan-rgb: 67, 240, 160;
  --gold: #ffce73;
}
[data-theme="light"] {
  --cyan-rgb: 10, 132, 199;
  --bg: #eef3fb;
  --bg-2: #e4ecf7;
  --surface: #ffffff;
  --surface-2: #f3f7fd;
  --surface-3: #e9f0fa;
  --ink: #0b1220;
  --ink-2: #34465c;
  --ink-dim: #6a7d93;
  --cyan: #0a84c7;
  --cyan-2: #086a9f;
  --cyan-soft: rgba(10, 132, 199, 0.35);
  --cyan-faint: rgba(10, 132, 199, 0.1);
  --line: #cdd9ea;
  --line-2: #b6c6dd;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(1200px 820px at 16% -10%, rgba(var(--accent-rgb), 0.1) 0%, rgba(0, 0, 0, 0) 58%),
    radial-gradient(900px 720px at 102% 4%, rgba(var(--accent-rgb), 0.06) 0%, rgba(0, 0, 0, 0) 55%),
    radial-gradient(1400px 1000px at 50% 120%, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--t-2);
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* light drifting particle field behind everything */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}

/* ============================================================ LEFT RAIL ==== */
#rail {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-4);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 18, 32, 0.92), rgba(8, 13, 24, 0.92));
  backdrop-filter: blur(6px);
  min-height: 0;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-2);
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: inline-block;
}
.brand-mark .bm-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--cyan-soft);
  border-top-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-faint);
  animation: spin 8s linear infinite;
}
.brand-mark .bm-core {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #eafcff, var(--cyan) 55%, #0a3a52);
  box-shadow: 0 0 10px var(--cyan), inset 0 0 6px #fff;
}

.brand-word {
  font-size: var(--t-4);
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--ink);
}

.rail-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  flex: 1;
  min-height: 0;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-2);
  letter-spacing: 0.06em;
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.rail-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.rail-item .ri-glyph {
  flex: 0 0 auto;
  width: 20px;
  text-align: center;
  font-size: var(--t-3);
  color: var(--ink-dim);
  transition: color 160ms ease;
}
.rail-item[aria-selected="true"] {
  background: var(--cyan-faint);
  border-color: var(--cyan-soft);
  color: var(--ink);
}
.rail-item[aria-selected="true"] .ri-glyph {
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-soft);
}

.rail-foot {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.brain-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--gold);
  font-size: var(--t-1);
  letter-spacing: 0.08em;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.brain-pill:hover {
  border-color: var(--gold-soft);
  box-shadow: 0 0 14px rgba(255, 206, 115, 0.18);
}
.brain-pill .bp-glyph {
  font-size: var(--t-2);
}
.brain-pill .bp-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--t-1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.conn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-dim);
  box-shadow: 0 0 8px currentColor;
}
.conn.is-online {
  color: var(--ok);
  border-color: var(--ok-soft);
}
.conn.is-online .dot {
  background: var(--ok);
}
.conn.is-offline {
  color: var(--danger);
  border-color: var(--danger-soft);
}
.conn.is-offline .dot {
  background: var(--danger);
}

/* =========================================================== MAIN CANVAS === */
#canvas {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.view {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: var(--s-6) var(--s-6) 0;
}
.view.is-active {
  display: flex;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
  flex: 0 0 auto;
}
.vh-title {
  margin: 0;
  font-size: var(--t-5);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.vh-sub {
  margin: var(--s-1) 0 0;
  font-size: var(--t-2);
  color: var(--ink-dim);
}
.vh-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 0 0 auto;
}

.kbd-hint {
  font-size: var(--t-1);
  color: var(--ink-dim);
  letter-spacing: 0.08em;
}
.kbd-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--cyan);
  font: inherit;
  font-size: var(--t-1);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  background: var(--surface-2);
  color: var(--cyan);
  font-size: var(--t-3);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.icon-btn:hover {
  border-color: var(--cyan-soft);
  box-shadow: 0 0 14px var(--cyan-faint);
  background: var(--surface-3);
}
.icon-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.icon-btn.mic.is-listening {
  border-color: var(--danger);
  color: var(--danger);
  animation: micPulse 1.3s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 8px var(--danger-soft); }
  50% { box-shadow: 0 0 20px rgba(255, 107, 120, 0.6); }
}

/* The body of a non-Command view scrolls; the head stays put. */
.view-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

/* ----------------------------------------------------- one card / panel --- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  padding: var(--s-5);
}
.panel-h {
  margin: 0 0 var(--s-4);
  font-size: var(--t-1);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.panel-hint {
  margin: 0 0 var(--s-4);
  font-size: var(--t-1);
  color: var(--ink-dim);
}
.panel-body {
  font-size: var(--t-2);
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.panel-tag {
  font-size: var(--t-0);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 1px 7px;
}
.panel-empty {
  font-size: var(--t-2);
  color: var(--ink-dim);
  padding: var(--s-3) 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
  padding: var(--s-4);
  animation: cardIn 240ms ease both;
}
.card.loading { opacity: 0.8; }
.card.err { border-color: var(--danger-soft); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.card-title {
  font-size: var(--t-2);
  color: var(--cyan);
  word-break: break-word;
}
.card-meta {
  font-size: var(--t-0);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  flex: 0 0 auto;
}
.card-body {
  font-size: var(--t-2);
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.send-btn {
  padding: 0 var(--s-5);
  height: 38px;
  border: 1px solid var(--cyan-soft);
  border-radius: var(--r-1);
  background: var(--cyan-faint);
  color: var(--cyan);
  font-size: var(--t-2);
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.send-btn:hover:not(:disabled) {
  background: rgba(79, 227, 255, 0.2);
  box-shadow: 0 0 16px var(--cyan-faint);
}
.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-input,
.searchbox input {
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  background: var(--bg-2);
  color: var(--ink);
  font-size: var(--t-2);
  padding: var(--s-2) var(--s-3);
  height: 38px;
  outline: none;
}
.filter-input { width: 220px; }
.filter-input::placeholder,
.searchbox input::placeholder { color: var(--ink-dim); }

/* ============================================================== COMMAND ==== */
.command-col {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--ink-dim);
  font-size: var(--t-2);
  max-width: 420px;
}
.chat-empty strong {
  display: block;
  color: var(--ink-2);
  font-size: var(--t-3);
  margin-bottom: var(--s-2);
}

.turn {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 86%;
  animation: cardIn 220ms ease both;
}
.turn.user {
  align-self: flex-end;
  align-items: flex-end;
}
.turn.friday {
  align-self: flex-start;
  align-items: flex-start;
}
.turn-bubble {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-2);
  font-size: var(--t-3);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.turn.user .turn-bubble {
  background: var(--cyan-faint);
  border: 1px solid var(--cyan-soft);
  color: var(--ink);
  border-bottom-right-radius: var(--s-1);
}
.turn.friday .turn-bubble {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: var(--s-1);
}
.turn.pending .turn-bubble { color: var(--ink-dim); }
.turn.err .turn-bubble { border-color: var(--danger-soft); color: var(--danger); }

.route-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-0);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 var(--s-1);
}
.route-chip b { color: var(--cyan); font-weight: 600; }
.route-chip .rc-conf { color: var(--gold); }

/* inline approval card inside the chat log */
.approval {
  align-self: flex-start;
  width: min(100%, 560px);
  border: 1px solid var(--gold-soft);
  border-radius: var(--r-2);
  background: var(--surface-2);
  padding: var(--s-4);
  box-shadow: 0 0 22px rgba(255, 206, 115, 0.12);
  animation: cardIn 220ms ease both;
}
.approval.resolved { border-color: var(--ok-soft); opacity: 0.92; }
.approval.denied { border-color: var(--danger-soft); opacity: 0.85; }
.approval .ap-title {
  font-size: var(--t-2);
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: var(--s-2);
}
.approval .ap-body {
  font-size: var(--t-2);
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}
.approval .ap-detail {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-1);
  background: var(--bg-2);
}
.approval .ap-detail .kv {
  font-size: var(--t-1);
  color: var(--ink-2);
  line-height: 1.7;
  word-break: break-word;
}
.ap-actions {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.btn {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  font-size: var(--t-1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--surface-3);
  color: var(--ink);
  transition: box-shadow 150ms ease, border-color 150ms ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.approve { border-color: var(--ok-soft); color: var(--ok); }
.btn.approve:hover:not(:disabled) { box-shadow: 0 0 14px var(--ok-soft); }
.btn.deny { border-color: var(--danger-soft); color: var(--danger); }
.btn.deny:hover:not(:disabled) { box-shadow: 0 0 14px var(--danger-soft); }
.btn.undo { border-color: var(--line-2); color: var(--ink-2); }

/* composer */
.composer {
  flex: 0 0 auto;
  padding: var(--s-3) 0 var(--s-5);
}
.address-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--cyan-soft);
  border-radius: var(--r-pill);
  background: var(--cyan-faint);
  font-size: var(--t-1);
  letter-spacing: 0.06em;
  color: var(--cyan);
}
.address-chip[hidden] { display: none; }
.address-chip .ac-arrow { color: var(--ink-dim); }
.address-chip .ac-clear {
  border: 0;
  background: none;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: var(--t-1);
  padding: 0 2px;
}
.address-chip .ac-clear:hover { color: var(--cyan); }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  padding: var(--s-2);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.composer-row:focus-within {
  border-color: var(--cyan-soft);
  box-shadow: 0 0 0 1px var(--cyan-faint);
}
.composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-size: var(--t-3);
  line-height: 1.5;
  padding: var(--s-2) var(--s-2);
  max-height: 200px;
}
.composer-input::placeholder { color: var(--ink-dim); }
.composer .send-btn { height: 38px; }

/* ================================================================ ARENA ==== */
.arena-setup { display: flex; flex-direction: column; gap: var(--s-4); }
.arena-prompt {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  background: var(--bg-2);
  color: var(--ink);
  font-size: var(--t-3);
  line-height: 1.5;
  padding: var(--s-3);
  resize: vertical;
  outline: none;
}
.arena-prompt::placeholder { color: var(--ink-dim); }
.arena-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.arena-models {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  flex: 1;
  min-width: 200px;
}
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--t-1);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.model-chip:hover { border-color: var(--cyan-soft); }
.model-chip input { accent-color: var(--cyan); margin: 0; }
.model-chip.is-on { border-color: var(--cyan-soft); color: var(--ink); background: var(--cyan-faint); }
.model-chip .mc-free {
  font-size: var(--t-00);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
}
.arena-actions { display: flex; align-items: center; gap: var(--s-4); }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-2);
  color: var(--ink-2);
  cursor: pointer;
}
.toggle input { accent-color: var(--cyan); }

.arena-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-4);
}
.arena-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  padding: var(--s-4);
  animation: cardIn 240ms ease both;
}
.arena-card.loading { opacity: 0.8; }
.arena-card.err { border-color: var(--danger-soft); }
.arena-card.winner {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(255, 206, 115, 0.18);
}
.arena-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}
.ac-label { font-size: var(--t-2); color: var(--cyan); word-break: break-word; }
.ac-free {
  font-size: var(--t-00);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
  border: 1px solid var(--ok-soft);
  border-radius: 5px;
  padding: 0 5px;
}
.ac-best {
  font-size: var(--t-1);
  letter-spacing: 0.08em;
  color: var(--gold);
}
.ac-text {
  font-size: var(--t-2);
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}
.arena-card.err .ac-text { color: var(--danger); }
.ac-foot {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-1);
  color: var(--ink-dim);
}
.ac-lat { color: var(--cyan); }

/* =============================================================== AGENTS ==== */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-4);
}
.agent-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  padding: var(--s-4);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}
.agent-card:hover {
  border-color: var(--cyan-soft);
  box-shadow: 0 0 16px var(--cyan-faint);
  transform: translateY(-2px);
}
.agent-card.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan-soft), 0 0 18px var(--cyan-faint);
}
.agent-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a4058;
  flex: 0 0 auto;
  transition: background 220ms ease, box-shadow 220ms ease;
}
.agent-card.is-active .agent-dot {
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok-soft);
  animation: dotPulse 1.8s ease-in-out infinite;
}
.agent-name {
  font-size: var(--t-2);
  letter-spacing: 0.1em;
  color: var(--cyan);
}
.agent-title { font-size: var(--t-2); color: var(--ink-2); }
.agent-scope {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-1);
}
.scope-tag {
  font-size: var(--t-0);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 8px var(--ok-soft); }
  50% { box-shadow: 0 0 16px var(--ok); }
}

/* =============================================================== MEMORY ==== */
.searchbox {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.searchbox input { flex: 1; min-width: 0; }
.searchbox input:focus { border-color: var(--cyan-soft); box-shadow: 0 0 0 1px var(--cyan-faint); }

.rag-sources { display: flex; flex-direction: column; gap: var(--s-2); }
.rag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
  font-size: var(--t-2);
}
.rag-id { color: var(--ink); word-break: break-all; }
.rag-del {
  border: 1px solid var(--danger-soft);
  background: transparent;
  color: var(--danger);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: var(--t-1);
  cursor: pointer;
}
.rag-del:hover { box-shadow: 0 0 10px var(--danger-soft); }

.chip-wrap { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.entity-chip {
  font-size: var(--t-1);
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
}

.journal-list { display: flex; flex-direction: column; gap: var(--s-2); }
.journal-row {
  padding: var(--s-3);
  border-left: 2px solid var(--cyan-soft);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  background: var(--surface-2);
  font-size: var(--t-2);
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* =============================================================== SYSTEM ==== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-4);
}
.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  padding: var(--s-4) var(--s-5);
}
.mc-label {
  font-size: var(--t-1);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.mc-value {
  font-size: var(--t-6);
  color: var(--cyan);
  text-shadow: 0 0 14px var(--cyan-faint);
  line-height: 1;
}

.sys-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}

.sysstats { display: flex; flex-direction: column; gap: var(--s-2); }
.sys-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: var(--s-3);
}
.sys-name { font-size: var(--t-1); color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.1em; }
.sys-bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.sys-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  transition: width 400ms ease;
}
.sys-val { font-size: var(--t-1); color: var(--cyan); }
.sysalerts { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }
.sys-alert {
  font-size: var(--t-1);
  padding: var(--s-2) var(--s-3);
  border-left: 2px solid var(--danger);
  background: var(--surface-2);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  color: var(--danger);
}

.by-mode { display: flex; flex-direction: column; gap: var(--s-2); }
.mode-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: var(--s-3);
}
.mode-name {
  font-size: var(--t-1);
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mode-bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.mode-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  box-shadow: 0 0 8px var(--cyan-faint);
  transition: width 400ms ease;
}
.mode-count { font-size: var(--t-1); color: var(--cyan); }

.badge {
  font-size: var(--t-00);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
}
.badge.is-ok { color: var(--ok); border-color: var(--ok-soft); }
.badge.is-bad {
  color: var(--danger);
  border-color: var(--danger-soft);
  animation: badgeAlarm 1.2s ease-in-out infinite;
}
@keyframes badgeAlarm {
  0%, 100% { box-shadow: 0 0 6px var(--danger-soft); }
  50% { box-shadow: 0 0 16px rgba(255, 107, 120, 0.6); }
}

.audit-list { display: flex; flex-direction: column; gap: var(--s-1); }
.audit-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--t-1);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
  background: var(--surface-2);
  border-left: 2px solid #2a4058;
}
.audit-row.ok { border-left-color: var(--ok); }
.audit-row.err { border-left-color: var(--danger); }
.audit-tool { color: var(--ink); }
.audit-ok { color: var(--ok); }
.audit-row.err .audit-ok { color: var(--danger); }

.flow-list { display: flex; flex-direction: column; gap: var(--s-2); }
.flow {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-align: left;
  width: 100%;
  padding: var(--s-3);
  border-radius: var(--r-1);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.flow:hover { border-color: var(--cyan-soft); box-shadow: 0 0 14px var(--cyan-faint); }
.flow-head { display: flex; align-items: baseline; gap: var(--s-3); }
.flow-mode { font-size: var(--t-2); color: var(--cyan); letter-spacing: 0.08em; }
.flow-cid { font-size: var(--t-1); color: var(--ink-dim); }
.flow-pipe { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); }
.flow-step {
  font-size: var(--t-1);
  color: var(--ink-2);
  padding: 2px var(--s-2);
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
}
.flow-step.empty { color: var(--ink-dim); border-style: dashed; }
.flow-ms { color: var(--ink-dim); font-size: var(--t-0); }
.flow-arrow { color: var(--cyan); font-size: var(--t-1); }

#log {
  font-size: var(--t-1);
  line-height: 1.7;
  color: var(--ink-dim);
  max-height: 240px;
  overflow: auto;
}
#log .line { white-space: pre-wrap; word-break: break-word; }
#log .line .t { color: #3f5d80; }
#log .line.ok { color: var(--ok); }
#log .line.err { color: var(--danger); }

/* ========================================================= boot sequence === */
#boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-5);
  background: radial-gradient(900px 600px at 50% 50%, #06121f, #02040a 75%);
  transition: opacity 600ms ease;
}
#boot.is-done { opacity: 0; pointer-events: none; }
.boot-reactor { position: relative; width: 120px; height: 120px; }
.boot-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--cyan-soft);
}
.boot-ring.br1 { border-top-color: var(--cyan); animation: spin 3.2s linear infinite; }
.boot-ring.br2 { inset: 16px; border-bottom-color: var(--gold); animation: spin 5s linear infinite reverse; }
.boot-core {
  position: absolute;
  inset: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #eafcff, var(--cyan) 55%, #0a3a52);
  box-shadow: 0 0 24px var(--cyan), inset 0 0 12px #fff;
  animation: pulse 2.4s ease-in-out infinite;
}
.boot-text {
  font-size: var(--t-1);
  letter-spacing: 0.28em;
  color: var(--cyan);
  min-height: 1.4em;
}
.boot-bar {
  width: min(60vw, 320px);
  height: 3px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  transition: width 180ms linear;
}

/* =============================================================== modals ==== */
#replay-overlay,
#brain-overlay {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(4px);
}
#replay-overlay[hidden],
#brain-overlay[hidden] { display: none; }

.replay,
.brain-modal {
  width: min(92vw, 620px);
  max-height: 78vh;
  overflow: auto;
  border: 1px solid var(--cyan-soft);
  border-radius: var(--r-3);
  background: var(--surface);
  box-shadow: var(--glow), 0 24px 80px rgba(0, 0, 0, 0.6);
  padding: var(--s-5);
}
.replay-head,
.brain-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--t-2);
  color: var(--ink-2);
  margin-bottom: var(--s-4);
}
.replay-head strong,
.brain-head strong { color: var(--cyan); }
.replay-sub {
  margin: var(--s-4) 0 var(--s-3);
  font-size: var(--t-1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.replay-spans,
.replay-audit { display: flex; flex-direction: column; gap: var(--s-2); }
.rspan {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
  background: var(--surface-2);
  border-left: 2px solid var(--cyan);
}
.rspan-name { font-size: var(--t-2); color: var(--ink); }
.rspan-ms { font-size: var(--t-1); color: var(--cyan); }
.rspan-attrs { font-size: var(--t-0); color: var(--ink-dim); width: 100%; word-break: break-word; }
.arow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-1);
  background: var(--surface-2);
  border-left: 2px solid #2a4058;
  font-size: var(--t-1);
}
.arow.ok { border-left-color: var(--ok); }
.arow.err { border-left-color: var(--danger); }
.arow-tool { color: var(--cyan); }
.arow-args { color: var(--ink-dim); word-break: break-word; flex: 1; }
.arow-ok { color: var(--ink); }
.arow.ok .arow-ok { color: var(--ok); }
.arow.err .arow-ok { color: var(--danger); }

.brain-list { display: flex; flex-direction: column; gap: var(--s-2); }
.brain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}
.brain-row:hover { border-color: var(--cyan-soft); background: var(--surface-3); }
.brain-row.is-active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-soft); }
.brain-row .br-label { font-size: var(--t-2); color: var(--ink); }
.brain-row .br-prov { font-size: var(--t-1); color: var(--ink-dim); }
.brain-row .br-free {
  font-size: var(--t-00);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
}
.brain-row .br-active-tag {
  font-size: var(--t-00);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ====================================================== command palette ==== */
#palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 13vh;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(4px);
}
#palette-overlay.is-open { display: flex; }
#palette {
  width: min(92vw, 640px);
  border: 1px solid var(--cyan-soft);
  border-radius: var(--r-3);
  background: var(--surface);
  box-shadow: var(--glow), 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
#palette-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--t-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
#palette-input::placeholder { color: var(--ink-dim); }
#palette-list {
  list-style: none;
  margin: 0;
  padding: var(--s-2);
  max-height: 44vh;
  overflow: auto;
}
#palette-list li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-1);
  cursor: pointer;
  color: var(--ink);
}
#palette-list li .cmd-title { flex: 1; }
#palette-list li .cmd-hint { font-size: var(--t-1); color: var(--ink-dim); }
#palette-list li.is-active,
#palette-list li:hover {
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--cyan-soft);
}
#palette-list li .cmd-glyph { color: var(--cyan); width: 18px; text-align: center; }
#palette-result {
  border-top: 1px solid var(--line);
  padding: var(--s-4) var(--s-5);
  font-size: var(--t-2);
  line-height: 1.6;
  color: var(--ink);
  max-height: 30vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
#palette-result:empty { display: none; }
#palette-result.is-err { color: var(--danger); }

/* ========================================================= drop overlay ==== */
#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 10, 0.85);
  backdrop-filter: blur(4px);
}
#drop-overlay.is-active { display: flex; }
.drop-card {
  text-align: center;
  padding: var(--s-7) calc(var(--s-7) + var(--s-2));
  border-radius: var(--r-3);
  border: 2px dashed var(--cyan);
  background: var(--surface);
  box-shadow: var(--glow);
}
.drop-glyph {
  font-size: 44px;
  color: var(--cyan);
  text-shadow: 0 0 18px var(--cyan-soft);
  animation: dropBob 1.4s ease-in-out infinite;
}
.drop-text { margin-top: var(--s-3); font-size: var(--t-3); letter-spacing: 0.08em; color: var(--ink); }
.drop-sub { margin-top: var(--s-2); font-size: var(--t-1); color: var(--ink-dim); }
@keyframes dropBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(7px); }
}

/* =============================================================== toast ===== */
#toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(86vw, 520px);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-2);
  border: 1px solid var(--cyan-soft);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-2);
  box-shadow: var(--glow);
  animation: toastIn 220ms ease both;
}
#toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================= keyframes === */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.05); filter: brightness(1.2); }
}

/* ============================================================================
   MAXIMAL FX — "FRIDAY OS" hybrid Stark + hacker layer.
   Everything below is additive and lives AFTER the base rules so it wins the
   cascade on equal specificity. It is driven by hud-fx.js (matrix rain,
   telemetry, sound, holographic reveal, calm-mode) and degrades to nothing
   under prefers-reduced-motion / html.calm.
   ============================================================================ */

/* Sharper, more "machined" corners than the soft app default. */
:root {
  --r-1: 5px;
  --r-2: 8px;
  --r-3: 11px;
}

/* ---- ambient backdrop layers (behind the app shell) --------------------- */
#matrix,
#grid,
#vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#matrix { opacity: 0.34; mix-blend-mode: screen; }
#grid {
  opacity: 0.6;
  background-image:
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 44px);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
}
#vignette {
  box-shadow: inset 0 0 240px 40px rgba(0, 0, 0, 0.7);
  background: radial-gradient(140% 120% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}
#particles { opacity: 0.6; }

/* ---- CRT scanlines + flicker (over everything, never blocks clicks) ----- */
#scanlines {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg, var(--scan) 0 1px, transparent 1px 3px
  );
  opacity: 0.55;
  animation: crtFlicker 5.5s steps(60) infinite;
}
#scanlines::after {
  /* a slow bright sweep sliding down the screen */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 26%;
  top: -26%;
  background: linear-gradient(
    180deg, transparent, rgba(var(--accent-rgb), 0.05), transparent
  );
  animation: crtSweep 7s linear infinite;
}
@keyframes crtFlicker {
  0%, 96%, 100% { opacity: 0.55; }
  97% { opacity: 0.4; }
  98% { opacity: 0.66; }
  99% { opacity: 0.46; }
}
@keyframes crtSweep {
  to { top: 130%; }
}

/* ---- holo-frame corner brackets on every framed surface ----------------- */
.panel,
.card,
.arena-card,
.agent-card,
.metric-card,
.composer-row,
.replay,
.brain-modal,
#palette,
.drop-card,
.approval {
  position: relative;
}
.panel::before,
.card::before,
.arena-card::before,
.agent-card::before,
.metric-card::before,
.composer-row::before,
.replay::before,
.brain-modal::before,
#palette::before,
.drop-card::before,
.approval::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  border-radius: inherit;
  --bl: 12px;   /* bracket arm length */
  --bw: 1.5px;  /* bracket thickness */
  background:
    linear-gradient(var(--bracket), var(--bracket)) 0 0 / var(--bl) var(--bw) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 0 0 / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 100% 0 / var(--bl) var(--bw) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 100% 0 / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 0 100% / var(--bl) var(--bw) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 0 100% / var(--bw) var(--bl) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 100% 100% / var(--bl) var(--bw) no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) 100% 100% / var(--bw) var(--bl) no-repeat;
  opacity: 0.45;
  transition: opacity 160ms ease;
}
.agent-card:hover::before,
.arena-card.winner::before,
.composer-row:focus-within::before,
.panel:hover::before { opacity: 0.95; }

/* a glowing instrument hairline along the top of headline panels */
.panel::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
  box-shadow: var(--glow-text);
  pointer-events: none;
}
.panel-h::before {
  /* a small "▌" tab marker before every panel heading */
  content: "▌ ";
  color: var(--accent);
  text-shadow: var(--glow-text);
}

/* ---- metric values + headings get the heavy-AI glow --------------------- */
.mc-value { text-shadow: var(--glow-strong); }
.vh-title {
  text-shadow: 0 0 18px rgba(var(--accent-rgb), 0.22);
}

/* ---- holographic reveal: data materialising in (added by hud-fx.js) ----- */
@keyframes fxReveal {
  0% { opacity: 0; transform: translateY(8px); filter: brightness(2.4) saturate(0.4); clip-path: inset(0 0 100% 0); }
  60% { filter: brightness(1.4); }
  100% { opacity: 1; transform: translateY(0); filter: none; clip-path: inset(0 0 0 0); }
}
.fx-reveal { animation: fxReveal 360ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }

/* ---- glitch wordmark (FRIDAY) ------------------------------------------- */
.brand-word { position: relative; }
.brand-word::before,
.brand-word::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
}
.brand-word.is-glitch::before {
  opacity: 0.9;
  color: var(--accent);
  animation: glitchA 460ms steps(2) 1;
}
.brand-word.is-glitch::after {
  opacity: 0.9;
  color: var(--danger);
  animation: glitchB 460ms steps(2) 1;
}
@keyframes glitchA {
  0% { transform: translate(0, 0); clip-path: inset(0 0 70% 0); }
  25% { transform: translate(-2px, -1px); clip-path: inset(40% 0 20% 0); }
  50% { transform: translate(2px, 1px); clip-path: inset(10% 0 60% 0); }
  75% { transform: translate(-1px, 1px); clip-path: inset(60% 0 5% 0); }
  100% { transform: translate(0, 0); clip-path: inset(0 0 70% 0); }
}
@keyframes glitchB {
  0% { transform: translate(0, 0); clip-path: inset(60% 0 10% 0); }
  25% { transform: translate(2px, 1px); clip-path: inset(15% 0 55% 0); }
  50% { transform: translate(-2px, -1px); clip-path: inset(50% 0 25% 0); }
  75% { transform: translate(1px, -1px); clip-path: inset(20% 0 60% 0); }
  100% { transform: translate(0, 0); clip-path: inset(60% 0 10% 0); }
}

/* ---- audio-reactive reactor (brand mark scales/glows with --level) ------ */
.brand-mark {
  transform: scale(calc(1 + var(--level) * 0.28));
  transition: transform 90ms linear;
}
.brand-mark .bm-core {
  box-shadow:
    0 0 calc(10px + var(--level) * 26px) var(--cyan),
    inset 0 0 6px #fff;
}

/* ---- rail telemetry readout (the "heavy AI system" data block) ---------- */
.rail-telemetry {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: rgba(var(--accent-rgb), 0.03);
}
.tele-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-0);
  letter-spacing: 0.1em;
}
.tele-k { color: var(--ink-dim); text-transform: uppercase; }
.tele-bar {
  height: 4px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.tele-bar i {
  display: block;
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: 0 0 8px var(--cyan-soft);
  transition: width 600ms ease;
}
.tele-v { color: var(--accent); text-shadow: var(--glow-text); justify-self: end; }
.tele-hex {
  font-size: var(--t-00);
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  opacity: 0.7;
}

/* ---- FX toggle buttons (calm mode + sound) ------------------------------ */
.fx-toggles { display: flex; gap: var(--s-2); }
.fx-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  background: var(--surface-2);
  color: var(--ink-dim);
  font-size: var(--t-0);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.fx-btn:hover { color: var(--ink-2); border-color: var(--cyan-soft); }
.fx-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--cyan-soft);
  box-shadow: inset 0 0 12px var(--cyan-faint);
}

/* ---- richer boot: a third ring, scanlines inside, glitchy title --------- */
#boot {
  background:
    repeating-linear-gradient(180deg, var(--scan) 0 1px, transparent 1px 3px),
    radial-gradient(900px 600px at 50% 50%, #06121f, #01030a 75%);
}
.boot-reactor::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px dashed var(--cyan-soft);
  opacity: 0.5;
  animation: spin 14s linear infinite reverse;
}
.boot-text {
  text-shadow: var(--glow-text);
  text-transform: uppercase;
}

/* ---- calm mode: keep the look, kill the continuous motion --------------- */
html.calm #matrix,
html.calm #scanlines { display: none; }
html.calm #particles { opacity: 0.28; }
html.calm .brand-word.is-glitch::before,
html.calm .brand-word.is-glitch::after { animation: none; opacity: 0; }
html.calm .brand-mark { transform: none; }

/* ---- reduced motion: freeze the heavy fx entirely ----------------------- */
@media (prefers-reduced-motion: reduce) {
  #matrix,
  #scanlines { display: none; }
  .fx-reveal { animation: none; }
}

/* ====================================================== responsive shell === */
/* Under 900px the rail becomes a bottom tab-bar and views go full width. */
@media (max-width: 900px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  #rail {
    grid-row: 2;
    flex-direction: row;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-right: 0;
    border-top: 1px solid var(--line);
    min-width: 0;
  }
  .rail-brand { display: none; }
  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    gap: var(--s-1);
    flex: 1 1 auto;
    min-width: 0;
  }
  .rail-item { flex-direction: column; gap: 2px; padding: var(--s-2); min-width: 0; }
  .rail-item .ri-glyph { width: auto; }
  .ri-label { font-size: var(--t-0); letter-spacing: 0.02em; }
  .rail-foot { flex: 0 0 auto; flex-direction: row; gap: var(--s-2); }
  .brain-pill { min-width: 0; padding: var(--s-2); }
  .brain-pill .bp-label { display: none; }
  .conn { display: none; }
  .rail-telemetry,
  .fx-toggles { display: none; }
  #grid { display: none; }

  .view { padding: var(--s-4) var(--s-4) 0; }
  .view-head { flex-direction: column; gap: var(--s-3); }
  .sys-cols { grid-template-columns: 1fr; }
  .filter-input { width: 100%; }
}

/* ===================================================== reduced motion ====== */
@media (prefers-reduced-motion: reduce) {
  #particles { display: none; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Live voice-mood chip (Phase 1 emotion sensing). Hidden until /ws/emotion
   streams a reading; background hue encodes valence, lightness encodes arousal. */
.mood {
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #04121a;
  text-transform: capitalize;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: background 240ms ease;
}

/* ============================================================================
   ARC-REACTOR CENTERPIECE — the JARVIS hero.
   A large, theme-tinted reactor (concentric dial rings + radial ticks + a
   sweeping arc + a Stark triangle + a glowing core) sits BEHIND the views in
   the main canvas. It is the star of the empty Command screen and an ambient
   core behind the data panels. Kept deliberately clean: moderate opacity, lots
   of breathing room, no clutter. Fades back when a conversation is on screen.
   ============================================================================ */
.view { position: relative; z-index: 1; }   /* lift view content above the reactor */

#reactor-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 600ms ease;
}
#reactor-stage.has-chat { opacity: 0.12; }   /* recede once a conversation begins */
/* pure-CSS fade once the chat log holds a turn (no JS needed) */
#canvas:has(.chat-log .turn) #reactor-stage,
#canvas:has(.chat-log .approval) #reactor-stage { opacity: 0.12; }

.reactor-core {
  position: relative;
  width: min(56vmin, 560px);
  height: min(56vmin, 560px);
  filter: drop-shadow(0 0 30px rgba(var(--accent-rgb), 0.25));
}
.rr { position: absolute; border-radius: 50%; inset: 0; }

/* faint base circle + a steady outer dashed bezel */
.rr-base { border: 1px solid rgba(var(--accent-rgb), 0.22); box-shadow: inset 0 0 60px rgba(var(--accent-rgb), 0.06); }
.rr-dash { inset: 4%; border: 1px dashed rgba(var(--accent-rgb), 0.3); animation: spin 48s linear infinite; }
.rr-inner { inset: 24%; border: 1px dashed rgba(var(--accent-rgb), 0.34); animation: spin 30s linear infinite reverse; }

/* a ring of radial measurement ticks (conic gradient, masked to an annulus) */
.rr-ticks {
  inset: 8%;
  background: repeating-conic-gradient(rgba(var(--accent-rgb), 0.5) 0 0.4deg, transparent 0.4deg 6deg);
  -webkit-mask: radial-gradient(circle, transparent 63%, #000 64%, #000 70%, transparent 71%);
  mask: radial-gradient(circle, transparent 63%, #000 64%, #000 70%, transparent 71%);
  animation: spin 90s linear infinite;
}
/* a single bright sweeping arc that orbits the core */
.rr-arc {
  inset: 14%;
  background: conic-gradient(from 0deg, transparent 0 286deg, rgba(var(--accent-rgb), 0.05) 300deg, var(--accent) 348deg, transparent 360deg);
  -webkit-mask: radial-gradient(circle, transparent 70%, #000 71%, #000 78%, transparent 79%);
  mask: radial-gradient(circle, transparent 70%, #000 71%, #000 78%, transparent 79%);
  animation: spin 12s linear infinite;
}
/* four cardinal gauge blocks on the mid ring */
.rr-gauge {
  inset: 0;
  background:
    conic-gradient(from 84deg, var(--accent) 0 12deg, transparent 12deg) ,
    conic-gradient(from 174deg, var(--accent) 0 12deg, transparent 12deg),
    conic-gradient(from 264deg, var(--accent) 0 12deg, transparent 12deg),
    conic-gradient(from 354deg, var(--accent) 0 12deg, transparent 12deg);
  -webkit-mask: radial-gradient(circle, transparent 80%, #000 81%, #000 85%, transparent 86%);
  mask: radial-gradient(circle, transparent 80%, #000 81%, #000 85%, transparent 86%);
  opacity: 0.7;
  animation: spin 40s linear infinite reverse;
}

/* the Stark triangle — an outline frame around the core */
.reactor-tri {
  position: absolute;
  inset: 30%;
  clip-path: polygon(50% 3%, 50% 3%, 97% 90%, 3% 90%);
}
.reactor-tri::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  clip-path: polygon(
    50% 3%, 53% 8%, 92% 86%, 86% 90%, 50% 16%, 14% 90%, 8% 86%, 47% 8%
  );
  opacity: 0.85;
  filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.6));
  animation: pulse 3.4s ease-in-out infinite;
}

/* the glowing reactor orb at dead center */
.reactor-orb {
  position: absolute;
  inset: 41%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #eafcff, var(--cyan) 52%, rgba(var(--accent-rgb), 0.18) 100%);
  box-shadow:
    0 0 36px var(--cyan),
    0 0 90px rgba(var(--accent-rgb), 0.5),
    inset 0 0 16px #fff;
  animation: pulse 3.4s ease-in-out infinite;
}

/* calm mode + reduced motion: keep the reactor, stop the spinning */
html.calm #reactor-stage * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  #reactor-stage * { animation: none !important; }
}
@media (max-width: 900px) {
  .reactor-core { width: min(72vmin, 360px); height: min(72vmin, 360px); }
  #reactor-stage { opacity: 0.4; }
}
