:root {
  --bg: #121212;
  --bg-elev: #181818;
  --bg-elev-2: #212121;
  --green: #1db954;
  --green-dim: #14833b;
  --red: #e22134;
  --amber: #f59b23;
  --text: #ffffff;
  --text-dim: #b3b3b3;
  --border: #2a2a2a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Circular Std", "Inter", -apple-system, system-ui, sans-serif; }
h2 { margin: 0 0 12px; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 600; }

header { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--border); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.dot { width: 12px; height: 12px; background: var(--green); border-radius: 50%;
  box-shadow: 0 0 12px var(--green); }
.pill { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }
.meta { color: var(--text-dim); font-size: 12px; font-family: ui-monospace, SF Mono, Menlo, monospace; }

main { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 32px; }
.left, .right { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; }
.card.hidden { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-dim); padding: 4px 12px; border-radius: 999px; font-size: 12px;
  cursor: pointer; transition: 0.15s; }
.chip:hover { border-color: var(--green); color: var(--text); }

textarea { width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 14px;
  font-family: inherit; resize: vertical; margin-bottom: 12px; }
textarea:focus { outline: none; border-color: var(--green); }

button { background: var(--green); color: #000; border: none; border-radius: 999px;
  padding: 10px 24px; font-weight: 700; cursor: pointer; font-size: 14px;
  transition: 0.15s; }
button:hover:not(:disabled) { transform: scale(1.03); background: #1ed760; }
button:disabled { background: var(--green-dim); cursor: not-allowed; opacity: 0.6; }

.reply { padding: 12px; background: var(--bg); border-left: 3px solid var(--green);
  border-radius: 6px; font-size: 14px; line-height: 1.5; margin-bottom: 10px; }
.reply-meta { font-size: 12px; color: var(--text-dim);
  font-family: ui-monospace, SF Mono, Menlo, monospace; }

.rail { position: relative; padding-left: 36px; }
/* rail spans first badge to last badge only, not below step 4 */
.rail::before { content: ""; position: absolute; left: 15px; top: 28px; height: calc(100% - 90px);
  width: 2px; background: var(--border); border-radius: 2px; }
.rail::after { content: ""; position: absolute; left: 15px; top: 28px; width: 2px;
  height: calc((100% - 90px) * var(--fill-frac, 0)); background: var(--green); border-radius: 2px;
  transition: height 0.4s ease; box-shadow: 0 0 8px var(--green); }

.step { position: relative; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; transition: 0.25s; margin-bottom: 16px; }
.step:last-child { margin-bottom: 0; }
.step.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.step.done { border-color: var(--green-dim); }

.step-head { display: flex; align-items: center; gap: 12px; font-weight: 600; margin-bottom: 8px; }
.badge { position: absolute; left: -36px; top: 12px; background: var(--bg);
  color: var(--text-dim); width: 32px; height: 32px; border: 2px solid var(--border);
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; z-index: 2; transition: 0.25s; }
.step.active .badge { background: var(--green); color: #000; border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(29,185,84,0.15); }
.step.done .badge { background: var(--green); color: #000; border-color: var(--green); }
.step.done .badge::after { content: "✓"; position: absolute; font-size: 14px; }
.step.done .badge span { display: none; }
.label { flex: 1; }
.status { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); font-family: ui-monospace, SF Mono, Menlo, monospace; }
.step-body { color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.step.active .step-body, .step.done .step-body { color: var(--text); }

.retrieved-item { padding: 10px 12px; background: var(--bg); border-radius: 8px;
  border: 1px solid var(--border); margin-top: 8px; font-size: 12px; line-height: 1.5; }
.retrieved-item .sim { color: var(--green); font-family: ui-monospace, monospace;
  font-weight: 700; margin-right: 8px; }
.retrieved-item .cust { color: var(--text-dim); }
.retrieved-item .reply-line { color: var(--text); margin-top: 4px; }
.retrieved-item .reply-line b { color: var(--green); }

.decision { display: inline-block; padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.decision.auto { background: var(--green); color: #000; }
.decision.escalate { background: var(--amber); color: #000; }
.reason { margin-top: 6px; color: var(--text-dim); font-family: ui-monospace, monospace;
  font-size: 12px; }
.reason b { color: var(--red); }

.conf-bar { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 4px;
  overflow: hidden; }
.conf-bar > span { display: block; height: 100%; background: var(--green);
  transition: width 0.4s; }

.cite { display: inline-block; background: var(--bg-elev-2); color: var(--green);
  padding: 2px 8px; border-radius: 999px; font-family: ui-monospace, monospace;
  font-size: 11px; margin-right: 6px; }
.tiny { font-size: 11px; color: var(--text-dim); font-family: ui-monospace, monospace; }

.bench-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.bench-empty { color: var(--text-dim); font-style: italic; padding: 16px 0; }
.bench-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bench-table th, .bench-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bench-table th:first-child, .bench-table td:first-child { text-align: left; }
.bench-table th:not(:first-child), .bench-table td:not(:first-child) { text-align: center; }
.bench-table th { color: var(--text-dim); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; }
.bench-table td.num { font-family: ui-monospace, monospace; color: var(--text); }
.bench-table tr.ours td { color: var(--text); background: rgba(29,185,84,0.05); }
.bench-table tr.ours td:first-child::after { content: "★"; margin-left: 8px; color: var(--green); }
.bench-table td.best { color: var(--green); font-weight: 700; }
.bench-table tr td:first-child { font-weight: 600; text-transform: capitalize; }

.dim-list { display: flex; flex-direction: column; gap: 10px; }
.dim { display: grid; grid-template-columns: 120px 1fr 48px; gap: 12px; align-items: center;
  font-size: 12px; }
.dim-name { color: var(--text-dim); text-transform: capitalize; }
.dim-bar { height: 6px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.dim-bar > span { display: block; height: 100%; background: var(--green);
  border-radius: 3px; transition: width 0.6s ease; }
.dim-val { font-family: ui-monospace, monospace; color: var(--text);
  text-align: right; font-size: 12px; }

.bench-meta { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; font-size: 12px; }
.bench-meta .k { color: var(--text-dim); }
.bench-meta .v { color: var(--text); font-family: ui-monospace, monospace; }
.bench-meta .badge-free { background: var(--green); color: #000; padding: 2px 10px;
  border-radius: 999px; font-weight: 700; font-size: 11px; }

.sub-h { color: var(--text-dim); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; margin: 0 0 10px; font-weight: 600; }

@media (max-width: 900px) {
  .bench-grid { grid-template-columns: 1fr; }
}

footer { border-top: 1px solid var(--border); padding: 24px 32px; background: var(--bg); }
pre { margin: 0; background: var(--bg-elev); border: 1px solid var(--border);
  padding: 16px; border-radius: var(--radius); font-size: 12px; overflow-x: auto;
  color: var(--text-dim); font-family: ui-monospace, SF Mono, Menlo, monospace; line-height: 1.6; }

/* readiness gate — shown while the backend wakes and the embedder downloads.
   Run agent stays disabled until this reaches the ready state. */
#gate { margin-top: 12px; }
#gate.gate-done { display: none; }
.gate-head { display: flex; align-items: center; gap: 8px; font-size: 12px;
  color: var(--text-dim); font-family: ui-monospace, SF Mono, Menlo, monospace; }
.gate-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber);
  flex: none; animation: gate-pulse 1.4s ease-in-out infinite; }
#gate.is-ready .gate-dot { background: var(--green); animation: none;
  box-shadow: 0 0 8px var(--green); }
#gate.is-failed .gate-dot { background: var(--red); animation: none; }
@keyframes gate-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.gate-bar { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden;
  margin-top: 8px; }
.gate-bar > span { display: block; height: 100%; width: 0%; background: var(--amber);
  border-radius: 2px; transition: width 0.3s ease; }
#gate.is-ready .gate-bar > span { background: var(--green); }
#gate.is-failed .gate-bar > span { background: var(--red); }
/* indeterminate: used while waking the backend, where there is no percentage to show */
#gate.is-indeterminate .gate-bar > span { width: 35%; animation: gate-slide 1.5s ease-in-out infinite; }
@keyframes gate-slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.gate-why { margin-top: 6px; line-height: 1.5; }
.gate-retry { margin-top: 10px; padding: 6px 16px; font-size: 12px; }
.gate-retry.hidden { display: none; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}
