@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0a0b0d;
  --panel: #111317;
  --panel-2: #16181d;
  --panel-3: #1c1f25;
  --line: rgba(255,255,255,0.06);
  --line-strong: rgba(255,255,255,0.10);
  --ink: #f4f5f7;
  --ink-2: #c8ccd2;
  --ink-3: #8b8f97;
  --ink-4: #5b6068;
  --ink-5: #3a3e46;

  --accent: #e85a3c;        /* stim red */
  --accent-2: #f2b04a;       /* highlight amber */
  --accent-3: #5ba3ff;       /* electrode blue */
  --accent-4: #4ec9a4;       /* good/positive green */

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 13px; -webkit-font-smoothing: antialiased; }

.hf {
  width: 100vw;
  height: 100vh;
  display: grid;
  /* minmax(0, 1fr) is the standard fix for grid items containing scrollable
     descendants — without it, the row/col silently grows to fit content and
     the whole grid pushes past the viewport, forcing the page itself to scroll. */
  grid-template-rows: 44px 38px minmax(0, 1fr) 96px;
  grid-template-columns: 340px minmax(0, 1fr) 300px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

/* ---------- typography ---------- */
.t-mono { font-family: var(--mono); font-feature-settings: 'ss01','cv11'; letter-spacing: -0.01em; }
.t-xs { font-size: 10px; }
.t-sm { font-size: 11px; }
.t-md { font-size: 13px; }
.t-lg { font-size: 15px; }
.t-xl { font-size: 18px; }
.t-2xl { font-size: 22px; }
.t-soft { color: var(--ink-3); }
.t-mute { color: var(--ink-4); }
.t-bold { font-weight: 600; }
.t-up { text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- chrome bits ---------- */
.bar {
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  height: 26px; padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink-2);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--panel-3); color: var(--ink); border-color: rgba(255,255,255,0.16); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: #fff; color: var(--bg); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #ee6b50; border-color: #ee6b50; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn-sm { height: 22px; padding: 0 8px; font-size: 11px; border-radius: 5px; }
.btn-icon { width: 26px; padding: 0; justify-content: center; }
.btn-disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-disabled:hover, .btn[disabled]:hover {
  background: var(--panel-2);
  color: var(--ink-2);
  border-color: var(--line-strong);
}

.task-select {
  height: 26px; padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink-2);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  cursor: pointer;
  min-width: 220px;
}
.task-select:hover { background: var(--panel-3); color: var(--ink); border-color: rgba(255,255,255,0.16); }
.task-select:focus { outline: none; border-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.02em;
}
.chip-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-accent { background: rgba(232,90,60,0.12); color: var(--accent); border-color: rgba(232,90,60,0.3); }

.seg {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.seg > div {
  padding: 3px 10px;
  white-space: nowrap;
  font-size: 11px; font-weight: 500;
  color: var(--ink-3);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.seg > div.on { background: var(--panel-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }

.divider { height: 1px; background: var(--line); margin: 10px 0; }
.vdiv { width: 1px; height: 20px; background: var(--line); }

.kv { display: grid; grid-template-columns: 70px 1fr; row-gap: 4px; column-gap: 8px; }
.kv .k { color: var(--ink-4); font-family: var(--mono); font-size: 10px; }
.kv .v { color: var(--ink); font-family: var(--mono); font-size: 11px; }

.pill { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 9px; font-family: var(--mono); font-size: 9.5px; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  display: flex; flex-direction: column;
  overflow: hidden;
  /* grid items default to min-height: auto; set to 0 so the inner
     panel-body's overflow: auto can actually shrink and scroll. */
  min-height: 0;
  height: 100%;
}
.panel-h {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  height: 38px;
}
.panel-body {
  flex: 1;
  overflow: auto;
  padding: 12px 14px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.card-accent { border-color: rgba(232,90,60,0.3); background: linear-gradient(180deg, rgba(232,90,60,0.04), transparent 30%) var(--panel-2); }

/* slider */
.slider {
  display: flex; flex-direction: column; gap: 4px;
}
.slider-track {
  position: relative; height: 4px; border-radius: 2px;
  background: var(--panel-3);
}
.slider-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink-2); border-radius: 2px;
}
.slider-knob {
  position: absolute; top: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--ink-2);
  transform: translate(-50%, -50%);
}

/* scroll */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--ink-5); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* status dot */
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--accent-4); box-shadow: 0 0 8px var(--accent-4); }
.dot-warn { background: var(--accent-2); }
.dot-stim { background: var(--accent); box-shadow: 0 0 8px rgba(232,90,60,0.6); }

/* logo glyph */
.logo {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  color: #1a0c08;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 6px 18px rgba(232,90,60,0.18);
}

/* chat bubbles */
.msg-user {
  align-self: flex-end;
  max-width: 92%;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px 10px 2px 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
}
.msg-agent {
  max-width: 100%;
  background: transparent;
  padding: 0;
}
.agent-think {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--ink-3);
}
.agent-think b { color: var(--ink-2); font-weight: 500; }

/* progress bar */
.prog {
  height: 4px; border-radius: 2px;
  background: var(--panel-3);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* electrode pin — anode warm (red) by default, cathode cool (blue) */
.epin {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px;
}
.epin .swatch {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px rgba(232,90,60,0.3);
}
.epin.cathode .swatch {
  background: var(--accent-3);
  box-shadow: 0 0 0 1.5px rgba(91,163,255,0.3);
}

/* ---------- hero performance card ---------- */
.hero-card {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hero-card[data-hero-state="running"] {
  border-color: rgba(232,90,60,0.35);
  box-shadow: 0 0 0 1px rgba(232,90,60,0.08), 0 6px 22px rgba(232,90,60,0.12);
}
.hero-card[data-hero-state="done"] {
  border-color: rgba(78,201,164,0.35);
  box-shadow: 0 0 0 1px rgba(78,201,164,0.06), 0 6px 22px rgba(78,201,164,0.10);
}
.hero-card[data-hero-state="error"] {
  border-color: rgba(255,107,107,0.35);
}
.hero-head {
  display: flex; align-items: center; gap: 6px; min-height: 16px;
}
.hero-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 6px 0 2px;
}
.hero-big {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.hero-big-idle { color: var(--ink-4); }
.hero-big-pulse {
  color: var(--accent);
  animation: heroPulse 1.0s ease-in-out infinite;
}
.hero-big-err { color: #ff6b6b; font-size: 30px; }
.hero-big-done.pos { color: var(--accent-4); }
.hero-big-done.neg { color: #ff8e8e; }
.hero-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hero-help {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  margin-top: 2px;
  text-align: center;
}
.hero-meta {
  display: flex; gap: 16px; margin-top: 4px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}
.hero-meta .t-mute { color: var(--ink-4); margin-right: 4px; }
.hero-bar {
  width: 80%; height: 4px; border-radius: 2px;
  background: var(--panel-3); overflow: hidden; margin-top: 4px;
}
.hero-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.18s ease;
}
.hero-empty {
  text-align: center;
  padding: 14px 12px;
}
@keyframes heroPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1.00; transform: scale(1.04); }
}
