/* J.A.R.V.I.S. HUD — Stark-lab holographic interface */
:root {
  --bg: #02070d;
  --bg-2: #041420;
  --panel: rgba(6, 26, 40, 0.58);
  --panel-solid: #061a28;
  --line: rgba(88, 214, 255, 0.22);
  --line-strong: rgba(88, 214, 255, 0.55);
  --cyan: #58d6ff;
  --cyan-hi: #b8f0ff;
  --cyan-dim: #2a7fa3;
  --amber: #ffb547;
  --amber-dim: #9a6420;
  --red: #ff4058;
  --green: #4dffb0;
  --text: #cdeffc;
  --text-dim: #6f9bb0;
  --glow: 0 0 12px rgba(88, 214, 255, 0.55);
  --glow-amber: 0 0 12px rgba(255, 181, 71, 0.55);
  --f-display: 'Orbitron', 'Rajdhani', sans-serif;
  --f-body: 'Rajdhani', system-ui, sans-serif;
  --f-mono: 'Share Tech Mono', ui-monospace, monospace;
  --cut: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  letter-spacing: 0.02em;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
::selection { background: rgba(88, 214, 255, 0.35); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── ambient backdrop ─────────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(30, 120, 170, 0.22), transparent 70%),
    radial-gradient(ellipse 40% 30% at 85% 90%, rgba(255, 160, 60, 0.06), transparent 70%),
    linear-gradient(180deg, #03101a 0%, var(--bg) 60%);
}
.backdrop::before { /* holo grid */
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(88, 214, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 214, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
}
.backdrop::after { /* scanlines */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.sweep {
  position: fixed; left: 0; right: 0; top: -20%; height: 20%; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(88, 214, 255, 0.05), transparent);
  animation: sweep 9s linear infinite;
}
@keyframes sweep { to { top: 120%; } }

/* ── layout ───────────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 420px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'top top top'
    'left center right'
    'left fleet right';
  gap: 14px;
  height: 100vh;
  padding: 14px 16px;
}
.topbar { grid-area: top; }
.col-left { grid-area: left; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
.col-center { grid-area: center; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.col-right { grid-area: right; min-height: 0; display: flex; }
.fleet { grid-area: fleet; }

/* ── panels ───────────────────────────────────────────────────── */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  backdrop-filter: blur(6px);
  padding: 14px 16px 16px;
}
.panel::before, .panel::after { /* corner ticks */
  content: ''; position: absolute; width: 22px; height: 22px; pointer-events: none;
  border-color: var(--cyan); border-style: solid; opacity: 0.85;
}
.panel::before { top: 0; right: 0; border-width: 2px 2px 0 0; }
.panel::after { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-display); font-size: 11px; font-weight: 600;
  letter-spacing: 0.24em; color: var(--cyan); text-transform: uppercase;
  margin-bottom: 12px;
}
.panel-head::before { content: ''; width: 6px; height: 6px; background: var(--cyan); box-shadow: var(--glow); transform: rotate(45deg); }
.panel-head .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.panel-head .aux { font-family: var(--f-mono); letter-spacing: 0.08em; color: var(--text-dim); font-size: 11px; font-weight: 400; }

/* ── top bar ──────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 6px 4px 10px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar::after {
  content: ''; position: absolute; left: 0; bottom: -1px; width: 180px; height: 2px;
  background: var(--cyan); box-shadow: var(--glow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; }
.brand-name {
  font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: 0.32em;
  color: var(--cyan-hi); text-shadow: var(--glow);
}
.brand-sub { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--text-dim); }
.clock { margin-left: auto; text-align: right; }
.clock-time { font-family: var(--f-display); font-size: 26px; font-weight: 500; letter-spacing: 0.12em; color: var(--cyan-hi); text-shadow: var(--glow); }
.clock-time .sec { font-size: 15px; color: var(--cyan); }
.clock-date { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.22em; color: var(--text-dim); }
.status-chips { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em;
  padding: 5px 10px; border: 1px solid var(--line); color: var(--text-dim);
  background: rgba(4, 20, 32, 0.6); text-transform: uppercase; white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 400; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex: none; }
.dot.warn { background: var(--amber); box-shadow: var(--glow-amber); }
.dot.bad { background: var(--red); box-shadow: 0 0 8px var(--red); animation: blink 1s steps(2) infinite; }
.dot.idle { background: var(--text-dim); box-shadow: none; }
@keyframes blink { 50% { opacity: 0.25; } }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  width: 32px; height: 32px; display: inline-grid; place-items: center; cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s;
}
.icon-btn:hover { color: var(--cyan-hi); border-color: var(--cyan); box-shadow: var(--glow); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── gauges ───────────────────────────────────────────────────── */
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gauge { position: relative; aspect-ratio: 1; }
.gauge svg { width: 100%; height: 100%; overflow: visible; }
.gauge .track { stroke: rgba(88, 214, 255, 0.12); }
.gauge .ticks { stroke: rgba(88, 214, 255, 0.35); }
.gauge .val { stroke: var(--cyan); filter: drop-shadow(0 0 4px var(--cyan)); transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1), stroke .3s; }
.gauge.warn .val { stroke: var(--amber); filter: drop-shadow(0 0 4px var(--amber)); }
.gauge.bad .val { stroke: var(--red); filter: drop-shadow(0 0 4px var(--red)); }
.gauge-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge-num { font-family: var(--f-display); font-size: 20px; font-weight: 600; color: var(--cyan-hi); line-height: 1; }
.gauge-num small { font-size: 10px; color: var(--cyan); }
.gauge-cap { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.2em; color: var(--text-dim); margin-top: 4px; }

.cores { display: grid; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); gap: 6px; margin-top: 12px; }
.core { font-family: var(--f-mono); font-size: 10px; color: var(--text-dim); }
.core-bar { height: 26px; background: rgba(88, 214, 255, 0.06); border: 1px solid var(--line); position: relative; overflow: hidden; margin-bottom: 3px; }
.core-bar i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(0deg, var(--cyan-dim), var(--cyan)); transition: height .8s; }

.stat-rows { display: grid; gap: 10px; }
.stat-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 11.5px; }
.stat-row .k { color: var(--text-dim); letter-spacing: 0.14em; }
.stat-row .v { color: var(--text); text-align: right; white-space: nowrap; }
.bar { height: 6px; background: rgba(88, 214, 255, 0.08); position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--cyan); box-shadow: var(--glow); transition: width .8s; }
.bar.warn i { background: var(--amber); box-shadow: var(--glow-amber); }
.bar.bad i { background: var(--red); }
.bar::after { /* segment notches */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, var(--bg) 9px 11px);
}

.spark-wrap { position: relative; }
.spark { width: 100%; height: 70px; display: block; }
.spark-legend { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.spark-legend .rx { color: var(--cyan); }
.spark-legend .tx { color: var(--amber); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-family: var(--f-mono); font-size: 11.5px; }
.kv-grid div { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(88, 214, 255, 0.12); padding-bottom: 4px; }
.kv-grid span { color: var(--text-dim); letter-spacing: 0.12em; }

/* ── center: reactor + launcher ───────────────────────────────── */
.hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 28px; padding: 6px 8px 18px; }
.reactor { width: 210px; height: 210px; position: relative; }
.reactor svg { width: 100%; height: 100%; overflow: visible; }
.reactor .spin-slow { animation: spin 40s linear infinite; transform-origin: 50% 50%; transform-box: fill-box; }
.reactor .spin-rev { animation: spin 26s linear infinite reverse; transform-origin: 50% 50%; transform-box: fill-box; }
.reactor .spin-fast { animation: spin 9s linear infinite; transform-origin: 50% 50%; transform-box: fill-box; }
.reactor .core { animation: pulse 3.2s ease-in-out infinite; transform-origin: 50% 50%; transform-box: fill-box; }
.reactor.thinking .spin-fast { animation-duration: 1.4s; }
.reactor.thinking .core { animation-duration: .9s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .85; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
.greeting h1 {
  font-family: var(--f-display); font-weight: 600; font-size: clamp(22px, 2.4vw, 34px);
  margin: 0; letter-spacing: 0.08em; color: var(--cyan-hi); text-shadow: var(--glow);
}
.greeting p { margin: 6px 0 16px; color: var(--text-dim); font-size: 16px; max-width: 560px; }
.greeting p b { color: var(--text); font-weight: 600; }

.cmdbar { position: relative; max-width: 620px; }
.cmdbar input {
  width: 100%; padding: 13px 16px 13px 44px;
  background: rgba(3, 16, 26, 0.85); border: 1px solid var(--line-strong); outline: none;
  font-family: var(--f-mono); font-size: 14px; letter-spacing: 0.06em; color: var(--cyan-hi);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: border-color .15s, box-shadow .15s;
}
.cmdbar input::placeholder { color: var(--text-dim); }
.cmdbar input:focus { border-color: var(--cyan); box-shadow: inset 0 0 24px rgba(88, 214, 255, 0.12); }
.cmdbar .prompt { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--cyan); font-family: var(--f-mono); }
.cmdbar kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
kbd { font-family: var(--f-mono); font-size: 10px; color: var(--text-dim); border: 1px solid var(--line); padding: 2px 6px; }

.app-group { margin-bottom: 18px; }
.app-group-title {
  font-family: var(--f-display); font-size: 11px; letter-spacing: 0.3em; color: var(--text-dim);
  text-transform: uppercase; margin: 0 0 10px; display: flex; align-items: center; gap: 10px;
}
.app-group-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.app {
  --hue: var(--cyan);
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; text-decoration: none; color: var(--text);
  background: linear-gradient(135deg, rgba(10, 40, 60, 0.55), rgba(4, 18, 28, 0.55));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  transition: border-color .15s, transform .15s, background .15s;
}
.app.amber { --hue: var(--amber); }
.app:hover, .app:focus-visible, .app.sel {
  border-color: var(--hue); outline: none; transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(20, 70, 100, 0.6), rgba(4, 22, 34, 0.7));
}
.app:hover .glyph, .app.sel .glyph { box-shadow: 0 0 16px var(--hue), inset 0 0 12px var(--hue); }
.glyph {
  width: 40px; height: 44px; flex: none; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 13px; color: var(--hue);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: radial-gradient(circle, rgba(88, 214, 255, 0.12), rgba(88, 214, 255, 0.03));
  box-shadow: inset 0 0 0 1px var(--hue);
  transition: box-shadow .2s;
  position: relative;
}
.glyph::before { /* hex outline */
  content: ''; position: absolute; inset: 0; background: var(--hue); opacity: .5;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%, 0 25%, 4% 27.3%, 4% 72.7%, 50% 95.5%, 96% 72.7%, 96% 27.3%, 50% 4.5%, 4% 27.3%, 0 25%);
}
.app-meta { min-width: 0; flex: 1; }
.app-name { font-weight: 700; font-size: 15px; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-desc { font-family: var(--f-mono); font-size: 10.5px; color: var(--text-dim); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app .dot { position: absolute; top: 9px; right: 14px; width: 6px; height: 6px; }
.app .lat { position: absolute; bottom: 6px; right: 12px; font-family: var(--f-mono); font-size: 9.5px; color: var(--text-dim); }

/* ── fleet (containers) ───────────────────────────────────────── */
.fleet { max-height: 30vh; display: flex; flex-direction: column; }
.fleet-body { overflow-y: auto; min-height: 0; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ctr {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px;
  padding: 8px 10px; border: 1px solid var(--line); background: rgba(4, 20, 32, 0.5);
  font-family: var(--f-mono); font-size: 11px;
}
.ctr.down { border-color: rgba(255, 64, 88, 0.45); background: rgba(40, 6, 14, 0.4); }
.ctr-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.ctr-stats { grid-column: 2 / 3; color: var(--text-dim); display: flex; gap: 10px; }
.ctr-stats .hot { color: var(--amber); }
.ctr-stats .ask { color: var(--amber); letter-spacing: 0.16em; }
.ctr-stats { white-space: nowrap; }
.ctr-actions { grid-row: 1 / 3; grid-column: 3; display: flex; gap: 4px; opacity: .35; transition: opacity .15s; }
.ctr:hover .ctr-actions, .ctr:focus-within .ctr-actions { opacity: 1; }
.ctr-actions .icon-btn { width: 26px; height: 26px; }
.ctr-actions .icon-btn svg { width: 13px; height: 13px; }
.ctr .dot { grid-row: 1 / 3; }
.stack { margin-bottom: 12px; }
.stack:last-child { margin-bottom: 0; }
.stack-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--text-dim);
  padding: 2px 0 7px;
}
.stack-head:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
.stack-head:hover .stack-name { color: var(--cyan-hi); }
.chev { display: inline-grid; transition: transform .15s; color: var(--cyan); }
.chev svg { width: 12px; height: 12px; }
.stack.collapsed .chev { transform: rotate(-90deg); }
.stack.collapsed .fleet-grid { display: none; }
.stack.collapsed .stack-head { padding-bottom: 2px; }
.stack-name { font-family: var(--f-display); font-size: 11.5px; font-weight: 600; letter-spacing: 0.18em; color: var(--text); text-transform: uppercase; transition: color .15s; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; letter-spacing: 0.14em; padding: 1px 6px; border: 1px solid var(--line); color: var(--text-dim); }
.tag svg { width: 9px; height: 9px; }
.tag.portainer { color: var(--cyan); border-color: rgba(88, 214, 255, 0.4); }
.tag.aio { color: #9fb7ff; border-color: rgba(159, 183, 255, 0.4); }
.tag.locked { color: var(--amber); border-color: rgba(255, 181, 71, 0.5); }
.stack-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); min-width: 10px; }
.stack-meta { white-space: nowrap; }
.stack-meta .warn { color: var(--amber); }
.stack-link { color: var(--amber); text-decoration: none; font-size: 10px; letter-spacing: 0.14em; border: 1px solid rgba(255, 181, 71, 0.5); padding: 1px 7px; }
.stack-link:hover { background: rgba(255, 181, 71, 0.15); }
.ctr.locked .ctr-actions { opacity: .6; }
.lock { width: 26px; height: 26px; display: inline-grid; place-items: center; color: var(--amber); }
.lock svg { width: 13px; height: 13px; }
.ctr.pending { border-color: var(--amber); box-shadow: inset 0 0 18px rgba(255, 181, 71, 0.12); }
.ctr-confirm { grid-row: 1 / 3; grid-column: 3; display: flex; flex-direction: column; gap: 4px; }
.ctr-confirm .tool { margin: 0; }
.mini-btn {
  background: none; border: 1px solid var(--line); color: var(--text-dim); cursor: pointer;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 8px;
}
.mini-btn:hover { color: var(--text); border-color: var(--line-strong); }
.mini-btn.amber { border-color: var(--amber); color: var(--amber); background: rgba(255, 181, 71, 0.1); animation: armed 1.2s ease-in-out infinite; }
.mini-btn.amber:hover { background: rgba(255, 181, 71, 0.25); }
@keyframes armed { 50% { box-shadow: 0 0 10px rgba(255, 181, 71, 0.6); } }
.filter-tabs { display: flex; gap: 4px; }
.filter-tabs button {
  background: none; border: 1px solid transparent; color: var(--text-dim); cursor: pointer;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.12em; padding: 2px 8px; text-transform: uppercase;
}
.filter-tabs button.on { border-color: var(--line-strong); color: var(--cyan); }

/* ── JARVIS console (chat) ────────────────────────────────────── */
.console { display: flex; flex-direction: column; width: 100%; padding: 0; }
.console-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.console-head .panel-head { margin-bottom: 10px; }
.console-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.select {
  appearance: none; background: rgba(3, 16, 26, 0.9); border: 1px solid var(--line);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--text);
  padding: 6px 24px 6px 9px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%;
  background-size: 4px 4px; background-repeat: no-repeat;
}
.select:focus { outline: 1px solid var(--cyan); }
.console-controls .grow { flex: 1; }
.connectors { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.conn { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.06em; padding: 2px 7px; border: 1px solid var(--line); color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; }
.conn .dot { width: 5px; height: 5px; }

.history { display: none; border-bottom: 1px solid var(--line); max-height: 40%; overflow-y: auto; background: rgba(2, 10, 18, 0.6); }
.history.open { display: block; }
.history-item { display: flex; align-items: center; gap: 8px; padding: 9px 16px; cursor: pointer; border-bottom: 1px solid rgba(88, 214, 255, 0.07); font-size: 14px; }
.history-item:hover, .history-item.on { background: rgba(88, 214, 255, 0.07); }
.history-item .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item time { font-family: var(--f-mono); font-size: 10px; color: var(--text-dim); }
.history-item .del { opacity: 0; border: 0; background: none; color: var(--text-dim); cursor: pointer; }
.history-item:hover .del { opacity: 1; }
.history-item .del:hover { color: var(--red); }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 0; scroll-behavior: smooth; }
.empty { margin: auto; text-align: center; color: var(--text-dim); max-width: 300px; }
.empty .reactor { width: 120px; height: 120px; margin: 0 auto 14px; }
.empty h3 { font-family: var(--f-display); letter-spacing: 0.2em; color: var(--cyan); font-size: 13px; margin: 0 0 8px; }
.suggests { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.suggests button {
  background: rgba(88, 214, 255, 0.05); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; text-align: left; cursor: pointer; font-size: 14px;
}
.suggests button:hover { border-color: var(--cyan); color: var(--cyan-hi); }

.msg { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 86%; }
.msg.user .bubble {
  background: rgba(255, 181, 71, 0.08); border: 1px solid rgba(255, 181, 71, 0.35);
  padding: 9px 13px; white-space: pre-wrap; word-wrap: break-word;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}
.msg-tag { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.2em; color: var(--text-dim); margin-bottom: 5px; }
.msg.user .msg-tag { text-align: right; color: var(--amber-dim); }
.msg.ai .msg-tag { color: var(--cyan-dim); }
.msg.ai .bubble { border-left: 2px solid var(--cyan); padding: 2px 0 2px 13px; line-height: 1.55; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .7em; }
.md h1, .md h2, .md h3 { font-family: var(--f-display); font-size: 13px; letter-spacing: .14em; color: var(--cyan); margin: 1em 0 .5em; text-transform: uppercase; }
.md code { font-family: var(--f-mono); background: rgba(88, 214, 255, 0.08); padding: 1px 5px; font-size: 13px; }
.md pre { background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; font-size: 13.5px; margin: .5em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 9px; text-align: left; }
.md th { color: var(--cyan); font-weight: 600; background: rgba(88, 214, 255, 0.06); }
.md ul, .md ol { padding-left: 1.3em; margin: 0 0 .7em; }
.md blockquote { margin: .5em 0; padding: 4px 10px; border-left: 2px solid var(--amber); color: var(--amber); background: rgba(255, 181, 71, 0.06); }
.md a { color: var(--cyan-hi); }
.cursor::after { content: '▍'; color: var(--cyan); animation: blink .9s steps(2) infinite; margin-left: 1px; }

.tool {
  display: inline-flex; align-items: center; gap: 8px; margin: 4px 0;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--text-dim);
  border: 1px solid var(--line); padding: 4px 9px; background: rgba(88, 214, 255, 0.04);
}
.tool b { color: var(--cyan); font-weight: 400; }
.tool .spin { width: 10px; height: 10px; border: 1.5px solid var(--cyan); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.tool .ok { color: var(--green); }
.tool .err { color: var(--red); }

.approval {
  border: 1px solid var(--amber); background: rgba(255, 181, 71, 0.07); padding: 12px; margin: 6px 0;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.approval h4 { margin: 0 0 6px; font-family: var(--f-display); font-size: 11px; letter-spacing: 0.24em; color: var(--amber); }
.approval .what { font-family: var(--f-mono); font-size: 12px; margin-bottom: 6px; }
.approval pre { font-family: var(--f-mono); font-size: 11px; max-height: 160px; overflow: auto; background: rgba(0,0,0,.4); padding: 8px; margin: 0 0 10px; white-space: pre-wrap; word-break: break-all; }
.approval .row { display: flex; gap: 8px; }
.approval.resolved { opacity: .6; }
.btn {
  border: 1px solid var(--cyan); background: rgba(88, 214, 255, 0.1); color: var(--cyan-hi);
  font-family: var(--f-display); font-size: 11px; letter-spacing: 0.2em; padding: 8px 14px; cursor: pointer;
  text-transform: uppercase; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(88, 214, 255, 0.22); box-shadow: var(--glow); }
.btn.amber { border-color: var(--amber); color: var(--amber); background: rgba(255, 181, 71, 0.1); }
.btn.amber:hover { background: rgba(255, 181, 71, 0.22); box-shadow: var(--glow-amber); }
.btn.armed { animation: armed 1.2s ease-in-out infinite; background: rgba(255, 181, 71, 0.22); }
.btn.ghost { border-color: var(--line); color: var(--text-dim); background: none; }
.btn.ghost:hover { color: var(--red); border-color: var(--red); box-shadow: none; }

.composer { border-top: 1px solid var(--line); padding: 12px 14px 14px; }
.composer-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line-strong); background: rgba(2, 12, 20, 0.9); padding: 6px 6px 6px 12px; }
.composer-box:focus-within { border-color: var(--cyan); box-shadow: inset 0 0 20px rgba(88, 214, 255, 0.08); }
.composer textarea {
  flex: 1; resize: none; background: none; border: 0; outline: none; padding: 7px 0;
  max-height: 160px; font-size: 15px; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--text-dim); }
.composer .icon-btn.on { color: var(--red); border-color: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1.2s steps(2) infinite; }
.send { background: var(--cyan); color: #00121c; border-color: var(--cyan); }
.send:hover { color: #00121c; background: var(--cyan-hi); }
.send.stop { background: var(--red); border-color: var(--red); }
.composer-foot { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 10px; color: var(--text-dim); margin-top: 6px; letter-spacing: 0.08em; }
.composer-foot label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }

/* ── modal ────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0, 6, 12, 0.78); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal.open { display: grid; }
.modal .panel { width: min(1000px, 100%); height: min(80vh, 760px); display: flex; flex-direction: column; background: var(--panel-solid); }
.modal pre { flex: 1; overflow: auto; margin: 0; font-family: var(--f-mono); font-size: 12px; line-height: 1.45; color: var(--text); white-space: pre-wrap; word-break: break-all; }

/* ── boot overlay ─────────────────────────────────────────────── */
.boot { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: grid; place-items: center; transition: opacity .6s ease .1s, visibility .6s .1s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-lines { font-family: var(--f-mono); font-size: 12px; color: var(--cyan); letter-spacing: 0.14em; min-width: 300px; }
.boot-lines div { opacity: 0; animation: fadein .2s forwards; }
.boot-lines div span { color: var(--green); float: right; }
@keyframes fadein { to { opacity: 1; } }

.mobile-tabs { display: none; }

/* ── responsive ───────────────────────────────────────────────── */
@media (max-width: 1400px) {
  .hud { grid-template-columns: 290px minmax(0, 1fr) 380px; }
  .reactor { width: 170px; height: 170px; }
}
@media (max-width: 1100px) {
  .hud {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: 'top top' 'center right' 'left right' 'fleet fleet';
    height: auto; min-height: 100vh;
  }
  .col-right { height: calc(100vh - 100px); position: sticky; top: 14px; }
  .col-left { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .fleet { max-height: none; }
}
@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: 64px; }
  .hud { display: block; padding: 10px 16px; height: auto; }
  .hud > * { margin-bottom: 14px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .brand-name { font-size: 17px; }
  .brand-sub, .status-chips .chip:nth-child(n+2) { display: none; }
  .clock-time { font-size: 20px; }
  .col-left { display: flex; }
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 12px; }
  .reactor { width: 140px; height: 140px; }
  .cmdbar { margin: 0 auto; }
  .app-grid { grid-template-columns: 1fr 1fr; }
  .app { padding: 9px; gap: 9px; }
  .glyph { width: 34px; height: 38px; font-size: 11px; }
  .col-right { position: fixed; inset: 0 0 56px 0; height: auto; z-index: 30; margin: 0; display: none; }
  .col-right .panel { clip-path: none; background: var(--panel-solid); backdrop-filter: none; }
  .app .lat { display: none; }
  body.chat-open .col-right { display: flex; }
  [data-view]:not(.view-on) { display: none !important; }
  body.chat-open [data-view] { display: none !important; }
  .mobile-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 56px; z-index: 40;
    background: rgba(2, 10, 18, 0.96); border-top: 1px solid var(--line-strong);
  }
  .mobile-tabs button {
    flex: 1; background: none; border: 0; color: var(--text-dim); cursor: pointer;
    font-family: var(--f-display); font-size: 9.5px; letter-spacing: 0.18em;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  }
  .mobile-tabs button svg { width: 18px; height: 18px; }
  .mobile-tabs button.on { color: var(--cyan); text-shadow: var(--glow); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 760px) {
  .stack-head { flex-wrap: wrap; row-gap: 4px; }
  .stack-rule { display: none; }
  .stack-meta { margin-left: auto; }
}
@media (max-width: 760px) {
  .fleet > .panel-head { flex-wrap: wrap; }
  .fleet > .panel-head .aux { display: none; }
}
