* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(79, 156, 255, 0.24), transparent 30%),
    radial-gradient(circle at top right, rgba(80, 216, 144, 0.14), transparent 28%),
    linear-gradient(180deg, #090d1a 0%, #0b1020 38%, #070b16 100%);
  color: #e8ecff;
}

a {
  color: inherit;
}

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

button {
  border: 0;
  cursor: pointer;
}

/* ─── Layout ─────────────────────────────────────────── */

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 2rem 0 1rem;
  margin-bottom: 1.5rem;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.7;
  pointer-events: none;
}

.hero::before {
  top: -130px;
  right: -120px;
}

.hero::after {
  bottom: -170px;
  left: -130px;
}

.hero-grid {
  position: relative;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1.35fr 0.65fr;
  align-items: stretch;
  z-index: 1;
}

/* ─── Cards ──────────────────────────────────────────── */

.hero-card,
.side-card,
.lesson-card,
.optional-card {
  background: rgba(17, 25, 51, 0.84);
  border: 1px solid rgba(133, 157, 255, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  display: grid;
  gap: 1.25rem;
}

.hero-card {
  padding: 2rem;
}

.side-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lesson-card,
.optional-card {
  padding: 1.75rem;
  scroll-margin-top: 2.5rem;
}

.lesson-card {
  display: grid;
  gap: 1.25rem;
}

/* ─── Typography ─────────────────────────────────────── */

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

h1 {
  margin: 1rem 0 0.75rem;
  font-size: clamp(2.3rem, 4vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.hero p,
.lesson-card p,
.optional-card p,
.footer-note,
.explanation-box,
.timeline-item {
  color: #a6b2d9;
  line-height: 1.65;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.12);
  color: #7dd3fc;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 700;
}

/* ─── Buttons ────────────────────────────────────────── */

.primary-btn,
.secondary-btn,
.reset-btn,
.option-btn,
.trace-line,
.chip {
  text-decoration: none;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.primary-btn,
.secondary-btn,
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-radius: 14px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #4f9cff, #6c7cff);
  color: white;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8ecff;
}

.reset-btn {
  background: rgba(255, 122, 122, 0.14);
  color: #ffd4d4;
  border: 1px solid rgba(255, 122, 122, 0.25);
  font-size: 0.88rem;
}

.primary-btn:hover,
.secondary-btn:hover,
.reset-btn:hover,
.option-btn:hover,
.trace-line:hover,
.chip:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.option-btn:disabled,
.trace-line:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.reset-btn:focus-visible,
.option-btn:focus-visible,
.trace-line:focus-visible,
.chip:focus-visible,
.show-hint-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.28);
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: #e8ecff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.5;
}

.completion-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.primary-btn.btn-done {
  background: rgba(255, 255, 255, 0.06);
  color: #6b7a9e;
  cursor: not-allowed;
  text-decoration: none;
}

/* ─── Hero actions & toolbar ─────────────────────────── */

.hero-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-actions {
  margin-top: 1.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: rgba(17, 25, 51, 0.6);
  border: 1px solid rgba(133, 157, 255, 0.12);
  border-radius: 16px;
  backdrop-filter: blur(12px);
}

/* ─── Progress ring ──────────────────────────────────── */

.progress-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 210px;
  border-radius: 20px;
  background:
    radial-gradient(circle at center, rgba(79, 156, 255, 0.12), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.progress-ring svg {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.09);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 402;
  stroke-dashoffset: 402;
  transition: stroke-dashoffset 0.5s ease;
}

.ring-label {
  position: absolute;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.ring-label strong {
  font-size: 2rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.ring-label span {
  font-size: 0.78rem;
  color: #a6b2d9;
  max-width: 100px;
  line-height: 1.3;
}

/* ─── Stats ──────────────────────────────────────────── */

.stats {
  display: grid;
  gap: 0.5rem;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 0.9rem;
}

.stat span {
  color: #a6b2d9;
}

.stat strong {
  color: #e8ecff;
  font-weight: 700;
}

/* ─── Chips ──────────────────────────────────────────── */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.45rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: #a6b2d9;
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
}

.chip.active {
  background: rgba(125, 211, 252, 0.14);
  color: #e8ecff;
  border-color: rgba(125, 211, 252, 0.3);
}

/* ─── Lesson header ──────────────────────────────────── */

.lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lesson-header h2 {
  margin-bottom: 0.35rem;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.step-meta,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.step-meta {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a6b2d9;
  white-space: nowrap;
  margin-bottom: 0.5rem;
}

.badge.good {
  background: rgba(80, 216, 144, 0.12);
  color: #a8f0c5;
  border: 1px solid rgba(80, 216, 144, 0.24);
}

.badge.warn {
  background: rgba(255, 200, 87, 0.12);
  color: #ffe3a0;
  border: 1px solid rgba(255, 200, 87, 0.22);
}

/* ─── Traceback ──────────────────────────────────────── */

.traceback {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(6, 10, 22, 0.8);
}

.traceback-title {
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: #6b7a9e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.trace-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.trace-line {
  width: 100%;
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1rem;
  text-align: left;
  padding: 0.75rem 1.25rem;
  background: transparent;
  color: #e8ecff;
  border-top: none;
  border-radius: 0;
}

.trace-line + .trace-line {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.trace-line:hover {
  background: rgba(125, 211, 252, 0.06);
}

.trace-line .line-tag,
.trace-line .line-code,
.mini-code,
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.trace-line .line-tag {
  color: #6b7a9e;
  font-size: 0.84rem;
  padding-top: 0.1rem;
}

.trace-line .line-code {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  color: #c4d0f5;
}

/* ─── Feedback & states ──────────────────────────────── */

.trace-line.correct,
.option-btn.correct {
  background: rgba(80, 216, 144, 0.1);
  border-color: rgba(80, 216, 144, 0.34);
}

.trace-line.wrong,
.option-btn.wrong {
  background: rgba(255, 122, 122, 0.1);
  border-color: rgba(255, 122, 122, 0.34);
}

.feedback {
  display: none;
  padding: 0.9rem 1.1rem;
  line-height: 1.6;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.95rem;
}

.feedback.show {
  display: block;
}

.feedback.good {
  background: rgba(80, 216, 144, 0.1);
  border-color: rgba(80, 216, 144, 0.22);
  color: #b8f5d4;
}

.feedback.warn {
  background: rgba(255, 200, 87, 0.1);
  border-color: rgba(255, 200, 87, 0.2);
  color: #fff1c8;
}

.feedback.bad {
  background: rgba(255, 122, 122, 0.1);
  border-color: rgba(255, 122, 122, 0.2);
  color: #ffd1d1;
}

/* ─── Choice group ───────────────────────────────────── */

.choice-group {
  display: grid;
  gap: 0.6rem;
}

/* ─── Explanation & code ─────────────────────────────── */

.explanation-box {
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  line-height: 1.6;
}

.mini-code {
  margin: 0;
  padding: 1.1rem 1.25rem;
  background: rgba(7, 11, 22, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  overflow-x: auto;
  line-height: 1.7;
  color: #dfe6ff;
  white-space: pre;
}

code {
  font-size: 0.93em;
}

.mini-code code[class*="language-"] {
  background: none;
  font-size: 0.93em;
  color: inherit;
}

.mini-code .token.keyword  { color: #7dd3fc; }
.mini-code .token.string   { color: #a8f0c5; }
.mini-code .token.comment  { color: #4a5680; font-style: italic; }
.mini-code .token.number   { color: #ffc857; }
.mini-code .token.function { color: #c4b5fd; }
.mini-code .token.builtin  { color: #f9a8d4; }
.mini-code .token.operator { color: #7dd3fc; }
.mini-code .token.punctuation { color: #6b7a9e; }
.mini-code .token.class-name  { color: #f9a8d4; }

/* ─── Timeline ───────────────────────────────────────── */

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  margin: 0.5rem 0;
}

.timeline {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.timeline-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  color: #a6b2d9;
  line-height: 1.65;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.timeline-index {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(125, 211, 252, 0.1);
  color: #7dd3fc;
  font-weight: 800;
  font-size: 0.88rem;
  margin-top: 0.1rem;
}

/* ─── Sticky progress ────────────────────────────────── */

.sticky-progress {
  position: sticky;
  top: -50px;
  z-index: 10;
  backdrop-filter: blur(16px);
  background: rgba(8, 12, 24, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 0.8rem 1rem;
  display: grid;
  gap: 0.65rem;
  margin: 0 0 1.5rem;
}

.sticky-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: #a6b2d9;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar > div {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f9cff, #50d890);
  transition: width 0.45s ease;
}

.keyboard-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
  color: #a6b2d9;
}

/* ─── Status dots ────────────────────────────────────── */

.status-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  margin-right: 0.4rem;
  vertical-align: middle;
}

.status-dot.done {
  background: #50d890;
}

.status-dot.active {
  background: #ffc857;
}

/* ─── Lesson stack ───────────────────────────────────── */

.lesson-stack {
  display: grid;
  gap: 1.25rem;
}

/* ─── Completion banner ──────────────────────────────── */

.completion-banner {
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(79, 156, 255, 0.1), rgba(80, 216, 144, 0.1));
  border: 1px solid rgba(80, 216, 144, 0.24);
  padding: 3rem 2rem;
  text-align: center;
}

.completion-inner {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.completion-emoji {
  font-size: 3rem;
  line-height: 1;
}

.completion-banner h2 {
  font-size: 1.8rem;
  margin: 0;
  background: linear-gradient(135deg, #4f9cff, #50d890);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.completion-banner p {
  color: #a6b2d9;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ─── Form fields ────────────────────────────────────── */

.field-row {
  display: grid;
  gap: 0.5rem;
}

.field-row label {
  color: #a6b2d9;
  font-size: 0.92rem;
  font-weight: 700;
}

.field-row input,
.field-row textarea,
.field-row select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: #e8ecff;
  padding: 0.85rem 1rem;
}

.field-row textarea {
  min-height: 110px;
  resize: vertical;
}

/* ─── Footer ─────────────────────────────────────────── */

.footer-note {
  margin-top: 1.5rem;
  font-size: 0.88rem;
  color: #4a5680;
  line-height: 1.6;
}

/* ─── Responsive ─────────────────────────────────────── */

@media (max-width: 980px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .progress-ring {
    min-height: 180px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
  }

  .hero-card,
  .side-card,
  .lesson-card,
  .optional-card {
    padding: 1.25rem;
  }

  .trace-line {
    grid-template-columns: 7rem 1fr;
  }

  h1 {
    font-size: 2.1rem;
  }

  .toolbar {
    align-items: flex-start;
  }

  .chip {
    font-size: 0.82rem;
    padding: 0.4rem 0.7rem;
  }
}

 @media (max-width: 795px) {
  .sticky-progress {
    top: -85px;
  }
}

/* ─── Sub-task blocks ────────────────────────────────── */

.sub-task {
  display: grid;
  gap: 0.9rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.sub-task-label {
  font-weight: 700;
  color: #e8ecff;
  font-size: 0.95rem;
  margin: 0;
}

/* ─── Error type overview grid ───────────────────────── */

.error-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.error-type-card {
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  display: grid;
  gap: 0.4rem;
  align-content: start;
}

.error-type-card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #a6b2d9;
}

.error-type-name {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
  color: #c4b5fd;
  font-weight: 600;
}