/* TimeTravelJS — dark debugger aesthetic */
:root {
  --bg: #0b0e14;
  --bg-raise: #10141d;
  --bg-panel: #121724;
  --bg-inset: #0d111a;
  --border: #1e2635;
  --border-soft: #182030;
  --text: #c9d3e0;
  --text-dim: #7d8a9e;
  --text-faint: #55617400;
  --accent: #4dd0e1;
  --accent-2: #8b7cf6;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --line-h: 21px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(139, 124, 246, 0.08), transparent 60%),
    radial-gradient(900px 420px at 5% -10%, rgba(77, 208, 225, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 26, 0.7);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-mark { font-size: 20px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.brand-accent { color: var(--accent); }
.brand-sub { color: var(--text-dim); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sample-label { color: var(--text-dim); font-size: 12px; }
.sample-select {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--sans);
  font-size: 13px;
  max-width: 300px;
}

.btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, transform 60ms;
  user-select: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-run { border-color: rgba(77, 208, 225, 0.5); font-weight: 600; }
.btn-run-icon { color: var(--err); }
.status-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.status-pill.ok { color: var(--ok); border-color: rgba(74, 222, 128, 0.4); }
.status-pill.err { color: var(--err); border-color: rgba(248, 113, 113, 0.4); }
.status-pill.busy { color: var(--accent); border-color: rgba(77, 208, 225, 0.4); }

/* ---------- transport ---------- */
.transport {
  padding: 8px 18px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 20, 29, 0.5);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "buttons pos" "slider slider" "canvas canvas";
  gap: 4px 12px;
}
.transport-buttons { grid-area: buttons; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.tbtn { font-family: var(--mono); min-width: 38px; text-align: center; padding: 5px 8px; }
.tbtn-primary { border-color: rgba(77, 208, 225, 0.55); color: var(--accent); font-weight: 700; }
.tbtn.playing { border-color: var(--accent); color: var(--accent); }
.tsep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.transport-pos { grid-area: pos; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.pos-label { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.pos-label b { color: var(--accent); font-size: 14px; }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
}
.badge-warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.5); }

.timeline-slider {
  grid-area: slider;
  width: 100%;
  margin: 2px 0 0;
  accent-color: var(--accent);
  height: 18px;
}
.timeline-canvas {
  grid-area: canvas;
  width: 100%;
  display: block;
  cursor: crosshair;
  border-top: 1px solid var(--border-soft);
}

/* ---------- workspace ---------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 1.2fr) minmax(340px, 1fr);
  gap: 14px;
  padding: 14px 18px;
  min-height: 0;
  align-items: stretch;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
}
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.015);
}
.panel-hint { text-transform: none; letter-spacing: 0; font-size: 11px; color: #5b6880; }
.panel-body { padding: 8px 10px; overflow: auto; }

/* ---------- editor ---------- */
.editor-card { min-height: 420px; }
.editor-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg-inset);
}
.gutter {
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--line-h);
  color: #4c586c;
  text-align: right;
  padding: 10px 0;
  user-select: none;
  border-right: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.012);
  overflow: hidden;
  flex: 0 0 auto;
  width: 56px;
}
.gutter .ln {
  padding: 0 8px 0 0;
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}
.gutter .ln:hover { color: var(--text); }
.gutter .ln.bp::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--err);
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.7);
}
.gutter .ln.cur { color: var(--accent); font-weight: 700; }
.editor-scroller {
  position: relative;
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.hl-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  min-width: 100%;
}
.hl-band {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(77, 208, 225, 0.10);
  border-left: 2px solid var(--accent);
}
.hl-band.hl-err {
  background: rgba(248, 113, 113, 0.12);
  border-left-color: var(--err);
}
.code-input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 380px;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  border: 0;
  outline: none;
  resize: none;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--line-h);
  white-space: pre;
  overflow: hidden;
}

/* ---------- side panels ---------- */
.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
#panel-vars .panel-body { max-height: 240px; min-height: 60px; }
#panel-stack .panel-body { max-height: 160px; min-height: 40px; }
.panel-console { min-height: 180px; }
.panel-console .panel-body { max-height: 220px; flex: 1; }
#panel-memory .panel-body { padding-bottom: 12px; }

.empty-note { color: #55617a; font-size: 12px; font-style: italic; padding: 4px 2px; }

/* value trees */
.vtree { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.vgroup-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5b6880;
  margin: 6px 0 2px;
}
.vrow { white-space: nowrap; }
.vrow.vchanged { background: rgba(255, 199, 92, 0.13); border-radius: 4px; box-shadow: inset 2px 0 0 rgba(255, 199, 92, 0.65); }
.vkey { color: #9ab0d0; }
.vkey.vkey-local { color: #a7c1e8; }
.vsep { color: #55617a; }
.v-num { color: #f0a45d; }
.v-str { color: #8fd18c; }
.v-bool { color: #d98fd0; }
.v-null, .v-undef { color: #7d8a9e; font-style: italic; }
.v-fn { color: #6db3f2; font-style: italic; }
.v-cls { color: #c9a7f5; }
.v-punct { color: #55617a; }
.v-special { color: var(--warn); }
.v-tdz { color: #55617a; font-style: italic; }
.vtoggle {
  cursor: pointer;
  color: #55617a;
  display: inline-block;
  width: 14px;
  user-select: none;
}
.vtoggle:hover { color: var(--accent); }
.vchildren { padding-left: 18px; }
.vchildren.collapsed { display: none; }

/* call stack */
.stack-row {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 2px 4px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.stack-row:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
.stack-fn { color: #6db3f2; }
.stack-loc { color: #55617a; }
.stack-row.stack-top .stack-fn { color: var(--accent); font-weight: 600; }

/* console */
.console-list { font-family: var(--mono); font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.console-row { padding: 2px 6px; border-left: 2px solid transparent; white-space: pre-wrap; word-break: break-word; }
.console-row.level-warn { color: var(--warn); border-left-color: rgba(251, 191, 36, 0.5); }
.console-row.level-error { color: var(--err); border-left-color: rgba(248, 113, 113, 0.5); }
.console-row.level-info { color: var(--accent); }
.console-row.level-input { color: #8fa3c0; }
.console-row.level-input::before { content: "❯ "; color: var(--accent-2); }
.console-row.level-result::before { content: "← "; color: #55617a; }
.console-row.level-sys { color: #55617a; font-style: italic; }
.console-row .step-tag {
  color: #46536a;
  font-size: 10px;
  margin-right: 6px;
  user-select: none;
}
.console-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border-soft);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.012);
}
.console-chevron { color: var(--accent-2); font-family: var(--mono); }
.console-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}
.fork-btn {
  flex: none;
  padding: 3px 10px;
  font-size: 11.5px;
  color: #f0a45d;
  border: 1px solid rgba(240, 164, 93, 0.35);
  border-radius: 6px;
  background: rgba(240, 164, 93, 0.08);
}
.fork-btn:hover {
  background: rgba(240, 164, 93, 0.18);
  border-color: rgba(240, 164, 93, 0.6);
}

/* memory panel */
.mem-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 8px;
}
.mem-stat { display: flex; justify-content: space-between; gap: 8px; }
.mem-stat .k { color: var(--text-dim); }
.mem-stat .v { color: var(--text); }
.mem-stat .v.hi { color: var(--ok); font-weight: 700; }
.mem-bar-outer {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 6px;
  background: rgba(139, 124, 246, 0.18);
  overflow: hidden;
  position: relative;
}
.mem-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 6px;
}
.mem-bar-caption {
  grid-column: 1 / -1;
  color: #5b6880;
  font-size: 11px;
  margin-top: -2px;
}
.mem-viz-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5b6880;
  margin: 8px 0 4px;
}
.mem-canvas { width: 100%; display: block; border-radius: 6px; background: var(--bg-inset); }

/* footer */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 18px 12px;
  color: #55617a;
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer em { color: var(--accent-2); font-style: normal; }

/* ---- v6: DOM document panels ---- */
.html-title { border-top: 1px solid var(--border, #2a2f3a); margin-top: 6px; }
.html-input { min-height: 84px; max-height: 160px; resize: vertical; width: 100%; box-sizing: border-box; }
.dom-body { padding: 0; }
.dom-preview { width: 100%; height: 180px; border: 0; background: #fff; border-radius: 0 0 8px 8px; }

/* ---- the multiverse: branch strip + what-if panel ---- */
.branch-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 2px 0;
}
.branch-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 2px;
}
.branch-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
}
.branch-chip:hover { border-color: var(--accent); }
.branch-chip.current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.branch-chip.errored .branch-steps { color: #ff7b72; }
.branch-chip .branch-edit {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
}
.branch-chip .branch-steps { opacity: 0.75; }

.whatif-body { display: flex; flex-direction: column; gap: 6px; }
.whatif-edits, .whatif-probe {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  resize: vertical;
}
.whatif-row { display: flex; gap: 6px; }
.whatif-row .btn { flex: none; }
.whatif-results { display: flex; flex-direction: column; gap: 4px; }
.whatif-head { font-size: 11px; color: var(--text-dim); }
.whatif-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 12px;
  text-align: left;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.whatif-result:hover { border-color: var(--accent); }
.whatif-edit { font-family: var(--mono); }
.whatif-outcome { white-space: nowrap; }
.whatif-first { color: var(--accent); font-size: 11px; }

/* ---- url input (editor card) ---- */
.url-input {
  width: 100%;
  height: 30px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 2px 0 6px;
}
