/* EZ AI — Design Tokens v2  ("Pro Dark")
   Audience: 15–18  |  Style: Linear / Vercel / Notion for teens */

:root {
  /* ---- Brand ---- */
  --brand:        #7C3AED;
  --brand-hi:     #A78BFA;
  --brand-dim:    rgba(124,58,237,.15);
  --brand-border: rgba(124,58,237,.35);
  /* Progress / status — not brand CTAs */
  --progress:     var(--cyan);
  --progress-dim: var(--cyan-dim);
  --cyan:         #06B6D4;
  --cyan-dim:     rgba(6,182,212,.12);
  --orange:       #F97316;
  --green:        #10B981;
  --green-dim:    rgba(16,185,129,.12);
  --red:          #EF4444;
  --yellow:       #F59E0B;

  /* ---- Track accents ---- */
  --t-prompt:  #818CF8;
  --t-vibe:    #A78BFA;
  --t-found:   #60A5FA;
  --t-auto:    #22D3EE;
  --t-agents:  #C084FC;
  --t-ml:      #34D399;
  --t-cursor:  #F472B6;
  --t-models:  #FB923C;
  --t-business:#2DD4BF;
  --t-sales-agent: #F59E0B;
  --t-sales-manager: #8B5CF6;
  --t-parent-guardian: #38BDF8;
  --t-parent-coach: #A78BFA;
  --t-parent-home: #34D399;

  /* ---- Surfaces — DARK default ---- */
  --bg:         #0A0A0F;
  --bg-2:       #111118;
  --bg-3:       #18181F;
  --bg-4:       #202028;
  --border:     rgba(255,255,255,.08);
  --border-hi:  rgba(255,255,255,.14);

  /* ---- Text ---- */
  --tx:         #F1F0F5;
  --tx-2:       #9493A8;
  --tx-3:       #5A5970;

  /* ---- Typography ---- */
  --font:       "Heebo", system-ui, -apple-system, sans-serif;
  --font-d:     "Rubik", "Heebo", system-ui, sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, monospace;

  /* ---- Scale ---- */
  --fs-xl:   28px;
  --fs-h1:   22px;
  --fs-h2:   17px;
  --fs-body: 15px;
  --fs-sm:   13px;
  --fs-xs:   11px;

  /* ---- Space ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* ---- Radius ---- */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 18px; --r-full: 999px;

  /* ---- Shadow ---- */
  --sh-card: 0 1px 3px rgba(0,0,0,.4), 0 0 0 1px var(--border);
  --sh-pop:  0 20px 60px rgba(0,0,0,.7);

  /* ---- Motion ---- */
  --ease: cubic-bezier(.22,1,.36,1);
  --dur:  200ms;

  /* ---- Layout ---- */
  --hud-h: 52px;
  --tab-h: 60px;
  --sidebar-w: 220px;
  --nav-w: 220px;
  --nav-rail: 56px;
  --dock-w: 380px;
  --dock-rail: 52px;

  /* ---- App chrome (header + nav + dock) ---- */
  --chrome-bg:     var(--bg-2);
  --chrome-border: var(--border);
}

/* Light override */
:root[data-theme="light"] {
  --bg:        #F8F8FC;
  --bg-2:      #FFFFFF;
  --bg-3:      #F1F0F8;
  --bg-4:      #E8E7F2;
  --border:    rgba(0,0,0,.07);
  --border-hi: rgba(0,0,0,.13);
  --tx:        #18181F;
  --tx-2:      #5A5970;
  --tx-3:      #9493A8;
  --sh-card:   0 1px 3px rgba(0,0,0,.08), 0 0 0 1px var(--border);
  --sh-pop:    0 20px 60px rgba(0,0,0,.18);
  --brand-dim: rgba(124,58,237,.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F8F8FC; --bg-2: #FFFFFF; --bg-3: #F1F0F8; --bg-4: #E8E7F2;
    --border: rgba(0,0,0,.07); --border-hi: rgba(0,0,0,.13);
    --tx: #18181F; --tx-2: #5A5970; --tx-3: #9493A8;
    --sh-card: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px var(--border);
    --sh-pop: 0 20px 60px rgba(0,0,0,.18);
    --brand-dim: rgba(124,58,237,.08);
  }
}

/* EZ AI — App styles v2  (mature / pro / Linear-inspired)
   RTL-native, mobile-first, then tablet → desktop               */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--tx);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ltr-inline {
  direction: ltr;
  unicode-bidi: embed;
  display: inline;
  white-space: pre-wrap;
}

/* ===================================================================
   SVG icon system
   =================================================================== */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  display: inline-block; vertical-align: middle;
}
.ic-xs { width: 14px; height: 14px; }
.ic-sm { width: 16px; height: 16px; }
.ic-md { width: 20px; height: 20px; }
.ic-lg { width: 24px; height: 24px; }
.ic-xl { width: 32px; height: 32px; }

/* ===================================================================
   App shell
   =================================================================== */
.app {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===================================================================
   HUD (top bar) — slim, professional
   =================================================================== */
.hud {
  height: var(--hud-h);
  min-height: var(--hud-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s5);
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  z-index: 30;
  box-sizing: border-box;
}

.hud-stat {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font); font-weight: 500; font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--tx-3);
}
.hud-stat .ic { opacity: .5; color: var(--tx-3); }
.hud-stat .val { color: var(--tx-2); font-weight: 600; }
.hud-stat.fire .val,
.hud-stat.coins .val { color: var(--tx-2); }
.hud-plan {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx-3);
  flex: 0 0 auto;
}

.hud-xp {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.hud-xp .row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--tx-3); font-weight: 500;
  letter-spacing: .01em;
}
.hud-gem-icon { vertical-align: middle; margin-right: 3px; border-radius: 3px; object-fit: cover; }
.hud-epithet {
  font-size: 10px;
  font-weight: 600;
  color: var(--tx-2);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.hud-epithet:not([hidden]) { display: block; }
.xpbar {
  height: 3px; border-radius: var(--r-full);
  background: var(--bg-4);
}
.xpbar > i {
  display: block; height: 100%; width: 62%;
  background: var(--progress);
  opacity: .85;
  border-radius: var(--r-full);
  transition: width var(--dur) var(--ease);
}

.hud-avatar {
  width: 28px; height: 28px; flex: 0 0 auto;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-4); color: var(--tx-2);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--dur); overflow: hidden; padding: 0;
}
.hud-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.hud-avatar:hover { border-color: var(--border-hi); color: var(--tx); }
.hud-avatar.active {
  border-color: var(--border-hi);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tx) 12%, transparent);
}

/* ===================================================================
   Screens container
   =================================================================== */
.screens { position: relative; flex: 1; overflow: hidden; }
.screen {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--s6) var(--s5) calc(var(--tab-h) + var(--bc-space, 0px) + var(--s6));
  opacity: 0; visibility: hidden;
  transform: translateY(6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
  z-index: 1;
}
.screen.active { opacity: 1; visibility: visible; transform: none; pointer-events: auto; z-index: 2; }

.page-head { margin-bottom: var(--s6); }
.page-head h1 {
  font-family: var(--font); font-weight: 600;
  font-size: var(--fs-h1); letter-spacing: -.02em;
  color: var(--tx);
}
.page-head p { font-size: var(--fs-sm); color: var(--tx-2); margin-top: 3px; }
.page-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3) var(--s4);
}
.learn-audio-pref {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--tx-2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-2);
  cursor: pointer;
  user-select: none;
}
.learn-audio-pref input { accent-color: var(--brand); }
.profile-setting-toggle { cursor: pointer; }
.profile-setting-toggle input { accent-color: var(--brand); }
.lesson-audio-autoplay-btn[aria-pressed="true"] {
  color: var(--brand-hi);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  background: color-mix(in srgb, var(--brand) 12%, var(--bg-2));
}

/* ===================================================================
   Track badge (world header)
   =================================================================== */
.track-badge {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s4);
  background: var(--brand-dim);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s5);
}
.track-badge .icon {
  width: 38px; height: 38px; border-radius: var(--r);
  background: var(--brand); color: #fff;
  display: grid; place-items: center; flex: 0 0 auto;
}
.track-badge h3 { font-weight: 700; font-size: var(--fs-h2); }
.track-badge p { font-size: var(--fs-sm); color: var(--tx-2); }
.track-badge .pill {
  margin-inline-start: auto; flex: 0 0 auto;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--bg-4); color: var(--tx-2);
  white-space: nowrap;
}

/* ===================================================================
   Path — clean vertical timeline (not bubbly nodes)
   =================================================================== */
.path { position: relative; display: flex; flex-direction: column-reverse; gap: 0; }

.path-item {
  position: relative;
  display: flex; align-items: stretch; gap: var(--s3);
  padding-bottom: var(--s2);
}

/* connector line */
.path-item:not(:last-child) .pi-line { display: block; }
.pi-line {
  display: none;
  position: absolute;
  inset-inline-start: 19px;
  top: 40px; bottom: 0;
  width: 2px;
  background: var(--border);
  z-index: 0;
}
.path-item.done .pi-line { background: var(--brand-dim); }

/* left column: step indicator */
.pi-step {
  position: relative; z-index: 1; flex: 0 0 auto;
  width: 40px; display: flex; flex-direction: column; align-items: center;
  padding-top: 10px;
}
.pi-dot {
  width: 22px; height: 22px; border-radius: var(--r-full);
  display: grid; place-items: center;
  border: 2px solid var(--border);
  background: var(--bg-2);
  color: var(--tx-3);
  transition: all var(--dur) var(--ease);
}
.path-item.done .pi-dot {
  background: var(--brand-dim); border-color: var(--brand);
  color: var(--brand-hi);
}
.path-item.current .pi-dot {
  background: var(--brand); border-color: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-dim);
}
.path-item.locked .pi-dot { opacity: .4; }

/* right column: card */
.pi-card {
  flex: 1; min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
  margin-bottom: var(--s2);
}
.pi-card:hover:not(.locked-card) {
  border-color: var(--border-hi);
  background: var(--bg-3);
}
.path-item.current .pi-card {
  border-color: var(--brand-border);
  background: var(--brand-dim);
}
.path-item.locked .pi-card { cursor: not-allowed; opacity: .5; }
.path-item.flag .pi-card {
  border-style: dashed; opacity: .6;
}

.pi-row { display: flex; align-items: center; gap: var(--s2); }
.pi-icon { width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--bg-4); color: var(--tx-2); flex: 0 0 auto; }
.path-item.done .pi-icon { color: var(--brand-hi); background: var(--brand-dim); }
.path-item.current .pi-icon { color: #fff; background: var(--brand); }

.pi-meta { flex: 1; min-width: 0; }
.pi-title { font-weight: 600; font-size: var(--fs-body); color: var(--tx); }
.pi-sub { font-size: var(--fs-xs); color: var(--tx-2); margin-top: 2px; }

.pi-badge {
  margin-inline-start: auto; flex: 0 0 auto;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-full); white-space: nowrap;
}
.badge-done    { background: var(--green-dim); color: var(--green); }
.badge-current { background: var(--brand-dim); color: var(--brand-hi); border: 1px solid var(--brand-border); }
.badge-locked  { background: var(--bg-4); color: var(--tx-3); }
.badge-xp      { background: transparent; color: var(--yellow); border: 1px solid rgba(245,158,11,.3); }

/* ===================================================================
   Cards (generic)
   =================================================================== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}
.card + .card { margin-top: var(--s2); }

/* project card */
.proj {
  overflow: hidden; display: flex; flex-direction: column;
  padding: 0;
}
.proj .thumb {
  height: 120px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--cyan) 100%);
  display: grid; place-items: center; color: #fff; position: relative;
}
.live-badge {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  color: #fff; font-size: var(--fs-xs); font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; gap: 5px;
}
.live-badge .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  animation: live 1.6s infinite;
}
@keyframes live { 70%,100% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
.proj .body { padding: var(--s4); }
.proj h4 { font-weight: 600; font-size: var(--fs-body); }
.proj .url { font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--tx-2); margin-top: 4px; }

/* list row (tools, settings) */
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); cursor: pointer;
  border-bottom: 1px solid var(--border); position: relative;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-3); }
.list-row .row-icon {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--bg-4); color: var(--tx-2);
}
.list-row .row-icon--asset img {
  width: 22px; height: 22px; object-fit: contain; display: block;
}
.list-row .row-label { flex: 1; font-weight: 500; }
.list-row .row-sub { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 1px; }
.list-row .row-end { color: var(--tx-3); }
.list-row .lock-chip {
  font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg-4); color: var(--tx-3);
}
.list-row .active-chip {
  font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-full);
  background: var(--brand-dim); color: var(--brand-hi);
  border: 1px solid var(--brand-border);
}
.list-row .done-chip {
  font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-full);
  background: rgba(16,185,129,.12); color: var(--green);
  border: 1px solid rgba(16,185,129,.3);
  display: inline-flex; align-items: center; gap: 4px;
}

/* ── Learn tab (curriculum matrix) ── */
.learn-root { display: flex; flex-direction: column; gap: var(--s4); }
.learn-root:has(.lib-mount--open) .lib-bar,
.learn-root:has(.lib-mount--open) #libResults { display: none; }
.learn-root:has(.lib-mount--open) { gap: var(--s2); }
.learn-loading { padding: var(--s5); text-align: center; color: var(--tx-2); }

/* Rank card — unified grade + skill XP */
.learn-rank {
  padding: 0;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(124,58,237,.14) 0%, rgba(6,182,212,.06) 42%, var(--bg-2) 100%);
  border-color: rgba(124,58,237,.22);
}
.learn-rank-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
}
.learn-rank-kicker {
  display: block;
  font-size: var(--fs-xs); font-weight: 800; color: var(--brand-hi);
  letter-spacing: .08em; text-transform: uppercase;
}
.learn-rank-title { font-family: var(--font-h); font-size: var(--fs-h1); margin: 4px 0 2px; line-height: 1.15; }
.learn-rank-sub { font-size: var(--fs-sm); color: var(--tx-2); margin: 0; }
.learn-rank-level {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-h1);
  background: var(--bg-3); border: 2px solid var(--brand-hi);
  box-shadow: 0 0 24px rgba(167,139,250,.28);
}
.learn-rank-xp { padding: 0 var(--s4) var(--s3); }
.learn-rank-xp-labels {
  display: flex; justify-content: space-between; gap: var(--s2);
  font-size: var(--fs-xs); color: var(--tx-2); margin-bottom: var(--s1);
}
.learn-rank-xp-now { font-weight: 700; color: var(--tx); }
.learn-rank-xp-next { text-align: end; }
.learn-rank-xp-bar {
  height: 8px; border-radius: var(--r-full); background: var(--bg-4); overflow: hidden;
}
.learn-rank-xp-bar i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  transition: width .35s ease;
}
.learn-rank-skills {
  padding: var(--s3) var(--s4) var(--s4);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}
.learn-rank-skills-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  margin-bottom: var(--s2);
}
.learn-rank-skills-label { font-size: var(--fs-sm); font-weight: 700; color: var(--tx-2); }
.learn-rank-skills-primary,
.learn-rank-skills-extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2);
}
.learn-rank-skills-extra.is-collapsed { display: none; }
.learn-rank-skill {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px var(--s2);
  align-items: center;
  padding: var(--s2) var(--s3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  border-inline-start: 3px solid var(--skill-color, var(--brand));
}
.learn-rank-skill-icon,
.learn-rank-skill-dot {
  grid-row: 1 / span 2;
  width: 18px; height: 18px; border-radius: 4px; object-fit: cover;
}
.learn-rank-skill-dot { display: block; }
.learn-rank-skill-name {
  font-size: 11px; font-weight: 600; color: var(--tx-2);
  line-height: 1.2; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.learn-rank-skill-bar {
  grid-column: 2;
  height: 4px; border-radius: var(--r-full); background: var(--bg-4); overflow: hidden;
}
.learn-rank-skill-bar i {
  display: block; height: 100%; border-radius: inherit;
  background: var(--skill-color, var(--brand));
  opacity: .85;
}
.learn-rank-skill-val {
  grid-row: 1 / span 2; grid-column: 3;
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm);
}
.learn-rank-mastery {
  margin: 0; padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

/* Legacy aliases (unused but kept for safety) */
.learn-grade {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: linear-gradient(135deg, rgba(124,58,237,.12), rgba(6,182,212,.08));
  border-color: rgba(124,58,237,.25);
}
.learn-grade-kicker {
  font-size: var(--fs-xs); font-weight: 800; color: var(--brand-hi);
  letter-spacing: .08em; text-transform: uppercase;
}
.learn-grade-title { font-family: var(--font-h); font-size: var(--fs-lg); margin: 2px 0; }
.learn-grade-sub { font-size: var(--fs-sm); color: var(--tx-2); margin: 0; }
.learn-grade-ring {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-lg);
  background: var(--bg-3); border: 2px solid var(--brand-hi);
  box-shadow: 0 0 20px rgba(167,139,250,.25);
}
.learn-skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: var(--s2); }
.learn-skill {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s3); text-align: center; border-top: 3px solid var(--skill-color, var(--brand));
}
.learn-skill-icon { width: 24px; height: 24px; object-fit: cover; border-radius: 5px; margin: 0 auto var(--s1); display: block; }
.learn-skill-val { display: block; font-family: var(--font-d); font-weight: 700; }
.learn-skill-key { display: block; font-size: 10px; color: var(--tx-3); margin-top: 2px; }
.learn-tracks { display: flex; flex-direction: column; gap: var(--s3); }
.learn-track.card { padding: 0; overflow: hidden; }
.learn-track-banner {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  opacity: .13; border-radius: inherit; pointer-events: none;
}
.learn-track-head {
  position: relative; overflow: hidden;
  width: 100%; display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4); background: transparent; border: none; color: inherit;
  text-align: inherit; cursor: pointer; font-family: inherit;
}
.learn-track-head:hover { background: var(--bg-3); }
.learn-track-head:hover .learn-track-banner { opacity: .22; }
.learn-track-icon {
  width: 44px; height: 44px; border-radius: var(--r-lg);
  display: grid; place-items: center; background: var(--bg-3); flex-shrink: 0;
}
.learn-track-meta { flex: 1; min-width: 0; }
.learn-track-title-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.learn-track-title { font-weight: 700; }
.learn-track-avail { font-size: 10px; color: var(--tx-3); font-family: var(--font-mono); }
.learn-track-sub { font-size: var(--fs-xs); color: var(--tx-3); margin: 4px 0 8px; }
.learn-track-bar { height: 5px; border-radius: var(--r-full); background: var(--bg-4); overflow: hidden; }
.learn-track-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--cyan)); }
.learn-unlock-hint { font-size: var(--fs-xs); color: var(--yellow); margin: var(--s2) 0 0; display: flex; gap: 6px; line-height: 1.35; }
.learn-chev { color: var(--tx-3); transform: rotate(-90deg); transition: transform .2s; flex-shrink: 0; margin-top: 8px; }
.learn-track-head.open .learn-chev { transform: rotate(90deg); }
.learn-track-body { border-top: 1px solid var(--border); padding: var(--s3) var(--s4) var(--s4); }
.learn-track-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.btn-sm { padding: 8px 14px; font-size: var(--fs-xs); }
.learn-track-final { font-size: var(--fs-xs); color: var(--tx-3); flex: 1; }
.learn-module { margin-bottom: var(--s2); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.learn-module-head {
  width: 100%; display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); background: var(--bg-2); border: none; color: inherit; cursor: pointer; font-family: inherit;
}
.learn-module-meta { flex: 1; min-width: 0; }
.learn-module-title-row {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.learn-module-title { font-weight: 600; font-size: var(--fs-sm); text-align: start; min-width: 0; }
.learn-module-progress {
  font-size: var(--fs-xs); color: var(--tx-3); font-family: var(--font-d);
  flex-shrink: 0; padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg-4); border: 1px solid var(--border);
}
.learn-module-head.open .learn-chev.sm { transform: rotate(90deg); }
.learn-chev.sm { transform: rotate(-90deg); transition: transform .2s; }
.learn-module-body { padding: var(--s2) var(--s3) var(--s3); }
.learn-module-body[hidden] { display: none; }
.learn-module-bar { height: 3px; border-radius: var(--r-full); background: var(--bg-4); margin-bottom: var(--s2); }
.learn-module-bar i { display: block; height: 100%; background: var(--brand-hi); }
.learn-lesson {
  width: 100%; display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s2); margin-bottom: 4px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; font-family: inherit; text-align: inherit;
}
.learn-lesson:not(.disabled):hover { background: var(--bg-3); border-color: var(--border); }
.learn-lesson.disabled { opacity: .55; cursor: not-allowed; }
.learn-lesson.state-current:not(.disabled) { border-color: rgba(124,58,237,.35); background: rgba(124,58,237,.08); }
.learn-lesson-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); flex-shrink: 0; }
.learn-lesson.state-done .learn-lesson-dot { background: rgba(16,185,129,.2); color: var(--green); }
.learn-lesson.state-current .learn-lesson-dot { background: rgba(124,58,237,.25); color: var(--brand-hi); }
.learn-lesson-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.learn-lesson-title { font-weight: 600; font-size: var(--fs-sm); }
.learn-lesson-meta { font-size: 10px; color: var(--tx-3); }
.learn-lesson-state { font-size: 10px; font-weight: 700; color: var(--tx-3); }
.learn-lesson.state-current .learn-lesson-state { color: var(--brand-hi); }
.learn-footnote { font-size: var(--fs-xs); color: var(--tx-3); text-align: center; padding-bottom: var(--s5); line-height: 1.45; }

/* ── Projects tab (EZ AI portfolio) ── */
.proj-root { display: flex; flex-direction: column; gap: var(--s4); }
.proj-loading { padding: var(--s5); text-align: center; color: var(--tx-2); }

.proj-hero {
  padding: var(--s4) var(--s5);
  background: linear-gradient(145deg, rgba(124,58,237,.1), rgba(6,182,212,.06));
  border-color: rgba(124,58,237,.22);
}
.proj-hero-agent { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.proj-agent-av {
  width: 44px; height: 44px; border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--brand-border); color: var(--brand-hi);
}
.proj-agent-kicker { font-size: 10px; font-weight: 700; color: var(--tx-3); letter-spacing: .04em; }
.proj-agent-title { font-family: var(--font-h); font-size: var(--fs-lg); font-weight: 700; }
.proj-hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-bottom: var(--s3);
}
.proj-stat {
  text-align: center; padding: var(--s2); background: var(--bg-3);
  border-radius: var(--r-md); border: 1px solid var(--border);
}
.proj-stat-val { display: block; font-family: var(--font-d); font-weight: 800; font-size: var(--fs-lg); color: var(--brand-hi); }
.proj-stat-key { font-size: 10px; color: var(--tx-3); }
.proj-hero-bar { margin-top: var(--s1); }

.proj-demo-banner {
  padding: var(--s3) var(--s4); font-size: var(--fs-sm); color: var(--tx-2);
  border-color: rgba(124, 58, 237, .28); background: rgba(124, 58, 237, .08);
}
.proj-next {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4); border-color: rgba(16, 185, 129, .25);
  background: linear-gradient(135deg, rgba(16, 185, 129, .08), rgba(124, 58, 237, .06));
}
.proj-next-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(124, 58, 237, .15); color: var(--brand-hi);
}
.proj-next-body h3 { margin: 0 0 var(--s1); font-size: var(--fs-body); }
.proj-next-body p { margin: 0 0 var(--s3); color: var(--tx-2); font-size: var(--fs-sm); line-height: 1.45; }
.proj-next-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

.proj-inspiration { margin-top: var(--s1); }
.proj-card--inspiration { border-color: rgba(6, 182, 212, .22); }
.proj-card--inspiration .proj-card-preview {
  display: block; text-decoration: none; color: inherit;
}
.proj-preview--draft {
  background: linear-gradient(145deg, #2e1067 0%, #1e1b4b 45%, #312e81 100%);
}
.proj-preview--vibe {
  background: linear-gradient(145deg, #4c1d95 0%, #5b21b6 40%, #0891b2 100%);
}
.proj-preview--prompt {
  background: linear-gradient(145deg, #78350f 0%, #92400e 45%, #7c3aed 100%);
}
.proj-preview--flow {
  background: linear-gradient(145deg, #064e3b 0%, #047857 45%, #6366f1 100%);
}
.proj-inspiration-track {
  position: absolute; bottom: var(--s2); inset-inline-start: var(--s2);
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-sm);
  background: rgba(0, 0, 0, .35); color: #fff;
}
.proj-achieve-bar {
  margin-top: var(--s3); height: 4px; border-radius: 999px;
  background: var(--bg-3); overflow: hidden;
}
.proj-achieve-bar span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-hi));
  transition: width var(--dur);
}

.proj-empty { padding: var(--s6) var(--s5); text-align: center; }
.proj-empty-icon { color: var(--tx-3); margin-bottom: var(--s3); opacity: .7; }
.proj-empty h3 { margin-bottom: var(--s2); }
.proj-empty p { color: var(--tx-2); font-size: var(--fs-sm); max-width: 320px; margin: 0 auto var(--s4); line-height: 1.45; }

.proj-grid-next {
  display: grid; gap: var(--s4);
  grid-template-columns: 1fr;
}
.proj-card { padding: 0; overflow: hidden; }
.proj-card-chrome { border-radius: 0; border: none; border-bottom: 1px solid var(--border-hi); }
.proj-card-preview {
  height: 140px; position: relative;
  background: linear-gradient(160deg, #1a1030 0%, #0f2840 50%, #0a1628 100%);
  display: grid; place-items: center; color: rgba(255,255,255,.85);
}
.proj-card-preview--open {
  width: 100%; border: none; padding: 0; cursor: pointer;
  font: inherit; text-align: inherit;
  transition: filter var(--dur);
}
.proj-card-preview--open:hover { filter: brightness(1.06); }
.proj-card-preview--open:focus-visible {
  outline: 2px solid var(--brand-hi);
  outline-offset: 2px;
}
.proj-draft-badge {
  position: absolute; top: var(--s2); inset-inline-start: var(--s2);
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 8px; border-radius: var(--r-sm);
  background: rgba(124,58,237,.35); color: #e9d5ff;
  border: 1px solid rgba(167,139,250,.35);
}
.proj-demo-hint {
  flex: 1 1 100%;
  font-size: var(--fs-xs); color: var(--tx-3); line-height: 1.4;
  padding: var(--s1) 0 0;
}
.proj-card-actions .btn:disabled {
  opacity: .45; cursor: not-allowed;
}
.proj-preview-glow {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(167,139,250,.25), transparent 55%),
              radial-gradient(circle at 70% 60%, rgba(6,182,212,.15), transparent 50%);
  pointer-events: none;
}
.proj-thumb-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .72;
  border-radius: 0;
}
.proj-card-body { padding: var(--s4); }
.proj-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.proj-card-head h3 { font-weight: 700; font-size: var(--fs-body); margin: 0; }
.proj-build-num { font-size: var(--fs-xs); color: var(--tx-3); font-family: var(--font-mono); }
.proj-card-url {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--cyan);
  margin-top: var(--s1); word-break: break-all;
}
.proj-card-meta {
  display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s3);
  font-size: 10px; color: var(--tx-3);
}
.proj-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.proj-card-actions {
  display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4);
}
.proj-card-actions .btn { flex: 1; min-width: 100px; justify-content: center; }

.proj-achieve-grid { display: grid; gap: var(--s2); }
.proj-achieve-card {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); opacity: .75;
}
.proj-achieve-card.done { opacity: 1; border-color: rgba(16,185,129,.25); background: rgba(16,185,129,.04); }
.proj-achieve-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center; background: var(--bg-3); flex-shrink: 0; overflow: hidden;
}
.proj-achieve-img { width: 100%; height: 100%; object-fit: cover; }
.proj-achieve-title { font-weight: 600; font-size: var(--fs-sm); }
.proj-achieve-sub { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 2px; }
.proj-footnote {
  font-size: var(--fs-xs); color: var(--tx-3); text-align: center;
  padding-bottom: var(--s5); line-height: 1.45;
}

/* ── Journey — EZ AI guided map ── */
.journey-root { min-height: 0; }
.journey-scene {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding-bottom: var(--s3);
  width: 100%;
  max-width: min(920px, 100%);
  margin-inline: auto;
}

/* Journey — compact EZ guide strip (one line) */
.journey-scene .ez-guide--strip {
  border-color: var(--border);
  box-shadow: none;
}
.journey-scene .ez-guide--strip .ez-guide-inner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  min-height: 44px;
  background: var(--bg-2);
}
.journey-scene .ez-guide--strip .ez-av,
.journey-scene .ez-guide--strip .ez-av-img,
.journey-scene .ez-guide--strip .ez-av-mark,
.journey-scene .ez-guide--strip .ez-av-chip {
  width: 36px;
  height: 36px;
  animation: none;
  box-shadow: none;
}
.journey-scene .ez-guide--strip .ez-speech-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.journey-scene .ez-guide--strip .ez-bubble {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: var(--fs-xs);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.journey-scene .ez-guide--strip .ez-bubble.typing::after { display: none; }
.journey-scene .ez-guide--strip .ez-actions {
  flex-shrink: 0;
  margin: 0;
  gap: 6px;
}
.journey-scene .ez-guide--strip .ez-actions .btn {
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.journey-scene .ez-guide--strip .ez-actions .btn-ghost,
.journey-scene .ez-guide--strip .ez-actions .btn-outline { display: none !important; }

/* Journey — compact EZ guide so the map gets more room */
.journey-scene .ez-guide {
  border-color: var(--border);
  box-shadow: 0 4px 18px rgba(0,0,0,.16);
}
.journey-scene .ez-guide-inner {
  padding: var(--s2) var(--s3);
  gap: var(--s2);
  align-items: center;
  background: var(--bg-2);
}
.journey-scene .ez-av {
  width: 44px;
  height: 44px;
  animation: none;
}
.journey-scene .ez-av-img,
.journey-scene .ez-av-mark,
.journey-scene .ez-av-chip {
  width: 44px;
  height: 44px;
  animation: ez-bounce-in .45s cubic-bezier(.34,1.56,.64,1) both;
  box-shadow: 0 0 10px rgba(167,139,250,.28);
}
.journey-scene .ez-av-spark { display: none; }
.journey-scene .ez-speech-head { margin-bottom: 2px; }
.journey-scene .ez-name { font-size: var(--fs-xs); }
.journey-scene .ez-role { font-size: 10px; }
.journey-scene .ez-bubble {
  padding: 6px var(--s2);
  font-size: var(--fs-xs);
  line-height: 1.45;
  min-height: 0;
}
.journey-scene .ez-actions {
  margin-top: var(--s2);
  gap: 6px;
}
.journey-scene .ez-actions .btn {
  padding: 7px 12px;
  font-size: var(--fs-xs);
}

.journey-top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.journey-track-pill {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: 6px var(--s3); border-radius: var(--r-sm);
  background: var(--bg-3); border: 1px solid var(--border);
  font-weight: 600; font-size: var(--fs-xs); color: var(--tx-2);
}
.journey-track-pill .ic { opacity: .65; color: var(--tx-3); }
.journey-track-sub { font-weight: 500; color: var(--tx-3); font-size: 11px; }
.journey-progress-ring {
  flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px; color: var(--tx-3);
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
}
.journey-progress-ring::after { display: none; }

/* EZ AI guide panel */
/* ── EZ AI animations ─────────────────────────────────────── */
@keyframes ez-float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes ez-bounce-in {
  0%   { transform: scale(.4) translateY(12px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(-3px); opacity: 1; }
  80%  { transform: scale(.94) translateY(1px); }
  100% { transform: scale(1) translateY(0); }
}
@keyframes ez-emote-pop {
  0%,100% { transform: scale(1); }
  40%     { transform: scale(1.22) rotate(-4deg); }
  70%     { transform: scale(.9) rotate(2deg); }
}
@keyframes ez-glow-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(167,139,250,.0), 0 0 12px rgba(167,139,250,.35); }
  50%     { box-shadow: 0 0 0 6px rgba(167,139,250,.18), 0 0 24px rgba(167,139,250,.55); }
}
@keyframes ez-spark-s1 {
  0%,100% { transform: translateY(0) scale(1); opacity:.7; }
  50%     { transform: translateY(-8px) scale(1.3) rotate(20deg); opacity:1; }
}
@keyframes ez-spark-s2 {
  0%,100% { transform: translateY(0) scale(1); opacity:.5; }
  50%     { transform: translateY(-6px) scale(.8) rotate(-15deg); opacity:.9; }
}
@keyframes ez-think-bob {
  0%,100% { transform: rotate(-4deg) scale(1); }
  50%     { transform: rotate(4deg) scale(1.05); }
}
@keyframes ez-excited-shake {
  0%,100% { transform: rotate(0deg); }
  20%     { transform: rotate(-5deg) scale(1.08); }
  40%     { transform: rotate(5deg) scale(1.1); }
  60%     { transform: rotate(-4deg) scale(1.06); }
  80%     { transform: rotate(3deg); }
}

.ez-guide { padding: 0; overflow: visible; border-color: rgba(167,139,250,.35); }
.ez-guide-inner {
  display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4);
  background: linear-gradient(135deg, rgba(45,16,96,.55) 0%, var(--bg-2) 60%);
}
.ez-av {
  position: relative; width: 64px; height: 64px; flex-shrink: 0;
  animation: ez-float 3.6s ease-in-out infinite;
}
.ez-av-img {
  width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-md);
  animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-glow-pulse 2.8s ease-in-out infinite .6s;
  transition: transform .15s ease;
}
.ez-av-img.emote-pop { animation: ez-emote-pop .4s ease both; }
.ez-av-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  isolation: isolate;
  animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-glow-pulse 2.8s ease-in-out infinite .6s;
}
.ez-av-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 18px;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.35), transparent 38%),
              linear-gradient(135deg, rgba(34,211,238,.22), rgba(139,92,246,.3));
  filter: blur(8px);
  z-index: -1;
}
.ez-av-mark-orbit {
  position: absolute;
  inset: 1px;
  border: 1px solid rgba(167,139,250,.45);
  border-radius: 20px;
  transform: rotate(12deg);
}
.ez-av-mark-svg {
  width: 100%;
  height: 100%;
  border-radius: var(--r-md);
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.42));
}
.ez-av-chip { width: 64px; height: 64px; }

/* mood tints on the container */
.ez-av.mood-excited  .ez-av-img { animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-excited-shake 1.2s ease-in-out infinite .5s; }
.ez-av.mood-think    .ez-av-img { animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-think-bob 1.8s ease-in-out infinite .5s; }
.ez-av.mood-proud    .ez-av-img { filter: drop-shadow(0 0 8px rgba(16,185,129,.7)); }
.ez-av.mood-happy    .ez-av-img { filter: drop-shadow(0 0 8px rgba(250,204,21,.5)); }
.ez-av.mood-excited  .ez-av-mark { animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-excited-shake 1.2s ease-in-out infinite .5s; }
.ez-av.mood-think    .ez-av-mark { animation: ez-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both, ez-think-bob 1.8s ease-in-out infinite .5s; }
.ez-av.mood-proud    .ez-av-mark { filter: drop-shadow(0 0 8px rgba(16,185,129,.55)); }
.ez-av.mood-happy    .ez-av-mark { filter: drop-shadow(0 0 8px rgba(250,204,21,.45)); }

/* sparks */
.ez-av-spark {
  position: absolute; pointer-events: none; color: var(--brand-hi);
  font-size: 10px;
}
.ez-av-spark.s1 { top: -4px; right: -4px; animation: ez-spark-s1 2.2s ease-in-out infinite; }
.ez-av-spark.s2 { bottom: 2px; left: -6px; animation: ez-spark-s2 2.8s ease-in-out infinite .7s; }
.ez-av.mood-excited .ez-av-spark { color: var(--yellow); display: block; }
.ez-av.mood-proud   .ez-av-spark { color: var(--green); display: block; }
.ez-av.mood-happy   .ez-av-spark { display: block; }

.ez-speech-wrap { flex: 1; min-width: 0; }
.ez-speech-head { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: 6px; }
.ez-name { font-weight: 600; font-size: var(--fs-sm); color: var(--tx); }
.ez-role { font-size: 11px; color: var(--tx-3); }
.ez-bubble {
  position: relative; padding: var(--s2) var(--s3);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r); border-start-start-radius: 3px;
  font-size: var(--fs-sm); line-height: 1.55; min-height: auto;
}
.ez-bubble.typing::after {
  content: "▋"; animation: ez-cursor .8s step-end infinite;
  color: var(--brand-hi); margin-inline-start: 2px;
}
.ez-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }

/* Interactive map — hand-drawn sketch trail */
.journey-map-wrap { position: relative; }
.journey-map-head {
  margin-bottom: var(--s2);
}
.journey-map-label {
  font-size: var(--fs-xs); color: var(--tx-3);
  letter-spacing: .04em;
  font-family: var(--font-mono);
}

/* Horizontal worlds carousel — flat, readable maps with smooth swipe */
.journey-worlds-viewport {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin-inline: auto;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  border-radius: 16px;
  isolation: isolate;
  background: #0a0814;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  outline: none;
}
.journey-worlds-viewport:focus-visible {
  box-shadow:
    0 10px 28px rgba(0,0,0,.22),
    0 0 0 2px color-mix(in srgb, var(--cyan) 25%, transparent);
}
.journey-worlds-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    155deg,
    rgba(255,255,255,.12) 0%,
    rgba(6,182,212,.18) 48%,
    rgba(255,255,255,.06) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 5;
}

.journey-edge-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(44px, 12vw, 56px);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: var(--brand-hi);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.journey-edge-nav[hidden] { display: none !important; }
.journey-edge-nav--start { inset-inline-start: 0; }
.journey-edge-nav--end { inset-inline-end: 0; }
.journey-edge-nav.is-available {
  opacity: 1;
  pointer-events: auto;
}
.journey-edge-nav:not(.is-available) {
  opacity: 0;
  pointer-events: none;
}
.journey-edge-nav-bg {
  position: absolute;
  inset: 8px 4px;
  border-radius: 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: journey-edge-breathe 3s ease-in-out infinite;
}
.journey-edge-nav--start .journey-edge-nav-bg {
  background: linear-gradient(to right, rgba(124,58,237,.28), rgba(124,58,237,.08) 55%, transparent);
}
.journey-edge-nav--end .journey-edge-nav-bg {
  background: linear-gradient(to left, rgba(124,58,237,.28), rgba(124,58,237,.08) 55%, transparent);
}
[dir="rtl"] .journey-edge-nav--start .journey-edge-nav-bg {
  background: linear-gradient(to left, rgba(124,58,237,.28), rgba(124,58,237,.08) 55%, transparent);
}
[dir="rtl"] .journey-edge-nav--end .journey-edge-nav-bg {
  background: linear-gradient(to right, rgba(124,58,237,.28), rgba(124,58,237,.08) 55%, transparent);
}
.journey-edge-chev {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(167,139,250,.65));
  animation: journey-chev-nudge 2s ease-in-out infinite;
}
.journey-edge-nav--end .journey-edge-chev { animation-direction: reverse; }
.journey-edge-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.journey-edge-particles i {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  opacity: 0;
  animation: journey-edge-flow 2.4s ease-in-out infinite;
}
.journey-edge-nav--start .journey-edge-particles i { inset-inline-start: 28%; }
.journey-edge-nav--end .journey-edge-particles i { inset-inline-end: 28%; animation-direction: reverse; }
.journey-edge-particles i:nth-child(2) { animation-delay: 0.55s; top: 42%; }
.journey-edge-particles i:nth-child(3) { animation-delay: 1.1s; top: 58%; }
.journey-edge-nav:hover .journey-edge-nav-bg { opacity: 1; }
.journey-edge-nav--start:hover .journey-edge-nav-bg {
  background: linear-gradient(to right, rgba(124,58,237,.42), rgba(6,182,212,.12) 50%, transparent);
}
.journey-edge-nav--end:hover .journey-edge-nav-bg {
  background: linear-gradient(to left, rgba(124,58,237,.42), rgba(6,182,212,.12) 50%, transparent);
}
.journey-edge-nav:active { transform: scale(0.96); }

.journey-worlds-track {
  position: relative;
  display: flex;
  transform: translateX(calc(var(--world-index, 0) * -100% + var(--world-drag-px, 0px)));
  will-change: transform;
}
.journey-worlds-track.is-animating {
  transition: transform .58s cubic-bezier(.22, 1, .36, 1);
}
.journey-worlds-track.is-dragging {
  transition: none;
}

.journey-world-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  opacity: 0.5;
  transition: opacity .48s ease;
}
.journey-world-slide.is-active-world {
  opacity: 1;
}

.journey-world-slide .journey-map {
  width: 100%;
  max-height: min(72vh, 640px);
  border-radius: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  padding: var(--s2) var(--s3);
}
.journey-world-slide .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.48), rgba(8,6,18,.24)),
    url("assets/journey/journey-map-bg.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
/* Per-track journey map backgrounds */
[data-world-id="prompt-mastery"] .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.42), rgba(8,6,18,.18)),
    url("assets/journey/maps/prompt-mastery.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
[data-world-id="vibe-coding"] .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.42), rgba(8,6,18,.18)),
    url("assets/journey/maps/vibe-coding.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
[data-world-id="automations"] .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.42), rgba(8,6,18,.18)),
    url("assets/journey/maps/automations.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
[data-world-id="agents"] .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.42), rgba(8,6,18,.18)),
    url("assets/journey/maps/agents.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
[data-world-id="ml"] .journey-map.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.42), rgba(8,6,18,.18)),
    url("assets/journey/maps/ml.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
}
.journey-world-slide.is-active-world .journey-map {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.journey-worlds-viewport .journey-sketch-map {
  min-height: min(62vh, 560px);
}
.journey-worlds-viewport .journey-chapter-pins {
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: var(--s4) var(--s3);
  padding: var(--s3) var(--s2) var(--s4);
}
.journey-scene .j-pin-note-text {
  background: rgba(8,6,18,.78);
  border-radius: 6px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.journey-scene .j-pin-title {
  color: var(--tx);
  text-shadow: 0 1px 2px rgba(0,0,0,.65), 0 0 8px rgba(0,0,0,.35);
}
.journey-scene .j-pin-sub {
  color: var(--tx-2);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.journey-scene .j-station.state-locked {
  opacity: .58;
}
.journey-world-lock {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8,6,18,.12), rgba(8,6,18,.58));
  border-radius: 14px;
}
.journey-world-lock-inner {
  text-align: center;
  padding: var(--s4);
  max-width: 260px;
  background: rgba(12,10,24,.82);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border));
  border-radius: var(--r);
  box-shadow: var(--sh-card);
  animation: world-lock-in .5s cubic-bezier(.22,1,.36,1);
}
.journey-world-lock-title {
  font-weight: 700;
  font-size: var(--fs-sm);
  margin: var(--s2) 0 var(--s1);
}
.journey-world-lock-reason {
  font-size: var(--fs-xs);
  color: var(--yellow);
  margin-bottom: var(--s1);
}
.journey-world-lock-hint {
  font-size: var(--fs-xs);
  color: var(--tx-3);
  line-height: 1.45;
}
.journey-swipe-hint {
  margin: var(--s2) 0 0;
  text-align: center;
  font-size: 10px;
  color: var(--tx-3);
  letter-spacing: .06em;
  font-family: var(--font-mono);
  opacity: .85;
}
@keyframes journey-edge-breathe {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}
@keyframes journey-chev-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-5px); }
}
@keyframes journey-edge-flow {
  0% { opacity: 0; transform: translateX(0) scale(0.6); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateX(22px) scale(1.1); }
}
@keyframes world-lock-in {
  from { opacity: 0; transform: translateY(12px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.journey-map {
  position: relative;
  overflow: auto;
  padding: var(--s4);
  scroll-snap-type: y proximity;
  -webkit-overflow-scrolling: touch;
}
.journey-sketch-map {
  background:
    linear-gradient(180deg, rgba(8,6,18,.55), rgba(8,6,18,.32)),
    url("assets/journey/journey-map-bg.png") center / cover no-repeat,
    url("assets/journey/journey-map-paper.png") center / cover no-repeat;
  min-height: 280px;
}
.journey-map.pulse-once { animation: map-pulse .5s var(--ease); }

.journey-sketch-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.j-trail-seg {
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.j-trail-seg--shadow {
  stroke: rgba(0,0,0,.45);
  stroke-width: 5;
  opacity: .35;
}
.j-trail-seg--todo {
  stroke: color-mix(in srgb, var(--tx-3) 70%, var(--brand));
  stroke-width: 2.4;
  stroke-dasharray: 6 8;
  opacity: .55;
}
.j-trail-seg--done {
  stroke: color-mix(in srgb, var(--green) 80%, var(--cyan));
  stroke-width: 3.2;
  filter: drop-shadow(0 0 6px rgba(16,185,129,.35));
}
.j-trail-dot {
  fill: var(--yellow);
  opacity: .85;
}

.journey-sketch-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.journey-chapter-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s2);
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 22%, transparent);
}
.journey-chapter-meta { flex: 1; min-width: 0; }
.journey-chapter-title-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}
.journey-chapter-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  background: var(--brand-dim);
  color: var(--brand-hi);
  border: 1px solid var(--brand-border);
  flex-shrink: 0;
}
.journey-chapter-title {
  font-weight: 700;
  font-size: var(--fs-sm);
  text-align: start;
}
.journey-chapter-progress {
  font-size: var(--fs-xs);
  color: var(--tx-3);
  font-family: var(--font-d);
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-4);
  border: 1px solid var(--border);
}

.journey-chapter-pins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: var(--s5) var(--s3);
  padding: var(--s4) var(--s3) var(--s5);
  justify-items: center;
  align-items: start;
}

.journey-exam-cta {
  display: flex;
  justify-content: center;
  padding: 0 var(--s3) var(--s5);
}

.journey-exam-cta .btn {
  min-width: min(100%, 240px);
}

.j-station {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  padding: 0;
  scroll-snap-align: center;
  animation: station-in .55s var(--ease) backwards;
  animation-delay: calc(var(--i) * 0.05s);
  width: min(100%, 120px);
  justify-self: center;
}
.j-station[data-col="0"],
.j-station[data-col="1"] { justify-self: center; }

.j-pin-marker {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}
.j-pin-art {
  width: 72px;
  height: 72px;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.35));
  transition: transform var(--dur) var(--ease);
}
.j-pin-img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; display: block; }
.j-pin-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: inherit;
  padding-bottom: 10px;
}
.j-station { position: relative; }

.j-pin-note {
  position: relative;
  width: 120px;
  margin-top: -6px;
  transform: rotate(var(--note-rot, 0deg));
  transition: transform var(--dur) var(--ease);
}
.j-note-art {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.28));
}
.j-pin-note-text {
  position: absolute;
  inset: 8px 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.j-pin-title {
  display: block;
  font-weight: 800;
  font-size: 11px;
  line-height: 1.25;
  color: var(--tx-1);
}
.j-pin-sub {
  display: block;
  font-size: 9px;
  color: var(--tx-3);
  line-height: 1.3;
}
.j-pin-live {
  display: inline-block;
  margin-top: 3px;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--progress-dim);
  color: var(--cyan);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent);
  animation: live-pulse 1.5s ease infinite;
  align-self: center;
}
.j-pin-xp {
  font-size: 9px;
  color: var(--yellow);
  margin-top: 1px;
}

.j-station.state-done .j-pin-icon { color: var(--green); }
.j-station.state-current .j-pin-art {
  filter: drop-shadow(0 0 10px rgba(6,182,212,.35)) drop-shadow(0 4px 10px rgba(0,0,0,.35));
  animation: orb-pulse 2.2s ease infinite;
}
.j-station.state-current .j-pin-icon { color: #fff; }
.j-station.state-locked {
  opacity: .42;
  cursor: not-allowed;
}
.j-station.state-locked .j-pin-art { filter: grayscale(.65) drop-shadow(0 2px 6px rgba(0,0,0,.2)); }
.j-station.selected .j-pin-note .j-note-paper {
  stroke: var(--cyan);
  stroke-width: 2.4;
}
.j-station.is-flag .j-pin-title::after {
  content: " · finish flag";
  font-weight: 600;
  color: var(--yellow);
  font-size: 8px;
}
.j-station:not(.state-locked):hover .j-pin-art { transform: scale(1.06) translateY(-2px); }
.j-station:not(.state-locked):hover .j-pin-note { transform: rotate(var(--note-rot, 0deg)) scale(1.02); }

@keyframes ez-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes ez-glow {
  from { opacity: .6; transform: scale(.95); }
  to { opacity: 1; transform: scale(1.05); }
}
@keyframes ez-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes ez-spark {
  0%, 100% { opacity: .3; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
@keyframes ez-cursor {
  50% { opacity: 0; }
}
@keyframes path-dash {
  to { stroke-dashoffset: -200; }
}
@keyframes station-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes orb-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--progress-dim), 0 0 14px rgba(6,182,212,.25); }
  50% { box-shadow: 0 0 0 5px var(--progress-dim), 0 0 22px rgba(6,182,212,.35); }
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
@keyframes map-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan) 30%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .ez-av, .j-station, .j-trail-seg, .j-pin-live, .j-station.state-current .j-pin-art {
    animation: none !important;
  }
}

@media (min-width: 640px) {
  .proj-grid-next { grid-template-columns: repeat(2, 1fr); }
  .proj-achieve-grid { grid-template-columns: repeat(3, 1fr); }
  .ez-guide-inner { padding: var(--s5); }
  .journey-scene .ez-guide-inner { padding: var(--s2) var(--s3); }
  .journey-chapter-pins { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .j-station { width: 128px; }
}

/* Journey — phone + mobile */
@media (max-width: 939px) {
  .journey-scene .ez-av,
  .journey-scene .ez-av-img,
  .journey-scene .ez-av-chip {
    width: 44px;
    height: 44px;
  }
  .journey-scene .ez-guide-inner {
    padding: var(--s2);
    gap: var(--s2);
  }
  .journey-scene .ez-speech-head { margin-bottom: 0; }
  .journey-scene .ez-actions .btn {
    padding: 6px 12px;
    font-size: var(--fs-xs);
    min-height: 36px;
  }
}

@media (max-width: 479px) {
  .journey-scene { gap: var(--s2); }
  .journey-top { gap: var(--s2); }
  .journey-track-pill {
    font-size: 10px;
    padding: 4px var(--s2);
  }
  .journey-track-sub { display: none; }
  .journey-map-head { margin-bottom: var(--s1); }
  .journey-map-label { font-size: 10px; }
  .journey-worlds-viewport {
    max-width: 100%;
    border-radius: 14px;
  }
  .journey-worlds-viewport::before { border-radius: 14px; }
  .journey-edge-nav { width: 40px; }
  .journey-world-slide .journey-map {
    max-height: min(56vh, 460px);
    padding: var(--s2);
    border-radius: calc(var(--r) - 1px);
  }
  .journey-worlds-viewport .journey-sketch-map { min-height: min(50vh, 400px); }
  .journey-worlds-viewport .journey-chapter-pins {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: var(--s3) var(--s2);
    padding: var(--s2) var(--s1) var(--s3);
  }
  .journey-scene .j-station { width: min(100%, 96px); }
  .journey-scene .j-pin-marker,
  .journey-scene .j-pin-art { width: 58px; height: 58px; }
  .journey-scene .j-pin-note { width: 96px; }
  .journey-scene .j-pin-title { font-size: 10px; }
  .journey-scene .ez-guide-inner {
    padding: var(--s2);
    gap: var(--s2);
  }
  .journey-scene .ez-av,
  .journey-scene .ez-av-img,
  .journey-scene .ez-av-chip {
    width: 36px;
    height: 36px;
  }
  .journey-scene .ez-actions .btn { padding: 6px 10px; }
  .journey-swipe-hint { font-size: 9px; letter-spacing: .04em; }
}

/* Journey — tablet */
@media (min-width: 480px) and (max-width: 939px) {
  .journey-worlds-viewport { max-width: min(100%, 640px); }
  .journey-world-slide .journey-map { max-height: min(64vh, 540px); }
  .journey-worlds-viewport .journey-chapter-pins {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }
}

/* section label */
.sec-label {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--tx-3);
  padding: var(--s5) 0 var(--s2);
}

/* stat row */
.stat-row {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 1px; background: var(--border); border-radius: var(--r-lg);
  overflow: hidden; border: 1px solid var(--border);
}
.stat-cell {
  padding: var(--s4) var(--s3); background: var(--bg-2); text-align: center;
}
.stat-cell .v {
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-h1);
  color: var(--brand-hi);
}
.stat-cell .k { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 2px; }

/* ===================================================================
   League Screen — Pro / restrained gamification
   =================================================================== */

#screen-league .page-head { margin-bottom: var(--s5); }
.lg-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}
.lg-page-head-main { flex: 1; min-width: 0; }
.lg-timer-pill {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--brand-hi);
  background: var(--brand-dim);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-full);
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}
#screen-league.lg-loading { opacity: 0.72; pointer-events: none; transition: opacity 0.2s ease; }

.lg-section-title {
  font-size: var(--fs-sm); font-weight: 600; color: var(--tx-2);
  margin-bottom: var(--s3);
}

/* ── Tier Hero ── */
.lg-hero {
  display: flex; align-items: center; gap: var(--s5);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5);
  margin-bottom: var(--s4); box-shadow: var(--sh-card);
}
.lg-hero-orb {
  position: relative; width: 72px; height: 72px; flex: 0 0 auto;
  display: grid; place-items: center;
}
.lg-hero-orb--asset { overflow: visible; }
.lg-orb-emblem {
  width: 72px; height: 72px; object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.35));
}
.lg-hero-info { flex: 1; min-width: 0; }
.lg-hero-meta {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-bottom: var(--s2);
}
.lg-tier-badge {
  font-size: var(--fs-xs); font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-sm); flex: 0 0 auto;
}
.tier-spark  { background: rgba(245,158,11,.1); color: #D97706; border: 1px solid rgba(245,158,11,.2); }
.tier-fighter{ background: rgba(148,163,184,.1); color: #94A3B8; border: 1px solid rgba(148,163,184,.2); }
.tier-artisan{ background: rgba(234,179,8,.1);  color: #CA8A04; border: 1px solid rgba(234,179,8,.2); }
.tier-master { background: rgba(6,182,212,.1);  color: #0891B2; border: 1px solid rgba(6,182,212,.2); }
.tier-champ  { background: rgba(167,139,250,.1);color: #A78BFA; border: 1px solid rgba(167,139,250,.2); }
.lg-div-num  { font-size: var(--fs-sm); font-weight: 500; color: var(--tx-2); }
.lg-shield-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 500; color: var(--tx-2);
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: var(--r-sm); flex: 0 0 auto;
}
.lg-shield-tag .ic { color: var(--yellow); opacity: .85; }
.lg-hero-rank-row {
  display: flex; align-items: baseline; gap: var(--s3); margin-bottom: 4px;
}
.lg-hero-rank-num {
  font-family: var(--font-d); font-weight: 700; font-size: 32px;
  line-height: 1; color: var(--tx); font-variant-numeric: tabular-nums;
}
.lg-hero-rank-detail { font-size: var(--fs-sm); color: var(--tx-2); }
.lg-hero-season { font-size: var(--fs-xs); color: var(--tx-3); }
.lg-hero-season strong { color: var(--tx-2); font-weight: 600; }

/* ── Tier Road ── */
.lg-road {
  display: flex; align-items: center;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4);
  margin-bottom: var(--s4);
}
.lg-rs {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 0 0 auto;
}
.lg-rs-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--border-hi); background: var(--bg-4);
  transition: all var(--dur);
}
.lg-rs.done .lg-rs-dot  { background: var(--tx-3); border-color: var(--tx-3); }
.lg-rs.current .lg-rs-dot {
  background: #94A3B8; border-color: #CBD5E1;
  box-shadow: 0 0 0 3px rgba(148,163,184,.15);
}
.lg-rs.locked .lg-rs-dot { opacity: .3; }
.lg-rs-name { font-size: 10px; font-weight: 500; color: var(--tx-3); white-space: nowrap; }
.lg-rs.done .lg-rs-name { color: var(--tx-2); }
.lg-rs.current .lg-rs-name { color: var(--tx); font-weight: 600; }
.lg-road-line { flex: 1; height: 1px; background: var(--border); margin-bottom: 18px; }
.lg-road-line.done { background: var(--tx-3); opacity: .4; }

/* ── LP Bar ── */
.lg-lp-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
  margin-bottom: var(--s4); box-shadow: var(--sh-card);
}
.lg-lp-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--s3);
}
.lg-lp-label { font-size: var(--fs-sm); font-weight: 500; color: var(--tx-2); }
.lg-lp-val {
  font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-body);
  color: var(--tx); font-variant-numeric: tabular-nums;
}
.lg-lp-max { color: var(--tx-3); font-weight: 400; font-size: var(--fs-sm); }
.lg-lp-track {
  position: relative; height: 6px; border-radius: var(--r-full);
  background: var(--bg-4); margin-bottom: var(--s3); overflow: visible;
}
.lg-lp-fill {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-hi));
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.lg-lp-milestone {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  transform: translateX(-50%); border-radius: 1px; pointer-events: none;
  background: rgba(255, 255, 255, 0.35);
}
.lg-lp-milestone--safe { background: rgba(16, 185, 129, 0.55); }
.lg-lp-milestone--promo { background: rgba(251, 191, 36, 0.75); }
.lg-lp-threshold {
  position: absolute; top: -3px; width: 1px; height: 10px;
  background: var(--yellow); opacity: .6;
}
.lg-lp-sub { font-size: var(--fs-xs); color: var(--tx-3); }
.lg-lp-sub strong { color: var(--tx-2); font-weight: 600; }
.lg-lp-breakdown {
  display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3);
}
.lg-lp-chip {
  font-size: 10px; font-weight: 600; color: var(--tx-2);
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: var(--r-full);
}
.lg-lp-chip--bonus { color: var(--yellow); border-color: rgba(245,158,11,.25); }

.lg-scope-bar {
  display: flex; gap: var(--s2); margin-bottom: var(--s4);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 4px; width: fit-content;
}
.lg-scope-btn {
  border: none; background: transparent; color: var(--tx-2);
  font-size: var(--fs-xs); font-weight: 600; padding: 8px 14px;
  border-radius: var(--r-full); cursor: pointer; transition: all var(--dur);
}
.lg-scope-btn.active {
  background: var(--brand); color: #fff;
  box-shadow: 0 0 0 1px rgba(124,58,237,.35);
}
.lg-scope-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.lg-grow {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); padding: var(--s4) var(--s5); margin-bottom: var(--s4);
  background: linear-gradient(135deg, rgba(124,58,237,.08), rgba(6,182,212,.06));
  border-color: rgba(124,58,237,.2);
}
.lg-grow-hint { font-size: var(--fs-sm); color: var(--tx-2); margin: 0; max-width: 42ch; }
.lg-grow-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.lg-gap {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  font-size: var(--fs-sm); font-weight: 500; color: var(--tx);
  background: rgba(245,158,11,.06); border-color: rgba(245,158,11,.2);
}
.lg-activity { margin-bottom: var(--s4); padding: var(--s4) var(--s5); }
.lg-activity-list { list-style: none; margin: 0; padding: 0; }
.lg-activity-item {
  display: flex; align-items: center; gap: var(--s2);
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--tx-2);
}
.lg-activity-item:last-child { border-bottom: none; }
.lg-activity-lp { margin-inline-start: auto; color: var(--brand-hi); font-weight: 600; }
.lg-activity-badge {
  margin-inline-start: auto; font-size: 10px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--yellow); padding: 2px 8px; border-radius: 999px;
  background: rgba(234, 179, 8, .12); border: 1px solid rgba(234, 179, 8, .22);
}
.lg-activity-item--achievement { background: rgba(234, 179, 8, .04); }
.lg-demo-banner {
  display: flex; align-items: flex-start; gap: var(--s3);
  margin-bottom: var(--s4); padding: var(--s3) var(--s4);
  border-color: rgba(124, 58, 237, .25);
  background: linear-gradient(135deg, rgba(124, 58, 237, .1), rgba(6, 182, 212, .06));
}
.lg-demo-banner strong { display: block; font-size: var(--fs-sm); margin-bottom: 4px; }
.lg-demo-banner p { margin: 0; font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.45; max-width: 52ch; }
.lg-demo-icon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--brand-hi);
  background: rgba(124, 58, 237, .16); border: 1px solid rgba(167, 139, 250, .22);
}
.lg-challenge-btn { flex: 0 0 auto; opacity: .7; }
.lg-challenge-btn:hover { opacity: 1; }
.lg-board--solo .lg-board-header { opacity: .6; }

.tab-alert {
  position: absolute; top: -2px; inset-inline-end: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,.6);
}
.ti-badge { position: relative; }

.parent-family-league {
  margin-top: var(--s4); padding-top: var(--s4);
  border-top: 1px solid var(--border);
}
.parent-fl-head b { display: block; margin-bottom: 4px; }
.parent-fl-head p { font-size: var(--fs-xs); color: var(--tx-3); margin: 0 0 var(--s3); }
.parent-fl-row {
  padding: var(--s3) 0; border-bottom: 1px solid var(--border);
}
.parent-fl-row:last-child { border-bottom: none; }
.parent-fl-name { font-weight: 600; margin-bottom: 4px; }
.parent-fl-stats {
  display: flex; flex-wrap: wrap; gap: var(--s3);
  font-size: var(--fs-xs); color: var(--tx-2); margin-bottom: 4px;
}
.parent-fl-age { font-size: var(--fs-xs); color: var(--tx-3); }

.lg-quest { margin-bottom: var(--s4); padding: var(--s4) var(--s5); }
.lg-quest-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--s2); margin-bottom: var(--s2);
}
.lg-quest-reward { font-size: var(--fs-xs); font-weight: 600; color: var(--yellow); }
.lg-quest-title { font-size: var(--fs-sm); font-weight: 500; margin-bottom: var(--s3); }
.lg-quest-track {
  height: 6px; border-radius: var(--r-full); background: var(--bg-4);
  overflow: hidden; margin-bottom: var(--s2);
}
.lg-quest-fill {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-hi));
  transition: width .5s var(--ease);
}
.lg-quest-meta { font-size: var(--fs-xs); color: var(--tx-3); margin-bottom: var(--s3); }
.lg-quest--done { opacity: .75; }
.lg-lp-card--promo {
  border-color: rgba(16,185,129,.35);
  box-shadow: 0 0 0 1px rgba(16,185,129,.15), var(--sh-card);
}
.lg-lp-card--promo .lg-lp-fill { background: linear-gradient(90deg, #10B981, var(--brand-hi)); }

/* ── Skill XP ── */
.lg-skills {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
  margin-bottom: var(--s4);
}
.lg-sk-row {
  display: flex; align-items: center; gap: var(--s2); margin-bottom: 10px;
}
.lg-sk-row:last-child { margin-bottom: 0; }
.lg-sk-icon { width: 20px; height: 20px; object-fit: cover; border-radius: var(--r-xs); flex: 0 0 auto; }
.lg-sk-label { font-size: var(--fs-xs); font-weight: 500; color: var(--tx-2); width: 52px; flex: 0 0 auto; }
.lg-sk-track { flex: 1; height: 3px; border-radius: var(--r-full); background: var(--bg-4); overflow: hidden; }
.lg-sk-fill {
  height: 100%; border-radius: var(--r-full);
  background: var(--sk-c, var(--brand)); opacity: .85;
  transition: width .6s var(--ease);
}
.lg-sk-val {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  color: var(--tx-3); width: 40px; text-align: start; flex: 0 0 auto;
}
.lg-sk-locked { opacity: .4; }

/* ── Leaderboard ── */
.lg-board {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  margin-bottom: var(--s4); box-shadow: var(--sh-card);
}
.lg-board-top { padding: var(--s4) var(--s5) 0; }
.lg-board-top .lg-section-title { margin-bottom: 0; }
.lg-board-header {
  display: flex; justify-content: space-between;
  padding: var(--s3) var(--s5); margin-top: var(--s3);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 500; color: var(--tx-3);
}
.lg-player {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s5); border-bottom: 1px solid var(--border);
  transition: background var(--dur);
}
.lg-player:last-child { border-bottom: none; }
.lg-player:hover { background: var(--bg-3); }
.lg-player.promo-zone { border-inline-start: 2px solid rgba(16,185,129,.35); }
.lg-player.demote-zone { border-inline-start: 2px solid rgba(239,68,68,.25); }
.lg-player.lg-dim { opacity: .5; }
.lg-player-me {
  background: var(--bg-3) !important;
  border-inline-start: 2px solid var(--brand) !important;
}
.lg-pos {
  width: 24px; text-align: center; flex: 0 0 auto;
  font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-xs);
  color: var(--tx-3); font-variant-numeric: tabular-nums;
}
.lg-pos-gold   { color: #CA8A04; }
.lg-pos-silver { color: #94A3B8; }
.lg-pos-bronze { color: #B45309; }
.lg-av {
  width: 32px; height: 32px; border-radius: var(--r-full); flex: 0 0 auto;
  background: var(--av-c, var(--bg-4)); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-d); font-weight: 600; font-size: 12px;
  border: 1px solid var(--border-hi);
}
.lg-av-me { border-color: var(--brand); box-shadow: none; }
.lg-av--asset { padding: 0; overflow: hidden; background: var(--bg-4); }
.lg-av--asset img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lg-info { flex: 1; min-width: 0; }
.lg-pname { display: block; font-weight: 500; font-size: var(--fs-sm); color: var(--tx); }
.lg-score-col { flex: 0 0 auto; text-align: end; min-width: 48px; }
.lg-score {
  font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-sm);
  color: var(--tx); font-variant-numeric: tabular-nums;
}
.lg-player-me .lg-score { color: var(--brand-hi); }
.lg-lesson-ct { font-size: 10px; color: var(--tx-3); margin-top: 1px; font-weight: 400; }
.lg-tk-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 500; color: var(--tx-3);
  margin-top: 2px;
}
.lg-tk-tag .ic { opacity: .6; }
.lg-you-tag {
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: var(--r-sm);
  background: var(--brand-dim); color: var(--brand-hi);
  border: 1px solid var(--brand-border); margin-inline-start: 4px;
}
.lg-divider {
  padding: 6px var(--s5);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}
.lg-divider span {
  font-size: 10px; font-weight: 500; color: var(--tx-3);
  display: block; text-align: center;
}
.lg-divider-red span { color: var(--tx-3); }

/* ── Rules (collapsible) ── */
.lg-rules {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: var(--s4); overflow: hidden;
}
.lg-rules-title {
  font-size: var(--fs-sm); font-weight: 500; color: var(--tx-2);
  padding: var(--s4) var(--s5); cursor: pointer; list-style: none;
  user-select: none;
}
.lg-rules-title::-webkit-details-marker { display: none; }
.lg-rules[open] .lg-rules-title { border-bottom: 1px solid var(--border); }
.lg-rules .lg-rule {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 0 var(--s5); margin-bottom: var(--s3);
  font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.5;
}
.lg-rules .lg-rule:first-of-type { padding-top: var(--s4); }
.lg-rules .lg-rule:last-child { padding-bottom: var(--s4); margin-bottom: 0; }
.lg-rule strong { color: var(--tx); font-weight: 600; }
.lg-rule .ic { flex: 0 0 auto; margin-top: 2px; opacity: .7; }

/* ── Season Rewards ── */
.lg-rewards {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
  margin-bottom: var(--s4);
}
.lg-rewards-row { display: flex; gap: var(--s3); }
.lg-reward {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 500; color: var(--tx-2); text-align: center;
}
.lg-reward-sub { font-size: 10px; color: var(--tx-3); font-weight: 400; }
.lg-reward--locked { opacity: .45; }
.lg-reward-icon {
  width: 40px; height: 40px; border-radius: var(--r);
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--tx-2); overflow: hidden;
}
.lg-reward-icon img {
  width: 28px; height: 28px; object-fit: contain; display: block;
}
.lg-reward-icon--coins { color: var(--yellow); }
.lg-reward-icon--medal { color: var(--brand-hi); }
.lg-reward-icon--locked { color: var(--tx-3); }

/* ── My week ── */
.lg-myweek {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
}
.lg-myweek-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3);
  margin-bottom: var(--s4);
}
.lg-ws { text-align: center; }
.lg-ws-val {
  font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-h1);
  color: var(--tx); font-variant-numeric: tabular-nums;
}
.lg-ws-streak {
  display: inline-flex; align-items: center; gap: 4px; color: var(--orange);
}
.lg-ws-streak .ic { opacity: .85; }
.lg-ws-key { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 2px; }
.lg-streak-bar { display: flex; gap: var(--s2); justify-content: center; }
.lg-day {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--bg-3); display: grid; place-items: center;
  font-size: 10px; font-weight: 500; color: var(--tx-3);
  border: 1px solid var(--border);
}
.lg-day.done { background: var(--bg-4); color: var(--tx-2); border-color: var(--border-hi); }
.lg-day.today {
  background: var(--brand-dim); color: var(--brand-hi);
  border-color: var(--brand-border);
}
.lg-day.active-streak {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}
.lg-day.done {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
  border-color: rgba(16, 185, 129, 0.35);
}
.lg-empty-card {
  padding: var(--s5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}
.lg-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  background: var(--brand-dim);
  color: var(--brand-hi);
  display: grid;
  place-items: center;
}
.lg-empty-icon .ic { width: 24px; height: 24px; }
.tab-alert--up { background: #10B981 !important; }
.tab-alert--down { background: #EF4444 !important; }


/* ===================================================================
   OLD Leaderboard — kept for fallback
   =================================================================== */
.league-hero {
  background: linear-gradient(135deg, var(--brand) 0%, #9333EA 100%);
  border-radius: var(--r-xl); padding: var(--s6); text-align: center;
  margin-bottom: var(--s4); position: relative; overflow: hidden;
}
.league-hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='30'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.league-hero .badge-lg {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(4px);
  padding: 4px 12px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; color: rgba(255,255,255,.9);
  margin-bottom: var(--s3);
}
.league-hero h2 { font-family: var(--font-d); font-weight: 900; font-size: 36px; color: #fff; }
.league-hero p { font-size: var(--fs-sm); color: rgba(255,255,255,.7); margin-top: 4px; }

.lb-header {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--tx-3);
  border-bottom: 1px solid var(--border);
}
.lb-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border); position: relative;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.me { background: var(--brand-dim); }

.lb-rank {
  width: 26px; font-family: var(--font-d); font-weight: 700;
  font-size: var(--fs-sm); color: var(--tx-3); text-align: center; flex: 0 0 auto;
}
.lb-rank.gold { color: var(--yellow); }
.lb-rank.silver { color: var(--tx-2); }

.lb-av {
  width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--bg-4); color: var(--tx-2);
  display: grid; place-items: center; flex: 0 0 auto;
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm);
}
.lb-av.me { background: var(--brand); color: #fff; }

.lb-name { flex: 1; font-weight: 500; font-size: var(--fs-body); }
.lb-name small { display: block; font-size: var(--fs-xs); color: var(--tx-3); font-weight: 400; }
.lb-xp {
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm);
  color: var(--tx-2); font-variant-numeric: tabular-nums;
}
.lb-row.me .lb-xp { color: var(--brand-hi); }

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: var(--font); font-weight: 600; font-size: var(--fs-body);
  border: none; border-radius: var(--r-lg); padding: 13px 22px;
  min-height: 48px; width: 100%; cursor: pointer;
  transition: opacity var(--dur), transform var(--dur);
}
.btn[hidden] { display: none !important; }
.btn:active { transform: scale(.98); opacity: .85; }

.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.2) inset, 0 4px 12px rgba(124,58,237,.35);
}
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #fff); }

.btn-success {
  background: var(--green); color: #fff;
  box-shadow: 0 4px 12px rgba(16,185,129,.25);
}
.btn-outline {
  background: transparent; color: var(--tx);
  border: 1px solid var(--border-hi);
}
.btn-outline:hover { background: var(--bg-3); }
.btn-ghost { background: transparent; color: var(--tx-2); min-height: 40px; }
.btn-ghost:hover { color: var(--tx); }

/* ===================================================================
   Lesson overlay
   =================================================================== */
.lesson {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 40;
  background: var(--bg);
  display: flex; flex-direction: column;
  direction: inherit;
  transform: translateY(100%);
  transition: transform var(--dur) var(--ease), left var(--dur) var(--ease);
  width: auto;
  max-width: none;
}
.lesson.open { transform: none; }

.lesson-shell {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}
.lesson-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Path rail — Learn lib-map style, collapsible on the left (LTR default) */
.lesson-path-rail {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  border-inline-end: 0 solid var(--chrome-border);
  background: var(--bg-2);
  transition:
    width var(--dur) var(--ease),
    flex-basis var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.lesson.is-rail-visible.is-rail-open .lesson-path-rail {
  flex: 0 0 min(300px, 38vw);
  width: min(300px, 38vw);
  border-inline-end-width: 1px;
}
.lesson-path-rail-inner {
  height: 100%;
  min-height: 0;
}
.lesson-path-rail-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* Chrome row — same height + border as .lesson-hud so dividers line up */
.lesson-path-rail-head {
  flex: 0 0 var(--hud-h);
  height: var(--hud-h);
  min-height: var(--hud-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
}
.lesson-path-rail-head-text {
  min-width: 0;
  flex: 1;
}
.lesson-path-rail-kicker,
.lesson-path-rail-head .lib-open-kicker {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--book, var(--brand-hi));
  line-height: 1;
  margin: 0 0 2px;
}
.lesson-path-rail-title {
  font-family: var(--font-d);
  font-size: var(--fs-sm);
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-path-rail-prog {
  flex-shrink: 0;
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--tx-3);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-3);
}
.lesson-path-rail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s3) var(--s3) var(--s4);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.lesson-path-mod { margin-bottom: var(--s2); }
.lesson-path-mod-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: var(--s2) var(--s2);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-3);
  color: var(--tx);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.lesson-path-mod-head:hover { background: var(--bg-4); }
.lesson-path-mod.is-active-mod .lesson-path-mod-head {
  border-color: color-mix(in srgb, var(--book) 45%, var(--border));
  background: color-mix(in srgb, var(--book) 8%, var(--bg-3));
}
.lesson-path-mod-chev {
  flex-shrink: 0;
  color: var(--tx-3);
  transition: transform var(--dur) var(--ease);
}
.lesson-path-mod.is-expanded .lesson-path-mod-chev { transform: rotate(90deg); }
html[dir="rtl"] .lesson-path-mod.is-expanded .lesson-path-mod-chev { transform: rotate(-90deg); }
.lesson-path-mod-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-path-mod-prog {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--tx-3);
}
.lesson-path-mod-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.lesson-path-mod-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur) var(--ease);
}
.lesson-path-mod.is-expanded .lesson-path-mod-body { grid-template-rows: 1fr; }
.lesson-path-mod-body-inner { overflow: hidden; min-height: 0; }
.lesson-path-mod-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tx-3);
  margin: 0 0 var(--s2) var(--s1);
}
.lesson-path-map { padding: var(--s2) 0 var(--s1) var(--s4); }
.lesson-path-map .lib-map-trail {
  inset-inline-start: 10px;
  background: linear-gradient(180deg, var(--book), color-mix(in srgb, var(--book) 20%, transparent));
  opacity: .45;
}
.lesson-path-rail .lib-class.is-active {
  border-color: color-mix(in srgb, var(--book) 55%, var(--border));
  background: color-mix(in srgb, var(--book) 10%, var(--bg-3));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--book) 18%, transparent);
}
.lesson-path-rail .lib-class.state-current .lib-class-node,
.lesson-path-rail .lib-class.is-active .lib-class-node {
  background: color-mix(in srgb, var(--book) 18%, var(--bg-4));
  color: var(--book);
}
.lesson-path-rail .lib-class-lock { color: var(--tx-3); flex-shrink: 0; opacity: .7; }
.lesson-path-empty { font-size: var(--fs-sm); color: var(--tx-3); padding: var(--s3); }

.lesson-path-toggle {
  position: static;
  inset: auto;
  transform: none;
  z-index: auto;
  flex-shrink: 0;
  display: none;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--chrome-border);
  border-radius: var(--r);
  background: var(--chrome-bg);
  color: var(--tx-2);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.lesson.is-rail-visible .lesson-path-toggle { display: inline-flex; }
.lesson-path-toggle:hover { background: var(--bg-3); color: var(--tx); }
.lesson-path-toggle.is-open {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--chrome-border));
  background: color-mix(in srgb, var(--brand) 10%, var(--chrome-bg));
  color: var(--brand-hi);
}
.lesson-path-toggle-chev {
  transition: transform var(--dur) var(--ease);
}
.lesson-path-toggle.is-open .lesson-path-toggle-chev {
  transform: rotate(180deg);
}
.lesson.is-rail-open .lesson-path-toggle-label { display: none; }

@media (max-width: 939px) {
  .lesson.is-rail-visible.is-rail-open .lesson-path-rail {
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    z-index: 3;
    flex: none;
    width: min(320px, 92vw);
    max-width: 92vw;
    border-inline-end-width: 1px;
    box-shadow: 12px 0 40px rgba(0,0,0,.45);
    transform: translateX(0);
  }
  html[dir="rtl"] .lesson.is-rail-visible.is-rail-open .lesson-path-rail {
    box-shadow: -12px 0 40px rgba(0,0,0,.45);
    transform: translateX(0);
  }
  .lesson.is-rail-visible:not(.is-rail-open) .lesson-path-rail {
    transform: translateX(-100%);
  }
  html[dir="rtl"] .lesson.is-rail-visible:not(.is-rail-open) .lesson-path-rail {
    transform: translateX(100%);
  }
  .lesson.is-rail-visible.is-rail-open .lesson-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(0, 0, 0, .42);
    animation: lessonRailScrimIn var(--dur) var(--ease) both;
  }
  .lesson-path-rail-head {
    flex: 0 0 calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-inline: var(--s3);
  }
  .lesson-path-toggle-label { display: none; }
}

@keyframes lessonRailScrimIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 940px) {
  .lesson-path-toggle-label { display: inline; }
}

/* keep task content beside the dock — dock stays on top (z-index 50) */
.app.dock-open .lesson.open { left: var(--dock-w); }
.app.dock-collapsed .lesson.open { left: var(--dock-rail); }
.app.dock-hidden .lesson.open { left: 0; }

.lesson-hud {
  height: var(--hud-h); min-height: var(--hud-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  width: 100%;
  box-sizing: border-box;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--bg-3);
  color: var(--tx-2); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--dur), color var(--dur);
}
.icon-btn:hover { background: var(--bg-4); color: var(--tx); }

.lp-bar { flex: 1; height: 4px; border-radius: var(--r-full); background: var(--bg-4); }
.lp-bar > i { display: block; height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-hi));
  transition: width var(--dur) var(--ease); }

.hint-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--cyan);
}

.lesson-coach {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4);
  background: linear-gradient(90deg, rgba(124,58,237,.12), transparent 72%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  direction: inherit;
}
.lesson-coach-face { flex-shrink: 0; }
.lesson-coach-chip { width: 40px; height: 40px; animation: ez-float 3.5s ease-in-out infinite; }
.lesson-coach-chip .ez-chip-body { border-radius: var(--r-sm); }
.lesson-coach-tip {
  margin: 0; font-size: var(--fs-sm); color: var(--tx-2); line-height: 1.5;
  flex: 1; text-align: start; direction: inherit;
  animation: coachTipIn 0.45s ease both;
}

.lesson-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s5) var(--s5) var(--s5);
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  min-width: 0;
  align-self: stretch;
  box-sizing: border-box;
  direction: inherit;
  text-align: start;
}
.lesson-head {
  margin-bottom: var(--s5);
  text-align: start;
  animation: lessonHeadIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.lesson-body .kicker,
.lesson-head .kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brand-hi); margin-bottom: var(--s3);
  text-align: start;
}
.lesson-body h2,
.lesson-head h2 {
  font-family: var(--font); font-weight: 600; font-size: clamp(1.35rem, 4vw, 1.75rem);
  letter-spacing: -.02em; margin-bottom: 0; line-height: 1.35;
  color: var(--tx);
  text-align: start;
}
.ls-step-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 700; color: var(--brand-hi);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--s4);
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--brand-dim); border: 1px solid var(--brand-border);
  animation: lessonHeadIn 0.35s ease both;
}
.ls-step-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-hi); animation: orb-pulse 1.8s ease infinite;
}

/* teaching card — LTR prose + motion (RTL scoped below) */
.lesson-card {
  position: relative;
  direction: inherit;
  text-align: start;
  padding: var(--s5) calc(var(--s5) + 4px) var(--s5) var(--s5);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-hi);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--brand) 6%, var(--bg-2)), var(--bg-2));
  box-shadow: var(--sh-card), inset 0 1px 0 color-mix(in srgb, #fff 4%, transparent);
  opacity: 0;
  transform: translate3d(-18px, 10px, 0) scale(0.985);
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}
.lesson-card::after {
  content: "";
  position: absolute;
  top: var(--s4); bottom: var(--s4); inset-inline-start: 0;
  width: 3px; border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--brand-hi), var(--cyan));
  opacity: 0.85;
}
.lesson-card.is-visible {
  opacity: 1;
  transform: none;
}
.ls-audio-bar {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-bottom: var(--s4);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--brand) 8%, var(--bg-1));
  border: 1px solid var(--border);
}
.ls-audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  width: 100%;
}
.ls-audio-btn {
  appearance: none;
  border: 1px solid var(--border-hi);
  background: var(--bg-2);
  color: var(--tx-1);
  border-radius: var(--r-full);
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.ls-audio-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 18%, var(--bg-2));
  border-color: var(--brand);
}
.ls-audio-btn--ghost {
  opacity: 0.85;
}
.ls-audio-btn--speed {
  min-width: 2.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ls-audio-btn--auto[aria-pressed="true"] {
  opacity: 1;
}
.ls-audio-volume {
  flex: 1 1 88px;
  min-width: 72px;
  max-width: 120px;
  margin-inline-start: auto;
  accent-color: var(--brand);
}
.ls-audio-progress {
  width: 100%;
  height: 3px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--tx-3) 25%, transparent);
  overflow: hidden;
}
.ls-audio-progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  transition: width 0.15s linear;
}
.lesson-card--quiz { padding-top: var(--s4); }
.lesson-card--task {
  background: linear-gradient(145deg, color-mix(in srgb, var(--cyan) 5%, var(--bg-2)), var(--bg-2));
}
.lesson-card--map {
  background: linear-gradient(145deg, color-mix(in srgb, var(--cyan) 8%, var(--bg-2)), var(--bg-2));
}
.lesson-card--pro {
  background: linear-gradient(145deg, color-mix(in srgb, var(--yellow) 10%, var(--bg-2)), var(--bg-2));
}
.lesson-card--pro::after {
  background: linear-gradient(180deg, var(--yellow), var(--orange));
}

.learn-mastery {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin: var(--s3) 0 var(--s4);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--brand) 5%, var(--bg-2));
  font-size: 0.875rem;
}
.learn-mastery-label { font-weight: 600; color: var(--tx-2); }
.learn-mastery-avg { color: var(--brand-hi); font-weight: 700; }
.learn-mastery-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-3);
  font-size: 0.75rem;
}
.learn-mastery-chip--weak {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn);
}

.learn-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin: 0 0 var(--s3);
  padding: var(--s3) var(--s4);
}
.learn-mode-label { font-size: var(--fs-sm); font-weight: 600; color: var(--tx-2); }
.learn-mode-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.learn-mode-btn {
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.learn-mode-btn.is-active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--bg-2)); color: var(--brand-hi); font-weight: 700; }

.learn-expansion { margin: 0 0 var(--s3); padding: var(--s3) var(--s4); }
.learn-expansion-head { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--tx-2); margin-bottom: var(--s2); }
.learn-expansion-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  gap: var(--s2);
  padding-bottom: var(--s1);
}
.learn-expansion-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  max-width: 180px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  border: 1px dashed var(--border);
  background: var(--bg-3);
}
.learn-expansion-soon { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tx-3); }
.learn-expansion-title { font-size: var(--fs-sm); font-weight: 600; line-height: 1.25; }

.ls-order {
  list-style: none;
  margin: var(--s4) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.ls-order-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--border-hi);
  background: var(--bg-2);
  cursor: grab;
  touch-action: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ls-order-item.is-dragging { opacity: 0.6; transform: scale(1.02); }
.ls-order-grip {
  flex: 0 0 auto;
  color: var(--tx-3);
  font-size: 0.75rem;
  letter-spacing: -0.15em;
  user-select: none;
}
.ls-order-text { flex: 1; min-width: 0; text-align: start; }
.ls-order-move {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ls-order-nudge {
  width: 28px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-3);
  color: var(--tx-2);
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.ls-order-nudge:hover { background: var(--bg-4); color: var(--tx); }
.lesson-footer .btn-primary:not(.is-ready) {
  opacity: 0.45;
  cursor: not-allowed;
}
.ls-match-grid {
  display: grid;
  gap: var(--s3);
  margin: var(--s4) 0;
}
.ls-match-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  align-items: center;
}
.ls-code-input {
  width: 100%;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.875rem;
  padding: var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-hi);
  background: var(--bg-1);
  min-height: 8rem;
}

/* ── UI map step (layout guide) ── */
.ls-ui-wireframe {
  display: flex; flex-direction: column; gap: var(--s3);
  margin: var(--s4) 0; padding: var(--s4);
  border-radius: var(--r);
  border: 1px dashed var(--border-hi);
  background: color-mix(in srgb, var(--bg-3) 80%, transparent);
}
.ls-ui-region {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--s3); align-items: center;
  opacity: 0; transform: translate3d(-12px, 8px, 0);
}
.lesson-card.is-visible .ls-ui-region {
  animation: lessonParaIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--i, 0) * 0.07s + 0.08s);
}
.ls-ui-mock {
  border-radius: var(--r-sm); padding: var(--s2) var(--s3);
  background: var(--bg-4); border: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ls-ui-mock--hud { padding: var(--s2); background: transparent; border: none; }
.ls-ui-bar-demo {
  display: block; height: 3px; width: 55%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  animation: ls-ui-bar-grow 1.2s ease-in-out infinite alternate;
}
@keyframes ls-ui-bar-grow { from { width: 35%; opacity: 0.7; } to { width: 72%; opacity: 1; } }
.ls-ui-mock-kicker {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-hi);
}
.ls-ui-mock-h2 {
  font-size: clamp(14px, 3.5vw, 18px); font-weight: 700; color: var(--tx);
  white-space: normal; line-height: 1.25;
}
.ls-ui-mock-section { font-size: 14px; font-weight: 600; color: var(--tx); white-space: normal; }
.ls-ui-mock-prose { font-size: 12px; color: var(--tx-3); white-space: normal; line-height: 1.5; }
.ls-ui-mock-cta {
  font-size: 11px; font-weight: 700; text-align: center;
  background: var(--brand-dim); color: var(--brand-hi); border-color: var(--brand-border);
}
.ls-ui-region-meta { min-width: 0; }
.ls-ui-label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--tx); }
.ls-ui-size {
  display: inline-block; margin-top: 2px; font-size: 10px; font-weight: 600;
  color: var(--cyan); font-family: var(--font-mono);
}
.ls-ui-hint { margin: var(--s1) 0 0; font-size: var(--fs-xs); color: var(--tx-3); line-height: 1.45; }
.ls-ui-trail {
  list-style: none; margin: var(--s4) 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.ls-ui-step-chip {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--tx-2);
  opacity: 0; transform: translateX(-8px);
}
.lesson-card.is-visible .ls-ui-step-chip {
  animation: lessonParaIn 0.45s ease forwards;
  animation-delay: calc(var(--i, 0) * 0.05s + 0.35s);
}
.ls-ui-step-n {
  font-weight: 800; color: var(--brand-hi); min-width: 1.2em;
}
.ls-ui-step-kind {
  margin-inline-start: auto; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--tx-3); font-family: var(--font-mono);
}
.ls-step-tag--pro {
  background: color-mix(in srgb, var(--yellow) 18%, transparent);
  border-color: color-mix(in srgb, var(--yellow) 45%, transparent);
  color: var(--yellow);
}
.ls-step-tag--pro::before { background: var(--yellow); }

/* ── Pro Advices step ── */
.ls-pro-list { list-style: none; margin: var(--s4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.ls-pro-item {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4); border-radius: var(--r);
  border: 1px solid color-mix(in srgb, var(--yellow) 35%, var(--border));
  background: color-mix(in srgb, var(--yellow) 6%, var(--bg-3));
  opacity: 0; transform: translate3d(0, 14px, 0);
}
.lesson-card.is-visible .ls-pro-item {
  animation: ls-pro-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--i, 0) * 0.1s + 0.12s);
}
@keyframes ls-pro-in {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to { opacity: 1; transform: none; }
}
.ls-pro-badge {
  flex-shrink: 0; font-size: 9px; font-weight: 800; letter-spacing: 0.12em;
  padding: 4px 7px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #1a1200;
  animation: ls-pro-badge-pulse 2.4s ease-in-out infinite;
}
@keyframes ls-pro-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--yellow) 40%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 15%, transparent); }
}
.ls-pro-item-title { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--tx); margin-bottom: var(--s1); }
.ls-pro-item-body { margin: 0; font-size: var(--fs-sm); color: var(--tx-2); line-height: 1.55; }

@media (max-width: 520px) {
  .ls-ui-region { grid-template-columns: 1fr; }
}

/* ── Lesson concept illustration (assets/lessons/manifest.json) ──
   Mobile-first: always fluid width inside lesson card; never fixed px in markup. */
.ls-concept-figure {
  --concept-fit: contain;
  margin: 0 0 var(--s5);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-3);
  box-shadow: var(--sh-card);
  contain: layout;
}
.ls-concept-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  object-fit: var(--concept-fit, contain);
  object-position: center;
}
.ls-concept-caption {
  margin: 0;
  padding: var(--s3) var(--s4);
  font-size: var(--fs-sm);
  color: var(--tx-2);
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(124, 58, 237, 0.06);
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}
.lesson-card.is-visible .ls-concept-figure {
  animation: lessonHeadIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@media (max-width: 520px) {
  .ls-concept-figure {
    margin-bottom: var(--s4);
    border-radius: var(--r-md);
  }
  .ls-concept-caption {
    padding: var(--s2) var(--s3);
    font-size: var(--fs-xs);
  }
}

/* ── Live AI lesson step ── */
.ls-live-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ls-live-chat:empty { margin-top: 0; }
.ls-bubble {
  max-width: 86%; padding: 11px 15px; border-radius: 18px;
  font-size: 15px; line-height: 1.45; animation: ls-bubble-in .25s ease;
}
@keyframes ls-bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ls-bubble--me {
  align-self: flex-end; color: #0a0a14; font-weight: 600;
  background: linear-gradient(135deg, var(--brand-hi, #a78bfa), var(--cyan, #22d3ee));
  border-bottom-right-radius: 6px;
}
.ls-bubble--ez {
  align-self: flex-start; color: var(--tx-1);
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.ls-bubble.is-typing { color: var(--tx-3); letter-spacing: 3px; animation: ls-typing 1s infinite; }
@keyframes ls-typing { 50% { opacity: .4; } }
.ls-live-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ls-live-chip {
  padding: 9px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); color: var(--tx-2);
  font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s;
}
.ls-live-chip:hover, .ls-live-chip:active { border-color: var(--brand-hi); color: #fff; }
.ls-live-inputrow { display: flex; gap: 8px; margin-top: 14px; }
.ls-live-input {
  flex: 1; min-width: 0; padding: 13px 16px; border-radius: 14px;
  border: 1px solid var(--border); background: rgba(255,255,255,.05);
  color: #fff; font-size: 16px; /* 16px avoids iOS zoom */
}
.ls-live-input:focus { outline: none; border-color: var(--brand-hi); }
.ls-live-send {
  flex: 0 0 auto; width: 52px; border: none; border-radius: 14px; cursor: pointer;
  color: #0a0a14; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-hi, #a78bfa), var(--cyan, #22d3ee));
}
.ls-live-send:active { transform: scale(.94); }
.ls-live-reveal {
  margin-top: 16px; padding: 15px 17px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,58,237,.2), rgba(34,211,238,.1));
  border: 1px solid rgba(167,139,250,.4); color: var(--tx-1);
  font-size: 15px; line-height: 1.5;
  opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .4s;
}
.ls-live-reveal.is-visible { opacity: 1; transform: none; }

.ls-explain { width: 100%; padding: 0; direction: inherit; text-align: start; }
.ls-prose {
  color: var(--tx-2); line-height: 1.8; font-size: var(--fs-body);
  max-width: 100%;
  text-align: start;
  direction: inherit;
  overflow-wrap: break-word;
  unicode-bidi: plaintext;
}
.ls-prose b, .ls-prose strong { color: var(--tx); font-weight: 600; }
.ls-prose-p {
  margin: 0 0 var(--s4);
  color: var(--tx-2); line-height: 1.8; font-size: var(--fs-body);
  text-align: start;
  transform: translate3d(-14px, 0, 0);
}
.lesson-card.is-visible .ls-prose-p {
  animation: lessonParaIn 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.lesson-card.is-visible .ls-prose-p,
.lesson-card.is-visible .ls-section-title,
.lesson-card.is-visible .quiz-q,
.lesson-card.is-visible .choice,
.lesson-card.is-visible .task-dock-status {
  opacity: 1;
}
.lesson-card.is-visible .ls-prose-p:nth-child(1) { animation-delay: 0.06s; }
.lesson-card.is-visible .ls-prose-p:nth-child(2) { animation-delay: 0.14s; }
.lesson-card.is-visible .ls-prose-p:nth-child(3) { animation-delay: 0.22s; }
.lesson-card.is-visible .ls-prose-p:nth-child(4) { animation-delay: 0.30s; }
.lesson-card.is-visible .ls-prose-p:nth-child(5) { animation-delay: 0.38s; }
.ls-prose-p:last-child { margin-bottom: 0; }
.ls-section-title {
  font-size: var(--fs-h3, 1.125rem); font-weight: 600; color: var(--tx);
  margin: 0 0 var(--s3); line-height: 1.4;
  text-align: start;
  transform: translate3d(-12px, 0, 0);
}
.lesson-card.is-visible .ls-section-title {
  animation: lessonParaIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.04s forwards;
}
.ls-section-lead { margin-top: var(--s1); }
.task-dock-prose { margin-bottom: var(--s4); direction: inherit; text-align: start; }
.task-dock-prose .ls-prose-p { margin-bottom: var(--s3); }
.ls-body { color: var(--tx-2); line-height: 1.75; font-size: var(--fs-body); }
.ls-body b, .ls-body strong { color: var(--tx); font-weight: 600; }

.ls-sandbox-head { margin-bottom: var(--s4); }
.sb-wrap { margin-top: 0; }
.sb-task {
  font-size: var(--fs-body); color: var(--tx-2); line-height: 1.65;
  margin-bottom: var(--s4); text-align: start; width: 100%;
}
.sb-task b { color: var(--tx); }

/* sandbox — IDE panel, not toy window */
.sandbox {
  border: 1px solid var(--border-hi); border-radius: var(--r);
  background: var(--bg-2); overflow: hidden;
  box-shadow: var(--sh-card);
}
.sandbox-live { margin: 0; }
.sb-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px var(--s4);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-3); color: var(--tx-3);
}
.sb-path { color: var(--tx-2); }
.sb-status {
  color: var(--green); font-weight: 500;
  text-transform: lowercase;
}
.sb-status::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--green); margin-inline-end: 6px;
  vertical-align: middle;
}
.sb-status--building { color: var(--yellow); }
.sb-status--building::before {
  background: var(--yellow);
  animation: pulse 1s ease infinite;
}
.sb-status--done { color: var(--green); }

.sb-build-log-wrap {
  border-top: 1px solid var(--border);
  background: #08080c;
}
.sb-build-log-head {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: 6px var(--s4);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--tx-3); border-bottom: 1px solid var(--border);
  margin-bottom: var(--s2);
}
.sb-build-progress {
  height: 4px; border-radius: 99px; background: var(--bg-4);
  margin: 0 0 var(--s2); overflow: hidden;
}
.sb-build-progress-fill {
  height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  transition: width 0.25s ease;
}
.sb-mode-hint {
  font-size: var(--fs-xs); color: var(--tx-2); margin: var(--s2) var(--s3) 0;
  padding: var(--s2) var(--s3); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-3));
  border: 1px solid var(--border);
}
.dock-pane.is-chat-only .btn-generate { opacity: 0.45; pointer-events: none; }
.dock-tab--emph { color: var(--brand-hi) !important; }
.sb-build-log {
  max-height: 88px; overflow-y: auto;
  padding: var(--s2) var(--s4) var(--s3);
  font-family: var(--font-mono); font-size: 11px;
  line-height: 1.55; color: #7dd3a8;
  direction: ltr; text-align: left;
}
.sb-log-line { opacity: 0; animation: logIn .25s forwards; }
.sb-log-line:last-child { color: #a5f3c4; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sb-preview-wrap {
  position: relative;
  background: #0c0c10;
}
.sb-preview-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s3);
  background: color-mix(in srgb, #0c0c10 82%, transparent);
  backdrop-filter: blur(4px);
  font-size: var(--fs-sm); color: var(--tx-2);
}
.sb-preview-wrap.is-building .sb-preview-overlay { display: flex; }
.sb-preview-wrap.is-building .sb-preview { opacity: .35; filter: blur(1px); }
.sb-overlay-text b { color: var(--brand-hi); font-weight: 600; }
.sb-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2);
  padding: var(--s3) var(--s4) 0;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--tx-3);
}
.sb-brief-count {
  font-size: 9px; font-weight: 600; letter-spacing: .04em;
  color: var(--tx-3); text-transform: none;
}
.sb-brief-count.is-warn { color: var(--orange); }
.sandbox textarea {
  width: 100%; border: none; outline: none; resize: vertical;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
  padding: var(--s3) var(--s4); background: var(--bg-2); color: var(--tx);
  direction: ltr; text-align: left; min-height: 96px;
  border-bottom: 1px solid var(--border);
}
.btn-generate {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - var(--s4)*2); margin: var(--s3) var(--s4);
  padding: 11px var(--s4);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brand) 18%, var(--bg-3));
  color: var(--tx); font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; transition: background var(--dur), border-color var(--dur);
}
.btn-generate:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand) 28%, var(--bg-3));
  border-color: var(--brand-hi);
}
.btn-generate:disabled { opacity: .55; cursor: not-allowed; }
.sb-preview-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s2) var(--s4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--tx-3);
}
.sb-preview-meta { color: var(--tx-3); font-weight: 400; }
.sb-preview {
  width: 100%; height: 260px; border: none;
  display: block; background: #0c0c10;
}
.sandbox .code-out {
  padding: var(--s4); border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.7;
  color: var(--tx-2); direction: ltr; text-align: left; white-space: pre;
  background: var(--bg-3);
}

/* lesson body + steps — ls-explain padding lives on .lesson-body only */
.ls-sandbox-head { margin-bottom: var(--s5); width: 100%; }
.sb-wrap { width: 100%; }

/* preview iframe */
.ls-preview {
  margin: var(--s5) var(--s5) 0;
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.preview-frame {
  width: 100%; height: 220px; border: none;
  display: block; background: var(--bg-3);
}
.live-dot-inline {
  margin-inline-start: auto; font-size: var(--fs-xs); color: var(--green); font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

/* quiz — exam-style options */
.quiz-block { padding-top: 0; width: 100%; direction: inherit; text-align: start; }
.quiz-title { margin-bottom: var(--s2); text-align: start; }
.quiz-q {
  font-size: var(--fs-body); font-weight: 500; color: var(--tx);
  line-height: 1.65; margin: var(--s4) 0 var(--s5);
  text-align: start; direction: inherit;
  transform: translate3d(-12px, 0, 0);
}
.lesson-card.is-visible .quiz-q {
  animation: lessonParaIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}
.choices { display: grid; gap: var(--s2); margin: 0; direction: inherit; }
.choice {
  text-align: start; padding: var(--s3) var(--s4);
  border: 1px solid var(--border-hi); border-radius: var(--r-sm);
  background: var(--bg-2); color: var(--tx-2);
  font-size: var(--fs-sm); cursor: pointer;
  display: flex; align-items: flex-start; gap: var(--s3);
  flex-direction: row;
  transition: border-color var(--dur), background var(--dur), color var(--dur), transform var(--dur);
  transform: translate3d(-10px, 4px, 0);
}
.lesson-card.is-visible .choice {
  animation: lessonChoiceIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.lesson-card.is-visible .choice:nth-child(1) { animation-delay: 0.12s; }
.lesson-card.is-visible .choice:nth-child(2) { animation-delay: 0.18s; }
.lesson-card.is-visible .choice:nth-child(3) { animation-delay: 0.24s; }
.choice-key {
  flex: 0 0 auto; width: 22px; height: 22px;
  border-radius: var(--r-sm); border: 1px solid var(--border-hi);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--tx-3); background: var(--bg-3);
}
.choice-text { flex: 1; line-height: 1.55; padding-top: 1px; text-align: start; }
.choice:hover { border-color: var(--brand-border); background: var(--bg-3); color: var(--tx); transform: translateX(2px); }
.choice:hover .choice-key { border-color: var(--tx-3); color: var(--tx-2); }
.choice.correct {
  border-color: color-mix(in srgb, var(--green) 50%, var(--border));
  background: var(--green-dim); color: var(--tx);
}
.choice.correct .choice-key { border-color: var(--green); color: var(--green); background: transparent; }
.choice.wrong {
  border-color: var(--red); background: rgba(239,68,68,.08);
  animation: choiceShake 0.35s ease;
}
.quiz-block.is-checkpoint .choice.wrong { animation: none; }
.quiz-feedback {
  margin: var(--s3) 0 0; padding: var(--s3) var(--s4);
  border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.55;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  color: var(--tx-2); text-align: start;
}

.exercise-block { padding-top: 0; width: 100%; direction: inherit; text-align: start; }
.exercise-badge {
  display: inline-block; margin-bottom: var(--s3);
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--amber); background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.3);
}
.exercise-scenario, .exercise-prompt {
  margin: 0 0 var(--s4); line-height: 1.6; color: var(--tx-2); text-align: start;
}
.exercise-prompt { color: var(--tx); font-weight: 600; }
.exercise-input {
  width: 100%; box-sizing: border-box; margin-bottom: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--border-hi); background: var(--bg-2);
  color: var(--tx); font: inherit; line-height: 1.55; resize: vertical;
}
.exercise-input:focus { outline: none; border-color: var(--brand-border); }
.exercise-choices { display: grid; gap: var(--s2); margin-bottom: var(--s3); }
.exercise-check {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-2); cursor: pointer;
}
.exercise-check input { margin-top: 4px; accent-color: var(--brand); }
.exercise-check.is-correct { border-color: var(--green); background: rgba(34,197,94,.08); }
.exercise-check.is-wrong { border-color: var(--red); background: rgba(239,68,68,.08); }
.exercise-rubric {
  list-style: none; margin: 0 0 var(--s3); padding: 0;
  display: grid; gap: 6px; font-size: var(--fs-sm);
}
.exercise-rubric-item { color: var(--tx-3); }
.exercise-rubric-item.is-met { color: var(--green); font-weight: 600; }
.exercise-feedback {
  margin: 0 0 var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.55;
}
.exercise-feedback.is-pass { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--green); }
.exercise-feedback.is-fail { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); color: var(--tx-2); }
.exercise-check-btn { width: 100%; margin-top: var(--s2); }
.exercise-dock-hint { font-size: var(--fs-sm); color: var(--tx-2); margin-bottom: var(--s3); }
.exercise-open-dock { width: 100%; margin-bottom: var(--s3); }
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  background: color-mix(in srgb, var(--red) 6%, transparent);
  animation: shake .35s;
}
@keyframes shake { 0%,100%{transform:translateX(0)} 30%{transform:translateX(-6px)} 70%{transform:translateX(6px)} }

.explain-box {
  margin: var(--s4) var(--s5) 0;
  padding: var(--s3) var(--s4); border-radius: var(--r-lg);
  background: var(--brand-dim); border: 1px solid var(--brand-border);
  color: var(--tx-2); font-size: var(--fs-sm); line-height: 1.6;
  display: flex; align-items: flex-start; gap: var(--s2);
}
.explain-box strong { color: var(--tx); }

.lesson-footer {
  flex: 0 0 auto;
  width: 100%;
  padding: var(--s4) var(--s5) calc(var(--s4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: blur(8px);
  direction: inherit;
}
.lesson-footer .btn-primary {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: 13px var(--s5);
  min-height: 46px;
  transition: transform var(--dur), box-shadow var(--dur);
}
.lesson-footer .btn-primary.is-ready {
  animation: lessonBtnReady 2.2s ease-in-out infinite;
}

/* loading state inside lesson footer */
.ls-loading {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s4); color: var(--tx-2); font-size: var(--fs-sm);
}

/* skeleton */
.skel {
  background: linear-gradient(90deg, var(--bg-4) 25%, var(--bg-3) 50%, var(--bg-4) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* AI send button spinner */
.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rotate .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes rotate { to { transform: rotate(360deg); } }

/* hidden utility */
.hidden { display: none !important; }

/* cel IDs */
#celXP { color: var(--tx-3); }

/* ===================================================================
   Celebration overlay — minimal, not gamified
   =================================================================== */
.celebrate {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  text-align: center;
  padding: var(--s4);
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.celebrate.show { display: flex; animation: fadein .2s; }

.cel-card {
  width: auto; max-width: min(300px, calc(100vw - 32px));
  padding: var(--s5) var(--s5) var(--s4);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  box-shadow: var(--sh-pop), 0 16px 48px rgba(0, 0, 0, .35);
  pointer-events: auto;
  cursor: pointer;
  animation: cel-pop .28s var(--ease-bounce, cubic-bezier(.34, 1.4, .64, 1));
}
@keyframes cel-pop {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.cel-icon {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  background: var(--green-dim); border: 1px solid color-mix(in srgb, var(--green) 35%, var(--border));
  color: var(--green); display: grid; place-items: center;
  margin: 0 auto var(--s3);
}
.cel-xp {
  font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-xs);
  color: var(--tx-3); margin-bottom: var(--s1); letter-spacing: .04em;
}
.celebrate h2 {
  font-family: var(--font); font-weight: 600; font-size: var(--fs-h2, 1.25rem);
  margin-bottom: var(--s1); letter-spacing: -.01em;
}
.celebrate p {
  color: var(--tx-2); font-size: var(--fs-xs); line-height: 1.55;
  margin-bottom: var(--s4); max-width: 240px; margin-inline: auto;
}
.cel-actions { width: 100%; display: grid; gap: var(--s2); }
.cel-actions .btn { border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; padding: 8px 12px; }
.cel-actions .btn-success {
  background: var(--bg-3); border: 1px solid var(--border-hi); color: var(--tx);
}
.cel-actions .btn-success:hover { background: var(--bg-4); }
.cel-dismiss-hint {
  display: block; margin-top: var(--s3);
  font-size: 10px; color: var(--tx-3); letter-spacing: .02em;
}

/* confetti */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.confetti i {
  position: absolute; top: -10px; width: 7px; height: 12px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0; } }

/* ===================================================================
   Profile
   =================================================================== */
.profile-banner {
  height: 110px; margin: calc(-1 * var(--s4)) calc(-1 * var(--s4)) var(--s5);
  background: linear-gradient(135deg, #2d1060 0%, #0d2050 50%, #1a0a3e 100%);
  background-size: cover; background-position: center top;
  border-radius: var(--r-md) var(--r-md) 0 0;
  position: relative;
}
.profile-banner::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--bg-card) 100%);
}
.profile-head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s6); }
.profile-av {
  width: 58px; height: 58px; border-radius: var(--r-full);
  background: var(--bg-4); border: 2px solid var(--border-hi);
  color: var(--tx-2); display: grid; place-items: center; flex: 0 0 auto;
  overflow: hidden; padding: 0; cursor: pointer; position: relative;
  font: inherit; transition: border-color var(--dur), box-shadow var(--dur);
}
.profile-av:hover { border-color: var(--brand-hi); box-shadow: 0 0 0 3px var(--brand-dim); }
.profile-av img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.profile-av img.avatar-emblem { object-fit: contain; padding: 6px; background: var(--bg-3); }
.hud-avatar img.avatar-emblem { object-fit: contain; padding: 3px; }
  position: absolute; inset-inline-end: -2px; bottom: -2px;
  width: 20px; height: 20px; border-radius: var(--r-full);
  background: var(--brand); color: #fff; border: 2px solid var(--bg-2);
  display: grid; place-items: center;
}

/* Avatar frames */
.av-frame--spark { box-shadow: 0 0 0 2px rgba(245,158,11,.55); }
.av-frame--fighter { box-shadow: 0 0 0 2px rgba(148,163,184,.5); }
.av-frame--champion { box-shadow: 0 0 0 2px rgba(167,139,250,.6), 0 0 12px rgba(124,58,237,.25); }
.av-frame--diamond { box-shadow: 0 0 0 2px rgba(244,114,182,.65), 0 0 16px rgba(236,72,153,.2); }

/* Avatar picker */
.av-picker {
  position: fixed; inset: 0; z-index: 65;
  display: none; align-items: flex-end; justify-content: center;
}
.av-picker.show { display: flex; }
.av-picker-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}
.av-picker-sheet {
  position: relative; z-index: 1; width: 100%; max-width: 480px;
  max-height: min(92vh, 720px); overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border-hi);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-pop); padding: var(--s5);
  animation: av-sheet-in .28s var(--ease);
}
@keyframes av-sheet-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
.av-picker-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--s3); margin-bottom: var(--s4);
}
.av-picker-head h2 {
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-h1);
}
.av-picker-sub { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 4px; line-height: 1.45; }
.av-preview {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4); background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: var(--s5);
}
.av-preview-ring {
  width: 72px; height: 72px; border-radius: var(--r-full); flex: 0 0 auto;
  overflow: hidden; background: var(--bg-4);
}
.av-preview-ring img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-preview-emblem { object-fit: contain !important; padding: 8px; }
.av-preview-meta strong { display: block; font-size: var(--fs-body); margin-bottom: 6px; }
.av-preview-meta p { font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.5; margin-top: 6px; }
.av-track-pill {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--av-c) 15%, transparent);
  color: var(--av-c); border: 1px solid color-mix(in srgb, var(--av-c) 30%, transparent);
}
.av-section { margin-bottom: var(--s5); }
.av-section-title {
  font-size: var(--fs-sm); font-weight: 600; color: var(--tx-2); margin-bottom: var(--s2);
}
.av-section-hint { font-size: var(--fs-xs); color: var(--tx-3); margin-bottom: var(--s3); }
.av-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3);
}
.av-card {
  border: 1px solid var(--border); background: var(--bg-3);
  border-radius: var(--r-lg); padding: var(--s3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; color: inherit; transition: border-color var(--dur), background var(--dur);
}
.av-card:hover:not(:disabled) { border-color: var(--border-hi); background: var(--bg-4); }
.av-card.selected { border-color: var(--brand); background: var(--brand-dim); }
.av-card.locked { opacity: .45; cursor: not-allowed; }
.av-card--buy { border-color: rgba(245,158,11,.35); }
.av-card-img {
  width: 52px; height: 52px; border-radius: var(--r-full); overflow: hidden;
  position: relative; background: var(--bg-4);
}
.av-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-card-img--emblem img { object-fit: contain; padding: 6px; }
.av-lock {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; color: #fff;
}
.av-card-name { font-size: 10px; font-weight: 600; text-align: center; line-height: 1.25; }
.av-card-hint { font-size: 9px; color: var(--tx-3); text-align: center; }
.av-frames { display: flex; gap: var(--s2); flex-wrap: wrap; }
.av-frame-btn {
  border: 1px solid var(--border); background: var(--bg-3);
  border-radius: var(--r); padding: var(--s2) var(--s3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 56px; font: inherit; color: var(--tx-2); font-size: 10px;
}
.av-frame-btn.selected { border-color: var(--brand); background: var(--brand-dim); }
.av-frame-btn.locked { opacity: .4; cursor: not-allowed; }
.av-frame-ring {
  width: 28px; height: 28px; border-radius: var(--r-full);
  border: 2px solid var(--border-hi); background: var(--bg-4);
}
.av-frame-ring.av-frame--spark { border-color: #F59E0B; box-shadow: 0 0 8px rgba(245,158,11,.3); }
.av-frame-ring.av-frame--fighter { border-color: #94A3B8; }
.av-frame-ring.av-frame--artisan { border-color: #EAB308; box-shadow: 0 0 8px rgba(234,179,8,.25); }
.av-frame-ring.av-frame--master { border-color: #06B6D4; box-shadow: 0 0 8px rgba(6,182,212,.3); }
.av-frame-ring.av-frame--champion { border-color: #A78BFA; box-shadow: 0 0 10px rgba(124,58,237,.35); }
.av-frame-cost { font-family: var(--font-mono); font-size: 9px; color: var(--yellow); }
.av-picker-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding-top: var(--s4); border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--bg-2);
}
.av-coins {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--yellow);
}

@media (min-width: 640px) {
  .av-picker { align-items: center; padding: var(--s4); }
  .av-picker-sheet { border-radius: var(--r-xl); max-height: 85vh; }
}

.profile-head h2 { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-h1); }
.profile-head p { font-size: var(--fs-sm); color: var(--tx-2); margin-top: 2px; }

/* parent banner */
.parent-banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  background: var(--cyan-dim);
  border: 1px solid rgba(6,182,212,.25);
  border-radius: var(--r-lg); padding: var(--s4);
  margin-top: var(--s4);
}
.parent-banner .pi { color: var(--cyan); flex: 0 0 auto; margin-top: 2px; }
.parent-banner b { font-weight: 600; font-size: var(--fs-body); }
.parent-banner p { font-size: var(--fs-sm); color: var(--tx-2); margin-top: 2px; }

/* theme toggle */
.theme-toggle {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-full);
  background: var(--bg-4); border: 1px solid var(--border);
}
.theme-toggle button {
  border: none; background: none; cursor: pointer; color: var(--tx-2);
  width: 30px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center;
  transition: background var(--dur), color var(--dur);
}
.theme-toggle button.on { background: var(--brand); color: #fff; }

.profile-settings-card { padding: var(--s3) var(--s4); }
.profile-about-card {
  padding: var(--s3) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.profile-about-lead {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--tx-2);
  line-height: 1.5;
}
.profile-about-creds {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--brand-hi);
  letter-spacing: .01em;
}
.profile-about-link {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand-hi);
  text-decoration: none;
}
.profile-about-link:hover { text-decoration: underline; }
.profile-sign-out-card {
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
}
.profile-sign-out-btn {
  width: 100%;
  border-color: color-mix(in srgb, var(--red) 35%, var(--border));
  color: color-mix(in srgb, var(--red) 85%, var(--tx));
}
.profile-sign-out-btn:hover {
  background: color-mix(in srgb, var(--red) 10%, var(--bg-3));
  border-color: color-mix(in srgb, var(--red) 50%, var(--border));
}
.profile-setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.profile-setting-label { font-weight: 500; }
.sb-usage { margin-inline-start: auto; font-size: var(--fs-xs); color: var(--tx-2); font-variant-numeric: tabular-nums; }

.model-picker-card {
  padding: var(--s4);
  margin-bottom: var(--s3);
  background: linear-gradient(145deg, var(--bg-2) 0%, color-mix(in srgb, var(--brand) 6%, var(--bg-2)) 100%);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--border));
  overflow: hidden;
  position: relative;
}
.model-picker-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 100% 0%, color-mix(in srgb, var(--cyan) 12%, transparent), transparent 55%);
  pointer-events: none;
}
.model-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s3);
  margin-bottom: var(--s4);
  position: relative;
}
.model-picker-title {
  font-family: var(--font-d);
  font-size: var(--fs-h3);
  font-weight: 700;
  margin: 0 0 4px;
}
.model-picker-sub {
  font-size: var(--fs-xs);
  color: var(--tx-2);
  margin: 0;
  max-width: 28rem;
  line-height: 1.45;
}
.model-picker-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand-hi);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  flex-shrink: 0;
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s3);
  position: relative;
}
.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--s3);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 118px;
}
.model-card:hover:not(.is-locked) {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--model-c) 55%, var(--border));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--model-c) 18%, transparent);
}
.model-card.is-selected {
  border-color: var(--model-c);
  box-shadow: 0 0 0 1px var(--model-c), 0 12px 32px color-mix(in srgb, var(--model-c) 22%, transparent);
}
.model-card.is-selected .model-card-glow { opacity: 1; }
.model-card.is-locked {
  opacity: 0.72;
  cursor: not-allowed;
  filter: saturate(0.65);
}
.model-card-glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 80%;
  background: radial-gradient(circle, color-mix(in srgb, var(--model-c) 35%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.model-card-orb {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--model-c) 22%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--model-c) 40%, transparent);
  margin-bottom: 4px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
  overflow: hidden;
}
.model-card-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: auto;
  transform: scale(1.08);
}
.model-card-tier {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--model-c);
  opacity: 0.9;
}
.model-card-name {
  font-weight: 700;
  font-size: var(--fs-sm);
  line-height: 1.2;
}
.model-card-tag {
  font-size: 10px;
  color: var(--tx-2);
  line-height: 1.35;
}
.model-card-lock {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--tx-2);
  margin-top: auto;
  padding-top: 4px;
}
.model-card-active {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  font-size: 9px;
  font-weight: 700;
  color: var(--model-c);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: model-pulse 2s ease-in-out infinite;
}
@keyframes model-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.profile-locale-select {
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--tx);
  font-family: inherit;
}

.usage-card { padding: var(--s4); margin-bottom: var(--s3); }
.usage-meter { margin-bottom: var(--s3); }
.usage-meter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--fs-sm); margin-bottom: var(--s2);
}
.usage-meter-vals { font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-bar {
  height: 8px; border-radius: 99px; background: var(--bg-3); overflow: hidden;
}
.usage-bar-fill {
  height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  transition: width 0.35s ease;
}
.usage-bar--calls .usage-bar-fill { background: linear-gradient(90deg, #22c55e, #06b6d4); }
.usage-bar-fill.is-warn { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.usage-household { font-size: var(--fs-xs); color: var(--tx-2); margin: 0 0 var(--s3); }
.usage-lessons { font-size: var(--fs-xs); color: var(--tx-2); }
.usage-lesson-row {
  display: flex; justify-content: space-between; gap: var(--s2);
  padding: 6px 0; border-top: 1px solid var(--border);
}
.usage-lesson-row:first-child { border-top: 0; }
.usage-upgrade-btn { width: 100%; margin-top: var(--s3); }
.parent-dashboard { padding: var(--s4); margin-bottom: var(--s3); }
.parent-dashboard-head { display: flex; gap: var(--s3); margin-bottom: var(--s4); }
.parent-dashboard-head p { font-size: var(--fs-sm); color: var(--tx-2); margin-top: 2px; }
.parent-learner-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--s2) var(--s3);
  align-items: center; padding: var(--s2) 0; border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.parent-learner-row:first-child { border-top: 0; }
.parent-learner-row .alias { font-weight: 600; }
.parent-learner-row .nums { text-align: end; font-variant-numeric: tabular-nums; color: var(--tx-2); }

/* Auth gate */
.auth-gate {
  --auth-ice: #67e8f9;
  --auth-sky: #38bdf8;
  --auth-violet: #c4b5fd;
  --auth-mint: #5eead4;
  --auth-indigo: #818cf8;
  --auth-door-solo: #a78bfa;
  --auth-door-family: #38bdf8;
  --auth-door-team: #67e8f9;
  --auth-door-invite: #5eead4;
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transition: opacity 0.55s var(--ease);
  box-sizing: border-box;
}
.auth-gate--open { opacity: 1; }
.auth-gate[hidden] { display: none !important; }
.app[hidden] { display: none !important; }

.auth-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #030308;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.auth-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.92;
}
.auth-bg-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.62;
  mix-blend-mode: screen;
  animation: auth-aurora-drift 18s ease-in-out infinite alternate;
  will-change: transform;
}
.auth-bg-aurora--1 {
  width: 70vmax; height: 70vmax;
  top: -25%; left: -20%;
  background: radial-gradient(circle, rgba(56,189,248,.42), transparent 68%);
}
.auth-bg-aurora--2 {
  width: 60vmax; height: 60vmax;
  bottom: -30%; right: -18%;
  background: radial-gradient(circle, rgba(167,139,250,.34), transparent 70%);
  animation-delay: -6s;
  animation-duration: 22s;
}
.auth-bg-aurora--3 {
  width: 45vmax; height: 45vmax;
  top: 30%; left: 30%;
  background: radial-gradient(circle, rgba(94,234,212,.28), transparent 72%);
  animation-delay: -11s;
  animation-duration: 26s;
}
.auth-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(167,139,250,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(167,139,250,.05) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.35;
  animation: auth-grid-pan 50s linear infinite;
}
.auth-bg-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 120% 90% at 50% 40%, transparent 25%, rgba(3,3,8,.75) 100%),
    linear-gradient(180deg, rgba(3,3,8,.15), rgba(3,3,8,.55));
  pointer-events: none;
}

.auth-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s4);
  box-sizing: border-box;
}

.auth-card {
  position: relative;
  width: 100%;
  padding: clamp(20px, 5vw, 28px) clamp(16px, 4vw, 24px);
  border-radius: 28px;
  border: none;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  backdrop-filter: blur(32px) saturate(1.4);
  -webkit-backdrop-filter: blur(32px) saturate(1.4);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.05) inset,
    0 32px 100px rgba(0,0,0,.55),
    0 0 100px rgba(124,58,237,.16);
  transform: translateY(24px) scale(0.97);
  opacity: 0;
  transition:
    transform 0.65s cubic-bezier(.22,1,.36,1),
    opacity 0.5s var(--ease),
    box-shadow 0.4s var(--ease);
  box-sizing: border-box;
  isolation: isolate;
  animation: auth-card-breathe 6s ease-in-out infinite;
}
.auth-card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    145deg,
    rgba(56,189,248,.45),
    rgba(167,139,250,.18) 45%,
    rgba(94,234,212,.1) 80%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.auth-gate--open .auth-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.auth-mark {
  position: relative;
  width: 76px; height: 76px;
  margin: 0 auto var(--s5);
}
.auth-mark-orbit {
  position: absolute; inset: -6px;
  border-radius: 22px;
  background: conic-gradient(from 0deg, var(--brand), var(--cyan), var(--brand-hi), var(--brand));
  animation: auth-ring-spin 10s linear infinite;
  opacity: 0.85;
  filter: blur(0.5px);
}
.auth-mark-orbit::after {
  content: "";
  position: absolute; inset: 2px;
  border-radius: 20px;
  background: #0a0a12;
}
.auth-mark-core {
  position: absolute; inset: 8px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(124,58,237,.35), rgba(6,182,212,.12));
  box-shadow: 0 12px 40px rgba(124,58,237,.35);
  animation: auth-logo-float 4.5s ease-in-out infinite;
}
.auth-mark-ez {
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -.04em;
  line-height: 1;
  background: linear-gradient(135deg, #fff, var(--brand-hi) 50%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-mark-spark {
  position: absolute;
  top: 6px; right: 8px;
  width: 14px; height: 14px;
  color: var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan));
  animation: auth-spark 2.2s ease-in-out infinite;
}

.auth-head { text-align: center; margin-bottom: var(--s5); }
.auth-head h1 {
  font-family: var(--font-d);
  font-size: clamp(20px, 5vw, 24px);
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 var(--s2);
  background: linear-gradient(135deg, #fff 0%, var(--auth-sky) 50%, var(--auth-mint) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-sub {
  font-size: var(--fs-sm);
  color: var(--tx-2);
  line-height: 1.55;
  max-width: 36ch;
  margin: 0 auto;
}
.auth-head p { font-size: var(--fs-sm); color: var(--tx-2); }

.auth-tabs {
  position: relative;
  display: flex;
  margin-bottom: var(--s5);
  padding: 5px;
  border-radius: 999px;
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(255,255,255,.06);
}
.auth-tab-indicator {
  position: absolute;
  top: 5px;
  left: 5px;
  height: calc(100% - 10px);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 65%, var(--cyan)) 100%);
  box-shadow: 0 4px 20px rgba(124,58,237,.45);
  transition: left 0.38s cubic-bezier(.22,1,.36,1), width 0.38s cubic-bezier(.22,1,.36,1);
  pointer-events: none;
  z-index: 0;
}
.auth-tab {
  position: relative; z-index: 1;
  flex: 1;
  min-width: 0;
  padding: 11px 10px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--tx-2);
  font-family: inherit;
  font-size: clamp(12px, 3.2vw, 13px);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.25s var(--ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-tab:hover { color: var(--tx); }
.auth-tab.active { color: #fff; }

.auth-panels { position: relative; min-height: 0; }
.auth-panel { animation: auth-panel-in 0.4s var(--ease) both; }
.auth-panel[hidden] { display: none !important; }

.auth-form { display: flex; flex-direction: column; gap: var(--s3); }
.auth-label { font-size: var(--fs-sm); font-weight: 600; color: var(--tx); }
.auth-input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.28);
  color: var(--tx);
  font-family: inherit;
  font-size: 16px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
  box-sizing: border-box;
}
.auth-input::placeholder { color: var(--tx-3); }
.auth-input:hover { border-color: rgba(255,255,255,.14); }
.auth-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  box-shadow: 0 0 0 3px var(--brand-dim), 0 0 28px rgba(124,58,237,.18);
  background: rgba(0,0,0,.38);
}
.auth-check {
  display: flex; gap: var(--s2); align-items: flex-start;
  font-size: var(--fs-sm); color: var(--tx-2); line-height: 1.45;
}
.auth-check input { margin-top: 3px; accent-color: var(--brand); flex-shrink: 0; }
.auth-error { color: var(--danger, #e55); font-size: var(--fs-sm); margin: 0; min-height: 1.2em; }
.auth-sent {
  color: var(--green);
  font-size: var(--fs-sm);
  padding: var(--s2) var(--s3);
  border-radius: 14px;
  background: var(--green-dim);
  border: 1px solid rgba(16,185,129,.25);
  animation: auth-panel-in 0.35s var(--ease);
}
.auth-dev-link { font-size: var(--fs-xs); color: var(--tx-2); }
.auth-submit {
  width: 100%;
  margin-top: var(--s1);
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  min-height: 48px;
}
.auth-submit::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.2) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.6s var(--ease);
}
.auth-submit:hover::after { transform: translateX(120%); }
.auth-demo {
  margin-top: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.auth-demo-heading {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tx-3);
  text-align: center;
}
.auth-demo-group { display: flex; flex-direction: column; gap: var(--s2); }
.auth-demo-group-label {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--tx-2);
}
.auth-demo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s2);
}
.auth-demo-grid--comply { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .auth-demo-grid--comply { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.auth-demo-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--s3);
  min-height: 72px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: var(--tx-1);
  text-align: start;
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-demo-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.22);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.auth-demo-card:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-demo-card-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.25;
}
.auth-demo-card-desc {
  font-size: var(--fs-xs);
  color: var(--tx-2);
  line-height: 1.35;
}
.auth-demo-card--teen {
  background: color-mix(in srgb, #c4b5fd 18%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #c4b5fd 35%, transparent);
}
.auth-demo-card--pro {
  background: color-mix(in srgb, #6ee7b7 16%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #6ee7b7 32%, transparent);
}
.auth-demo-card--parent {
  background: color-mix(in srgb, #fdba74 16%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #fdba74 32%, transparent);
}
.auth-demo-card--hr {
  background: color-mix(in srgb, #7dd3fc 16%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #7dd3fc 32%, transparent);
}
.auth-demo-card--manager {
  background: color-mix(in srgb, #c4b5fd 16%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #c4b5fd 32%, transparent);
}
.auth-demo-card--auditor {
  background: color-mix(in srgb, #94a3b8 14%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #94a3b8 30%, transparent);
}
.auth-demo-card--sales-manager {
  background: color-mix(in srgb, #f472b6 14%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #f472b6 30%, transparent);
}
.auth-demo-card--employee-sales {
  background: color-mix(in srgb, #fb923c 14%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #fb923c 30%, transparent);
}
.auth-demo-card--employee {
  background: color-mix(in srgb, #fcd34d 14%, rgba(255,255,255,.04));
  border-color: color-mix(in srgb, #fcd34d 30%, transparent);
}
.auth-demo-card--teen:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #c4b5fd 22%, transparent); }
.auth-demo-card--pro:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #6ee7b7 20%, transparent); }
.auth-demo-card--parent:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #fdba74 20%, transparent); }
.auth-demo-card--hr:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #7dd3fc 20%, transparent); }
.auth-demo-card--manager:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #c4b5fd 20%, transparent); }
.auth-demo-card--auditor:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #cbd5e1 18%, transparent); }
.auth-demo-card--sales-manager:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #f472b6 18%, transparent); }
.auth-demo-card--employee-sales:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #fb923c 18%, transparent); }
.auth-demo-card--employee:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, #fcd34d 18%, transparent); }
.auth-panel-title { font-size: var(--fs-md); font-weight: 700; margin: 0 0 var(--s1); }
.auth-panel-sub { font-size: var(--fs-sm); color: var(--tx-2); margin: 0 0 var(--s4); line-height: 1.5; }
.auth-hint { font-size: var(--fs-xs); color: var(--tx-3); margin-top: var(--s3); text-align: center; }
.auth-foot {
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--tx-3), var(--brand-hi), var(--cyan), var(--tx-3));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s var(--ease) 0.25s, transform 0.6s var(--ease) 0.25s;
  animation: auth-tagline-shine 8s linear infinite;
}
.auth-gate--open .auth-foot {
  opacity: 1;
  transform: translateY(0);
}
.auth-showcase-link {
  text-align: center;
  margin: var(--s2) 0 0;
  font-size: var(--fs-sm);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s var(--ease) 0.35s, transform 0.6s var(--ease) 0.35s;
}
.auth-showcase-link a {
  color: var(--brand-hi);
  text-decoration: none;
  font-weight: 600;
}
.auth-showcase-link a:hover { text-decoration: underline; }
.auth-gate--open .auth-showcase-link {
  opacity: 1;
  transform: translateY(0);
}

@keyframes auth-aurora-drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(5%, -4%) scale(1.1); }
}
@keyframes auth-grid-pan {
  0% { background-position: 0 0; }
  100% { background-position: 56px 56px; }
}
@keyframes auth-ring-spin { to { transform: rotate(360deg); } }
@keyframes auth-logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes auth-spark {
  0%, 100% { opacity: 0.35; transform: scale(0.85) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.15) rotate(12deg); }
}
@keyframes auth-panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes auth-card-breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,.05) inset, 0 32px 100px rgba(0,0,0,.55), 0 0 80px rgba(124,58,237,.12); }
  50% { box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset, 0 32px 100px rgba(0,0,0,.55), 0 0 110px rgba(124,58,237,.22); }
}
@keyframes auth-tagline-shine {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate, .auth-card, .auth-foot, .auth-tab-indicator, .auth-panel { transition: none !important; }
  .auth-bg-aurora, .auth-bg-grid, .auth-mark-orbit, .auth-mark-core, .auth-mark-spark, .auth-foot, .auth-card { animation: none !important; }
  .auth-gate--open .auth-card, .auth-gate--open .auth-foot { opacity: 1; transform: none; }
}

@media (min-width: 768px) {
  .auth-stage { max-width: 460px; }
  .auth-card { padding: 32px 28px 28px; border-radius: 32px; }
  .auth-card::before { border-radius: 32px; }
}

@media (max-width: 380px) {
  .auth-tab { padding-inline: 6px; font-size: 11px; }
  .auth-mark { width: 64px; height: 64px; }
}
.parent-invite-block { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.parent-invite-url { display: flex; gap: var(--s2); align-items: stretch; }
.parent-invite-url .auth-input { flex: 1; font-size: var(--fs-xs); }
.parent-household-settings { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.parent-consent-row { margin-top: var(--s1); }

.sb-usage { margin-inline-start: auto; font-size: var(--fs-xs); color: var(--tx-2); font-variant-numeric: tabular-nums; }

/* ===================================================================
   Nav dock (mobile bottom bar · desktop right sidebar)
   =================================================================== */
.nav-dock {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--chrome-bg) 94%, transparent);
  border-top: 1px solid var(--chrome-border);
  z-index: 35;
  box-sizing: border-box;
}
.nav-inner {
  display: flex; flex: 1; align-items: stretch;
}
.nav-resize-handle,
.dock-resize-handle { display: none; }

.nav-head { display: none; }
.nav-icon-btn { display: none; }
.nav-rail-only { display: none; }
.nav-desktop-only { display: none; }
.tab-label { display: none; }

.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--tx-3);
  font-family: var(--font); font-size: 10px; font-weight: 600;
  transition: color var(--dur), background var(--dur);
}
/* Must beat .tab { display:flex } — same specificity, later wins */
.nav-dock .tab.nav-desktop-only { display: none !important; }
.tab.active { color: var(--tx); }
.tab .ti { transition: transform var(--dur) var(--ease); }
.tab .ti-img {
  width: 22px; height: 22px; object-fit: contain; flex: 0 0 auto;
  opacity: .75; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
  transition: opacity var(--dur), transform var(--dur) var(--ease);
}
.tab .ti-img--avatar { border-radius: var(--r-full); object-fit: cover; opacity: 1; }
.tab.active .ti-img { opacity: 1; }
.tab.active .ti { transform: translateY(-1px); }

/* Nav badge icons */
.ti-badge {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  opacity: .7; transition: opacity var(--dur), transform var(--dur) var(--ease);
  background: rgba(255,255,255,.07);
  color: var(--tx-2);
}
.tab .ti-badge .ic {
  width: 22px; height: 22px;
}
.tab.active .ti-badge { opacity: 1; transform: translateY(-1px); color: #fff; }
.tab:hover .ti-badge { opacity: .9; }
.ti-badge--journey  { background: rgba(255,255,255,.06); color: var(--tx-2); }
.ti-badge--projects { background: rgba(34,211,238,.18); color: #22d3ee; }
.ti-badge--league   { background: rgba(251,191,36,.2);  color: #fbbf24; }
.ti-badge--learn    { background: rgba(52,211,153,.18); color: #34d399; }
.ti-badge--studio   { background: rgba(192,132,252,.2); color: #c084fc; }
.tab.active .ti-badge--journey  { background: rgba(124,58,237,.22); color: #c4b5fd; }
.tab.active .ti-badge--projects { background: rgba(34,211,238,.3);   color: #67e8f9; }
.tab.active .ti-badge--league   { background: rgba(251,191,36,.35);  color: #fde68a; }
.tab.active .ti-badge--learn    { background: rgba(52,211,153,.3);   color: #6ee7b7; }
.tab.active .ti-badge--studio   { background: rgba(192,132,252,.35); color: #e9d5ff; }

/* PWA install prompt + standalone */
.pwa-install {
  position: fixed;
  inset-inline: var(--s3);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s3));
  z-index: 60;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-hi);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  box-shadow: var(--sh-pop);
  backdrop-filter: blur(12px);
  animation: pwa-in .25s var(--ease);
}
@keyframes pwa-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.pwa-install-body { padding: var(--s4); }
.pwa-install-title { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--s2); }
.pwa-install-hint { font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.45; margin-bottom: var(--s3); }
.pwa-install-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pwa-install-actions .btn { flex: 1; min-width: 7rem; justify-content: center; }
html.is-standalone .pwa-install { display: none !important; }
@media (min-width: 940px) {
  .pwa-install { display: none !important; }
}

.sidebar-brand { display: none; }
.sidebar-section { display: none; }
.sidebar-spacer { display: none; }

body.is-resizing-nav,
body.is-resizing-dock {
  cursor: ew-resize !important;
  user-select: none;
}
body.is-resizing-nav *,
body.is-resizing-dock * {
  cursor: ew-resize !important;
}

/* ===================================================================
   EZ AI Sandbox Dock — persistent left panel
   =================================================================== */
.sandbox-dock {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: row;
  background: var(--chrome-bg);
  border-right: 1px solid var(--chrome-border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, .35);
  transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
  width: var(--dock-w);
  overflow: hidden;
}
.sandbox-dock.hidden {
  width: 0;
  border: none;
  pointer-events: none;
}
.sandbox-dock.hidden .dock-panel { opacity: 0; }
.sandbox-dock.collapsed {
  width: var(--dock-rail);
}
.sandbox-dock.collapsed .dock-panel {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  left: var(--dock-rail);
}
.sandbox-dock.open .dock-resize-handle { display: block; }

.dock-resize-handle {
  position: absolute;
  top: 0; right: 0;
  width: 6px; height: 100%;
  cursor: ew-resize;
  z-index: 5;
  touch-action: none;
}
.dock-resize-handle::after {
  content: "";
  position: absolute;
  top: 50%; right: 1px;
  width: 3px; height: 48px;
  transform: translateY(-50%);
  border-radius: var(--r-full);
  background: var(--chrome-border);
  opacity: 0;
  transition: opacity var(--dur), background var(--dur);
}
.sandbox-dock.open .dock-resize-handle:hover::after,
body.is-resizing-dock .dock-resize-handle::after {
  opacity: 1;
  background: var(--brand-hi);
}

.dock-rail {
  width: var(--dock-rail);
  flex: 0 0 var(--dock-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: 0 0 var(--s3);
  background: var(--chrome-bg);
  border-right: 1px solid var(--chrome-border);
  z-index: 2;
}
/* HUD-height strip — aligned with main header */
.dock-rail::before {
  content: "";
  display: block;
  height: var(--hud-h);
  min-height: var(--hud-h);
  flex: 0 0 var(--hud-h);
  width: 100%;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  box-sizing: border-box;
}
.dock-rail-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--tx-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.dock-rail-btn:hover { background: var(--bg-4); color: var(--brand-hi); border-color: var(--brand-border); }
.dock-rail-label {
  font-size: 9px; font-weight: 700;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin-top: 4px;
  letter-spacing: .04em;
}
.dock-rail-btn#dockOpenBtn {
  height: auto; min-height: 72px;
  padding: var(--s2) 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}

.dock-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity var(--dur);
}
.dock-head {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--hud-h);
  min-height: var(--hud-h);
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  flex: 0 0 auto;
  box-sizing: border-box;
}
.dock-agent { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.dock-agent-av {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brand) 20%, var(--bg-2));
  border: 1px solid var(--brand-border);
  color: var(--brand-hi);
  display: grid; place-items: center; flex: 0 0 auto;
}
.dock-agent-mark {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 0 8px rgba(167,139,250,.42));
}
.dock-agent-mark rect {
  fill: color-mix(in srgb, var(--brand) 64%, var(--cyan) 36%);
}
.dock-agent-mark path {
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dock-agent-name { font-weight: 700; font-size: var(--fs-sm); color: var(--tx); line-height: 1.2; }
.dock-ctx {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--tx-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px; line-height: 1.3;
}
.dock-head-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.dock-icon-btn {
  width: 28px; height: 28px;
  font-size: 16px; line-height: 1; padding: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--tx-2);
}
.dock-icon-btn:hover {
  background: var(--bg-4);
  color: var(--tx);
  border-color: var(--brand-border);
}

.dock-tabs {
  display: flex; gap: 2px; padding: var(--s2);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  flex: 0 0 auto;
}
.dock-tab {
  flex: 1; padding: 7px 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent; color: var(--tx-3);
  font-size: var(--fs-xs); font-weight: 600;
  cursor: pointer; transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.dock-tab:hover { color: var(--tx-2); background: var(--bg-3); border-color: var(--border); }
.dock-tab.active {
  background: var(--bg-3); color: var(--tx);
  border-color: var(--border-hi);
}

.dock-body { flex: 1; overflow: hidden; position: relative; }
.dock-pane {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: var(--s3);
  opacity: 0; visibility: hidden;
  transition: opacity .15s;
}
.dock-pane.active { opacity: 1; visibility: visible; }

.dock-pane[data-pane="build"] {
  display: flex; flex-direction: column; gap: 0;
  padding: 0;
}
.dock-pane[data-pane="build"] .sb-label { padding: var(--s3) var(--s3) 0; }
.dock-pane[data-pane="build"] textarea {
  margin: var(--s2) var(--s3);
  width: calc(100% - var(--s3) * 2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-3);
  font-family: var(--font-mono);
  font-size: 12px; padding: var(--s3);
  color: var(--tx); resize: vertical; min-height: 88px;
  direction: ltr; text-align: left;
}
.dock-pane[data-pane="build"] .btn-generate { margin: 0 var(--s3) var(--s3); width: calc(100% - var(--s3)*2); }
.dock-pane[data-pane="build"] .sb-build-log-wrap { margin: 0 var(--s3); }
.dock-pane[data-pane="build"] .sb-preview-head { margin: 0 var(--s3); }
.dock-pane[data-pane="build"] .sb-preview-wrap { margin: 0 var(--s3) var(--s3); }
.dock-pane[data-pane="build"] .sb-preview { height: 200px; border-radius: var(--r-sm); }

.dock-chat-wrap {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
}
.dock-chat-scroll, #dockChat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s3);
  min-height: 0;
}
.dock-chat-compose {
  flex: 0 0 auto;
  display: flex;
  gap: var(--s2);
  padding: var(--s3);
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}
.dock-chat-compose textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: var(--s2) var(--s3);
  color: var(--tx);
  resize: none;
  min-height: 44px;
}
.dock-chat-send { flex: 0 0 auto; align-self: flex-end; }

.dock-msg {
  border-radius: var(--r-sm);
  padding: var(--s3);
  border: 1px solid var(--border);
  background: var(--bg-3);
}
.dock-msg--user { border-color: var(--brand-border); background: color-mix(in srgb, var(--brand) 8%, var(--bg-3)); }
.dock-msg--agent { border-color: var(--border-hi); }
.dock-msg-head {
  font-size: 10px; font-weight: 600; color: var(--tx-3);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.dock-msg-body { font-size: var(--fs-sm); color: var(--tx-2); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

.dock-empty {
  padding: var(--s6) var(--s4); text-align: center;
  font-size: var(--fs-sm); color: var(--tx-3); line-height: 1.6;
}
.dock-rules {
  margin: var(--s2) var(--s3) var(--s3);
  padding: var(--s3);
  font-size: 0.8rem;
  color: var(--tx-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-3);
}
.dock-rules-title {
  font-weight: 700;
  color: var(--tx-1);
  margin-bottom: var(--s2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dock-rules-list {
  margin: 0;
  padding-inline-start: 1.1rem;
  display: grid;
  gap: 0.35rem;
  line-height: 1.45;
}
.dock-mem-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--s3); margin-bottom: var(--s2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-3); font-size: var(--fs-sm); color: var(--tx-2);
}
.dock-mem-tag {
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--cyan);
}

.hud-sandbox {
  width: 28px; height: 28px; flex: 0 0 auto;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx-3);
  display: grid; place-items: center; cursor: pointer;
}
.hud-sandbox:hover { background: var(--bg-4); color: var(--tx-2); }

.app.dock-open { padding-left: var(--dock-w); }
.app.dock-collapsed { padding-left: var(--dock-rail); }
.app.dock-hidden { padding-left: 0; }

.task-dock-hint {
  padding: var(--s4);
  border: 1px solid color-mix(in srgb, var(--cyan) 25%, var(--border));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--cyan) 4%, var(--bg-2));
  margin-top: var(--s4);
  direction: inherit;
  text-align: start;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--border-hi) 40%, transparent);
}
.task-dock-hint .ls-section-title { margin-top: 0; }
.task-dock-hint p { color: var(--tx-2); line-height: 1.65; margin-bottom: var(--s4); font-size: var(--fs-sm); text-align: start; }
.task-dock-hint .task-dock-actions { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-start; }
.task-dock-status {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--cyan); margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px solid var(--border);
  text-align: start;
}
.task-project-progress {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--brand-hi);
  margin-bottom: var(--s4); padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid var(--brand-border);
  text-align: start; direction: inherit;
}
.task-project-progress--new { color: var(--tx-2); border-color: var(--border); background: var(--bg-3); }
.task-project-head { margin-bottom: var(--s2); text-align: start; }
.task-project-name { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--tx); }
.task-project-sub { display: block; font-size: 11px; color: var(--tx-3); margin-top: 2px; line-height: 1.4; }
.task-project-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--green);
  animation: orb-pulse 1.6s ease infinite;
}
.dock-ctx-row {
  display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1;
}
.dock-build-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--green); padding: 2px 8px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  white-space: nowrap;
}

/* Hebrew RTL — lesson overlay + task dock */
html[dir="rtl"] .lesson-coach {
  background: linear-gradient(270deg, rgba(124,58,237,.12), transparent 72%);
}
html[dir="rtl"] .lesson-card {
  padding: var(--s5) var(--s5) var(--s5) calc(var(--s5) + 4px);
  transform: translate3d(18px, 10px, 0) scale(0.985);
}
html[dir="rtl"] .lesson-card::after {
  inset-inline-start: auto;
  inset-inline-end: 0;
}
html[dir="rtl"] .ls-prose-p { transform: translate3d(14px, 0, 0); }
html[dir="rtl"] .ls-section-title { transform: translate3d(12px, 0, 0); }
html[dir="rtl"] .quiz-q { transform: translate3d(12px, 0, 0); }
html[dir="rtl"] .choice {
  flex-direction: row-reverse;
  transform: translate3d(10px, 4px, 0);
}
html[dir="rtl"] .choice:hover { transform: translateX(-2px); }

@keyframes lessonHeadIn {
  from { opacity: 0; transform: translate3d(-16px, 8px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes lessonParaIn {
  from { opacity: 0; transform: translate3d(-14px, 6px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes lessonChoiceIn {
  from { opacity: 0; transform: translate3d(-10px, 6px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes coachTipIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}
html[dir="rtl"] .lesson-head { animation-name: lessonHeadInRtl; }
html[dir="rtl"] .lesson-card.is-visible .ls-prose-p { animation-name: lessonParaInRtl; }
html[dir="rtl"] .lesson-card.is-visible .choice { animation-name: lessonChoiceInRtl; }
html[dir="rtl"] .lesson-coach-tip { animation-name: coachTipInRtl; }
@keyframes lessonHeadInRtl {
  from { opacity: 0; transform: translate3d(16px, 8px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes lessonParaInRtl {
  from { opacity: 0; transform: translate3d(14px, 6px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes lessonChoiceInRtl {
  from { opacity: 0; transform: translate3d(10px, 6px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes coachTipInRtl {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes lessonBtnReady {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 0%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 18%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-card,
  .lesson-card .ls-prose-p,
  .lesson-card .ls-section-title,
  .lesson-card .quiz-q,
  .lesson-card .choice,
  .lesson-head,
  .ls-step-tag,
  .lesson-coach-tip,
  .lesson-footer .btn-primary.is-ready {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .lesson-card { opacity: 1; transform: none; }
}

/* ===================================================================
   RESPONSIVE — Tablet ≥ 680px
   =================================================================== */
@media (min-width: 680px) {
  .screen:not(#screen-studio) {
    padding-inline: max(var(--s5), calc((100% - 620px) / 2));
  }
  .lesson-body,
  .lesson-footer .btn-primary {
    max-width: 680px;
  }
}

@media (max-width: 939px) {
  .app.dock-open { padding-left: 0; }
  .app.dock-collapsed { padding-left: 0; }

  /* Left AI dock — hidden on phone; full-screen sheet only when a lesson opens it */
  .sandbox-dock.collapsed,
  .sandbox-dock.hidden {
    display: none !important;
  }
  .sandbox-dock.open {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 85;
    width: 100vw !important;
    max-width: 100vw;
    box-shadow: none;
  }
  .sandbox-dock.open .dock-rail { display: none; }
  .sandbox-dock.open .dock-panel { flex: 1; width: 100%; }
  .hud-sandbox { display: none !important; }

  /* Journey — map first; hide dock shortcuts on phone */
  .journey-scene #ezOpenDock,
  .journey-scene #ezOpenDock2 { display: none !important; }
  .journey-scene .ez-guide-inner {
    display: grid;
    grid-template-columns: 36px 1fr;
    align-items: start;
    gap: var(--s2);
    padding: var(--s2) var(--s3);
  }
  .journey-scene .ez-speech-wrap { min-width: 0; }
  .journey-scene .ez-role { display: none; }
  .journey-scene .ez-bubble { max-height: 3.2em; overflow: hidden; }
  .journey-scene .ez-actions .btn-ghost { display: none !important; }

  /* Floating companion — mobile sheet (see companion block below) */
  .ez-companion:not(.is-hidden) {
    display: flex !important;
  }

  .app.dock-open .lesson.open { left: 0; }
  .app.dock-collapsed .lesson.open { left: 0; }
}

@media (min-width: 940px) {
  .app.dock-open {
    padding-left: var(--dock-w);
  }
  .app.dock-collapsed {
    padding-left: var(--dock-rail);
  }
}

/* ===================================================================
   RESPONSIVE — Desktop ≥ 940px  →  sidebar layout
   =================================================================== */
@media (min-width: 940px) {
  .app {
    display: grid;
    direction: ltr;
    grid-template-columns: 1fr var(--nav-w, 220px);
    grid-template-rows: var(--hud-h) 1fr;
    grid-template-areas:
      "hud side"
      "main side";
    height: 100dvh; max-width: 100%; min-height: 0;
  }

  .hud,
  .screens,
  .nav-dock { direction: inherit; }

  html[dir="rtl"] .hud,
  html[dir="rtl"] .screens,
  html[dir="rtl"] .nav-dock { direction: rtl; }

  .hud      { grid-area: hud; }
  .screens  { grid-area: main; min-width: 0; }
  .nav-dock { grid-area: side; }

  .screen:not(#screen-studio) { padding-block: var(--s8); padding-bottom: var(--s8); }

  /* Right nav dock — desktop */
  .nav-dock {
    position: relative;
    left: auto; right: auto; bottom: auto;
    width: 100%; height: 100%; min-height: 0;
    padding: 0;
    border-top: none;
    border-inline-start: 1px solid var(--chrome-border);
    background: var(--chrome-bg);
    overflow: hidden;
    z-index: 36;
    flex-direction: column;
  }
  .nav-inner {
    flex-direction: column;
    align-items: stretch;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 2px;
    padding: 0 0 var(--s3);
  }
  .nav-head {
    display: flex;
    align-items: center;
    gap: var(--s2);
    height: var(--hud-h);
    min-height: var(--hud-h);
    padding: 0 var(--s3);
    border-bottom: 1px solid var(--chrome-border);
    flex-shrink: 0;
    box-sizing: border-box;
  }
  .nav-head .sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--s2);
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    margin: 0;
    height: auto;
    font-family: var(--font-d);
    font-weight: 700;
    font-size: 17px;
    color: var(--tx);
  }
  .nav-icon-btn {
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    border: 1px solid var(--chrome-border);
    border-radius: var(--r-sm);
    background: var(--bg-3);
    color: var(--tx-2);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
  }
  .nav-icon-btn:hover { color: var(--brand-hi); border-color: var(--brand-border); }
  .nav-desktop-only { display: flex; }
  .nav-dock .tab.nav-desktop-only { display: flex !important; }
  .nav-rail-only { display: none; }

  .nav-resize-handle {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 6px; height: 100%;
    cursor: ew-resize;
    z-index: 4;
    touch-action: none;
  }
  .nav-resize-handle::after {
    content: "";
    position: absolute;
    top: 50%; left: 1px;
    width: 3px; height: 48px;
    transform: translateY(-50%);
    border-radius: var(--r-full);
    background: var(--chrome-border);
    opacity: 0;
    transition: opacity var(--dur), background var(--dur);
  }
  .nav-dock.open .nav-resize-handle:hover::after,
  body.is-resizing-nav .nav-resize-handle::after {
    opacity: 1;
    background: var(--brand-hi);
  }
  .nav-dock.collapsed .nav-resize-handle { display: none; }

  .sidebar-section {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4) var(--s2);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tx-3);
  }
  .sidebar-brand .logo-icon {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    background: var(--bg-4);
    display: grid; place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
  }
  .sidebar-brand .logo-icon img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }
  .nav-ic {
    width: 16px; height: 16px;
    object-fit: contain;
    opacity: .6;
  }
  .sidebar-spacer { display: block; flex: 1; }

  .tab {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--s3);
    margin-inline: var(--s2);
    padding: 10px var(--s3);
    border-radius: var(--r);
    font-size: var(--fs-body);
    font-weight: 500;
    color: color-mix(in srgb, var(--tx-2) 88%, var(--tx-3));
  }
  .tab-label { display: inline; }
  .tab:hover { background: color-mix(in srgb, var(--bg-3) 92%, transparent); color: var(--tx); }
  .tab.active {
    background: var(--bg-3);
    color: var(--tx);
    box-shadow: inset 3px 0 0 var(--brand);
  }
  .tab.active .ti { transform: none; }
  .tab .ti-badge {
    width: 36px; height: 36px;
    border-radius: 10px;
  }
  .tab .ti-badge .ic {
    width: 24px; height: 24px;
  }

  /* Collapsed → icon rail only */
  .nav-dock.collapsed .nav-desktop-only { display: none !important; }
  .nav-dock.collapsed .nav-rail-only { display: grid; }
  .nav-dock.collapsed .nav-inner {
    align-items: center;
    padding: var(--s2) 0 var(--s3);
    gap: var(--s2);
  }
  .nav-dock.collapsed .nav-head {
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0;
    flex-shrink: 0;
  }
  .nav-dock.collapsed .nav-head .sidebar-brand { display: none !important; }
  .nav-dock.collapsed .nav-brand-text { display: none; }
  .nav-dock.collapsed .nav-icon-btn {
    width: 44px;
    height: 44px;
    margin: var(--s2) 0;
    border-radius: var(--r-md);
    font-size: 22px;
    background: var(--bg-2);
    border-color: var(--border-hi);
  }
  .nav-dock.collapsed .tab {
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    gap: 0;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    box-shadow: none;
  }
  .nav-dock.collapsed .tab .ti-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    opacity: .88;
    filter: none;
  }
  .nav-dock.collapsed .tab .ti-badge .ic {
    width: 24px;
    height: 24px;
  }
  .nav-dock.collapsed .tab .ti-img {
    width: 24px;
    height: 24px;
    opacity: .88;
    filter: none;
  }
  .nav-dock.collapsed .tab .ti-img--avatar {
    width: 26px;
    height: 26px;
    border: 2px solid var(--border-hi);
    box-sizing: border-box;
  }
  .nav-dock.collapsed .tab:hover {
    background: var(--bg-3);
    border-color: var(--border-hi);
    color: var(--tx);
  }
  .nav-dock.collapsed .tab.active {
    background: var(--bg-3);
    border-color: var(--border-hi);
    color: var(--tx);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent);
  }
  .nav-dock.collapsed .tab.active .ti-badge,
  .nav-dock.collapsed .tab.active .ti-img { opacity: 1; }
  .nav-dock.collapsed .tab-label { display: none; }

  .hud { padding-inline: var(--s6); }

  .proj-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s3);
  }
  .proj-grid .card + .card { margin-top: 0; }
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--tab-h) + var(--bc-space, 0px) + 16px);
  inset-inline-start: 50%; transform: translateX(50%);
  background: var(--bg-3); color: var(--tx);
  border: 1px solid var(--border-hi); padding: 10px 18px;
  border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--sh-pop); z-index: 70; pointer-events: none;
  max-width: 85%; text-align: center; white-space: nowrap;
  opacity: 0; transition: opacity .18s, transform .18s;
  transform: translateX(50%) translateY(8px);
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

@media (max-width: 939px) {
  .hud,
  .nav-dock {
    background: color-mix(in srgb, var(--chrome-bg) 94%, transparent);
    backdrop-filter: blur(10px);
  }

  :root {
    --bc-w: min(100%, calc(100vw - 24px));
    --bc-avatar: 42px;
    --bc-space-collapsed: 50px;
  }
}

@media (min-width: 940px) {
  .toast { inset-inline-start: calc(var(--nav-w, 220px) + 50%); bottom: 24px; }
}

/* ===================================================================
   EZ AI floating companion (all tabs)
   =================================================================== */
:root {
  --bc-space: 0px;
  --bc-w: 268px;
  --bc-avatar: 44px;
  --bc-space-collapsed: 52px;
}

.ez-companion.is-hidden { display: none !important; }

/* Shared EZ AI chip (journey / inline — not floating companion) */
.ez-chip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.ez-chip-glow {
  position: absolute;
  inset: -5px;
  border-radius: var(--r-md);
  background: radial-gradient(circle at 50% 40%, rgba(167,139,250,.35), transparent 70%);
  animation: ez-glow 2s ease-in-out infinite alternate;
}
.ez-chip-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--r-md);
  background: linear-gradient(145deg, var(--bg-3), var(--bg-4));
  border: 2px solid var(--brand-hi);
  box-shadow: 0 4px 20px rgba(124,58,237,.35);
  display: grid;
  place-items: center;
  color: var(--brand-hi);
  transition: transform .2s var(--ease), border-color .2s, color .2s;
}
.ez-chip.emote-think .ez-chip-body { animation: bc-think 1.2s ease-in-out infinite; color: var(--cyan); }
.ez-chip.emote-laugh .ez-chip-body { animation: bc-celebrate .55s ease infinite; color: var(--yellow); }
.ez-chip.emote-blah .ez-chip-body { animation: bc-peek 1s ease-in-out 2; }
.ez-chip.emote-retro .ez-chip-body { animation: bc-zap .4s ease 3; color: var(--cyan); border-radius: 5px; }
.bc-chip { width: 56px; height: 56px; }
@keyframes bc-think {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px) scale(.97); }
}
@keyframes bc-celebrate {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-8px) rotate(-6deg); }
  75% { transform: translateY(-4px) rotate(6deg); }
}
@keyframes bc-peek {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px) scale(1.04); }
}
@keyframes bc-zap {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); transform: scale(1.06); }
}

.ez-companion {
  position: fixed;
  z-index: 65;
  inset-inline-end: max(10px, env(safe-area-inset-right));
  bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  max-width: min(var(--bc-w), calc(100vw - 20px));
}
.ez-companion > * { pointer-events: auto; }

html.bc-sheet-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.bc-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
@media (max-width: 939px) {
  .bc-backdrop { display: block; }
  .ez-companion.is-open .bc-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

.bc-panel {
  position: relative;
  width: var(--bc-w);
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-2) 94%, #000);
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--brand) 10%);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  transform-origin: bottom right;
  transition:
    opacity .22s ease,
    transform .24s cubic-bezier(.22, 1, .36, 1),
    max-height .24s ease,
    padding .22s ease;
  max-height: min(34dvh, 260px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
html[dir="rtl"] .bc-panel { transform-origin: bottom left; }

.bc-sheet-handle {
  display: none;
  width: 28px;
  height: 3px;
  margin: 0 auto 8px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--tx-3) 45%, transparent);
  flex-shrink: 0;
}

.ez-companion.collapsed .bc-panel,
.ez-companion:not(.is-open) .bc-panel {
  opacity: 0;
  transform: translateY(8px) scale(.97);
  max-height: 0;
  padding-block: 0;
  padding-inline: 12px;
  border-width: 0;
  pointer-events: none;
  box-shadow: none;
}
.ez-companion.is-open .bc-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.bc-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.bc-head-av .bc-fab-face {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}
.bc-head-av .bc-fab-ic { width: 16px; height: 16px; }
.bc-head-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.bc-name {
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--tx);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.bc-sub {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  color: var(--tx-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-sub:empty { display: none; }
.bc-minimize {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--tx-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.bc-minimize:hover {
  color: var(--tx);
  background: var(--bg-3);
}

.bc-text-scroll {
  flex: 1;
  min-height: 0;
  max-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
  scrollbar-width: thin;
}
.bc-chat-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bc-msg { max-width: 88%; }
.bc-msg--user {
  align-self: flex-end;
  padding: 6px 10px;
  border-radius: 12px 12px 4px 12px;
  background: color-mix(in srgb, var(--brand) 72%, #1a1030);
  color: #fff;
  font-size: var(--fs-xs);
  line-height: 1.4;
}
.bc-msg--bot { align-self: flex-start; }
.bc-msg-tag {
  display: inline-block;
  margin-bottom: 3px;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--brand) 12%, var(--bg-3));
  color: var(--tx-3);
}
.bc-msg-body {
  padding: 6px 10px;
  border-radius: 4px 12px 12px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--tx);
}
.bc-msg-body b { color: var(--brand-hi); font-weight: 600; }
.bc-msg-body.typing::after {
  content: "▋";
  animation: ez-cursor .7s step-end infinite;
  color: var(--brand-hi);
}
.bc-msg--thinking .bc-thinking-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 4px 12px 12px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.bc-thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tx-3);
  animation: bc-dot 1.1s ease-in-out infinite;
}
.bc-thinking-dots i:nth-child(2) { animation-delay: .12s; }
.bc-thinking-dots i:nth-child(3) { animation-delay: .24s; }

.bc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.bc-chip-btn {
  min-height: 26px;
  padding: 4px 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx-2);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.bc-chip-btn:hover {
  color: var(--tx);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  background: color-mix(in srgb, var(--brand) 8%, var(--bg-3));
}

.bc-ask-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.bc-ask-input {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--tx);
  font-size: var(--fs-xs);
}
.bc-ask-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
}
.bc-ask-send {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s, background .12s;
}
.bc-ask-send:hover { background: color-mix(in srgb, var(--brand) 88%, #fff); }
.bc-ask-send:active { transform: scale(.94); }
.bc-send-ic { width: 16px; height: 16px; }
html[dir="rtl"] .bc-send-ic { transform: scaleX(-1); }

.ez-companion.collapsed .bc-ask-row,
.ez-companion:not(.is-open) .bc-ask-row,
.ez-companion.collapsed .bc-chips,
.ez-companion:not(.is-open) .bc-chips {
  display: none;
}

.bc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 6px;
}
.bc-actions:empty { display: none; }

/* ── Compact FAB ── */
.bc-fab-face {
  display: grid;
  place-items: center;
  width: var(--bc-avatar);
  height: var(--bc-avatar);
  border-radius: 14px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 88%, #000), color-mix(in srgb, var(--brand-hi) 40%, var(--brand)));
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  transition: transform .18s ease, box-shadow .18s ease;
}
.bc-fab-ic { width: 22px; height: 22px; opacity: .95; }

.bc-avatar-wrap {
  position: relative;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  align-self: flex-end;
  transition: transform .18s ease;
}
.bc-avatar-wrap:hover .bc-fab-face {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .32);
}
.bc-avatar-wrap:active { transform: scale(.94); }
.ez-companion.is-open .bc-avatar-wrap { transform: scale(.92); opacity: .85; }
.ez-companion.bc-emote-wave .bc-fab-face { animation: bc-fab-wiggle .45s ease; }
.ez-companion.bc-emote-think .bc-fab-face { opacity: .88; }
.ez-companion.is-thinking .bc-fab-face {
  background: linear-gradient(145deg, color-mix(in srgb, var(--cyan) 55%, var(--brand)), var(--brand));
}

.bc-unread {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid var(--bg-1);
  z-index: 1;
  pointer-events: none;
}
.bc-unread[hidden] { display: none; }
.ez-companion.has-unread:not(.is-open) .bc-unread {
  animation: bc-unread-blink 1.6s ease-in-out infinite;
}

@keyframes bc-dot {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@keyframes bc-fab-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@keyframes bc-unread-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

@media (max-width: 939px) {
  :root {
    --bc-w: min(268px, calc(100vw - 24px));
    --bc-avatar: 42px;
    --bc-space-collapsed: 50px;
  }
  .ez-companion.is-open .bc-sheet-handle { display: block; }
  .ez-companion.is-open .bc-panel {
    max-height: min(38dvh, 280px);
  }
}

@media (min-width: 940px) {
  .ez-companion {
    inset-inline-end: calc(var(--nav-w, 220px) + 14px);
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  :root { --bc-w: 276px; --bc-avatar: 44px; }
  .bc-backdrop { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .ez-companion,
  .ez-companion *,
  .bc-panel,
  .bc-avatar-wrap,
  .bc-fab-face {
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

/* ── Teen UX: onboarding, streak nudge, league solo, parent banner ── */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s5);
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
}
.onboarding-overlay[hidden] { display: none !important; }
.onboarding-card {
  max-width: 420px; width: 100%;
  padding: var(--s6);
  text-align: center;
}
.onboarding-kicker {
  font-size: var(--fs-xs); color: var(--tx-3);
  margin-bottom: var(--s3);
}
.onboarding-demo-note {
  font-size: var(--fs-sm); color: var(--orange);
  margin: var(--s3) 0;
}
.onboarding-actions {
  display: flex; flex-direction: column; gap: var(--s3);
  margin-top: var(--s5);
}
.onboarding-skip { align-self: center; }

.streak-nudge {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s5);
  background: linear-gradient(90deg, rgba(249, 115, 22, .12), transparent);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--tx-2);
}
.streak-nudge[hidden] { display: none !important; }
.streak-nudge-dismiss {
  margin-inline-start: auto;
  background: none; border: none;
  font-size: 1.25rem; line-height: 1;
  color: var(--tx-3); cursor: pointer;
  padding: var(--s1) var(--s2);
}

.parent-banner {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4) var(--s5);
  margin: var(--s4) var(--s5) 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
}
.parent-banner[hidden] { display: none !important; }
.parent-controls { margin-top: var(--s4); }

.lg-av-initial {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-weight: 600; font-size: var(--fs-sm);
  color: var(--tx-2);
  text-transform: uppercase;
}
.lg-solo-hint, .lg-empty {
  padding: var(--s4) var(--s5);
  font-size: var(--fs-sm);
  color: var(--tx-3);
  text-align: center;
}

/* ===================================================================
   RESPONSIVE — Phone only (iPhone Pro / Pro Max, <=480px)
   Tablet (>=680px) and desktop (>=940px) rules are untouched above.
   =================================================================== */
@media (max-width: 480px) {
  .app {
    --s4: 14px;
    --s5: 16px;
    --s6: 18px;
    --s8: 24px;
    --hud-h: 48px;
    --tab-h: 56px;
    --fs-h1: 20px;
    --fs-h2: 16px;
    --fs-body: 14px;
    --fs-sm: 12px;
    --fs-xs: 10px;
    --fs-xl: 24px;
    --r-lg: 12px;
    --r-xl: 14px;
  }

  /* Safe-area chrome */
  .hud {
    gap: var(--s1);
    padding: env(safe-area-inset-top) var(--s4) 0;
    height: calc(var(--hud-h) + env(safe-area-inset-top));
    min-height: calc(var(--hud-h) + env(safe-area-inset-top));
  }
  .hud-stat { gap: 3px; font-size: 10px; }
  .hud-stat .ic-sm { width: 14px; height: 14px; }
  .hud-xp { gap: 2px; min-width: 72px; }
  .hud-xp .row { font-size: 10px; }
  .hud-gem-icon { width: 12px !important; height: 12px !important; margin-right: 2px; }
  .hud-plan {
    font-size: 9px;
    padding: 2px 6px;
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hud-sandbox {
    width: 32px; height: 32px;
    min-width: 32px; padding: 0;
  }
  .hud-avatar { width: 32px; height: 32px; }

  .screen:not(#screen-studio) {
    padding: var(--s5) var(--s4) calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s5));
  }
  .page-head { margin-bottom: var(--s5); }
  .page-head h1 { font-size: var(--fs-h1); letter-spacing: -.018em; }
  .page-head p { font-size: var(--fs-sm); line-height: 1.45; }
  .sec-label { padding-top: var(--s4); font-size: 10px; }

  /* Bottom nav — 3 tabs on phone (Journey · Learn · League); Settings in HUD */
  .nav-dock {
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    gap: 2px;
    font-size: 9px;
    min-width: 0;
    padding-inline: 2px;
  }
  .tab .ti-img { width: 20px; height: 20px; }
  .tab .ti-badge { width: 30px; height: 30px; border-radius: 8px; }
  .tab .ti-badge .ic { width: 20px; height: 20px; }
  .tab.active .ti { transform: none; }
  .tab.active .ti-badge { transform: none; }

  /* Journey (extends existing max-width:479 rules) */
  .journey-scene .ez-guide-inner { padding: var(--s2) var(--s3); }
  .journey-world-slide .journey-map { max-height: min(52vh, 380px); }
  .journey-edge-nav { width: 36px; }

  /* League */
  .lg-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s4);
    padding: var(--s4);
  }
  .lg-hero-orb,
  .lg-orb-emblem { width: 56px; height: 56px; }
  .lg-hero-rank-num { font-size: 26px; }
  .lg-road {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--s3);
  }
  .lg-board-top,
  .lg-board-header,
  .lg-player,
  .lg-divider { padding-inline: var(--s4); }
  .lg-player { gap: var(--s2); padding-block: 8px; }
  .lg-pname { font-size: var(--fs-sm); }
  .lg-score-col { min-width: 40px; }
  .lg-grow-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .lg-grow-actions .btn { width: 100%; justify-content: center; min-height: 44px; }
  .lg-grow-actions .btn-ghost { grid-column: 1 / -1; }
  .lg-lp-breakdown { gap: var(--s1); }
  .lg-lp-chip { font-size: 10px; padding: 4px 8px; }
  .lg-scope-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lg-activity-item { font-size: var(--fs-xs); padding: var(--s2) 0; gap: var(--s2); }
  .lg-demo-banner { padding: var(--s3); margin-bottom: var(--s3); }
  .lg-page-head { flex-direction: column; align-items: stretch; }
  .lg-timer-pill { align-self: flex-start; }
  .lg-gap { flex-wrap: wrap; font-size: var(--fs-sm); padding: var(--s3); }
  .lg-quest-head { flex-wrap: wrap; gap: var(--s2); }

  /* Me / Profile */
  #screen-me .profile-banner {
    height: 88px;
    margin: calc(-1 * var(--s4)) calc(-1 * var(--s4)) var(--s4);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .profile-head { gap: var(--s3); margin-bottom: var(--s5); }
  .profile-head h2 { font-size: var(--fs-h1); }
  .stat-row { border-radius: var(--r); }
  .stat-cell { padding: var(--s3) var(--s2); }
  .stat-cell .v { font-size: 18px; }
  .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .model-card { min-height: 104px; padding: var(--s2); }
  .model-picker-head { flex-direction: column; align-items: flex-start; gap: var(--s2); }
  .parent-banner { margin: var(--s3) var(--s4) 0; padding: var(--s3); }
  .usage-card { padding: var(--s3); }

  /* Projects */
  .proj-hero { padding: var(--s4); }
  .proj-hero-stats { grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
  .proj-stat-val { font-size: var(--fs-body); }
  .proj-grid-next { grid-template-columns: 1fr; gap: var(--s3); }
  .proj-achieve-grid { grid-template-columns: 1fr; }
  .proj-card-preview { height: 120px; }
  .proj-card-actions { flex-direction: column; }
  .proj-card-actions .btn { min-width: 0; width: 100%; }

  /* Learn */
  .learn-rank-head { flex-direction: row; align-items: center; padding: var(--s3); }
  .learn-rank-title { font-size: var(--fs-lg); }
  .learn-rank-level { width: 48px; height: 48px; font-size: var(--fs-lg); }
  .learn-rank-xp { padding: 0 var(--s3) var(--s3); }
  .learn-rank-skills { padding: var(--s3); }
  .learn-rank-skills-primary,
  .learn-rank-skills-extra { grid-template-columns: 1fr; gap: var(--s1); }
  .learn-rank-xp-labels { flex-direction: column; align-items: flex-start; gap: 2px; }
  .learn-rank-xp-next { text-align: start; }
  .route-pick { grid-template-columns: 1fr; gap: var(--s1); padding: 0 0 var(--s2); }
  .route-chip { padding: var(--s2) var(--s3); }
  .learn-grade {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s3);
    padding: var(--s4);
  }
  .learn-skills { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s1); }
  .learn-skill { padding: var(--s2); }
  .learn-track-head { padding: var(--s3); }
  .learn-track-body { padding: var(--s2) var(--s3) var(--s3); }
  .learn-lesson { padding: var(--s2) var(--s3); gap: var(--s2); }

  /* Lesson overlay */
  .lesson-hud {
    padding: env(safe-area-inset-top) var(--s3) 0;
    height: calc(var(--hud-h) + env(safe-area-inset-top));
    min-height: calc(var(--hud-h) + env(safe-area-inset-top));
    gap: var(--s2);
  }
  .lesson-body {
    padding: var(--s4);
    max-width: none;
  }
  .lesson-card .ls-concept-figure {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
  .lesson-card .ls-concept-img {
    width: 100%;
    max-width: 100%;
    height: auto;
  }
  .lesson-footer {
    padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  }
  .lesson-coach { padding: var(--s2) var(--s3); }
  .lesson-coach-chip { width: 36px; height: 36px; }
  .lesson-path-rail-head {
    flex: 0 0 calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
  .app.dock-open .lesson.open,
  .app.dock-collapsed .lesson.open { left: 0; }

  /* Sandbox dock — full-screen sheet when opened from a lesson */
  .sandbox-dock.open {
    width: 100vw;
    max-width: 100vw;
  }

  /* Auth + overlays */
  .auth-gate { padding: var(--s4); padding-top: calc(var(--s4) + env(safe-area-inset-top)); }
  .auth-stage { max-width: 100%; }
  .auth-card { padding: var(--s5) var(--s4); border-radius: var(--r-xl); }
  .auth-demo-grid,
  .auth-demo-grid--comply { grid-template-columns: 1fr; }
  .onboarding-overlay { padding: var(--s4); padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
  .onboarding-card { padding: var(--s5); }
  .streak-nudge { padding: var(--s2) var(--s4); font-size: var(--fs-xs); }
  .pwa-install {
    inset-inline: var(--s2);
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s2));
  }

  /* Companion — safe-area + touch targets (sheet rules in main block) */
  .ez-companion:not(.is-hidden) {
    inset-inline-end: max(10px, env(safe-area-inset-right));
    bottom: calc(var(--tab-h) + 6px + env(safe-area-inset-bottom));
  }
  .bc-text { font-size: var(--fs-sm); }
  .bc-actions .btn { min-height: 44px; }
  .card { border-radius: var(--r-lg); }
  .btn { min-height: 44px; padding: 11px 16px; font-size: var(--fs-body); }
  .celebrate { padding: var(--s4); padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
}

/* iPhone Pro Max — slightly roomier gutters without affecting tablet */
@media (min-width: 414px) and (max-width: 480px) {
  .app { --s4: 15px; --s5: 17px; }
  .screen { padding-inline: var(--s5); }
  .tab { font-size: 9.5px; }
  .model-grid { gap: var(--s3); }
}

.auth-turnstile {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 0.25rem;
  min-height: 65px;
}

.auth-legal-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.78rem;
}

.auth-legal-nav a {
  color: var(--text-muted, #9493a8);
  text-decoration: none;
}

.auth-legal-nav a:hover {
  color: var(--accent, #06b6d4);
}

/* Retention platform — Daily Drop (HUD chip + popover), Feed, Prestige */
.hud-daily-drop {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--brand-hi);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.hud-daily-drop:hover {
  border-color: var(--brand-border);
  background: var(--brand-dim);
  color: var(--brand-hi);
}
.hud-daily-drop.is-open {
  border-color: var(--brand);
  background: var(--brand-dim);
  box-shadow: 0 0 0 1px var(--brand-border);
}
.hud-daily-drop--pending::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-end: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--chrome-bg);
}
.hud-daily-drop--done { color: var(--green); opacity: .85; }
.hud-daily-drop--done::after { display: none; }

.daily-drop-portal {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}
.daily-drop-portal:not([hidden]) {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(var(--s4), env(safe-area-inset-top, 0px))
    max(var(--s4), env(safe-area-inset-right, 0px))
    max(var(--s4), env(safe-area-inset-bottom, 0px))
    max(var(--s4), env(safe-area-inset-left, 0px));
}
body.daily-drop-open { overflow: hidden; }

.daily-drop-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(4px);
}

.daily-drop-popover {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(85dvh, 640px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--s4);
  border-radius: var(--r-lg);
  border: 1px solid rgba(124, 58, 237, .4);
  background: linear-gradient(160deg, rgba(124, 58, 237, .14), var(--bg-2) 42%);
  box-shadow: var(--sh-pop);
  pointer-events: auto;
  animation: daily-drop-in .2s ease-out;
}
@keyframes daily-drop-in {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.daily-drop-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.daily-drop-popover-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  flex-wrap: wrap;
}
.daily-drop-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: rgba(249, 115, 22, .15);
  color: var(--orange);
}
.daily-drop-badge--lab {
  background: rgba(139, 92, 246, .18);
  color: var(--purple, #a78bfa);
}
.daily-drop-lab {
  font-size: var(--fs-xs);
  color: var(--purple, #a78bfa);
  margin: 0 0 var(--s2);
  line-height: 1.4;
}
.daily-drop-summary {
  color: var(--tx-2);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s2);
  line-height: 1.45;
}
.daily-drop-steps {
  margin-bottom: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, .15);
  max-height: 9.5rem;
  overflow: auto;
}
.daily-drop-steps-label {
  font-size: var(--fs-xs);
  color: var(--tx-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: var(--s2);
}
.daily-drop-steps-list {
  margin: 0;
  padding-inline-start: 1.1rem;
  font-size: var(--fs-xs);
  color: var(--tx-2);
  line-height: 1.4;
}
.daily-drop-steps-list li + li { margin-top: 4px; }
.daily-drop-meta {
  font-size: var(--fs-xs);
  color: var(--tx-3);
  margin: 0 0 var(--s3);
}
.daily-drop-progress {
  margin-bottom: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-3);
}
.daily-drop-progress--ready { border-color: rgba(16, 185, 129, .35); }
.daily-drop-progress-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--fs-xs);
  color: var(--tx-3);
  margin-bottom: var(--s2);
}
.daily-drop-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-4);
  overflow: hidden;
}
.daily-drop-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-hi));
  transition: width .2s ease;
}
.daily-drop-progress--ready .daily-drop-progress-fill { background: var(--green); }
.daily-drop-progress-note,
.daily-drop-hint {
  font-size: var(--fs-xs);
  color: var(--tx-2);
  margin: var(--s2) 0 0;
  line-height: 1.4;
}
.daily-drop-hint { color: var(--orange); margin-bottom: 0; }
.daily-drop-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.daily-drop-minimize {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx-3);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.daily-drop-minimize:hover { color: var(--tx); border-color: var(--border-hi); }
.daily-drop-kicker {
  font-size: var(--fs-xs);
  color: var(--brand-hi);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.daily-drop-title { margin: 0 0 var(--s2); font-size: var(--fs-md); line-height: 1.25; }
.daily-drop-prompt {
  color: var(--tx-2);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s3);
  line-height: 1.45;
  max-height: 8.5em;
  overflow: auto;
}
.daily-drop-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.daily-drop-done { color: var(--green); font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: var(--s2); }
.daily-drop-popover--done { opacity: .92; }

/* Tablet / phone — bottom sheet above tab bar */
@media (max-width: 939px) {
  .daily-drop-portal:not([hidden]) {
    align-items: flex-end;
    justify-content: stretch;
    padding:
      var(--s4)
      var(--s3)
      calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + var(--s3));
  }
  .daily-drop-popover {
    width: 100%;
    max-width: none;
    max-height: min(78dvh, 560px);
    border-end-start-radius: 0;
    border-end-end-radius: 0;
    animation: daily-drop-sheet-in .22s ease-out;
  }
  @keyframes daily-drop-sheet-in {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: none; }
  }
}

/* Desktop — centered modal, clear of right nav rail */
@media (min-width: 940px) {
  .daily-drop-portal:not([hidden]) {
    /* Keep modal in main column — inset from sidebar width */
    padding-inline-end: calc(var(--nav-w, 220px) + var(--s5));
  }
  html[dir="rtl"] .daily-drop-portal:not([hidden]) {
    padding-inline-end: max(var(--s4), env(safe-area-inset-right, 0px));
    padding-inline-start: calc(var(--nav-w, 220px) + var(--s5));
  }
  .daily-drop-popover {
    width: min(400px, calc(100vw - var(--nav-w, 220px) - var(--s8)));
    max-height: min(80dvh, 600px);
  }
}

@media (max-width: 479px) {
  .hud-daily-drop { width: 32px; height: 32px; }
  .daily-drop-portal:not([hidden]) {
    padding-inline: var(--s2);
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + var(--s2));
  }
  .daily-drop-popover {
    max-height: min(82dvh, 520px);
    padding: var(--s3);
  }
  .daily-drop-steps { max-height: 7rem; }
}

.feed-root { padding: 0 var(--s5) var(--s6); max-width: 680px; margin-inline: auto; }
.feed-list { display: flex; flex-direction: column; gap: var(--s4); }

.feed-demo-banner {
  display: flex; align-items: flex-start; gap: var(--s3);
  margin-bottom: var(--s3); padding: var(--s3) var(--s4);
  border-color: rgba(124, 58, 237, .25);
  background: linear-gradient(135deg, rgba(124, 58, 237, .1), rgba(6, 182, 212, .06));
}
.feed-demo-banner strong { display: block; font-size: var(--fs-sm); color: var(--tx-1); margin-bottom: 4px; }
.feed-demo-banner p { margin: 0; font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.45; }
.feed-demo-icon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--brand-hi);
  background: rgba(124, 58, 237, .16); border: 1px solid rgba(167, 139, 250, .22);
}

.feed-crew-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(124,58,237,.06));
}
.feed-crew-left { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.feed-crew-stack { display: flex; align-items: center; padding-inline-start: 4px; }
.feed-crew-av {
  width: 32px; height: 32px; margin-inline-start: -10px;
  border-radius: 50%; border: 2px solid var(--bg-2);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff;
}
.feed-crew-av:first-child { margin-inline-start: 0; }
.feed-crew-title { font-weight: 700; font-size: var(--fs-sm); }
.feed-crew-sub { font-size: var(--fs-xs); color: var(--tx-3); }
.feed-crew-stats { display: flex; flex-wrap: wrap; gap: var(--s2); }
.feed-crew-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--tx-2);
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
}

.feed-compose {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  border-color: rgba(16, 185, 129, .22);
  background: linear-gradient(135deg, rgba(16,185,129,.07), rgba(124,58,237,.05));
}
.feed-compose-av {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: #fff;
}
.feed-compose-body strong { display: block; font-size: var(--fs-sm); margin-bottom: 2px; }
.feed-compose-body p { margin: 0 0 var(--s2); font-size: var(--fs-xs); color: var(--tx-2); line-height: 1.4; }
.feed-compose-reward {
  font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: #fde047; white-space: nowrap;
  padding: 4px 8px; border-radius: 999px; background: rgba(234, 179, 8, .12);
  border: 1px solid rgba(234, 179, 8, .25);
}

.feed-av--a { background: linear-gradient(135deg, #7c3aed, #06b6d4); }
.feed-av--b { background: linear-gradient(135deg, #db2777, #7c3aed); }
.feed-av--c { background: linear-gradient(135deg, #059669, #0891b2); }
.feed-av--d { background: linear-gradient(135deg, #d97706, #dc2626); }
.feed-av--e { background: linear-gradient(135deg, #4f46e5, #2563eb); }

.feed-post {
  padding: 0; overflow: hidden;
  border-color: rgba(255,255,255,.09);
  background: var(--bg-2);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.feed-post-head {
  display: flex; align-items: flex-start; gap: var(--s2);
  padding: var(--s3) var(--s4) var(--s2);
}
.feed-post-av {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm); color: #fff;
}
.feed-post-meta { flex: 1; min-width: 0; }
.feed-post-line { font-size: var(--fs-sm); line-height: 1.35; color: var(--tx-1); }
.feed-post-line strong { font-weight: 700; }
.feed-post-sub { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 2px; }
.feed-you { color: var(--brand-hi); font-weight: 600; }

.feed-post-media {
  display: block; position: relative; height: 200px; overflow: hidden;
  text-decoration: none; color: #fff;
}
.feed-media-glow {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 25% 20%, rgba(255,255,255,.22), transparent 50%),
              linear-gradient(180deg, transparent 40%, rgba(0,0,0,.45));
}
.feed-media-icon {
  position: absolute; inset: 0; margin: auto; width: 48px; height: 48px;
  opacity: .85; filter: drop-shadow(0 6px 16px rgba(0,0,0,.4));
}
.feed-trend {
  position: absolute; top: var(--s2); inset-inline-start: var(--s2);
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 9px; border-radius: 999px;
  color: #fdba74; background: rgba(0,0,0,.45); border: 1px solid rgba(249,115,22,.35);
}
.feed-media-live {
  position: absolute; bottom: var(--s2); inset-inline-end: var(--s2);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(16,185,129,.25); color: #6ee7b7; border: 1px solid rgba(16,185,129,.4);
}
.feed-media-live .dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; box-shadow: 0 0 8px #34d399; }

.feed-preview--vibe { background: linear-gradient(145deg, #4c1d95, #7c3aed 40%, #0891b2); }
.feed-preview--prompt { background: linear-gradient(145deg, #78350f, #a855f7 45%, #312e81); }
.feed-preview--flow { background: linear-gradient(145deg, #064e3b, #059669 40%, #6366f1); }
.feed-preview--studio { background: linear-gradient(145deg, #1e1b4b, #4338ca 45%, #06b6d4); }
.feed-preview--agent { background: linear-gradient(145deg, #312e81, #6366f1 45%, #8b5cf6); }
.feed-preview--ml { background: linear-gradient(145deg, #334155, #475569 45%, #0ea5e9); }
.feed-preview--site { background: linear-gradient(145deg, #1e293b, #334155 45%, #7c3aed); }

.feed-post-copy { padding: var(--s3) var(--s4) var(--s2); }
.feed-post-title { margin: 0 0 4px; font-size: var(--fs-body); line-height: 1.3; }
.feed-post-title a { color: var(--tx-1); text-decoration: none; }
.feed-post-title a:hover { color: var(--brand-hi); }
.feed-post-hint { margin: 0; font-size: var(--fs-xs); color: var(--tx-3); line-height: 1.4; }

.feed-post-stats {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  padding: 0 var(--s4) var(--s2); font-size: var(--fs-xs); color: var(--tx-2);
}
.feed-post-stats-sep { opacity: .5; }
.feed-post-stats-reactions { display: inline-flex; align-items: center; gap: 6px; }
.feed-mini-react {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid rgba(255,255,255,.12); background: var(--bg-3);
}
.feed-mini-react--fire { color: #fb923c; }
.feed-mini-react--clap { color: #facc15; }
.feed-mini-react--idea { color: #c4b5fd; }
.feed-mini-react--love { color: #f472b6; }
.feed-mini-react--rocket { color: #22d3ee; }
.feed-post-stats-remix { color: var(--tx-3); }

.feed-react-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: var(--s2) var(--s4);
  border-top: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.12);
}
.feed-react {
  width: 36px; height: 36px; padding: 0; border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04);
  color: var(--tx-2); cursor: pointer; position: relative;
  display: inline-grid; place-items: center;
  transition: transform var(--dur), border-color var(--dur), background var(--dur), color var(--dur);
}
.feed-react:hover { transform: translateY(-1px); color: var(--tx-1); background: rgba(255,255,255,.1); }
.feed-react.is-active { border-color: var(--brand); background: rgba(124, 58, 237, .22); color: var(--brand-hi); }
.feed-react--fire.is-active { border-color: #f97316; background: rgba(249, 115, 22, .18); color: #fdba74; }
.feed-react--clap.is-active { border-color: #eab308; background: rgba(234, 179, 8, .14); color: #fde047; }
.feed-react--idea.is-active { border-color: #a78bfa; background: rgba(167, 139, 250, .18); color: #ddd6fe; }
.feed-react--love.is-active { border-color: #ec4899; background: rgba(236, 72, 153, .18); color: #f9a8d4; }
.feed-react--rocket.is-active { border-color: #06b6d4; background: rgba(6, 182, 212, .18); color: #67e8f9; }
.feed-react-count {
  position: absolute; top: -6px; inset-inline-end: -6px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 9px; font-weight: 800;
  display: grid; place-items: center; line-height: 1; border: 2px solid var(--bg-2);
}

.feed-action-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: rgba(255,255,255,.06);
}
.feed-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 52px; padding: var(--s2) var(--s1);
  border: none; background: var(--bg-2); color: var(--tx-2);
  font-size: 11px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.feed-action:hover { background: rgba(255,255,255,.05); color: var(--tx-1); }
.feed-action--remix { color: var(--brand-hi); }
.feed-action--remix:hover { background: rgba(124,58,237,.12); }
.feed-action--open:hover { color: #67e8f9; }
.feed-action--yours { color: #6ee7b7; cursor: default; }
.feed-action-xp {
  display: block; font-size: 9px; font-weight: 800; color: #fde047;
  letter-spacing: .03em; text-transform: uppercase;
}

.feed-icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-md); border: 1px solid transparent;
  background: transparent; color: var(--tx-3); cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  transition: color var(--dur), background var(--dur), border-color var(--dur);
}
.feed-icon-btn:hover { color: var(--tx-1); background: var(--surface-2); border-color: var(--border); }

.feed-react-row.is-highlight {
  animation: feed-row-pulse 1.2s ease;
  border-radius: var(--r-md);
}
@keyframes feed-row-pulse {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: 0 0 0 2px rgba(124, 58, 237, .45); background: rgba(124, 58, 237, .08); }
}
.feed-react.is-busy,
.feed-action.is-busy,
.feed-icon-btn.is-busy { opacity: .55; pointer-events: none; }

.feed-solo {
  text-align: center; padding: var(--s6) var(--s5); color: var(--tx-2);
  background: linear-gradient(180deg, rgba(124,58,237,.08), transparent);
}
.feed-solo-art {
  position: relative; width: 88px; height: 88px; margin: 0 auto var(--s4);
  display: grid; place-items: center;
}
.feed-solo-orbit {
  position: absolute; inset: 0; border-radius: 50%; border: 1px dashed rgba(167,139,250,.35);
}
.feed-solo-orbit--1 { animation: feed-orbit 12s linear infinite; }
.feed-solo-orbit--2 { inset: 10px; animation: feed-orbit 18s linear infinite reverse; }
.feed-solo-core {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; color: var(--brand-hi);
  background: rgba(124,58,237,.15); border: 1px solid rgba(167,139,250,.3);
}
@keyframes feed-orbit { to { transform: rotate(360deg); } }
.feed-solo h3 { margin: 0 0 var(--s2); color: var(--tx-1); }
.feed-solo p { margin: 0 auto var(--s4); max-width: 320px; line-height: 1.45; font-size: var(--fs-sm); }

@media (max-width: 640px) {
  .feed-compose { grid-template-columns: auto 1fr; }
  .feed-compose-reward { grid-column: 1 / -1; justify-self: start; }
  .feed-action-bar { grid-template-columns: repeat(2, 1fr); }
  .feed-post-media { height: 160px; }
  .feed-crew-bar { flex-direction: column; align-items: stretch; }
}

.prestige-ring {
  position: absolute; bottom: -2px; inset-inline-end: -2px;
  background: var(--brand); color: #fff; font-size: .65rem; font-weight: 700;
  padding: .1rem .35rem; border-radius: 999px; line-height: 1.2;
}
.hud-avatar { position: relative; }
.maker-tier-card { margin: var(--s4) var(--s5); }
.maker-tier-kicker { font-size: var(--fs-xs); color: var(--brand-hi); text-transform: uppercase; }
.ti-badge--feed { background: rgba(6, 182, 212, .15); color: #06b6d4; }

/* Retention — notifications, today, quests, friends, paywall */
.notif-prefs-card,
.quest-panel,
.friends-panel {
  display: grid;
  gap: var(--s3);
  margin: var(--s3) 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  padding: var(--s4);
}

.notif-prefs-card { display: grid; gap: var(--s3); margin: 0; padding: 0; border: none; background: transparent; }
.quest-panel,
.friends-panel { margin: var(--s3) 0; }

.notif-row { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.notif-quiet { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.notif-consent { display: grid; gap: var(--s2); padding: var(--s2); border-radius: var(--r-md); background: var(--surface-2, rgba(0,0,0,.04)); }
.notif-consent-stale { outline: 1px solid var(--warn, #c90); }
.notif-consent-row { align-items: flex-start; }
.notif-consent-row span { line-height: 1.4; font-size: var(--fs-xs); }
.notif-consent-note { margin: 0; font-size: var(--fs-xs); opacity: .85; }
.notif-quiet input[type="time"] {
  font: inherit;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx);
}
.parent-notif-opt { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); margin-top: var(--s2); }

.today-card-root { margin: 0 0 var(--s2); }

.today-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  margin: 0 0 var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-2);
  font-size: var(--fs-xs);
  line-height: 1.3;
}
.today-strip-kicker {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--tx-3);
  font-size: 10px;
}
.today-strip-kicker::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
}
.today-strip-action {
  flex: 1 1 120px;
  min-width: 0;
  color: var(--tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.today-strip-go {
  flex-shrink: 0;
  padding: 5px 12px !important;
  font-size: 11px !important;
  min-height: 32px !important;
  border-color: var(--border-hi) !important;
  color: var(--tx) !important;
  background: transparent !important;
  box-shadow: none !important;
}
.today-strip-go:hover {
  background: var(--bg-3) !important;
  border-color: color-mix(in srgb, var(--cyan) 40%, var(--border-hi)) !important;
}
.today-strip-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  flex-shrink: 0;
  margin-inline-start: auto;
  color: var(--tx-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.today-strip-streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--warn);
}
.today-strip-streak .ic { opacity: .9; }
.today-strip-goal {
  padding: 2px 6px;
  border-radius: var(--r-full);
  background: var(--bg-3);
  font-size: 10px;
}
.today-strip-goal--week { color: var(--tx-2); }

@media (max-width: 520px) {
  .today-strip { gap: var(--s2); }
  .today-strip-meta { width: 100%; margin-inline-start: 0; justify-content: flex-start; }
  .journey-scene .ez-guide--strip .ez-guide-inner { flex-wrap: wrap; }
  .journey-scene .ez-guide--strip .ez-actions { width: 100%; justify-content: flex-end; }
}

.today-card {
  display: grid;
  gap: var(--s3);
  margin-bottom: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  padding: var(--s4);
}
.today-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.today-kicker { font-size: var(--fs-xs); color: var(--brand-hi); text-transform: uppercase; letter-spacing: .04em; }
.today-title { font-size: var(--fs-lg); margin: 0; }
.today-streak { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--warn); }
.today-action-label { margin: 0; font-size: var(--fs-sm); color: var(--tx-2); }
.today-goals { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.today-goal { display: flex; align-items: center; gap: var(--s2); }
.today-goal-label { font-size: var(--fs-xs); color: var(--tx-3); }
.today-goal-meta { font-size: var(--fs-sm); font-weight: 600; }
.today-goal-ring { width: 36px; height: 36px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--pct) * 1%), var(--bg-3) 0); flex-shrink: 0; }
.today-goal-bar { width: 36px; height: 8px; background: var(--bg-3); border-radius: var(--r-full); overflow: hidden; flex-shrink: 0; }
.today-goal-bar-fill { height: 100%; background: var(--brand); border-radius: inherit; }

.quest-list { display: grid; gap: var(--s2); }
.quest-row {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-3);
}
.quest-row.is-claimed { opacity: .7; }
.quest-row-head { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--tx-3); margin-bottom: var(--s1); }
.quest-title { font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--s2); }
.quest-progress { height: 6px; background: var(--bg-3); border-radius: var(--r-full); overflow: hidden; margin-bottom: var(--s1); }
.quest-progress-bar { height: 100%; background: var(--brand); }
.quest-meta { font-size: var(--fs-xs); color: var(--tx-3); margin-bottom: var(--s2); }
.quest-done { font-size: var(--fs-xs); color: var(--ok); }
.quest-badge { position: absolute; top: -2px; inset-inline-end: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full); background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.friends-invite-row { display: flex; gap: var(--s2); }
.friends-invite-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--tx);
  font: inherit;
}
.friends-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
}
.friends-row:last-child { border-bottom: none; }
.friends-link { font-weight: 600; color: var(--brand-hi); text-decoration: none; }
.friends-sub { font-size: var(--fs-xs); color: var(--tx-3); margin-bottom: var(--s2); }

.onboarding-intents { display: grid; gap: var(--s2); margin: var(--s3) 0; }
.onboarding-intent { justify-content: flex-start; text-align: start; }

.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
}
.paywall-overlay[hidden] { display: none !important; }
.paywall-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.paywall-card {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
  display: grid;
  gap: var(--s3);
  padding: var(--s5);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-xl);
  background: var(--bg-2);
  box-shadow: var(--sh-pop);
}
.paywall-kicker { font-size: var(--fs-xs); color: var(--brand-hi); text-transform: uppercase; }
.paywall-plans { display: grid; gap: var(--s2); }
.paywall-plan {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  background: var(--bg-3);
}
.paywall-plan--featured {
  border-color: var(--brand-border);
  background: var(--brand-dim);
}
.paywall-plan b { display: block; margin-bottom: 2px; }
.paywall-plan span { color: var(--brand-hi); font-weight: 700; }
.paywall-close { position: absolute; top: var(--s3); inset-inline-end: var(--s3); }

/* ── Library (Learn tab) ── */
.learn-viewtabs {
  display: flex; width: 100%; max-width: 100%; gap: 4px; padding: 4px;
  margin: var(--s4) 0 var(--s3);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--r-full);
}
.learn-viewtab {
  flex: 1; justify-content: center;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 7px var(--s3); border: none; border-radius: var(--r-full);
  background: transparent; color: var(--tx-2);
  font-family: var(--font); font-weight: 700; font-size: var(--fs-sm);
  cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.learn-viewtab.active {
  background: var(--bg-3);
  color: var(--tx);
  box-shadow: inset 0 -2px 0 var(--brand);
}
.learn-viewtab:not(.active):hover { color: var(--tx); background: var(--bg-4); }

.lib-bar {
  margin: var(--s4) 0 var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.lib-bar-head { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.lib-bar-title { display: inline-flex; align-items: center; gap: var(--s2); font-family: var(--font-d); font-weight: 700; font-size: var(--fs-h2); color: var(--tx); }
.lib-bar-title .ic { color: var(--brand-hi); }
.lib-bar-note { font-size: var(--fs-sm); color: var(--tx-2); }
.lib-search {
  width: 100%;
  height: 40px;
  padding: 0 var(--s4);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--tx);
  font-family: var(--font);
  font-size: var(--fs-body);
  transition: border-color var(--dur) var(--ease);
}
.lib-search::placeholder { color: var(--tx-3); }
.lib-search:focus { outline: none; border-color: var(--brand-border); background: var(--bg-2); }

.lib-bar-stats {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  margin-bottom: var(--s3);
}
.lib-stat {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-3); color: var(--tx-2);
}
.lib-stat--read { color: var(--map); border-color: color-mix(in srgb, var(--map) 30%, var(--border)); }
.lib-stat--soon { color: var(--tx-3); border-style: dashed; }
.lib-stat--tracks { color: var(--tx-2); }

.lib-results { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.lib-results-count { font-size: var(--fs-xs); color: var(--tx-3); text-transform: uppercase; letter-spacing: .04em; margin: 0 var(--s1) var(--s1); }
.lib-empty { color: var(--tx-2); text-align: center; padding: var(--s6); }

/* Library lesson row extras (rows are always open now) */
.learn-lesson-track { font-size: 10px; color: var(--brand-hi); font-weight: 600; }
.ll-chip { font-size: 10px; font-weight: 700; padding: 2px var(--s2); border-radius: var(--r-full); white-space: nowrap; flex-shrink: 0; }
.ll-done { color: var(--green); background: var(--green-dim); }
.ll-current { color: var(--brand-hi); background: var(--brand-dim); }
.ll-ahead { color: var(--tx-3); background: var(--bg-4); }
.ll-soon { color: var(--tx-3); background: var(--bg-3); border: 1px dashed var(--border); }
.learn-lesson.is-soon { opacity: .72; cursor: not-allowed; }
.learn-lesson.is-soon .learn-lesson-read { opacity: .45; border-style: dashed; }
.learn-lesson-read {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 700; color: var(--brand-hi);
  padding: 4px var(--s2); border: 1px solid var(--brand-border); border-radius: var(--r-full);
  flex-shrink: 0; opacity: .85; transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.learn-lesson:hover .learn-lesson-read { opacity: 1; background: var(--brand-dim); }

/* Library reader — full page inside Learn tab */
#screen-learn.screen-learn--reader .page-head { display: none; }
#screen-learn.screen-learn--reader {
  padding-top: max(var(--s3), env(safe-area-inset-top));
  padding-left: max(var(--s3), env(safe-area-inset-left));
  padding-right: max(var(--s3), env(safe-area-inset-right));
}
#screen-learn.screen-learn--reader .learn-root { gap: 0; min-height: 0; flex: 1; }

.lib-read-page {
  display: flex; flex-direction: column;
  width: 100%; max-width: 720px; margin: 0 auto;
  min-height: 0;
}
.lib-read-header {
  position: sticky; top: 0; z-index: 3; flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) 0 var(--s3);
  background: linear-gradient(to bottom, var(--bg) 75%, transparent);
}
.lib-read-back {
  display: inline-flex; align-items: center; gap: var(--s1);
  min-width: 44px; min-height: 44px; flex-shrink: 0;
  padding: 0 var(--s2);
}
.lib-read-back-label { font-weight: 700; font-size: var(--fs-sm); }
.lib-read-header-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.lib-read-kicker {
  display: inline-flex; align-items: center; gap: var(--s1);
  font-size: var(--fs-xs); font-weight: 700; color: var(--brand-hi);
}
.lib-read-title {
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm);
  color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-read-main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s6);
}
.lib-read-article { padding: 0 0 var(--s4); }
.lib-read-footer {
  position: sticky; bottom: 0; z-index: 3; flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) 0 calc(var(--s3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: linear-gradient(to top, var(--bg) 80%, transparent);
}
.lib-read-foot-note { font-size: var(--fs-xs); color: var(--tx-3); flex: 1; min-width: 0; }
.lib-read-journey { min-height: 44px; flex-shrink: 0; }
.lib-read-page--loading,
.lib-read-page--error { justify-content: center; padding: var(--s6) 0; }
.lib-read-error { color: var(--tx-2); text-align: center; margin-top: var(--s4); }

/* Reader article content */
.rd-lead { margin-bottom: var(--s5); }
.rd-lead .kicker { font-size: var(--fs-xs); font-weight: 700; color: var(--brand-hi); text-transform: uppercase; letter-spacing: .05em; }
.rd-lead h2 { font-family: var(--font-d); font-size: var(--fs-xl); margin: var(--s2) 0 var(--s1); color: var(--tx); }
.rd-meta { font-size: var(--fs-sm); color: var(--tx-3); }
.rd-sec { padding: var(--s4) 0; border-top: 1px solid var(--border); }
.rd-sec:first-of-type { border-top: none; }
.rd-h { font-family: var(--font-d); font-size: var(--fs-h2); margin: 0 0 var(--s2); color: var(--tx); }
.rd-reveal { margin-top: var(--s3); padding: var(--s3) var(--s4); background: var(--brand-dim); border-radius: var(--r); border: 1px solid var(--brand-border); }
.rd-reveal-tag, .rd-task-tag { display: inline-block; font-size: var(--fs-xs); font-weight: 700; color: var(--brand-hi); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--s2); }
.rd-quiz-q { font-weight: 600; font-size: var(--fs-body); color: var(--tx); margin-bottom: var(--s3); }
.rd-choices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.rd-choice { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--r); font-size: var(--fs-sm); color: var(--tx-2); }
.rd-choice.is-correct { background: var(--green-dim); border-color: rgba(16,185,129,.35); color: var(--tx); }
.rd-choice-key { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-4); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; flex-shrink: 0; }
.rd-correct-tag { margin-inline-start: auto; font-size: 10px; font-weight: 700; color: var(--green); }
.rd-hands { opacity: .9; }

@media (min-width: 640px) {
  .lib-bar { padding: var(--s4) var(--s5); }
  .lib-read-back-label { display: inline; }
  .lib-read-title { font-size: var(--fs-body); }
  .lib-read-article { padding-inline: var(--s2); }
  .lib-read-footer { flex-wrap: nowrap; }
}

@media (min-width: 768px) {
  #screen-learn.screen-learn--reader {
    padding-left: max(var(--s5), env(safe-area-inset-left));
    padding-right: max(var(--s5), env(safe-area-inset-right));
  }
  .learn-viewtabs { max-width: 420px; }
}

@media (max-width: 639px) {
  .lib-read-back-label { display: none; }
  .lib-bar-stats { gap: var(--s1); }
  .lib-stat { font-size: 9px; padding: 3px 8px; }
  .lib-section-head { flex-direction: column; align-items: stretch; gap: var(--s1); }
  .lib-section-meta { align-self: flex-start; }
  .lib-shelf-books {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: var(--s4) var(--s3); padding: var(--s3) var(--s1) var(--s4);
  }
  .lib-book-title { font-size: var(--fs-xs); }
  .lib-book-sub { -webkit-line-clamp: 2; }
  .lib-open-head { flex-wrap: wrap; gap: var(--s2); }
  .lib-open-title { font-size: var(--fs-h2); }
  .lib-open-modules { gap: var(--s2); padding-bottom: var(--s8); }
  .lib-mod-head { padding: var(--s2) var(--s3); min-height: 44px; }
  .lib-mod-title { font-size: 10px; }
  .lib-class { padding: var(--s2) var(--s3); min-height: 44px; }
  .learn-lesson {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: var(--s3);
    gap: var(--s2);
  }
  .learn-lesson-read {
    width: 100%;
    justify-content: center;
    min-height: 40px;
    margin-top: var(--s1);
    opacity: 1;
  }
  .ll-chip { margin-inline-start: auto; }
  .lib-bar-head { flex-direction: column; align-items: flex-start; gap: var(--s1); }
  .lib-read-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .lib-read-journey { width: 100%; justify-content: center; }
  .lib-read-foot-note { text-align: center; }
  .rd-choice { flex-wrap: wrap; }
  .rd-correct-tag { margin-inline-start: 0; width: 100%; }
}


/* ── Library bookshelf (Learn → Library) ── */
.lib-shelf { padding: var(--s2) 0 var(--s5); display: flex; flex-direction: column; gap: var(--s5); }
.lib-section { display: flex; flex-direction: column; gap: var(--s2); }
.lib-section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: 0 var(--s2);
}
.lib-section-titles { flex: 1; min-width: 0; }
.lib-section-title {
  font-family: var(--font-d); font-size: var(--fs-h2); font-weight: 700;
  margin: 0; line-height: 1.15;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2);
}
.lib-section-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: var(--r-full);
  color: var(--tx-2); background: var(--bg-3); border: 1px solid var(--border);
}
.lib-section-desc { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--tx-3); line-height: 1.35; }
.lib-section-meta {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; color: var(--tx-3);
  padding: 4px 8px; border-radius: var(--r-full); background: var(--bg-3);
  white-space: nowrap;
}
.lib-shelf-books {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: var(--s5) var(--s4); padding: var(--s4) var(--s2) var(--s5);
  perspective: 1400px;
}
.lib-shelf-plank {
  height: 14px; border-radius: 0 0 var(--r) var(--r);
  background: linear-gradient(var(--bg-4), var(--bg-3));
  box-shadow: 0 10px 22px rgba(0,0,0,.4), inset 0 1px 0 var(--border-hi);
  margin-top: -8px;
}
.lib-book {
  position: relative; aspect-ratio: 3 / 4; border: none; background: none; padding: 0;
  cursor: pointer; transform-style: preserve-3d;
  transition: transform var(--dur) var(--ease);
}
.lib-book:hover { transform: translateY(-6px) rotateY(-14deg); }
.lib-book-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 11px;
  background: var(--book); filter: brightness(.62);
  border-radius: var(--r-sm) 2px 2px var(--r-sm); transform: translateZ(-1px);
}
.lib-book-cover {
  position: absolute; inset: 0 0 0 6px;
  display: flex; flex-direction: column; gap: 5px; padding: var(--s3);
  border-radius: 2px var(--r) var(--r) 2px;
  background: var(--book);
  background-image: linear-gradient(140deg, rgba(255,255,255,.16), rgba(0,0,0,.28));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 8px 18px rgba(0,0,0,.42);
  transform-origin: left center; transition: transform .34s var(--ease);
  color: #fff; overflow: hidden;
}
.lib-book-cover::after {
  content: ""; position: absolute; top: 3px; bottom: 3px; right: 0; width: 4px;
  background: repeating-linear-gradient(#fff, #fff 1px, #d7d7df 1px, #d7d7df 2px); opacity: .5;
}
.lib-book-ic { color: #fff; opacity: .92; }
.lib-book-title { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm); line-height: 1.14; }
.lib-book-sub {
  font-size: 10px; opacity: .82; line-height: 1.25; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-book-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; margin-top: auto; }
.lib-book-count { font-size: 10px; font-weight: 700; background: rgba(0,0,0,.3); padding: 2px 7px; border-radius: var(--r-full); }
.lib-book-soon {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: var(--r-full);
  background: rgba(0,0,0,.22); color: rgba(255,255,255,.75); border: 1px dashed rgba(255,255,255,.25);
}
.lib-book-journey { color: rgba(255,255,255,.65); opacity: .85; }
.lib-book.is-journey-locked .lib-book-cover { filter: saturate(.88) brightness(.9); }
.lib-book.is-locked .lib-book-cover { filter: saturate(.6) brightness(.82); }
.lib-book.is-opening { transform: translateY(-10px) translateZ(40px); z-index: 5; }
.lib-book.is-opening .lib-book-cover { transform: rotateY(-118deg); }

.lib-open { opacity: 0; transform: translateY(10px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
.lib-open.is-in { opacity: 1; transform: none; }
.lib-shelf-mount.lib-mount--open {
  display: flex; flex-direction: column; min-height: 0;
}
.lib-open-head { display: flex; align-items: center; gap: var(--s3); margin: var(--s3) 0 var(--s4); flex-shrink: 0; }
.lib-open-back { flex: 0 0 auto; width: auto; }
.lib-open-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lib-open-kicker { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--book); text-transform: uppercase; letter-spacing: .05em; }
.lib-open-title { font-family: var(--font-d); font-size: var(--fs-h1); margin: 2px 0 0; line-height: 1.15; }
.lib-open-stats { display: block; margin-top: 4px; font-size: 10px; font-weight: 600; color: var(--tx-3); }
.lib-open-modules {
  display: flex; flex-direction: column; gap: var(--s3);
  padding-bottom: var(--s6);
  -webkit-overflow-scrolling: touch;
}
.lib-mod-section {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--book) 4%, var(--bg-2));
  overflow: hidden; flex-shrink: 0;
}
.lib-mod-head {
  width: 100%; display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3); border: none; border-bottom: 1px solid transparent;
  background: var(--bg-3); cursor: pointer; font-family: inherit;
  color: inherit; text-align: start;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.lib-mod-section.is-open .lib-mod-head {
  border-bottom-color: var(--border);
}
.lib-mod-head:hover { background: var(--bg-4); }
.lib-mod-chev {
  flex-shrink: 0; color: var(--tx-3);
  transform: rotate(-90deg); transition: transform .2s var(--ease);
}
.lib-mod-section.is-open .lib-mod-chev { transform: rotate(90deg); color: var(--book); }
.lib-mod-title {
  margin: 0; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; line-height: 1.2; flex: 1; min-width: 0;
}
.lib-mod-prog {
  font-size: 10px; font-weight: 700; color: var(--tx-3);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg-4); border: 1px solid var(--border);
}
.lib-mod-body[hidden] { display: none; }
.lib-mod-map { padding: var(--s2) var(--s2) var(--s3) var(--s4); }
.lib-class.state-soon,
.lib-class.is-soon {
  opacity: .62; cursor: not-allowed; border-style: dashed;
}
.lib-class-soon {
  font-size: 9px; font-weight: 700; color: var(--tx-3);
  padding: 2px 6px; border-radius: var(--r-full);
  background: var(--bg-4); border: 1px dashed var(--border); flex-shrink: 0;
}
.lib-class.state-soon .lib-class-node,
.lib-class.is-soon .lib-class-node { background: var(--bg-4); color: var(--tx-3); }
.lib-map { position: relative; padding-inline-start: var(--s5); }
.lib-map-trail {
  position: absolute; inset-inline-start: 14px; top: 10px; bottom: 10px; width: 2px;
  background: repeating-linear-gradient(var(--book), var(--book) 5px, transparent 5px, transparent 11px); opacity: .5;
}
.lib-class {
  position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: var(--s2) var(--s3); margin-bottom: var(--s2);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r);
  cursor: pointer; text-align: start; color: var(--tx);
  animation: lib-class-in .3s var(--ease) both; animation-delay: calc(var(--i) * 26ms);
}
@keyframes lib-class-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.lib-class:hover { border-color: var(--book); background: var(--bg-3); }
.lib-class-node {
  position: relative; z-index: 1; width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-4); box-shadow: 0 0 0 3px var(--bg); color: var(--tx-2);
}
.lib-class.state-done .lib-class-node { background: var(--green-dim); color: var(--green); }
.lib-class.state-current .lib-class-node { background: var(--brand-dim); color: var(--brand-hi); }
.lib-class-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-class-title { font-weight: 600; font-size: var(--fs-sm); }
.lib-class-meta { font-size: 10px; color: var(--tx-3); }
.lib-class-go { color: var(--tx-3); flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  .lib-book, .lib-book-cover, .lib-open, .lib-class { transition: none; animation: none; }
  .lib-book:hover { transform: translateY(-4px); }
}

/* ── Paths adventure trail (Learn → Paths) ── */
.trail { position: relative; margin: var(--s4) 0 var(--s2); }
.trail-road { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trail-road-base { fill: none; stroke: var(--bg-4); stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; }
.trail-road-dash { fill: none; stroke: var(--tx-3); stroke-width: 2; stroke-dasharray: 2 12; stroke-linecap: round; opacity: .55; }
.trail-road-done { fill: none; stroke: var(--brand-hi); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px var(--brand-dim));
  stroke-dasharray: 1; stroke-dashoffset: 1; pathLength: 1; transition: stroke-dashoffset 1.1s var(--ease) .15s; }
.trail.is-in .trail-road-done { stroke-dashoffset: 0; }

.trail-station { position: absolute; transform: translate(-50%, -50%); border: none; background: none; padding: 0;
  opacity: 0; transition: opacity .4s var(--ease); }
.trail.is-in .trail-station { opacity: 1; }
.trail-track { cursor: pointer; }

.trail-node { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-2); box-shadow: 0 0 0 4px var(--bg), 0 6px 16px rgba(0,0,0,.45); color: var(--tx); }
.trail-node-ring { position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(var(--book) calc(var(--ring) * 1%), var(--bg-4) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 70%, #000 72%);
  mask: radial-gradient(closest-side, transparent 70%, #000 72%); }
.trail-node-ic { position: relative; z-index: 1; color: var(--book); }
.trail-node-lock { position: absolute; z-index: 2; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-3); box-shadow: 0 0 0 2px var(--bg); color: var(--tx-3); font-size: 9px; }
.trail-track.is-locked .trail-node { filter: saturate(.5) brightness(.78); }
.trail-track.is-locked .trail-node-ic { color: var(--tx-3); }
.trail-track:not(.is-locked):hover .trail-node { transform: scale(1.08); transition: transform var(--dur) var(--ease); }
.trail-track.is-done .trail-node { box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--green-dim); }

.trail-lvl { position: absolute; z-index: 3; bottom: -8px; left: 50%; transform: translateX(-50%);
  background: var(--brand); color: #fff; font-size: 9px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-full); white-space: nowrap; }
.trail-here { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 800; color: var(--brand-hi);
  background: var(--brand-dim); border: 1px solid var(--brand-border); padding: 2px 8px; border-radius: var(--r-full); }
.trail-track.is-current .trail-node { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--brand-border); animation: trail-pulse 2s var(--ease) infinite; }
@keyframes trail-pulse { 0%,100% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--brand-border); } 50% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 12px transparent; } }

.trail-card { position: absolute; top: 50%; transform: translateY(-50%); width: min(44vw, 210px);
  display: flex; flex-direction: column; gap: 1px; padding: var(--s2) var(--s3);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh-card); }
.trail-station.is-left .trail-card { inset-inline-start: 44px; text-align: start; }
.trail-station.is-right .trail-card { inset-inline-end: 44px; text-align: end; align-items: flex-end; }
.trail-card-title { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm); color: var(--tx); }
.trail-card-sub { font-size: 10px; color: var(--tx-2); line-height: 1.2; }
.trail-card-prog { font-size: 10px; font-weight: 800; color: var(--book); margin-top: 2px; }
.trail-card-lock { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; color: var(--tx-3); margin-top: 2px; }
.trail-card--locked { opacity: .72; }

.trail-cap .trail-node--cap { width: 48px; height: 48px; }
.trail-cap--start .trail-node--cap { background: var(--green-dim); color: var(--green); box-shadow: 0 0 0 4px var(--bg); }
.trail-cap--mastery .trail-node--cap { background: linear-gradient(140deg, var(--yellow), var(--orange)); color: #fff; box-shadow: 0 0 0 4px var(--bg), 0 0 18px rgba(245,158,11,.4); }
.trail-caplabel { position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap;
  font-family: var(--font-d); font-weight: 800; font-size: var(--fs-sm); color: var(--tx-2); }
.trail-cap.is-left .trail-caplabel { inset-inline-start: 40px; }
.trail-cap.is-right .trail-caplabel { inset-inline-end: 40px; }
.trail-cap--mastery .trail-caplabel { color: var(--yellow); text-transform: uppercase; letter-spacing: .06em; }

@media (prefers-reduced-motion: reduce) {
  .trail-road-done { transition: none; stroke-dashoffset: 0; }
  .trail-station { transition: none; opacity: 1; }
  .trail-track.is-current .trail-node { animation: none; }
}

/* ── Paths: route selector grid ── */
.route-pick-wrap { margin: var(--s3) 0 var(--s2); }
.route-pick-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2);
  margin-bottom: var(--s2); padding: 0 var(--s1);
}
.route-pick-label { font-size: var(--fs-sm); font-weight: 700; color: var(--tx-2); }
.route-pick-count { font-size: var(--fs-xs); color: var(--tx-3); }
.route-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
  gap: var(--s2);
  padding: 0 var(--s1) var(--s2);
  margin: 0;
  overflow: visible;
}
.route-why { margin: 0 var(--s2) var(--s3); font-size: var(--fs-sm); line-height: 1.65; color: var(--tx-2); max-width: 42rem; }
.route-chip {
  width: 100%;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  cursor: pointer; color: var(--tx); text-align: start;
  transition: border-color .15s, background .15s, transform .12s;
}
.route-chip:active { transform: scale(.98); }
.route-chip.is-active {
  border-color: var(--book);
  background: color-mix(in srgb, var(--book) 12%, var(--bg-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--book) 35%, transparent);
}
@media (min-width: 520px) {
  .route-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .learn-rank-skills-primary,
  .learn-rank-skills-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .route-pick { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .learn-rank-skills-primary,
  .learn-rank-skills-extra { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .learn-rank-skills-extra.is-collapsed { display: grid; }
  .learn-rank-toggle { display: none; }
}
.route-chip-ic { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bg-4); color: var(--book); flex-shrink: 0; }
.route-chip-ring { position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(var(--book) calc(var(--ring) * 1%), transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent 72%, #000 74%); mask: radial-gradient(closest-side, transparent 72%, #000 74%); }
.route-chip-body { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.route-chip-name { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-sm); }
.route-chip-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; color: var(--tx-2); }
.route-chip.is-earned .route-chip-meta { color: var(--yellow); }
.trail-card-go { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; color: var(--book); margin-top: 3px; }

/* certificate end-cap */
.trail-cap--cert .trail-node--cert { background: var(--bg-3); color: var(--tx-3); box-shadow: 0 0 0 4px var(--bg); }
.trail-cap--cert.is-earned .trail-node--cert { background: linear-gradient(140deg, var(--yellow), var(--orange)); color: #fff; box-shadow: 0 0 0 4px var(--bg), 0 0 18px rgba(245,158,11,.4); }
.trail-cap--cert .trail-caplabel { color: var(--tx-2); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; max-width: 130px; white-space: normal; }
.trail-cap--cert.is-earned .trail-caplabel { color: var(--yellow); }

/* ── Tests hub (Learn → Tests) ── */
.tests-bar { margin: var(--s4) 0 var(--s3); padding: var(--s3) var(--s4); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg); }
.tests-mode-note { margin: 0 0 var(--s3); padding: var(--s2) var(--s3); font-size: var(--fs-sm); color: var(--tx-2); border-inline-start: 3px solid var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--bg-2)); border-radius: var(--r-sm); }
.tests-stats { display: flex; gap: var(--s4); margin-top: var(--s2); flex-wrap: wrap; }
.tests-stat { font-size: var(--fs-sm); color: var(--tx-2); }
.tests-stat b { color: var(--tx); font-family: var(--font-d); }
.test-group { margin-bottom: var(--s4); }
.test-route-group { margin-bottom: var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.test-route-group:last-child { border-bottom: none; }
.test-route-head { font-family: var(--font-d); font-size: var(--fs-h1); margin: 0 0 var(--s3); color: var(--tx); }
.test-group-head { display: flex; align-items: center; gap: var(--s2); font-family: var(--font-d); font-size: var(--fs-h2); margin: 0 0 var(--s2); color: var(--tx); }
.test-group-head .ic { color: var(--book); }
.test-group-count { margin-inline-start: auto; font-size: var(--fs-xs); font-weight: 700; color: var(--tx-3); background: var(--bg-3); padding: 1px 8px; border-radius: var(--r-full); }
.test-cards { display: grid; grid-template-columns: 1fr; gap: var(--s2); }
@media (min-width: 560px) { .test-cards { grid-template-columns: 1fr 1fr; } }
.test-card { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; text-align: start; color: var(--tx); }
.test-card:hover { border-color: var(--book); background: var(--bg-3); }
.test-card--locked { opacity: .65; cursor: default; }
.test-card--locked:hover { border-color: var(--border); background: var(--bg-2); }
.test-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.test-card-title { font-weight: 600; font-size: var(--fs-sm); }
.test-card-meta { font-size: 10px; color: var(--tx-3); }
.test-diff-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.exam-diff { display: inline-flex; align-items: center; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border-radius: var(--r-full); border: 1px solid transparent; }
.exam-diff--easy { color: #34d399; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.35); }
.exam-diff--medium { color: #fbbf24; background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.35); }
.exam-diff--hard { color: #f87171; background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.35); }
.test-card--visual { align-items: flex-start; }
.test-card-hero { flex-shrink: 0; width: 48px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg-3); }
.test-card-hero-img { display: block; width: 100%; height: auto; object-fit: cover; }
.test-status { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: var(--r-full); white-space: nowrap; }
.test-status--locked { color: var(--tx-3); background: var(--bg-4); }
.test-status--open { color: var(--brand-hi); background: var(--brand-dim); }
.test-status--retry { color: var(--yellow); background: rgba(245,158,11,.14); }
.test-status--passed { color: var(--green); background: var(--green-dim); }

/* ── Auth Door Picker ("what brings you here?") ── */
.auth-card--dooring .auth-panels { display: none !important; }
.auth-panels[hidden],
.auth-panel[hidden],
.auth-magic-form[hidden] { display: none !important; }
.auth-funnel-badge {
  display: inline-block; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--auth-mint); background: color-mix(in srgb, var(--auth-mint) 14%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--auth-mint) 35%, transparent);
  border-radius: var(--r-full); padding: 4px 10px; margin: 0 0 var(--s3);
}

/* Auth login split + recovery */
.auth-mode-switch { display: flex; gap: var(--s1); margin-bottom: var(--s3); background: var(--bg-3); border-radius: var(--r-full); padding: 3px; }
.auth-card--dooring .auth-door { display: block; animation: auth-door-in .35s var(--ease) both; }
@keyframes auth-door-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.auth-door-q { text-align: center; font-family: var(--font-d); font-weight: 700; font-size: var(--fs-h2); color: var(--tx); margin: var(--s2) 0 var(--s4); }
.auth-door-grid { display: flex; flex-direction: column; gap: var(--s2); }
.auth-door-card {
  display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: start;
  padding: var(--s3); border-radius: var(--r-lg); cursor: pointer; color: var(--tx);
  background: var(--bg-2); border: 1px solid var(--border);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.auth-door-card:hover { transform: translateY(-3px); border-color: var(--door); background: color-mix(in srgb, var(--door) 9%, var(--bg-2)); }
.auth-door-card:focus-visible { outline: none; border-color: var(--door); box-shadow: 0 0 0 3px color-mix(in srgb, var(--door) 30%, transparent); }
.auth-door-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; background: color-mix(in srgb, var(--door) 16%, var(--bg-3)); color: var(--door); }
.auth-door-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.auth-door-title { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-body); }
.auth-door-desc { font-size: var(--fs-sm); color: var(--tx-2); }
.auth-door-arrow { color: var(--tx-3); flex-shrink: 0; }
.auth-door-card:hover .auth-door-arrow { color: var(--door); }
.auth-door-signin { display: block; width: 100%; margin-top: var(--s4); background: none; border: none; color: var(--auth-sky); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; padding: var(--s2); }
.auth-door-signin:hover { text-decoration: underline; }
.auth-door-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: var(--s3); background: none; border: none; color: var(--tx-2); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; }
.auth-door-back[hidden] { display: none !important; }
.auth-door-back:hover { color: var(--tx); }
.auth-team-note { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--brand-hi); background: var(--brand-dim); border: 1px solid var(--brand-border); border-radius: var(--r); padding: var(--s2) var(--s3); margin: var(--s2) 0; }
.auth-funnel-hint { font-size: var(--fs-sm); color: var(--tx-2); margin: 0 0 var(--s3); line-height: 1.45; }
.auth-funnel-choice { margin-bottom: var(--s3); }
.auth-funnel-choice-q { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-body); margin: 0 0 var(--s2); text-align: center; }
.auth-funnel-choice-grid { display: flex; flex-direction: column; gap: var(--s2); }
.auth-funnel-choice-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start;
  width: 100%; padding: var(--s3); border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--bg-2); cursor: pointer; transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.auth-funnel-choice-card:hover { transform: translateY(-2px); border-color: var(--auth-sky); background: color-mix(in srgb, var(--auth-sky) 10%, var(--bg-2)); }
.auth-funnel-choice-title { font-family: var(--font-d); font-weight: 700; font-size: var(--fs-body); color: var(--tx); }
.auth-funnel-choice-desc { font-size: var(--fs-sm); color: var(--tx-2); }
.auth-org-fields { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s2); }
.auth-age-row { margin-bottom: var(--s2); }
@media (max-width: 480px) {
  .auth-funnel-choice-card { padding: var(--s2) var(--s3); }
}

/* Per-funnel accent + legal row */
.auth-card[data-funnel="signin"] { --funnel-accent: var(--auth-sky); }
.auth-card[data-funnel="solo"] { --funnel-accent: var(--auth-door-solo); }
.auth-card[data-funnel="kid_trial"] { --funnel-accent: var(--auth-mint); }
.auth-card[data-funnel="parent"] { --funnel-accent: var(--auth-door-family); }
.auth-card[data-funnel="org_buyer"] { --funnel-accent: var(--auth-door-team); }
.auth-card[data-funnel="join"] { --funnel-accent: var(--auth-door-invite); }
.auth-panel.auth-panel--active {
  padding-top: var(--s2);
  border-top: 2px solid color-mix(in srgb, var(--funnel-accent, var(--auth-sky)) 55%, transparent);
}
.auth-funnel-legal-note { font-size: var(--fs-xs); color: var(--tx-3); margin: var(--s1) 0 var(--s3); line-height: 1.45; }
.auth-legal-nav { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); margin: var(--s2) 0 var(--s3); font-size: var(--fs-xs); }
.auth-legal-nav a { color: var(--auth-sky); text-decoration: none; font-weight: 600; }
.auth-legal-nav a:hover { color: var(--auth-ice); text-decoration: underline; }
.auth-check a { color: var(--auth-sky); font-weight: 600; }
.auth-check a:hover { color: var(--auth-ice); }
.auth-funnel-badge {
  display: inline-block; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--auth-mint); background: color-mix(in srgb, var(--auth-mint) 14%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--auth-mint) 35%, transparent);
  border-radius: var(--r-full); padding: 4px 10px; margin: 0 0 var(--s3);
}

.auth-door { display: none; }
.auth-mode-btn { flex: 1; border: none; background: transparent; color: var(--tx-2); font-weight: 600; font-size: var(--fs-sm); padding: var(--s2); border-radius: var(--r-full); cursor: pointer; }
.auth-mode-btn.active { background: var(--bg-2); color: var(--tx); box-shadow: var(--sh-sm); }
.auth-recovery { animation: auth-door-in .35s var(--ease) both; }
.btn-danger { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.35); }

/* Trial gate */
.trial-gate-overlay { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; padding: var(--s4); }
.trial-gate-card { max-width: 420px; width: 100%; padding: var(--s4); text-align: center; }
.trial-gate-sub { color: var(--tx-2); margin-bottom: var(--s3); }
.trial-gate-dismiss { margin-top: var(--s2); width: 100%; }

/* Account settings */
.account-settings-section { margin-bottom: var(--s3); }
.account-settings-section .card-title { margin: 0 0 var(--s3); font-family: var(--font-d); }
.acct-sessions-list { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); }
.acct-session-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); background: var(--bg-3); border-radius: var(--r); font-size: var(--fs-sm); }
.acct-session-row--current { border: 1px solid var(--brand-border); }
.acct-session-meta { margin-inline-start: auto; color: var(--tx-3); font-size: var(--fs-xs); }
.acct-session-badge { font-size: 10px; font-weight: 800; color: var(--brand-hi); background: var(--brand-dim); padding: 2px 8px; border-radius: var(--r-full); }
.parent-mode-toggle { display: flex; gap: var(--s1); margin-bottom: var(--s3); }
.parent-mode-toggle .btn.active { background: var(--brand-dim); color: var(--brand-hi); }
.hud-parent-mode { display: flex; gap: 4px; align-items: center; }
.hud-parent-mode .parent-mode-btn {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--bg-3); color: var(--tx-2); cursor: pointer;
}
.hud-parent-mode .parent-mode-btn.active { border-color: var(--brand); color: var(--brand-hi); background: var(--brand-dim); }
.hud-context { max-width: 140px; }
.context-switch-label { font-size: 10px; color: var(--tx-3); display: block; }
.context-switch-select { font-size: 11px; padding: 4px 8px; min-height: 32px; }
.btn-xs { font-size: var(--fs-xs); padding: 4px 8px; }

/* ── EZ Studio tab ── */
.st-screen {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  --st-panel: var(--bg-2);
  --st-canvas: var(--bg);
  --st-edge: var(--chrome-border);
}

.st-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.st-brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed 55%, #5b21b6);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35);
  flex-shrink: 0;
  position: relative;
}

.st-brand-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 2px;
  transform: rotate(45deg);
}

.st-brand--hero .st-brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
}

.st-brand-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a78bfa;
}

.st-header {
  padding: 1rem 1.25rem 0.5rem;
}

.st-header--hero {
  padding: 1.25rem 1.25rem 0.75rem;
}

.st-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0;
  line-height: 1.1;
  background: linear-gradient(135deg, #ede9fe, #c4b5fd 40%, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.st-sub {
  margin: 0.35rem 0 0;
  color: var(--muted, #9493a8);
  font-size: 0.88rem;
}

.st-picker-actions {
  padding: 0 1.25rem 0.75rem;
}

.st-project-list {
  display: grid;
  gap: 0.65rem;
  padding: 0 1.25rem 1.5rem;
  max-width: 720px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.st-project-card {
  text-align: start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.st-project-card:hover {
  border-color: rgba(124, 58, 237, 0.55);
  background: rgba(124, 58, 237, 0.08);
}

.st-project-card-title {
  display: block;
  font-weight: 600;
}

.st-project-card-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.st-project-card-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

.st-project-card-wrap .st-project-card {
  flex: 1;
}

.st-project-delete {
  flex-shrink: 0;
  width: 1.75rem;
  align-self: stretch;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.st-project-delete:hover {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
}

.st-project-restore {
  flex-shrink: 0;
  width: 1.75rem;
  align-self: stretch;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.st-project-restore:hover {
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
}

.st-live-badge {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #34d399;
}

.st-empty {
  color: var(--muted);
  padding: 1rem;
}

.st-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.st-workspace.hidden,
.st-project-picker.hidden {
  display: none;
}

/* ── Minimal top chrome ── */
.st-chrome {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem;
  min-height: var(--hud-h);
  background: var(--st-panel);
  border-bottom: 1px solid var(--st-edge);
  flex-shrink: 0;
}

.st-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.st-chrome-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8ed;
}

.st-chrome-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.st-chrome-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1 1 140px;
}

.st-chrome-live {
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #34d399;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(52, 211, 153, 0.12);
}

.st-chrome-published {
  font-size: 0.58rem;
  color: var(--muted);
}

.st-chrome-title {
  flex: 0 1 auto;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #c4c4d0;
}

.st-chrome-title--editable {
  cursor: pointer;
}

.st-chrome-title--editable:hover {
  color: #e8e8ed;
  text-decoration: underline dotted;
}

.st-chrome-brand {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c3aed;
  flex-shrink: 0;
}

.st-layout--ide {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Cursor-style IDE shell ── */
.st-ide-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.st-ide-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: auto auto 1fr;
  overflow: hidden;
}

.st-activity-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.12rem;
  width: 2.75rem;
  padding: 0.35rem 0.25rem;
  background: var(--st-panel);
  border-inline-end: 1px solid var(--st-edge);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  overflow: hidden;
  transition:
    width 0.24s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.24s ease;
}

.st-activity-rail[data-expanded="true"] {
  width: 11.25rem;
  box-shadow: 6px 0 28px rgba(0, 0, 0, 0.28);
}

.st-rail-divider {
  align-self: center;
  width: 1.35rem;
  height: 1px;
  margin: 0.2rem 0;
  background: var(--st-edge);
  opacity: 0.55;
  flex-shrink: 0;
}

.st-rail-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  position: relative;
}

.st-rail-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  min-width: 0;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    opacity 0.2s ease,
    max-width 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.st-activity-rail[data-expanded="true"] .st-rail-meta {
  opacity: 1;
  max-width: 8.5rem;
}

.st-rail-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  color: #ececf1;
}

.st-rail-hint {
  font-size: 0.62rem;
  line-height: 1.25;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.st-rail-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2rem;
  padding: 0.15rem 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.78;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease,
    transform 0.12s ease;
  position: relative;
  transform-origin: center;
  gap: 0;
}

.st-activity-rail[data-expanded="true"] .st-rail-btn {
  justify-content: flex-start;
  gap: 0.45rem;
  padding: 0.3rem 0.45rem;
}

.st-rail-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8ed;
  opacity: 1;
  transform: scale(1.05);
}

.st-rail-btn.active {
  background: rgba(124, 58, 237, 0.35);
  color: #e9d5ff;
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}

.st-rail-btn.active::before {
  content: "";
  position: absolute;
  inset-inline-start: -0.2rem;
  top: 0.3rem;
  bottom: 0.3rem;
  width: 3px;
  background: #a78bfa;
  border-radius: 0 2px 2px 0;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.st-rail-btn--locked {
  opacity: 0.42;
  cursor: pointer;
}

.st-rail-btn--locked .st-rail-hint {
  color: #a78bfa;
}

.st-rail-btn--locked:hover {
  background: transparent;
  color: var(--muted);
}

.st-rail-btn--bottom {
  margin-top: auto;
}

.st-rail-btn--log {
  position: relative;
}

.st-rail-badge {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  min-width: 0.85rem;
  height: 0.85rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 0.85rem;
  text-align: center;
  pointer-events: none;
}

.st-sidebar {
  width: 0;
  overflow: hidden;
  background: var(--st-panel);
  border-inline-end: 1px solid var(--st-edge);
  transition: width 0.15s ease;
  flex-shrink: 0;
}

.st-sidebar--open {
  width: min(260px, 34vw);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.st-sidebar-panel {
  height: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.st-sidebar-panel[hidden] {
  display: none !important;
}

.st-sidebar-panel.is-active {
  animation: stPanelIn 0.2s ease;
}

@keyframes stPanelIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.st-sidebar-head {
  padding: 0.55rem 0.75rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx-3);
  border-bottom: 1px solid var(--st-edge);
  flex-shrink: 0;
}

.st-sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.55rem 0.65rem;
}

.st-publish-hint {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

.st-publish-live {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: #34d399;
  font-weight: 600;
}

.st-publish-url-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.st-publish-url {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: #d4d4d8;
  font-size: 0.65rem;
  font-family: ui-monospace, monospace;
}

.st-publish-copy {
  flex-shrink: 0;
}

.st-publish-date {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.st-import-block {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--st-edge);
}

.st-import-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.st-import-select {
  width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: #e8e8ed;
  font-size: 0.68rem;
}

.st-import-btn {
  width: 100%;
}

.st-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--st-canvas);
}

.st-canvas-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--st-panel);
  border-bottom: 1px solid var(--st-edge);
  flex-shrink: 0;
  min-height: 2rem;
}

.st-canvas-tab {
  padding: 0.35rem 0.85rem;
  border: none;
  border-inline-end: 1px solid var(--st-edge);
  background: transparent;
  color: var(--tx-3);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.st-canvas-tab:hover {
  background: color-mix(in srgb, var(--bg-3) 80%, transparent);
  color: var(--tx);
}

.st-canvas-tab.active {
  background: var(--st-canvas);
  color: var(--tx);
  box-shadow: inset 0 -2px 0 var(--brand);
}

.st-canvas-tab--locked {
  opacity: 0.45;
}

.st-canvas-tab--live::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-start: 0.35rem;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.65);
  vertical-align: middle;
}

.st-sidebar-context {
  padding: 0.45rem 0.75rem 0.35rem;
  font-size: 0.62rem;
  line-height: 1.35;
  color: var(--muted);
  border-bottom: 1px solid var(--st-edge);
  flex-shrink: 0;
}

.st-panel-intro,
.st-panel-foot {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.62rem;
  line-height: 1.4;
  color: var(--muted);
}

.st-panel-foot {
  border-top: 1px solid var(--st-edge);
  margin-top: auto;
}

.st-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 1.25rem 0.75rem;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.45;
}

.st-panel-empty .ic {
  opacity: 0.55;
  color: var(--brand-hi);
}

.st-main--pulse {
  animation: stMainPulse 0.28s ease;
}

@keyframes stMainPulse {
  from {
    opacity: 0.88;
  }
  to {
    opacity: 1;
  }
}

.st-mission-hint {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.st-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.st-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-file-meta {
  font-size: 0.58rem;
  opacity: 0.65;
}

.st-monaco-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.st-monaco-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(7, 7, 12, 0.92);
  z-index: 2;
}

.st-code-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 1rem;
  text-align: center;
  background: rgba(7, 7, 12, 0.88);
  color: var(--muted);
  font-size: 0.72rem;
}

.st-code-empty .ic {
  width: 28px;
  height: 28px;
  color: var(--brand-hi);
  opacity: 0.75;
}

.st-code-empty[hidden],
.st-monaco-loading[hidden] {
  display: none !important;
}

.st-code-fallback-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem;
}

.st-code-fallback-note {
  margin: 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.35;
}

.st-code-fallback {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #0a0a10;
  color: #e8e8ed;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: none;
  tab-size: 2;
}

.st-code-fallback:focus {
  outline: none;
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.25);
}

.st-main-canvas {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.st-canvas-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.st-canvas-view[hidden] {
  display: none !important;
}

#stPreviewHost {
  background: #07070c;
}

/* ── Bottom composer (Cursor-style) ── */
.st-composer-error {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
  cursor: pointer;
}

.st-composer-error-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-composer-error-dismiss {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #fca5a5;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.st-composer-error-dismiss:hover {
  background: rgba(239, 68, 68, 0.2);
}

.st-composer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--st-edge);
  background: var(--st-panel);
  max-height: min(180px, 28vh);
  min-height: 5.5rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.st-composer--coach {
  border-top-color: rgba(124, 58, 237, 0.35);
  box-shadow: 0 -4px 24px rgba(124, 58, 237, 0.08);
}

.st-composer-log {
  flex: 1;
  min-height: 2.5rem;
  max-height: 6rem;
  overflow-y: auto;
  padding: 0.35rem 0.65rem 0.2rem;
  font-size: 0.72rem;
  line-height: 1.4;
}

.st-composer-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0.4rem 0.55rem 0.5rem;
  border-top: 1px solid var(--st-edge);
}

.st-composer-ctx {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}

.st-brief-chips {
  margin-top: 6px;
}

.st-file-chip {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.12);
  color: #c4b5fd;
  cursor: pointer;
}

.st-file-chip:hover {
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(167, 139, 250, 0.55);
}

.st-edit-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(34, 197, 94, 0.1);
  border-bottom: 1px solid rgba(34, 197, 94, 0.25);
  font-size: 12px;
}

.st-edit-preview-text {
  flex: 1;
  min-width: 120px;
  color: #86efac;
}

.st-edit-apply {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: rgba(34, 197, 94, 0.45) !important;
  color: #bbf7d0 !important;
}

.st-edit-discard {
  opacity: 0.85;
}

.st-composer-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.st-composer-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--tx-3);
  white-space: nowrap;
  padding-inline-start: 0.2rem;
  flex-shrink: 0;
}

.st-composer-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
}

.st-composer-bar input:focus {
  outline: none;
  border-color: rgba(124, 58, 237, 0.5);
}

.st-composer-model {
  flex-shrink: 0;
  position: relative;
}

.st-model-picker {
  position: relative;
}

.st-model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #c4c4d0;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.st-model-trigger:hover {
  border-color: rgba(124, 58, 237, 0.4);
}

.st-model-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--model-c, #7c3aed);
  flex-shrink: 0;
}

.st-model-chev {
  opacity: 0.5;
  transform: rotate(90deg);
}

.st-model-menu {
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 0;
  min-width: 10rem;
  max-height: 12rem;
  overflow-y: auto;
  background: #1a1a22;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 20;
  padding: 0.25rem;
}

.st-model-menu.hidden {
  display: none;
}

.st-model-opt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 0.68rem;
  text-align: start;
  cursor: pointer;
}

.st-model-opt:hover:not(.locked) {
  background: rgba(124, 58, 237, 0.15);
}

.st-model-opt.active {
  background: rgba(124, 58, 237, 0.22);
}

.st-model-opt.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.st-model-lock {
  margin-inline-start: auto;
  font-size: 0.58rem;
  color: var(--muted);
}

.st-sidebar-head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.st-thread-new {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 5px;
  background: rgba(124, 58, 237, 0.15);
  color: #c4b5fd;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.st-thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 0.25rem !important;
}

.st-thread-row {
  display: flex;
  align-items: stretch;
  gap: 0.2rem;
}

.st-thread-row.active .st-thread {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.15);
}

.st-thread-delete {
  flex-shrink: 0;
  width: 1.35rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.st-thread-delete:hover {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
}

.st-thread-rename {
  flex-shrink: 0;
  width: 1.35rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
}

.st-thread-rename:hover {
  border-color: rgba(124, 58, 237, 0.35);
  color: #c4b5fd;
}

.st-thread {
  flex: 1;
  text-align: start;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.4rem 0.45rem;
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.st-thread:hover {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.08);
}

.st-thread-row.active .st-thread,
.st-thread.active {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.15);
}

.st-thread-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-thread-meta {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.st-log-clear {
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.58rem;
  cursor: pointer;
}

.st-log-clear:hover {
  border-color: rgba(124, 58, 237, 0.35);
  color: #c4b5fd;
}

.st-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.25rem !important;
  max-height: calc(100vh - 12rem);
  overflow-y: auto;
}

.st-log-empty {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 0;
}

.st-log-entry {
  border-inline-start: 2px solid rgba(255, 255, 255, 0.12);
  padding: 0.35rem 0.4rem 0.35rem 0.5rem;
  border-radius: 0 5px 5px 0;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.65rem;
  line-height: 1.4;
}

.st-log-entry--ok {
  border-inline-start-color: #22c55e;
}

.st-log-entry--err {
  border-inline-start-color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

.st-log-entry--warn {
  border-inline-start-color: #eab308;
  background: rgba(234, 179, 8, 0.06);
}

.st-log-head {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}

.st-log-kind {
  font-weight: 600;
  color: #e8e8ed;
  text-transform: uppercase;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
}

.st-log-time {
  color: var(--muted);
  font-size: 0.58rem;
  flex-shrink: 0;
}

.st-log-detail {
  margin: 0 0 0.2rem;
  color: #d4d4d8;
}

.st-log-prompt {
  margin: 0.15rem 0;
  padding: 0.25rem 0.35rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  word-break: break-word;
}

.st-log-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
  align-items: center;
  margin-top: 0.15rem;
}

.st-log-code {
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  font-family: ui-monospace, monospace;
  font-size: 0.58rem;
}

.st-log-entry--ok .st-log-code {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.st-log-meta {
  color: var(--muted);
  font-size: 0.58rem;
}

.st-composer-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(124, 58, 237, 0.35);
  color: #c4b5fd;
  cursor: pointer;
  flex-shrink: 0;
}

.st-composer-send:hover {
  background: rgba(124, 58, 237, 0.55);
}

/* ── Preview ── */
.st-preview-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.5rem;
  box-sizing: border-box;
}

.st-preview-chrome {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  background: var(--st-panel);
  border: 1px solid var(--st-edge);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-size: 0.62rem;
  color: var(--tx-3);
}

.st-preview-dots {
  display: inline-flex;
  gap: 0.18rem;
}

.st-preview-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: block;
}

.st-preview-url {
  flex: 1;
  text-align: center;
  font-family: ui-monospace, monospace;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-preview-live {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #34d399;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
}

.st-preview-live.hidden,
.st-preview-loading.hidden,
.st-preview-empty.hidden,
.st-preview-frame.hidden {
  display: none !important;
}

.st-preview-stage {
  position: relative;
  flex: 1;
  min-height: 120px;
  border: 1px solid var(--st-edge);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  overflow: hidden;
  background: var(--bg);
}

.st-preview-stage.is-building .st-preview-frame {
  opacity: 0.35;
  filter: blur(1px);
  pointer-events: none;
}

.st-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  gap: 0.5rem;
  background: linear-gradient(160deg, #0c0c12, #14141c);
  z-index: 1;
}

.st-preview-empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.15), rgba(124, 58, 237, 0.25));
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-preview-empty-icon svg {
  width: 20px;
  height: 20px;
  opacity: 0.65;
}

.st-preview-empty-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e8e8ed;
  margin: 0;
}

.st-preview-empty-hint {
  font-size: 0.72rem;
  color: #9493a8;
  line-height: 1.45;
  max-width: 240px;
}

.st-preview-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(10, 10, 15, 0.72);
  color: #c4b5fd;
  font-size: 0.72rem;
  font-weight: 600;
}

.st-preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  z-index: 2;
}

/* ── Sidebar tools ── */
.st-brief {
  width: 100%;
  min-height: 72px;
  max-height: 140px;
  resize: vertical;
  border-radius: var(--r-sm);
  border: 1px solid var(--st-edge);
  background: var(--bg);
  color: var(--tx);
  font-family: inherit;
  font-size: 0.76rem;
  line-height: 1.4;
  padding: 0.45rem 0.55rem;
  box-sizing: border-box;
  margin-bottom: 0.45rem;
}

.st-brief:focus {
  outline: none;
  border-color: var(--brand-border);
  box-shadow: 0 0 0 2px var(--brand-dim);
}

.st-generate {
  width: 100%;
}

.st-generate.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.st-missions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.st-mission {
  text-align: start;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  background: rgba(124, 58, 237, 0.06);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.st-mission:hover {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.12);
}

.st-mission-title {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

.st-engine-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.st-engine {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.4rem 0.45rem;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  cursor: pointer;
  text-align: start;
  font-size: 0.68rem;
}

.st-engine.active {
  border-color: var(--model-c, #7c3aed);
  box-shadow: 0 0 0 1px var(--model-c, #7c3aed);
}

.st-engine.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.st-engine-name {
  font-weight: 600;
  display: block;
}

.st-engine-lock {
  font-size: 0.6rem;
  color: var(--muted);
}

.st-file-tree {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.st-file {
  text-align: start;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
}

.st-file:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #e8e8ed;
}

.st-file.active {
  background: rgba(124, 58, 237, 0.18);
  color: #e8e8ed;
}

.st-project-files {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  border-bottom: 1px solid var(--st-edge);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  overflow-x: auto;
}

.st-project-files-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.st-project-files-list {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.st-proj-file {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--st-edge);
  background: var(--st-panel);
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.st-proj-file:hover {
  border-color: rgba(124, 58, 237, 0.35);
  color: #ececf1;
}

.st-proj-file.active {
  border-color: rgba(124, 58, 237, 0.55);
  background: rgba(124, 58, 237, 0.12);
  color: #e9d5ff;
}

.st-proj-file--empty {
  opacity: 0.55;
}

.st-proj-file-icon {
  opacity: 0.65;
  font-size: 0.55rem;
}

.st-proj-file-meta {
  font-size: 0.58rem;
  opacity: 0.7;
}

/* ── Code canvas ── */
.st-code-canvas {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.st-code-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.68rem;
  background: #111116;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.st-code-file {
  font-family: ui-monospace, monospace;
  color: #e8e8ed;
}

.st-save-state {
  color: var(--muted);
  flex: 1;
}

.st-code-action {
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.65rem;
  cursor: pointer;
}

.st-code-action:hover {
  border-color: rgba(124, 58, 237, 0.4);
  color: #c4b5fd;
}

.st-monaco-wrap .st-monaco-mount {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* ── Chat ── */
.st-chat-empty {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

.st-chat-msg {
  margin-bottom: 0.35rem;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.st-chat-msg--user {
  background: rgba(124, 58, 237, 0.12);
}

.st-chat-who {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.1rem;
}

.st-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.62rem;
  color: var(--tx-3);
  border-top: 1px solid var(--st-edge);
  background: var(--st-panel);
  flex-shrink: 0;
}

#screen-studio {
  padding: 0 !important;
  overflow: hidden;
}

#screen-studio.active {
  display: flex;
  flex-direction: column;
}

#studioRoot {
  flex: 1;
  min-height: 0;
}

#studioRoot .btn {
  width: auto;
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.78rem;
  border-radius: var(--r-sm);
}

#studioRoot .btn-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.72rem;
}

#studioRoot .st-generate,
#studioRoot .st-import-btn {
  width: 100%;
}

#studioRoot .btn:not(.btn-primary):not(.btn-outline):not(.btn-ghost):not(.btn-success) {
  background: var(--bg-3);
  color: var(--tx);
  border: 1px solid var(--st-edge);
}

#app:has(#screen-studio.active) .ez-companion,
#app:has(#screen-studio.active) .sandbox-dock,
#app:has(#screen-studio.active) .streak-nudge {
  display: none !important;
}

#app:has(#screen-studio.active) {
  padding-left: 0 !important;
}

@media (max-width: 900px) {
  .st-sidebar--open {
    width: min(200px, 40vw);
  }
  .st-composer {
    max-height: min(160px, 32vh);
  }
}

/* Flow Lab workspace */
.st-layout--flow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.st-flow-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.st-mode-tabs {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.st-mode-tab {
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-full);
  border: 1px solid var(--st-edge);
  background: transparent;
  color: var(--tx-2);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.st-mode-tab:hover {
  border-color: var(--brand-border);
  color: var(--tx);
}

.st-mode-tab.is-active {
  opacity: 1;
  border-color: var(--brand-border);
  background: var(--brand-dim);
  color: var(--brand-hi);
}

#stWorkspace .st-mode-tabs.hidden {
  display: none !important;
}

#stWorkspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#stWorkspace .st-layout {
  flex: 1;
  min-height: 0;
}

.studio-flow-host {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.studio-flow-host .fl-root {
  flex: 1;
  min-height: 0;
}

@media (max-width: 480px) {
  .st-header,
  .st-header--hero { padding: 0.75rem var(--s4) 0.5rem; }
  .st-title { font-size: 1.35rem; }
  .st-sub { font-size: 0.8rem; }
  .st-picker-actions { padding: 0  var(--s4) 0.65rem; }
  .st-project-list { padding: 0 var(--s4); }
  .st-layout--ide { min-height: 0; }
  .st-sidebar--open { width: min(180px, 44vw); }
  .st-composer { max-height: min(140px, 28vh); }
  .st-composer-bar input { font-size: 14px; }
  .st-mode-tabs { padding: 0.3rem var(--s4) 0; flex-wrap: wrap; }
  .st-mode-tab { font-size: 0.72rem; padding: 0.3rem 0.6rem; }
  #screen-studio .screen { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s4)); }
}

.st-catalog {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.st-catalog-head {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.st-catalog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.st-catalog-chip {
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  background: rgba(124, 58, 237, 0.08);
  color: inherit;
  cursor: pointer;
}

.st-catalog-chip:hover {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.16);
}

.st-catalog-chip--block {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.08);
}

.st-data-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.st-data-hint,
.st-data-note {
  font-size: 0.72rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}

.st-data-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
}

.st-data-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.st-data-col {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.75rem;
}

.st-data-col.active {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.12);
}

.st-data-col-count {
  opacity: 0.65;
  font-size: 0.68rem;
}

.st-data-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
}

.st-data-row {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font-size: 0.72rem;
}

.st-data-row-main {
  flex: 1;
  min-width: 0;
}

.st-data-row-text {
  display: block;
  line-height: 1.35;
}

.st-data-row-when {
  display: block;
  margin-top: 0.15rem;
  opacity: 0.55;
  font-size: 0.65rem;
}

.st-data-row-del {
  border: none;
  background: transparent;
  color: rgba(255, 120, 120, 0.85);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.st-agent-fix {
  margin-top: 0.45rem;
  width: 100%;
}

/* EZ Flow Lab */

.fl-root {
  --fl-trigger: #22c55e;
  --fl-logic: #f59e0b;
  --fl-action: #8b5cf6;
  --fl-wire: #a78bfa;
  --fl-canvas-bg: rgba(10, 12, 22, 0.92);
  --fl-grid: rgba(139, 92, 246, 0.07);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  flex: 1;
}

.fl-root--studio-dark {
  --fl-canvas-bg: rgba(4, 6, 14, 0.96);
  --fl-grid: rgba(139, 92, 246, 0.1);
  padding: 0.35rem;
  border-radius: 10px;
  background: rgba(6, 8, 16, 0.65);
}

.fl-dev-banner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(
    120deg,
    rgba(124, 58, 237, 0.2) 0%,
    rgba(6, 182, 212, 0.1) 50%,
    rgba(124, 58, 237, 0.16) 100%
  );
  border: 1px solid rgba(167, 139, 250, 0.3);
  flex-shrink: 0;
}

.fl-dev-banner-badge {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
}

.fl-dev-banner-text {
  flex: 1;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.fl-dev-banner-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f5f3ff;
}

.fl-dev-banner-sub {
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(241, 240, 245, 0.68);
}

.fl-dev-banner-pulse {
  position: absolute;
  inset: -40% auto -40% -20%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}

.fl-canvas-dev-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  transform: translate(-50%, -50%) rotate(-18deg);
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: rgba(167, 139, 250, 0.07);
  pointer-events: none;
  user-select: none;
}

.fl-root--compact .fl-body {
  min-height: 320px;
}

.fl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.fl-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.fl-sub {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  opacity: 0.7;
  max-width: 40rem;
  line-height: 1.4;
}

.fl-palette-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  opacity: 0.5;
  line-height: 1.35;
}

.fl-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.fl-hint {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.fl-hint--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.fl-hint--warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.fl-hint--info {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
}

.fl-run-banner {
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
}

.fl-run-banner.is-ok {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.fl-run-banner.is-warn {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
}

.fl-body {
  display: grid;
  grid-template-columns: minmax(140px, 168px) 1fr minmax(160px, 200px);
  gap: 0.5rem;
  min-height: 0;
  flex: 1;
}

.fl-canvas-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
  min-width: 0;
}

.fl-canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.65rem;
  flex-shrink: 0;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.fl-toolbar-hint {
  font-size: 0.72rem;
  opacity: 0.55;
  line-height: 1.35;
  flex: 1;
  min-width: 10rem;
}

.fl-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.fl-toolbar-actions .btn-sm {
  min-height: 32px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.fl-side-label {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
  font-weight: 600;
}

/* Palette */
.fl-palette-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.fl-palette {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline-end: 2px;
  scrollbar-width: thin;
}

.fl-palette-group {
  margin-bottom: 0.5rem;
}

.fl-palette-group-label {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.5;
}

.fl-palette-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fl-palette-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
  cursor: grab;
  font-size: 0.72rem;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.fl-palette-item:hover {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.08);
}

.fl-palette-item.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.fl-palette-item--trigger { border-left: 3px solid var(--fl-trigger); }
.fl-palette-item--logic { border-left: 3px solid var(--fl-logic); }
.fl-palette-item--action { border-left: 3px solid var(--fl-action); }

.fl-palette-icon {
  font-size: 0.85rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.fl-palette-label {
  line-height: 1.25;
}

/* Canvas */
.fl-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  background: var(--fl-canvas-bg);
  overflow: hidden;
}

.fl-canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--fl-grid) 1px, transparent 1px);
  background-size: 18px 18px;
  pointer-events: none;
  z-index: 0;
}

.fl-canvas-wrap.is-wiring .fl-port-in {
  transform: scale(1.35);
  background: var(--fl-action);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.65);
}

.fl-canvas-wrap.is-wiring .fl-port-out {
  background: rgba(255, 255, 255, 0.2);
}

.fl-canvas-wrap.is-drag-over::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(139, 92, 246, 0.55);
  border-radius: 12px;
  pointer-events: none;
  z-index: 3;
}

.fl-canvas-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.fl-canvas-inner {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.fl-canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  pointer-events: none;
}

.fl-canvas-empty-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.7;
}

.fl-canvas-empty-sub {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  opacity: 0.45;
  max-width: 16rem;
}

/* Edges */
.fl-edge {
  fill: none;
  stroke: var(--fl-wire);
  stroke-width: 2.5;
  opacity: 0.75;
  transition: opacity 0.2s, stroke-width 0.2s;
}

.fl-edge.is-active {
  stroke: #c4b5fd;
  stroke-width: 3;
  opacity: 1;
}

.fl-edge--ghost {
  stroke-dasharray: 6 4;
  opacity: 0.9;
  stroke: #e9d5ff;
}

/* Nodes */
.fl-node {
  position: absolute;
  height: var(--fl-node-h, 76px);
  border-radius: 10px;
  background: rgba(18, 20, 32, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  cursor: grab;
  touch-action: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.fl-node.is-dragging {
  cursor: grabbing;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.fl-node.is-selected {
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35), 0 4px 16px rgba(0, 0, 0, 0.35);
}

.fl-node.is-active {
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.6), 0 0 20px rgba(139, 92, 246, 0.25);
}

.fl-node.is-ok {
  border-color: rgba(34, 197, 94, 0.55);
}

.fl-node.is-fail {
  border-color: rgba(245, 158, 11, 0.65);
}

.fl-node-body {
  display: flex;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
}

.fl-node-accent {
  width: 4px;
  flex-shrink: 0;
}

.fl-node--trigger .fl-node-accent { background: var(--fl-trigger); }
.fl-node--logic .fl-node-accent { background: var(--fl-logic); }
.fl-node--action .fl-node-accent { background: var(--fl-action); }

.fl-node-content {
  flex: 1;
  padding: 0.4rem 0.55rem 0.45rem;
  min-width: 0;
}

.fl-node-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

.fl-node-icon {
  font-size: 0.75rem;
  opacity: 0.85;
}

.fl-node-kind {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.45;
  flex: 1;
}

.fl-node-del {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.4;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.fl-node-del:hover {
  opacity: 0.9;
  color: #f87171;
}

.fl-node-title {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Ports */
.fl-port {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: #1a1630;
  padding: 0;
  cursor: crosshair;
  z-index: 4;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}

.fl-port:hover {
  transform: scale(1.25);
  background: var(--fl-action);
}

.fl-port-in {
  left: -8px;
  top: 50%;
  margin-top: -8px;
  border-color: #c4b5fd;
}

.fl-port-out {
  right: -8px;
  top: 50%;
  margin-top: -8px;
}

.fl-node--trigger .fl-port-out {
  border-color: var(--fl-trigger);
}

.fl-node--logic .fl-port-out {
  border-color: var(--fl-logic);
}

.fl-node--action .fl-port-out {
  border-color: var(--fl-action);
}

/* Side panels */
.fl-side {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.fl-config-panel,
.fl-log-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.fl-config {
  flex: 0 0 auto;
  font-size: 0.82rem;
}

.fl-config-empty {
  margin: 0;
  opacity: 0.5;
  font-size: 0.8rem;
}

.fl-config-head {
  margin-bottom: 0.65rem;
}

.fl-config-kind {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}

.fl-kind-trigger { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.fl-kind-logic { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.fl-kind-action { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }

.fl-config-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
}

.fl-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
}

.fl-field span {
  font-size: 0.72rem;
  opacity: 0.65;
}

.fl-field input {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font-size: 0.82rem;
}

.fl-log-body {
  flex: 1;
  min-height: 120px;
  max-height: 200px;
  overflow: auto;
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.76rem;
  font-family: ui-monospace, monospace;
  line-height: 1.45;
}

.fl-log-line {
  margin-bottom: 0.25rem;
}

.fl-log-empty {
  margin: 0;
  opacity: 0.45;
  font-family: inherit;
}

.fl-log-warn { color: #fcd34d; }
.fl-log-error { color: #fca5a5; }
.fl-log-info { color: #c4b5fd; }

.fl-sim-note {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.45;
  text-align: center;
}

.fl-rubric {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.fl-rubric-item {
  padding: 0.2rem 0;
  opacity: 0.65;
}

.fl-rubric-item.is-met {
  opacity: 1;
  color: #86efac;
}

.fl-feedback {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.fl-feedback.is-pass { color: #86efac; }
.fl-feedback.is-fail { color: #fca5a5; }

.fl-inline-wrap {
  margin-top: 0.75rem;
  min-height: 460px;
}

.fl-inline-wrap .fl-body {
  min-height: 380px;
}

.fl-inline-wrap .fl-canvas-wrap {
  min-height: 340px;
}

/* Studio full-screen mode */
.studio-flow-host {
  flex: 1;
  min-height: 0;
  display: flex;
}

.studio-flow-host .fl-root {
  width: 100%;
}

.studio-flow-host .fl-body {
  flex: 1;
  min-height: 0;
}

.studio-flow-host .fl-canvas-wrap {
  min-height: 360px;
}

.studio-flow-host .fl-palette-wrap {
  max-height: 100%;
}

@media (max-width: 900px) {
  .fl-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .fl-canvas-wrap {
    min-height: 300px;
  }

  .fl-log-body {
    max-height: 140px;
  }
}

@media (max-width: 480px) {
  .fl-body { gap: 0.35rem; }
  .fl-canvas-wrap { min-height: 240px; }
  .fl-log-body { max-height: 110px; }
  .fl-palette-wrap { max-height: 42vh; }
  .fl-toolbar { flex-wrap: wrap; gap: 0.25rem; padding: 0.35rem var(--s4); }
  .fl-toolbar-btn { font-size: 0.72rem; padding: 0.3rem 0.55rem; }
  .studio-flow-host .fl-canvas-wrap { min-height: 260px; }
}

/* Shared assessment UI — lesson player + exam runner alignment */

.exercise-scenario,
.order-block .exercise-scenario,
.match-block .exercise-scenario,
.quiz-intro.exercise-scenario {
  margin: 0 0 var(--s3);
  font-size: var(--fs-sm);
  color: #c4b5fd;
  line-height: 1.5;
}

.lesson-card.is-step-enter {
  animation: assessCardIn 0.35s ease both;
}

@keyframes assessCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.lesson-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.exercise-check-btn {
  width: 100%;
  max-width: 640px;
  margin: var(--s3) auto 0;
  min-height: 44px;
}

@media (max-width: 479px) {
  .ls-match-row {
    grid-template-columns: 1fr;
    gap: var(--s2);
  }

  .ls-match-left {
    font-weight: 600;
    font-size: var(--fs-sm);
    padding-bottom: var(--s1);
    border-bottom: 1px solid var(--border);
  }

  .ls-match-select {
    width: 100%;
    min-height: 44px;
    font-size: var(--fs-body);
  }

  .ls-order-item {
    padding: var(--s3);
    gap: var(--s2);
  }

  .ls-order-nudge {
    width: 44px;
    height: 32px;
    font-size: 0.75rem;
  }

  .choice {
    padding: var(--s3);
    min-height: 44px;
    border-radius: 10px;
  }

  .choice-key {
    width: 26px;
    height: 26px;
  }
}

/* ── EZ Exam system (host overlay + iframe runner) ── */
.exam-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(4, 4, 8, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.exam-overlay[hidden] {
  display: none !important;
}

body.exam-mode-open {
  overflow: hidden;
}

.exam-overlay-inner {
  width: min(760px, 100%);
  height: min(82dvh, 760px);
  margin: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-2, #12121a);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.exam-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--chrome-border, rgba(255, 255, 255, 0.08));
}

.exam-overlay-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exam-overlay-close {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}

.exam-overlay-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.exam-overlay-stage.hidden {
  display: none;
}

.exam-iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  background: #0a0a0f;
  display: block;
}

.exam-results {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.exam-results.hidden {
  display: none;
}

.exam-score-card {
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  animation: examScoreIn 0.5s ease;
}

.exam-score-card.pass {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.exam-score-card.fail {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes examScoreIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.exam-score-ring {
  width: 5rem;
  height: 5rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: conic-gradient(#a78bfa calc(var(--pct, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
  display: grid;
  place-items: center;
}

.exam-score-ring::before {
  content: "";
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: var(--bg-2, #12121a);
}

.exam-score-num {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 800;
}

.exam-score-card {
  position: relative;
}

.exam-result-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.exam-result-row {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.04);
}

.exam-result-pts {
  font-weight: 700;
  font-size: 0.72rem;
  color: #c4b5fd;
  white-space: nowrap;
}

.exam-points,
.exam-coins {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.exam-coins {
  color: #fbbf24;
  font-weight: 700;
}

.exam-result-row.ok { border-inline-start: 3px solid #34d399; }
.exam-result-row.bad { border-inline-start: 3px solid #f87171; }

/* ── iframe runner ── */
.exm-body {
  margin: 0;
  min-height: 100dvh;
  background: #0a0a0f;
  color: #e8e8ed;
  font-family: "Heebo", system-ui, sans-serif;
  overflow: hidden;
}

.exm-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.exm-head {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.exm-progress-wrap {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.exm-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  transition: width 0.25s ease;
}

.exm-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.exm-q-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9493a8;
}

.exm-timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.85rem;
}

.exm-timer-ring {
  width: 1.75rem;
  height: 1.75rem;
  transform: rotate(-90deg);
}

.exm-timer-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 2.5;
}

.exm-timer-fill {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s ease;
}

.exm-anticheat {
  margin: 0.35rem 0 0;
  font-size: 0.65rem;
  color: #9493a8;
}

.exm-main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.exm-card {
  animation: exmCardIn 0.35s ease;
}

@keyframes exmCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.exm-scenario {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: #c4b5fd;
  line-height: 1.45;
}

.exm-q-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.exm-diff {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.exm-diff--easy { color: #34d399; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); }
.exm-diff--medium { color: #fbbf24; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.35); }
.exm-diff--hard { color: #f87171; background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }

.exm-pts {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9493a8;
}

.exm-concept-figure {
  margin: 0 0 0.85rem;
  width: 100%;
}

.exm-concept-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.25);
  background: rgba(255, 255, 255, 0.03);
}

.exm-concept-caption {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: #9493a8;
  line-height: 1.4;
}

.exm-q {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  line-height: 1.4;
}

.exm-hint {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: #9493a8;
}

.exm-choices {
  display: grid;
  gap: 0.45rem;
}

.exm-choice {
  text-align: start;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.exm-choice:hover {
  border-color: rgba(124, 58, 237, 0.45);
}

.exm-choice.is-selected {
  border-color: #a78bfa;
  background: rgba(124, 58, 237, 0.2);
}

.exm-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
}

.exm-check.is-selected {
  border-color: #a78bfa;
  background: rgba(124, 58, 237, 0.15);
}

.exm-written {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
  resize: vertical;
}

.exm-order {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.exm-order-item {
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: grab;
}

.exm-order-item.is-dragging {
  opacity: 0.5;
}

.exm-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: #0a0a0f;
}

.exm-btn {
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.exm-btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
}

.exm-btn--primary {
  background: #7c3aed;
  color: #fff;
}

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

.exm-submitting {
  text-align: center;
  padding: 2rem;
  color: #a78bfa;
}

.learn-exam-cta {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.learn-exam-cta .btn {
  width: 100%;
}

@media (min-width: 1100px) {
  .exam-overlay-inner {
    width: min(820px, calc(100vw - 3rem));
  }
}

@media (max-height: 680px) and (min-width: 641px) {
  .exam-overlay {
    padding-block: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-bottom));
  }

  .exam-overlay-inner {
    height: min(92dvh, 640px);
  }

  .exm-head {
    padding: 0.55rem 0.85rem 0.45rem;
  }

  .exm-anticheat {
    display: none;
  }

  .exm-main {
    padding: 0.75rem 0.85rem;
  }
}

@media (max-width: 640px) {
  .exam-overlay {
    align-items: stretch;
    padding: 0;
  }

  .exam-overlay-inner {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border-inline: 0;
  }

  .exam-overlay-head {
    min-height: calc(3.25rem + env(safe-area-inset-top, 0px));
    padding:
      calc(0.65rem + env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-right, 0px))
      0.65rem
      max(0.75rem, env(safe-area-inset-left, 0px));
  }

  .exam-overlay-title {
    font-size: 0.92rem;
  }

  .exam-overlay-close {
    width: 2.25rem;
    height: 2.25rem;
  }

  .exm-head {
    padding: 0.65rem 0.85rem 0.5rem;
  }

  .exm-progress-wrap {
    height: 5px;
  }

  .exm-anticheat {
    margin-top: 0.25rem;
    font-size: 0.62rem;
  }

  .exm-main {
    padding: 0.85rem;
  }

  .exm-q {
    font-size: clamp(1rem, 4vw, 1.15rem);
  }

  .exm-choice,
  .exm-check,
  .exm-order-item {
    min-height: 44px;
    padding: 0.75rem 0.85rem;
  }

  .exm-foot {
    padding:
      0.65rem
      max(0.85rem, env(safe-area-inset-right, 0px))
      calc(0.65rem + env(safe-area-inset-bottom, 0px))
      max(0.85rem, env(safe-area-inset-left, 0px));
  }

  .exm-btn {
    flex: 1;
    min-height: 44px;
  }
}

/* Learn system — exam-runner visual alignment (parts 2–10)
   Layered on app.css + assessment.css + exam.css — no feature removal. */

:root {
  --learn-shell-bg: #12121a;
  --learn-shell-border: rgba(124, 58, 237, 0.35);
  --learn-shell-muted: #9493a8;
  --learn-shell-accent: #c4b5fd;
  --learn-shell-glow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --learn-read-body: 1.0625rem;
  --learn-read-title: 1.25rem;
  --learn-read-choice: 1rem;
  --lesson-chrome-h: 68px;
}

/* ── Part 2: Lesson player shell ── */
.lesson.open {
  background: rgba(4, 4, 8, 0.96);
  backdrop-filter: blur(6px);
}

.lesson-main {
  background: var(--learn-shell-bg);
  border-inline-start: 1px solid var(--learn-shell-border);
  box-shadow: var(--learn-shell-glow);
}

.lesson-hud {
  height: var(--lesson-chrome-h);
  min-height: var(--lesson-chrome-h);
  align-items: center;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--learn-shell-bg) 92%, #000);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.lesson-hud-context {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.lesson-hud-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.lesson-hud-context .lesson-coach-chip {
  width: 34px;
  height: 34px;
  animation: none;
}

.lesson-hud-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lesson-hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.lesson-step-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--learn-shell-accent);
  white-space: nowrap;
}

.lesson-coach-tip {
  margin: 0;
  color: var(--tx);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lesson-step-pct {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--learn-shell-accent);
}

.lesson-hud .lp-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.lesson-hud .lp-bar > i {
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.lesson-body {
  max-width: min(720px, 100%);
  padding: 1.25rem 1rem 1.5rem;
  flex: 0 1 auto;
  align-self: stretch;
  max-height: calc(100dvh - var(--lesson-chrome-h) - 5.5rem - env(safe-area-inset-bottom, 0px));
}

.lesson-card {
  border: 1px solid rgba(124, 58, 237, 0.28);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.08), var(--bg-2));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: exmCardIn 0.35s ease both;
}

.lesson-card.is-visible {
  animation: exmCardIn 0.35s ease both;
}

.lesson-body .kicker,
.lesson-head .kicker {
  color: var(--learn-shell-accent);
  letter-spacing: 0.08em;
}

.ls-step-tag {
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.35);
  color: var(--learn-shell-accent);
}

.ls-prose,
.lesson-body h2,
.lesson-head h2 {
  line-height: 1.55;
}

/* ── Readability: larger lesson copy ── */
.lesson-body .ls-prose,
.lesson-body .ls-prose-p,
.lesson-body .ls-body,
.lesson-card .sb-task,
.lesson-card .task-dock-prose {
  font-size: var(--learn-read-body);
  line-height: 1.75;
}

.lesson-body .ls-section-title {
  font-size: var(--learn-read-title);
  line-height: 1.45;
}

.lesson-body h2,
.lesson-head h2 {
  font-size: clamp(1.45rem, 4.5vw, 1.95rem);
}

.lesson-card .quiz-q,
.lesson-card .quiz-intro {
  font-size: var(--learn-read-body);
  line-height: 1.7;
}

.lesson-card .choice {
  font-size: var(--learn-read-choice);
  padding: 0.85rem 1rem;
}

.lesson-card .choice-key {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.lesson-card .choice-text {
  line-height: 1.6;
}

.lesson-coach,
.lesson-coach p {
  font-size: var(--learn-read-choice);
  line-height: 1.55;
}

/* coach merged into .lesson-hud — hide legacy standalone row if present */
.lesson-main > .lesson-coach:not(.lesson-hud-context) {
  display: none;
}

.quiz-intro.exercise-scenario,
.ls-prose .exercise-scenario {
  color: var(--learn-shell-accent);
}

.lesson-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: color-mix(in srgb, var(--learn-shell-bg) 94%, transparent);
}

.lesson-footer .btn-primary {
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

.ls-section-title.ls-section-primary {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  margin-bottom: 0.75rem;
}

/* ── Part 3: Path rail (module tree) ── */
.lesson-path-rail {
  background: #0e0e14;
  border-inline-end-color: rgba(255, 255, 255, 0.08);
}

.lesson-path-rail-head {
  flex: 0 0 var(--lesson-chrome-h);
  height: var(--lesson-chrome-h);
  min-height: var(--lesson-chrome-h);
  background: color-mix(in srgb, var(--learn-shell-bg) 95%, #000);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.lesson-path-mod-head {
  border-radius: 10px;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.lesson-path-mod.is-active-mod .lesson-path-mod-head {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.1);
}

.lesson-path-rail-title {
  font-size: var(--fs-body);
}

.lesson-path-mod-title {
  font-size: var(--fs-sm);
}

.lesson-path-rail .lib-class-title {
  font-size: var(--fs-body);
}

.lesson-path-mod-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.lesson-path-mod-badge.is-here {
  color: #a78bfa;
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.35);
}

.lesson-path-mod-badge.is-locked {
  color: var(--learn-shell-muted);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.lesson-path-mod-badge.is-open {
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
}

.lesson-path-rail .lib-class {
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.lesson-path-rail .lib-class.is-active {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.12);
  box-shadow: inset 3px 0 0 #a78bfa;
}

.lesson-path-rail .lib-class.state-current:not(.is-active) {
  background: rgba(255, 255, 255, 0.04);
}

.lesson-path-toggle {
  border-color: rgba(124, 58, 237, 0.35);
  background: color-mix(in srgb, var(--learn-shell-bg) 92%, #000);
}

.lesson-hud .hint-btn {
  flex-shrink: 0;
}

/* ── Part 4: Journey / Path tab ── */
.journey-track-pill {
  border: 1px solid rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.08);
  border-radius: 999px;
}

.journey-progress-ring {
  background: conic-gradient(#a78bfa calc(var(--pct, 0) * 1%), rgba(255, 255, 255, 0.08) 0);
}

.journey-chapter-head {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.journey-chapter-title {
  font-weight: 700;
}

.path-item.current .pi-card {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.18);
}

/* ── Part 5: Learn tab (matrix + library) ── */
.learn-rank.card,
.learn-mode.card,
.learn-expansion.card,
.learn-track.card {
  border: 1px solid var(--learn-shell-border);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(124, 58, 237, 0.06), var(--bg-2));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.learn-rank-kicker,
.learn-grade-kicker {
  color: var(--learn-shell-accent);
  letter-spacing: 0.08em;
}

.learn-rank-xp-bar,
.learn-track-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.learn-rank-xp-bar i,
.learn-track-bar i {
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.learn-track-head {
  transition: background 0.15s;
}

.learn-track-head.open {
  background: rgba(124, 58, 237, 0.06);
}

.learn-mastery-chip {
  border-radius: 999px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  font-size: 0.68rem;
  font-weight: 700;
}

.learn-mode-btn.is-active {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.16);
  color: var(--learn-shell-accent);
}

.lib-bar {
  border: 1px solid var(--learn-shell-border);
  border-radius: 14px;
  background: var(--learn-shell-bg);
}

.lib-open-book,
.lib-read-page {
  border-radius: 14px;
}

.lib-read-page {
  font-size: var(--learn-read-body);
  line-height: 1.75;
  max-width: min(680px, 100%);
}

.lib-read-page p,
.lib-read-page li {
  font-size: inherit;
  line-height: inherit;
}

/* ── Library reader: readable literacy layout ── */
.lib-read-header {
  padding: 0.75rem 0 0.5rem;
  gap: 0.75rem;
}

.lib-read-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--learn-shell-accent);
}

.lib-read-title {
  font-family: var(--font-d);
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  font-weight: 700;
  white-space: normal;
  line-height: 1.25;
}

.lib-read-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(124, 58, 237, 0.28);
  background: rgba(124, 58, 237, 0.1);
  color: var(--learn-shell-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.lib-read-notice .ic {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--learn-shell-accent);
}

.lib-read-main {
  padding-bottom: 1.5rem;
}

.lib-read-article {
  padding-inline: clamp(0.25rem, 2vw, 0.5rem);
  overflow-wrap: anywhere;
}

.lib-read-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding-top: 1rem;
}

.lib-read-journey {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

.rd-lead {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rd-lead .kicker {
  color: var(--learn-shell-accent);
  letter-spacing: 0.08em;
}

.rd-lead h2 {
  font-size: clamp(1.65rem, 5vw, 2.15rem);
  line-height: 1.2;
  margin: 0.35rem 0 0.5rem;
}

.rd-meta {
  font-size: 0.95rem;
  color: var(--learn-shell-muted);
}

.rd-sec {
  padding: 1.35rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rd-sec:first-of-type {
  border-top: none;
  padding-top: 0;
}

.rd-h {
  font-size: clamp(1.2rem, 3.5vw, 1.45rem);
  line-height: 1.35;
  margin: 0 0 0.85rem;
}

.rd-subh,
.rd-h4 {
  font-family: var(--font-d);
  color: var(--learn-shell-accent);
  line-height: 1.35;
  margin: 1.25rem 0 0.65rem;
}

.rd-subh {
  font-size: 1.15rem;
}

.rd-h4 {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.01em;
}

.ls-prose-p {
  margin: 0 0 0.85rem;
}

.ls-prose-p:last-child {
  margin-bottom: 0;
}

.rd-list {
  margin: 0.5rem 0 1rem;
  padding-inline-start: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rd-list--ol {
  list-style: decimal;
}

.rd-list--ul {
  list-style: disc;
}

.rd-list-item {
  padding-inline-start: 0.15rem;
}

.rd-list-item strong {
  color: var(--tx);
}

.rd-reveal {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
}

.rd-task-tag {
  display: inline-flex;
  margin-bottom: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.14);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.rd-quiz-q {
  font-size: var(--learn-read-body);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.rd-choice {
  font-size: var(--learn-read-choice);
  padding: 0.75rem 1rem;
}

.rd-lab .lib-read-lab-journey {
  margin-top: 1rem;
}

/* Library shelf module headers */
.lib-mod-title {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.lib-open-title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
}

.lib-class-title {
  font-size: 0.95rem;
  line-height: 1.35;
}

.lib-class-meta {
  font-size: 0.82rem;
}

/* ── Part 6: Tests hub ── */
.tests-bar {
  border: 1px solid var(--learn-shell-border);
  border-radius: 14px;
  background: var(--learn-shell-bg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.test-card {
  border-radius: 10px;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.test-card:not(.test-card--locked):hover {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.08);
  transform: translateY(-1px);
}

.test-route-head {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

/* ── Part 7: Mastery + cert routes ── */
.learn-mastery,
.learn-rank-mastery {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.route-chip,
.trail-card {
  border-radius: 10px;
}

.trail-cap--cert.is-earned .trail-node--cert {
  box-shadow: 0 0 0 4px var(--bg), 0 0 18px rgba(167, 139, 250, 0.45);
}

/* ── Part 8: Assessment steps (quiz / order / match) ── */
.lesson-card--quiz {
  border-color: rgba(251, 191, 36, 0.28);
}

.exercise-badge,
.quiz-block.is-checkpoint .exercise-badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.choice {
  border-radius: 10px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.choice:hover:not(.correct):not(.wrong) {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.08);
}

.choice.correct {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.12);
}

.choice.wrong {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
}

.exercise-check-btn {
  border-radius: 10px;
  font-weight: 700;
}

/* ── Part 9: Celebration + reader ── */
.cel-card {
  border: 1px solid var(--learn-shell-border);
  border-radius: 16px;
  box-shadow: var(--learn-shell-glow);
}

.lib-read-page--loading .learn-loading {
  border: 1px solid var(--learn-shell-border);
  border-radius: 14px;
}

/* ── Part 10: Responsive ── */
@media (min-width: 940px) {
  .lesson.open {
    inset-inline-end: var(--nav-w, 220px);
  }

  .lesson.is-rail-visible.is-rail-open .lesson-path-rail {
    flex: 0 0 min(280px, 32vw);
    width: min(280px, 32vw);
  }

  .lesson-main {
    border-radius: 0;
  }
}

@media (max-width: 939px) {
  .lesson-main {
    border-inline-start: none;
  }

  .lesson-hud {
    height: calc(var(--lesson-chrome-h) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--lesson-chrome-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-inline: 0.85rem;
  }

  .lesson-path-rail-head {
    flex: 0 0 calc(var(--lesson-chrome-h) + env(safe-area-inset-top, 0px));
    height: calc(var(--lesson-chrome-h) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--lesson-chrome-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }

  .lesson-body {
    padding: 1rem 0.85rem 1.25rem;
  }

  .lesson-hud-row {
    font-size: 0.78rem;
  }
}

@media (max-width: 479px) {
  .test-cards {
    grid-template-columns: 1fr;
  }

  .learn-rank-head {
    flex-wrap: wrap;
  }
}
