:root {
  --bg: #01050a;
  --panel: rgba(6, 14, 22, 0.46);
  --line: rgba(140, 200, 240, 0.17);
  --line-mid: rgba(150, 212, 255, 0.3);
  --line-hot: rgba(175, 225, 255, 0.72);
  --ice: #a8dcff;
  --ice-2: #6aabd0;
  --dim: #43697f;
  --white: #eaf7ff;
  --amber: #f0b46a;
  --danger: #ff6b74;
  --ok: #57e0a4;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: #a9cee2;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ───────── ambient ───────── */

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 820px at 50% 44%, rgba(24, 96, 138, 0.2), transparent 74%),
    linear-gradient(rgba(140, 200, 240, 0.028) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, rgba(140, 200, 240, 0.028) 1px, transparent 1px) 0 0 / 44px 100%;
}

body::after {
  content: '';
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.26) 2px 3px);
  opacity: 0.38;
}

.vignette {
  position: fixed; inset: 0; z-index: 65; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.8) 100%);
}

.sweep {
  position: fixed; left: 0; right: 0; height: 160px; z-index: 64; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(150, 215, 255, 0.045), transparent);
  animation: sweep 9s linear infinite;
}
@keyframes sweep { from { transform: translateY(-180px); } to { transform: translateY(100vh); } }

/* ───────── shell ───────── */

.shell {
  position: relative; z-index: 10;
  height: 100vh;
  display: grid;
  grid-template-rows: 44px 1fr 18px;
  gap: 8px;
  padding: 8px 12px 6px;
}

.deck {
  display: grid;
  grid-template-columns: 252px 1fr 288px;
  gap: 10px;
  min-height: 0;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ───────── surfaces + brackets ───────── */

.rail, .mod, .stage, .ovl {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
}

.rail::before, .rail::after,
.mod::before, .mod::after,
.stage::before, .stage::after {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  pointer-events: none;
  z-index: 5;
}
.rail::before, .mod::before, .stage::before {
  top: -1px; left: -1px;
  border-top: 1px solid var(--line-hot);
  border-left: 1px solid var(--line-hot);
}
.rail::after, .mod::after, .stage::after {
  bottom: -1px; right: -1px;
  border-bottom: 1px solid var(--line-hot);
  border-right: 1px solid var(--line-hot);
}

.mod { display: flex; flex-direction: column; min-height: 0; overflow: hidden; flex: 0 0 auto; }
.mod.grow { flex: 1 1 auto; }

/* ───────── rail ───────── */

.rail { display: flex; align-items: center; gap: 13px; padding: 0 13px; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand span {
  letter-spacing: 0.44em;
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  text-shadow: 0 0 18px rgba(150, 215, 255, 0.65);
}

.rail-sep { width: 1px; height: 17px; background: var(--line-mid); }
.rail-spacer { flex: 1; }

.rail-state { font-size: 10px; letter-spacing: 0.2em; color: #9ec3d8; text-transform: uppercase; white-space: nowrap; }
.rail-state b { color: var(--white); font-weight: 500; }
.sl { color: var(--ice-2); opacity: 0.55; }

.rail-metrics { display: flex; gap: 15px; font-size: 9px; letter-spacing: 0.16em; color: var(--dim); text-transform: uppercase; }
.rail-metrics b { color: var(--ice); font-weight: 500; font-variant-numeric: tabular-nums; }

.rail-clock { font-size: 11px; letter-spacing: 0.1em; color: var(--white); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rail-clock span { color: var(--dim); font-size: 10px; margin-left: 4px; }

/* ───────── buttons ───────── */

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line-mid);
  color: var(--dim);
  font-family: inherit;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ghost-btn:hover { color: var(--ice); border-color: var(--line-hot); box-shadow: inset 0 0 10px rgba(150, 215, 255, 0.15); }
.ghost-btn.mini { padding: 1px 6px; font-size: 10px; line-height: 1.3; }

/* ───────── module heads ───────── */

.mod-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(150, 215, 255, 0.055), transparent 72%);
  flex: 0 0 auto;
}
.mod-head h2 {
  margin: 0;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--white);
}
.mod-head .x { color: var(--ice-2); opacity: 0.5; font-size: 8px; margin-left: auto; }
.sp { flex: 1; }

.count {
  font-size: 8px; letter-spacing: 0.1em; color: var(--ice);
  border: 1px solid var(--line-mid); padding: 1px 5px; min-width: 18px; text-align: center;
}

.pad { padding: 9px 10px; }

/* ───────── key/value + meters ───────── */

.kv {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 8.5px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--dim); line-height: 1.95;
}
.kv b { color: var(--ice); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }

.meter { margin-bottom: 8px; }
.bar { height: 2px; background: rgba(150, 215, 255, 0.11); margin-top: 3px; }
.bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, rgba(168, 220, 255, 0.45), var(--ice));
  box-shadow: 0 0 8px rgba(150, 215, 255, 0.55);
  transition: width 0.6s ease;
}

/* ───────── location / weather ───────── */

.loc-name { font-size: 13px; letter-spacing: 0.1em; color: var(--white); text-transform: uppercase; }
.loc-coord { font-size: 8.5px; letter-spacing: 0.12em; color: var(--dim); margin-top: 2px; }

.wx { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.wx-ico { font-size: 26px; color: var(--ice); line-height: 1; text-shadow: 0 0 16px rgba(150, 215, 255, 0.6); }
.wx-temp { font-size: 24px; color: var(--white); line-height: 1.1; font-variant-numeric: tabular-nums; }
.wx-cond { font-size: 8.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.wx-hl { margin-top: 8px; font-size: 8.5px; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }

/* ───────── network ───────── */

.spark { display: block; width: 100%; height: 34px; margin: 7px 0; }
.spark.wide { height: 40px; }

.nsplit { display: flex; gap: 14px; border-top: 1px solid var(--line); padding-top: 7px; }
.nlabel { font-size: 7.5px; letter-spacing: 0.2em; color: var(--dim); text-transform: uppercase; }
.nval { font-size: 12px; color: var(--white); font-variant-numeric: tabular-nums; }

/* ───────── stage ───────── */

.stage { overflow: hidden; }
#globe { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

.ovl {
  position: absolute;
  z-index: 3;
  background: rgba(3, 10, 17, 0.5);
  backdrop-filter: blur(2px);
  padding: 0;
}
.ovl-tl { top: 10px; left: 10px; width: 236px; }
.ovl-tr { top: 10px; right: 10px; width: 176px; }
.ovl-ml { top: 176px; left: 10px; width: 176px; }

.ovl-head {
  font-size: 7.5px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--ice-2);
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
}
.ovl-body { padding: 7px 8px; display: flex; gap: 10px; }
.ovl-body.col-body { flex-direction: column; gap: 0; }
.ovl-kv { flex: 1; }

.minigl { width: 86px; height: 86px; flex: 0 0 auto; }

.micro-note { font-size: 7px; letter-spacing: 0.22em; color: var(--dim); text-transform: uppercase; text-align: center; }

.sig-state {
  font-size: 9px; letter-spacing: 0.24em; color: var(--dim); text-transform: uppercase; margin-bottom: 4px;
}

.heard {
  font-size: 8.5px;
  color: var(--ice-2);
  line-height: 1.5;
  min-height: 24px;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ghost-btn.wide { width: 100%; margin-top: 7px; }

.btn-row { display: flex; gap: 5px; }

.diag {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.core-hint {
  margin-top: 7px;
  font-size: 8px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--dim);
}
.wave { display: block; width: 100%; height: 30px; margin-bottom: 4px; }

/* ───────── core identity ───────── */

.core-id {
  position: absolute;
  left: 50%; top: 52%;
  transform: translate(-50%, -50%);
  z-index: 4;
  text-align: center;
  pointer-events: none;
  width: min(420px, 60%);
}
.core-name {
  font-size: 21px;
  letter-spacing: 0.6em;
  text-indent: 0.6em;
  color: var(--white);
  text-shadow: 0 0 26px rgba(150, 215, 255, 0.8);
}
.bigwave { display: block; width: 100%; height: 46px; margin: 6px 0 2px; }
.core-state { font-size: 8.5px; letter-spacing: 0.34em; text-transform: uppercase; color: var(--ice-2); }

/* ───────── transcript ───────── */

.chat-log {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  width: min(600px, calc(100% - 40px));
  max-height: 27%;
  overflow-y: auto;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 4px 2px;
}

.msg {
  max-width: 92%;
  padding: 7px 10px;
  font-size: 11px;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: rgba(3, 11, 18, 0.62);
  backdrop-filter: blur(4px);
  animation: msg-in 0.22s ease-out;
}
.msg.rich { white-space: normal; }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.msg::before { display: block; font-size: 7px; letter-spacing: 0.28em; margin-bottom: 4px; }
.msg.assistant { align-self: flex-start; border-left: 2px solid var(--ice); color: #d1eafa; }
.msg.assistant::before { content: 'JARVIS'; color: var(--ice); }
.msg.user { align-self: flex-end; text-align: right; border-right: 2px solid var(--amber); color: #f0dcc0; }
.msg.user::before { content: 'OPERATOR'; color: var(--amber); }
.msg.pending { color: var(--dim); font-style: italic; }

.msg strong { color: #fff; font-weight: 600; }
.msg h4 { margin: 10px 0 4px; font-size: 8.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ice); }
.msg h4:first-child { margin-top: 0; }
.msg ul { margin: 4px 0; padding-left: 14px; }
.msg li { margin: 2px 0; }
.msg li::marker { color: var(--ice-2); }
.msg code { background: rgba(150, 215, 255, 0.12); padding: 1px 4px; }

/* ───────── command bar ───────── */

.cmd {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 40px));
  display: flex; align-items: center; gap: 8px;
  z-index: 5;
  background: rgba(3, 10, 17, 0.88);
  border: 1px solid var(--line-mid);
  padding: 6px 8px;
}
.cmd-mark { color: var(--ice); opacity: 0.75; }
.cmd input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--white);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 2px;
  outline: none;
}
.cmd input::placeholder { color: var(--dim); letter-spacing: 0.05em; }
.cmd button {
  background: rgba(150, 215, 255, 0.1);
  border: 1px solid var(--line-hot);
  color: var(--ice);
  font-family: inherit;
  font-size: 8.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.cmd button:hover { background: rgba(150, 215, 255, 0.2); box-shadow: 0 0 16px rgba(150, 215, 255, 0.3); }

/* ───────── lists ───────── */

.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }

.item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 6px 8px; margin-bottom: 4px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--ice-2);
  background: rgba(150, 215, 255, 0.02);
  transition: background 0.15s, border-color 0.15s;
}
.item:hover { background: rgba(150, 215, 255, 0.055); border-color: var(--line-mid); }

.item-title { font-size: 10.5px; color: #d6ebf8; line-height: 1.38; }
.item-meta { font-size: 7.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); margin-top: 2px; }

.item.priority-high { border-left-color: var(--danger); }
.item.priority-high .item-meta { color: var(--danger); }
.item.priority-medium { border-left-color: var(--amber); }
.item.status-done { opacity: 0.36; }
.item.status-done .item-title { text-decoration: line-through; }
.item.status-active { border-left-color: var(--ok); }
.item.status-active .item-meta { color: var(--ok); }

.item-check {
  width: 11px; height: 11px; flex: 0 0 auto;
  border: 1px solid var(--line-mid); cursor: pointer; margin-top: 2px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.item-check:hover { border-color: var(--ok); background: rgba(87, 224, 164, 0.25); box-shadow: 0 0 8px rgba(87, 224, 164, 0.35); }

.empty {
  padding: 11px 8px; font-size: 8px; letter-spacing: 0.2em;
  text-transform: uppercase; color: rgba(67, 105, 127, 0.7); text-align: center;
}

/* ───────── command hints ───────── */

.cmds { list-style: none; margin: 0; padding: 7px; overflow-y: auto; }
.cmds li {
  padding: 6px 8px;
  margin-bottom: 4px;
  border-left: 1px solid var(--line-mid);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cmds li:hover { background: rgba(150, 215, 255, 0.06); border-left-color: var(--ice); }
.cmds b { display: block; font-size: 10.5px; font-weight: 400; color: #d6ebf8; }
.cmds span { font-size: 7.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }

/* ───────── foot ───────── */

.foot {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  font-size: 7px; letter-spacing: 0.34em; text-transform: uppercase;
  color: rgba(67, 105, 127, 0.72);
}
.foot i { color: var(--ice-2); font-style: normal; opacity: 0.55; }

/* ───────── scrollbar ───────── */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(150, 215, 255, 0.22); }

/* ───────── login ───────── */

.boot { height: 100vh; display: grid; place-items: center; position: relative; z-index: 10; }
.boot-card {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line-mid);
  background: rgba(2, 8, 14, 0.9);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
  padding: 26px 24px 22px;
  text-align: center;
  position: relative;
}
.boot-card::before, .boot-card::after {
  content: ''; position: absolute; width: 11px; height: 11px;
}
.boot-card::before { top: -1px; left: -1px; border-top: 1px solid var(--line-hot); border-left: 1px solid var(--line-hot); }
.boot-card::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--line-hot); border-right: 1px solid var(--line-hot); }

.boot-card .brand { justify-content: center; margin-bottom: 15px; }
.login-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }

.boot-card p {
  margin: 0 0 15px; font-size: 8.5px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--dim);
}

.boot-card input {
  width: 100%;
  background: rgba(2, 9, 16, 0.82);
  border: 1px solid var(--line-mid);
  color: var(--white);
  font-family: inherit; font-size: 13px; letter-spacing: 0.2em; text-align: center;
  padding: 10px; outline: none; margin-bottom: 9px;
}
.boot-card input:focus { border-color: var(--line-hot); box-shadow: inset 0 0 16px rgba(150, 215, 255, 0.16); }

.boot-card button {
  width: 100%;
  background: rgba(150, 215, 255, 0.1);
  border: 1px solid var(--line-hot);
  color: var(--ice);
  font-family: inherit; font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase;
  padding: 11px; cursor: pointer;
}
.boot-card button:hover { background: rgba(150, 215, 255, 0.2); box-shadow: 0 0 20px rgba(150, 215, 255, 0.3); }

.boot-err {
  margin-top: 11px; min-height: 13px; font-size: 8px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--danger);
}

/* ───────── responsive ───────── */

@media (max-width: 1280px) {
  .deck { grid-template-columns: 222px 1fr 246px; }
  .ovl-tl { width: 206px; }
  .ovl-tr, .ovl-ml { width: 158px; }
}

@media (max-width: 1040px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; grid-template-rows: auto auto auto; }
  .deck { grid-template-columns: 1fr; }
  .stage { height: 74vh; min-height: 520px; order: -1; }
  .mod { max-height: 300px; }
  .rail { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 9px; }
  .rail-metrics { display: none; }
  .ovl-ml { display: none; }
}

@media (max-width: 720px) {
  .ovl-tl, .ovl-tr { position: static; width: auto; margin: 8px; }
  .stage { height: auto; }
  #globe { position: relative; height: 320px; }
  .core-id, .chat-log, .cmd { position: static; transform: none; width: auto; margin: 10px; }
  .chat-log { max-height: 340px; }
}

/* ───────── wake word training ───────── */

.train-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(1, 5, 10, 0.86);
  backdrop-filter: blur(4px);
}

.train-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line-mid);
  background: rgba(3, 11, 18, 0.96);
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.9);
  padding: 0 0 14px;
  text-align: center;
}

.train-card::before, .train-card::after {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
}
.train-card::before { top: -1px; left: -1px; border-top: 1px solid var(--line-hot); border-left: 1px solid var(--line-hot); }
.train-card::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--line-hot); border-right: 1px solid var(--line-hot); }

.train-head {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 7.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ice-2);
  text-align: left;
}

.train-step {
  margin-top: 16px;
  font-size: 8.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}

.train-prompt {
  margin: 14px 0 18px;
  font-size: 30px;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--ice-2);
  transition: color 0.12s, text-shadow 0.12s, transform 0.12s;
}

.train-prompt.live {
  color: #ffffff;
  text-shadow: 0 0 34px rgba(150, 215, 255, 0.95);
  transform: scale(1.06);
}

.train-bar {
  height: 2px;
  margin: 0 18px;
  background: rgba(150, 215, 255, 0.12);
}
.train-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ice);
  box-shadow: 0 0 10px rgba(150, 215, 255, 0.7);
  transition: width 0.25s ease;
}

.train-hint {
  margin: 12px 18px 14px;
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 0.08em;
  color: var(--dim);
  min-height: 30px;
}

.train-card .btn-row { padding: 0 18px; }
