:root {
  --bg: #eceae4;
  --ink: #14140f;
  --muted: #6b6b63;
  --line: #14140f;
  --card: #ffffff;
  --card-alt: #fbfbe8;
  --yellow: #e9f56a;
  --green: #1f7a4d;
  --red: #b23a3a;
  --blue: #2f5fb0;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(20, 20, 15, 0.15);
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; background: var(--ink); border-radius: 50%; display: inline-block; }
.status { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid rgba(20, 20, 15, 0.25);
  border-radius: 999px;
  white-space: nowrap;
}
.pill-muted { color: var(--muted); }
.pill-ok { background: var(--yellow); border-color: var(--ink); color: var(--ink); }
.pill-off { background: #f3d6d6; border-color: #b23a3a; color: #7c1f1f; }

/* ---- layout ---- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.intro h1 { font-size: 40px; line-height: 1.05; letter-spacing: -0.02em; margin: 8px 0 10px; }
.intro .lead { color: var(--muted); max-width: 720px; font-size: 15px; margin: 0; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 12px; margin: 26px 0 18px; flex-wrap: wrap; }
.tab {
  flex: 1 1 220px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: transparent;
  border: 1px solid rgba(20, 20, 15, 0.2);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.tab:hover { border-color: var(--ink); }
.tab.is-active { background: var(--card); border-color: var(--ink); box-shadow: 4px 4px 0 rgba(20, 20, 15, 0.12); }
.tab .num {
  font-family: var(--mono);
  font-size: 12px;
  background: #e7e7de;
  padding: 2px 6px;
}
.num-yellow { background: var(--yellow) !important; }
.num-dark { background: var(--ink) !important; color: #fff; }
.tab-title { font-weight: 700; font-size: 18px; }
.tab-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--muted); margin-left: auto; }
/* Locked tabs stay legible and clickable: the panel behind them carries the
   explanation, so dimming them into unreadability would hide the answer. LOCKED
   takes over the right-hand slot from the character label rather than sitting
   next to it, which would wrap the title in a four-tab row. */
.tab.is-locked { border-style: dashed; }
.tab.is-locked .tab-title, .tab.is-locked .num { opacity: 0.6; }
.tab.is-locked .tab-sub { display: none; }
.tab-lock {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
  background: #f3d6d6; border: 1px solid #b23a3a; color: #7c1f1f; padding: 1px 5px;
  margin-left: auto;
}

/* ---- panels ---- */
.panel { display: none; }
.panel.is-active { display: block; }
.panel.is-gated .grid { display: none; }

/* ---- gate notice ---- */
/* There is no soft "degraded" notice any more: a loop either has all three keys
   and runs traced, or it is gated. There is no third state to style. */
.gate-notice { border: 1px solid var(--ink); background: var(--card-alt); padding: 18px; }
.gate-notice h3 { margin: 6px 0 6px; font-size: 20px; letter-spacing: -0.01em; }
.gate-notice p { margin: 0; font-size: 14px; color: #33332b; }
/* Beats the later width:100% on .run, which would stretch this to the panel. */
.gate-notice .gate-btn { width: auto; margin-top: 14px; }
.grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid rgba(20, 20, 15, 0.2);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-head .num { font-family: var(--mono); font-size: 12px; background: #e7e7de; padding: 2px 6px; }
.card h2 { margin: 2px 0 12px; font-size: 26px; letter-spacing: -0.01em; }
.facts { list-style: none; margin: 0 0 14px; padding: 0; }
.facts li { padding: 6px 0; border-bottom: 1px dotted rgba(20, 20, 15, 0.18); font-size: 15px; }
.trace-line { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 10px; }
.trace-line b { color: var(--ink); }

textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(20, 20, 15, 0.3);
  padding: 10px;
  font-family: var(--sans);
  font-size: 14px;
  resize: vertical;
  background: #fff;
}
textarea:focus { outline: 2px solid var(--yellow); border-color: var(--ink); }

/* ---- setup form ---- */
.field { margin-bottom: 16px; }
.field + .field { border-top: 1px dotted rgba(20, 20, 15, 0.18); padding-top: 14px; }
.field label { display: block; }
.field .hint { margin-top: 6px; }
.sublabel { margin-top: 10px; }
input[type="text"], input[type="password"], select {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(20, 20, 15, 0.3);
  padding: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input[type="text"], input[type="password"] { font-family: var(--mono); }
select { font-family: var(--sans); }
input:focus, select:focus { outline: 2px solid var(--yellow); border-color: var(--ink); }
/* Only .req exists: every credential this form collects is required. */
.req {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; padding: 1px 5px; margin-left: 6px;
  background: var(--ink); color: #fff;
}
.setup-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.setup-actions .run { width: auto; margin-top: 0; }
.setup-msg { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 12px 0 0; min-height: 16px; }
.setup-msg.is-ok { color: #145c39; }
.setup-msg.is-warn { color: #7c1f1f; }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip {
  font-size: 12px;
  border: 1px solid rgba(20, 20, 15, 0.25);
  background: #fff;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
}
.chip:hover { border-color: var(--ink); background: var(--card-alt); }

.run {
  margin-top: 12px;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.run:hover { background: #2c2c22; }
.run:disabled { opacity: 0.55; cursor: default; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
code { font-family: var(--mono); font-size: 12px; background: #eeeee2; padding: 1px 4px; }

/* ---- file view (coding) ---- */
.file-view { margin-top: 16px; border-top: 1px dotted rgba(20, 20, 15, 0.2); padding-top: 12px; }
.file-view .eyebrow { display: flex; justify-content: space-between; align-items: center; }
.link { background: none; border: none; color: var(--blue); cursor: pointer; font-family: var(--mono); font-size: 11px; text-decoration: underline; padding: 0; }
.code {
  font-family: var(--mono);
  font-size: 12px;
  background: #1b1b16;
  color: #eee;
  padding: 12px;
  overflow: auto;
  margin: 8px 0 0;
  max-height: 240px;
  line-height: 1.5;
}

/* ---- run box (right column) ---- */
.runbox {
  background: var(--card);
  border: 1px solid rgba(20, 20, 15, 0.2);
  min-height: 320px;
  padding: 18px;
}
.runbox-empty { color: var(--muted); font-size: 14px; padding: 30px 6px; text-align: center; }

.run-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.run-head .eyebrow { display: flex; align-items: center; gap: 8px; }
.spinner {
  width: 12px; height: 12px; border: 2px solid rgba(20,20,15,0.25); border-top-color: var(--ink);
  border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* steps timeline */
.steps { list-style: none; margin: 0; padding: 0; }
.step {
  border-left: 2px solid rgba(20, 20, 15, 0.2);
  padding: 0 0 14px 16px;
  position: relative;
  opacity: 0;
  transform: translateY(4px);
  animation: reveal 0.28s ease forwards;
}
@keyframes reveal { to { opacity: 1; transform: none; } }
.step.is-shown { opacity: 1; transform: none; animation: none; }
.step::before {
  content: "";
  position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; background: var(--ink); border-radius: 50%;
}
.step-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-name { font-weight: 700; font-size: 14px; }
.badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 6px; border: 1px solid rgba(20,20,15,0.25);
}
.badge-generation { background: var(--yellow); border-color: var(--ink); }
.badge-tool { background: #dfe8f7; border-color: #2f5fb0; color: #23407a; }
.badge-deterministic { background: #e7e7de; }
.badge-approval { background: var(--ink); color: #fff; }
.badge-score { background: #d8efe1; border-color: var(--green); color: #145c39; }
.step-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: auto; }
.step-body { font-size: 13.5px; color: #33332b; margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }

/* answer + scores + trace link */
.result { margin-top: 16px; border-top: 1px dotted rgba(20, 20, 15, 0.25); padding-top: 14px; }
.result .eyebrow { display: block; margin-bottom: 6px; }
.answer { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.scores { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.score {
  font-family: var(--mono); font-size: 12px; padding: 5px 10px;
  background: #d8efe1; border: 1px solid var(--green); color: #145c39;
}
.score.bad { background: #f3d6d6; border-color: var(--red); color: #7c1f1f; }

.trace-cta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.trace-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--yellow); color: var(--ink); border: 1px solid var(--ink);
  padding: 10px 16px; font-weight: 700; font-size: 14px; text-decoration: none;
  box-shadow: 3px 3px 0 rgba(20,20,15,0.18);
}
.trace-btn:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 rgba(20,20,15,0.18); }
.trace-btn.disabled { background: #e7e7de; border-color: rgba(20,20,15,0.25); color: var(--muted); box-shadow: none; cursor: default; pointer-events: none; }
.feedback { display: flex; align-items: center; gap: 6px; }
.fb { border: 1px solid rgba(20,20,15,0.3); background: #fff; cursor: pointer; padding: 6px 10px; font-size: 13px; }
.fb:hover { border-color: var(--ink); }
.fb.chosen { background: var(--ink); color: #fff; }

/* approval gate */
.gate { margin-top: 16px; border: 1px solid var(--ink); background: var(--card-alt); padding: 14px; }
.gate h3 { margin: 0 0 8px; font-size: 15px; }
.gate .row { display: flex; gap: 10px; margin-top: 12px; }
.btn-approve { background: var(--green); color: #fff; border: none; padding: 10px 16px; font-weight: 700; cursor: pointer; }
.btn-reject { background: #fff; color: var(--red); border: 1px solid var(--red); padding: 10px 16px; font-weight: 700; cursor: pointer; }
.btn-approve:hover { filter: brightness(1.08); }
.btn-reject:hover { background: #fbeaea; }

/* diff */
.diff { font-family: var(--mono); font-size: 12px; background: #1b1b16; padding: 12px; overflow: auto; margin: 8px 0 0; line-height: 1.5; max-height: 320px; }
.diff .ln { display: block; white-space: pre; color: #c9c9be; }
.diff .add { background: rgba(56, 161, 105, 0.22); color: #a6e6c2; }
.diff .del { background: rgba(178, 58, 58, 0.22); color: #f0b3b3; }
.diff .hunk { color: #7f9fd6; }

.err { background: #f3d6d6; border: 1px solid var(--red); color: #7c1f1f; padding: 12px; font-size: 13px; font-family: var(--sans); }
/* Small and selectable: enough for a visitor to quote the id in a support note,
   not enough to read as the headline of the failure. */
.err-id { display: block; margin-top: 8px; font-family: var(--mono); font-size: 11px; opacity: 0.75; user-select: all; }

.foot { margin-top: 34px; border: 1px solid rgba(20,20,15,0.3); padding: 14px 16px; }
