/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; }

:root {
  --ink: #1e2430;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --ok: #067647;
  --ok-bg: #dcfae6;
  --no: #b42318;
  --no-bg: #fee4e2;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

body {
  min-height: 100vh;
  background: #f6f7fb;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top, .page { max-width: 1120px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top { padding-top: 28px; padding-bottom: 8px; }
.top h1 { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.5px; }
.top p { color: var(--muted); margin-top: 6px; }
.page { display: grid; gap: 16px; padding-top: 16px; padding-bottom: 32px; }

.panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel h2 { font-size: 18px; }

.chip-btn {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: 13px system-ui, sans-serif;
  cursor: pointer;
}
.chip-btn:hover { border-color: #a5b4fc; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.scenarios, .modes { display: flex; flex-wrap: wrap; gap: 6px; }
/* ---------- END BASE ---------- */

/* ---------- STEPPER ---------- */
.stepper-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 190px;
  gap: 12px;
  align-items: stretch;
}
.code-box { padding: 12px 0; border-radius: 12px; background: #111827; overflow-x: auto; }
.code-lines { list-style: none; padding: 0; counter-reset: ln; font: 13.5px/1.75 var(--mono); color: #d1d5db; }
.code-lines li { counter-increment: ln; padding: 0 14px 0 0; white-space: pre; }
.code-lines li::before { content: counter(ln); display: inline-block; width: 32px; margin-right: 8px; text-align: right; color: #4b5563; }
.code-lines li.now { background: rgba(250, 204, 21, .16); color: #fff; box-shadow: inset 3px 0 0 #facc15; }

.machine { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.box { min-width: 0; min-height: 124px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fcfcfd; }
.box h3 { margin-bottom: 8px; font-size: 12.5px; }
.box h3 small { display: block; color: var(--muted); font-weight: 400; }
.box ul { display: flex; flex-direction: column; gap: 5px; padding: 0; list-style: none; }
.box li { padding: 5px 7px; border-radius: 6px; font: 12px/1.35 var(--mono); overflow-wrap: anywhere; animation: pop .22s ease both; }

.stack { flex-direction: column-reverse !important; } /* newest call on top */
.stack li { background: #eef2ff; color: #3730a3; }
.web li { background: #f2f4f7; color: #344054; }
.micro { border-color: #a7f3d0; }
.micro-q li { background: var(--ok-bg); color: var(--ok); }
.tasks { border-color: #fde68a; }
.task-q li { background: #fef3c7; color: #92400e; }
.console { background: #111827; border-color: #111827; color: #d1d5db; }
.console h3 { color: #9ca3af; }
.log li { padding: 2px 0; color: #e5e7eb; font-size: 13px; }
.log li::before { content: "> "; color: #6b7280; }

.note { min-height: 66px; margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #eef2ff; color: #3730a3; font-size: 14.5px; line-height: 1.5; }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.btn {
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: 700 14px system-ui, sans-serif;
  cursor: pointer;
}
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.counter { margin-left: auto; color: var(--muted); font-size: 13px; }
.btn:focus-visible, .chip-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* ---------- END STEPPER ---------- */

/* ---------- RACE ---------- */
.fail { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.fail input { accent-color: var(--no); }
.race-intro { margin: -6px 0 12px; color: var(--muted); font-size: 14.5px; }
.race-code { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #111827; color: #e5e7eb; font: 13px/1.6 var(--mono); overflow-x: auto; }

.timeline { margin-top: 16px; }
.ticks { display: flex; justify-content: space-between; margin-left: 84px; color: var(--muted); font: 12px var(--mono); }
.track { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 8px; }
.track > span { font-size: 13px; font-weight: 600; }
.lane {
  position: relative;
  height: 28px;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, #f2f4f7 0 calc(25% - 1px), #e4e7ec calc(25% - 1px) 25%);
  overflow: hidden;
}
.bar { position: absolute; top: 0; bottom: 0; width: 0; border-radius: 6px; background: #a5b4fc; }
.bar.done { background: #34d399; }
.bar.failed { background: #f87171; }

.outcome { min-height: 46px; margin-top: 14px; font-size: 14.5px; line-height: 1.5; }
.outcome strong { font-family: var(--mono); }
/* ---------- END RACE ---------- */

/* ---------- KEYFRAMES ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  .box li { animation: none; }
  .bar { transition: none !important; }
}
/* ---------- END KEYFRAMES ---------- */

/* ---------- SMALL SCREENS ---------- */
@media (max-width: 960px) {
  .stepper-grid { grid-template-columns: minmax(0, 1fr); }
  .box { min-height: 92px; }
  .note { min-height: 96px; }
}
/* ---------- END SMALL SCREENS ---------- */
