:root {
  --bg: #F3F1EB;
  --card: rgba(255, 255, 255, 0.82);
  --ink: #18202A;
  --muted: #556474;
  --accent: #2859C5;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6EDFF;
  --border: rgba(24, 32, 42, 0.13);
  --code-bg: #F5F7FC;
  --err: #B3372F;
  --err-soft: #F9ECEA;
  --ok: #1E7A3C;
  --shadow: 0 14px 42px rgba(30, 38, 52, 0.09);
  --code-bar: #E8ECF4;
  --tok-k: #CF222E;
  --tok-s: #0A3069;
  --tok-n: #0550AE;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E141B;
    --card: rgba(23, 31, 41, 0.88);
    --ink: #EDF3F8;
    --muted: #98A7B6;
    --accent: #80A7FF;
    --accent-ink: #091327;
    --accent-soft: #1A2B52;
    --border: rgba(237, 243, 248, 0.14);
    --code-bg: #0A1119;
    --err: #E5716A;
    --err-soft: #35211F;
    --ok: #5FC97E;
    --shadow: 0 18px 52px rgba(0, 0, 0, 0.3);
    --code-bar: #182230;
    --tok-k: #FF7B72;
    --tok-s: #A5D6FF;
    --tok-n: #79C0FF;
  }
}
:root[data-theme="dark"] {
  --bg: #0E141B;
  --card: rgba(23, 31, 41, 0.88);
  --ink: #EDF3F8;
  --muted: #98A7B6;
  --accent: #80A7FF;
  --accent-ink: #091327;
  --accent-soft: #1A2B52;
  --border: rgba(237, 243, 248, 0.14);
  --code-bg: #0A1119;
  --err: #E5716A;
  --err-soft: #35211F;
  --ok: #5FC97E;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.3);
  --code-bar: #182230;
  --tok-k: #FF7B72;
  --tok-s: #A5D6FF;
  --tok-n: #79C0FF;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 34%),
    radial-gradient(circle at 88% 92%, rgba(243, 200, 75, 0.14), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
code, pre, .mono { font-family: "SFMono-Regular", Consolas, Menlo, monospace; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.brand { font-weight: 700; font-size: 1.02rem; letter-spacing: 0.01em; }
.brand .prompt { color: #D19C00; font-family: "SFMono-Regular", Consolas, monospace; margin-right: 6px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.progress-label { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.theme-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }

.progress-track {
  height: 3px;
  background: var(--border);
  max-width: 720px;
  width: calc(100% - 40px);
  margin: 0 auto;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 38px 20px 70px;
}
.screen { animation: rise 0.28s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .progress-fill { transition: none; }
}

h1 { font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.08; margin: 0 0 13px; text-wrap: balance; letter-spacing: -0.045em; }
h2 { font-size: 1.3rem; margin: 0 0 8px; text-wrap: balance; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 56ch; }
.part-tag {
  display: inline-block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.q-text { font-size: 1.22rem; font-weight: 600; line-height: 1.4; margin: 0 0 18px; text-wrap: balance; }
code.inline {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.92em;
}
.q-note { color: var(--muted); font-size: 0.92rem; margin: -8px 0 18px; }

.codewin {
  border: 1px solid var(--border);
  border-radius: 15px;
  overflow: hidden;
  margin: 0 0 20px;
  box-shadow: var(--shadow);
}
.codewin-bar {
  display: flex;
  gap: 6px;
  padding: 9px 13px;
  background: var(--code-bar);
  border-bottom: 1px solid var(--border);
}
.codewin-bar span { width: 11px; height: 11px; border-radius: 50%; }
.codewin-bar span:nth-child(1) { background: #E8695A; }
.codewin-bar span:nth-child(2) { background: #F0B429; }
.codewin-bar span:nth-child(3) { background: #57BB63; }
pre.code {
  background: var(--code-bg);
  padding: 14px 18px;
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
}
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-s { color: var(--tok-s); }
.tok-n { color: var(--tok-n); }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 17px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s, transform 0.12s;
}
.option:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(25, 32, 39, 0.06), 0 6px 18px rgba(25, 32, 39, 0.07);
}
.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
@media (prefers-reduced-motion: reduce) {
  .option, .option:hover { transition: none; transform: none; }
}
.option .key {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.option.selected .key { color: var(--accent); border-color: var(--accent); }

textarea, input[type="text"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
textarea { min-height: 130px; resize: vertical; }
textarea.codearea { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.95rem; }
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

.nav-row {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  align-items: center;
}
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 26px;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(25, 32, 39, 0.15);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn.ghost { background: none; border-color: var(--border); color: var(--muted); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.hint { color: var(--muted); font-size: 0.85rem; }

.error-msg {
  background: var(--err-soft);
  color: var(--err);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 500;
  margin-top: 14px;
}

.svg-wrap { margin: 0 0 20px; }
.svg-wrap svg { max-width: 100%; height: auto; display: block; }
.robot-grid-line { stroke: var(--border); }
.robot-cell-label { fill: var(--ink); font-family: Inter, "Segoe UI", sans-serif; font-weight: 600; font-size: 20px; }
.robot-start { fill: var(--accent); }
.robot-start-label { fill: var(--muted); font-size: 12px; font-family: Inter, "Segoe UI", sans-serif; }

.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 22px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.task-card .lvl { color: var(--accent); font-weight: 700; }
.task-card p { margin: 8px 0; }

.status { margin-top: 20px; font-weight: 500; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

@media (max-width: 620px) {
  main { padding-top: 26px; }
  .nav-row { flex-wrap: wrap; }
  .nav-row .btn { flex: 1 1 145px; min-width: 0; padding: 11px 13px; }
  .nav-row .hint { flex-basis: 100%; }
}
