:root {
  --bg: #0c1210;
  --bg2: #141c18;
  --ink: #e8f0ea;
  --muted: #8fa396;
  --line: #24302a;
  --accent: #3ecf8e;
  --accent-dim: #1f6b4a;
  --danger: #ff6b5a;
  --card: #121a16;
  --input: #0a100e;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Source+Sans+3:wght@400;600;700&display=swap");

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 85% -10%, #1a3d2e 0%, transparent 55%),
    radial-gradient(700px 400px at -10% 20%, #1a2830 0%, transparent 50%),
    var(--bg);
  line-height: 1.5;
}

.wrap { width: min(960px, calc(100% - 32px)); margin: 0 auto; }
.brand {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 6px 0 8px;
  line-height: 1.15;
}
.lead { color: var(--muted); margin: 0 0 8px; max-width: 42rem; }
.muted { color: var(--muted); font-size: 0.92rem; }

.top { padding: 36px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.top-inner { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }

.panel {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }

.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; }
input[type="url"],
input[type="password"],
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--ink);
  font: inherit;
}
input:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #4ae09c, #2bb873);
  color: #04140c;
  font-weight: 700;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost, .btnish {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.ghost:hover, .btnish:hover { color: var(--ink); border-color: var(--muted); }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 26px 24px;
}
.flash {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
}
.flash.error {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: #ffd2cc;
}
.flash.warn {
  background: color-mix(in srgb, #f0a020 16%, transparent);
  border: 1px solid color-mix(in srgb, #f0a020 40%, transparent);
  color: #ffe2b0;
}

.jobs { display: grid; gap: 10px; }
.job {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: var(--bg2);
}
.job:hover { border-color: var(--accent-dim); }
.job .meta { color: var(--muted); font-size: 0.85rem; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.done { color: var(--accent); border-color: var(--accent-dim); }
.pill.error { color: var(--danger); }
.pill.cancelled, .pill.cancelling,
.pill.paused, .pill.pausing { color: #f0a020; border-color: color-mix(in srgb, #f0a020 45%, transparent); }
.ms.paused::before {
  background: #f0a020;
  border-color: #f0a020;
}
.ms.paused .ms-badge { color: #f0a020; border-color: color-mix(in srgb, #f0a020 50%, transparent); }
#status[data-status="paused"],
#status[data-status="pausing"] { color: #f0a020; }

.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
button.danger {
  background: linear-gradient(180deg, #ff8576, #e04a3a);
  color: #1a0604;
}
button.danger:disabled { opacity: 0.55; }

.report-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.report-tabs .tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.report-tabs .tab.active {
  color: var(--ink);
  border-color: var(--line);
  background: var(--bg2);
}
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.md-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.markdown-view {
  margin: 0;
  padding: 14px 16px;
  max-height: min(70vh, 720px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #d5e4da;
  user-select: text;
  -webkit-user-select: text;
}
.step-fail-detail {
  color: #ffd2cc;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
#findings-panel { margin-top: 20px; }
#findings-panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
#status[data-status="error"] { color: var(--danger); }
#status[data-status="cancelled"],
#status[data-status="cancelling"] { color: #f0a020; }
#status[data-status="done"] { color: var(--accent); }

.scoreline {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 16px;
}
.scoreline span:first-child {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--accent);
  font-weight: 700;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 800px) {
  .grid3 { grid-template-columns: 1fr; }
  .top-inner { flex-direction: column; }
}
.grid3 .box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg2);
}
.grid3 h3 { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); }
.grid3 ul { margin: 0; padding-left: 1.1rem; }
.finding {
  border-left: 3px solid var(--line);
  padding: 10px 12px;
  margin: 0 0 10px;
  background: var(--bg2);
  border-radius: 0 8px 8px 0;
}
.finding.P0 { border-left-color: var(--danger); }
.finding.P1 { border-left-color: #f0a020; }
.finding.P2 { border-left-color: #4a8fd4; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* ── Job timeline / thought chain ───────────────────────────────────── */
.job-layout { padding-bottom: 72px; }
.status-bar .status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.45s ease;
}

.timeline-panel .timeline-head h2 { margin: 0 0 4px; }
.timeline-panel .timeline-head { margin-bottom: 18px; }

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 4px;
  border-left: 2px solid var(--line);
}

.ms {
  position: relative;
  padding: 0 0 22px 22px;
}
.ms:last-child { padding-bottom: 0; }
.ms::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--line);
  box-shadow: 0 0 0 3px var(--bg);
}
.ms.done::before {
  background: var(--accent);
  border-color: var(--accent);
}
.ms.active::before {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  animation: pulse 1.4s ease-in-out infinite;
}
.ms.error::before {
  background: var(--danger);
  border-color: var(--danger);
}
.ms.skipped::before {
  background: #3a4540;
  border-color: #5a6a62;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.ms-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 6px;
}
.ms-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font-display);
}
.ms-desc { color: var(--muted); font-size: 0.88rem; margin: 0 0 10px; }
.ms-badge {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.ms.done .ms-badge { color: var(--accent); border-color: var(--accent-dim); }
.ms.active .ms-badge { color: #b8f5d4; border-color: var(--accent); }
.ms.error .ms-badge { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.step {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--line);
}
.step.pass { border-left-color: var(--accent); }
.step.fail { border-left-color: var(--danger); }
.step.warn { border-left-color: #f0a020; }
.step.info { border-left-color: #4a8fd4; }
.step-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.step-kind {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.step-title { font-weight: 600; font-size: 0.95rem; }
.step-detail {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.step-detail a { color: var(--accent); }
.step-shot {
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  max-width: 420px;
}
.step-shot img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: cover;
  object-position: top;
  cursor: zoom-in;
}
.ms.pending .steps { opacity: 0.45; }
.ms.pending .ms-head h3 { color: var(--muted); }
