:root {
  --bg: #060b11;
  --bg-2: #0a131c;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-brd: rgba(0, 229, 255, 0.14);
  --text: #cfeaf2;
  --text-dim: #5f8090;
  --accent: #00e5ff;      /* driven by JS per state */
  --accent-soft: rgba(0, 229, 255, 0.15);
  --gold: #fec453;
  --green: #22d3a6;
  --blue: #3b82f6;
  --red: #ff4d6d;
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #0d2130 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.hud { display: flex; flex-direction: column; height: 100vh; padding: 14px; gap: 12px; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  border: 1px solid var(--panel-brd);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.05), transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 14px var(--accent-soft), inset 0 0 10px var(--accent-soft);
  position: relative;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.brand-name { font-family: 'Orbitron'; font-weight: 700; letter-spacing: 4px; font-size: 20px; color: #eafbff; }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 2px; }
.tagline { color: var(--text-dim); font-style: italic; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-family: 'Orbitron'; font-size: 18px; color: var(--accent); letter-spacing: 1px; }
.theme-toggle {
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--panel-brd); color: var(--text);
  font-size: 16px;
}

/* ── Grid ── */
.grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 230px 1fr 340px; gap: 12px;
}

.panel {
  border: 1px solid var(--panel-brd); border-radius: 14px;
  background: var(--panel); padding: 14px;
  backdrop-filter: blur(4px);
}
.panel-title {
  font-family: 'Orbitron'; font-size: 11px; letter-spacing: 2px;
  color: var(--text-dim); margin-bottom: 12px;
}
.panel-title.row { display: flex; justify-content: space-between; align-items: center; }

/* ── Sidebar ── */
.sidebar { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  font-size: 13px; transition: .15s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--accent); background: var(--accent-soft);
  border-color: var(--panel-brd); box-shadow: inset 2px 0 0 var(--accent);
}
.status-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.status-list li { display: flex; justify-content: space-between; font-size: 12px; }
.status-list em { font-style: normal; color: var(--text-dim); }
.status-list em.ok { color: var(--green); }
.status-list em.bad { color: var(--red); }
.metric { display: flex; align-items: center; gap: 8px; font-size: 11px; margin-bottom: 10px; }
.metric span { width: 56px; color: var(--text-dim); }
.bar { flex: 1; height: 5px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 8px var(--accent); transition: width .5s; }
.uptime { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.uptime b { color: var(--text); }
.google-btn {
  width: 100%; margin-top: 10px; padding: 9px; border-radius: 10px; cursor: pointer;
  background: var(--accent-soft); border: 1px solid var(--panel-brd); color: var(--accent);
  font-size: 11px; font-family: 'Orbitron'; letter-spacing: .5px;
}
.google-btn:hover { box-shadow: 0 0 12px var(--accent-soft); }
.google-btn.connected { color: var(--green); border-color: var(--green); background: rgba(34,211,166,0.1); }
.bar.quota { height: 8px; margin-bottom: 7px; }
.bar.quota i { transition: width .4s, background .4s; }
.bar.quota i.warn { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.bar.quota i.full { background: var(--red); box-shadow: 0 0 8px var(--red); }
.quota-note { font-size: 9.5px; color: var(--text-dim); margin-top: 5px; font-style: italic; }

/* ── Center stage ── */
.stage {
  position: relative; border: 1px solid var(--panel-brd); border-radius: 16px;
  background:
    radial-gradient(600px 400px at 50% 45%, rgba(0,229,255,0.06), transparent 70%),
    var(--bg-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
#face { position: absolute; inset: 0; width: 100%; height: 100%; }
.wake-toggle {
  position: absolute; top: 14px; left: 14px; z-index: 4;
  padding: 7px 13px; border-radius: 20px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--panel-brd); color: var(--text-dim);
  font-family: 'Orbitron'; font-size: 11px; letter-spacing: 1px; transition: .2s;
}
.wake-toggle.on {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft); box-shadow: 0 0 14px var(--accent-soft);
}
.style-toggle {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  padding: 7px 13px; border-radius: 20px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--panel-brd); color: var(--text-dim);
  font-family: 'Orbitron'; font-size: 11px; letter-spacing: 1px; transition: .2s;
}
.style-toggle:hover { color: var(--accent); border-color: var(--accent); }
.stage-status { position: absolute; bottom: 120px; display: flex; align-items: center; gap: 10px; z-index: 2; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.status-label { font-family: 'Orbitron'; letter-spacing: 3px; font-size: 14px; color: var(--accent); }
.status-hint { position: absolute; bottom: 96px; font-size: 11px; color: var(--text-dim); z-index: 2; }
.wave { position: absolute; bottom: 150px; display: flex; align-items: flex-end; gap: 3px; height: 34px; z-index: 2; }
.wave i { width: 3px; background: var(--accent); border-radius: 2px; height: 4px; box-shadow: 0 0 6px var(--accent); }
.mic-btn {
  position: absolute; bottom: 26px; width: 58px; height: 58px; border-radius: 50%;
  border: 2px solid var(--accent); background: radial-gradient(circle, rgba(0,229,255,0.2), rgba(0,0,0,0.3));
  color: var(--accent); cursor: pointer; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px var(--accent-soft); transition: .2s;
}
.mic-btn:hover { box-shadow: 0 0 30px var(--accent); transform: translateY(-1px); }
.send-now {
  display: none; position: absolute; bottom: 36px; left: calc(50% + 52px);
  align-items: center; gap: 4px; padding: 9px 16px; border-radius: 22px;
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent);
  font-family: 'Orbitron'; font-size: 12px; letter-spacing: 1px; cursor: pointer; z-index: 3;
  box-shadow: 0 0 16px var(--accent-soft); white-space: nowrap;
}
.send-now:hover { box-shadow: 0 0 24px var(--accent); }

/* ── Right column ── */
.rightcol { display: flex; flex-direction: column; gap: 12px; min-height: 0; height: 100%; }
.convo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.convo-feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.msg { font-size: 13px; line-height: 1.5; }
.msg b { display: block; font-size: 10px; letter-spacing: 1px; margin-bottom: 3px; }
.msg.you b { color: var(--text-dim); }
.msg.jarvis b { color: var(--accent); }
.msg p {
  background: rgba(255,255,255,0.04); padding: 8px 11px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05); color: var(--text);
  white-space: pre-line; line-height: 1.6;
}
.msg.jarvis p { border-color: var(--panel-brd); background: var(--accent-soft); }
.tool-note { font-size: 10px; color: var(--text-dim); margin-top: 4px; font-style: italic; }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer input {
  flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-brd); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 13px; outline: none;
}
.composer input:focus { border-color: var(--accent); }
.send, .mini-btn {
  background: var(--accent-soft); border: 1px solid var(--panel-brd); color: var(--accent);
  border-radius: 10px; cursor: pointer; padding: 0 14px; font-size: 14px;
}
.mini-btn { padding: 3px 10px; font-size: 11px; }
.tools { flex-shrink: 0; transition: padding .15s; }
.tools.collapsed { padding-bottom: 14px; }
.tools.collapsed .tool-grid { display: none; }
.panel-title.collapsible { cursor: pointer; user-select: none; margin-bottom: 0; }
.panel-title.collapsible .chev { display: inline-block; transition: transform .15s; color: var(--text-dim); }
.tools:not(.collapsed) .panel-title.collapsible { margin-bottom: 12px; }
.tools:not(.collapsed) .chev, .api-status:not(.collapsed) .chev { transform: rotate(90deg); }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px;
  border: 1px solid var(--panel-brd); border-radius: 10px; background: rgba(255,255,255,0.02);
  cursor: pointer; font-size: 10.5px; color: var(--text-dim); text-align: center; transition: .15s;
}
.tool:hover { color: var(--accent); background: var(--accent-soft); }
.tool .ico { font-size: 18px; }
.tool.add { border-style: dashed; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #16303d; border-radius: 3px; }

/* ── Gold / Iron-Man theme (toggle) ── */
body.gold {
  --bg: #0b0704; --bg-2: #140b05;
  --panel-brd: rgba(254, 196, 83, 0.18);
  --text: #f3e2c4; --text-dim: #9a7b4a;
  --accent: #fec453; --accent-soft: rgba(254, 196, 83, 0.15);
}
body.gold {
  background:
    radial-gradient(1200px 700px at 50% -10%, #241206 0%, transparent 60%),
    var(--bg);
}

/* ── Bottom API status panel ── */
.api-status { flex-shrink: 0; max-height: 170px; overflow-y: auto; transition: max-height .15s; }
.api-status.collapsed { max-height: 42px; overflow: hidden; }
.api-status.collapsed .panel-title { margin-bottom: 0; }
.api-active { font-size: 11px; color: var(--accent); font-style: normal; }
.api-table { display: flex; flex-direction: column; gap: 6px; font-size: 11px; margin-top: 12px; }
.api-row {
  display: grid; grid-template-columns: 110px 70px 150px 90px 1fr;
  gap: 10px; align-items: center; padding: 6px 9px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
}
.api-row .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.api-row .dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.api-row .dot.unused { background: #5f8090; }
.api-row .dot.exhausted { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.api-row .dot.error, .api-row .dot.notset { background: var(--red); box-shadow: 0 0 6px var(--red); }
.api-row .name { color: var(--text); }
.api-row .model { color: var(--text-dim); }
.api-row .meta { color: var(--text-dim); }
.api-row .status-text { text-transform: capitalize; }
.api-row .status-text.ok { color: var(--green); }
.api-row .status-text.exhausted { color: var(--gold); }
.api-row .status-text.error, .api-row .status-text.notset { color: var(--red); }
.api-desc { font-size: 9.5px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; font-style: italic; }

/* ── Floating mini media player ── */
.mini-player {
  display: none; position: fixed; bottom: 20px; right: 20px; z-index: 60;
  width: 340px; background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: 12px; box-shadow: 0 0 30px var(--accent-soft); overflow: hidden;
}
.mini-player.open { display: block; }
.mini-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: move; user-select: none;
  font-family: 'Orbitron'; font-size: 12px; color: var(--accent);
}
.mini-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btns { display: flex; gap: 2px; flex-shrink: 0; }
.mini-btns button {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 2px 7px; border-radius: 6px;
}
.mini-btns button:hover { color: var(--accent); background: var(--accent-soft); }
.player-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000;
  overflow: hidden; transition: height .2s;
}
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Minimized: collapse the video but keep the iframe loaded so audio plays on. */
.mini-player.min .player-frame { height: 0; aspect-ratio: auto; }

/* ── Settings modal ── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 8, 12, 0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(460px, 92vw); max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--accent); border-radius: 16px;
  padding: 20px; box-shadow: 0 0 40px var(--accent-soft);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'Orbitron'; letter-spacing: 3px; color: var(--accent);
  margin-bottom: 16px; font-size: 15px;
}
.modal label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.modal label b { color: var(--accent); }
.modal input, .modal select {
  width: 100%; margin-top: 6px; padding: 9px 11px; font-size: 13px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--panel-brd); border-radius: 9px;
  color: var(--text); outline: none;
}
.modal input[type="range"] { padding: 0; accent-color: var(--accent); }
.modal small { display: block; margin-top: 4px; color: var(--text-dim); font-size: 10px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.modal-actions .send { padding: 9px 20px; }

/* ── Mobile ── */
@media (max-width: 880px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  .sidebar { order: 3; flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
  .stage { order: 1; min-height: 60vh; }
  .rightcol { order: 2; }
  .tagline { display: none; }
}
