/* TwiddleLab app: extensions on top of friendly.css (copied from design/friendly).
   Sections: shell, home, track map, catalog, course, player, widgets, AI-1 scenes. */

/* ---------- shell ---------- */
body { background: var(--white); }
.app-loading { padding: 40vh 0 0; text-align: center; color: var(--ink-3); font-weight: 600; }
.app-error { padding: 80px 0; }
.app-error .lead { margin: 14px 0 28px; }
.app-footer { margin-top: 96px; }
.footer { padding: 36px 0 48px; border-top: 1.5px solid var(--line); }
.footer-in { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 22px; }
.footer-links a { color: var(--ink-2); font-weight: 500; text-decoration: none; }
.footer-links a:hover { color: var(--ink); }
.nav-links a { white-space: nowrap; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255,255,255,.96); border-top: 1.5px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; padding: 10px 4px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--ink-2); text-decoration: none; }
  .tabbar a[aria-current] { background: var(--cream); color: var(--ink); }
  .app-footer { padding-bottom: 90px; }
}
.link-btn { border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: var(--pip); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.link-btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 4px; }

/* ---------- home ---------- */
.continue-art { position: relative; display: flex; align-items: flex-end; justify-content: center; min-height: 260px; }
.continue-art .toy { width: min(300px, 70%); aspect-ratio: 1; border-radius: 50%; background: #fff; }
.continue-art .pip { position: absolute; right: 6%; bottom: -6px; }
.continue .bar i { background: var(--c, var(--violet)); }
.courses-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.courses-head h2 { margin-bottom: 0 !important; }
.empty-row { padding: 28px 24px; border-radius: var(--r-l); background: var(--cream); color: var(--ink-2); }

/* ---------- track map ---------- */
.track-head { padding: 28px 0 56px; }
.track-head-grid { display: grid; grid-template-columns: 200px 1fr; gap: 44px; align-items: center; margin-top: 26px; }
.track-head .toy { width: 100%; aspect-ratio: 1; border-radius: 50%; }
.track-head .subj { font-weight: 600; color: var(--c); font-size: 18px; }
.track-head h1 { margin-top: 6px; font-size: clamp(40px, 4.4vw, 60px); }
.track-head .lead { margin-top: 12px; }
.track-head .row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
.track-switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.track-switch a { padding: 8px 18px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 17px; color: var(--ink-2); }
.track-switch a small { font-weight: 500; font-size: 13px; color: var(--ink-3); }
.track-switch a[aria-current] { background: var(--cream); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.soon-note { display: flex; align-items: center; gap: 18px 24px; flex-wrap: wrap; padding: 16px 20px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.soon-note p { flex: 1; min-width: 260px; color: var(--ink-2); }
.soon-note b { color: var(--ink); }

.map-wrap { margin-top: 40px; }
.map-legend { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.lg::before { content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 8px; vertical-align: -2px; }
.lg.done::before { background: var(--mint-btn); }
.lg.open::before { background: #fff; box-shadow: inset 0 0 0 3px var(--violet); }
.lg.locked::before { background: #ECE8E1; }
.lg.soon::before { background: #fff; box-shadow: inset 0 0 0 2px var(--line-2); }
.map-scroll { overflow-x: auto; padding-bottom: 6px; }
.map { --label: 168px; position: relative; display: flex; flex-direction: column; gap: 8px; min-width: calc(var(--label) + var(--cols) * 172px); }
.band { position: relative; display: grid; grid-template-columns: var(--label) repeat(var(--cols), minmax(0, 1fr)); gap: 0 14px; align-items: center; border-radius: 20px; background: var(--cream); padding: 14px 14px; min-height: 112px; }
.band.alt { background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
.band-head { background: transparent; min-height: 0; padding: 0 14px; font-weight: 600; font-size: 15px; color: var(--ink-3); }
.band-head span { padding-left: 6px; }
.band-title { font-family: var(--body); font-weight: 700; font-size: 16px; letter-spacing: 0; line-height: 1.3; color: var(--ink-2); padding-right: 8px; }
.cell { display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 2; }
.cnode { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 16px; background: #fff; text-decoration: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); transition: transform .12s ease, box-shadow .12s ease; }
a.cnode:hover { transform: translateY(-2px); }
a.cnode:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.cnode-toy { position: relative; width: 52px; height: 52px; border-radius: 50%; flex: none; overflow: visible; }
.cnode-toy svg { border-radius: 50%; }
.cnode-toy::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: conic-gradient(var(--mint-btn) var(--p), transparent 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); }
.cnode-lock { position: absolute; right: -6px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: #A8A4B4; display: grid; place-items: center; box-shadow: 0 0 0 1.5px var(--line-2); }
.cnode-lock svg { width: 15px; height: 15px; }
.cnode-body { display: flex; flex-direction: column; min-width: 0; }
.cnode-body b { font-weight: 700; font-size: 15px; line-height: 1.25; }
.cnode-body small { font-weight: 500; font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.cnode-hint { display: flex; gap: 4px; align-items: flex-start; margin-top: 6px; font-size: 12.5px; line-height: 1.3; font-weight: 600; color: var(--sun-ink); }
.cnode-hint svg { width: 13px; height: 13px; flex: none; margin-top: 1px; color: #B3AEBF; }
.cnode.is-open { box-shadow: inset 0 0 0 2px var(--violet), 0 3px 0 var(--violet-ink); }
.cnode.is-open small { color: var(--violet-ink); font-weight: 600; }
.cnode.is-open.is-soon { box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); }
.cnode.is-open.is-soon small { color: var(--ink-3); font-weight: 500; }
.cnode.is-started { box-shadow: inset 0 0 0 2px var(--pip), 0 3px 0 var(--pip-edge); }
.cnode.is-started small { color: var(--pip-edge); font-weight: 600; }
.cnode.is-done { background: var(--mint-soft); box-shadow: inset 0 0 0 1.5px #A9E5CB, 0 3px 0 #A9E5CB; }
.cnode.is-locked { background: #FBFAF7; box-shadow: inset 0 0 0 1.5px var(--line); }
.cnode.is-locked .cnode-toy { filter: grayscale(1); opacity: .55; }
.cnode.is-locked b { color: var(--ink-2); }
.cnode.is-mock { background: #FBFAF7; box-shadow: inset 0 0 0 1.5px var(--line); cursor: default; }
.cnode.is-mock .cnode-toy { opacity: .55; }
.cnode.is-mock b { color: var(--ink-2); }
.map-links { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; overflow: visible; }
.map-links path { fill: none; stroke: #CFC8E8; stroke-width: 2.5; stroke-dasharray: 2 7; stroke-linecap: round; }
.map-links path.on { stroke: var(--violet); stroke-dasharray: none; }
.is-mock .map-links path { stroke: var(--line-2); }
.map-note { margin-top: 18px; color: var(--ink-2); font-size: 16px; }
@media (max-width: 760px) {
  .track-head-grid { grid-template-columns: 1fr; gap: 16px; }
  .track-head .toy { width: 120px; }
  .map { --label: 0px; }
  .band { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
  .band-title { grid-column: 1 / -1; position: sticky; left: 0; justify-self: start; margin-bottom: 8px; }
  .band-head span:first-child { display: none; }
}

/* ---------- catalog ---------- */
.catalog-head { padding: 44px 0 8px; }
.catalog-head .lead { margin-top: 12px; }
.cat-track { margin-top: 48px; padding: clamp(22px, 3vw, 36px); border-radius: var(--r-xl); background: var(--soft); }
.cat-track-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cat-track-head .subj { font-weight: 600; color: var(--c); font-size: 17px; }
.cat-track-head h2 { font-size: clamp(28px, 3vw, 38px); margin-top: 4px; }
.cat-area { margin-top: 26px; }
.cat-area h3 { font-family: var(--body); font-weight: 700; font-size: 17px; letter-spacing: 0; color: var(--ink-2); margin-bottom: 10px; }
.ccards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ccard { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: #fff; text-decoration: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); transition: transform .12s ease; }
a.ccard:hover { transform: translateY(-2px); }
.ccard .toy { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.ccard-body { display: flex; flex-direction: column; min-width: 0; }
.ccard .lvl { font-size: 13px; font-weight: 600; color: var(--c); }
.ccard b { font-size: 16px; line-height: 1.25; }
.ccard .st { display: flex; gap: 5px; align-items: center; font-size: 13.5px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }
.ccard .st svg { width: 13px; height: 13px; color: #B3AEBF; flex: none; }
.ccard.is-locked .toy, .ccard.is-mock .toy { opacity: .55; filter: grayscale(.6); }
.ccard.is-mock { box-shadow: inset 0 0 0 1.5px var(--line); cursor: default; }

/* ---------- course ---------- */
.crumbs a { font-weight: 600; color: var(--c); font-size: 18px; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip-s { padding: 4px 12px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); font-weight: 600; font-size: 15px; color: var(--ink-2); }
.lock-note { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); font-weight: 600; color: var(--ink-2); }
.lock-note svg { width: 20px; height: 20px; color: #B3AEBF; }
.section-tight { padding: 40px 0 56px; }
.prereq-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.prereq-grid h2 { font-size: 24px; letter-spacing: -0.015em; margin-bottom: 10px; }
.prereqs { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.prereqs li { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.prereqs li::before { content: ""; width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px var(--line-2); margin-top: 3px; }
.prereqs li.ok::before { display: none; }
.prereqs li.ok svg { width: 22px; height: 22px; flex: none; margin-top: 3px; border-radius: 50%; background: var(--mint-btn); }
.prereqs li.ok svg circle { fill: var(--mint-btn); }
.prereqs li.ok svg path { stroke: #fff; }
.prereqs small { display: block; font-weight: 500; font-size: 15px; color: var(--ink-3); }
.prereqs a { color: var(--ink); text-decoration-color: var(--pip); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.step.open .node { background: #fff; color: var(--violet-ink); box-shadow: inset 0 0 0 2.5px var(--violet), 0 3px 0 var(--violet-ink); }
.step.open .label small { color: var(--violet-ink); }
a.node:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; }
.bridge-hint { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 8px; background: var(--sun-soft); color: var(--sun-ink); font-weight: 600; font-size: 14px; }

/* ---------- player ---------- */
.lmain .q-sub p + p { margin-top: 8px; }
.lmain .q-sub[hidden] { display: none; }
.lmain .scene-stage:empty { display: none; }
.scene-slot .stage { margin-top: 22px; }
.widget-slot > :first-child { margin-top: 22px; }
.scene-error { padding: 18px; border-radius: 14px; background: #FFF5EE; color: var(--pip-edge); font-weight: 600; }
.lfoot .fb .pip { --size: 96px; }
.md-list { margin: 8px 0 0; padding-left: 1.2em; }
.md-list li + li { margin-top: 4px; }

/* ---------- widgets ---------- */
/* narrative */
.narr-card { padding: 20px 24px; border-radius: var(--r-l); background: var(--cream); font-size: 19px; }
.narr-card p + p, .narr-card ul + p { margin-top: 12px; }
.narr-card .md-list { margin: 0; padding-left: 1.2em; }
.narr-card .md-list li::marker { color: var(--pip); }

/* reveal */
.reveal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.reveal-card { display: block; width: 100%; padding: 16px 20px; border-radius: 16px; font-size: 18px; line-height: 1.45; text-align: left; }
.reveal-card.is-open { background: var(--violet-soft); }
.reveal-card.is-open b { color: var(--violet-ink); }
.reveal-card.is-new { animation: rise .3s ease-out; }
.reveal-card.is-closed { border: 0; cursor: pointer; background: #fff; box-shadow: inset 0 0 0 2px var(--violet), 0 3px 0 var(--violet-ink); font-family: var(--body); font-weight: 700; color: var(--violet-ink); text-align: center; }
.reveal-card.is-closed:hover { background: var(--violet-soft); }
.reveal-card.is-closed:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

/* choice */
.choice span { min-width: 0; }
.choices.stack .choice { font-size: 18px; line-height: 1.35; }
.choice.is-wrong[aria-pressed=true] { background: #FFFBEF; box-shadow: inset 0 0 0 2px var(--sun-edge), 0 3px 0 var(--sun-ink); }
.choice.is-right[aria-pressed=true] { background: var(--mint-soft); box-shadow: inset 0 0 0 2px var(--mint-btn), 0 3px 0 var(--mint-edge); }
.choice[disabled] { cursor: default; }

/* true or false cards */
.tf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tf-card { display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: center; padding: 14px 16px 14px 20px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.tf-text { font-weight: 600; font-size: 18px; line-height: 1.35; }
.tf-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--cream); }
.tf-seg button { border: 0; cursor: pointer; padding: 8px 16px; border-radius: 9px; background: transparent; font-weight: 700; font-size: 16px; color: var(--ink-2); min-width: 78px; }
.tf-seg button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.tf-seg button[aria-checked=true][data-v=true] { background: var(--mint-btn); color: #fff; box-shadow: 0 2px 0 var(--mint-edge); }
.tf-seg button[aria-checked=true][data-v=false] { background: var(--pip-btn); color: #fff; box-shadow: 0 2px 0 var(--pip-edge); }
.tf-why { grid-column: 1 / -1; font-size: 16px; color: var(--ink-2); }
.tf-why[hidden] { display: none; }
.tf-card.is-wrong { background: #FFFBEF; box-shadow: inset 0 0 0 2px var(--sun-edge); }
.tf-card.is-right { background: var(--mint-soft); box-shadow: none; }
@media (max-width: 600px) { .tf-card { grid-template-columns: 1fr; } }

/* sort bins: extra tones on top of .sb-pile (pip is the default) */
.sb-pile.tone-mint { --c: var(--mint-ink); --soft: var(--mint-soft); --ln: #A9E5CB; }
.sb-pile.tone-sky { --c: var(--sky-ink); --soft: var(--sky-soft); --ln: #BFDCFB; }
.sb-pile.tone-violet { --c: var(--violet-ink); --soft: var(--violet-soft); --ln: #D6D0FB; }
.sb-pile.tone-sun { --c: var(--sun-ink); --soft: var(--sun-soft); --ln: #F5DD95; }
.scene-slot:not(:empty) + .widget-slot .sb-pile { min-height: 110px; }

/* order steps */
.ord-end { font-weight: 600; font-size: 15px; color: var(--ink-3); margin: 0 0 6px 6px; }
.ord-list + .ord-end { margin: 6px 0 0 6px; }
.ord-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ord-item { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; position: relative; }
.ord-item.is-drag { z-index: 5; cursor: grabbing; box-shadow: inset 0 0 0 2px #2F86E8, 0 14px 28px -10px rgba(31,42,85,.35); }
.ord-n { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet-ink); font-family: var(--display); font-weight: 600; font-size: 17px; }
.ord-grip { width: 20px; height: 20px; color: #C9C5D3; flex: none; }
.ord-label { flex: 1; font-weight: 600; font-size: 18px; line-height: 1.3; }
.ord-btns { display: flex; gap: 4px; }
.ord-b { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--cream); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.ord-b svg { width: 20px; height: 20px; }
.ord-b:hover { background: var(--cream-2); color: var(--ink); }
.ord-b:disabled { opacity: .35; cursor: default; }
.ord-b:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.ord-item.is-wrong { background: #FFFBEF; box-shadow: inset 0 0 0 2.5px var(--sun-edge), 0 3px 0 var(--sun-ink); }
.ord-list.is-right .ord-item { background: var(--mint-soft); box-shadow: inset 0 0 0 1.5px #A9E5CB; }
.ord-list.is-right .ord-n { background: var(--mint-btn); color: #fff; }

/* match pairs */
.mp { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 40px; }
.mp-col { display: grid; gap: 10px; align-content: start; }
.mp-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; border: 0; cursor: pointer; padding: 12px 16px; border-radius: 14px; background: #fff; text-align: left; font-weight: 600; font-size: 18px; line-height: 1.3; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); transition: background .15s ease, box-shadow .15s ease; }
.mp-card:hover { background: var(--cream); }
.mp-card:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.mp-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px var(--line-2); }
.mp-card.is-sel { background: var(--sky-soft); box-shadow: inset 0 0 0 2px #2F86E8, 0 3px 0 #1B62B5; }
.mp-card.is-paired { --t: var(--sky); --ts: var(--sky-soft); background: var(--ts); box-shadow: inset 0 0 0 2px var(--t), 0 3px 0 var(--t); }
.mp-card.is-paired .mp-dot { background: var(--t); box-shadow: none; }
.mp-card.tone-violet { --t: var(--violet); --ts: var(--violet-soft); }
.mp-card.tone-sun { --t: var(--sun); --ts: var(--sun-soft); }
.mp-card.tone-mint { --t: var(--mint); --ts: var(--mint-soft); }
.mp-card.tone-pip { --t: var(--pip); --ts: var(--pip-soft); }
.mp-card.is-wrong { background: #FFFBEF; box-shadow: inset 0 0 0 2.5px var(--sun-edge), 0 3px 0 var(--sun-ink); }
.mp.is-right .mp-card { background: var(--mint-soft); box-shadow: inset 0 0 0 1.5px #A9E5CB; }
.mp.is-right .mp-dot { background: var(--mint-btn); box-shadow: none; }

/* number input */
.num { max-width: 340px; }
.num-row { display: flex; align-items: center; gap: 12px; }
.num-unit { font-family: var(--display); font-weight: 600; font-size: 24px; color: var(--ink-2); }

/* slider scene */
.sl-box { display: grid; gap: 14px; padding: 18px 20px; border-radius: var(--r-l); background: #fff; box-shadow: 0 0 0 1.5px var(--line); }
.slider-row label { display: flex; justify-content: space-between; font-weight: 600; font-size: 17px; }
.slider-row output { font-family: var(--display); font-variant-numeric: tabular-nums; color: var(--violet-ink); }
.sl-box.is-locked { opacity: .7; }

/* scrubber: the shared .scrub style from friendly.css, placed under the scene */
.scrub-host .scrub { margin-top: 18px; }

/* tap hotspot */
.hs-pic { position: relative; }
.hs-pic img, .hs-pic svg { width: 100%; height: auto; display: block; }
.hs-spot { --r: 6%; position: absolute; width: calc(var(--r) * 2); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 0; cursor: pointer; background: rgba(77,163,255,.12); box-shadow: inset 0 0 0 2.5px rgba(47,134,232,.55); }
.hs-target { cursor: pointer; transition: box-shadow .15s ease, background .15s ease; }
.hs-target:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.hs-target.is-picked { box-shadow: inset 0 0 0 3px #2F86E8, 0 0 0 4px rgba(77,163,255,.18) !important; }
.hs-target.is-right { box-shadow: inset 0 0 0 3px var(--mint-btn), 0 0 0 4px rgba(61,214,163,.2) !important; }
.hs-target.is-wrong { box-shadow: inset 0 0 0 3px var(--sun-edge), 0 0 0 4px rgba(255,201,60,.22) !important; }
.hs-cta { margin-top: 12px; color: var(--ink-2); font-weight: 500; }

/* ---------- AI-1 scenes ---------- */
.ib-again { display: block; margin: 14px auto 0; font-size: 17px; }
.ib-again[hidden] { display: none; }

/* copy-your-rule board */
.lmain .cr-stage { padding: 18px; }
.cr-left { position: relative; }
.cr-new { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 2px var(--violet), 0 3px 0 var(--violet-ink); animation: rise .3s ease-out; }
.cr-new .tr-msg { background: transparent; padding: 0; font-size: 18px; font-weight: 600; }
.cr-new-tag { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--violet); color: #fff; font-weight: 700; font-size: 14px; }
.cr-piles { position: relative; border-radius: 18px; }
.cr-piles.is-set { outline: 2px dashed var(--violet); outline-offset: 6px; margin-top: 20px; }
.cr-set-tag { position: absolute; top: -20px; left: 10px; z-index: 2; }
.cr-tag { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--violet); color: #fff; font-family: var(--body); font-weight: 700; font-size: 13px; letter-spacing: 0; vertical-align: 3px; animation: rise .3s ease-out; }
.tr-pile[data-hotspot] { border-radius: 16px; padding: 8px; margin: -8px; }
.cr-stage .tr-pile ul { min-height: 40px; }
.tr-msg.cr-pizza { background: #fff !important; box-shadow: inset 0 0 0 2px var(--violet); font-weight: 600; }
.tr-msg.cr-added { box-shadow: inset 0 0 0 1.5px rgba(31,42,85,.14); }
.cr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-chip { padding: 4px 12px; border-radius: 999px; background: #FFD3BF; color: #8A2D0C; font-weight: 700; font-size: 16px; }
.cr-chip small { font-weight: 600; font-size: 13px; }
.cr-chip.is-off { background: #fff; color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 2px; }
.cr-chip.is-off small { text-decoration: none; display: inline-block; }
.cr-chip.is-flash { animation: ib-bump .6s ease 2; box-shadow: 0 0 0 3px var(--pip); }
.tr-side.is-model { box-shadow: inset 0 0 0 2px var(--violet); }

/* bad-label */
.lmain .bl-stage { padding: 18px; }
.bl-card { display: block; width: 100%; border: 0; text-align: left; font: inherit; font-size: 16px; font-weight: 500; line-height: 1.32; cursor: pointer; }
.tr-pile.o .bl-card { background: var(--mint-soft); }
.bl-card:hover { filter: brightness(.98); }
.bl-card.is-fixed { background: var(--mint-soft) !important; box-shadow: inset 0 0 0 2px var(--mint-btn) !important; }
.tr-pile.is-faded { opacity: .35; }

/* round 1 fixes: wider map, compact nodes */
.map-wrap { width: min(1380px, 100% - 32px); margin: 40px auto 0; }
.map { --label: 132px; }
.cnode { display: grid; grid-template-columns: 40px 1fr; gap: 4px 10px; align-items: start; }
.cnode-toy { width: 40px; height: 40px; }
.cnode-lock { width: 20px; height: 20px; right: -6px; bottom: -4px; }
.cnode-lock svg { width: 12px; height: 12px; }
.cnode-body b { font-size: 15px; }
.cnode-hint { grid-column: 1 / -1; margin-top: 4px; padding-top: 6px; border-top: 1.5px dashed var(--line-2); }
.band { min-height: 96px; padding: 12px; }
.band-title { font-size: 15px; }
.continue-art .pip { --size: 132px !important; }
.track-page .wrap { width: min(1380px, 100% - 32px); }
.band-head { padding-top: 0; padding-bottom: 0; }
.map-legend { margin-bottom: 4px; }
.learned.single { grid-template-columns: 1fr; max-width: 760px; margin-inline: auto; }
.learned:empty { display: none; }

/* ---------- player feedback: I don't know, See answer, Why?, XP ---------- */
.xp-pill { flex: none; min-width: 72px; padding: 6px 12px; border-radius: 999px; background: var(--sun-soft); color: var(--sun-ink); font-weight: 700; font-size: 15px; text-align: center; font-variant-numeric: tabular-nums; }
.xp-pill b { font-weight: 800; }
.xp-pill.bump { animation: xp-bump .45s ease-out; }
@keyframes xp-bump { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }
.xp-gain { display: inline-block; margin-left: 12px; padding: 3px 10px; border-radius: 999px; background: #fff; color: var(--mint-ink); font-family: var(--body); font-size: 15px; font-weight: 700; vertical-align: middle; }
.lfoot .btns .btn-sec { min-width: 150px; }
.why-dlg { width: min(560px, 100% - 32px); border: 0; padding: 26px 28px 22px; border-radius: var(--r-l, 20px); background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(30,20,60,.22); }
.why-dlg::backdrop { background: rgba(30,24,50,.32); }
.why-dlg[open] { animation: rise .22s ease-out; }
.why-dlg h2 { font-size: 24px; }
.why-body { margin-top: 10px; font-size: 18px; line-height: 1.5; }
.why-body p + p, .why-body ul + p { margin-top: 10px; }
.why-btns { margin-top: 20px; display: flex; justify-content: flex-end; }
.why-btns .btn { min-width: 140px; }
.done-xp { margin-top: 8px; color: var(--ink-2); font-size: 17px; }
.done-xp b { color: var(--sun-ink); }
@media (prefers-reduced-motion: reduce) { .xp-pill.bump, .why-dlg[open] { animation: none; } }
html.calm .xp-pill.bump, html.calm .why-dlg[open] { animation: none; }

/* ---------- course page: winding path with levels ---------- */
.cpath { position: relative; max-width: 960px; margin: 0 auto; --amp: 1; }
.plevel + .plevel { margin-top: 40px; }
.plevel-head {
  display: flex; align-items: center; gap: 16px; max-width: 560px; margin: 0 auto 18px; padding: 14px 20px 14px 14px;
  background: #fff; border-radius: var(--r-l); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2);
}
.plevel-n { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--soft); color: var(--c); font-family: var(--display); font-weight: 600; font-size: 22px; }
.plevel-n svg { width: 26px; height: 26px; }
.plevel.is-done .plevel-n { background: var(--mint-btn); }
.plevel-t { flex: 1; min-width: 0; }
.plevel-t small { display: block; font-weight: 600; font-size: 15px; color: var(--c); line-height: 1.2; }
.plevel-t h3 { font-size: 24px; line-height: 1.2; margin-top: 2px; }
.plevel-p { flex: none; width: 96px; text-align: right; }
.plevel-p small { font-weight: 700; font-size: 14px; color: var(--ink-3); }
.plevel-p .bar { width: 100%; margin-top: 4px; background: var(--cream-2); }
.plevel-path { position: relative; padding: 6px 0 4px; }
.ptrail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ptrail path { fill: none; stroke: var(--line-2); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 11; }
.ptrail path.on { stroke: #A9E5CB; stroke-dasharray: none; }

.pstep { position: relative; height: 104px; }
.pstep.is-practice { height: 84px; }
.pstep.is-check { height: 100px; }
.pbtn {
  position: absolute; top: 50%; display: flex; align-items: center; gap: 18px; padding: 0; border: 0; background: none; cursor: pointer;
  text-align: left; color: var(--ink); --r: 36px;
  left: calc(50% + var(--x) * var(--amp) - var(--r)); transform: translateY(-50%);
}
.side-left .pbtn { left: auto; right: calc(50% - var(--x) * var(--amp) - var(--r)); flex-direction: row-reverse; text-align: right; }
.pbtn:focus-visible { outline: none; }
.pbtn:focus-visible .pnode { outline: 3px solid var(--sky); outline-offset: 4px; }
.pnode {
  width: calc(var(--r) * 2); height: calc(var(--r) * 2); border-radius: 50%; flex: none; display: grid; place-items: center; position: relative; z-index: 1;
  font-family: var(--display); font-weight: 600; font-size: 24px; transition: transform .12s ease, box-shadow .12s ease;
}
.pnode svg { width: 30px; height: 30px; }
.pbtn:hover .pnode, .pstep.is-open .pnode { transform: translateY(-2px); }
.plabel { display: block; max-width: 290px; line-height: 1.25; }
.plabel b { display: block; font-weight: 600; font-size: 18px; }
.plabel small { display: block; font-weight: 500; font-size: 15px; color: var(--ink-3); margin-top: 3px; }
.plabel .bridge-hint { margin-top: 6px; }
.soon-tag { font-style: normal; display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--cream-2); color: var(--ink-2); font-weight: 600; font-size: 13.5px; }

/* lesson states */
.st-done .pnode { background: var(--mint-btn); color: #fff; box-shadow: 0 4px 0 var(--mint-edge); }
.st-ready .pnode { background: #fff; color: var(--c); box-shadow: inset 0 0 0 3px var(--bar), 0 4px 0 var(--c); }
.st-ready .plabel small { color: var(--c); font-weight: 600; }
.is-lesson.st-current .pbtn { --r: 44px; }
.st-current .pnode { background: var(--pip-btn); color: #fff; font-size: 30px; box-shadow: 0 4px 0 var(--pip-edge), 0 0 0 10px rgba(255,107,61,.14); }
.st-current .plabel b { font-family: var(--display); font-size: 24px; }
.st-current .plabel { max-width: 360px; }
.st-current .plabel small { color: var(--pip-edge); font-weight: 600; }
.st-locked .pnode { background: #fff; color: #A8A4B4; box-shadow: inset 0 0 0 1.5px var(--line-2), 0 3px 0 var(--line-2); }
.st-locked .plabel b { color: var(--ink-2); }
.is-lesson.st-soon .pnode { background: #FBFAF7; color: #A8A4B4; box-shadow: inset 0 0 0 2px var(--line-2); }
.is-lesson.st-soon .plabel b { color: var(--ink-2); }
.is-signature .pnode .pstar { position: absolute; right: -6px; top: -6px; width: 26px; height: 26px; border-radius: 50%; background: var(--sun); color: #fff; display: grid; place-items: center; box-shadow: 0 2px 0 var(--sun-edge); }
.is-signature .pnode .pstar svg { width: 16px; height: 16px; }

/* practice and level check placeholders */
.is-practice .pbtn { --r: 27px; }
.is-practice .pnode { background: #fff; color: #ACA6B8; border: 2.5px dashed #D3CCC0; }
.is-practice .pnode svg { width: 26px; height: 26px; }
.is-practice .plabel b, .is-check .plabel b { font-size: 16px; color: var(--ink-2); }
.is-check .pbtn { --r: 33px; }
.is-check .pnode { border-radius: 22px; background: #fff; color: #ACA6B8; border: 2.5px dashed #D3CCC0; }
.is-check .pnode svg { width: 28px; height: 28px; }

/* practice layer (prac): playable and finished practice, check and warm-up nodes */
.pstep.is-warmup { height: 84px; }
.is-warmup .pbtn { --r: 27px; }
.is-warmup .pnode { background: #fff; color: #ACA6B8; border: 2.5px dashed #D3CCC0; }
.is-warmup .pnode svg { width: 26px; height: 26px; }
.is-warmup .plabel b { font-size: 16px; color: var(--ink-2); }
.is-practice.st-ready .pnode, .is-check.st-ready .pnode, .is-warmup.st-ready .pnode { border: 0; background: #fff; color: var(--c); box-shadow: inset 0 0 0 3px var(--bar), 0 4px 0 var(--c); }
.is-practice.st-done .pnode, .is-check.st-done .pnode, .is-warmup.st-done .pnode { border: 0; background: var(--mint-btn); color: #fff; box-shadow: 0 4px 0 var(--mint-edge); }
.is-practice.st-ready .plabel b, .is-check.st-ready .plabel b, .is-warmup.st-ready .plabel b,
.is-practice.st-done .plabel b, .is-check.st-done .plabel b { color: var(--ink); }
.pcard .prac-skip { margin-top: 8px; }
.prac-end { text-align: center; padding-top: 28px; }
.prac-end .pip { --size: 120px; margin: 0 auto 6px; }
.prac-end h1 { font-size: clamp(36px, 4vw, 50px); }
.prac-end .lead { margin: 12px auto 0; }
.prac-score { margin: 26px auto 6px; }
.prac-score p { margin-top: 10px; font-size: 18px; color: var(--ink-2); }
.prac-score b { color: var(--ink); }
.prac-dots { display: flex; justify-content: center; gap: 10px; }
.prac-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--cream-2); box-shadow: inset 0 0 0 2px var(--line-2); }
.prac-dots i.on { background: var(--mint-btn); box-shadow: 0 3px 0 var(--mint-edge); }
.prac-end .actions { align-items: center; gap: 18px; margin-top: 26px; }

/* the small card under a node */
.pcard {
  position: absolute; z-index: 5; width: 300px; padding: 18px 20px 20px; border-radius: var(--r-l); background: #fff; color: var(--ink);
  box-shadow: 0 14px 40px rgba(30,20,60,.16), inset 0 0 0 1.5px var(--line); animation: pcard-in .18s ease-out;
}
.pcard::before { content: ""; position: absolute; top: -8px; left: calc(var(--tip, 50%) - 8px); width: 16px; height: 16px; background: #fff; transform: rotate(45deg); border-radius: 3px; box-shadow: -1.5px -1.5px 0 var(--line); }
.pcard small { display: block; font-weight: 600; font-size: 14px; color: var(--c); }
.pcard h4 { font-size: 21px; line-height: 1.2; margin-top: 2px; outline: none; }
.pcard p { margin: 6px 0 14px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.pcard .btn { width: 100%; }
.pcard.is-practice small, .pcard.is-check small { color: var(--ink-3); }
@keyframes pcard-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pcard { animation: none; } .pnode { transition: none; } .pbtn:hover .pnode, .pstep.is-open .pnode { transform: none; } }
html.calm .pcard { animation: none; }

@media (max-width: 700px) {
  .cpath { --amp: .3; }
  .pbtn, .side-left .pbtn { left: calc(28% + var(--x) * var(--amp) - var(--r)); right: auto; flex-direction: row; text-align: left; }
  .plabel { max-width: 200px; }
  .plabel b { font-size: 16px; }
  .st-current .plabel b { font-size: 19px; }
  .is-lesson.st-current .pbtn { --r: 38px; }
  .plevel-head { padding: 12px 14px 12px 12px; }
  .plevel-t h3 { font-size: 20px; }
  .plevel-p { width: 64px; }
}

/* grade labels on course cards */
.grade-tag { font-style: normal; display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--soft, var(--cream-2)); color: var(--c, var(--ink-2)); font-weight: 600; font-size: 12.5px; line-height: 1.5; white-space: nowrap; }
.ccard .lvl { display: flex; align-items: center; gap: 8px; }
.cnode-body .grade-tag { align-self: flex-start; margin-top: 5px; font-size: 12px; }
.band-head span small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-3); }
/* plr2: XP on home and profile */
.bit-xp { background: #FFFBEF; box-shadow: inset 0 0 0 1.5px #F6E7B8; }
.prof-stats { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .prof-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .prof-stats { grid-template-columns: 1fr; } }
/* plr2: compact number keypad, two rows beside the field, used when a tall scene leaves no room for the full one */
.num.compact { max-width: 760px; display: grid; grid-template-columns: minmax(200px, 280px) 1fr; column-gap: 18px; align-items: end; }
.num.compact .answer-label { grid-column: 1 / -1; }
.num.compact .keypad { margin-top: 0; gap: 8px; }
.num.compact .key { height: 48px; font-size: 22px; }
.num.compact .answer { height: 104px; }
@media (max-width: 640px) {
  .num.compact { grid-template-columns: 1fr; row-gap: 10px; }
  .num.compact .answer { height: 60px; font-size: 30px; }
  .num.compact .key { height: 44px; font-size: 20px; }
}

/* ---------- lesson player: fit the step above the footer (see fit() in js/player.js) ---------- */
.lmain .stage svg { max-height: var(--svg-max, 34vh); min-height: min(200px, var(--svg-max, 200px)); }
.lmain .stage svg svg { max-height: none; min-height: 0; }
@media (max-height: 1080px) and (min-width: 641px) {
  .lbar { height: 60px; }
  .lmain { padding-top: 0; }
  .lmain h1 { font-size: clamp(26px, 2.3vw, 32px); margin-top: 2px; }
  .lmain .q-sub { margin-top: 4px; font-size: 18px; }
  .lmain .stage, .scene-slot .stage, .widget-slot > :first-child { margin-top: 14px; }
  .lmain .choices { margin-top: 14px; }
  .lfoot-in { min-height: 88px; padding: 12px 0; }
}
@media (max-height: 820px) and (min-width: 641px) {
  .lbar { height: 52px; }
  .lmain .kicker { font-size: 15px; }
  .lmain h1 { font-size: clamp(24px, 2vw, 28px); }
  .lmain .q-sub { font-size: 17px; }
  .lfoot-in { min-height: 76px; padding: 10px 0; }
  .lfoot .fb .pip { --size: 72px; margin: -18px -4px -8px -8px; }
  .lfoot .fb h3 { font-size: 22px; }
  .lfoot .fb p { font-size: 16px; }
}
/* is-fit: the step did not fit at full size; dense rows for the shared code machines (cs-1, cs-2 kits) */
.lmain.is-fit .cmx-prog { gap: 3px; min-height: 0; padding: 6px; }
.lmain.is-fit .cmx-row { min-height: 34px; }
.lmain.is-fit .cmx-tile { padding-top: 3px; padding-bottom: 3px; min-height: 30px; }
.lmain.is-fit .cmx-ptray { gap: 5px; padding: 8px; }
.lmain.is-fit .cmx-tray { min-height: 0; }
.lmain.is-fit .cm-boxes { min-height: 56px; padding: 10px 14px; }
