/* =========================================================================
   Code in 15: styles
   ========================================================================= */

/* The hidden attribute always wins, even over a class that sets display. */
[hidden] {
  display: none !important;
}

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --code-size: 14px;
  --code-line: 22px;
  --editor-pad: 12px;
  --header-h: 64px;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e8ebf3;
  --border: #e3e7ef;
  --border-strong: #cdd3df;
  --text: #141821;
  --text-2: #4b5364;
  --text-3: #7a8294;
  --primary: #4257e0;
  --primary-hover: #3345c7;
  --primary-soft: #eceffd;
  --primary-ink: #2f40b5;
  --on-primary: #ffffff;
  --accent: #f4b52f;
  --accent-soft: #fff4d9;
  --accent-ink: #8a5a00;
  --success: #16a34a;
  --success-soft: #e6f6ec;
  --success-ink: #0f6b35;
  --error: #e5484d;
  --error-soft: #fdeeee;
  --error-ink: #b0242b;
  --pink: #ec4899;
  --teal: #14b8a6;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.05), 0 6px 20px rgba(20, 24, 40, 0.06);
  --shadow-lg: 0 18px 50px rgba(20, 24, 40, 0.14);
  --ring: 0 0 0 3px rgba(66, 87, 224, 0.3);

  --code-bg: #fbfcfe;
  --code-gutter: #a7aebd;
  --code-active: rgba(66, 87, 224, 0.06);
  --console-bg: #f5f7fb;
  --tok-kw: #8b3fd9;
  --tok-str: #18794e;
  --tok-num: #b54708;
  --tok-com: #8a92a3;
  --tok-fn: #2f5fd0;
  --tok-bi: #0b7285;
  --tok-def: #2f5fd0;
  --tok-const: #b54708;
  --tok-self: #c2255c;
  --tok-op: #5a6275;
  --tok-dec: #b54708;
  --tok-fexpr: #0b7285;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1217;
    --surface: #161a21;
    --surface-2: #1c2129;
    --surface-3: #252b35;
    --border: #282f3a;
    --border-strong: #3a4250;
    --text: #e8ebf1;
    --text-2: #a9b1bf;
    --text-3: #778194;
    --primary: #7d8dff;
    --primary-hover: #97a4ff;
    --primary-soft: rgba(125, 141, 255, 0.14);
    --primary-ink: #aab5ff;
    --on-primary: #0c0f16;
    --accent: #f6c451;
    --accent-soft: rgba(246, 196, 81, 0.13);
    --accent-ink: #f6c451;
    --success: #3ccb74;
    --success-soft: rgba(60, 203, 116, 0.12);
    --success-ink: #72e29f;
    --error: #ff6b6b;
    --error-soft: rgba(255, 107, 107, 0.12);
    --error-ink: #ff9d9d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --ring: 0 0 0 3px rgba(125, 141, 255, 0.35);
    --code-bg: #12161c;
    --code-gutter: #4d5668;
    --code-active: rgba(125, 141, 255, 0.07);
    --console-bg: #11151b;
    --tok-kw: #c792ea;
    --tok-str: #a5d6a7;
    --tok-num: #f9a66c;
    --tok-com: #697386;
    --tok-fn: #82aaff;
    --tok-bi: #6fd3e8;
    --tok-def: #82aaff;
    --tok-const: #f9a66c;
    --tok-self: #f78c9c;
    --tok-op: #9aa4b5;
    --tok-dec: #f9a66c;
    --tok-fexpr: #6fd3e8;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0f1217;
  --surface: #161a21;
  --surface-2: #1c2129;
  --surface-3: #252b35;
  --border: #282f3a;
  --border-strong: #3a4250;
  --text: #e8ebf1;
  --text-2: #a9b1bf;
  --text-3: #778194;
  --primary: #7d8dff;
  --primary-hover: #97a4ff;
  --primary-soft: rgba(125, 141, 255, 0.14);
  --primary-ink: #aab5ff;
  --on-primary: #0c0f16;
  --accent: #f6c451;
  --accent-soft: rgba(246, 196, 81, 0.13);
  --accent-ink: #f6c451;
  --success: #3ccb74;
  --success-soft: rgba(60, 203, 116, 0.12);
  --success-ink: #72e29f;
  --error: #ff6b6b;
  --error-soft: rgba(255, 107, 107, 0.12);
  --error-ink: #ff9d9d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px rgba(125, 141, 255, 0.35);
  --code-bg: #12161c;
  --code-gutter: #4d5668;
  --code-active: rgba(125, 141, 255, 0.07);
  --console-bg: #11151b;
  --tok-kw: #c792ea;
  --tok-str: #a5d6a7;
  --tok-num: #f9a66c;
  --tok-com: #697386;
  --tok-fn: #82aaff;
  --tok-bi: #6fd3e8;
  --tok-def: #82aaff;
  --tok-const: #f9a66c;
  --tok-self: #f78c9c;
  --tok-op: #9aa4b5;
  --tok-dec: #f9a66c;
  --tok-fexpr: #6fd3e8;
  color-scheme: dark;
}

/* ---- base ------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--primary-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text-2);
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 12px;
}

.muted {
  color: var(--text-3);
}

.icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.noscript {
  padding: 40px;
  text-align: center;
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-lg {
  height: 50px;
  padding: 0 24px;
  font-size: 16px;
  border-radius: 13px;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 9px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 2px 8px rgba(66, 87, 224, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.btn-soft:hover:not(:disabled) {
  filter: brightness(0.97);
}

.btn-kbd {
  margin-left: 2px;
  font-size: 11px;
  padding: 0 5px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  opacity: 0.85;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  flex: none;
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-icon .icon {
  width: 20px;
  height: 20px;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--primary-ink);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--error-ink);
}

/* ---- header ------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1160px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex: none;
}

.brand-mark svg {
  width: 32px;
  height: 32px;
  display: block;
}

.brand-accent {
  color: var(--primary);
}

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.stat-chip.streak {
  color: var(--text-3);
}

.stat-chip.streak.lit {
  color: #f0690f;
}

.stat-chip.xp .icon {
  color: var(--accent);
}

@media (max-width: 760px) {
  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .brand-name {
    display: none;
  }
  .main-nav {
    justify-content: center;
  }
  .nav-link {
    padding: 0 10px;
  }
  .nav-link > span:not(.icon) {
    display: none;
  }
  .nav-link .icon {
    width: 20px;
    height: 20px;
  }
  .stat-chip {
    padding: 0 9px;
  }
}



/* ---- pages ------------------------------------------------------------- */

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 36px 20px 64px;
}

.page.narrow {
  max-width: 720px;
}

.page-head {
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 6px;
}

.page-head p {
  max-width: 680px;
}

@media (max-width: 640px) {
  .page {
    padding: 24px 16px 48px;
  }
  .page-head h1 {
    font-size: 26px;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-ink);
}

.eyebrow.warm {
  color: var(--accent-ink);
}

.empty-state {
  text-align: center;
  padding: 48px 0;
}

.empty-state h1 {
  margin-bottom: 12px;
}

.empty-state p {
  margin-bottom: 20px;
}

/* ---- hero: new visitor ----------------------------------------------- */

.hero-new {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 48px;
  align-items: center;
  padding: 24px 0 56px;
}

.hero-title {
  font-size: clamp(36px, 5.4vw, 58px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 14px 0 18px;
}

.grad {
  background: linear-gradient(100deg, var(--primary) 10%, #9b5de5 55%, #e7a13a 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  font-size: 18px;
  color: var(--text-2);
  max-width: 560px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 32px;
}

.hero-skip {
  margin: -18px 0 28px;
  color: var(--text-2);
  font-size: 15px;
}

.hero-skip a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary-ink);
  font-weight: 650;
  text-decoration: none;
}

.hero-skip a:hover {
  text-decoration: underline;
}

.hero-skip svg {
  width: 16px;
  height: 16px;
}

.how {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}

.how li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.how li > .icon {
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.how strong {
  display: block;
  font-size: 15px;
}

.how span {
  color: var(--text-2);
  font-size: 14px;
}

.hero-visual {
  position: relative;
  min-width: 0;
}

.home {
  overflow-x: clip;
}

.hero-visual::before {
  content: '';
  position: absolute;
  inset: -30px 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 18%, transparent), transparent);
  filter: blur(10px);
  z-index: 0;
}

.mock {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  transform: rotate(-1.2deg);
}

.mock-top {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 18px;
}

.mock-top .seg {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
}

.mock-top .seg.done {
  background: var(--success);
}

.mock-top .seg.current {
  background: var(--primary);
}

.mock-xp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  font-weight: 700;
  font-size: 13px;
}

.mock-xp .icon {
  color: var(--accent);
}

.mock-eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-ink);
}

.mock-title {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 14px;
}

.mock-code,
.mock-out {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  white-space: pre;
  overflow: hidden;
}

.mock-code {
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.mock-out {
  margin-top: 8px;
  background: var(--console-bg);
  color: var(--text-2);
}

.mock-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success-ink);
  font-weight: 700;
  font-size: 14px;
}

.mock-toast strong {
  margin-left: auto;
}

@media (max-width: 900px) {
  .hero-new {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-top: 8px;
  }
  .hero-visual {
    max-width: 480px;
  }
}

/* ---- hero: returning learner ------------------------------------------- */

.hero-back {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  grid-template-areas: 'welcome welcome' 'continue stats';
  gap: 16px 20px;
  margin-bottom: 48px;
}

.welcome {
  grid-area: welcome;
}

.welcome h1 {
  font-size: 30px;
  font-weight: 800;
}

.continue-card {
  grid-area: continue;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface) 55%, color-mix(in srgb, var(--primary) 9%, var(--surface)) 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

a.continue-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.continue-meta {
  color: var(--text-3);
  font-size: 14px;
  font-weight: 600;
  margin-top: 6px;
}

.continue-card h2 {
  font-size: 30px;
  font-weight: 800;
}

.continue-card p {
  color: var(--text-2);
  max-width: 520px;
}

.continue-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-2);
}

.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  flex: 1;
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--primary);
  border-radius: inherit;
}

.continue-progress .bar {
  max-width: 260px;
}

.continue-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 18px;
}

.continue-actions .muted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.stats-card {
  grid-area: stats;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stats-top {
  display: flex;
  align-items: center;
  gap: 22px;
}

.ring {
  position: relative;
  width: 96px;
  height: 96px;
  flex: none;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.ring-label strong {
  font-size: 24px;
  font-weight: 800;
}

.ring-label span {
  font-size: 12px;
  color: var(--text-3);
}

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

.stat-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 15px;
}

.stat-line strong {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.stat-line .icon {
  width: 20px;
  height: 20px;
}

.stat-line.streak .icon {
  color: var(--text-3);
}

.stat-line.streak.lit .icon {
  color: #f0690f;
}

.stat-line.xp .icon {
  color: var(--accent);
}

.stat-line.goal.met {
  color: var(--success-ink);
  font-weight: 600;
}

.stat-line.goal.met .icon {
  color: var(--success);
}

.week {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.day .dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #fff;
}

.day .dot .icon {
  width: 16px;
  height: 16px;
}

.day.active .dot {
  background: var(--success);
  border-color: var(--success);
}

.day.today .dot {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px color-mix(in srgb, var(--primary) 45%, transparent);
}

.day.today .day-label {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 860px) {
  .hero-back {
    grid-template-columns: 1fr;
    grid-template-areas: 'welcome' 'continue' 'stats';
  }
  .continue-card {
    padding: 22px;
  }
  .continue-card h2 {
    font-size: 26px;
  }
}

/* ---- course map ---------------------------------------------------------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 24px;
  font-weight: 800;
}

.unit {
  margin-bottom: 32px;
}

/* A track (Foundations, Advanced Python) groups several units. */
.track-head {
  display: grid;
  gap: 4px;
  margin: 8px 0 22px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.track-head.advanced {
  margin-top: 44px;
  border-left-color: var(--accent);
}

.track-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
}

.track-label svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.track-head.advanced .track-label svg {
  color: var(--accent-ink);
}

.track-head p {
  color: var(--text-2);
  font-size: 15px;
}

.track-meta {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}

.unit-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.unit-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 800;
  font-size: 18px;
}

.unit-done .unit-badge {
  background: var(--success);
  color: #fff;
}

.unit-text {
  flex: 1;
  min-width: 0;
}

.unit-text h3 {
  font-size: 19px;
  font-weight: 750;
}

.unit-text p {
  color: var(--text-2);
  font-size: 15px;
}

.unit-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 140px;
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.unit-progress .bar {
  height: 6px;
}

.unit-done .unit-progress .bar span {
  background: var(--success);
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.session-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.session-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.session-card.is-next {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow);
}

.session-card h4 {
  font-size: 16px;
  font-weight: 700;
}

.session-card p {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sc-num {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.is-done .sc-num {
  background: var(--success-soft);
  color: var(--success-ink);
}

.sc-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.sc-status.done {
  background: var(--success-soft);
  color: var(--success-ink);
}

.sc-status.next {
  background: var(--primary);
  color: var(--on-primary);
}

.sc-status.progress {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.sc-foot {
  display: flex;
  gap: 14px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}

.sc-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

@media (max-width: 1000px) {
  .session-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .session-grid {
    grid-template-columns: 1fr;
  }
  .unit-head {
    flex-wrap: wrap;
  }
  .unit-progress {
    width: 100%;
    order: 3;
  }
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-3);
}

/* ---- session shell (focus mode) -------------------------------------------- */

body.focus-mode .site-header {
  display: none;
}

.session-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.session-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  flex: none;
}

.session-top-title {
  font-weight: 600;
  color: var(--text-3);
  font-size: 14px;
}

.progress-track {
  flex: 1;
  display: flex;
  gap: 4px;
  max-width: 900px;
  margin: 0 auto;
}

.progress-track .seg {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  transition: background-color 0.3s;
}

.progress-track .seg.done {
  background: var(--success);
}

.progress-track .seg.current {
  background: var(--primary);
  animation: pulse 1.8s ease-in-out infinite;
}

.progress-track .seg.warm:not(.done):not(.current) {
  background: color-mix(in srgb, var(--accent) 40%, var(--surface-3));
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
}

.xp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.xp-pill.bump {
  animation: bump 0.45s ease;
}

@keyframes bump {
  40% {
    transform: scale(1.25);
  }
}

.stage {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 40px;
  -webkit-overflow-scrolling: touch;
}

.stage-center {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5vh;
}

.enter {
  animation: enter 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 640px) {
  .session-top {
    gap: 10px;
    padding: 10px 12px;
  }
  .time-left {
    display: none;
  }
  .stage {
    padding: 8px 16px 32px;
  }
}

/* ---- footer / feedback bar ----------------------------------------------- */

.session-footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  transition: background-color 0.2s, border-color 0.2s;
}

.session-footer[data-kind='success'] {
  background: var(--success-soft);
  border-top-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.session-footer[data-kind='error'] {
  background: var(--error-soft);
  border-top-color: color-mix(in srgb, var(--error) 35%, transparent);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-status {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.footer-hint {
  color: var(--text-3);
  font-size: 14px;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  color: #fff;
  animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.status-icon .icon {
  width: 20px;
  height: 20px;
}

[data-kind='success'] .status-icon {
  background: var(--success);
}

[data-kind='error'] .status-icon {
  background: var(--error);
}

[data-kind='info'] .status-icon {
  background: var(--primary);
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

.status-text {
  min-width: 0;
  max-height: 32vh;
  overflow-y: auto;
}

.status-title {
  font-weight: 800;
  font-size: 17px;
  white-space: pre-wrap;
}

[data-kind='success'] .status-title {
  color: var(--success-ink);
}

[data-kind='error'] .status-title {
  color: var(--error-ink);
}

.status-body {
  color: var(--text);
  font-size: 15px;
}

.status-body p + p {
  margin-top: 6px;
}

.status-output {
  font-family: var(--mono);
  font-size: 13px;
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  white-space: pre;
  overflow-x: auto;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.footer-actions .btn-primary {
  min-width: 132px;
}

@media (max-width: 640px) {
  .session-footer {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .footer-status:empty {
    display: none;
  }
  .footer-hint {
    display: none;
  }
  .footer-status:has(> .footer-hint:only-child) {
    display: none;
  }
  .footer-actions .btn-primary {
    flex: 1;
  }
  .status-icon {
    width: 30px;
    height: 30px;
  }
}

/* ---- step cards --------------------------------------------------------------- */

.step-card {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 12px;
}

.step-title {
  font-size: 28px;
  font-weight: 800;
  margin: 10px 0 14px;
  outline: none;
}

.step-title:focus-visible {
  box-shadow: none;
}

.prose {
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
}

.prose > * + * {
  margin-top: 12px;
}

.prose ul,
.prose ol {
  padding-left: 24px;
}

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

.prose strong {
  font-weight: 700;
}

.md-heading {
  font-size: 18px;
  margin-top: 18px;
}

code.inline {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: break-spaces;
  word-break: break-word;
}

.code-block {
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

.output-block {
  background: var(--console-bg);
  color: var(--text);
}

.callout {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
}

.try-it {
  margin-top: 22px;
}

.try-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.try-label .icon {
  color: var(--accent);
}

@media (max-width: 640px) {
  .step-title {
    font-size: 23px;
  }
  .prose {
    font-size: 16px;
  }
}

/* ---- intro & completion ------------------------------------------------------ */

.intro-card,
.complete {
  width: 100%;
  max-width: 620px;
  padding: 36px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.intro-title {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 10px 0 8px;
}

.intro-goal {
  font-size: 18px;
  color: var(--text-2);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 20px 0 24px;
  font-size: 14px;
  color: var(--text-2);
  font-weight: 600;
}

.meta-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-row .icon {
  color: var(--text-3);
}

.intro-sub {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.outcomes {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 8px;
}

.outcomes li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.outcomes .icon {
  margin-top: 3px;
  width: 20px;
  height: 20px;
  padding: 3px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.intro-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 20px;
}

.intro-note .icon {
  color: var(--accent-ink);
  margin-top: 2px;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.kbd-hint {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-3);
}

.complete {
  text-align: center;
}

.complete-badge {
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f08c2e);
  color: #fff;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 45%, transparent);
  animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.complete-badge .icon {
  width: 42px;
  height: 42px;
}

.complete h1 {
  font-size: 34px;
  font-weight: 800;
  margin-top: 18px;
  outline: none;
}

.complete-sub {
  color: var(--text-2);
  margin-top: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 26px 0;
}

.stat {
  padding: 14px 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  animation: enter 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.stat:nth-child(2) {
  animation-delay: 0.08s;
}

.stat:nth-child(3) {
  animation-delay: 0.16s;
}

.stat:nth-child(4) {
  animation-delay: 0.24s;
}

.stat-icon .icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.stat.xp .icon {
  color: var(--accent);
}

.stat.streak .icon {
  color: #f0690f;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
}

.next-card {
  text-align: left;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.next-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 4px;
}

.next-card p {
  color: var(--text-2);
}

.next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .intro-card,
  .complete {
    padding: 24px 20px;
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
  .stage-center {
    padding-top: 12px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .intro-actions .btn,
  .next-actions .btn {
    flex: 1;
  }
}

/* ---- quiz -------------------------------------------------------------------- */

.question {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  margin: 10px 0 16px;
  outline: none;
}

.question:focus-visible {
  box-shadow: none;
}

.question code.inline {
  font-weight: 500;
}

.quiz-code {
  margin-bottom: 18px;
}

.quiz-run {
  margin: -8px 0 16px;
}

.run-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  margin: 4px 0 6px;
}

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

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  border-bottom-width: 3px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.12s, background-color 0.12s, transform 0.1s;
}

.option:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.option:active:not(:disabled) {
  transform: translateY(1px);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

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

.option.wrong {
  border-color: var(--error);
  background: var(--error-soft);
  opacity: 0.8;
}

.option:disabled {
  cursor: default;
}

.option:disabled:not(.correct):not(.wrong) {
  opacity: 0.55;
}

.opt-key {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
}

.selected .opt-key {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.correct .opt-key {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.wrong .opt-key {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.opt-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}

.shake {
  animation: shake 0.4s;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-5px);
  }
  40%,
  80% {
    transform: translateX(5px);
  }
}

@media (max-width: 640px) {
  .question {
    font-size: 19px;
  }
  .option {
    padding: 12px 14px;
  }
}

/* ---- order ------------------------------------------------------------------- */

.order-label {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.order-program {
  list-style: none;
  margin: 0;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}

.order-line {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 6px 12px;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 15px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  white-space: pre;
  overflow-x: auto;
}

button.order-line {
  cursor: pointer;
}

.order-line.placed {
  background: var(--surface);
  border-color: var(--border);
}

.order-line.placed:hover:not(:disabled) {
  border-color: var(--error);
}

.order-line.placed.wrong {
  border-color: var(--error);
  background: var(--error-soft);
}

.order-line.placed.correct {
  border-color: color-mix(in srgb, var(--success) 50%, transparent);
  background: var(--success-soft);
  cursor: default;
}

.order-line.empty {
  min-height: 34px;
  border: 1px dashed var(--border-strong);
}

.step-card.order-card {
  max-width: 1040px;
}

.order-card > .eyebrow,
.order-card > .step-title,
.order-card > .prose {
  max-width: 760px;
}

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

@media (max-width: 900px) {
  .order-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

.order-num {
  width: 20px;
  flex: none;
  text-align: right;
  color: var(--code-gutter);
  font-size: 13px;
}

.order-indent {
  display: inline-block;
  flex: none;
  align-self: stretch;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 4ch);
  opacity: 0.8;
}

.order-pool {
  display: grid;
  gap: 8px;
}

.order-line.chip {
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 3px;
  transition: border-color 0.12s, transform 0.1s;
}

.order-line.chip:hover {
  border-color: var(--primary);
}

.order-line.chip:active {
  transform: translateY(1px);
}

.order-pool-empty {
  font-size: 14px;
  color: var(--text-3);
  padding: 6px 2px;
}

/* ---- code exercise layout --------------------------------------------------- */

.stage-code {
  padding: 0;
  overflow: hidden;
}

.step-code {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.25fr);
  height: 100%;
}

.code-brief {
  overflow-y: auto;
  padding: 16px 28px 40px;
  border-right: 1px solid var(--border);
}

.code-brief .prose {
  font-size: 16px;
}

.code-work {
  overflow-y: auto;
  padding: 16px 20px 28px;
  background: color-mix(in srgb, var(--surface-2) 45%, var(--bg));
}

.hints {
  margin-top: 22px;
}

.hint-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  counter-reset: hint;
  display: grid;
  gap: 8px;
}

.hint-list li {
  counter-increment: hint;
  position: relative;
  padding: 10px 14px 10px 42px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 15px;
}

.hint-list li::before {
  content: counter(hint);
  position: absolute;
  left: 12px;
  top: 10px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #3b2a00;
  font-size: 12px;
  font-weight: 800;
}

.hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nudge {
  animation: nudge 1.6s ease-in-out infinite;
}

@keyframes nudge {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

.solution-box {
  margin-top: 14px;
}

.solution-head {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.solution-box .btn {
  margin-top: 8px;
}

@media (max-width: 960px) {
  .stage-code {
    overflow-y: auto;
  }
  .step-code {
    display: block;
    height: auto;
  }
  .code-brief {
    border-right: none;
    padding: 8px 16px 12px;
    overflow: visible;
  }
  .code-work {
    padding: 8px 16px 28px;
    background: transparent;
    overflow: visible;
  }
}

/* ---- code panel ---------------------------------------------------------------- */

.code-panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-toolbar .spacer {
  flex: 1;
}

.file-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.file-tab .icon {
  color: var(--primary);
}

.py-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.py-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.py-status[data-status='ready']::before {
  background: var(--success);
}

.py-status[data-status='loading']::before,
.py-status[data-status='running']::before {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.py-status[data-status='error']::before {
  background: var(--error);
}

.btn-run {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--success);
  color: #fff;
  font-size: 14px;
}

.btn-run:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-run .icon {
  width: 14px;
  height: 14px;
}

.busy .btn-run .icon {
  animation: pulse 0.8s ease-in-out infinite;
}

@media (max-width: 480px) {
  .py-status {
    display: none;
  }
}

/* ---- editor --------------------------------------------------------------------- */

.editor {
  position: relative;
  background: var(--code-bg);
}

.editor-scroller {
  display: flex;
  /* Let the code grow past the scroller's max height (and scroll as one),
     instead of being squeezed to it: a squeezed textarea scrolls on its own
     and its caret drifts away from the highlighted text. */
  align-items: flex-start;
  overflow: auto;
  max-height: 460px;
  cursor: text;
}

.playground .editor-scroller {
  max-height: 60vh;
}

.editor-gutter {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: none;
  padding: var(--editor-pad) 10px var(--editor-pad) 12px;
  min-width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: calc(var(--code-size) - 1px);
  line-height: var(--code-line);
  color: var(--code-gutter);
  background: var(--code-bg);
  user-select: none;
}

.editor-gutter span {
  display: block;
}

.editor-gutter span.error {
  color: var(--error);
  font-weight: 700;
}

.editor-stack {
  position: relative;
  flex: 1 0 auto;
  display: grid;
}

.editor-highlight,
.editor-input {
  grid-area: 1 / 1;
  margin: 0;
  padding: var(--editor-pad) 16px var(--editor-pad) 4px;
  border: 0;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  font-variant-ligatures: none;
  letter-spacing: normal;
  tab-size: 4;
  white-space: pre;
  word-wrap: normal;
  overflow: hidden;
  min-width: 0;
}

.editor-highlight {
  pointer-events: none;
  color: var(--text);
  z-index: 1;
}

.editor-input {
  z-index: 2;
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  -webkit-text-fill-color: transparent;
  width: 100%;
  height: 100%;
}

.editor-input::selection {
  background: color-mix(in srgb, var(--primary) 28%, transparent);
  -webkit-text-fill-color: transparent;
}

.editor-input:focus-visible {
  box-shadow: none;
}

.editor.focused {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent);
}

.editor-active-line,
.editor-error-line {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--code-line);
  pointer-events: none;
  display: none;
}

.editor-active-line {
  background: var(--code-active);
}

.editor-error-line {
  background: color-mix(in srgb, var(--error) 13%, transparent);
  box-shadow: inset 3px 0 0 var(--error);
}

@media (pointer: coarse) {
  :root {
    --code-size: 16px;
    --code-line: 24px;
  }
  .editor-scroller {
    max-height: 50vh;
  }
}

/* syntax tokens */
.tok-kw {
  color: var(--tok-kw);
  font-weight: 500;
}
.tok-str {
  color: var(--tok-str);
}
.tok-num {
  color: var(--tok-num);
}
.tok-com {
  color: var(--tok-com);
  font-style: italic;
}
.tok-fn {
  color: var(--tok-fn);
}
.tok-bi {
  color: var(--tok-bi);
}
.tok-def {
  color: var(--tok-def);
  font-weight: 600;
}
.tok-const {
  color: var(--tok-const);
  font-weight: 500;
}
.tok-self {
  color: var(--tok-self);
}
.tok-op {
  color: var(--tok-op);
}
.tok-dec {
  color: var(--tok-dec);
}
.tok-fexpr {
  color: var(--tok-fexpr);
}

/* ---- symbol bar (touch) -------------------------------------------------------- */

.symbol-bar {
  display: flex;
  gap: 4px;
  padding: 6px;
  overflow-x: auto;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  scrollbar-width: none;
}

.symbol-bar::-webkit-scrollbar {
  display: none;
}

.sym {
  flex: none;
  min-width: 38px;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.sym:active {
  background: var(--primary-soft);
}

/* ---- input & console --------------------------------------------------------- */

.stdin-box {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface);
}

.stdin-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
}

.stdin-label .muted {
  font-weight: 500;
}

.stdin-input {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: 1.5;
}

.stdin-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.console {
  border-top: 1px solid var(--border);
  background: var(--console-bg);
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.console-output {
  margin: 0;
  padding: 8px 14px 14px;
  min-height: 48px;
  max-height: 260px;
  overflow: auto;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.console-output.placeholder {
  color: var(--text-3);
  font-family: var(--font);
  font-size: 14px;
}

.console-extra:empty {
  display: none;
}

.console-extra {
  padding: 0 12px 12px;
  display: grid;
  gap: 10px;
}

.error-card {
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--error) 40%, transparent);
  background: var(--error-soft);
  padding: 12px 14px;
  font-size: 14px;
}

.error-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--error-ink);
}

.error-message {
  margin-top: 6px;
}

.error-message code {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}

.error-code {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre;
  overflow-x: auto;
}

.error-friendly {
  margin-top: 8px;
  color: var(--text);
}

.error-trace {
  margin-top: 8px;
}

.error-trace summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
}

.error-trace pre {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  color: var(--text-2);
}

.diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.diff-col {
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.diff-title {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.diff-body {
  margin: 0;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
}

.diff-line {
  padding: 0 10px;
  white-space: pre;
}

.diff-line.differs {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

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

/* ---- recap -------------------------------------------------------------------- */

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

.recap-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 16px;
  animation: enter 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.recap-list li > .icon {
  width: 22px;
  height: 22px;
  padding: 3px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
}

.recap-list.compact li {
  padding: 8px 0;
  border: none;
  background: none;
  animation: none;
  font-size: 15px;
}

.recap-list.compact li + li {
  border-top: 1px solid var(--border);
}

.recap-list.compact li > .icon {
  background: var(--success-soft);
  color: var(--success);
}

.recap-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-3);
}

/* ---- notes -------------------------------------------------------------------- */

.search-wrap {
  position: relative;
  max-width: 520px;
  margin-bottom: 28px;
}

.search-wrap > .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.notes-unit {
  margin-bottom: 32px;
}

.notes-unit h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--text-2);
}

.notes-unit {
  display: grid;
  gap: 12px;
}

.note-card {
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.note-card.locked {
  background: transparent;
  border-style: dashed;
}

.note-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.note-head h3 {
  flex: 1;
  font-size: 17px;
}

.note-head .icon {
  color: var(--text-3);
}

.note-card.locked .note-head {
  margin-bottom: 2px;
}

.note-card.locked p {
  font-size: 14px;
  padding-left: 38px;
}

/* ---- playground ----------------------------------------------------------------- */

.playground .console-output {
  max-height: 40vh;
}

/* ---- toasts & confetti --------------------------------------------------------- */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 60;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (pointer: coarse) {
  .kbd-hint,
  .btn-kbd {
    display: none;
  }
}

.question .code-block,
.question code.inline {
  font-weight: 400;
}

.question .code-block {
  font-size: var(--code-size);
  margin-top: 12px;
}

/* =========================================================================
   Mode switch, account menu
   ========================================================================= */

.mode-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-right: 4px;
}

.mode-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.mode-switch button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.mode-switch button:not(.on):hover {
  color: var(--text);
}

.account-control {
  position: relative;
}

.avatar-btn {
  padding: 2px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #9b5de5);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.avatar.large {
  width: 64px;
  height: 64px;
  font-size: 22px;
  flex: none;
}

.avatar.syncing {
  animation: pulse 1s ease-in-out infinite;
}

.avatar-btn.warn .avatar {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 240px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: enter 0.18s ease;
}

.menu-head {
  display: grid;
  padding: 10px 12px 8px;
}

.menu-head span {
  font-size: 13px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}

.menu-item:hover {
  background: var(--surface-2);
}

.sign-in {
  height: 34px;
}

@media (max-width: 760px) {
  .mode-switch button > span:not(.icon),
  .sign-in > span:not(.icon) {
    display: none;
  }
  .mode-switch button {
    padding: 0 7px;
  }
  .sign-in {
    width: 34px;
    padding: 0;
  }
}

@media (max-width: 480px) {
  .theme-toggle {
    display: none;
  }
  .header-inner {
    gap: 6px;
  }
  .nav-link {
    padding: 0 8px;
  }
  .stat-chip {
    padding: 0 8px;
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .stat-chip.xp {
    display: none;
  }
}

/* Single-column grids: let long code lines scroll inside their box instead of
   widening the whole column. */
.refresher-list,
.options,
.recap-list,
.hint-list,
.order-pool,
.order-program,
.outcomes,
.title-outcomes,
.console-extra {
  grid-template-columns: minmax(0, 1fr);
}

.refresher-item,
.option > *,
.recap-list li > span,
.title-outcomes li > span {
  min-width: 0;
}

/* ---- account page ------------------------------------------------------ */

.account-page {
  max-width: 560px;
}

.account-stack {
  display: grid;
  gap: 16px;
}

.account-card {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.account-card h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
}

.account-card h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.account-card > p + p {
  margin-top: 10px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 12px;
  background: var(--surface-2);
}

.auth-tab {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.auth-form.compact {
  margin-top: 0;
}

.auth-form .btn-lg {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.field-hint {
  font-size: 13px;
  color: var(--text-3);
}

.field-input {
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--error-soft);
  color: var(--error-ink);
  font-size: 14px;
  font-weight: 600;
}

.small {
  font-size: 13px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-head h1 {
  margin-bottom: 0;
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 16px;
}

.profile-stats > div {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-2);
}

.profile-stats strong {
  color: var(--text);
  font-size: 16px;
}

.profile-stats .icon {
  color: var(--accent);
}

.sync-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  color: var(--text-2);
}

.sync-state.synced {
  color: var(--success-ink);
}

.sync-state.error,
.sync-state.offline {
  color: var(--accent-ink);
}

.account-actions {
  margin-top: 18px;
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.danger-zone {
  border-color: color-mix(in srgb, var(--error) 35%, var(--border));
}

.danger-zone > p {
  margin-bottom: 14px;
}

/* ---- scroll promo on the course page ------------------------------------ */

.scroll-promo {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin: -24px 0 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(110deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), color-mix(in srgb, #e7a13a 10%, var(--surface)));
  border: 1px solid var(--border);
}

.scroll-promo-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
}

.scroll-promo-icon .icon {
  width: 24px;
  height: 24px;
}

.scroll-promo-text {
  display: grid;
  flex: 1;
  font-size: 14px;
  color: var(--text-2);
}

.scroll-promo-text strong {
  color: var(--text);
  font-size: 15px;
}

@media (max-width: 640px) {
  .scroll-promo {
    flex-wrap: wrap;
    margin-top: -32px;
  }
  .scroll-promo .btn {
    width: 100%;
  }
}

/* ---- refresher step ---------------------------------------------------------- */

.refresher-intro {
  margin-bottom: 18px;
  color: var(--text-2);
}

.refresher-list {
  display: grid;
  gap: 12px;
}

.refresher-item {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.refresher-item h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.refresher-item p {
  color: var(--text-2);
  margin-bottom: 10px;
}

.refresher-basics {
  margin-top: 22px;
}

.refresher-basics-title {
  margin-bottom: 10px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.refresher-basics .refresher-list {
  gap: 8px;
}

.refresher-item.folded {
  padding: 0;
}

.refresher-item.folded summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}

.refresher-item.folded summary::-webkit-details-marker {
  display: none;
}

.refresher-item.folded summary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.refresher-item.folded summary .icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-3);
  transition: transform 0.15s ease;
}

.refresher-item.folded[open] summary .icon {
  transform: rotate(180deg);
}

.refresher-item.folded > p,
.refresher-item.folded > div {
  margin: 0 18px;
}

.refresher-item.folded > div {
  margin-bottom: 16px;
}

/* =========================================================================
   Scroll mode (feed)
   ========================================================================= */

body.feed-mode {
  overflow: hidden;
  overscroll-behavior-y: none;
}

.feed-shell {
  position: relative;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
}

.feed-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: contain;
}

.feed-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform;
}

.feed-card.is-hidden {
  display: none;
}

.feed-card.is-current {
  transform: translateY(0);
}

.feed-card.is-above {
  transform: translateY(-100%);
}

.feed-card.is-below {
  transform: translateY(100%);
}

.feed-card.animating {
  transition: transform 0.4s cubic-bezier(0.2, 0.75, 0.25, 1);
}

.feed-card.bounce {
  animation: bounce 0.35s ease;
}

@keyframes bounce {
  40% {
    transform: translateY(24px);
  }
}

.feed-card-body {
  flex: 1;
  min-height: 0;
}

.feed-card-body > .enter {
  animation: none;
}

.feed-context {
  flex: none;
  padding: 10px 20px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-footer {
  flex: none;
}

.feed-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 760px;
  margin: 8px auto 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: enter 0.4s ease;
}

.feed-banner .icon {
  width: 30px;
  height: 30px;
  color: var(--text-3);
}

.feed-banner.success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.feed-banner.success .icon {
  color: var(--accent);
}

.feed-banner div {
  display: grid;
}

.feed-banner span {
  font-size: 14px;
  color: var(--text-2);
}

.xp-float {
  position: absolute;
  right: 24px;
  top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  pointer-events: none;
  animation: xpfloat 1.3s ease forwards;
  z-index: 3;
}

@keyframes xpfloat {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: none;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-18px);
  }
}

/* title cards: one per topic, like a video's opening frame */

.title-card {
  display: grid;
  place-items: center;
  padding: 24px 20px;
  overflow-y: auto;
  background:
    radial-gradient(120% 90% at 10% 0%, hsl(var(--hue) 85% 62% / 0.28), transparent 60%),
    radial-gradient(100% 80% at 100% 100%, hsl(calc(var(--hue) + 70) 85% 60% / 0.26), transparent 60%),
    var(--bg);
}

.title-card-inner {
  width: 100%;
  max-width: 620px;
}

.title-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.title-tags span {
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.title-card-title {
  font-size: clamp(38px, 7vw, 64px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.02;
  outline: none;
}

.title-card-goal {
  margin-top: 14px;
  font-size: 19px;
  color: var(--text-2);
}

.title-outcomes {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  gap: 8px;
}

.title-outcomes li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text);
}

.title-outcomes .icon {
  margin-top: 3px;
  color: var(--success);
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.swipe-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 22px;
  font-size: 13px;
  color: var(--text-3);
}

.icon.rot-up svg {
  transform: rotate(90deg);
}

.icon.rot-down svg {
  transform: rotate(-90deg);
}

.feed-nav {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 10px;
  z-index: 5;
}

.feed-nav-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.feed-nav-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
}

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

.feed-nav-btn .icon {
  width: 20px;
  height: 20px;
}

@media (max-width: 1100px) {
  .feed-nav {
    display: none;
  }
}

@media (max-width: 640px) {
  .feed-context {
    padding: 8px 16px 0;
  }
  .title-card-goal {
    font-size: 17px;
  }
  .title-actions .btn {
    flex: 1;
  }
}

/* Browsers give <code> the generic monospace font. Inside a <pre> it must use
   the pre's font instead: the editor's highlight layer has to match the
   textarea above it exactly, or the caret drifts away from the text line by
   line. */
pre code {
  font: inherit;
}

/* Beginners type what they see: never merge >= or != into one glyph. */
code,
pre,
kbd,
textarea,
.opt-code,
.order-line {
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'calt' 0;
}

/* Keep the floating up/down buttons clear of the cards' content. */
@media (min-width: 1101px) {
  .feed-card {
    padding-right: 76px;
  }
}

/* =========================================================================
   Python loading screen
   ========================================================================= */

.py-loader {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.py-loader.open {
  opacity: 1;
}

.py-loader-card {
  width: 100%;
  max-width: 440px;
  padding: 30px 28px 22px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.py-loader.open .py-loader-card {
  transform: none;
}

.py-loader-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
}

.py-loader-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.py-loader-arc {
  transform-origin: 24px 24px;
  animation: py-spin 1.1s linear infinite;
}

.py-loader.failed .py-loader-arc {
  animation: none;
  stroke: var(--error);
}

@keyframes py-spin {
  to {
    transform: rotate(360deg);
  }
}

.py-loader-card h2 {
  font-size: 22px;
  font-weight: 800;
}

.py-loader-sub {
  margin: 8px auto 20px;
  max-width: 360px;
  font-size: 15px;
  color: var(--text-2);
}

.py-loader-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.py-loader-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #9b5de5);
  transition: width 0.3s ease;
  overflow: hidden;
}

.py-loader-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: py-shimmer 1.4s ease-in-out infinite;
}

@keyframes py-shimmer {
  to {
    transform: translateX(100%);
  }
}

.py-loader-stage {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.py-loader-amount {
  color: var(--text-3);
}

.py-loader-after {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.py-loader-tip {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 14px;
  color: var(--text);
  text-align: left;
  min-height: 3.6em;
}

.py-loader-tip strong {
  color: var(--accent-ink);
  margin-right: 4px;
}

.py-loader-tip.fade {
  animation: enter 0.35s ease;
}

.py-loader-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.py-loader-actions kbd {
  margin-left: 4px;
  font-size: 11px;
}

.py-loader.failed .py-loader-bar,
.py-loader.failed .py-loader-stage,
.py-loader.failed .py-loader-tip {
  display: none;
}

@media (pointer: coarse) {
  .py-loader-actions kbd {
    display: none;
  }
}

@media (max-width: 480px) {
  .py-loader-card {
    padding: 24px 20px 18px;
  }
  .py-loader-card h2 {
    font-size: 20px;
  }
}

/* ---- Java and Haskell: examples, transcripts, fill-in exercises ------------------ */

.tok-prompt {
  color: var(--text-3);
  user-select: none;
}

.tok-out {
  color: var(--text-2);
}

.example {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  grid-template-columns: minmax(0, 1fr);
}

.example-input {
  margin-top: 12px;
}

.example-output .run-label,
.example-input .run-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.example-output .run-label .icon,
.example-input .run-label .icon {
  width: 16px;
  height: 16px;
}

.example-output.is-error .output-block {
  background: var(--error-soft);
  color: var(--error-ink);
  border-color: color-mix(in srgb, var(--error) 30%, var(--border));
}

.fill-code {
  margin-top: 18px;
  line-height: 32px;
}

.blank-input {
  font: inherit;
  line-height: 24px;
  height: 28px;
  min-width: 4ch;
  max-width: 100%;
  padding: 0 6px;
  margin: 0 1px;
  border: none;
  border-bottom: 2px solid var(--primary);
  border-radius: 6px 6px 2px 2px;
  background: var(--primary-soft);
  color: var(--text);
  vertical-align: baseline;
  transition: background-color 0.12s, border-color 0.12s;
}

.blank-input:focus {
  outline: none;
  box-shadow: var(--ring);
}

.blank-input.correct {
  border-bottom-color: var(--success);
  background: var(--success-soft);
}

.blank-input.wrong {
  border-bottom-color: var(--error);
  background: var(--error-soft);
}

.fill-card .hints {
  margin-top: 16px;
}

/* ---- learning goals ----------------------------------------------------------------- */

.hero-ask {
  font-size: 17px;
  font-weight: 750;
  margin: 26px 0 10px;
}

.goal-picker {
  display: grid;
  gap: 14px;
}

.goal-group {
  display: grid;
  gap: 8px;
}

.goal-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.goal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

.goal-chip:hover {
  border-color: var(--primary);
}

.goal-check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  color: transparent;
}

.goal-check .icon {
  width: 14px;
  height: 14px;
}

.goal-chip[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.goal-chip[aria-pressed='true'] .goal-check {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.goal-text {
  display: grid;
}

.goal-note {
  font-size: 13px;
}

/* On the Preferences page each choice is a full-width row with a description. */
.goal-picker.detailed .goal-chips {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.goal-picker.detailed .goal-chip {
  border-radius: var(--radius);
  padding: 12px 14px;
  gap: 12px;
}

.goal-picker.detailed .goal-name {
  font-size: 15px;
}

.goal-blurb {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.goal-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
  white-space: nowrap;
}

.goal-summary {
  display: grid;
  gap: 12px;
  justify-items: start;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.prefs-page {
  max-width: 640px;
}

.prefs-intro {
  margin: -4px 0 18px;
  font-size: 14px;
}

.prefs-link.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
}

.segment {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.segment .icon {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
  color: var(--text-3);
}

.segment-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.segment-text strong {
  font-size: 15px;
}

.segment-text span {
  font-size: 13px;
  color: var(--text-2);
}

.segment.on {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.segment.on .icon {
  color: var(--primary);
}

@media (max-width: 520px) {
  .segmented {
    grid-auto-flow: row;
  }
}

/* ---- courses on the home page ---------------------------------------------------- */

.goals-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  margin: -6px 0 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  color: var(--text-2);
}

.goals-bar > .icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.goals-bar > span:not(.icon) {
  flex: 1;
  min-width: 0;
}

.goals-bar strong {
  color: var(--text);
}

.course-block {
  margin-bottom: 44px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.course-head {
  display: grid;
  gap: 4px;
  margin-bottom: 22px;
}

.course-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.course-title-row h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lang-chip,
.runs-chip,
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.lang-chip {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.lang-chip.lang-java {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.lang-chip.lang-haskell {
  background: color-mix(in srgb, #9b5de5 16%, var(--surface));
  color: color-mix(in srgb, #7c3aed 80%, var(--text));
}

.runs-chip {
  background: var(--success-soft);
  color: var(--success-ink);
}

.runs-chip .icon {
  width: 12px;
  height: 12px;
}

.course-blurb {
  color: var(--text-2);
  font-size: 16px;
  max-width: 760px;
}

.course-meta {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.topic-chip {
  height: 22px;
  padding: 0 8px;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.topic-chip.match {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary-ink);
}

.more-courses {
  margin-top: 8px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.more-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 14px;
}

.course-block.other {
  margin-bottom: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.course-block.other > summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.course-block.other > summary::-webkit-details-marker {
  display: none;
}

.course-block.other .course-head {
  flex: 1;
  margin: 0;
}

.course-block.other .course-title-row h2 {
  font-size: 20px;
}

.course-toggle .icon {
  width: 22px;
  height: 22px;
  color: var(--text-3);
  transition: transform 0.15s;
}

.course-block.other[open] .course-toggle .icon {
  transform: rotate(180deg);
}

.course-block.other .course-body {
  padding: 4px 20px 8px;
}
