/* Minimal Material-style theme. */
:root {
  --text: #202124;
  --text-2: #5f6368;
  --line: #dadce0;
  --line-2: #f1f3f4;
  --surface: #ffffff;
  --hover: #f8f9fa;
  --primary: #1a73e8;
  --primary-hover: #1b66c9;
  --primary-tint: #e8f0fe;
  --green: #137333;  --green-bg: #e6f4ea;
  --amber: #b06000;  --amber-bg: #fef7e0;
  --red: #c5221f;    --red-bg: #fce8e6;
  --blue: #1967d2;   --blue-bg: #e8f0fe;
  --sans: Roboto, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--text); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 18px; font-weight: 500; }
code { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* ---- top bar ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line-2); }
.brand { font-size: 20px; color: var(--text-2); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.badge.live { border-color: transparent; background: var(--green-bg); color: var(--green); }
.badge.sim { border-color: transparent; background: var(--amber-bg); color: var(--amber); }

main { max-width: 1040px; margin: 0 auto; padding: 0 24px 48px; }

/* ---- hero + gate ---- */
.hero { text-align: center; padding: 72px 0 48px; }
.hero h1 { font-size: 48px; font-weight: 400; letter-spacing: -0.5px; }
.lede { margin-top: 8px; font-size: 18px; color: var(--text-2); }
.hint { margin-top: 20px; color: var(--text-2); }

.gate { display: inline-flex; margin-top: 32px; border: 1px solid var(--line); border-radius: 12px; }
.gate-check { display: flex; align-items: center; gap: 16px; min-width: 300px; padding: 20px 28px; background: none; border: 0; border-radius: 12px; font: inherit; color: inherit; cursor: pointer; }
.gate-check:hover { background: var(--hover); }
.gate-check:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.gate-check .box { width: 22px; height: 22px; flex: none; border: 2px solid var(--text-2); border-radius: 4px; background: var(--surface); }
.gate-check:hover .box { border-color: var(--text); }
.gate-check.checking .box { border-color: var(--line-2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.gate-label { font-size: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- cards, buttons, fields ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 24px; border: 1px solid transparent; border-radius: 20px; background: var(--primary); color: #fff; font: 500 14px var(--sans); letter-spacing: 0.25px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15); }
.btn:disabled { opacity: 0.5; cursor: progress; box-shadow: none; }
.btn-outline { background: var(--surface); color: var(--primary); border-color: var(--line); }
.btn-outline:hover { background: var(--primary-tint); box-shadow: none; }

.field-row { display: flex; gap: 12px; }
.field-row input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; font: 400 15px var(--mono); color: var(--text); background: var(--surface); }
.field-row input:hover { border-color: var(--text-2); }
.field-row input:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* ---- challenge ---- */
.challenge { margin-bottom: 24px; }
.timer { --p: 1; }
.progress { height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.progress-fill { height: 100%; width: calc(var(--p) * 100%); background: var(--primary); }
.timer.danger .progress-fill { background: var(--red); }
.timer-label { display: block; margin-top: 8px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.timer.danger .timer-label { color: var(--red); }
.question { margin: 16px 0; font-size: 18px; }
.challenge .field-row { margin-bottom: 16px; }

.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: 12px; font-weight: 500; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.rows td { white-space: nowrap; }
.rows td:first-child { font-family: var(--mono); font-size: 13px; }
.rows td:last-child { color: var(--text-2); white-space: normal; }

/* ---- verdict ---- */
.verdict { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.verdict h3 { font-size: 22px; font-weight: 400; margin-bottom: 4px; }
.verdict.v-pass h3 { color: var(--green); }
.verdict.v-hijack h3 { color: var(--amber); }
.verdict.v-wrong h3 { color: var(--red); }
.verdict.v-slow h3 { color: var(--blue); }
.verdict .reveal { margin-top: 12px; display: grid; gap: 4px; color: var(--text-2); }

/* ---- sections ---- */
.section { padding-top: 40px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head .muted { margin-top: 2px; }

.contestants { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.contestant { display: grid; gap: 12px; align-content: start; }
.contestant h3 { font-size: 16px; font-weight: 500; }
.contestant .btn { width: 100%; }
.tag { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px; background: var(--line-2); font: 400 12px var(--mono); color: var(--text-2); }
.result { display: grid; gap: 6px; min-height: 96px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.result .status { font-weight: 500; }
.result .answer { font: 400 13px var(--mono); word-break: break-word; }
.result .why { color: var(--text-2); }
.result .flag { color: var(--green); font-weight: 500; }
.result .trapquote { padding: 8px 12px; border-left: 3px solid #f9ab00; background: var(--hover); color: var(--text-2); font-size: 13px; }
mark { background: var(--amber-bg); color: var(--amber); font-weight: 500; padding: 0 2px; border-radius: 3px; }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.vbadge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.vbadge.v-pass { color: var(--green); background: var(--green-bg); }
.vbadge.v-hijack { color: var(--amber); background: var(--amber-bg); }
.vbadge.v-wrong { color: var(--red); background: var(--red-bg); }
.vbadge.v-slow { color: var(--blue); background: var(--blue-bg); }
.vbadge.v-error { color: var(--text-2); background: var(--line-2); }

/* ---- trace + log ---- */
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
.trace { display: grid; gap: 4px; }
.span-row { display: grid; grid-template-columns: minmax(150px, 40%) 1fr 56px; gap: 12px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.span-row:hover, .span-row.selected { background: var(--hover); }
.span-name { font: 400 12px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.span-track { position: relative; height: 8px; border-radius: 4px; background: var(--line-2); }
.span-bar { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 4px; background: var(--primary); }
.span-bar.tool { background: #9aa0a6; }
.span-bar.chat { background: #8430ce; }
.span-bar.err { background: var(--red); }
.span-ms { font: 400 12px var(--mono); color: var(--text-2); text-align: right; }
.span-detail { margin: 12px 0 0; padding: 12px; max-height: 220px; overflow: auto; border-radius: 8px; background: var(--hover); font: 400 12px/1.5 var(--mono); white-space: pre-wrap; }

.log-wrap { padding: 0; max-height: 320px; overflow: auto; }
.log td:first-child, .log td:last-child { font: 400 12px var(--mono); color: var(--text-2); white-space: nowrap; }
.log .who small { display: block; font: 400 11px var(--mono); color: var(--text-2); }
.log tr.fresh { animation: fresh 1.2s ease; }
@keyframes fresh { from { background: var(--primary-tint); } to { background: transparent; } }

/* ---- lane ---- */
#lane .field-row { max-width: 640px; }
.lane-result { margin-top: 12px; font-weight: 500; }
.lane-result.ok { color: var(--green); }
.lane-result.no { color: var(--red); }

.foot { padding: 24px; border-top: 1px solid var(--line-2); text-align: center; font-size: 12px; color: var(--text-2); }

@media (max-width: 900px) {
  .contestants, .two-col { grid-template-columns: 1fr; }
  .hero { padding-top: 48px; }
  .hero h1 { font-size: 36px; }
  .verdict { flex-direction: column; }
}
