:root {
  --bg0: #0f1419;
  --bg1: #171d25;
  --bg2: #1e2732;
  --line: #2a3542;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3db89a;
  --accent-dim: #2a7d6a;
  --warn: #d4a24c;
  --err: #d66767;
  --ok: #5cb88a;
  --run: #4aa3d9;
  --radius: 10px;
  --font: "IBM Plex Sans", "Source Han Sans SC", "Noto Sans SC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2a28 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2433 0%, transparent 50%),
    var(--bg0);
  color: var(--text);
}

.app { min-height: 100%; display: flex; flex-direction: column; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #041510;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 0.02em;
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -0.02em; }
.sub { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.8rem; }
.top-actions { display: flex; gap: 0.75rem; align-items: center; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.pane { min-height: 0; }
.list-pane {
  border-right: 1px solid var(--line);
  background: rgba(23, 29, 37, 0.7);
  display: flex;
  flex-direction: column;
}
.pane-head, .detail-head, .sample-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.pane-head { padding: 0.9rem 1rem 0.4rem; }
.pane-head h2, .detail h2, .sample-bar h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.muted { color: var(--muted); font-size: 0.8rem; }
.path {
  margin: 0.25rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

.run-list {
  overflow: auto;
  padding: 0.4rem 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.run-item {
  text-align: left;
  border: 1px solid transparent;
  background: var(--bg2);
  color: inherit;
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.run-item:hover { border-color: var(--accent-dim); }
.run-item.active { border-color: var(--accent); background: #22303a; }
.run-item .name { font-weight: 600; font-size: 0.92rem; }
.run-item .meta { margin-top: 0.35rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.bar {
  margin-top: 0.45rem;
  height: 4px;
  background: #0c1116;
  border-radius: 99px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  width: 0%;
  transition: width 0.4s ease;
}

.detail-pane { padding: 1rem 1.25rem 2rem; overflow: auto; }
.detail.hidden, .empty.hidden { display: none; }
.empty {
  color: var(--muted);
  padding: 4rem 1rem;
  text-align: center;
}
.detail-head { margin-bottom: 1rem; }

.badge {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
}
.badge.running { color: var(--run); border-color: #2a5f7d; }
.badge.completed { color: var(--ok); border-color: #2f6b4e; }
.badge.stale, .badge.failed { color: #e08a7a; border-color: #7a3f36; }
.badge.unknown { color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}
.metric {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
}
.metric .label { color: var(--muted); font-size: 0.72rem; }
.metric .value { margin-top: 0.25rem; font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.metric .value small { font-size: 0.75rem; font-weight: 500; color: var(--muted); }

.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.tab.active { color: var(--text); border-color: var(--accent); background: rgba(61, 184, 154, 0.12); }

.sample-bar { margin: 0.5rem 0 0.75rem; }
.sample-actions { display: flex; gap: 0.35rem; }

.btn {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.btn:hover { border-color: var(--accent-dim); }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.78rem; }
.btn.active { border-color: var(--accent); color: var(--accent); }

.samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.sample {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: fadein 0.35s ease both;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.sample-img {
  aspect-ratio: 3 / 4;
  background: #0c1116;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.sample-img button.thumb {
  all: unset;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}
.sample-img img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.sample-img .zoom-hint {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  font-size: 0.65rem;
  color: #dfe8f0;
  background: rgba(0, 0, 0, 0.55);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.sample-img:hover .zoom-hint { opacity: 1; }
.sample-img .ph { color: var(--muted); font-size: 0.75rem; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 10, 14, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 0.75rem;
  animation: fadein 0.18s ease both;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: min(96vw, 1200px);
  max-height: calc(100vh - 5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.lightbox-caption {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
  max-width: 96vw;
}
.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.lightbox-close:hover { color: var(--accent); }

.json-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 10, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadein 0.18s ease both;
}
.json-modal.hidden { display: none; }
.json-panel {
  width: min(960px, 96vw);
  max-height: min(88vh, 900px);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.json-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.json-panel-head h3 { margin: 0; font-size: 1rem; }
.json-panel-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.json-body {
  margin: 0;
  padding: 1rem 1.1rem 1.25rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: #d5dee8;
  white-space: pre;
  tab-size: 2;
}
.btn-json {
  margin-top: 0.55rem;
  width: 100%;
}
.sample-body { padding: 0.65rem 0.75rem 0.8rem; }
.sample-id {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 0.4rem;
}
.kv { display: grid; gap: 0.25rem; }
.kv div { font-size: 0.8rem; line-height: 1.35; }
.kv b { color: var(--muted); font-weight: 500; margin-right: 0.35rem; }
.err-line { color: #e08a7a; font-size: 0.75rem; margin-top: 0.4rem; }
details.raw {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
}
details.raw pre {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
  background: #0c1116;
  padding: 0.45rem;
  border-radius: 6px;
  color: #c5d0db;
}
