:root {
  --bg: #f5f5f2;
  --card: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b65;
  --line: #e3e3de;
  --accent: #d9480f;
  --accent-text: #ffffff;
  --ok: #2b8a3e;
  --warn: #a86a00;
  --bad: #c92a2a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --card: #1e1e1c;
    --text: #ecece7;
    --muted: #9b9b94;
    --line: #2e2e2b;
    --accent: #ff6b2c;
    --accent-text: #1a0c04;
    --ok: #51cf66;
    --warn: #fcc419;
    --bad: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -0.01em; }
.brand .muted { font-weight: 450; }

main, #dash { display: grid; gap: 14px; }
main { max-width: 880px; margin: 0 auto; padding: 8px 16px 48px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  min-width: 0;
}
.gate { width: 100%; max-width: 420px; margin: 12vh auto 0; text-align: center; }

h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 650; margin: 0; }
.card > h2 { margin-bottom: 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.error { color: var(--bad); font-size: 14px; margin: 10px 0 0; }
.note:empty, .error:empty { display: none; }

button {
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.quiet { border-color: transparent; color: var(--muted); padding: 4px 8px; }
button.quiet:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
button.danger:hover:not(:disabled) { color: var(--bad); }
.gate button.primary { margin-top: 8px; padding: 10px 18px; }

.badge {
  font-size: 12px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
}
.badge[data-state="running"] { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge[data-state="pending"],
.badge[data-state="stopping"] { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 14px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--bg); min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .v.small { font-size: 15px; font-weight: 600; padding: 6px 0 3px; overflow-wrap: anywhere; }
.stat .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.mono { font-family: var(--mono); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.matches li { justify-content: flex-start; align-items: baseline; }
.list .when { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.log {
  margin: 0;
  max-height: 340px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  font: 12px/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
