:root {
  --ink: #10282b; --muted: #4d6366; --line: #d9e5e3; --page: #f1f7f6;
  --hero: #07393c; --hero-end: #0d5c5a; --on-hero: #cfe6e3; --hero-accent: #fbbf24;
  --primary: #0f766e; --primary-tint: #dff3f0;
  --cta: #f59e0b; --cta-hover: #e08e06; --on-cta: #231503;
  --code-bg: #1e1e1e; --code-line: #3c3c3c; --code-ink: #d4d4d4; --code-note: #cccccc; --bar-bg: #252526; --output-bg: #181818;
  --error: #b3261e; --ok: #15803d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--page); color: var(--ink); line-height: 1.55;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { padding: 0 20px; }
h1, h2 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid #5eb8ae; outline-offset: 2px; }

.btn { display: inline-block; font: inherit; font-weight: 600; background: var(--cta); color: var(--on-cta); border: 0;
  border-radius: 6px; padding: 11px 20px; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--cta-hover); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid #a9bcba; }
.btn.secondary:hover { background: var(--primary-tint); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.topbar { background: linear-gradient(120deg, var(--hero), var(--hero-end)); color: #fff; padding: 10px 0; flex: none; }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 20px; }
h1 { font-size: 1.1rem; font-weight: 700; }
.topbar a { color: var(--on-hero); font-size: .86rem; }

#quiz { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.progress { background: #fff; border-bottom: 1px solid var(--line); padding: 7px 0; flex: none; }
.progress .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
#position { font-weight: 600; font-size: .93rem; }
.steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.steps button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid #a9bcba; background: #fff; color: var(--muted);
  font: 600 .85rem Inter, system-ui, sans-serif; cursor: pointer; }
.steps button[aria-current="step"] { border: 2px solid var(--primary); color: var(--primary); }
.steps button.solved { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps button.solved[aria-current="step"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); }
.steps button[disabled] { cursor: not-allowed; }

/* --split is the question panel's share of the screen. The divider updates it. */
.workspace { --split: 50%; flex: 1; min-height: 0; display: grid;
  grid-template-columns: calc(var(--split) - 6px) 12px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.panel { background: #fff; padding: 20px; overflow: auto; min-width: 0; min-height: 0; }
.divider { background: var(--line); cursor: col-resize; touch-action: none; display: flex; align-items: center; justify-content: center; }
.divider::after { content: ""; width: 4px; height: 44px; border-radius: 2px; background: #8fa5a2; }
.divider:hover, .divider.dragging { background: #b7d3cf; }
body.resizing { user-select: none; -webkit-user-select: none; }
.topic { color: var(--primary); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 4px; }
.panel h2 { font-size: 1.3rem; }
#task { margin: 10px 0 14px; }
.label { font-size: .85rem; font-weight: 600; margin: 0 0 4px; }
.expected { margin: 0 0 14px; padding: 10px 12px; background: var(--page); border: 1px solid var(--line); border-radius: 6px;
  font: .9rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
details { border-top: 1px solid var(--line); padding: 10px 0 0; margin-top: 10px; font-size: .92rem; }
summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details p { margin: 8px 0 0; color: var(--muted); }
details pre { margin: 8px 0 0; padding: 10px 12px; background: var(--page); border-radius: 6px; font: .88rem/1.5 var(--mono); overflow: auto; }

.lab { background: var(--code-bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.lab textarea { display: block; flex: 1; min-height: 0; width: 100%; resize: none; overflow: auto; border: 0; padding: 16px; background: transparent;
  color: var(--code-ink); font: .95rem/1.5 var(--mono); tab-size: 4; }
.lab-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--code-line); color: var(--code-note); font-size: .85rem; flex: none; }
.lab-bar .btn { padding: 8px 16px; font-size: .92rem; }
.lab > pre { margin: 0; padding: 12px 16px; flex: 0 0 35%; min-height: 0; overflow: auto; background: var(--output-bg); color: #ffffff;
  font: .9rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.lab .CodeMirror { flex: 1 1 0; height: 0; min-height: 0; }
.lab > pre.failed { color: #f48771; }
#verdict { font-weight: 600; font-size: .88rem; }
#verdict.right { color: #86efac; }
#verdict.wrong { color: #ffb4ab; }

.pager { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; padding-bottom: 8px; flex: none; background: #fff; border-top: 1px solid var(--line); }
.pager .btn { padding: 8px 20px; }

#results { flex: 1; min-height: 0; overflow: auto; padding: 40px 20px 56px; }
.results-card { max-width: 560px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.results-card h2 { font-size: 1.6rem; }
.results-card > p { color: var(--muted); margin: 8px 0 18px; }
#summary { list-style: none; margin: 0 0 22px; padding: 0; }
#summary li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .95rem; }
#summary .yes { color: var(--ok); font-weight: 600; white-space: nowrap; }
#summary .no { color: var(--muted); white-space: nowrap; }
.results-actions { display: flex; flex-wrap: wrap; gap: 10px; }

[hidden] { display: none !important; }

/* Two columns would be too narrow to read or type on a phone, so the panels stack. */
@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: calc(var(--split) - 7px) 14px minmax(0, 1fr); }
  .divider { cursor: row-resize; }
  .divider::after { width: 44px; height: 4px; }
  .panel { padding: 14px 20px; }
  .lab > pre { flex-basis: 26%; padding: 8px 16px; }
  .lab-bar { padding: 6px 16px; }
  .terminal-title { padding: 3px 16px; }
}
/* On very short screens, such as a phone held sideways, let the page scroll instead. */
@media (max-height: 480px) {
  body { height: auto; overflow: auto; }
  .workspace { flex: none; height: 640px; }
}
.lab-bar { background: var(--bar-bg); }
.terminal-title { flex: none; padding: 6px 16px; background: var(--output-bg); border-top: 1px solid var(--code-line);
  color: #cccccc; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
