/* console.css — chrome shared by both pages: tokens, reset, top bar, panels,
   controls, boot overlay. Page-specific rules are in workbench.css and
   playground.css. */

:root {
  --bg: #0d0f12;
  --surface: #14171c;
  --surface-hi: #1a1e25;
  --line: #232931;
  --line-hi: #313943;
  --text: #dfe4ea;
  --text-2: #98a2af;
  --text-3: #697380;
  --accent: #4c8dff;
  --accent-hi: #7bacff;
  --accent-soft: rgba(76, 141, 255, 0.12);
  --ok: #3ec98a;
  --warn: #e3a63c;
  --err: #eb5f63;

  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bar-h: 46px;
  --foot-h: 44px;
  --gap: 8px;
  --radius: 5px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -16px rgba(0, 0, 0, 0.75);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.45;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--text-3); }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg.i {
  width: 15px; height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  color: var(--text-3);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 3px 5px;
  background: rgba(255, 255, 255, 0.03);
}

/* ── top bar ─────────────────────────────────────────────── */

#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--bar-h);
  z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: rgba(15, 18, 22, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: block; width: 18px; height: 18px; color: var(--accent); }
.brand h1 {
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
}
.brand-sub {
  font-size: 12px; color: var(--text-3);
  padding-left: 10px; margin-left: 2px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.topbar-group { display: flex; gap: 6px; align-items: center; }
.topbar-group.right { margin-left: auto; }

/* a pair of mode buttons reads as one control */
.segmented { display: flex; }
.segmented .btn { border-radius: 0; }
.segmented .btn + .btn { margin-left: -1px; }
.segmented .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.segmented .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented .btn.on { z-index: 1; }

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

.btn {
  font-family: var(--ui);
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  background: var(--surface-hi);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
  padding: 6px 11px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
  transition: color .12s, background .12s, border-color .12s;
}
.btn:hover { color: var(--text); border-color: #3d4552; background: #1f242c; }
.btn.on {
  color: var(--accent-hi);
  border-color: rgba(76, 141, 255, 0.45);
  background: var(--accent-soft);
}
.btn.accent { color: var(--text); border-color: rgba(76, 141, 255, 0.4); }
.btn.accent:hover { background: var(--accent-soft); border-color: rgba(76, 141, 255, 0.6); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-hi); border-color: var(--line-hi); }
.btn.danger:hover { color: var(--err); border-color: rgba(235, 95, 99, 0.5); }
.btn.playing { color: var(--ok); border-color: rgba(62, 201, 138, 0.45); background: rgba(62, 201, 138, 0.1); }
.btn.grow { flex: 1; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { color: var(--text-2); border-color: var(--line-hi); background: var(--surface-hi); }
.btn.icon { padding: 6px; }

.mini {
  background: none; border: none; cursor: pointer;
  color: var(--text-3);
  border-radius: 3px;
  padding: 2px;
  display: inline-flex;
}
.mini:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.mini svg.i { width: 14px; height: 14px; }

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

/* ── inputs ──────────────────────────────────────────────── */

select {
  background: var(--surface-hi);
  color: var(--text);
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  font-family: var(--ui); font-size: 12px;
  padding: 5px 6px;
  flex: 1; min-width: 0;
  cursor: pointer;
}
select:hover { border-color: #3d4552; }
select:focus { border-color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1; min-width: 0;
  height: 16px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: var(--line-hi);
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px; background: var(--line-hi);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--text-2);
  border: none;
  transition: background .12s, box-shadow .12s;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-2);
  border: none;
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent); }
input[type="range"]:hover::-moz-range-thumb { background: var(--accent); }
input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

.chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.chk:hover { color: var(--text); }
.chk input[type="checkbox"] {
  appearance: none;
  width: 13px; height: 13px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  background: var(--surface-hi);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.chk input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
.chk input[type="checkbox"]:checked::after {
  content: '';
  position: absolute; left: 3.5px; top: 0.5px;
  width: 4px; height: 8px;
  border: solid #0d0f12;
  border-width: 0 1.7px 1.7px 0;
  transform: rotate(40deg);
}

/* ── panels ──────────────────────────────────────────────── */

.panel {
  background: rgba(20, 23, 28, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel > h2 {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.panel-body {
  padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 0;
}

.subhead {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3);
  padding-top: 2px;
}

.row { display: flex; align-items: center; gap: 9px; }
.row > label {
  font-size: 12px; color: var(--text-2);
  width: 78px; flex-shrink: 0;
}
.row .val {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 11px; color: var(--text);
  width: 46px; text-align: right; flex-shrink: 0;
}
.row.checks { gap: 14px; flex-wrap: wrap; }

.hint { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.empty { font-size: 12px; color: var(--text-3); padding: 8px 2px; }

/* thin scrollbars wherever a panel or column scrolls */
.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
.scroll::-webkit-scrollbar-thumb:hover { background: #47505d; background-clip: content-box; }

/* ── status bar cells ────────────────────────────────────── */

.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--foot-h);
  z-index: 20;
  display: flex; align-items: stretch;
  background: rgba(15, 18, 22, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.statusbar::-webkit-scrollbar { height: 0; }

.t-cell {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 0 14px;
  border-right: 1px solid var(--line);
  min-width: 72px;
}
.t-cell label {
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
}
.t-cell span {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text);
}
.t-cell.wide { min-width: 158px; }
.t-cell.ok span { color: var(--ok); }
.t-cell.warn span { color: var(--warn); }
.t-cell.err span { color: var(--err); }

/* ── boot overlay ────────────────────────────────────────── */

#boot {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .4s ease, visibility .4s;
}
#boot.done { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-card {
  width: min(420px, 88vw);
  display: flex; flex-direction: column; gap: 6px;
  padding: 26px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.boot-mark { width: 26px; height: 26px; color: var(--accent); margin-bottom: 8px; }
.boot-card h1 { font-size: 16px; font-weight: 600; color: var(--text); }
.boot-sub { font-size: 12px; color: var(--text-3); }

.boot-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  margin: 14px 0 8px;
}
.boot-bar i {
  display: block; height: 100%; width: 0%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .18s linear;
}
/* the byte total is unknown until the first chunk lands, so sweep instead of
   sitting at zero */
.boot-bar.indeterminate i {
  width: 32% !important;
  animation: boot-sweep 1.2s ease-in-out infinite;
}
@keyframes boot-sweep { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

.boot-stat {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px;
}
#boot-stage { color: var(--text-2); }
#boot-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-3); }
.boot-note { font-size: 11.5px; color: var(--text-3); line-height: 1.55; margin-top: 10px; }

#boot.failed .boot-mark { color: var(--err); }
#boot.failed #boot-stage { color: var(--err); }
#boot.failed .boot-bar i { background: var(--err); }
.boot-trace {
  font-family: var(--mono);
  font-size: 11px; line-height: 1.6; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 34vh; overflow: auto;
  margin-top: 12px;
  border-left: 2px solid var(--err);
  padding-left: 10px;
  user-select: text;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
