:root {
  --ink: #241b4d;
  --muted: #625b86;
  --soft: #8d87a8;
  --line: #ebe7f5;
  --bg: #f6f4fc;
  --card: #ffffff;
  --orange: #f26b3a;
  --orange-2: #ff9a5c;
  --violet: #7c5ce0;
  --green: #1f9d68;
  --red: #c2410c;
  --r: 22px;
  /* one inset for everything inside the cards (question, headings, editor, buttons, classroom,
     feedback), so their left and right edges line up */
  --inset: 24px;
  /* the page's own side margin */
  --page: clamp(12px, 1.6vw, 24px);
  --shadow: 0 1px 2px rgba(36, 27, 77, 0.04), 0 14px 36px -22px rgba(36, 27, 77, 0.28);
  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(201, 187, 255, 0.35), transparent 70%),
    radial-gradient(ellipse 40% 35% at 0% 100%, rgba(255, 211, 184, 0.35), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
p,
ol,
ul {
  margin: 0;
}
button {
  font: inherit;
}

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  padding: 14px var(--page);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
}
.logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  color: #fff;
  font: 700 13px var(--mono);
}

.wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 1840px;
  margin: 0 auto;
  padding: 0 var(--page) 24px;
}
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---------- A: the question (kept compact) ---------- */
.task {
  display: grid;
  gap: 14px;
  padding: 20px var(--inset);
  /* a thin orange-to-lavender outline, and inside a faint warm wash at the top left fading to
     lavender at the bottom right */
  border: 1.5px solid transparent;
  background:
    radial-gradient(120% 90% at 0% 0%, #fff4ec 0%, rgba(255, 244, 236, 0) 55%) padding-box,
    radial-gradient(110% 90% at 100% 100%, #f4f0ff 0%, rgba(244, 240, 255, 0) 60%) padding-box,
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(120deg, #ffc4a2 0%, #ffe0cc 30%, #e2d8fc 65%, #c9bbf7 100%) border-box;
  box-shadow: 0 1px 2px rgba(36, 27, 77, 0.04), 0 16px 40px -24px rgba(124, 92, 224, 0.32);
}
.task-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
}
.task h1 {
  margin-top: 2px;
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chip-list {
  display: contents;
  list-style: none;
  padding: 0;
}
.chip,
.chip-list li {
  padding: 4px 12px;
  border-radius: 999px;
  background: #f3f0fb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.chip.level {
  background: #e8f7ef;
  color: #157a45;
}
.progress {
  display: grid;
  justify-items: end;
  gap: 2px;
}
.progress[hidden] {
  display: none;
}
.progress-k {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
}
.stars {
  display: flex;
  gap: 4px;
  font-size: 24px;
  line-height: 1;
}
.stars span {
  color: #e3dff0;
}
.stars span.on {
  color: #ffc233;
  text-shadow: 0 2px 8px rgba(255, 194, 51, 0.45);
}
.task-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px 32px;
}
.story {
  font-size: 16px;
  color: var(--ink);
}
.data-k {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
}
.data {
  margin-top: 14px;
}
/* the marks the student types in */
.marks {
  width: 100%;
  max-width: 460px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
}
.marks th,
.marks td {
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.marks thead th {
  background: #f6f3fd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.marks tbody th {
  font-weight: 700;
}
.marks td {
  font: 600 15px var(--mono);
  color: var(--ink);
}
.marks tbody tr:last-child > * {
  border-bottom: 0;
}
/* the variable names, as small code chips in three groups */
.vars {
  display: grid;
  gap: 8px;
}
.var-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}
.var-k {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.var-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.var-chip {
  position: relative;
  padding: 3px 9px;
  border-radius: 8px;
  background: #f4f1fc;
  border: 1px solid #e8e3f7;
  font: 500 13px var(--mono);
  color: #4a3aa6;
  cursor: copy;
  transition: transform 0.2s var(--ease, ease), background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
/* hover: the chip lifts a little and deepens */
.var-chip:hover {
  transform: translateY(-2px);
  background: #ece6fd;
  border-color: #cfc3f5;
  box-shadow: 0 6px 14px -8px rgba(74, 58, 166, 0.55);
}
.var-chip:active {
  transform: translateY(0);
}
.var-chip:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}
.var-chip.copied {
  background: #e9f9f0;
  border-color: #a9e5c3;
  color: #1c8a52;
}
.var-tag {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #1f1747;
  color: #fff;
  font: 600 11px var(--font);
  white-space: nowrap;
  pointer-events: none;
}
/* expected output: a card that opens to show a small terminal */
.expect {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcfbff;
}
.expect-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.expect-btn:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: -3px;
  border-radius: 16px;
}
.expect-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3d2e92, #261b60);
  color: #ff9a5c;
}
.expect-ic svg,
.expect-chev {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.expect-t {
  display: grid;
  flex: 1;
  line-height: 1.3;
}
.expect-t b {
  font-size: 15px;
}
.expect-t span {
  font-size: 13px;
  color: var(--soft);
}
.expect-chev {
  flex: none;
  color: var(--soft);
  transition: transform 0.35s var(--ease, ease);
}
.expect-btn[aria-expanded='true'] .expect-chev {
  transform: rotate(180deg);
  color: var(--orange);
}
.expect-body {
  overflow: hidden;
}
.expect-body[hidden] {
  display: none;
}
.expect-out {
  display: grid;
  gap: 2px;
  margin: 0 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2b2160, #221a50);
  font: 14px/1.7 var(--mono);
  color: #ece8ff;
}
.expect-out span::before {
  content: '\203A';
  margin-right: 10px;
  color: #ff9a5c;
}
.expect-note {
  margin: 8px 14px 14px;
  font-size: 13px;
  color: var(--soft);
}

.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px var(--inset) 12px;
}
.bar h2 {
  font-size: 17px;
  font-weight: 800;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #f3f0fb;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b5aed1;
}
.status[data-s='ready']::before {
  background: #22b36b;
}
.status[data-s='running']::before {
  background: var(--orange);
  animation: pulse 0.9s ease-in-out infinite;
}
.status[data-s='loading']::before {
  animation: pulse 0.9s ease-in-out infinite;
}
.status[data-s='failed'] {
  background: #fff1ec;
  color: var(--red);
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* the code editor: clean, roomy, easy to read */
.editor-wrap {
  position: relative;
  margin: 0 var(--inset);
}
.editor {
  padding-left: var(--rail);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #f6f3fd;
}
/* the Output toggle: a slim rail down the editor's left edge */
.editor-wrap {
  --rail: 38px;
}
.out-toggle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 1px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: var(--rail);
  padding: 14px 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 15px 0 0 15px;
  background: linear-gradient(180deg, #ffffff, #f6f3fd);
  color: var(--muted);
  font: 700 12px var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.out-toggle span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.out-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.out-toggle:hover,
.out-toggle[aria-expanded='true'] {
  color: var(--orange);
}
.out-toggle[aria-expanded='true'] {
  background: #fff5ee;
  border-color: #ffd3b8;
}
.out-toggle:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: -3px;
}
.out-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px #fff;
}
.out-dot[hidden] {
  display: none;
}
/* the panel draws open over the editor from the left, like a curtain */
.out-panel {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: calc(var(--rail) + 1px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: min(78%, 520px);
  border-radius: 0 18px 18px 0;
  background: linear-gradient(180deg, #2b2160, #221a50);
  color: #ece8ff;
  box-shadow: 16px 0 34px -18px rgba(20, 12, 60, 0.6);
}
.out-panel[hidden] {
  display: none;
}
.out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.out-head p {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b9addf;
}
.out-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.out-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.out-close:focus-visible {
  outline: 3px solid #b9a6ff;
  outline-offset: 2px;
}
.out-body {
  flex: 1;
  margin: 0;
  padding: 14px 18px 18px;
  overflow: auto;
  font: 14px/1.75 var(--mono);
  white-space: pre-wrap;
}
.out-line {
  display: block;
  min-height: 1.75em;
  opacity: 0;
}
.out-line.on {
  opacity: 1;
}
.out-line.on::before {
  content: '\203A';
  margin-right: 10px;
  color: #ff9a5c;
}
.out-empty {
  color: #9d92cf;
}
.editor .CodeMirror {
  height: 440px;
  font: 15px/1.7 var(--mono);
  background: #fbfaff;
  color: #2a2350;
}
.editor .CodeMirror-gutters {
  background: #f4f2fb;
  border-right: 1px solid var(--line);
}
.editor .CodeMirror-linenumber {
  padding: 0 10px 0 6px;
  color: #aaa4c4;
}
.editor .CodeMirror-lines {
  padding: 14px 0;
}
.editor .CodeMirror pre.CodeMirror-line {
  padding: 0 16px;
}
.editor .CodeMirror-cursor {
  border-left: 2px solid var(--orange);
}
.editor .CodeMirror-selected,
.editor .CodeMirror-focused .CodeMirror-selected {
  background: #e9e3ff;
}
.editor .CodeMirror-matchingbracket {
  color: var(--orange) !important;
  background: #fff1e8;
}
.cm-s-default .cm-comment {
  color: #9c95bd;
  font-style: italic;
}
.cm-s-default .cm-keyword {
  color: #7c3aed;
  font-weight: 700;
}
.cm-s-default .cm-builtin {
  color: #0e7490;
}
.cm-s-default .cm-variable {
  color: #2a2350;
}
.cm-s-default .cm-def {
  color: #2563eb;
}
.cm-s-default .cm-number {
  color: #d9480f;
}
.cm-s-default .cm-string {
  color: #15803d;
}
.cm-s-default .cm-operator {
  color: #be185d;
}
.pp-line-err {
  background: #fff0eb;
  box-shadow: inset 3px 0 0 var(--orange)
}

.editor .pp-marks {
  width: 22px;
}
.pp-line-warn {
  background: #fff9ec;
  box-shadow: inset 3px 0 0 #f0b429;
}
.pp-badge {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin: 3px 0 0 3px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font: 800 11px var(--font);
}
.pp-badge.warn {
  background: #f0b429;
}
.pp-note {
  display: grid;
  gap: 2px;
  margin: 4px 16px 8px 4px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff3ee;
  border: 1px solid #ffd3c2;
  font: 14px/1.45 var(--font);
  color: var(--muted);
  white-space: normal;
}
.pp-note b {
  color: #b8380c;
  font-size: 14px;
}
.pp-note.warn {
  background: #fffaf0;
  border-color: #f6dfa7;
}
.pp-note.warn b {
  color: #8a5a00;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px var(--inset) var(--inset);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background-color 0.2s;
}
.btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.btn.primary {
  background: linear-gradient(135deg, var(--orange-2), var(--orange) 60%, #e2531c);
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(226, 83, 28, 0.8);
}
.btn.ghost {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px #e1dcf2;
}
.btn.small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}
.bar-btns {
  display: flex;
  gap: 8px;
}
.btn.icon {
  width: 36px;
  padding: 0;
}
.btn.icon .off,
.btn.icon[aria-pressed='false'] .on {
  display: none;
}
.btn.icon[aria-pressed='false'] .off {
  display: block;
}
.btn.icon[aria-pressed='false'] {
  color: var(--soft);
}
.kbd {
  margin-left: auto;
  font-size: 13px;
  color: var(--soft);
}
.pp-scene {
  position: relative;
  margin: 0 var(--inset) var(--inset);
  overflow: hidden;
  border-radius: 18px;
  background: #fbf7ff;
}
.pp-scene svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font);
}
/* the illustrated classroom */
.pp-25d {
  background: #f6f1fe;
}
.pp-bubble {
  position: absolute;
  top: 5%;
  right: 3%;
  max-width: 42%;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  background: #fff;
  box-shadow: 0 10px 26px -14px rgba(36, 27, 77, 0.45);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.pp-bubble[hidden] {
  display: none;
}
.pp-anim {
  transform-box: fill-box;
  transform-origin: center;
}
.pp-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pp-confetti span {
  position: absolute;
  top: 0;
  border-radius: 2px;
}
.feedback {
  display: grid;
  gap: 6px;
  margin: 0 var(--inset) var(--inset);
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7f0;
  border: 1px solid #ffe2cf;
}
.feedback[hidden] {
  display: none;
}
.feedback[data-s='success'] {
  background: #ecfaf2;
  border-color: #c6efd9;
}
.feedback[data-s='error'] {
  background: #fff3ee;
  border-color: #ffd3c2;
}
.fb-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
}
.fb-title {
  font-size: 16px;
  font-weight: 800;
}
.fb-text {
  font-size: 15px;
  color: var(--muted);
}
.tests {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.dots {
  display: inline-flex;
  gap: 4px;
}
.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f1b9a3;
}
.dots span.pass {
  background: #22b36b;
}

/* tablets: the question stacks, the workspace stays side by side down to 900px, then stacks */
@media (max-width: 1100px) {
  .task-body {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 600px) {
  :root {
    --inset: 16px;
  }
  .progress {
    justify-items: start;
  }
  .editor-wrap {
    --rail: 32px;
  }
  .editor .CodeMirror {
    font-size: 13px;
  }
}
@media (max-width: 900px) {
  .work {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor .CodeMirror {
    height: 360px;
  }
  .kbd {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn,
  .status::before {
    transition: none;
    animation: none;
  }
}
