:root {
  --bg: #0a0d12;
  --bg-raised: #11151c;
  --bg-panel: #151a22;
  --border: #232a35;
  --border-soft: #1a2029;
  --text: #e4e9f0;
  --text-dim: #8b96a5;
  --text-faint: #56616f;
  --accent: #5eead4;
  --accent-dim: #2c7a6e;
  --accent-soft: rgba(94, 234, 212, 0.1);
  --amber: #f5b955;
  --amber-soft: rgba(245, 185, 85, 0.1);
  --red: #f47174;
  --red-soft: rgba(244, 113, 116, 0.1);
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

code,
.mono {
  font-family: var(--mono);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg));
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.brand .bracket {
  color: var(--text-faint);
}

#top-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lab-crumb {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .lab-crumb {
    display: none;
  }
}

.progress-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-pill .bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-pill .bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ---------- Layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 250px 1fr;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

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

.layout.no-sidebar {
  grid-template-columns: 1fr;
}

.layout.no-sidebar .sidebar {
  display: none;
}

/* ---------- Sidebar ---------- */

.sidebar {
  border-right: 1px solid var(--border-soft);
  padding: 20px 12px;
}

@media (max-width: 880px) {
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
    padding: 12px;
  }
  .nav-list {
    display: flex;
    overflow-x: auto;
    gap: 6px;
  }
  .nav-list .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

.nav-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
  padding: 0 10px 8px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: var(--bg-panel);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item .check {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: transparent;
}

.nav-item.done .check {
  border-color: var(--accent-dim);
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.back-item {
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
}

.nav-item.back-item .check {
  border: none;
  color: var(--text-faint);
}

.nav-item.back-item:hover {
  color: var(--accent);
}

/* ---------- Main ---------- */

.main {
  padding: 34px 32px 80px;
  min-width: 0;
}

@media (max-width: 620px) {
  .main {
    padding: 22px 16px 60px;
  }
}

.module-header {
  margin-bottom: 26px;
}

.module-kicker {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.module-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.module-tagline {
  color: var(--text-dim);
  font-size: 15.5px;
  max-width: 640px;
  line-height: 1.5;
  margin: 0;
}

.save-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

.save-badge strong {
  color: var(--amber);
  font-weight: 600;
}

/* ---------- Info module ---------- */

.info-body p {
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  max-width: 680px;
}

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 16px 18px;
  margin: 18px 0;
  max-width: 680px;
}

.callout.warning {
  border-left-color: var(--red);
}

.callout.steps {
  border-left-color: var(--amber);
}

.callout-title {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.callout ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.65;
}

.callout li + li {
  margin-top: 6px;
}

/* ---------- Walkthrough layout ---------- */

.walkthrough {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.code-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 78px;
}

@media (max-width: 880px) {
  .code-panel {
    position: static;
  }
}

.code-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-raised);
}

.code-panel-head .filename {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

.copy-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.copy-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.copy-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.copy-btn.primary {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-soft);
}

.code-lines {
  padding: 14px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}

.code-line {
  display: flex;
  white-space: pre;
  padding: 1px 14px;
  transition: background 0.25s ease, opacity 0.25s ease;
  opacity: 1;
}

.code-lines.dimmed .code-line {
  opacity: 0.32;
}

.code-lines.dimmed .code-line.active {
  opacity: 1;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  margin-left: -2px;
}

.line-no {
  color: var(--text-faint);
  width: 26px;
  flex: 0 0 auto;
  text-align: right;
  margin-right: 14px;
  -webkit-user-select: none;
  user-select: none;
}

.line-code {
  color: var(--text);
  white-space: pre;
}

.code-lines.dimmed .code-line.active .line-code {
  color: var(--text);
}

/* ---------- Stepper ---------- */

.stepper-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.stepper-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.stepper-progress .step-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  flex: 0 0 auto;
}

.step-dots {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.step-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s ease;
}

.step-dots span.past {
  background: var(--accent-dim);
}

.step-dots span.current {
  background: var(--accent);
}

.beat-title {
  font-size: 17px;
  font-weight: 650;
  margin: 0 0 10px;
  color: var(--text);
}

.beat-body {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.65;
  flex: 1;
}

.beat-body code {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  color: var(--amber);
}

.stepper-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  gap: 10px;
}

.nav-btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.nav-btn.primary {
  background: var(--accent);
  color: #06231e;
  border-color: var(--accent);
}

.nav-btn.primary:hover {
  filter: brightness(1.08);
}

.intro-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  flex: 1;
}

.intro-card p {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0;
}

/* ---------- Wrap-up card ---------- */

.wrapup {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wrapup-cta {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.wrapup-cta .label {
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
}

.wrapup-cta .sub {
  color: var(--text-dim);
  font-size: 13px;
}

.big-copy-btn {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13.5px;
  background: var(--accent);
  color: #06231e;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s ease;
}

.big-copy-btn:hover {
  filter: brightness(1.08);
}

.big-copy-btn.copied {
  background: var(--text);
}

.section-block {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.section-block h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text-dim);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.section-block ol,
.section-block ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.section-block li + li {
  margin-top: 4px;
}

.section-block code {
  font-family: var(--mono);
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--amber);
  font-size: 13px;
}

/* ---------- Quick check ---------- */

.quiz {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.quiz-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--amber);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.quiz-question {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.correct {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-option.incorrect {
  border-color: var(--red);
  background: var(--red-soft);
}

.quiz-explanation {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}

/* ---------- Module footer nav ---------- */

.module-footer {
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;
}

.next-btn {
  font-family: var(--sans);
  font-weight: 650;
  font-size: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 12px 20px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.next-btn:hover {
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}

/* ---------- Home (lab picker) ---------- */

.main-home {
  padding: 56px 32px 80px;
  max-width: 880px;
  margin: 0 auto;
}

.home-hero {
  margin-bottom: 36px;
}

.home-hero .module-title {
  font-size: 34px;
  font-family: var(--mono);
}

.home-hero .module-tagline {
  font-size: 16px;
  max-width: 560px;
}

.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.lab-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.lab-card:hover {
  border-color: var(--accent-dim);
}

.lab-card-tag {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lab-card-title {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
  color: var(--text);
}

.lab-card-sub {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
  flex: 1;
}

.lab-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.lab-card-meta .bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.lab-card-meta .bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.lab-card-btn {
  align-self: flex-start;
  margin-top: 6px;
}

/* ---------- Hero (welcome only) ---------- */

.hero-kicker {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.hero-kicker .cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 22px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  font-family: var(--mono);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-raised);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
