:root {
  color-scheme: light;
  --paper: #f4f3ec;
  --surface: #fffefa;
  --surface-strong: #edf5ee;
  --surface-inset: #f7f6ef;
  --ink: #20242d;
  --muted: #656f70;
  --muted-soft: #8a928f;
  --line: rgba(42, 55, 49, 0.16);
  --line-soft: rgba(42, 55, 49, 0.09);
  --teal: #0f766e;
  --teal-dark: #0b5d58;
  --coral: #d9483b;
  --gold: #b77900;
  --blue: #2f63d8;
  --green-soft: #dff4ec;
  --red-soft: #fde7e3;
  --yellow-soft: #fff1c7;
  --shadow: 0 14px 34px rgba(32, 36, 45, 0.075);
  --shadow-tight: 0 8px 22px rgba(32, 36, 45, 0.055);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(15, 118, 110, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #fbfaf4, var(--paper));
  background-size: 32px 32px, 32px 32px, auto;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.choice-control {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--teal);
}

.choice.is-disabled {
  cursor: not-allowed;
}


.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px clamp(14px, 2vw, 24px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 254, 250, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(42, 55, 49, 0.04);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 21px;
  font-weight: 800;
}

.brand h1 {
  margin: 1px 0 0;
  font-size: clamp(18px, 1.55vw, 23px);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.section-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px clamp(14px, 2vw, 24px) 0;
}

.section-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  padding: 0 18px;
  background: rgba(255, 254, 250, 0.86);
  color: var(--muted);
  font-weight: 800;
}

.section-tab:first-child {
  border-radius: 8px 0 0 8px;
}

.section-tab:last-child {
  border-radius: 0 8px 8px 0;
}

.section-tab.is-active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(190px, 236px);
  align-items: start;
  gap: 12px;
  padding: 10px clamp(14px, 2vw, 24px) 18px;
}

.left-rail,
.right-rail {
  display: grid;
  align-content: start;
  gap: 10px;
  position: sticky;
  top: 66px;
  max-height: calc(100vh - 78px);
  overflow: auto;
}

.panel,
.question-panel {
  background: rgba(255, 254, 250, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-tight);
}

.panel {
  padding: 12px;
}

.filters {
  display: grid;
  gap: 9px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field.compact {
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  min-width: 214px;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-inset);
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(56px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-inset);
  min-height: 36px;
}

.mode-btn {
  border: 0;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--line);
}

.mode-btn.is-active {
  color: #fff;
  background: var(--teal);
}

.ghost-btn,
.secondary-btn,
.primary-btn,
.pin-btn {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.ghost-btn:hover,
.secondary-btn:hover,
.pin-btn:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.ghost-btn.danger:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.primary-btn {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  min-width: 118px;
}

.primary-btn:hover {
  background: var(--teal-dark);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.stats {
  display: grid;
  gap: 10px;
}

.stat-row,
.rail-heading,
.source-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-row span,
.rail-heading span,
.source-note span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.meter {
  height: 8px;
  background: var(--surface-inset);
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.score-grid div {
  display: grid;
  gap: 3px;
  padding: 8px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-inset);
  min-width: 0;
}

.score-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-grid strong {
  font-size: 18px;
}

.quiz-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 8px;
}

.question-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 0 2px;
}

.question-toolbar > div {
  min-width: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-strong);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
}

.tag.source {
  background: var(--yellow-soft);
  color: #765200;
}

.tag.generated {
  background: #e8edff;
  color: var(--blue);
}

.pin-btn {
  width: 36px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
  flex: 0 0 auto;
}

.pin-btn.is-active {
  border-color: var(--gold);
  background: var(--yellow-soft);
  color: var(--gold);
}

.question-panel {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: hidden;
  padding: clamp(12px, 1.5vw, 16px);
  min-height: 0;
  box-shadow: var(--shadow);
}

.question-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.question-panel > * {
  position: relative;
}

.question-panel h2 {
  margin: 0;
  max-height: min(26vh, 188px);
  overflow: auto;
  padding: 0 4px 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: clamp(15px, 1.16vw, 18px);
  line-height: 1.34;
  letter-spacing: 0;
  white-space: pre-line;
  scrollbar-width: thin;
}

.choice-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.choice {
  display: grid;
  grid-template-columns: 20px 28px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
  cursor: pointer;
}

.choice:hover {
  border-color: var(--teal);
  background: #fbfffb;
}

.choice.is-selected {
  border-color: var(--blue);
  background: #f4f7ff;
  box-shadow: 0 0 0 2px rgba(47, 99, 216, 0.1);
}

.choice.is-correct {
  border-color: #249766;
  background: var(--green-soft);
}

.choice.is-wrong {
  border-color: var(--coral);
  background: var(--red-soft);
}

.choice-letter {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface-inset);
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}

.choice.is-selected .choice-letter {
  background: #e8edff;
  color: var(--blue);
}

.choice.is-correct .choice-letter {
  background: #249766;
  color: #fff;
}

.choice.is-wrong .choice-letter {
  background: var(--coral);
  color: #fff;
}

.choice-text {
  min-width: 0;
  line-height: 1.32;
  white-space: pre-line;
}

.feedback {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: min(24vh, 180px);
  overflow: auto;
  padding: 11px 12px;
  background: var(--surface-inset);
  line-height: 1.45;
}

.feedback strong {
  display: block;
  margin-bottom: 4px;
}

.feedback.good {
  border-color: #249766;
  background: var(--green-soft);
}

.feedback.bad {
  border-color: var(--coral);
  background: var(--red-soft);
}

.nav-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(108px, 148px));
  justify-content: center;
  gap: 10px;
}

.nav-row .secondary-btn:last-child {
  justify-self: stretch;
}

.nav-row > button {
  width: 100%;
}

.question-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(31px, 1fr));
  gap: 6px;
  max-height: min(42vh, 304px);
  overflow: auto;
  margin-top: 10px;
  padding-right: 2px;
  scrollbar-width: thin;
}

.map-btn {
  aspect-ratio: 1;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.map-btn.is-current {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.map-btn.is-answered {
  background: #e8edff;
  color: var(--blue);
  border-color: rgba(47, 99, 216, 0.35);
}

.map-btn.is-correct {
  background: var(--green-soft);
  color: #116a47;
  border-color: #79c9a6;
}

.map-btn.is-wrong {
  background: var(--red-soft);
  color: #b83226;
  border-color: #efaca3;
}

.source-note {
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
}

.source-note strong {
  max-height: 72px;
  overflow: auto;
  line-height: 1.4;
  font-size: 12.5px;
  word-break: break-word;
  scrollbar-width: thin;
}

.lab-layout {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr) minmax(200px, 236px);
  align-items: start;
  gap: 12px;
  padding: 10px clamp(14px, 2vw, 24px) 18px;
}

.lab-sidebar,
.lab-reference {
  position: sticky;
  top: 66px;
}

.exercise-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.exercise-section {
  margin-top: 10px;
  padding: 5px 6px 2px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.exercise-section:first-child {
  margin-top: 0;
}

.exercise-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.exercise-item:hover,
.exercise-item.is-active {
  border-color: var(--teal);
  background: var(--surface-strong);
}

.exercise-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-inset);
  color: var(--muted);
  font-weight: 900;
}

.exercise-item.is-complete .exercise-number {
  background: var(--teal);
  color: #fff;
}

.exercise-item strong,
.exercise-item small {
  display: block;
}

.exercise-item strong {
  font-size: 14px;
  line-height: 1.3;
}

.exercise-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.lab-workspace {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.lab-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px;
}

.lab-heading h2 {
  margin: 8px 0 3px;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.15;
}

.lab-heading p,
.task-card p,
.lab-reference p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.python-status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.python-status[data-status="running"] {
  border-color: rgba(47, 99, 216, 0.35);
  background: #edf2ff;
  color: var(--blue);
}

.python-status[data-status="success"] {
  border-color: #79c9a6;
  background: var(--green-soft);
  color: #116a47;
}

.python-status[data-status="error"] {
  border-color: #efaca3;
  background: var(--red-soft);
  color: #b83226;
}

.task-card {
  display: grid;
  gap: 7px;
}

.text-btn {
  justify-self: start;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 800;
}

.hint-box {
  border-left: 3px solid var(--gold);
  padding: 8px 11px;
  background: var(--yellow-soft);
  color: var(--ink) !important;
}

.editor-panel {
  overflow: hidden;
  border: 1px solid #162231;
  border-radius: 10px;
  background: #111923;
  box-shadow: var(--shadow);
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #a9b8c9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.code-editor {
  display: block;
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 0;
  padding: 18px;
  background: #111923;
  color: #e9f2ef;
  caret-color: #6ee7d0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.6;
  tab-size: 4;
  outline: none;
}

.code-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(110, 231, 208, 0.35);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #162231;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 10px;
}

.result-panel pre {
  min-height: 88px;
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  border-radius: 8px;
  padding: 12px;
  background: #17202b;
  color: #dce8e4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.test-results {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.test-results li {
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-inset);
  font-size: 13px;
}

.test-results .is-passed {
  background: var(--green-soft);
  color: #116a47;
}

.test-results .is-failed {
  background: var(--red-soft);
  color: #b83226;
}

.python-chart {
  display: block;
  max-width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.lab-reference h3 {
  margin: 5px 0 10px;
  font-size: 18px;
}

.lab-reference ul {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--ink);
}

.lab-reference code {
  color: var(--teal-dark);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: minmax(184px, 230px) minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .right-rail .question-map {
    max-height: 178px;
  }

  .lab-layout {
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  }

  .lab-reference {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (min-width: 980px) {
  .choice {
    min-height: 42px;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding-inline: 12px;
  }

  .section-tabs {
    padding-inline: 12px;
  }

  .section-tab {
    flex: 1;
    padding-inline: 10px;
  }

  .brand {
    min-width: 0;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
    align-items: stretch;
  }

  .field.compact,
  .segmented {
    grid-column: 1 / -1;
  }

  .field.compact {
    grid-template-columns: auto minmax(0, 1fr);
    min-width: 0;
  }

  .ghost-btn {
    width: 100%;
  }

  .layout,
  .lab-layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 8px;
    padding-inline: 12px;
  }

  .left-rail,
  .right-rail,
  .lab-sidebar,
  .lab-reference {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .quiz-stage {
    order: 1;
  }

  .left-rail {
    order: 2;
  }

  .right-rail {
    order: 3;
  }

  .quiz-stage {
    grid-template-rows: auto auto auto;
  }

  .choice-list {
    grid-template-columns: 1fr;
  }

  .question-map {
    max-height: 170px;
  }

  .question-toolbar,
  .nav-row {
    align-items: stretch;
  }

  .nav-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-row .secondary-btn:last-child {
    justify-self: stretch;
  }

  .primary-btn {
    min-width: 0;
  }

  .lab-sidebar {
    order: 2;
  }

  .lab-workspace {
    order: 1;
  }

  .lab-reference {
    order: 3;
  }

  .exercise-list {
    max-height: 230px;
  }

  .lab-heading,
  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .python-status {
    align-self: flex-start;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .code-editor {
    min-height: 320px;
  }
}
