/* Ambar Studio — engineering workspace
 * Strict CSP compliant (style-src 'self'): zero inline style attributes required.
 * Shared original identity and source decisions: docs/brand-identity.md.
 */
:root,
[data-theme="dark"] {
  --font-display: var(--font-brand);
  --sans: var(--font-brand);
  --mono: var(--font-code);

  /* Obsidian Carbon (Default Industrial Dark) */
  --bg: #060911;
  --panel: #0b111e;
  --panel-2: #080d18;
  --panel-3: #141f35;
  --border: #1e2d47;
  --border-subtle: rgba(148, 163, 184, 0.14);
  --text: #e2e8f0;
  --heading: #f8fafc;
  --muted: #94a3b8;
  --accent: #6dc9eb;
  --accent-2: #38bdf8;
  --accent-hover: #0284c7;
  --accent-text: #041019;
  --accent-glow: rgba(0, 229, 255, 0.16);
  --amber: #f59e0b;
  --violet: #8b5cf6;
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.16);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.16);
  --err: #ef4444;
  --err-bg: rgba(239, 68, 68, 0.18);
  --scene-bg: #080d18;
  --editor-bg: #050811;
  --editor-text: #f1f5f9;
  --topbar-bg: #0b111e;
  --glass-bg: rgba(11, 17, 30, 0.84);
  --label-bg: rgba(6, 9, 17, 0.90);
  --label-text: #f8fafc;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --specular: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --radius: 7px;
  color-scheme: dark;
}

/* Cleanroom Daylight (High-Contrast Field / Bright Environment) */
[data-theme="light"] {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #e2e8f0;
  --border: #cbd5e1;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --heading: #020617;
  --muted: #475569;
  --accent: #0284c7;
  --accent-2: #0369a1;
  --accent-hover: #0369a1;
  --accent-text: #ffffff;
  --accent-glow: rgba(2, 132, 199, 0.14);
  --amber: #d97706;
  --violet: #7c3aed;
  --ok: #16a34a;
  --ok-bg: rgba(22, 163, 74, 0.14);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.14);
  --err: #dc2626;
  --err-bg: rgba(220, 38, 38, 0.14);
  --scene-bg: #dbeafe;
  --editor-bg: #0f172a;
  --editor-text: #f8fafc;
  --topbar-bg: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  --glass-bg: rgba(255, 255, 255, 0.92);
  --label-bg: rgba(15, 23, 42, 0.90);
  --label-text: #f8fafc;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  --specular: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color-scheme: light;
}

/* Foundry Tactical (Aerospace Stealth & Phosphor Emerald Telemetry) */
[data-theme="foundry"] {
  --bg: #05090c;
  --panel: #091116;
  --panel-2: #060c10;
  --panel-3: #102029;
  --border: #18323f;
  --border-subtle: rgba(16, 185, 129, 0.14);
  --text: #d1fae5;
  --heading: #ecfdf5;
  --muted: #6ee7b7;
  --accent: #10b981;
  --accent-2: #06b6d4;
  --accent-hover: #059669;
  --accent-text: #022c22;
  --accent-glow: rgba(16, 185, 129, 0.18);
  --amber: #f59e0b;
  --violet: #06b6d4;
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.18);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.16);
  --err: #f43f5e;
  --err-bg: rgba(244, 63, 94, 0.18);
  --scene-bg: #060d12;
  --editor-bg: #04080b;
  --editor-text: #ecfdf5;
  --topbar-bg: linear-gradient(180deg, #0c171e 0%, #060c10 100%);
  --glass-bg: rgba(9, 17, 22, 0.88);
  --label-bg: rgba(5, 9, 12, 0.92);
  --label-text: #ecfdf5;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
  --specular: inset 0 1px 0 rgba(16, 185, 129, 0.12);
  color-scheme: dark;
}

/* Kinetic Gold (Heavy Intralogistics & Signal Gold / Laser Cyan) */
[data-theme="kinetic"] {
  --bg: #09090b;
  --panel: #121216;
  --panel-2: #0c0c0f;
  --panel-3: #1e1e26;
  --border: #2e2e38;
  --border-subtle: rgba(255, 159, 28, 0.15);
  --text: #f4f4f5;
  --heading: #ffffff;
  --muted: #a1a1aa;
  --accent: #ff9f1c;
  --accent-2: #00f0ff;
  --accent-hover: #f59e0b;
  --accent-text: #181104;
  --accent-glow: rgba(255, 159, 28, 0.18);
  --amber: #ff9f1c;
  --violet: #00f0ff;
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, 0.16);
  --warn: #ff9f1c;
  --warn-bg: rgba(255, 159, 28, 0.16);
  --err: #ef4444;
  --err-bg: rgba(239, 68, 68, 0.18);
  --scene-bg: #0c0c10;
  --editor-bg: #070709;
  --editor-text: #fafafa;
  --topbar-bg: linear-gradient(180deg, #18181f 0%, #0c0c10 100%);
  --glass-bg: rgba(18, 18, 22, 0.88);
  --label-bg: rgba(9, 9, 11, 0.92);
  --label-text: #ffffff;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
  --specular: inset 0 1px 0 rgba(255, 159, 28, 0.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.5 var(--sans);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* OpenType Tabular Numeric Discipline across all engineering telemetry */
.clock,
.badge,
.kpi-value,
.grid-table .num,
.tag-value,
.minimap-coords,
.events .t,
.asrs-row .num,
.metric-big,
.kbd-hint {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ================================================================ TOP STUDIO COMMAND BAR */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 52px;
  padding: 6px 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--specular);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  cursor: pointer;
  padding: 2px 6px 2px 2px;
  border-radius: 7px;
  transition: background 0.14s ease;
}
.brand:hover {
  background: var(--accent-glow);
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 25%, rgba(0, 229, 255, 0.25), rgba(15, 23, 42, 0.92));
  border: 1px solid var(--accent);
  box-shadow: 0 0 14px var(--accent-glow), var(--specular);
  overflow: hidden;
}
.logo svg {
  width: 22px;
  height: 22px;
  display: block;
}

.brand-titles { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.7px;
  color: var(--heading);
}
.brand-ver {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--accent-glow);
}
.site-name {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

.scene-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  box-shadow: var(--specular);
}
.picker-label { color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.scene-picker select {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  padding: 2px 4px;
  max-width: 235px;
}

.transport { display: flex; align-items: center; gap: 5px; }
.tools { display: flex; align-items: center; gap: 5px; margin-left: auto; flex-wrap: wrap; }
.speed { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11.5px; }
.clock {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--specular);
}
.export-group { display: flex; align-items: center; gap: 4px; }
.lang-select,
.theme-select { font-weight: 700; font-size: 11.5px; padding: 4px 6px; }
.link-btn { text-decoration: none; display: inline-flex; align-items: center; }

.cmd-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--heading);
}
.kbd-hint {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
}

/* ================================================================ BUTTONS & INPUTS */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 650;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 9px;
  cursor: pointer;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--specular);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
.btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.btn:active {
  transform: translateY(0.5px);
}
.btn:focus-visible,
.input:focus-visible,
select:focus-visible,
summary:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 750;
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}
.btn.primary[aria-pressed="true"] {
  background: var(--ok);
  border-color: var(--ok);
  color: #052e16;
}
.btn.accent-outline {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.btn.accent-outline:hover {
  background: var(--accent);
  color: var(--accent-text);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.btn.ghost[aria-pressed="true"] {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.btn.danger {
  color: var(--err);
  background: var(--err-bg);
  border-color: rgba(239, 68, 68, 0.45);
}
.btn.danger:hover {
  border-color: var(--err);
  background: rgba(239, 68, 68, 0.28);
}
.btn.small { padding: 3px 8px; font-size: 11px; font-weight: 650; }
.btn.icon {
  padding: 0 7px;
  font-size: 18px;
  line-height: 1.1;
  border: none;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn.icon:hover { color: var(--heading); }
.btn.icon.small { font-size: 14px; padding: 0 5px; }
.full-btn { width: 100%; justify-content: center; padding: 7px 10px; margin: 4px 0; }
.panels-toggle { display: none; }

select, .input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 7px;
  min-width: 0;
}
.input[type="search"] { width: 100%; margin-bottom: 7px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-err { color: var(--err); background: var(--err-bg); }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
  font-family: var(--mono);
}
.badge-scan { color: var(--accent); background: var(--accent-glow); border: 1px solid var(--accent); }
.badge-plc { color: var(--warn); background: var(--warn-bg); font-size: 11px; }
.badge-forced { color: var(--warn); background: var(--warn-bg); }
.badge-fault { color: var(--err); background: var(--err-bg); }
.badge-in { color: var(--accent); background: var(--accent-glow); border: 1px solid rgba(56, 189, 248, 0.35); }
.badge-out { color: var(--warn); background: var(--warn-bg); border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-pass { color: var(--ok); background: var(--ok-bg); border: 1px solid rgba(16, 185, 129, 0.45); }
.badge-warn { color: var(--warn); background: var(--warn-bg); border: 1px solid rgba(245, 158, 11, 0.45); }
.badge-fail { color: var(--err); background: var(--err-bg); border: 1px solid rgba(239, 68, 68, 0.45); }

/* ================================================================ 3-COLUMN WORKSPACE LAYOUT */
.main {
  position: relative;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 390px;
  min-height: 0;
}

/* ================================================================ DOCK TABS & PANES */
.dock-tabs {
  display: flex;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex: none;
}
.dock-tab {
  appearance: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 7px;
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 auto;
  text-align: center;
  transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}
.dock-tab:hover { color: var(--text); background: var(--accent-glow); }
.dock-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-glow);
}

.dock-pane { display: none; padding: 10px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dock-pane.active { display: flex; flex-direction: column; gap: 8px; }

.pane-intro {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--specular);
}
.pane-intro strong { color: var(--heading); font-size: 12px; font-family: var(--font-display); }
.pane-intro span { color: var(--muted); font-size: 11px; }

/* ================================================================ LEFT DOCK */
.left-dock {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.scene-cards { display: flex; flex-direction: column; gap: 6px; }
.scene-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--specular);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.scene-card:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.scene-card.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: inset 3px 0 0 var(--accent), var(--specular);
}
.scene-card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.scene-card-title { font-weight: 700; font-size: 12px; color: var(--heading); font-family: var(--font-display); }
.scene-card-cat {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--accent);
}
.scene-card-desc { color: var(--muted); font-size: 11px; line-height: 1.3; }

.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--specular);
  transition: border-color 0.14s ease, background 0.14s ease;
}
.palette-card:hover { border-color: var(--accent); background: var(--accent-glow); }
.palette-icon { width: 22px; height: 8px; border-radius: 3px; display: inline-block; }
.icon-conv { background: #3b82f6; }
.icon-pe { background: #f59e0b; }
.icon-bcr { background: #ef4444; }
.icon-st { background: #14b8a6; }
.icon-asrs { background: #eab308; }
.palette-title { font-weight: 700; font-size: 11.5px; }
.palette-sub { color: var(--muted); font-size: 10px; }

.card-sub {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--specular);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sub-head {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.25px;
}
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; }
.field-row .input, .field-row select { width: 115px; }
.field-col { display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; font-size: 11.5px; }

.cad-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 12px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-glow);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.cad-dropzone:hover { filter: brightness(1.12); }
.drop-title { font-weight: 700; color: var(--accent); font-size: 12px; }
.drop-sub { color: var(--muted); font-size: 11px; }
.compact-list { margin: 0; padding-left: 16px; color: var(--muted); font-size: 11px; line-height: 1.5; }

/* ================================================================ CENTER STAGE & BOTTOM DOCK */
.center-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 196px;
  min-width: 0;
  min-height: 0;
}
.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--scene-bg);
}
.viewport > canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.hud-banner {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  pointer-events: none;
  z-index: 4;
}
.hud-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--specular);
  backdrop-filter: blur(8px);
}
.hud-chip-active {
  border-color: var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}

/* 2D Interactive CAD Radar Minimap */
.minimap-card {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 244px;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--specular);
  z-index: 6;
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.minimap-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.minimap-title { font-size: 11px; font-weight: 750; color: var(--accent); font-family: var(--font-display); }
.minimap-coords { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.minimap-body { padding: 5px; }
.minimap-card.collapsed .minimap-body { display: none; }
.minimap-card.collapsed .minimap-head { border-bottom: none; }
#minimap-canvas {
  display: block;
  width: 232px;
  height: 142px;
  border-radius: 4px;
  background: #070b12;
  border: 1px solid var(--border);
  cursor: crosshair;
}

.bottom-dock {
  display: flex;
  min-width: 0;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding-right: 10px;
}
.bottom-actions { display: flex; align-items: center; gap: 6px; }
.bottom-pane { display: none; flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 10px; }
.bottom-pane.active { display: block; }
#btab-scope.active { padding: 4px 8px; overflow: hidden; }
#scope-canvas {
  width: 100%;
  height: 146px;
  display: block;
  border-radius: 5px;
  background: #070b12;
  border: 1px solid var(--border);
}

.verify-box { font-size: 12px; line-height: 1.45; }
.verify-empty p { margin: 4px 0 0; color: var(--muted); }
.verify-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px; margin-top: 6px; }
.verify-check {
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
}
.verify-check.pass { border-color: rgba(16, 185, 129, 0.45); color: var(--ok); }
.verify-check.fail { border-color: rgba(239, 68, 68, 0.5); color: var(--err); }
.sha-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
}

/* ================================================================ RIGHT DOCK: PLC STUDIO, KPI & SWARM */
.side {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.plc-toolbar { display: flex; gap: 5px; flex-wrap: wrap; }
.plc-status {
  padding: 5px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.plc-status.ok { color: var(--ok); border-color: rgba(16, 185, 129, 0.35); background: var(--ok-bg); }
.plc-status.err { color: var(--err); border-color: rgba(239, 68, 68, 0.45); background: var(--err-bg); }

.plc-subtabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 5px;
}
.plc-subtab {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  cursor: pointer;
  white-space: nowrap;
}
.plc-subtab:hover { color: var(--text); }
.plc-subtab.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: var(--accent);
}
.plc-copy-btn { margin-left: auto; }

.editor-wrap { display: flex; flex: 1 1 220px; min-height: 165px; }
.st-editor {
  width: 100%;
  height: 100%;
  resize: none;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--editor-text);
  background: var(--editor-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  tab-size: 4;
}
.code-preview { color: #a5f3fc; }

.watch-box { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.watch-scroll { max-height: 175px; }

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--specular);
  flex: none;
}
.panel > summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 700;
  font-family: var(--font-display);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--heading);
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before {
  content: "";
  width: 0;
  height: 0;
  flex: none;
  border-left: 5px solid var(--accent);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
}
.panel[open] > summary::before { transform: rotate(90deg); }
.summary-note { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 11px; font-family: var(--mono); }
.panel-body { padding: 0 10px 10px; }

/* ================================================================ METRICS, AS/RS MATRIX & TABLES */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.kpi {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--specular);
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 10.5px; }
.kpi-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
}
.kpi-value.bad { color: var(--err); }

.grid-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.grid-table th {
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}
.grid-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid-table tr:last-child td { border-bottom: none; }
.grid-table .num { text-align: right; font-family: var(--mono); }
.table-scroll { max-height: 290px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }

.tags-table td:first-child { font-family: var(--mono); word-break: break-all; font-weight: 600; }
.tag-value { font-family: var(--mono); }
.bool { display: inline-block; min-width: 20px; text-align: center; border-radius: 4px; padding: 0 5px; font-weight: 700; }
.bool.on { color: #052e16; background: var(--ok); }
.bool.off { color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); }
.tag-actions { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.tags-table td:last-child { width: 1%; white-space: nowrap; }
.tag-actions .input { width: 58px; padding: 2px 4px; font-size: 11px; }
.tag-flags { display: inline-flex; gap: 3px; margin-left: 4px; }

.asrs-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.asrs-item { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.asrs-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; }
.asrs-row .num { font-family: var(--mono); }
.meter { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin: 5px 0 4px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.muted { color: var(--muted); }

.asrs-matrix-box {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#asrs-matrix-canvas {
  width: 100%;
  height: 124px;
  display: block;
  border-radius: 4px;
  background: #070b12;
  border: 1px solid var(--border);
}

/* ================================================================ 10-AGENT SWARM ORCHESTRATION */
.swarm-actions { display: flex; flex-direction: column; gap: 5px; }
.swarm-actions .form-row > button { flex: 1 1 0; }
.swarm-overview { gap: 5px; border-color: var(--accent); }
.swarm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.swarm-card {
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--specular);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.swarm-card.pass { border-left: 3px solid var(--ok); }
.swarm-card.warn { border-left: 3px solid var(--warn); }
.swarm-card.fail { border-left: 3px solid var(--err); }
.swarm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.swarm-agent-name { font-weight: 750; font-size: 11.5px; color: var(--heading); font-family: var(--font-display); }
.swarm-agent-role { font-size: 10px; color: var(--accent); font-weight: 600; }
.swarm-agent-desc { font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.swarm-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.swarm-bus { max-height: 150px; }

.form-row { display: flex; gap: 6px; margin-bottom: 6px; }
.form-row > select { flex: 1 1 0; }
.fault-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fault-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.fault-list li.empty { color: var(--muted); justify-content: flex-start; }
.fault-list .what { font-family: var(--mono); font-size: 11.5px; }

.events {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 138px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--editor-bg);
  color: var(--editor-text);
}
.events li {
  display: grid;
  grid-template-columns: 60px 88px minmax(0, 1fr);
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.events li:last-child { border-bottom: none; }
.events .t { color: #94a3b8; text-align: right; }
.events .k { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.events .d { color: #cbd5e1; overflow-wrap: anywhere; }
.events .k-fault, .events .k-stall { color: var(--err); }
.events .k-tote_out { color: var(--ok); }
.events .k-tote_in { color: var(--accent); }
.events .k-diverter, .events .k-asrs_cycle { color: var(--warn); }
.events .empty { display: block; color: #94a3b8; }

/* ================================================================ 3D VIEWPORT OVERLAYS */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  text-align: center;
  padding: 20px;
  background: rgba(6, 9, 17, 0.58);
}
.overlay.error { color: var(--err); }

.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--mono);
  white-space: nowrap;
  will-change: transform;
  background: var(--label-bg);
  color: var(--label-text);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.label.minor { font-size: 9.5px; font-weight: 600; opacity: 0.88; }
.label.state-stop { background: #475569; }
.label.state-fault { background: #dc2626; border-color: #fca5a5; }
.label.state-on { background: #15803d; border-color: #86efac; }

.legend {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 55%;
  pointer-events: none;
  z-index: 4;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px 2px 5px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, 0.3); }
.swatch-c1 { background: #f2c14e; }
.swatch-c2 { background: #e4572e; }
.swatch-c3 { background: #17bebb; }
.swatch-c4 { background: #a259ff; }
.swatch-c5 { background: #76b041; }

.selection {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 336px;
  max-width: calc(100% - 24px);
  background: var(--glass-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--specular);
  padding: 10px 12px;
  z-index: 6;
  backdrop-filter: blur(8px);
}
.selection-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.selection-kind {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}
.selection-id { font-family: var(--mono); font-weight: 700; font-size: 13.5px; overflow-wrap: anywhere; }
.selection-head .btn.icon { margin-left: auto; }
.selection-props { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; margin: 0 0 8px; font-size: 11.5px; }
.selection-props dt { color: var(--muted); }
.selection-props dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.selection-edit { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.selection-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.selection-actions:empty { display: none; }

/* ================================================================ MODALS, COMMAND PALETTE & BRAND SYSTEM */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.78);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.modal-card {
  width: min(760px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow), var(--specular);
  padding: 16px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; color: var(--heading); font-family: var(--font-display); }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric-big { font-size: 20px; font-weight: 800; color: var(--ok); font-family: var(--mono); }
.roi-card { gap: 10px; }
.roi-summary { font-size: 13.5px; }
.roi-summary strong { color: var(--ok); font-size: 16px; font-family: var(--mono); }
.roi-summary a { color: var(--accent); }

/* Native <dialog> Modals (Command Palette & Brand Inspector) */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow), var(--specular);
  padding: 0;
  width: min(720px, 94vw);
  max-height: 85vh;
  overflow: hidden;
}
dialog.modal:not([open]) {
  display: none;
}
dialog.modal[open] {
  display: flex;
  flex-direction: column;
}
dialog.modal::backdrop {
  background: rgba(4, 8, 16, 0.76);
  backdrop-filter: blur(6px);
}

dialog.cmd-modal {
  width: min(640px, 94vw);
}

.cmd-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.cmd-search-icon {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}
.cmd-search-input {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  color: var(--heading);
  font: 600 13.5px var(--sans);
  padding: 4px 2px;
  outline: none;
}
.cmd-search-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  max-height: 370px;
  overflow-y: auto;
}
.cmd-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.cmd-item:hover,
.cmd-item.active {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.cmd-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.cmd-item-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  flex: none;
}
.cmd-item-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--heading);
}
.cmd-item-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  flex: none;
}

.cmd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* Brand & Design System Modal */
.brand-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.brand-modal-head h2 {
  margin: 0;
  font-size: 15px;
  font-family: var(--font-display);
  color: var(--heading);
}
.brand-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.theme-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}
.theme-preset-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  box-shadow: var(--specular);
}
.theme-preset-card:hover,
.theme-preset-card.active {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.theme-swatch-row {
  display: flex;
  gap: 5px;
}
.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.dot-obsidian-bg { background: #060911; }
.dot-obsidian-acc { background: #00e5ff; }
.dot-obsidian-amb { background: #f59e0b; }
.dot-light-bg { background: #f1f5f9; }
.dot-light-acc { background: #0284c7; }
.dot-light-amb { background: #d97706; }
.dot-foundry-bg { background: #05090c; }
.dot-foundry-acc { background: #10b981; }
.dot-foundry-amb { background: #06b6d4; }
.dot-kinetic-bg { background: #09090b; }
.dot-kinetic-acc { background: #ff9f1c; }
.dot-kinetic-amb { background: #00f0ff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: var(--radius);
  background: #3a1414;
  color: #fca5a5;
  border: 1px solid var(--err);
  box-shadow: var(--shadow);
  font-weight: 650;
}
.toast.ok { background: #0f2e1c; color: #86efac; border-color: var(--ok); }

/* ================================================================ RESPONSIVE BREAKPOINTS */
.topbar { gap: 8px 12px; padding: 10px 14px; }
.brand-name { letter-spacing: .02em; font-size: 13px; }
.logo { box-shadow: none; border-color: var(--border); background: var(--panel-2); }
.scene-picker { flex: 1 1 190px; max-width: 310px; }
.scene-picker select { min-width: 0; width: 100%; color: var(--text); }
.transport { flex-wrap: wrap; }
.tools { flex-wrap: nowrap; }
.btn, select { min-height: 34px; }
.studio-tools { position: relative; }
.studio-tools > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.studio-tools > summary::after { content: '⌄'; color: var(--muted); }
.studio-tools > summary::-webkit-details-marker { display: none; }
.studio-tools[open] > summary { border-color: var(--accent); }
.tool-menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(390px, calc(100vw - 28px));
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
  box-shadow: var(--shadow); max-height: calc(100dvh - 100px); overflow-y: auto;
}
.tool-menu .export-group { grid-column: 1 / -1; padding: 8px 0; border-block: 1px solid var(--border); }
.tool-menu .export-group select { flex: 1; min-width: 0; }
.tool-menu .btn { justify-content: center; }
.panel-scrim, .drawer-head { display: none; }
.mobile-command { display: none; }
.mobile-connection { display: none; }
.full-btn, .plc-toolbar .btn { white-space: normal; line-height: 1.4; height: auto; }
.bottom-bar { flex-wrap: wrap; padding: 0; min-width: 0; flex-shrink: 0; }
.bottom-bar .dock-tabs { min-width: 0; width: 100%; }
.bottom-actions { padding: 6px 10px; flex-wrap: wrap; }
.dock-tabs { scrollbar-width: thin; }
.dock-tab { min-height: 38px; font-size: 12px; padding: 8px 12px; flex: 0 0 auto; }
.left-dock .dock-tab { flex: 1 1 auto; padding-inline: 8px; }
.side > .dock-tabs { flex-wrap: wrap; overflow: visible; }
.side > .dock-tabs .dock-tab { flex: 1 1 auto; }
.center-stage { grid-template-rows: minmax(0, 1fr) 224px; }
.hud-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-banner { left: 12px; }
#hud-hint { max-width: 100%; font-weight: 400; }
.scene-card { box-shadow: none; padding: 10px 12px; }
.scene-card.active { background: var(--panel-3); border-color: var(--accent); }
.badge-scan { border-color: var(--border); color: var(--muted); background: var(--panel-2); }
.about-dialog { padding: 0; }
.about-dialog .modal-card { width: auto; border: 0; margin: 0; box-shadow: none; max-height: 85dvh; overflow: auto; }
:is(button, a, select, input, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 1320px) {
  .main { grid-template-columns: 224px minmax(0, 1fr) 354px; }
  .topbar .scene-picker { max-width: 250px; }
  .topbar .transport { order: 2; width: 100%; padding-top: 4px; border-top: 1px solid var(--border); }
}
@media (max-width: 980px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .left-dock, .side { display: none; }
  .panels-toggle { display: inline-block; }
  .left-dock, .side {
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(410px, 100%);
    z-index: 42;
    box-shadow: var(--shadow);
  }
  .left-dock { left: 0; }
  .side { right: 0; }
  .app.panels-open .side, .app.library-open .left-dock { display: flex; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .panel-scrim:not([hidden]) { display: block; position: absolute; inset: 0; background: #03060ba8; border: 0; z-index: 40; cursor: pointer; }
  .center-stage { grid-template-rows: minmax(0, 1fr) 208px; }
  .tool-menu { z-index: 60; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .topbar .brand { flex: 1; }
  .brand-titles .site-name, .brand-ver, .kbd-hint { display: none; }
  .brand-name { font-size: 12px; }
  .brand { gap: 5px; padding: 0; }
  .logo { width: 24px; height: 24px; }
  .tools { gap: 4px; }
  .tools > .cmd-trigger-btn { display: none; }
  .mobile-command { display: block; grid-column: 1 / -1; }
  .mobile-connection { display: inline-flex; position: absolute; bottom: 8px; left: 8px; z-index: 5; }
  .tools > #conn { display: none; }
  .tools .btn, .tools summary { padding-inline: 8px; }
  .topbar .scene-picker { order: 1; width: 100%; max-width: none; flex-basis: 100%; }
  .topbar .transport { gap: 4px; padding-top: 0; border: 0; }
  .transport .clock { margin-left: auto; font-size: 11px; padding-inline: 5px; }
  #plc-scans { display: none; }
  .transport .btn { padding-inline: 6px; font-size: 12px; }
  .speed select { width: 52px; }
  .speed-label { display: none; }
  .btn, select, .dock-tab { min-height: 40px; }
  #hud-hint { display: none; }
  .hud-banner { top: 40px; right: 8px; left: 8px; }
  .legend { left: 8px; right: 8px; top: 8px; max-width: none; gap: 4px; }
  .legend-item { font-size: 10px; padding-inline: 5px; }
  .label.minor { display: none; }
  .hud-chip { font-size: 10px; }
  .minimap-card { width: 154px; right: 8px; bottom: 8px; }
  #minimap-canvas { width: 142px; height: 87px; }
  .minimap-coords { display: none; }
  .bottom-actions { gap: 5px; padding: 5px 8px; }
  .bottom-actions .btn { font-size: 11px; }
  .center-stage { grid-template-rows: minmax(0, 1fr) 210px; }
  .tool-menu { position: fixed; top: 58px; right: 10px; max-height: calc(100dvh - 74px); }
}
@media (max-width: 360px) {
  .brand-titles { display: none; }
  .topbar .brand { flex: 0 0 24px; }
  .transport .clock { font-size: 10px; padding-inline: 3px; }
}
@media (max-height: 540px) and (max-width: 980px) {
  .center-stage { grid-template-rows: minmax(0, 1fr) 136px; }
  .minimap-card { display: none; }
  .tool-menu { position: fixed; top: 104px; right: 10px; max-height: calc(100dvh - 120px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
