:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --ink: #1e2422;
  --muted: #5c6761;
  --line: #cfd8d0;
  --panel: #ffffff;
  --accent: #146c63;
  --accent-strong: #0f4c46;
  --warm: #c75732;
  --soft: #e7eee8;
  --good: #17804d;
  --risk: #b5462f;
  --shadow: 0 18px 50px rgba(31, 45, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(20, 108, 99, 0.12), transparent 35%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 12px 18px;
  font-weight: 750;
  cursor: pointer;
  min-height: 46px;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: var(--soft);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.workspace,
.results {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(207, 216, 208, 0.9);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border-radius: 8px 8px 0 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.06;
}

.loop-label {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.progress-panel {
  min-width: min(320px, 100%);
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  background: var(--soft);
  border-radius: 999px;
}

#progressFill {
  width: 5%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 180ms ease;
}

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 620px;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.student-panel {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(231, 238, 232, 0.58);
}

label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px;
  outline: none;
}

select {
  margin-bottom: 18px;
}

input {
  margin-bottom: 18px;
}

textarea {
  min-height: 238px;
  resize: vertical;
  line-height: 1.45;
  margin-bottom: 10px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.16);
}

.skill-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.skill-stack span,
.question-meta span,
.skill-pill {
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.question-panel {
  padding: clamp(24px, 4vw, 46px);
  display: flex;
  flex-direction: column;
}

.question-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

#questionTitle {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.15;
  margin-bottom: 12px;
}

#questionPrompt {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.answer-area {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

.answer-warning {
  min-height: 22px;
  margin-bottom: 20px;
  color: var(--risk);
  font-size: 0.9rem;
  font-weight: 750;
}

.option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
  cursor: pointer;
}

.option:hover {
  border-color: var(--accent);
  background: #fbfdfb;
}

.option input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.nav-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
}

.results {
  margin-top: 0;
  padding: clamp(22px, 4vw, 38px);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.studio {
  margin-top: 18px;
  padding: clamp(22px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(207, 216, 208, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.studio-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.studio-header h2 {
  margin-bottom: 0;
}

.studio-body {
  margin-top: 24px;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1.25fr);
  gap: 22px;
}

.studio-help,
.studio-status {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.studio-status {
  min-height: 22px;
  margin: 14px 0 0;
  font-weight: 750;
}

.studio-status.error {
  color: var(--risk);
}

.studio-actions {
  margin-top: 14px;
}

.hidden {
  display: none;
}

.results-header,
.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
}

.score-badge {
  display: grid;
  place-items: center;
  min-width: 128px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

.score-badge strong {
  font-size: 2rem;
  line-height: 1;
}

.score-badge span {
  opacity: 0.88;
  font-weight: 800;
}

.result-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  margin: 28px 0;
}

.result-grid > div,
.missed-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.skill-results {
  display: grid;
  gap: 10px;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px 46px;
  gap: 12px;
  align-items: center;
}

.mini-track {
  height: 8px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  background: var(--good);
}

.missed-list {
  display: grid;
  gap: 10px;
}

.missed-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.missed-item strong {
  display: block;
  margin-bottom: 5px;
}

.missed-item p {
  margin-bottom: 5px;
  color: var(--muted);
}

.missed-item em {
  color: var(--risk);
  font-style: normal;
  font-weight: 750;
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 10px 0;
  }

  .topbar,
  .workspace,
  .results-header,
  .result-grid,
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .workspace {
    min-height: 0;
  }

  .student-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .results-header {
    align-items: stretch;
  }

  .score-badge {
    min-width: 0;
    aspect-ratio: auto;
    padding: 16px;
  }

  .skill-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .nav-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #nextButton,
  #adaptiveButton,
  #downloadButton {
    grid-column: span 2;
  }
}
