/* =================================================================
   Design tokens
   ================================================================= */
:root {
  --purple:       #7B4DFF;
  --purple-light: #AA8AFF;
  --purple-dark:  #5A2EE0;
  --orange:       #F5A623;
  --orange-light: #FFCC66;
  --blue:         #3B82F6;
  --magenta:      #9C2C6B;
  --coral:        #FF4B5C;
  --green:        #10B981;
  --green-light:  #34D399;

  /* World/category accent — overridden at runtime by applyWorldTheme().
     Defaults fall back to brand purple so the page works without a world. */
  --world-color:        #7B4DFF;
  --world-color-light:  #AA8AFF;
  --world-color-rgb:        123, 77, 255;
  --world-color-light-rgb:  170, 138, 255;
  --world-tint-strong: 0.20;
  --world-tint-soft:   0.10;

  --font-h: 'Nunito', sans-serif;
  --font-b: 'Space Grotesk', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  --easing: cubic-bezier(.4, 0, .2, 1);

  --bg:           #0B0820;
  --bg-top:       #0D0826;
  --bg-bottom:    #07122E;
  --surface:      #120E2A;
  --surface-lift: #1A1440;

  --text:         #FFFFFF;
  --text-soft:    rgba(255,255,255,0.88);
  --text-muted:   #CEC9E3;
  --text-dim:     #B8B0D0;

  --card-fill:        rgba(255,255,255,0.04);
  --card-fill-strong: rgba(255,255,255,0.08);
  --card-border:      rgba(255,255,255,0.10);
  --card-border-hover:rgba(255,255,255,0.22);
  --card-hover:       rgba(255,255,255,0.06);

  --nav-bg:   rgba(13,8,38,0.88);
  --nav-bg-2: rgba(13,8,38,0.95);
  --crumb:    rgba(255,255,255,0.60);
  --chip-bg:  rgba(123,77,255,0.18);

  --input-bg:     rgba(255,255,255,0.06);
  --input-border: rgba(255,255,255,0.10);
  --scrollbar:    rgba(255,255,255,0.10);

  --hero-gradient: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 50%, var(--bg-bottom) 100%);

  --world-tint-strong: 0.22;
  --world-tint-soft:   0.12;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background: var(--bg);
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: clip;
  font-size: 17px; /* a11y: bigger root so rem-like sizes read comfortably */
}
body {
  font-family: var(--font-b);
  color: var(--text);
  font-size: 17px;
  background: transparent;
  background-image: var(--hero-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}
/* World ambience: a soft, theme-aware tint behind everything.
   The starfield canvas (z-index 0) sits in front so stars stay crisp. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%,
      rgba(var(--world-color-rgb), var(--world-tint-strong)) 0%,
      transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% 100%,
      rgba(var(--world-color-rgb), var(--world-tint-soft)) 0%,
      transparent 70%);
  transition: background 400ms var(--easing);
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input { font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

/* =================================================================
   Starfield
   ================================================================= */
#starfield {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* =================================================================
   Layout shell
   ================================================================= */
.app {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px 96px;
}
/* Viewer screen owns its own sticky bottom nav, so the .app padding-bottom
   must not push the page beyond .viewer-shell — otherwise the sticky nav
   (bottom: 0) ends up floating ~96px above the actual page bottom once you
   scroll all the way down. */
.app:has(#screen-viewer.active) { padding-bottom: 0; }
.screen { display: none; }
.screen.active { display: block; }

/* ---- Top bar ---- */
.site-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 32px 28px;
  margin: 0 -32px 8px;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--easing), box-shadow .25s var(--easing);
  isolation: isolate;
}
/* Translucent backdrop, faded at the bottom so it blends into the page wash
   (and any world tint) instead of leaving a hard horizontal edge. */
.site-bar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: -1;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 88%, transparent) 0%,
    color-mix(in srgb, var(--bg) 78%, transparent) 55%,
    color-mix(in srgb, var(--bg) 0%,  transparent) 100%
  );
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  /* Feather only the bottom edge — the bar's blurred backdrop now spans
     100vw so there are no visible left/right edges to worry about. */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 100%);
  pointer-events: none;
}
.site-bar.is-stuck::before {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 94%, transparent) 0%,
    color-mix(in srgb, var(--bg) 84%, transparent) 60%,
    color-mix(in srgb, var(--bg) 0%,  transparent) 100%
  );
}
.site-bar.is-stuck {
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: clamp(30px, 3.2vw, 40px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}
.brand .brand-icon {
  width: clamp(40px, 4.2vw, 52px);
  height: clamp(40px, 4.2vw, 52px);
  object-fit: contain;
  display: block;
}
.brand .brand-text {
  display: inline-flex;
  align-items: baseline;
}
.brand .b-get,
.brand .b-plain { color: var(--text); }
.brand .b-x {
  background: linear-gradient(180deg, #7B4DFF 0%, #AA8AFF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0 1px;
}
.brand .b-dot { color: #F5A623; }
.brand .b-ai {
  background: linear-gradient(180deg, #F5A623 0%, #FFD700 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* legacy fallback if any markup still uses .dot */
.brand .dot { color: #F5A623; }

.site-nav {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-muted);
}
@media (min-width: 900px) { .site-nav { display: inline-flex; } }
.site-nav a { padding: 10px 14px; border-radius: 999px; transition: color .15s, background .15s; }
.site-nav a:hover { color: var(--text); background: var(--card-hover); }
.site-nav a.active { color: var(--text); background: var(--card-fill-strong); }

.site-bar-tail { display: inline-flex; align-items: center; gap: 10px; }
@media (min-width: 900px) { .site-bar-tail { margin-left: 8px; } }
@media (max-width: 899px) { .site-bar-tail { margin-left: auto; } }

/* ---- Breadcrumb (path trail) ---- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 14px 0 36px;
  font-family: var(--font-h);
  line-height: 1.2;
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  max-width: 22ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s var(--easing);
}
.crumb:hover {
  color: var(--text);
}
.crumb:hover .crumb-label {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
}
.crumb:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
  color: var(--text);
}
.crumb i {
  width: 13px;
  height: 13px;
  color: var(--purple-light);
  opacity: 0.85;
  flex: 0 0 auto;
}
.crumb-sep {
  width: 12px;
  height: 12px;
  opacity: 0.4;
  color: var(--text-muted);
  flex: 0 0 auto;
  margin: 0 -1px;
}
/* Match the unified `.is-current` selector used by the Jinja
   breadcrumb macro on SSR pages; keep the legacy `.current`
   class working too for any older cached scripts. */
.crumb.is-current,
.crumb.current {
  color: var(--text);
  font-family: var(--font-h);
  font-weight: 800;
  max-width: 60ch;
  background: linear-gradient(135deg, #7B4DFF 0%, #3B82F6 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          text-fill-color: transparent;
}
.crumb.is-current i,
.crumb.current i {
  color: #F5A623;
  opacity: 1;
}
.crumb.is-current:hover .crumb-label,
.crumb.current:hover .crumb-label {
  background-image: linear-gradient(135deg, #7B4DFF 0%, #3B82F6 100%);
  background-size: 100% 1px;
}
@media (max-width: 720px) {
  .crumbs {
    flex-wrap: nowrap;
    gap: 4px 6px;
    margin: 12px 0 22px;
    min-width: 0;
  }
  .crumb {
    font-size: 12.5px;
    padding: 2px 2px;
    max-width: none;
    min-width: 0;
    flex: 0 1 auto;
  }
  .crumb i { width: 12px; height: 12px; }
  .crumb-sep { width: 11px; height: 11px; }
}

/* =================================================================
   Intro — hero row
   ================================================================= */
.intro-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  margin-bottom: 56px;
}
@media (min-width: 900px) {
  .intro-hero { grid-template-columns: 1.05fr 1fr; align-items: center; gap: 56px; }
}

.hero-image-wrap {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  box-shadow:
    0 20px 60px rgba(13,8,38,0.4),
    0 14px 40px rgba(var(--world-color-rgb), 0.18);
}
.hero-image-wrap img { width: 100%; height: auto; display: block; }

.hero-title {
  margin: 0 0 18px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: clamp(34px, 3.8vw, 54px);
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.01em;
}
.hero-summary {
  margin: 0 0 26px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 62ch;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.meta-row .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  line-height: 1;
}
.meta-row .meta-item i { width: 16px; height: 16px; color: currentColor; }
.meta-row .meta-item.world {
  background: rgba(var(--world-color-rgb), 0.18);
  color: var(--world-color-light);
  border-color: rgba(var(--world-color-rgb), 0.35);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 14px;
}
.meta-row .meta-item.ages {
  background: rgba(59,130,246,0.15);
  color: var(--blue);
  border-color: rgba(59,130,246,0.30);
}
.meta-row .meta-item.time {
  background: rgba(245,166,35,0.15);
  color: var(--orange);
  border-color: rgba(245,166,35,0.30);
}
.meta-row .meta-item.lang {
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border-color: rgba(16,185,129,0.30);
}

/* =================================================================
   Intro — difficulty row
   ================================================================= */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 24px;
  color: var(--text);
}
.section-hint { font-size: 14.5px; color: var(--text-muted); }

.difficulty-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 56px;
}
@media (min-width: 700px) { .difficulty-row { grid-template-columns: repeat(3, 1fr); } }

.diff-card {
  position: relative;
  padding: 22px 22px 20px;
  border-radius: var(--radius-lg);
  background: var(--card-fill);
  border: 1.5px solid var(--card-border);
  cursor: pointer;
  text-align: left;
  transition: transform .15s var(--easing), border-color .2s, background .2s, box-shadow .2s;
}
.diff-card:hover { border-color: var(--card-border-hover); background: var(--card-hover); transform: translateY(-2px); }
.diff-card.selected {
  box-shadow:
    0 0 0 2px var(--accent, var(--purple)) inset,
    0 14px 34px rgba(var(--world-color-rgb), 0.18);
  background: var(--card-fill-strong);
}
.diff-card[data-diff="easy"]   { --accent: #10B981; }
.diff-card[data-diff="medium"] { --accent: #F5A623; }
.diff-card[data-diff="hard"]   { --accent: #FF4B5C; }
.diff-card.selected[data-diff="easy"]   { border-color: #10B981; }
.diff-card.selected[data-diff="medium"] { border-color: #F5A623; }
.diff-card.selected[data-diff="hard"]   { border-color: #FF4B5C; }

.diff-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.diff-head .icon-puck {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.diff-head .icon-puck i { width: 22px; height: 22px; }
.diff-head .diff-label {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
}
.diff-blurb {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 6px 0 14px;
}
.diff-meta {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: center;
}
.diff-meta .dot { opacity: 0.5; }

/* =================================================================
   Intro — two-col: learn + details
   ================================================================= */
.intro-dual {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin-bottom: 72px;
}
@media (min-width: 900px) {
  .intro-dual { grid-template-columns: 1.1fr 1fr; gap: 32px; }
}

.panel {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 26px;
  backdrop-filter: blur(12px);
}
.panel .section-title { margin-bottom: 16px; }

.learn-list { display: flex; flex-direction: column; gap: 2px; }
.learn-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--card-border);
}
.learn-row:last-child { border-bottom: 0; }
.learn-row .num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--purple) 14%, transparent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-b);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.learn-row .body {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.learn-row.more .num { background: transparent; color: var(--orange); font-weight: 800; }
.learn-row.more .body { color: var(--text-muted); font-weight: 500; }

.details-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.detail-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--card-border);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .icon-puck {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.detail-row .icon-puck i { width: 20px; height: 20px; }
.detail-row .label { flex: 1; font-size: 16px; color: var(--text-muted); font-weight: 500; }
.detail-row .value { font-family: var(--font-h); font-size: 17px; font-weight: 700; color: var(--text); }
.detail-row[data-c="blue"] .icon-puck   { background: rgba(59,130,246,.14);  color: var(--blue); }
.detail-row[data-c="orange"] .icon-puck { background: rgba(245,166,35,.14);  color: var(--orange); }
.detail-row[data-c="green"] .icon-puck  { background: rgba(16,185,129,.14);  color: var(--green); }
.detail-row[data-c="magenta"] .icon-puck{ background: rgba(156,44,107,.14);  color: var(--magenta); }

/* =================================================================
   Buttons
   ================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  padding: 0 24px;
  border-radius: var(--radius-lg);
  font-family: var(--font-b);
  font-weight: 700;
  font-size: 17px;
  transition: transform .12s var(--easing), box-shadow .18s, background .18s, color .18s, border-color .18s;
  cursor: pointer;
  width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn i { width: 20px; height: 20px; }

.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: #2A1B02;
  box-shadow: 0 10px 28px rgba(245,166,35,0.35);
  font-weight: 800;
}
.btn-primary:hover { box-shadow: 0 14px 34px rgba(245,166,35,0.5); }
.btn.compact { height: 44px; font-size: 14.5px; padding: 0 16px; }

.btn-purple {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff;
  box-shadow: 0 10px 26px rgba(123,77,255,0.38);
  font-weight: 700;
}
.btn-purple:hover { box-shadow: 0 14px 32px rgba(123,77,255,0.5); }

.btn-accent-purple {
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  box-shadow: 0 8px 20px rgba(123,77,255,0.32);
  font-weight: 700;
}
.btn-accent-purple:hover { box-shadow: 0 12px 28px rgba(123,77,255,0.48); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--card-border-hover);
}
.btn-outline:hover { background: var(--card-hover); border-color: var(--card-border-hover); }
.btn-outline:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--card-hover); }

.btn.fit { width: auto; min-width: 160px; }

/* =================================================================
   Intro — continue exploring
   ================================================================= */
.explore-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 700px) { .explore-grid { grid-template-columns: repeat(3, 1fr); } }
.explore-card {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s var(--easing), border-color .2s, background .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}
.explore-card:focus-visible {
  outline: 2px solid var(--card-world, var(--primary));
  outline-offset: 3px;
}
.explore-card:hover { transform: translateY(-2px); border-color: var(--card-border-hover); background: var(--card-hover); box-shadow: 0 14px 36px rgba(123,77,255,.12); }
.explore-card .ec-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--card-hover);
  overflow: hidden;
}
.explore-card .ec-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s var(--easing);
}
.explore-card:hover .ec-image img { transform: scale(1.04); }
.explore-card .ec-image .ec-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.explore-card .ec-body { padding: 22px; display: flex; flex-direction: column; flex: 1; }
.explore-card .ec-world {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  background: rgba(var(--card-world-rgb, var(--world-color-rgb)), 0.18);
  color: var(--card-world-light, var(--world-color-light));
  border: 1px solid rgba(var(--card-world-rgb, var(--world-color-rgb)), 0.35);
}
.explore-card .ec-world i { width: 14px; height: 14px; color: currentColor; }
.explore-card .ec-title {
  margin: 10px 0 14px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 19px;
  line-height: 1.3;
  color: var(--text);
}
.explore-card .ec-diffs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.ec-diff-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ec-diff-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-b);
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.ec-diff-chip i { width: 13px; height: 13px; }
.ec-diff-chip.easy   { background: rgba(16,185,129,0.15); color: var(--green);  border-color: rgba(16,185,129,0.3); }
.ec-diff-chip.medium { background: rgba(245,166,35,0.15); color: var(--orange); border-color: rgba(245,166,35,0.3); }
.ec-diff-chip.hard   { background: rgba(255,75,92,0.15);  color: var(--coral);  border-color: rgba(255,75,92,0.3); }
.ec-diff-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-b);
}
.ec-diff-meta .dot { color: var(--text-muted); opacity: 0.6; }
.ec-diff-meta .xp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--orange);
  font-weight: 700;
}
.ec-diff-meta .xp i { width: 11px; height: 11px; }

/* =================================================================
   Viewer — desktop grid
   ================================================================= */
.viewer-shell {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background .2s var(--easing), color .2s, transform .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--card-hover); }
.icon-btn.muted { color: var(--text-muted); }
.icon-btn.accent-orange { color: var(--orange); }
.icon-btn i { width: 22px; height: 22px; }

/* Viewer header (step meta + segmented progress) */
.viewer-header { padding: 0 4px 6px; }
.step-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 2px 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.step-header .sh-label { flex-shrink: 0; }
.step-header .sh-track { flex: 1; display: flex; gap: 4px; height: 8px; min-width: 120px; }
.step-header .sh-seg { flex: 1; background: color-mix(in srgb, var(--text) 10%, transparent); border-radius: 4px; transition: background .3s var(--easing); }
.step-header .sh-seg.current { background: var(--purple); }
.step-header .sh-seg.completed { background: var(--green); }
.step-header .xp-pill-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--orange);
  font-weight: 800;
  flex-shrink: 0;
}
.step-header .xp-pill-inline i { width: 16px; height: 16px; }

.viewer-lesson-title {
  padding: 12px 2px 4px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 21px;
  line-height: 1.3;
  color: var(--text);
}

/* The grid that powers the desktop split */
.viewer-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: 1fr;
  align-items: start;
  flex: 1;
}
@media (min-width: 960px) {
  .viewer-grid { grid-template-columns: minmax(0, 1fr) 340px; }
}

.viewer-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.viewer-side { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 960px) { .viewer-side { position: sticky; top: 20px; } }

/* Mobile: lift the bottom nav out of the grid so the Answer/Next button
   appears immediately after the step content, before the sidebar. */
@media (max-width: 959px) {
  .viewer-grid { display: contents; }
  .viewer-main { order: 1; }
  .viewer-nav  { order: 2; }
  .viewer-side { order: 3; margin-top: 16px; }
}

.card-anim-enter      { animation: slideIn .35s var(--easing); }
.card-anim-enter-back { animation: slideInBack .35s var(--easing); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInBack {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.glass-card {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.content-card, .assessment-card, .recap-card {
  position: relative;
  padding: 28px;
}

.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-b);
  font-weight: 700;
  font-size: 13.5px;
}
.pill i { width: 13px; height: 13px; }
.pill.step     { background: var(--chip-bg); color: var(--text); border: 1px solid var(--card-border); }
.pill.xp       { background: rgba(245,166,35,0.14); color: var(--orange); border: 1px solid rgba(245,166,35,0.24); }
.pill.question { background: rgba(123,77,255,0.14); color: var(--purple-light); border: 1px solid rgba(123,77,255,0.28); }
.pill.step-out { background: transparent; color: var(--text-muted); font-weight: 600; padding: 4px 0; }

.sub-title {
  margin: 0 0 10px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 28px;
  line-height: 1.25;
  color: var(--text);
}
.sub-summary {
  margin: 0 0 18px;
  font-size: 17.5px;
  line-height: 1.55;
  font-weight: 500;
  color: var(--text-soft);
}
.sub-image {
  margin: 8px 0 18px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card-fill);
  border: 1px solid var(--card-border);
}
.sub-image img { width: 100%; height: auto; display: block; }

.content-fig {
  margin: 0 0 22px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--card-fill);
}
.content-fig img { width: 100%; height: auto; display: block; }

.sub-content {
  font-size: 18px;
  line-height: 1.78;
  color: var(--text);
  opacity: 0.94;
  white-space: pre-wrap;
}

/* Assessment */
.question-text {
  margin: 0 0 22px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 23px;
  line-height: 1.35;
  color: var(--text);
}
.choices { display: flex; flex-direction: column; gap: 12px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--card-border);
  background: var(--card-fill);
  cursor: pointer;
  text-align: left;
  transition: background .2s, border-color .2s, transform .15s;
  outline-offset: 2px;
}
.choice:focus-visible { outline: 2px solid var(--purple); }
.choice:hover:not(:disabled) { background: var(--card-hover); border-color: var(--card-border-hover); }
.choice:disabled { cursor: not-allowed; }
.choice .letter {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(123,77,255,0.12);
  color: var(--purple);
  font-family: var(--font-b);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.choice .body {
  flex: 1;
  font-size: 16.5px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--text);
}
.choice .trailing { width: 20px; height: 20px; display: none; }

.choice.correct { background: rgba(16,185,129,0.10); border-color: rgba(16,185,129,0.45); }
.choice.correct .letter { background: rgba(16,185,129,0.2); color: var(--green); }
.choice.correct .body { color: var(--green); font-weight: 700; }
.choice.correct .trailing { display: inline-block; color: var(--green); }

.choice.wrong { background: rgba(255,75,92,0.08); border-color: rgba(255,75,92,0.35); animation: shake .4s var(--easing); }
.choice.wrong .letter { background: rgba(255,75,92,0.15); color: var(--coral); }
.choice.wrong .body { color: color-mix(in srgb, var(--text-muted) 80%, transparent); }
.choice.wrong .trailing { display: inline-block; color: var(--coral); }

@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-8px); }
  40%  { transform: translateX(8px); }
  60%  { transform: translateX(-6px); }
  80%  { transform: translateX(6px); }
  100% { transform: translateX(0); }
}

.feedback-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  font-weight: 600;
}
.feedback-banner i { width: 18px; height: 18px; flex-shrink: 0; }
.feedback-banner.error   { background: rgba(255,75,92,0.1); border: 1px solid rgba(255,75,92,0.25); color: var(--coral); }
.feedback-banner.success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: var(--green); }

/* Split assessment.
   DOM order is question-first so mobile readers get the call-to-action
   immediately. On wide viewports we use grid `order` to flip the columns
   back to the conventional "context on the left, action on the right". */
.assessment-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 1100px) {
  .assessment-split { grid-template-columns: 1fr 1fr; gap: 24px; }
  .assessment-split > .recap-card      { order: 1; }
  .assessment-split > .assessment-card { order: 2; }
}

/* "Tap your answer below" CTA on the assessment card */
.answer-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(123,77,255,0.12);
  color: var(--purple-light);
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(123,77,255,0.28);
  animation: cta-pulse 2.4s var(--easing) infinite;
}
.answer-cta i { width: 14px; height: 14px; }
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123,77,255,0.28); }
  50%      { box-shadow: 0 0 0 8px rgba(123,77,255,0); }
}
@media (prefers-reduced-motion: reduce) {
  .answer-cta { animation: none; }
}
/* Once the question is answered, the prompt is no longer relevant. */
.assessment-card:has(.choice.correct, .choice.wrong) .answer-cta { display: none; }
.recap-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
}
.recap-card p.recap-summary {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-soft);
}
.recap-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  opacity: 0.9;
  position: relative;
  overflow: hidden;
}
.recap-body.collapsed {
  max-height: 240px;
  mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
}
.recap-toggle {
  margin-top: 12px;
  background: transparent;
  color: var(--purple);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.recap-toggle:hover { background: var(--card-hover); }
.recap-toggle i { width: 14px; height: 14px; }

/* Bottom nav */
.viewer-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px calc(18px + env(safe-area-inset-bottom));
  background: var(--nav-bg-2);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-border);
  margin: 16px -28px 0;
  z-index: 3;
}
@media (max-width: 600px) {
  .viewer-nav { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); margin: 12px -18px 0; }
}
.viewer-nav .kbd-hint {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: auto;
  flex: 1;
}
@media (min-width: 900px) { .viewer-nav .kbd-hint { display: inline-flex; } }
.viewer-nav .kbd-hint kbd {
  font-family: var(--font-b);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card-fill-strong);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.viewer-nav .nav-actions { display: flex; gap: 12px; margin-left: auto; }
.viewer-nav .nav-actions .btn { width: auto; min-width: 160px; }
@media (max-width: 899px) {
  .viewer-nav { gap: 10px; }
  .viewer-nav .nav-actions { flex: 1; margin-left: 0; }
  .viewer-nav .nav-actions .btn { flex: 1; min-width: 0; }
}

/* =================================================================
   Sidebar components
   ================================================================= */
.side-card {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 18px;
  backdrop-filter: blur(12px);
}
.side-card .side-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.side-card .side-title i { width: 16px; height: 16px; color: var(--purple-light); }
/* Progress stepper */
.step-list { display: flex; flex-direction: column; gap: 2px; }
.step-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.step-row:hover:not(.upcoming) { background: var(--card-hover); }
.step-row.current {
  background: var(--card-fill-strong);
  border-color: var(--card-border);
  box-shadow: inset 3px 0 0 var(--purple);
}
.step-row.upcoming { opacity: 0.55; cursor: default; }
.step-row .num {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
  font-family: var(--font-b);
  font-weight: 800;
  font-size: 12.5px;
  flex-shrink: 0;
}
.step-row.done .num  { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }
.step-row.failed .num{ background: color-mix(in srgb, var(--coral) 22%, transparent); color: var(--coral); }
.step-row.current .num { background: var(--purple); color: #fff; }
.step-row .txt {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.step-row.upcoming .txt { color: var(--text-muted); font-weight: 500; }
.step-row .mark { width: 16px; height: 16px; flex-shrink: 0; }
.step-row.done .mark   { color: var(--green); }
.step-row.failed .mark { color: var(--coral); }
.step-row.current .mark { color: var(--purple); }
.step-row.upcoming .mark { color: var(--text-muted); opacity: 0.55; }

/* XP meter */
.xp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.xp-head .xp-big {
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 26px;
  color: var(--orange);
}
.xp-head .xp-total { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.xp-meter {
  height: 10px;
  border-radius: 5px;
  background: var(--card-border);
  overflow: hidden;
}
.xp-meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-light));
  border-radius: 5px;
  transition: width .35s var(--easing);
}
.xp-next {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.xp-next i { width: 14px; height: 14px; color: var(--orange); }
.xp-next strong { color: var(--orange); font-weight: 800; }

/* Tip card */
.tip-card {
  background: linear-gradient(180deg, rgba(123,77,255,0.08), rgba(245,166,35,0.04));
  border: 1px solid var(--card-border);
}
.tip-card .tip-body {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-soft);
}

/* Info card */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 14px;
  border-bottom: 1px dashed var(--card-border);
}
.info-row:last-child { border-bottom: 0; }
.info-row .label { color: var(--text-muted); font-weight: 500; }
.info-row .value {
  color: var(--text);
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.info-row .value i { width: 14px; height: 14px; color: var(--purple-light); }
/* =================================================================
   Celebration overlay
   ================================================================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .2s var(--easing);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.celebration {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  position: relative; z-index: 2; pointer-events: none;
}
.celebration .medal {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green), var(--green-light));
  box-shadow: 0 0 30px 6px rgba(16,185,129,0.42);
  color: #fff;
  animation: medalPop .6s cubic-bezier(.2,1.4,.4,1);
}
.celebration .medal i { width: 52px; height: 52px; stroke-width: 3; }
.celebration.loss .medal {
  background: linear-gradient(135deg, var(--orange), var(--coral));
  box-shadow: 0 0 30px 6px rgba(255,75,92,0.4);
}
@keyframes medalPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.celebration .xp-big {
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 52px;
  animation: xpIn .5s var(--easing) backwards;
  animation-delay: .2s;
}
.celebration.win .xp-big {
  background: linear-gradient(90deg, var(--orange), #FFE066, var(--orange));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: xpIn .5s var(--easing) backwards, shimmer 2s linear infinite;
}
.celebration.loss .xp-big { color: var(--coral); }
@keyframes xpIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.celebration .msg {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
}

.particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.particle {
  position: absolute;
  left: 50%; top: 50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  opacity: 0;
  will-change: transform, opacity;
}
.particle.burst { animation: burst 1.2s var(--easing) forwards; }
.particle.fall { top: 30%; animation: fall 1.2s ease-in forwards; }
@keyframes burst {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3); opacity: 0; }
}
@keyframes fall {
  0%   { transform: translate(-50%, 0) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%, var(--dy)) scale(0.7); opacity: 0; }
}

/* =================================================================
   Modals
   ================================================================= */
.overlay.overlay-modal { background: rgba(7, 4, 26, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
/* Image lightbox: click any .zoomable image to open and zoom/pan. */
img.zoomable { cursor: zoom-in; transition: filter .2s var(--easing); }
img.zoomable:hover { filter: brightness(1.05); }

.lightbox-overlay {
  position: fixed; inset: 0;
  z-index: 250;
  display: flex; flex-direction: column;
  background: rgba(2, 0, 14, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: fadeIn .2s var(--easing);
  touch-action: none;
  user-select: none;
}
.lightbox-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
}
.lightbox-stage.is-panning { cursor: grabbing; }
.lightbox-img {
  max-width: 92vw;
  max-height: calc(100vh - 120px);
  width: auto; height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  transform-origin: 0 0;
  transition: transform .18s var(--easing);
  will-change: transform;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  border-radius: 10px;
}
.lightbox-img.no-anim { transition: none; }
.lightbox-toolbar {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex; gap: 8px;
  z-index: 2;
}
.lightbox-toolbar .icon-btn {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.lightbox-toolbar .icon-btn:hover { background: rgba(255,255,255,0.18); }
.lightbox-toolbar .icon-btn i { width: 20px; height: 20px; }
.lightbox-caption {
  color: rgba(255,255,255,0.82);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  padding: 10px 24px calc(10px + env(safe-area-inset-bottom));
  max-width: 92vw;
  margin: 0 auto;
}
.lightbox-hint {
  position: absolute;
  left: 16px; bottom: calc(12px + env(safe-area-inset-bottom));
  color: rgba(255,255,255,0.55);
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
  flex-wrap: wrap;
}
.lightbox-hint kbd {
  font-family: var(--font-b);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
@media (max-width: 720px) { .lightbox-hint { display: none; } }

.modal-card {
  position: relative;
  width: min(460px, 92vw);
  background: #1A1440;
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(245,166,35,0.14), transparent 60%),
    linear-gradient(180deg, #1E1748 0%, #14102F 100%);
  border: 1px solid rgba(245,166,35,0.30);
  border-radius: var(--radius-2xl);
  padding: 30px;
  text-align: left;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 30px 80px rgba(0,0,0,0.55),
    0 0 60px rgba(245,166,35,0.10);
  animation: modalPop .3s var(--easing);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  margin-bottom: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(245,166,35,0.35), rgba(245,166,35,0.05) 70%);
  color: var(--orange);
  box-shadow: 0 0 40px 4px rgba(245,166,35,0.25);
}
.modal-icon.purple { background: radial-gradient(circle, rgba(123,77,255,0.35), rgba(123,77,255,0.05) 70%); color: var(--purple-light); box-shadow: 0 0 40px 4px rgba(123,77,255,0.25); }
.modal-icon.coral  { background: radial-gradient(circle, rgba(255,75,92,0.35),  rgba(255,75,92,0.05) 70%);  color: var(--coral);  box-shadow: 0 0 40px 4px rgba(255,75,92,0.25); }
.modal-icon i { width: 32px; height: 32px; }

.modal-title {
  margin: 0 0 10px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 24px;
  color: var(--text);
}
.modal-body {
  margin: 0 0 22px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-muted);
}
.signup-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: border-color .2s;
}
.signup-field:focus-within { border-color: rgba(245,166,35,0.6); }
.signup-field i { width: 18px; height: 18px; color: var(--text-muted); }
.signup-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
}
.signup-field input::placeholder { color: var(--text-dim); }

.modal-actions {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 16px;
}
.modal-actions.row { flex-direction: row; }
.modal-actions.row .btn { flex: 1; }

/* Keyboard shortcut help */
.kbd-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: center;
}
.kbd-grid .kbd-keys { display: inline-flex; gap: 4px; }
.kbd-grid kbd {
  font-family: var(--font-b);
  font-size: 12.5px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
}
.kbd-grid .kbd-desc { color: var(--text-muted); font-size: 14.5px; }

/* =================================================================
   Completion screen
   ================================================================= */
.completion-shell { padding: 12px 0 80px; }
.completion-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}
@media (min-width: 960px) {
  .completion-grid { grid-template-columns: minmax(0, 1fr) 400px; gap: 48px; }
}
.completion-celebrate { text-align: left; }
@media (max-width: 959px) { .completion-celebrate { text-align: center; } }

.mascot-wrap {
  position: relative;
  width: 220px; height: 220px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 959px) { .mascot-wrap { margin: 0 auto 8px; } }
.mascot-wrap::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(123,77,255,0.28), rgba(123,77,255,0) 70%);
}
.mascot {
  width: 180px; height: 180px;
  object-fit: contain;
  position: relative;
  animation: float 3s ease-in-out infinite;
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
}
@keyframes float {
  0%, 100% { transform: translateY(-4px); }
  50%      { transform: translateY(4px); }
}

.complete-title {
  margin: 24px 0 10px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 44px;
  line-height: 1.1;
  background: linear-gradient(90deg, var(--purple), var(--orange), var(--purple));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: shimmer 3s linear infinite;
}
.complete-sub {
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 0 8px;
}
@media (max-width: 959px) { .complete-sub { margin: 0 auto 8px; } }

.xp-box {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 30px;
  margin: 28px 0 22px;
  border-radius: var(--radius-2xl);
  background: rgba(245,166,35,0.10);
  border: 1px solid rgba(245,166,35,0.30);
}
.xp-box i { width: 28px; height: 28px; color: var(--orange); }
.xp-box .amount {
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 40px;
  color: var(--orange);
}

.chip-row {
  display: flex; gap: 12px;
  margin-bottom: 30px; flex-wrap: wrap;
}
@media (max-width: 959px) { .chip-row { justify-content: center; } }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
}
.chip i { width: 16px; height: 16px; }
.chip.easy   { background: rgba(16,185,129,0.15); color: var(--green);  border: 1px solid rgba(16,185,129,0.3); }
.chip.medium { background: rgba(245,166,35,0.15); color: var(--orange); border: 1px solid rgba(245,166,35,0.3); }
.chip.hard   { background: rgba(255,75,92,0.15);  color: var(--coral);  border: 1px solid rgba(255,75,92,0.3); }
.chip.blue   { background: rgba(59,130,246,0.15); color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }

.signup-card {
  width: 100%;
  padding: 28px;
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
}
.signup-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 22px;
  color: var(--text);
}
.signup-heading i { width: 24px; height: 24px; color: var(--orange); }
.signup-sub {
  margin: 0 0 18px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-muted);
}
.signup-sub strong { color: var(--orange); font-weight: 800; }
.signup-perks { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 4px; }
.signup-perk { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text-muted); }
.signup-perk i { width: 16px; height: 16px; color: var(--green); }

.upnext-card { margin-top: 20px; padding: 22px; }
.upnext-card h4 {
  margin: 0 0 12px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.upnext-list { display: flex; flex-direction: column; gap: 10px; }
.upnext-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--card-hover);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: transform .15s, border-color .2s;
}
.upnext-item:hover { transform: translateX(2px); border-color: var(--card-border-hover); }
.upnext-item .num {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--purple) 15%, transparent);
  color: var(--purple);
}
.upnext-item .num i { width: 18px; height: 18px; }
.upnext-item .u-body { flex: 1; min-width: 0; }
.upnext-item .u-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upnext-item .u-meta {
  font-size: 12.5px; color: var(--text-muted); margin-top: 2px;
}

.completion-actions { margin: 16px 0 0; }
.completion-actions .btn { width: auto; min-width: 240px; }
@media (max-width: 959px) { .completion-actions { text-align: center; } .completion-actions .btn { width: 100%; } }

/* =================================================================
   Loading / error
   ================================================================= */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 60vh;
  color: var(--text-muted);
  font-size: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Small screens trims */
@media (max-width: 720px) {
  /* Keyboard shortcuts only matter on devices with keyboards. */
  #viewerHelpBtn { display: none; }
}
@media (max-width: 600px) {
  .app { padding: 0 18px 72px; }
  .site-bar { padding: 14px 18px 22px; margin: 0 -18px 4px; gap: 8px; }

  /* Compact action buttons + tail to reclaim space for the brand. */
  .site-bar .icon-btn { width: 40px; height: 40px; }
  .site-bar .icon-btn i { width: 20px; height: 20px; }
  .site-bar-tail { gap: 4px; }

  /* Brand: keep the logo prominent and let the wordmark shrink so it
     can never collide with the action buttons. */
  .brand { gap: 8px; min-width: 0; }
  .brand .brand-icon { width: 38px; height: 38px; }
  .brand .brand-text {
    font-size: 22px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  /* In the lesson viewer the tail has 3 buttons (backpack, close, theme),
     which together with the wordmark overflows narrow phones. The lesson
     context lives in the breadcrumb directly underneath, so the wordmark
     is redundant here — hide it and keep just the logo as a home affordance. */
  #screen-viewer .brand .brand-text { display: none; }

  .intro-hero { gap: 24px; margin-bottom: 40px; }
  .intro-dual { margin-bottom: 48px; }
  .hero-title { font-size: 30px; }
  .panel { padding: 20px; }
  .content-card, .assessment-card, .recap-card { padding: 22px; }
  .sub-title { font-size: 24px; }
  .sub-content { font-size: 17px; }
  .question-text { font-size: 21px; }
  .complete-title { font-size: 36px; }
}

/* Knowledge-fuel meter — global golden vertical slider pinned to the
   viewport's right edge so Xplorer's mission progress stays visible
   even while a lesson is being played. Hidden below 1200 px to avoid
   overlapping the player UI. Decorative only. */
.fuel-rail {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: none;
}
@media (min-width: 1200px) {
  .fuel-rail { display: block; }
}
.fuel-rail__side {
  position: fixed;
  top: 112px;
  bottom: 40px;
  right: 24px;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}
@media (min-width: 1440px) {
  .fuel-rail__side { width: 76px; right: 36px; }
}
.fuel-rail__cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5A623, #FFD700);
  color: #2A1700;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 0 0 5px rgba(245, 166, 35, 0.10),
    0 0 28px rgba(245, 166, 35, 0.55),
    inset 0 -3px 8px rgba(0, 0, 0, 0.12);
}
.fuel-rail__cap i { width: 20px; height: 20px; }
.fuel-rail__label {
  font-family: var(--font-h, "Plus Jakarta Sans", sans-serif);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}
.fuel-rail__label--top    { color: #FFB74D; }
.fuel-rail__label--bottom { color: rgba(255, 255, 255, 0.7); }
.fuel-rail__pipe {
  position: relative;
  width: 30px;
  flex: 1 1 auto;
  min-height: 180px;
  border-radius: 999px;
  background:
    linear-gradient(180deg,
      rgba(12, 4, 30, 0.55) 0%,
      rgba(12, 4, 30, 0.35) 100%);
  border: 2px solid rgba(255, 255, 255, 0.10);
  overflow: hidden;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.55),
    inset 0 -2px 8px rgba(255, 255, 255, 0.04),
    0 0 30px rgba(245, 166, 35, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.fuel-rail__pipe::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 74%;
  background:
    linear-gradient(180deg,
      rgba(245, 166, 35, 0.35) 0%,
      rgba(245, 166, 35, 0.85) 45%,
      rgba(255, 183, 77, 1)    100%);
  box-shadow:
    inset 0 0 24px rgba(245, 166, 35, 0.65),
    0 -6px 22px rgba(245, 166, 35, 0.55);
}
