:root {
  --bg: #050a0f;
  --bg-2: #081019;
  --cyan: #4be3ff;
  --cyan-dim: #1c8ba8;
  --cyan-glow: rgba(75, 227, 255, 0.55);
  --gold: #ffb238;
  --gold-glow: rgba(255, 178, 56, 0.55);
  --red: #ff4d4d;
  --text: #d9f6ff;
  --text-dim: #7fa9b8;
  --panel: rgba(9, 22, 32, 0.72);
  --panel-border: rgba(75, 227, 255, 0.25);
  --font-display: 'Orbitron', 'Rajdhani', sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, #0b1822 0%, var(--bg) 55%, #020407 100%);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
}

button, input {
  font-family: var(--font-body);
}

/* ---------- scrollbars (themed to match the HUD, not the OS default) ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dim) var(--bg-2);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-2);
}
::-webkit-scrollbar-thumb {
  background: var(--cyan-dim);
  border-radius: 5px;
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
}
::-webkit-scrollbar-corner {
  background: var(--bg-2);
}

/* ---------- ambient overlays ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(75, 227, 255, 0.035) 0px,
    rgba(75, 227, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
  opacity: 0.5;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 51;
  box-shadow: inset 0 0 220px rgba(0, 0, 0, 0.85);
}

/* ---------- layout ---------- */

.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 28px 22px;
  padding-left: calc(28px + env(safe-area-inset-left));
  padding-right: calc(28px + env(safe-area-inset-right));
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-ring {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow), inset 0 0 10px var(--cyan-glow);
  position: relative;
}
.brand-ring::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: pulse 2.4s ease-in-out infinite;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.status-cluster {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  font-size: 11px;
  letter-spacing: 1.5px;
}
.status-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
}
.status-chip.ok .dot { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.status-chip.bad .dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-chip .label { color: var(--text-dim); }
.status-chip .value { color: var(--text); font-weight: 600; }

.clock {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
  min-width: 92px;
  text-align: right;
}

/* Always-visible summary strip (stat cards + usage) — the at-a-glance parts
   of Mission Control worth keeping on the chat page. The four detail panels
   (agents/schedule/content/machines) stay modal-only; see .mc-box below. */
.mc-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.stage {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 24px;
  min-height: 0;
}

/* ---------- reactor column (chat is the main event — wide, not the
   cramped fixed-width sidebar it used to be). No max-width: on a large/
   fullscreen display the two columns should fill the page edge-to-edge
   rather than sit centered with dead space either side, so both this and
   .vault-graph-column grow to fill .stage — chat gets the bigger share
   (flex-grow 3 vs 2) since it's the primary surface. ---------- */

.reactor-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-height: 0;
  width: 100%;
  flex: 3 1 0;
}

/* ---------- vault graph column — persistent on the homescreen, right of
   chat on desktop (row order in the HTML puts it second → right side),
   below chat on narrow/mobile layouts (see the 980px breakpoint, which
   switches .stage to a column). Separate <svg>/instance from the one in
   the VAULT modal's GRAPH tab — see createVaultGraph() in app.js. ---------- */

.vault-graph-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  width: 100%;
  min-width: 300px;
  flex: 2 1 0;
}
.vault-graph-column-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--cyan);
}
.vault-graph-column-header span:first-child { flex-shrink: 0; }
.vault-graph-column-header input {
  flex: 1;
  min-width: 0;
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-body);
  letter-spacing: normal;
  outline: none;
}
.vault-graph-column-header input:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.home-graph-body {
  position: relative;
  flex: 1;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 40%, rgba(75, 227, 255, 0.05) 0%, transparent 70%);
}
#home-vault-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#home-vault-graph-svg.panning { cursor: grabbing; }

.reactor {
  position: relative;
  width: 170px;
  height: 170px;
  flex-shrink: 0;
  margin-top: 8px;
}

.reactor-rings { position: absolute; inset: 0; width: 100%; height: 100%; }

.ring {
  fill: none;
  stroke: var(--cyan-dim);
  stroke-width: 1;
  opacity: 0.55;
}
.ring-outer { stroke-dasharray: 4 6; animation: spin 40s linear infinite; transform-origin: 200px 200px; }
.ring-ticks { stroke-dasharray: 1 7; stroke-width: 3; animation: spin-rev 60s linear infinite; transform-origin: 200px 200px; }
.ring-mid { stroke: var(--cyan); opacity: 0.75; animation: spin 26s linear infinite; transform-origin: 200px 200px; stroke-dasharray: 60 12; }
.ring-inner { stroke: var(--cyan); opacity: 0.9; stroke-width: 2; }
.core-ring { stroke: var(--gold); stroke-width: 2; opacity: 0.9; filter: drop-shadow(0 0 6px var(--gold-glow)); }
.triangles polygon {
  fill: var(--cyan);
  opacity: 0.85;
  filter: drop-shadow(0 0 4px var(--cyan-glow));
}

.reactor-core {
  position: absolute;
  inset: 61px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #eafcff 0%, var(--cyan) 35%, rgba(75,227,255,0.15) 70%, transparent 100%);
  box-shadow: 0 0 40px 6px var(--cyan-glow), 0 0 90px 20px rgba(75,227,255,0.25);
  animation: breathe 3.2s ease-in-out infinite;
}

.wave {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 113px;
  height: 40px;
  opacity: 0.9;
  pointer-events: none;
}

.mic-btn {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(4, 12, 18, 0.7);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 18px var(--cyan-glow);
  transition: box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  z-index: 5;
}
.mic-btn:hover { transform: translate(-50%, -50%) scale(1.05); }
.mic-btn:active { transform: translate(-50%, -50%) scale(0.96); }

/* reactor states */
.reactor[data-state="listening"] .reactor-core { background: radial-gradient(circle at 50% 45%, #fff 0%, var(--gold) 35%, rgba(255,178,56,0.2) 70%, transparent 100%); box-shadow: 0 0 50px 10px var(--gold-glow); animation: breathe 1s ease-in-out infinite; }
.reactor[data-state="listening"] .mic-btn { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 22px var(--gold-glow); }
.reactor[data-state="listening"] .ring-mid { stroke: var(--gold); }

.reactor[data-state="thinking"] .ring-outer,
.reactor[data-state="thinking"] .ring-ticks,
.reactor[data-state="thinking"] .ring-mid { animation-duration: 4s; }
.reactor[data-state="thinking"] .reactor-core { animation: breathe 0.6s ease-in-out infinite; }

.reactor[data-state="speaking"] .reactor-core { box-shadow: 0 0 60px 14px var(--cyan-glow); }
.reactor[data-state="speaking"] .core-ring { animation: spin 4s linear infinite; transform-origin: 200px 200px; }

.state-readout {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-dim);
}
.reactor[data-state="listening"] ~ .state-readout { color: var(--gold); }

.brain-chip-wrap { position: relative; margin-top: 2px; }
.brain-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-family: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.brain-chip:hover { border-color: var(--panel-border); background: rgba(75, 227, 255, 0.06); }
.brain-label { opacity: 0.7; }
.brain-value { color: var(--cyan); font-family: var(--font-display); }
.brain-sep { opacity: 0.4; }
.brain-spend {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  font-size: 10px;
  font-family: var(--font-display);
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: rgba(75, 227, 255, 0.03);
}

.brain-picker {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  z-index: 20;
  width: max-content;
  min-width: 260px;
  max-width: 340px;
  background: #071019; /* solid — var(--panel) is translucent and hard to read over the graph/transcript behind it */
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
}
.brain-picker-heading {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 4px 8px 6px;
}
.brain-picker-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.brain-picker-item:hover { background: rgba(75, 227, 255, 0.1); }
.brain-picker-item .name { font-size: 12px; }
.brain-picker-item .meta { font-size: 10px; color: var(--text-dim); }
.brain-picker-item.default-item { border-top: 1px solid var(--panel-border); margin-top: 4px; padding-top: 8px; }

.transcript {
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  border-left: 2px solid var(--panel-border);
  padding: 6px 0 6px 14px;
  font-size: 15px;
  line-height: 1.45;
  -webkit-overflow-scrolling: touch;
}
.transcript-line {
  margin-bottom: 6px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.transcript-line.placeholder { color: var(--text-dim); font-style: italic; }
.transcript-line.you { color: var(--gold); }
.transcript-line.hermes { color: var(--text); }
.transcript-line.system { color: var(--text-dim); font-size: 12px; letter-spacing: 1px; }

.tool-call-block { margin-bottom: 8px; }
.tool-call-block + .tool-call-block { margin-top: 8px; }
.tool-call-name {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 4px;
}
.tool-call-cmd, .tool-call-result {
  background: rgba(4, 12, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  margin: 0 0 4px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.4;
}
.tool-call-cmd code, .tool-call-result code {
  font-family: 'Rajdhani', monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-call-cmd code { color: var(--cyan); }
.tool-call-result {
  border-left: 2px solid var(--panel-border);
  border-radius: 0 4px 4px 0;
}
.tool-call-result code { color: var(--text-dim); }

/* ---- Rendered markdown inside Jarvis's replies ---- */
.transcript-line.hermes p { margin: 0 0 8px; }
.transcript-line.hermes p:last-child { margin-bottom: 0; }
.transcript-line.hermes strong { color: var(--cyan); font-weight: 700; }
.transcript-line.hermes em { color: var(--text); font-style: italic; }
.transcript-line.hermes h1,
.transcript-line.hermes h2,
.transcript-line.hermes h3,
.transcript-line.hermes h4,
.transcript-line.hermes h5,
.transcript-line.hermes h6 {
  font-family: var(--font-display);
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan-glow);
  margin: 10px 0 6px;
  line-height: 1.3;
}
.transcript-line.hermes h1 { font-size: 18px; }
.transcript-line.hermes h2 { font-size: 16px; }
.transcript-line.hermes h3,
.transcript-line.hermes h4,
.transcript-line.hermes h5,
.transcript-line.hermes h6 { font-size: 14px; }
.transcript-line.hermes ul,
.transcript-line.hermes ol {
  margin: 0 0 8px;
  padding-left: 22px;
}
.transcript-line.hermes li { margin-bottom: 3px; }
.transcript-line.hermes .md-inline-code {
  background: rgba(75, 227, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'Rajdhani', monospace;
  font-size: 0.92em;
  color: var(--cyan);
}
.transcript-line.hermes .md-code-block {
  background: rgba(4, 12, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 0 0 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.4;
}
.transcript-line.hermes .md-code-block code {
  font-family: 'Rajdhani', monospace;
  color: var(--text);
  white-space: pre;
}
.transcript-line.hermes .md-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  margin: 0 0 10px;
  font-size: 13px;
}
.transcript-line.hermes .md-table th,
.transcript-line.hermes .md-table td {
  border: 1px solid var(--panel-border);
  padding: 5px 9px;
  text-align: left;
}
.transcript-line.hermes .md-table th {
  background: rgba(75, 227, 255, 0.08);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.transcript-line.hermes .md-table tr:nth-child(even) td {
  background: rgba(75, 227, 255, 0.03);
}

.input-row {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.input-row #text-input { min-width: 160px; }

#text-input {
  flex: 1;
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}
#text-input:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }

.btn-ghost, .btn-danger {
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  letter-spacing: 1.5px;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--cyan);
  transition: all 0.15s ease;
}
.btn-ghost:hover { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.btn-ghost.small, .btn-danger.small { padding: 6px 10px; }
.btn-ghost.active { background: rgba(75, 227, 255, 0.15); border-color: var(--cyan); color: var(--cyan); animation: pulse 1.4s infinite; }
/* Muted is a static "off" state, not an ongoing action like recording/
   sharing — no pulse, and red rather than cyan so it doesn't read as
   "active and working" at a glance. */
#mute-btn.active { background: rgba(255, 77, 77, 0.1); border-color: var(--red); color: var(--red); animation: none; }

.btn-danger {
  color: var(--red);
  border-color: rgba(255, 77, 77, 0.4);
}
.btn-danger:hover { border-color: var(--red); box-shadow: 0 0 10px rgba(255, 77, 77, 0.5); }
.btn-danger.active { background: rgba(255, 77, 77, 0.15); animation: pulse-danger 1s infinite; }

.slash-row {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.slash-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 3px;
  padding: 5px 9px;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
}
.slash-btn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- mission control (modal — see .mc-box below) ---------- */

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
}
.stat-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
  margin-top: 4px;
}

.usage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
}
.usage-item { display: flex; align-items: center; gap: 6px; }
.usage-label { font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim); }
.usage-value { font-size: 13px; color: var(--cyan); font-family: var(--font-display); }
.usage-quota-track {
  width: 60px;
  height: 5px;
  background: rgba(75, 227, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
}
.usage-quota-fill { display: block; height: 100%; background: var(--gold); }

.file-box.mc-box { width: min(920px, 94vw); }
/* The vault modal specifically needs the full page, not just a bigger box —
   a graph needs real room to drag nodes around and actually be readable. */
#vault-overlay { padding: 0; }
#vault-overlay .file-box.mc-box {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
}

.mc-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.mc-tab {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 3px;
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2.5px;
  font-weight: 600;
  cursor: pointer;
}
.mc-tab:hover { color: var(--cyan); border-color: var(--cyan); }
.mc-tab.active { color: var(--gold); border-color: var(--gold); text-shadow: 0 0 6px var(--gold-glow); }

/* ---------- settings ---------- */
.settings-hint { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin: 10px 0; }
.settings-hint code {
  background: rgba(75, 227, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'Rajdhani', monospace;
  color: var(--cyan);
}
.settings-config-dump {
  background: rgba(4, 12, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 40vh;
}
.settings-kv-row { display: flex; gap: 8px; margin-bottom: 8px; }
.settings-kv-row input {
  flex: 1;
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.settings-kv-row input:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }

.settings-key-list { display: flex; flex-direction: column; gap: 6px; }
.settings-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(75, 227, 255, 0.03);
}
.settings-key-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  font-size: 12px;
  color: var(--text);
  font-family: 'Rajdhani', monospace;
}
.settings-key-name .meta { color: var(--text-dim); font-size: 11px; margin-left: auto; }
.settings-key-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.settings-key-dot.set { background: var(--gold); box-shadow: 0 0 5px var(--gold-glow); }
.settings-key-row input {
  flex: 1;
  min-width: 120px;
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.settings-key-row input:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }

.agent-cards, .machine-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.schedule-list, .content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty { color: var(--text-dim); font-size: 12px; font-style: italic; }

.agent-card, .schedule-item, .content-item {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(75, 227, 255, 0.03);
}

.agent-card { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.agent-card:hover { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.agent-card .name { font-size: 13px; color: var(--text); font-weight: 600; }
.agent-card .meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.agent-card canvas { width: 100%; height: 28px; margin-top: 6px; display: block; }

.schedule-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.schedule-item .name { font-size: 12px; color: var(--text); }
.schedule-item .cron { font-size: 10px; color: var(--text-dim); }
.schedule-item .actions { display: flex; gap: 4px; }
.schedule-item button {
  background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 3px; padding: 3px 6px; font-size: 10px; cursor: pointer;
}
.schedule-item button:hover { color: var(--cyan); border-color: var(--cyan); }

.content-item { cursor: pointer; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.content-item:hover { border-color: var(--cyan); color: var(--cyan); }
.content-item .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-item .fsize { color: var(--text-dim); font-size: 10px; flex-shrink: 0; }

.machine-card {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(75, 227, 255, 0.03);
  font-size: 11px;
}
.machine-card .name { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.machine-card .meta { color: var(--text-dim); margin-bottom: 6px; }
.machine-bar-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.machine-bar-row .bar-label { width: 34px; flex-shrink: 0; color: var(--text-dim); }
.machine-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(75, 227, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.machine-bar-fill { height: 100%; background: var(--cyan); box-shadow: 0 0 6px var(--cyan-glow); }
.machine-bar-fill.warn { background: var(--gold); box-shadow: 0 0 6px var(--gold-glow); }
.machine-bar-fill.danger { background: var(--red); }
.machine-bar-row .bar-value { width: 34px; flex-shrink: 0; text-align: right; color: var(--text-dim); }

/* ---------- overlays / modals ---------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(2, 6, 10, 0.82);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.hidden { display: none; }

.approval-box, .file-box {
  width: min(560px, 92vw);
  background: #071019;
  border: 1px solid var(--gold);
  box-shadow: 0 0 40px rgba(255, 178, 56, 0.25);
  border-radius: 6px;
  overflow: hidden;
}

.approval-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 178, 56, 0.08);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(255, 178, 56, 0.3);
}
.warn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pulse-danger 1.2s infinite;
}

.approval-body { padding: 16px; }
.approval-desc { font-size: 14px; margin-bottom: 10px; }
.approval-cmd {
  background: #020507;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px;
  font-size: 12px;
  color: var(--cyan);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
}

.approval-actions {
  display: flex; gap: 8px; padding: 0 16px 16px;
  flex-wrap: wrap;
}
.approval-btn {
  flex: 1;
  min-width: 110px;
  padding: 10px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
}
.approval-btn.allow { color: var(--cyan); border-color: var(--cyan-dim); }
.approval-btn.allow:hover { box-shadow: 0 0 10px var(--cyan-glow); }
.approval-btn.allow-always { color: var(--gold); border-color: var(--gold); }
.approval-btn.allow-always:hover { box-shadow: 0 0 10px var(--gold-glow); }
.approval-btn.deny { color: var(--red); border-color: rgba(255,77,77,0.5); }
.approval-btn.deny:hover { box-shadow: 0 0 10px rgba(255,77,77,0.5); }

.file-box { width: min(700px, 92vw); max-height: 80vh; display: flex; flex-direction: column; }
.file-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--cyan);
}
.file-body {
  padding: 14px;
  margin: 0;
  overflow: auto;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.file-edit-area {
  border: none;
  background: rgba(4, 12, 18, 0.5);
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 300px;
}
.file-header > div { display: flex; gap: 6px; }

.kanban-new-task {
  display: flex;
  gap: 8px;
  padding: 12px 14px 0;
}
.kanban-new-task.hidden { display: none; }
.kanban-new-task input, .kanban-new-task textarea {
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.kanban-new-task input:focus, .kanban-new-task textarea:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
#vault-new-form { flex-direction: column; align-items: stretch; }
#vault-new-body { resize: vertical; min-height: 140px; }
.vault-new-actions { display: flex; gap: 8px; justify-content: flex-end; }
#kanban-new-title { flex: 1; }
#kanban-new-body { flex: 1.4; }
#kanban-new-assignee {
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.board-body {
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.board-column-title {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.board-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.task-item, .session-row {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(75, 227, 255, 0.03);
  font-size: 12px;
  margin-bottom: 6px;
}
.task-item .title, .session-row .title { color: var(--text); font-weight: 600; }
.task-item .meta, .session-row .meta { color: var(--text-dim); font-size: 10px; margin-top: 3px; }
.session-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- memory panel ---------- */

.mem-hint { color: var(--text-dim); font-size: 10px; margin: -4px 0 8px; }
.mem-item { display: flex; align-items: flex-start; gap: 8px; }
.mem-text {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.mem-text:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.mem-actions { display: flex; flex-direction: column; gap: 6px; }
.mem-add { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; }
.mem-add .mem-new-text {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  background: rgba(4, 12, 18, 0.8);
  border: 1px dashed var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.mem-add .mem-new-text:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }

/* ---------- spend panel ---------- */

.spend-filters { flex-wrap: wrap; align-items: center; }
.spend-preset.active { color: var(--gold); border-color: var(--gold); text-shadow: 0 0 6px var(--gold-glow); }
.spend-filter-sep { color: var(--text-dim); }
#spend-from, #spend-to {
  background: rgba(4, 12, 18, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  color-scheme: dark;
}
#spend-from:focus, #spend-to:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }

.spend-total-card {
  margin: 0 14px 4px;
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.spend-total-label { font-size: 11px; letter-spacing: 1.5px; color: var(--text-dim); text-transform: uppercase; }
.spend-total-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan-glow);
}

.spend-row-active { border-color: var(--cyan); background: rgba(75, 227, 255, 0.08); }
.spend-active-badge {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.spend-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.spend-row-main { flex: 1; min-width: 0; }
.spend-row-cost {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
  white-space: nowrap;
}

/* ---------- vault graph view ---------- */

.graph-body {
  position: relative;
  flex: 1;
  min-height: 70vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, rgba(75, 227, 255, 0.05) 0%, transparent 70%);
}
#vault-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#vault-graph-svg.panning { cursor: grabbing; }
.graph-edge {
  stroke: var(--panel-border);
  stroke-width: 1.5;
  transition: opacity 0.15s ease;
}
/* Hovering a node, clicking one (sticky), or a search match — see
   applyFocus()/toggleStickyNode()/search() in app.js — dims everything not
   connected/matching and brightens what is, instead of a static layout you
   have to visually trace by eye. */
.graph-edge.highlighted {
  stroke: var(--cyan);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px var(--cyan-glow));
}
.graph-edge.dimmed { opacity: 0.12; }
.graph-node { transition: opacity 0.15s ease; }
.graph-node.dimmed { opacity: 0.25; }
/* Press-and-hold-to-open feedback: the node visibly grows over the same
   HOLD_MS duration the JS timer uses, so "keep holding" is discoverable
   instead of a silent timer with no cue. transform-box is required for an
   SVG element's transform-origin: center to scale from its own middle
   rather than the whole SVG viewport's (0,0) corner. */
.graph-node.pressing circle:first-child {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.5s ease-out;
  transform: scale(1.4);
}
.graph-node circle {
  fill: rgba(9, 22, 32, 0.9);
  /* --node-color is set per-node from JS (cluster color) via a CSS custom
     property, not a direct inline `stroke`, specifically so the :hover
     rule below (a normal stylesheet rule) still wins on hover — an inline
     style would out-specificity :hover and make hover feedback dead. */
  stroke: var(--node-color, var(--cyan));
  stroke-width: 1.5;
  filter: drop-shadow(0 0 5px var(--node-glow, var(--cyan-glow)));
  cursor: pointer;
}
.graph-node.unresolved circle {
  stroke: var(--text-dim);
  stroke-dasharray: 3 3;
  filter: none;
}
.graph-node:hover circle {
  stroke: var(--gold);
  filter: drop-shadow(0 0 8px var(--gold-glow));
}
/* Hub nodes — bridge notes linked into 2+ sections (e.g. a "me" note
   connecting family and business) — get a bolder ring on the node itself
   plus a small dot per section they touch (see .graph-node-hub-dot),
   instead of a single fixed cluster color that would misrepresent them as
   belonging to only one. :first-child reliably targets the main circle
   since buildGraphDom() always appends it before any hub dots. */
.graph-node.hub circle:first-child { stroke-width: 2.5; }
.graph-node-hub-dot {
  stroke: var(--bg);
  stroke-width: 1;
  filter: none;
  pointer-events: none;
}
.graph-node text {
  fill: var(--text);
  font-family: var(--font-body);
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
}
.graph-node.unresolved text { fill: var(--text-dim); font-style: italic; }
.graph-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: rgba(2, 6, 10, 0.7);
  padding: 4px 10px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}
.vault-link {
  color: var(--cyan);
  text-decoration: underline dotted;
  cursor: pointer;
}
.vault-link.unresolved { color: var(--text-dim); font-style: italic; }
.vault-insert-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 0;
}
.vault-insert-links .hint { font-size: 10px; color: var(--text-dim); width: 100%; margin-bottom: 2px; }
.vault-insert-links button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.vault-insert-links button:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- animations ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes pulse-cyan {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (max-width: 980px) {
  /* Below this width the header/stats stack take up enough of the viewport
     that the reactor column can no longer be force-stretched to fill .stage
     (align-items: stretch, the default) without squeezing .transcript to
     zero height via its flex: 1; min-height: 0. Letting the column size to
     its own content and scrolling .stage instead means the chat area keeps
     its min-height floor and just becomes reachable by scrolling. */
  .stage { flex-direction: column; overflow-y: auto; align-items: flex-start; }
  .reactor-column { min-height: auto; margin: 0 auto; max-width: 880px; }
  .vault-graph-column { max-width: 880px; min-width: 0; margin: 0 auto; flex: 0 0 auto; }
  .home-graph-body { min-height: 60vh; }
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .agent-cards, .machine-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app {
    padding: 10px 12px 14px;
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    gap: 10px;
  }
  .topbar { flex-wrap: wrap; row-gap: 10px; padding-bottom: 10px; }
  .topbar-left { gap: 14px; }
  .brand-title { font-size: 16px; letter-spacing: 2px; }
  .brand-sub { font-size: 9px; letter-spacing: 2px; }
  .status-cluster { gap: 6px; width: 100%; justify-content: space-between; }
  .status-chip { padding: 5px 7px; font-size: 10px; }
  .clock { min-width: 0; font-size: 12px; }

  .overview-grid { gap: 6px; }
  .stat-card { padding: 7px 8px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 16px; margin-top: 2px; }
  .usage-strip { gap: 8px 14px; padding: 6px 10px; }

  .reactor { width: 116px; height: 116px; margin-top: 0; }
  .mic-btn { width: 34px; height: 34px; }
  .wave { width: 78px; height: 28px; }

  .transcript { font-size: 14px; min-height: 45vh; }

  .input-row { gap: 6px; }
  .input-row #text-input { flex: 1 1 100%; }
  .btn-ghost, .btn-danger { padding: 8px 10px; font-size: 11px; flex: 1 1 auto; }

  .file-box, .approval-box { width: 96vw; max-height: 88dvh; }
}

/* ---- Boot sequence overlay ---- */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #020407;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  transition: opacity 0.6s ease;
}
.boot-overlay.hidden { opacity: 0; pointer-events: none; }
.boot-text {
  width: 100%;
  max-width: 640px;
  font-family: 'Rajdhani', monospace;
  font-size: 15px;
  line-height: 1.8;
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan-glow);
  white-space: pre-wrap;
}
.boot-text .ok { color: var(--gold); }
.boot-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
  animation: pulse-cyan 0.8s steps(2) infinite;
  vertical-align: -2px;
}
