/* KYA Mission Control — demo console
 *  Brand palette: dark slate (#0F1419) + gold (#D4A843) + teal (#2DD4BF)
 */

:root {
  --bg: #0F1419;
  --bg-2: #161D26;
  --bg-3: #1F2935;
  --line: #2A3744;
  --text: #E6EDF3;
  --text-muted: #8FA1B5;
  --gold: #D4A843;
  --gold-2: #B98F2F;
  --teal: #2DD4BF;
  --green: #4ADE80;
  --red: #F87171;
  --yellow: #FACC15;
  --shadow: 0 1px 0 rgba(255,255,255,.04), 0 4px 24px rgba(0,0,0,.45);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a, .link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
  font-size: 13px;
}
a:hover, .link:hover { color: var(--gold); border-color: var(--gold); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(to bottom, var(--bg), rgba(15,20,25,.85));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .14em;
  font-size: 15px;
  color: var(--gold);
  background: rgba(212,168,67,.10);
  border: 1px solid rgba(212,168,67,.35);
  padding: 4px 10px;
  border-radius: 6px;
}
.brand-tag { color: var(--text-muted); font-size: 14px; letter-spacing: .04em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 28px 80px;
}

.hero { padding: 48px 0 24px; }
.hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  margin: 0 0 12px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.hero .lede {
  color: var(--text-muted);
  max-width: 820px;
  font-size: 16px;
  margin: 0;
}
.hero strong { color: var(--gold); font-weight: 600; }

/* ----- card ----- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; gap: 14px;
  margin: -4px 0 18px;
}
.card-header h2 {
  font-size: 18px; margin: 0;
  font-weight: 600;
  flex: 1;
}
.step-num {
  font-family: var(--mono);
  color: var(--gold);
  background: rgba(212,168,67,.10);
  border: 1px solid rgba(212,168,67,.30);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  letter-spacing: .12em;
}

.small { font-size: 12px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ----- form ----- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input, .field textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,168,67,.18);
}
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin: 16px 0 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font: 600 14px var(--sans);
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .05s ease, background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active { transform: translateY(1px); }
.btn-arrow { font-size: 16px; line-height: 1; }
.btn-gold {
  background: var(--gold); color: #1A1A1A;
}
.btn-gold:hover { background: var(--gold-2); }
.btn-outline {
  background: transparent; color: var(--text);
  border-color: var(--line);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

/* ----- pills ----- */
.pill {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-3);
}
.pill-muted { color: var(--text-muted); }
.pill-success { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.08); }
.pill-running { color: var(--teal); border-color: rgba(45,212,191,.4); background: rgba(45,212,191,.08); }
.pill-stuck   { color: var(--yellow); border-color: rgba(250,204,21,.4); background: rgba(250,204,21,.10); }
.pill-blocked { color: var(--red);    border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.10); }
.pill-error   { color: var(--red);    border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.10); }

/* ============================================================
   GATE STORY  ── three agents arrive
   ============================================================ */

.gate-card .card-header { gap: 16px; }

.agents-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1180px) { .agents-row { grid-template-columns: 1fr 1fr; } }
@media (max-width:  600px) { .agents-row { grid-template-columns: 1fr; } }

.agent {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  min-height: 220px;
  transition: border-color .25s ease, transform .15s ease;
}
.agent.running   { border-color: rgba(45,212,191,.55); }
.agent.passed    { border-color: rgba(74,222,128,.55); }
.agent.blocked   { border-color: rgba(248,113,113,.55); }
.agent.checkpoint{ border-color: rgba(250,204,21,.55); }

.agent-head { display: flex; align-items: center; gap: 12px; }
.agent-emoji {
  font-size: 30px; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}
.agent-name {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .04em;
  font-size: 14px;
}
.agent-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
}
.agent-intent {
  color: var(--text-muted);
  font-size: 13px;
  margin: 6px 0 4px;
}
.agent-attrs {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11px;
  color: var(--text-muted);
}
.agent-attr {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
}
.agent-attr.gold { color: var(--gold); border-color: rgba(212,168,67,.4); }
.agent-attr.red  { color: var(--red);  border-color: rgba(248,113,113,.4); }

.agent-stamp {
  position: absolute;
  right: 16px; top: 16px;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .14em;
  padding: 6px 10px;
  border-radius: 6px;
  transform: rotate(-8deg);
  border: 2px dashed transparent;
  opacity: 0;
  transition: opacity .35s ease;
}
.agent.passed    .agent-stamp { opacity: 1; color: var(--green);  border-color: var(--green); }
.agent.blocked   .agent-stamp { opacity: 1; color: var(--red);    border-color: var(--red); }
.agent.checkpoint .agent-stamp{ opacity: 1; color: var(--yellow); border-color: var(--yellow); }

/* The gate-check lane under each agent: 4 pills lighting up sequentially. */
.lanes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 1180px) { .lanes { grid-template-columns: 1fr 1fr; } }
@media (max-width:  600px) { .lanes { grid-template-columns: 1fr; } }

.lane {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.lane-name {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.lane-checks { display: flex; flex-direction: column; gap: 6px; }
.check {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text-muted);
  transition: color .25s ease, border-color .25s ease, background .25s ease;
}
.check .icon { width: 14px; text-align: center; }
.check.in-progress { color: var(--teal); border-color: rgba(45,212,191,.4); }
.check.ok          { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.06); }
.check.fail        { color: var(--red);   border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.06); }
.check.warn        { color: var(--yellow);border-color: rgba(250,204,21,.4); background: rgba(250,204,21,.06); }

/* ----- log ----- */
.log {
  margin-top: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono); font-size: 12.5px;
  max-height: 220px; overflow: auto;
}
.log-line { padding: 2px 0; }
.log-line.ok { color: var(--green); }
.log-line.warn { color: var(--yellow); }
.log-line.err { color: var(--red); }
.log-line.tag {
  display: inline-block; min-width: 80px;
  color: var(--gold); font-weight: 600;
}

/* ----- receipts ----- */
.receipts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
@media (max-width: 880px) { .receipts-grid { grid-template-columns: 1fr; } }

.receipt-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.receipt-card h3 {
  font-size: 14px;
  margin: 0 0 12px;
  font-family: var(--mono);
  display: flex; align-items: center; gap: 10px;
}
.receipt-card .blocked-msg {
  color: var(--red);
  font-size: 13px;
  font-family: var(--mono);
  background: rgba(248,113,113,.06);
  border: 1px solid rgba(248,113,113,.3);
  padding: 12px;
  border-radius: 8px;
}
.kv { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.kv > span { width: 110px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .12em; padding-top: 2px; flex-shrink: 0; }
.kv code { flex: 1; font-family: var(--mono); word-break: break-all; color: var(--text); font-size: 11.5px; }
.kv code.ok { color: var(--green); }
.kv code.bad { color: var(--red); }

.receipt-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.receipt-actions .btn { padding: 7px 12px; font-size: 12px; }

.raw { margin-top: 14px; }
.raw summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.raw summary:hover { color: var(--gold); }
.raw pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono); font-size: 11px;
  overflow: auto; max-height: 240px;
  margin-top: 8px;
}

/* ----- custom-mode (collapsed by default) ----- */
.custom-mode {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin: 24px 0;
}
.custom-mode summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.custom-mode summary:hover { color: var(--gold); }
.custom-mode form { margin-top: 18px; }

footer {
  display: flex; justify-content: space-between;
  color: var(--text-muted); font-size: 12px;
  margin: 36px 0 0;
  padding-top: 24px; border-top: 1px solid var(--line);
}

/* ============================================================
   MISSION LAB  — interactive scenario picker + flow graph
   ============================================================ */

.lab-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  margin: 24px 0;
}
@media (max-width: 980px) { .lab-grid { grid-template-columns: 1fr; } }

.lab-aside {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky; top: 80px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.lab-aside .subhead { margin: 0 0 4px; }

.lab-main { display: flex; flex-direction: column; gap: 18px; }
.lab-card { margin: 0; }

.scenario-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 16px; }
.scenario-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s ease, background .15s ease, transform .05s;
}
.scenario-btn:hover { border-color: var(--gold); background: var(--bg-2); }
.scenario-btn:active { transform: translateY(1px); }
.scenario-btn.selected { border-color: var(--gold); background: rgba(212,168,67,.06); }
.scenario-num {
  font-family: var(--mono); font-size: 11px;
  color: var(--gold); text-align: center;
  background: rgba(212,168,67,.08);
  border-radius: 6px;
  padding: 4px 0;
  letter-spacing: .04em;
}
.scenario-text { display: flex; flex-direction: column; gap: 2px; }
.scenario-title { font-size: 13px; font-weight: 600; }
.scenario-summary { font-size: 11.5px; color: var(--text-muted); }
.scenario-expected {
  font-size: 9.5px !important;
  letter-spacing: .08em;
  padding: 2px 6px !important;
}

.aside-footer { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.btn.full { width: 100%; justify-content: center; margin-bottom: 8px; }
.btn.small-btn { padding: 6px 10px; font-size: 12px; }

/* ----- advanced links sidebar ----- */
.aside-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.aside-links li { margin: 0; }
.aside-links a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-3);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: border-color 120ms ease, background 120ms ease;
}
.aside-links a:hover {
  border-color: var(--gold);
  background: rgba(212, 168, 67, 0.06);
}
.aside-links a code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(45, 212, 191, 0.10);
  color: var(--teal);
  padding: 0 4px;
  border-radius: 3px;
}

/* ----- flow graph ----- */
.flow-graph {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
}
.flow-step {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-muted);
  transition: color .25s, border-color .25s, background .25s;
}
.flow-step .step-bullet {
  text-align: center;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 0;
  font-size: 11px;
  color: var(--text-muted);
}
.flow-step .step-icon {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}
.flow-step.running  { color: var(--teal);   border-color: rgba(45,212,191,.5);  background: rgba(45,212,191,.06); }
.flow-step.ok       { color: var(--green);  border-color: rgba(74,222,128,.4);  background: rgba(74,222,128,.06); }
.flow-step.fail     { color: var(--red);    border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.06); }
.flow-step.warn     { color: var(--yellow); border-color: rgba(250,204,21,.4);  background: rgba(250,204,21,.06); }
.flow-step.skipped  { opacity: .35; }

/* ----- decision panel ----- */
.decision-panel {
  font-size: 13px;
  line-height: 1.55;
}
.why-verdict {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .04em;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.why-verdict.ok  { color: var(--green); border-color: rgba(74,222,128,.4); }
.why-verdict.bad { color: var(--red);   border-color: rgba(248,113,113,.4); }
.why-list { margin: 0; padding-left: 18px; color: var(--text-muted); }
.why-list li { padding: 3px 0; }
.why-list li::marker { color: var(--gold); }

/* ----- receipt body ----- */
.receipt-body { font-size: 13px; }
.receipt-body .kv { padding: 5px 0; }
.receipt-body .kv > span { width: 130px; font-size: 11px; }
.receipt-body .kv code { font-size: 11.5px; }
.receipt-body .kv code.ok { color: var(--green); }
.receipt-body .kv code.bad { color: var(--red); }

/* ============================================================
   CHECKPOINT MODAL
   ============================================================ */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(6px);
}
.modal-panel {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 28px 32px;
  width: min(640px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(212,168,67,.1);
}
.modal-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.modal-header h3 { font-size: 18px; margin: 0; flex: 1; }
.modal-body { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.modal-kv { display: flex; gap: 12px; padding: 4px 0; font-size: 13px; }
.modal-kv > span { width: 110px; color: var(--text-muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; padding-top: 2px; }
.modal-kv code { flex: 1; font-family: var(--mono); color: var(--text); font-size: 12px; word-break: break-all; }
.modal-warn {
  font-size: 12.5px;
  color: var(--yellow);
  background: rgba(250,204,21,.08);
  border: 1px solid rgba(250,204,21,.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.modal-warn strong { color: var(--gold); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn-danger { color: var(--red); border-color: rgba(248,113,113,.4); }
.btn-danger:hover { color: #fff; background: var(--red); border-color: var(--red); }

/* hide [hidden] explicitly — some browsers ignore it on flex */
[hidden] { display: none !important; }
