:root {
  --bg: #eef6ff;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #607086;
  --line: #cfe0f3;
  --accent: #3178c6;
  --accent-strong: #235a97;
  --accent-soft: #dbeafe;
  --warn: #235a97;
  --good: #15803d;
  --bad: #b91c1c;
  --code: #0f172a;
  --shadow: 0 14px 35px rgba(30, 64, 175, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(49, 120, 198, 0.14), rgba(96, 165, 250, 0.08)),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  padding: 24px;
  background: #12243a;
  color: #eef6ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark-wrap {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.15rem;
}

.brand p {
  margin-top: 3px;
  color: #b8d8f8;
  font-size: 0.9rem;
}

.lesson-list {
  display: grid;
  gap: 8px;
}

.lesson-tab {
  width: 100%;
  min-width: 0;
  padding: 13px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #eef6ff;
  text-align: left;
  cursor: pointer;
}

.lesson-tab strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.lesson-tab span {
  color: #b8d8f8;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.lesson-tab.active {
  border-color: rgba(96, 165, 250, 0.9);
  background: rgba(49, 120, 198, 0.38);
}

.lesson-tab.done strong::after {
  content: " ✓";
  color: #9ed0ff;
}

.progress-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #dbeafe;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

.progress-track div {
  width: 0;
  height: 100%;
  background: #3178c6;
  transition: width 180ms ease;
}

.progress-note {
  margin: 12px 0 0;
  color: #b8d8f8;
  font-size: 0.84rem;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  overflow-x: hidden;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: clamp(1.55rem, 2.6vw, 2.35rem);
  letter-spacing: 0;
}

.topbar-actions,
.step-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  line-height: 1;
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.icon-button:hover,
.small-button:hover,
.choice:hover {
  border-color: var(--accent);
}

.learning-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr);
  min-width: 0;
  gap: 18px;
  align-items: start;
}

.lesson-panel,
.visual-panel,
.practice-panel,
.code-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lesson-panel,
.practice-panel,
.code-panel {
  padding: 18px;
}

.visual-panel {
  padding: 18px 18px 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.panel-header h3 {
  font-size: 1rem;
}

.lesson-panel p,
.practice-panel p,
.caption,
.steps li,
.choice {
  overflow-wrap: anywhere;
}

.lesson-panel p,
.practice-panel p,
.caption {
  color: var(--muted);
  line-height: 1.55;
}

.steps {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-left: 22px;
}

.steps li {
  line-height: 1.45;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1.65;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.caption {
  min-height: 46px;
  margin: 12px 0 0;
}

.status-pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

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

.quiz-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.ok {
  background: #dcfce7;
  color: var(--good);
}

.status-pill.miss {
  background: #fee2e2;
  color: var(--bad);
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.choice {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.choice.correct {
  border-color: var(--good);
  background: #f0fdf4;
}

.choice.wrong {
  border-color: var(--bad);
  background: #fef2f2;
}

.choice:disabled {
  cursor: default;
}

.next-question {
  margin-top: 12px;
}

.feedback {
  min-height: 48px;
  margin: 12px 0 0;
}

pre {
  overflow: auto;
  max-width: 100%;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--code);
  color: #e5e7eb;
  line-height: 1.5;
  tab-size: 2;
}

.solution-lock {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.solution-lock pre {
  transition: filter 180ms ease, opacity 180ms ease;
}

.solution-lock:not(.revealed) pre {
  max-height: 360px;
  filter: blur(6px);
  opacity: 0.66;
  user-select: none;
  pointer-events: none;
}

.solution-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(
    180deg,
    rgba(248, 251, 255, 0.18),
    rgba(219, 234, 254, 0.86)
  );
}

.solution-lock.revealed .solution-overlay {
  display: none;
}

.reveal-solution {
  min-height: 44px;
  padding: 0 18px;
  border-color: #3178c6;
  background: #eff6ff;
  box-shadow: 0 12px 32px rgba(30, 64, 175, 0.2);
  font-weight: 800;
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

.hint {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--warn);
  background: #dbeafe;
  color: #1d4ed8;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.64);
}

.modal-backdrop[hidden] {
  display: none;
}

.implementation-dialog {
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(49, 120, 198, 0.45);
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 251, 255, 0.96);
  backdrop-filter: blur(10px);
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0;
}

.implementation-steps {
  display: grid;
  gap: 16px;
  padding: 18px 22px 22px;
}

.implementation-step {
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(0, 1.25fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.implementation-copy h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.implementation-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.fancy-code {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: var(--code);
}

.code-titlebar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #12243a;
  color: #bfdbfe;
}

.code-titlebar strong {
  margin-left: 6px;
  font-size: 0.82rem;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #3178c6;
}

.code-dot:nth-child(2) {
  background: #60a5fa;
}

.code-dot:nth-child(3) {
  background: #93c5fd;
}

.fancy-code pre {
  border-radius: 0;
  background: transparent;
}

.results-shell {
  min-height: 100vh;
  padding: 32px;
}

.results-wrap {
  max-width: 1100px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.results-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.results-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-tile,
.lesson-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-tile {
  padding: 18px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.lesson-result {
  margin-top: 14px;
  overflow: hidden;
}

.lesson-result header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--accent-soft);
}

.lesson-result h2 {
  margin: 0;
  font-size: 1.1rem;
}

.question-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 14px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}

.question-result p {
  margin: 0;
  line-height: 1.45;
}

.question-answer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

@media (max-width: 760px) {
  .results-shell {
    padding: 18px;
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-summary,
  .question-result {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    min-height: auto;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    justify-content: flex-start;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-header {
    padding: 16px;
  }

  .implementation-steps {
    padding: 14px;
  }

  .implementation-step {
    grid-template-columns: 1fr;
    padding: 14px;
  }
}
