/* ============================================================================
   J.A.R.V.I.S. HUD stylesheet
   Tokens first; everything else references them. Series colours were validated
   with the dataviz palette validator against the panel surface (#0b1320).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #050a12;
  --bg-2: #070d17;
  --surface-1: #0b1320;      /* panel / chart surface */
  --surface-2: #101c2e;
  --surface-3: #15243a;

  /* ink */
  --text-1: #e6f1ff;
  --text-2: #9fb3c8;
  --text-3: #5f7590;         /* muted: axis labels, meta */

  /* accent (theme-able) */
  --hud: #22d3ee;
  --hud-2: #7dd3fc;
  --hud-rgb: 34, 211, 238;
  --line: rgba(var(--hud-rgb), 0.22);
  --line-strong: rgba(var(--hud-rgb), 0.55);
  --glow: 0 0 14px rgba(var(--hud-rgb), 0.35);

  /* categorical series - fixed order, never cycled past 6 (fold to "Other") */
  --series-1: #0f97b8;
  --series-2: #d97706;
  --series-3: #db2777;
  --series-4: #65a30d;
  --series-5: #8b5cf6;
  --series-6: #ea580c;
  --series-other: #5f7590;

  /* status - reserved for meaning, never for identity */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  /* chart chrome */
  --grid-line: #16263b;
  --axis: #243650;

  --font-ui: 'Rajdhani', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --radius: 4px;
  --gap: 14px;
}
:root[data-theme="stark"] { --hud: #f5b73a; --hud-2: #ffd98a; --hud-rgb: 245, 183, 58; }
:root[data-theme="matrix"] { --hud: #39ff88; --hud-2: #a8ffcc; --hud-rgb: 57, 255, 136; }
:root[data-theme="plasma"] { --hud: #c084fc; --hud-2: #e4ccff; --hud-rgb: 192, 132, 252; }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.35;
  color: var(--text-1);
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(var(--hud-rgb), 0.10), transparent 60%),
    linear-gradient(rgba(var(--hud-rgb), 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(var(--hud-rgb), 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
/* scanlines */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
a { color: var(--hud-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(var(--hud-rgb), 0.25); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 0.86em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.good { color: var(--status-good); }
.warn { color: var(--status-warning); }
.bad { color: var(--status-critical); }
.hud-c { color: var(--hud); }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- reactor */
.reactor { position: relative; border-radius: 50%; display: grid; place-items: center; }
.reactor.sm { width: 38px; height: 38px; }
.reactor.xl { width: 160px; height: 160px; margin: 0 auto 18px; }
.reactor .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.reactor .r1 { border-color: rgba(var(--hud-rgb), 0.9) transparent rgba(var(--hud-rgb), 0.9) transparent; animation: spin 6s linear infinite; }
.reactor .r2 { inset: 18%; border-color: transparent rgba(var(--hud-rgb), 0.7) transparent rgba(var(--hud-rgb), 0.7); animation: spin 4s linear infinite reverse; }
.reactor .r3 { inset: 32%; border-color: rgba(var(--hud-rgb), 0.5); border-style: dashed; animation: spin 10s linear infinite; }
.reactor .core { width: 34%; height: 34%; border-radius: 50%; background: radial-gradient(circle, #fff 0 20%, var(--hud) 45%, transparent 72%); box-shadow: 0 0 18px rgba(var(--hud-rgb), 0.9), 0 0 40px rgba(var(--hud-rgb), 0.4); animation: pulse 2.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---------------------------------------------------------------- boot */
.boot {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(800px 500px at 50% 40%, rgba(var(--hud-rgb), 0.12), var(--bg) 70%);
  transition: opacity 0.6s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.boot-title { font-size: 42px; font-weight: 700; letter-spacing: 0.35em; color: var(--hud); text-shadow: var(--glow); }
.boot-sub { color: var(--text-2); letter-spacing: 0.2em; text-transform: uppercase; font-size: 12px; margin-top: 4px; }
.boot-lines { margin-top: 22px; font-family: var(--font-mono); font-size: 12px; color: var(--text-2); min-height: 80px; }
.boot-line { animation: fadein 0.3s ease both; }
.boot-line::before { content: '› '; color: var(--hud); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- header */
.hud-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11,19,32,0.92), rgba(11,19,32,0.6));
  backdrop-filter: blur(4px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: 0.32em; font-weight: 700; color: var(--hud); text-shadow: var(--glow); line-height: 1; }
.brand-sub { display: block; font-size: 12px; color: var(--text-2); letter-spacing: 0.06em; margin-top: 3px; }
.status-strip { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.strip-item { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.12em; color: var(--text-2); text-transform: uppercase; }
.strip-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
#uplink[data-state="on"] .dot { background: var(--hud); box-shadow: 0 0 8px var(--hud); }
#uplink[data-state="off"] .dot { background: var(--status-critical); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.clock { flex-direction: column; align-items: flex-end; gap: 0; }
.clock-time { font-family: var(--font-mono); font-size: 22px; color: var(--text-1); letter-spacing: 0.04em; line-height: 1; }
.clock-date { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-2); }
.badge { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: rgba(var(--hud-rgb), 0.15); color: var(--hud); font-family: var(--font-mono); font-size: 11px; text-align: center; }
.badge.hot { background: rgba(208,59,59,0.2); color: #ff9b9b; }
.hud-actions { display: flex; gap: 6px; }
.hb, .pa {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(var(--hud-rgb), 0.06); color: var(--hud);
  border-radius: var(--radius); font-size: 16px; line-height: 1; transition: background 0.15s, box-shadow 0.15s;
}
.hb:hover, .pa:hover { background: rgba(var(--hud-rgb), 0.18); box-shadow: var(--glow); }

/* ticker */
.hud-ticker {
  position: relative; z-index: 1; display: flex; gap: 12px; align-items: baseline;
  padding: 4px 20px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2);
  border-bottom: 1px solid rgba(var(--hud-rgb), 0.10); cursor: pointer; white-space: nowrap; overflow: hidden;
}
.hud-ticker .tk-time { color: var(--hud); }
.hud-ticker .tk-msg { overflow: hidden; text-overflow: ellipsis; animation: fadein 0.25s ease; }
.hud-ticker[data-level="error"] .tk-msg { color: #ff9b9b; }
.hud-ticker[data-level="warn"] .tk-msg { color: var(--status-warning); }

/* ---------------------------------------------------------------- grid */
.grid {
  position: relative; z-index: 1;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  padding: var(--gap) 20px 40px;
  align-items: stretch; /* panels in a row share one height - HUD frames line up */
}
.panel.size-sm   { grid-column: span 3; }
.panel.size-md   { grid-column: span 4; }
.panel.size-lg   { grid-column: span 6; }
.panel.size-wide { grid-column: span 8; }
.panel.size-xl   { grid-column: span 12; }
.panel.size-tall { grid-column: span 4; min-height: 480px; }
/* laptop: halves for sm/md/lg, thirds for tall - with the default layout every
   row closes at 12 (clock+system · uptime+weather · nav · tasks+github · 3 talls) */
@media (max-width: 1400px) {
  .panel.size-sm, .panel.size-md, .panel.size-lg { grid-column: span 6; }
  .panel.size-tall { grid-column: span 4; }
  .panel.size-wide { grid-column: span 12; }
}
/* tablet: two columns */
@media (max-width: 1000px) {
  .panel.size-sm, .panel.size-md, .panel.size-tall { grid-column: span 6; }
  .panel.size-lg, .panel.size-wide { grid-column: span 12; }
}
@media (max-width: 760px) {
  .grid { padding: 10px; }
  .panel { grid-column: span 12 !important; }
  .hud-top { flex-wrap: wrap; gap: 10px 16px; padding: 10px 12px; }
  .status-strip { margin-left: 0; width: 100%; justify-content: space-between; gap: 12px; }
  .brand h1 { font-size: 20px; }
}

/* ---------------------------------------------------------------- panel */
.panel {
  position: relative; display: flex; flex-direction: column; min-height: 170px;
  background: linear-gradient(180deg, rgba(16,28,46,0.92), rgba(11,19,32,0.96));
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02), 0 6px 24px rgba(0,0,0,0.35);
  transition: opacity 0.25s ease, border-color 0.2s ease, transform 0.15s ease;
}
/* corner brackets */
.panel::before, .panel::after, .panel-head::after, .panel-foot::before {
  content: ''; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--hud); border-style: solid; border-width: 0;
}
.panel::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.panel::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }
.panel-head::after { top: -1px; right: -1px; border-top-width: 2px; border-right-width: 2px; }
.panel-foot::before { bottom: -1px; left: -1px; border-bottom-width: 2px; border-left-width: 2px; }
.panel:hover { border-color: var(--line-strong); }
.panel.loading .panel-body { opacity: 0.55; transition: opacity 0.2s ease; }
.panel.error { border-color: rgba(208,59,59,0.5); }
.panel.dragging { opacity: 0.4; transform: scale(0.98); }
.panel.drop-before { box-shadow: -4px 0 0 var(--hud); }
.panel.drop-after { box-shadow: 4px 0 0 var(--hud); }

.panel-head {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px; border-bottom: 1px solid rgba(var(--hud-rgb), 0.14);
  background: linear-gradient(90deg, rgba(var(--hud-rgb), 0.10), transparent 70%);
  cursor: grab; user-select: none;
}
.panel-head:active { cursor: grabbing; }
.panel-title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--hud); white-space: nowrap; }
.panel-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot[data-status="ok"]   { background: var(--hud); box-shadow: 0 0 8px var(--hud); }
.dot[data-status="warn"] { background: var(--status-warning); box-shadow: 0 0 8px var(--status-warning); }
.dot[data-status="crit"] { background: var(--status-critical); box-shadow: 0 0 8px var(--status-critical); animation: blink 1s steps(2) infinite; }
.dot[data-status="busy"] { background: var(--hud-2); animation: pulse 0.8s ease-in-out infinite; }
.dot[data-status="off"]  { background: var(--text-3); }
.panel-sub { font-size: 12px; color: var(--text-2); letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.panel-actions { display: flex; gap: 4px; margin-left: auto; opacity: 0.35; transition: opacity 0.15s; }
.panel:hover .panel-actions, .panel:focus-within .panel-actions { opacity: 1; }
.panel-actions .pa { width: 24px; height: 24px; font-size: 13px; }
.panel-body { padding: 12px; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.panel-body.scroll { overflow: auto; max-height: 520px; }
.panel-foot { position: relative; display: flex; align-items: center; gap: 10px; padding: 4px 12px 6px; font-size: 11px; color: var(--text-3); font-family: var(--font-mono); border-top: 1px solid rgba(var(--hud-rgb), 0.08); min-height: 24px; }
.panel-foot .err { color: #ff9b9b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-foot .meta { white-space: nowrap; }

/* empty / error states */
.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--text-2); padding: 18px 10px; gap: 6px; }
.empty .empty-icon { font-size: 28px; color: var(--hud); opacity: 0.7; }
.empty.err .empty-icon { color: var(--status-critical); }
.empty small { color: var(--text-3); }

/* ---------------------------------------------------------------- common bits */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--line-strong); background: rgba(var(--hud-rgb), 0.10); color: var(--hud);
  border-radius: var(--radius); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(var(--hud-rgb), 0.22); box-shadow: var(--glow); }
.btn.primary { background: var(--hud); color: #041018; border-color: var(--hud); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn.danger { border-color: rgba(208,59,59,0.6); color: #ff9b9b; background: rgba(208,59,59,0.08); }
.btn.sm { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 11px; letter-spacing: 0.06em; background: rgba(var(--hud-rgb), 0.10); color: var(--hud-2); border: 1px solid rgba(var(--hud-rgb), 0.18); white-space: nowrap; }
.chip.good { color: #7ee07e; background: rgba(12,163,12,0.12); border-color: rgba(12,163,12,0.3); }
.chip.warn { color: var(--status-warning); background: rgba(250,178,25,0.12); border-color: rgba(250,178,25,0.3); }
.chip.bad { color: #ff9b9b; background: rgba(208,59,59,0.14); border-color: rgba(208,59,59,0.35); }
.chip.muted { color: var(--text-2); background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid rgba(var(--hud-rgb), 0.08); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); letter-spacing: 0.04em; }
.kv .v { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-1); text-align: right; }

.hud-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hud-table th { text-align: left; font-weight: 600; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hud-table td { padding: 5px 6px; border-bottom: 1px solid rgba(var(--hud-rgb), 0.07); vertical-align: middle; }
.hud-table tr:last-child td { border-bottom: 0; }
.hud-table td.n, .hud-table th.n { text-align: right; font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hud-table tbody tr:hover td { background: rgba(var(--hud-rgb), 0.05); }

/* stat tile (label · value · delta · sparkline) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { padding: 8px 10px; border: 1px solid rgba(var(--hud-rgb), 0.12); background: rgba(var(--hud-rgb), 0.04); border-radius: var(--radius); min-width: 0; }
.stat .label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.stat .value { font-size: 24px; font-weight: 600; line-height: 1.1; margin-top: 2px; color: var(--text-1); }
.stat .value.hero { font-size: 48px; }
.stat .delta { font-size: 12px; font-family: var(--font-mono); }
.stat .delta.up { color: var(--status-good); }
.stat .delta.down { color: var(--status-critical); }
.stat .trend { margin-top: 4px; }
.stat .spark { display: block; width: 100%; height: 28px; }

/* meter (single ratio against a limit) */
.meter { position: relative; height: 6px; border-radius: 3px; background: rgba(var(--hud-rgb), 0.16); overflow: hidden; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--hud); border-radius: 3px; transition: width 0.4s ease; }
.meter.warn { background: rgba(250,178,25,0.18); } .meter.warn > i { background: var(--status-warning); }
.meter.crit { background: rgba(208,59,59,0.18); } .meter.crit > i { background: var(--status-critical); }

/* segmented bar (part-to-whole, ≤ 6 parts + Other) */
.segbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: transparent; }
.segbar > i { display: block; height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .key.line { height: 2px; width: 14px; vertical-align: 3px; }

/* sparkline / gauge svg text */
.spark .spark-empty { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.spark .spark-base { stroke: var(--axis); stroke-width: 1; }
.gauge .gauge-value { fill: var(--text-1); font-size: 22px; font-weight: 600; font-family: var(--font-ui); }
.gauge .gauge-unit { fill: var(--text-2); font-size: 10px; letter-spacing: 0.1em; font-family: var(--font-ui); }
.gauge .gauge-label { fill: var(--text-3); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; font-family: var(--font-ui); }
.gauges { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 6px; }

/* generic list rows */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid rgba(var(--hud-rgb), 0.08); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: rgba(var(--hud-rgb), 0.04); }
.list-row .title { font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* inputs */
.input, input[type="text"], input[type="number"], input[type="password"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; padding: 7px 10px; background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--hud); box-shadow: 0 0 0 2px rgba(var(--hud-rgb), 0.18); }
textarea { resize: vertical; min-height: 70px; font-family: var(--font-mono); font-size: 12.5px; }
select option { background: var(--surface-2); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.1); border: 1px solid var(--line); position: relative; transition: background 0.2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform 0.2s, background 0.2s; }
.switch input:checked + .track { background: rgba(var(--hud-rgb), 0.35); border-color: var(--hud); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--hud); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 2px rgba(var(--hud-rgb), 0.3); }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast {
  position: relative; padding: 10px 34px 10px 14px; background: rgba(11,19,32,0.96);
  border: 1px solid var(--line-strong); border-left: 3px solid var(--hud); box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: slidein 0.25s ease both; font-size: 13.5px;
}
.toast.out { animation: slideout 0.35s ease forwards; }
.toast.level-good { border-left-color: var(--status-good); }
.toast.level-warn { border-left-color: var(--status-warning); }
.toast.level-critical { border-left-color: var(--status-critical); border-color: rgba(208,59,59,0.6); }
.toast-title { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; color: var(--hud); }
.toast.level-critical .toast-title { color: #ff9b9b; }
.toast.level-warn .toast-title { color: var(--status-warning); }
.toast.level-good .toast-title { color: #7ee07e; }
.toast-body { color: var(--text-2); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.toast-x { position: absolute; top: 6px; right: 6px; background: none; border: 0; color: var(--text-3); font-size: 12px; }
.toast-actions { display: flex; gap: 6px; margin-top: 8px; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes slideout { to { opacity: 0; transform: translateX(20px); } }

/* ---------------------------------------------------------------- tooltip */
.tooltip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 320px;
  padding: 8px 10px; background: rgba(5,10,18,0.96); border: 1px solid var(--line-strong);
  color: var(--text-1); font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.tooltip .tt-title { color: var(--text-2); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; font-family: var(--font-mono); font-size: 12px; }
.tooltip .tt-row b { font-weight: 600; color: var(--text-1); }
.tooltip .tt-key { display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; }

/* ---------------------------------------------------------------- dialogs */
.hud-dialog { border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--text-1); padding: 0; box-shadow: 0 20px 80px rgba(0,0,0,0.7), var(--glow); max-height: 90vh; }
.hud-dialog::backdrop { background: rgba(2,6,12,0.72); backdrop-filter: blur(3px); }
.hud-dialog.settings { width: min(980px, 94vw); height: min(720px, 90vh); }
.hud-dialog.modal { width: min(680px, 94vw); }
.hud-dialog.modal.wide { width: min(1200px, 96vw); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 14px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--hud); }
.dlg-head .x { margin-left: auto; }
.dlg-body { padding: 16px; overflow: auto; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.dlg-foot .spacer { flex: 1; }
.settings-layout { display: grid; grid-template-columns: 210px 1fr; height: calc(100% - 52px - 57px); }
.settings-nav { border-right: 1px solid var(--line); padding: 8px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.settings-nav button { text-align: left; padding: 8px 10px; background: none; border: 1px solid transparent; color: var(--text-2); border-radius: var(--radius); letter-spacing: 0.06em; font-weight: 600; font-size: 13px; }
.settings-nav button.active { color: var(--hud); background: rgba(var(--hud-rgb), 0.10); border-color: var(--line); }
.settings-content { padding: 16px 20px; overflow: auto; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-section h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hud); }
.settings-section .desc { color: var(--text-2); font-size: 13px; margin: 0 0 14px; }
.field { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; align-items: start; padding: 10px 0; border-bottom: 1px solid rgba(var(--hud-rgb), 0.08); }
.field:last-child { border-bottom: 0; }
.field > label { font-weight: 600; color: var(--text-1); padding-top: 7px; letter-spacing: 0.03em; }
.field .help { grid-column: 2; font-size: 12px; color: var(--text-3); }
.field .ctl { min-width: 0; }
.field.invalid input, .field.invalid textarea { border-color: var(--status-critical); }
.field .invalid-msg { grid-column: 2; font-size: 12px; color: #ff9b9b; }
@media (max-width: 760px) {
  .settings-layout { grid-template-columns: 1fr; height: auto; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .field { grid-template-columns: 1fr; }
  .field .help, .field .invalid-msg { grid-column: 1; }
}

/* log drawer */
.loglist { font-family: var(--font-mono); font-size: 12px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column-reverse; }
.loglist div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); white-space: pre-wrap; word-break: break-word; }
.loglist .t { color: var(--hud); margin-right: 8px; }
.loglist .l-error { color: #ff9b9b; }
.loglist .l-warn { color: var(--status-warning); }

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

/* phone access steps */
.remote-steps { margin: 6px 0 10px; padding-left: 20px; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.remote-steps li.good { color: var(--text-1); }
.remote-steps li.good::marker { color: var(--status-good); content: '✓  '; }
