:root {
  --bg: #0b0f1e;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #e8ebf7;
  --muted: #9aa3c0;
  --cyan: #22d3ee;
  --indigo: #6366f1;
  --magenta: #f472b6;
  --purple: #a855f7;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  z-index: 0;
  animation: float 14s ease-in-out infinite alternate;
}
.bg-glow-1 {
  width: 480px; height: 480px;
  background: var(--indigo);
  top: -150px; left: -100px;
}
.bg-glow-2 {
  width: 420px; height: 420px;
  background: var(--magenta);
  bottom: -150px; right: -80px;
  animation-delay: 3s;
}
@keyframes float {
  from { transform: translate(0, 0); }
  to { transform: translate(40px, 30px); }
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 22px;
  color: var(--cyan);
  text-shadow: 0 0 16px var(--cyan);
}
h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: 0.2px; }
.accent { color: var(--muted); font-weight: 400; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
code {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.bad { background: var(--red); box-shadow: 0 0 8px var(--red); }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 22px;
  backdrop-filter: blur(16px);
  margin-bottom: 22px;
}

.input-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
textarea {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--indigo); }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.example-chip {
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.35);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.example-chip:hover { background: rgba(99,102,241,0.25); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--indigo));
  border: none;
  color: #0b0f1e;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(11,15,30,0.3);
  border-top-color: #0b0f1e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  color: var(--red);
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.workflow {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.arrow {
  text-align: center;
  color: var(--muted);
  font-size: 20px;
  margin: 2px 0;
  opacity: 0.6;
}

.stage { margin-bottom: 4px; }
.bot-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.stage.active .bot-card {
  border-color: var(--cyan);
  box-shadow: 0 0 24px rgba(34,211,238,0.15);
}
.stage.done .bot-card {
  border-color: var(--green);
}
.stage.error .bot-card {
  border-color: var(--red);
}

.bot-avatar {
  flex: none;
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
}
.bot-cyan { box-shadow: inset 0 0 0 1px rgba(34,211,238,0.3); }
.bot-magenta { box-shadow: inset 0 0 0 1px rgba(244,114,182,0.3); }

.bot-meta { flex: 1; min-width: 0; }
.bot-meta h3 { margin: 0 0 2px; font-size: 15px; }
.bot-meta p { margin: 0; font-size: 12.5px; color: var(--muted); }

.stage-status {
  flex: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: 999px;
}
.stage.active .stage-status { color: var(--cyan); background: rgba(34,211,238,0.12); }
.stage.done .stage-status { color: var(--green); background: rgba(52,211,153,0.12); }
.stage.error .stage-status { color: var(--red); background: rgba(248,113,113,0.12); }

.stage-output {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-q-item, .qa-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  animation: reveal 0.35s ease;
}
.qa-item .q { color: var(--cyan); font-weight: 600; margin-bottom: 4px; }
.qa-item .a { color: var(--text); line-height: 1.5; }

.final-output {
  background: linear-gradient(135deg, rgba(34,211,238,0.08), rgba(168,85,247,0.08));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.final-card { padding: 16px 18px; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.how-it-works h2 { margin-top: 0; font-size: 16px; }
.arch-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0 18px;
}
.arch-node {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12.5px;
}
.arch-node.highlight {
  border-color: var(--cyan);
  color: var(--cyan);
}
.arch-arrow { color: var(--muted); font-size: 14px; }

.facts {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

@media (max-width: 560px) {
  .bot-card { flex-wrap: wrap; }
  .stage-status { order: 3; }
}

/* ---------- AI Evaluation Center ---------- */
.tabs { display: flex; gap: 6px; margin-left: auto; margin-right: 16px; }
.tab { background: transparent; color: var(--muted); border: 1px solid var(--panel-border); border-radius: 999px; padding: 8px 16px; cursor: pointer; font: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel); border-color: var(--cyan); }
.muted { color: var(--muted); }
.trace-ref { margin-top: 12px; font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }

#evalView { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --grid: rgba(255,255,255,0.08); }
#evalView h2 { margin: 0 0 12px; font-size: 18px; }
#evalView h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#evalView .card { margin-bottom: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; }
.inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.inline-form label, .filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#evalView input, #evalView select { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 130px; }
#evalView select option { background: #151a2b; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filter-actions { display: flex; gap: 8px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }
.btn-ghost:hover:not(:disabled) { border-color: var(--cyan); }
.btn-ghost:disabled { opacity: .4; cursor: default; }

.hero { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.hero-score { font-size: 56px; font-weight: 700; line-height: 1; }
.hero-label { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px 14px; background: rgba(255,255,255,0.03); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 4px; }
.tile .n { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.pass { color: var(--green); } .badge.fail { color: var(--red); } .badge.warn { color: var(--amber); } .badge.na { color: var(--muted); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.chart { border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px 14px; position: relative; }
.chart h4 { margin: 0 0 2px; font-size: 14px; }
.chart .sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.chart .empty { padding: 36px 0; text-align: center; color: var(--muted); font-size: 13px; }
.tooltip { position: absolute; pointer-events: none; background: #0b0f1e; border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; font-size: 12px; z-index: 5; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.tooltip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: top; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td, table.data tr.click:focus td { background: rgba(255,255,255,0.05); }
.scroll-x { overflow-x: auto; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
.flow .step { border: 1px solid var(--panel-border); border-radius: 10px; padding: 8px 12px; background: rgba(255,255,255,0.04); font-size: 13px; }
.flow .step.bad { border-color: var(--red); }
.flow .sep { color: var(--muted); }
.block { white-space: pre-wrap; background: rgba(0,0,0,0.25); border: 1px solid var(--panel-border); border-radius: 10px; padding: 12px; font-size: 13px; max-height: 320px; overflow: auto; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 10px 0; }
.reason { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 520px; }
.warnline { color: var(--amber); margin: 4px 0; }
@media (max-width: 640px) { .tabs { margin: 0; } .hero-score { font-size: 42px; } }

/* Access password (shown only when the server sets AGENT_ACCESS_TOKEN) */
.access-row { margin-top: 14px; max-width: 360px; }
.access-row input {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.access-row input:focus { outline: 2px solid var(--indigo); }
