:root {
  --bg:        #0d1117;
  --bg-soft:   #161b22;
  --bg-soft2:  #1c2129;
  --line:      #30363d;
  --line-soft: #21262d;
  --fg:        #c9d1d9;
  --fg-dim:    #8b949e;
  --fg-mute:   #6e7681;
  --accent:    #58a6ff;
  --accent-d:  #1f6feb;
  --green:     #3fb950;
  --green-d:   #238636;
  --green-h:   #2ea043;
  --red:       #f85149;
  --amber:     #d29922;
  --kbd-bg:    #21262d;
  --radius:    8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--fg);
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.name { font-weight: 600; color: var(--fg); }
.phase {
  background: var(--bg-soft2); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 99px;
  font-size: 11px; color: var(--accent); letter-spacing: 0.04em;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-stat {
  font-size: 12px; color: var(--fg-dim);
  background: var(--bg-soft2); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 99px;
}
.topbar-stat.ok  { color: var(--green); }
.topbar-stat.err { color: var(--red); }
.topbar-meta { font-size: 11px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font: inherit; cursor: pointer;
  background: var(--bg-soft2); border: 1px solid var(--line);
  color: var(--fg); padding: 6px 14px; border-radius: 6px;
  transition: background 80ms, border-color 80ms;
}
.btn:hover { background: #262d36; border-color: #404750; }
.btn-primary {
  background: var(--green-d); border-color: var(--green-d); color: #fff;
}
.btn-primary:hover { background: var(--green-h); border-color: var(--green-h); }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 49px);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.sidebar-header h2 {
  margin: 0 0 8px 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-mute);
}
#filter {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
}
#filter:focus { outline: none; border-color: var(--accent); }

.test-list {
  list-style: none; margin: 0; padding: 6px 6px;
  overflow-y: auto;
}
.test-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px;
  border-radius: 6px; cursor: pointer;
  font-size: 13px;
  color: var(--fg-dim);
  user-select: none;
}
.test-item:hover { background: var(--bg-soft2); color: var(--fg); }
.test-item.active {
  background: var(--bg-soft2); color: var(--fg);
  border-left: 2px solid var(--accent);
  padding-left: 7px;
}
.test-item .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--line);
}
.test-item.pass .dot { background: var(--green); }
.test-item.fail .dot { background: var(--red); }
.test-item.run  .dot { background: var(--amber); animation: pulse 1s infinite; }
.test-item.unavailable { opacity: 0.5; }
.test-item .badge {
  margin-left: auto;
  font-size: 10px; color: var(--fg-mute);
}
@keyframes pulse {
  50% { opacity: 0.4; }
}

/* ── Detail ──────────────────────────────────────────────────────────────── */
.detail {
  overflow-y: auto;
  padding: 24px 28px;
}
.placeholder {
  height: 100%;
  display: grid; place-content: center; gap: 6px;
  text-align: center;
}
.placeholder p { margin: 0; font-size: 14px; }

.detail-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.detail-header h1 {
  margin: 0; font-size: 18px; font-weight: 600;
}
.detail-header .summary {
  margin-left: auto;
  font-size: 12px;
  background: var(--bg-soft2); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 99px;
  color: var(--fg-dim);
}
.detail-header .summary.ok  { color: var(--green); border-color: var(--green); }
.detail-header .summary.err { color: var(--red);   border-color: var(--red);   }

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft2);
}
.panel-header h3 {
  margin: 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--fg-mute); font-weight: 600;
}
.panel-actions { display: flex; gap: 6px; }
.panel-body {
  padding: 0;
}
.panel-body pre {
  margin: 0; padding: 14px;
  font: inherit;
  white-space: pre;
  overflow-x: auto;
  color: var(--fg);
}
.panel-body.collapsed { display: none; }

/* Source highlighting (very minimal — keyword tokens only). */
.kw  { color: #ff7b72; }
.lit { color: #79c0ff; }
.com { color: var(--fg-mute); font-style: italic; }
.str { color: #a5d6ff; }

/* Calls table */
.calls {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.calls th, .calls td {
  text-align: left; padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.calls th {
  font-size: 11px; font-weight: 500;
  color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg-soft2);
}
.calls tr:last-child td { border-bottom: none; }
.calls td.status { width: 70px; }
.calls td.call   { color: var(--fg); }
.calls td.want, .calls td.got {
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.calls td.got.diff { color: var(--red); }
.calls .pill {
  display: inline-block;
  font-size: 10px; padding: 1px 8px; border-radius: 99px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.calls .pill.pass { background: rgba(63,185,80,0.15);  color: var(--green); }
.calls .pill.fail { background: rgba(248,81,73,0.15);  color: var(--red);   }
.calls .pill.idle { background: var(--bg-soft2); color: var(--fg-mute); }

.dim { color: var(--fg-dim); }
kbd {
  background: var(--kbd-bg); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  font-family: inherit;
}

/* Hex preview compact */
.hex {
  font-size: 11px;
  color: var(--fg-dim);
  max-height: 220px; overflow-y: auto;
}

/* Responsive */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 220px; }
}
