/* Academias Edison — app shell, shared components and the lesson player. Tokens: static/css/tokens.css (loaded first).
   Mobile first where it matters (player, tutor, intake). */

/* ======================================================================
   Base
   ====================================================================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; }
body { min-height: 100vh; min-height: 100dvh; background: var(--paper); color: var(--ink); font: var(--fs-base)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: var(--lh-tight); margin: 0 0 .5em; letter-spacing: var(--track-tight); text-wrap: balance; }
h1 { font-size: var(--fs-h1); font-weight: 800; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-lg); letter-spacing: -.015em; }
p { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
img, svg { display: block; }
svg { flex: none; }
::selection { background: rgba(255, 90, 31, .22); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--r-xs); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow); font-weight: 700; }
.skip-link:focus { top: 8px; }

/* ======================================================================
   Top bar
   ====================================================================== */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) max(20px, var(--safe-r)) 0 max(20px, var(--safe-l));
  background: rgba(250, 247, 242, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.02em;
  min-height: var(--tap); border-radius: var(--r-xs); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .brand-long { color: var(--dim); font-weight: 600; }
.brand strong { font-weight: 700; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.topnav { display: flex; align-items: center; gap: var(--s4); }
.topnav > a:not(.btn) { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--ink-2); font-weight: 600; padding: 0 4px; border-radius: var(--r-xs); }
.topnav > a:not(.btn):hover { color: var(--ink); text-decoration: none; }
.nav-toggle { display: none; width: var(--tap); height: var(--tap); border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.nav-toggle span { display: block; width: 20px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform var(--dur), opacity var(--dur); }
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); border: 1px solid; white-space: nowrap; letter-spacing: .01em; }
.badge-demo { color: var(--amber-ink); border-color: var(--amber-line); background: var(--amber-soft); }
.badge-live { color: var(--ok-ink); border-color: var(--ok-line); background: var(--ok-soft); }

/* ======================================================================
   Buttons, chips, tags
   ====================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 18px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 700; font-size: 15px; line-height: 1.2; text-align: center; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast), color var(--dur-fast); }
.btn:hover { border-color: var(--ink); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); box-shadow: 0 8px 24px -10px rgba(28, 26, 23, .5); }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); box-shadow: var(--shadow-accent); }
.btn-accent:hover { background: #F04E14; border-color: #F04E14; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--paper-2); border-color: transparent; }
.btn-sm { min-height: var(--tap); padding: 7px 14px; font-size: 14px; }
.btn-lg { min-height: 54px; padding: 14px 26px; font-size: 16px; }
.btn-icon { width: var(--tap); height: var(--tap); min-height: 0; padding: 0; border-radius: 50%; }
.btn .ico, .btn-icon svg { width: 20px; height: 20px; }
.btn-block { width: 100%; min-height: 50px; font-size: 16px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 700; cursor: pointer; min-height: var(--tap); }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { display: inline-flex; align-items: center; min-height: 28px; font-size: var(--fs-xs); font-weight: 700; padding: 3px 11px; border-radius: var(--r-pill); background: var(--paper-2); border: 1px solid transparent; color: var(--ink-2); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-pill); vertical-align: middle; }
.tag-full, .tag-ready { background: var(--ok-soft); color: var(--ok-ink); }
.tag-outline { background: var(--paper-2); color: var(--ink-2); }
.tag-running { background: var(--info-soft); color: var(--info); }
.tag-queued { background: var(--amber-soft); color: var(--amber-ink); }
.tag-pending { background: var(--paper-2); color: var(--ink-2); }
.tag-error { background: var(--danger-soft); color: var(--danger-ink); }
.tag-progress { background: var(--paper-2); color: var(--ink-2); }

/* ======================================================================
   Page, cards, notices
   ====================================================================== */
.page { max-width: var(--max); margin: 0 auto; padding: var(--s6) max(20px, var(--safe-r)) 88px max(20px, var(--safe-l)); }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); min-width: 0; }
.card h3 { font-size: 17px; }
.card p { color: var(--ink-2); margin: 0 0 12px; }
.state-card { max-width: 640px; margin: 60px auto; text-align: center; padding: 36px 28px; }
.state-card h2 { font-size: var(--fs-xl); }
/* /creditos: the narration voices' attributions */
.credits-card { max-width: 720px; margin: 0 auto; }
.credits-card h2 { font-size: var(--fs-md); margin: 18px 0 8px; }
.credits-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
.notice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--amber-line); background: var(--amber-soft); color: var(--amber-ink); padding: 12px 16px; border-radius: var(--r); margin: 16px 0; font-size: var(--fs-sm); line-height: 1.5; }
.notice b { color: inherit; }
.notice::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 3l9.5 17h-19z' fill='none' stroke='%238A5A0A' stroke-width='2' stroke-linejoin='round'/><path d='M12 10v4.5M12 17.5v.5' stroke='%238A5A0A' stroke-width='2.2' stroke-linecap='round'/></svg>") center / contain no-repeat; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* ======================================================================
   Forms
   ====================================================================== */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14.5px; }
.field input { width: 100%; min-height: 50px; padding: 10px 16px; font-size: 16px; border: 1.5px solid var(--line-2); border-radius: 14px; background: var(--card); color: var(--ink); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.field input:hover { border-color: var(--line-3); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--danger); background: #FFFBFA; }
.field-hint { display: block; color: var(--dim); font-size: 13px; margin-top: 5px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 98px; }
.pw-toggle { position: absolute; right: 5px; top: 5px; bottom: 5px; min-width: 80px; border: 0; border-radius: var(--r-pill); background: var(--paper-2); color: var(--ink-2); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.pw-toggle:hover { background: var(--line); color: var(--ink); }
.form-error { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger-ink); padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 15px; font-weight: 600; }

/* ======================================================================
   Intake chat (guided builder lives in intake.css)
   ====================================================================== */
.page-chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.page-chat .topbar { flex: none; }
.chat-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-col { max-width: 780px; margin: 0 auto; padding: 28px max(20px, var(--safe-r)) 24px max(20px, var(--safe-l)); }
.msg { display: flex; gap: 14px; margin-bottom: 22px; animation: fadeUp var(--dur) var(--ease); }
.msg .avatar { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.msg.assistant .avatar { background: var(--accent); color: var(--on-ink); }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line); }
.msg .bubble { max-width: 85%; min-width: 0; overflow-wrap: anywhere; }
.msg.assistant .bubble { flex: 1; max-width: none; padding-top: 5px; }
.msg .bubble p { margin: 0 0 .7em; } .msg .bubble p:last-child { margin-bottom: 0; }
.msg.user .bubble { background: var(--paper-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 16px 16px 5px 16px; font-weight: 600; }
.msg-error .avatar { background: var(--danger-soft) !important; color: var(--danger) !important; border: 1px solid var(--danger-line); }
.msg-error .bubble { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger-ink); padding: 10px 14px; border-radius: var(--r-sm); }
.msg-error .btn { margin-top: 8px; }
.done-card .btn { margin-top: 10px; }
.done-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.done-card .done-actions .btn { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 14px; }
.pcard { text-align: left; min-height: var(--tap); padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card); cursor: pointer; box-shadow: 0 1px 2px rgba(28, 26, 23, .04);
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast); }
.pcard:hover { border-color: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pcard:active { transform: none; }
.pcard.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pcard b { display: block; font-size: 15px; margin-bottom: 2px; color: var(--ink); }
.pcard span { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.45; }
.cards.proposals { grid-template-columns: 1fr; }
.cards.proposals .pcard { padding: 16px 18px; }
.cards.proposals .pcard b { font-size: 16px; }
.cards[aria-disabled="true"] .pcard { pointer-events: none; opacity: .6; box-shadow: none; }
.composer-wrap { flex: none; padding: 10px max(16px, var(--safe-r)) max(14px, var(--safe-b)) max(16px, var(--safe-l)); background: linear-gradient(rgba(250, 247, 242, 0), var(--paper) 30%); }
.composer { max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--card); border: 1.5px solid var(--line-2); border-radius: 26px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow), var(--focus); }
.composer textarea { flex: 1; min-width: 0; min-height: var(--tap); background: transparent; border: 0; color: var(--ink); font-size: 16px; line-height: 1.45; resize: none; outline: none; padding: 10px 0; max-height: 160px; }
.composer textarea::placeholder { color: var(--dim); }
.composer textarea:disabled { opacity: .6; }
.composer .btn-icon { width: var(--tap); height: var(--tap); border-radius: 50%; background: var(--accent); border-color: var(--accent); box-shadow: var(--shadow-accent); }
.composer .btn-icon:hover { background: #F04E14; border-color: #F04E14; }
.composer-hint { max-width: 780px; margin: 8px auto 0; font-size: var(--fs-xs); color: var(--dim); text-align: center; }

/* ======================================================================
   Course page header (the map itself lives in game.css)
   ====================================================================== */

/* ======================================================================
   Player
   ====================================================================== */
/* The player fills exactly the visible height under the top bar (no page scroll): svh/dvh with a vh fallback. The first
   screen (title + stage + subtitles + controls) always fits; the panels below scroll inside .player-main. */
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - var(--topbar-h) - var(--safe-t)); height: calc(100svh - var(--topbar-h) - var(--safe-t)); height: calc(100dvh - var(--topbar-h) - var(--safe-t)); }
.player-layout.tutor-closed { grid-template-columns: minmax(0, 1fr) 0; }
.player-layout.tutor-closed .tutor { display: none; }
.player-main { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 12px 24px 32px; min-width: 0; min-height: 0; }
.player-title { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: 10px; }
.player-heading { min-width: 0; }
.player-heading .eyebrow::after { content: ""; position: absolute; inset: -12px 0; }
.timeline::before { content: ""; position: absolute; inset: -6px 0; }
.player-heading .eyebrow { position: relative; display: inline-block; font-size: 13px; font-weight: 700; color: var(--accent-ink); margin-bottom: 2px; }
.player-title h1 { font-size: 20px; margin: 0; font-weight: 700; }
.player-title small { color: var(--dim); display: block; margin-top: 4px; font-size: 13px; font-weight: 600; }
/* Short desktop windows (laptops): narration info and the course bar share one line, so the stage gets the room. */
@media (min-width: 1101px) and (max-height: 820px) {
  .player-heading { display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; }
  .player-heading .eyebrow, .player-title h1 { flex-basis: 100%; }
  .player-title h1 { font-size: 18px; }
  .player-title small { margin-top: 2px; }
  .player-heading .course-bar { margin-top: 2px; width: min(360px, 40%); }
}
.tutor-toggle { flex: none; }
.tutor-toggle[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
/* While the side panel is open its own header shows Edi and its close button: the opener would only repeat them.
   visibility (not display) keeps its room, so the title never shifts when the panel opens or closes. */
.tutor-toggle[aria-expanded="true"] { visibility: hidden; }

.stage-wrap { position: relative; background: var(--card); border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); --ctl-h: 92px; }
/* The stage shrinks (16:9 kept) so subtitles and controls stay on screen. --stage-max-h is the height left for the
   stage, measured by the player (bindFit in static/js/player/player.js); the CSS default is a rough estimate. */
.stage-wrap:not(.immersive) { width: min(100%, max(480px, calc(var(--stage-max-h, calc(100vh - 300px)) * 16 / 9 + 2px))); margin-inline: auto; }
.stage-box { position: relative; container-type: inline-size; container-name: stage; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: radial-gradient(ellipse at 30% 20%, #FFFDF9, var(--paper-2) 55%, var(--paper-3) 100%); }
.scene-root { position: absolute; inset: 0; }
/* Each scene mounts in its own layer, so the outgoing one can fade over the incoming one (static/js/player/transitions.js). */
.scene-layer { position: absolute; inset: 0; }
.scene-layer.scene-leaving { z-index: 3; pointer-events: none; opacity: 1; transition: opacity var(--fade-ms, 350ms) ease; }
.scene-layer.scene-leaving.go { opacity: 0; }
.scene-layer.scene-entering { opacity: 0; transition: opacity var(--fade-ms, 375ms) ease var(--fade-delay, 0ms); }
.scene-layer.scene-entering.go { opacity: 1; }
.stage:has(.scene-leaving.fade-through) { background: var(--ink); }
.chapter-card { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.98); z-index: 6; pointer-events: none;
  max-width: 86%; padding: 12px 22px; border-radius: 14px; background: rgba(28, 26, 23, .82); color: var(--on-ink); text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(15px, 2.6vw, 24px); line-height: 1.25; letter-spacing: -.01em; box-shadow: 0 10px 30px rgba(28, 26, 23, .25);
  opacity: 0; transition: opacity .35s ease, transform .35s ease; }
.chapter-card.in { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.chapter-card.in.out { opacity: 0; }
.chapter-card.still, .chapter-card.still.in { transition: none; transform: translate(-50%, -50%); }
@media (prefers-reduced-motion: reduce) {
  .scene-layer.scene-leaving, .scene-layer.scene-entering, .chapter-card { transition: none; }
}

/* subtitles: overlay on the stage (desktop, tablet, immersive); a band under the stage on phones in portrait */
.subtitles { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; max-width: min(88%, 900px); text-align: center; pointer-events: none; z-index: 30; }
.subtitles span { display: inline; background: rgba(28, 26, 23, .84); color: var(--on-ink); font-size: clamp(15px, 1.9cqw, 20px); font-weight: 600; line-height: 1.55; padding: 4px 11px; border-radius: 8px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.subtitles.off { display: none; }
.interactive-scene .subtitles { bottom: 6px; max-width: 72%; }
.interactive-scene .subtitles span { font-size: 13.5px; }

.big-play { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); background: rgba(250, 247, 242, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); z-index: 40; cursor: pointer; padding: var(--s4); text-align: center; }
.big-play button { display: grid; place-items: center; width: clamp(64px, 11cqw, 88px); height: clamp(64px, 11cqw, 88px); border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); cursor: pointer;
  box-shadow: 0 0 0 10px rgba(28, 26, 23, .08), 0 14px 34px -10px rgba(28, 26, 23, .6); transition: transform var(--dur-fast), background var(--dur-fast); }
.big-play button svg { width: 44%; height: 44%; margin-left: 6%; }
.big-play:hover button { transform: scale(1.05); background: var(--accent); box-shadow: 0 0 0 10px var(--accent-tint), 0 14px 34px -10px var(--accent-glow); }
.big-play p { margin: 0; color: var(--ink); font-weight: 700; font-size: 15px; background: rgba(255, 255, 255, .85); padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--line); }
.wait-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 35; background: var(--amber); color: #3B2600; box-shadow: var(--shadow-sm); font-weight: 700; font-size: var(--fs-sm); padding: 6px 14px; border-radius: var(--r-pill); max-width: calc(100% - 24px); text-align: center; }
.scene-badge { position: absolute; top: 12px; left: 12px; z-index: 31; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 5px 10px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.scene-badge:empty { display: none; }
/* narrow stages: the wait banner keeps clear of Edi's top corner on his side only (not on both), so it wraps less */
@container stage (max-width: 480px) {
  .stage-wrap.edi-on .stage .wait-banner { left: 10px; right: auto; transform: none; max-width: calc(100% - 28px - var(--edi-size) * .72); }
  .stage-wrap.edi-on[data-edi-side="left"] .stage .wait-banner { left: auto; right: 10px; }
}

/* controls: scrubber row + button row */
.controls { position: relative; z-index: 45; padding: 2px 10px 6px; background: var(--card); border-top: 1px solid var(--line); transition: opacity .25s; }
.timeline-row { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.time { font: 700 12.5px var(--font); color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline { position: relative; flex: 1; margin: 0 8px; height: 32px; cursor: pointer; display: flex; align-items: center; touch-action: none; border-radius: 6px; }
.timeline:focus-visible { outline-offset: 0; }
.timeline .track { position: relative; width: 100%; height: 6px; background: var(--paper-2); border-radius: 4px; transition: height .12s; }
.timeline:hover .track, .timeline.dragging .track { height: 8px; }
.timeline .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.timeline .knob { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(28, 26, 23, .2); pointer-events: none; transition: transform .12s; }
.timeline.dragging .knob { transform: scale(1.3); }
.timeline .chap-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--card); }
.timeline .cp-mark { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; transform: rotate(45deg); background: var(--amber); border: 1px solid #fff; pointer-events: none; }
.timeline .cp-mark.done { background: var(--ok); }
.timeline .hover-tip { position: absolute; bottom: 34px; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 4px 9px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; pointer-events: none; z-index: 5; }
.buttons-row { display: flex; align-items: center; gap: 2px; }
.ctl { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast); }
.ctl svg { width: 22px; height: 22px; }
.ctl:hover { background: var(--paper-2); color: var(--ink); }
.ctl:active { background: var(--line); }
.ctl.on { color: var(--accent-ink); background: var(--accent-soft); }
.ctl-play { color: var(--on-ink); background: var(--ink); border-radius: 50%; margin-right: 4px; }
.ctl-play:hover { background: #000; color: var(--on-ink); }
.ctl-play svg { width: 24px; height: 24px; }
.ctl-tutor { display: none; }
.now-title { flex: 1; min-width: 0; padding: 0 10px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* popovers (settings, chapters): above the controls on large screens; bottom sheets on phones */
.popover { position: absolute; right: 12px; bottom: calc(var(--ctl-h) + 8px); z-index: 60; width: 340px; max-width: calc(100% - 24px); max-height: calc(100% - var(--ctl-h) - 20px); overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 16px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: 14px; animation: fadeUp .15s ease; }
.chapter-sheet { width: 400px; }
/* A popover taller than its room scrolls: its title and close button stay at the top (sticky) and a shadow at the bottom
   edge says that more is below (the "local" covers hide each shadow at the matching end; nothing shows when it fits). */
.popover { background: linear-gradient(rgba(255, 255, 255, 0), var(--card) 70%) center bottom / 100% 40px no-repeat local,
  radial-gradient(farthest-side at 50% 100%, rgba(28, 26, 23, .24), rgba(28, 26, 23, 0)) center bottom / 100% 16px no-repeat scroll, var(--card); }
.popover > .sheet-head { position: sticky; top: 0; z-index: 2; background: var(--card); box-shadow: 0 -14px 0 var(--card); }   /* the shadow hides what scrolls through the padding above it */
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 8px 0; }
.sheet-head b { font-family: var(--font-display); font-size: 15px; }
.sheet-head .ctl { width: var(--tap); height: var(--tap); }
.settings-menu .field-label { display: block; font-weight: 700; margin: 6px 0 6px; color: var(--ink); }
.settings-menu select { width: 100%; min-height: 42px; padding: 6px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r-sm); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.settings-row .field-label { margin: 0; }
.settings-row select { width: auto; min-width: 110px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; min-height: var(--tap); cursor: pointer; font-weight: 600; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.settings-menu .hint { margin: 8px 0 0; color: var(--dim); font-size: 12.5px; }
.settings-menu .credits, .voice-credits { margin: 8px 0 0; color: var(--dim); font-size: 12px; line-height: 1.45; }
.voice-credits { margin-top: 14px; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 1090; background: rgba(28, 26, 23, .4); display: none; }

/* chapters (panel below the player and chapter sheet) */
.below-player { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; margin-top: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.panel-title { font-family: var(--font); font-size: 12.5px; color: var(--dim); text-transform: uppercase; letter-spacing: var(--track-caps); font-weight: 800; margin-bottom: 10px; }
.chapters { list-style: none; margin: 0; padding: 0; }
.chapters > li { border-radius: var(--r-sm); margin-bottom: 4px; }
.chapters > li.active { background: var(--accent-soft); }
.chapters button { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: var(--tap); padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); text-align: left; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.chapters button:hover { background: rgba(28, 26, 23, .05); }
.chapters > li.active .chapter-head { background: transparent; }
.chapters .chapter-head b { color: var(--ink); font-weight: 700; }
.chapters .t { font: 700 12px var(--font); color: var(--dim); min-width: 42px; font-variant-numeric: tabular-nums; }
.chapters ol { list-style: none; margin: 0 0 4px; padding: 0; }
.chapters .chapter-scene { min-height: var(--tap); padding: 6px 10px; font-size: 14px; font-weight: 500; }
.chapters .chapter-scene .t { visibility: hidden; }
.chapters .chapter-scene.current { color: var(--accent-ink); font-weight: 700; }
.chapters .chapter-scene.current .t { visibility: visible; color: var(--accent-ink); }
.objectives { margin: 0; padding-left: 0; list-style: none; color: var(--ink-2); }
.objectives li { position: relative; margin-bottom: 6px; padding-left: 26px; }
.objectives li::before { content: ""; position: absolute; left: 0; top: .3em; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-soft) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 12.5l4 4 8-9' fill='none' stroke='%23C2410C' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 12px no-repeat; }
.sources { font-size: 14px; color: var(--ink-2); }
.sources b { color: var(--ink); font-weight: 700; }

/* ---------- tutor (Edi's side panel) ---------- */
.tutor { border-left: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.tutor-head { padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.tutor-head .avatar { flex: none; width: 36px; height: 36px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; color: var(--on-ink); font-weight: 800; }
.tutor-head-text { flex: 1; min-width: 0; }
.tutor-head b { display: block; font-family: var(--font-display); font-size: 15px; letter-spacing: -.01em; }
.tutor-head small { color: var(--dim); font-size: 12.5px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tutor-ctx { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 10px 14px 0; padding: 7px 12px; border-radius: var(--r-sm); border: 1px dashed var(--line-2); background: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tutor-ctx::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: ctxBlink 1.6s ease-in-out infinite; }
@keyframes ctxBlink { 50% { opacity: .35; } }
.tutor-ctx b { color: var(--ink); font-weight: 800; }
.tutor-msgs { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; -webkit-overflow-scrolling: touch; position: relative; overflow-anchor: none; }
.tmsg { margin-bottom: 14px; font-size: 14.5px; animation: fadeUp .2s; overflow-wrap: anywhere; }
.tmsg.user { text-align: right; }
.tmsg.user .b { display: inline-block; text-align: left; background: var(--paper-2); padding: 9px 13px; border-radius: 16px 16px 5px 16px; max-width: 92%; font-weight: 600; }
.tmsg.assistant { display: flex; gap: 8px; align-items: flex-start; }
.tmsg.assistant .edi-avatar { width: 30px; height: 30px; margin-top: 2px; }
.tmsg-body { flex: 1; min-width: 0; }
.tmsg-body .who { font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 3px; }
.tmsg.assistant .b { background: var(--accent-soft); color: #3F1F0E; border-radius: 5px 16px 16px 16px; padding: 9px 13px; line-height: 1.5; }
.tmsg .b p { margin: 0 0 .6em; } .tmsg .b p:last-child { margin: 0; }
.tmsg .b code { font-family: var(--mono); font-size: .9em; background: rgba(255, 255, 255, .7); border: 1px solid var(--accent-soft-2); padding: 1px 5px; border-radius: 4px; }
.tmsg .b ul { margin: .3em 0 .6em; padding-left: 18px; }
.tutor-suggest { display: flex; gap: 6px; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none; flex-wrap: wrap; }
.tutor-suggest::-webkit-scrollbar { display: none; }
/* chips in one row that scrolls sideways: the side that hides more fades out (tutor.js chipEdges) */
.tutor-suggest:is(.more-l, .more-r) { -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--chip-fl, 0px), #000 calc(100% - var(--chip-fr, 0px)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--chip-fl, 0px), #000 calc(100% - var(--chip-fr, 0px)), transparent); }
.tutor-suggest.more-l { --chip-fl: 44px; }
.tutor-suggest.more-r { --chip-fr: 44px; }
.tutor-suggest button { flex: none; max-width: 100%; min-height: var(--tap); font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); cursor: pointer; transition: border-color var(--dur-fast), color var(--dur-fast); }
.tutor-suggest button:hover { border-color: var(--ink); color: var(--ink); }
.tutor .composer { margin: 0 12px 14px; box-shadow: none; border-radius: 22px; }
.tutor .composer textarea { max-height: 120px; }
.tutor-fab { display: none; }
.tutor-new { flex: none; font-size: 12.5px; padding: 4px 11px; min-height: var(--tap); }
.tutor-new .tn-short { display: none; }
@media (max-width: 480px) { .tutor-new .tn-long { display: none; } .tutor-new .tn-short { display: inline; } }
.tutor-welcome { display: flex; gap: 12px; align-items: flex-start; padding: 6px 2px 4px; color: var(--ink-2); font-size: 14.5px; }
.tutor-welcome .edi-avatar { width: 52px; height: 52px; }
.tutor-welcome p { margin: 0 0 .45em; }
.tutor-welcome .tw-hi { color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 15.5px; }
.tutor-welcome .tw-note { font-size: 13px; color: var(--dim); }
.texchange { margin-bottom: 18px; }
.texchange + .texchange { padding-top: 14px; border-top: 1px dashed var(--line); }
.tutor-notice { font-size: 13px; color: var(--amber-ink); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 12px; }
.tutor.has-chat .tutor-suggest { flex-wrap: nowrap; }
.tutor-signup { padding: 14px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid var(--accent-soft-2); font-size: 14.5px; margin: 6px 0 12px; }
.tutor-signup p { margin: 0 0 6px; color: var(--ink-2); }
.tutor-signup p:first-child { color: var(--ink); }
.tutor-signup-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Edi (brand mark, avatars) ---------- */
.edi-avatar { display: grid; place-items: center; border-radius: 12px; background: var(--ink); overflow: hidden; flex: none; }
.edi-avatar img { display: block; width: 100%; height: 100%; }
.msg.assistant .avatar.edi-avatar { border-radius: 11px; }
.tutor-head .avatar.edi-avatar { width: 38px; height: 38px; }
.tutor-head .avatar.edi-avatar img { width: 100%; height: 100%; }
.edi-ico { width: 20px; height: 20px; border-radius: 5px; }
.edi-glow { animation: ediGlow 3.2s ease-in-out infinite; }
@keyframes ediGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 31, 0); } 50% { box-shadow: 0 0 0 4px rgba(255, 90, 31, .22), 0 0 16px 2px rgba(255, 90, 31, .28); } }
@media (prefers-reduced-motion: reduce) { .edi-glow { animation: none; } }
.tutor-fab .edi-avatar { width: 30px; height: 30px; background: var(--ink); border-radius: 9px; }
.tutor-fab .edi-avatar img { width: 30px; height: 30px; }

/* ======================================================================
   Scenes
   ====================================================================== */
/* slide */
.slide { position: absolute; inset: 0; padding: 6% 7% 12%; display: flex; flex-direction: column; justify-content: center; }
.slide h2 { font-size: clamp(18px, 3cqw, 38px); margin-bottom: .6em; font-weight: 800; }
.slide.layout-title h2 { font-size: clamp(22px, 4.2cqw, 52px); color: var(--ink); }
.slide.layout-title h2 .mk { color: var(--accent-ink); }
.slide ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .55em; }
.slide li { font-size: clamp(13px, 1.75cqw, 21px); padding-left: 1.4em; position: relative; opacity: .12; transform: translateX(-8px); transition: opacity .5s, transform .5s; font-weight: 500; color: var(--ink); }
.slide li.on { opacity: 1; transform: none; }
.slide li::before { content: ""; position: absolute; left: 0; top: .55em; width: .5em; height: .5em; border-radius: 50%; background: var(--accent); }
.slide.layout-warning { background: radial-gradient(ellipse at 80% 0, rgba(180, 35, 24, .09), transparent 60%); }
.slide.layout-warning h2 { color: var(--danger); }
.slide.layout-warning li::before { background: var(--danger); }
.slide .callout { margin-top: 1.2em; padding: .7em 1em; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r-xs) var(--r-xs) 0; font-size: clamp(12px, 1.45cqw, 17px); color: var(--accent-deep); font-weight: 600; opacity: 0; transition: opacity .6s; }
.slide .callout.on { opacity: 1; }
.slide.layout-warning .callout { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-ink); }
.slide table { border-collapse: collapse; width: 100%; font-size: clamp(11px, 1.5cqw, 18px); }
.slide th, .slide td { padding: .45em .6em; border-bottom: 1px solid var(--line-2); text-align: left; }
.slide th { color: var(--dim); font-weight: 700; font-size: .85em; text-transform: uppercase; letter-spacing: .05em; }
.slide tr.row { opacity: .15; transition: opacity .5s; }
.slide tr.row.on { opacity: 1; }
.slide td:first-child { font-weight: 700; font-family: var(--mono); }
.warn-icon { font-size: clamp(22px, 3cqw, 40px); }
/* Fit (scenes/slide.js): a slide taller than its stage first shrinks its type and spacing by --fit (never under the px
   floors here, the legible minimum) and, only if still needed, scrolls its body under the title, top-aligned. Without
   data-fit none of this applies: a slide that fits looks exactly as authored. */
.slide[data-fit] { padding-top: calc(6% * var(--fit, 1)); padding-bottom: calc(12% * var(--fit, 1)); }
.slide[data-fit] h2 { font-size: max(15px, calc(clamp(18px, 3cqw, 38px) * var(--fit, 1))); margin-bottom: calc(.6em * var(--fit, 1)); }
.slide.layout-title[data-fit] h2 { font-size: max(17px, calc(clamp(22px, 4.2cqw, 52px) * var(--fit, 1))); }
.slide[data-fit] .warn-icon { font-size: max(16px, calc(clamp(22px, 3cqw, 40px) * var(--fit, 1))); }
.slide[data-fit] ul { gap: calc(.55em * var(--fit, 1)); }
.slide[data-fit] li { font-size: max(12px, calc(clamp(13px, 1.75cqw, 21px) * var(--fit, 1))); }
.slide[data-fit] .callout { margin-top: calc(1.2em * var(--fit, 1)); font-size: max(12px, calc(clamp(12px, 1.45cqw, 17px) * var(--fit, 1))); }
.slide[data-fit] table { font-size: max(11px, calc(clamp(11px, 1.5cqw, 18px) * var(--fit, 1))); }
.slide.fit-scroll { justify-content: flex-start; }
.slide.fit-scroll > h2, .slide.fit-scroll > .warn-icon { flex: none; }
.slide.fit-scroll > .slide-body { flex: 1 1 auto; min-height: 0; margin: -6px -8px 0; padding: 6px 8px 10px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%); }
/* the last lines can scroll clear of Edi's corner */
.stage-wrap.edi-on:not([data-edi-mode="big"]) .slide.fit-scroll > .slide-body { padding-bottom: calc(var(--edi-size, 80px) + 8px); }

/* diagram */
.diagram { position: absolute; inset: 0; }
.diagram svg { width: 100%; height: 100%; }
.diagram .caption { position: absolute; top: 12px; right: 14px; max-width: 52%; background: rgba(255, 255, 255, .95); border: 1px solid var(--line); box-shadow: var(--shadow-sm); padding: 7px 12px; border-radius: var(--r-sm); font-size: clamp(12px, 1.3cqw, 15px); font-weight: 600; color: var(--ink-2); z-index: 2; }
/* The drawing's view (scenes/diagram.js, diagram-view.js): the drawing fits it, or (.dg-pan) it is drawn at the scale that
   keeps its smallest text at 12 px and the view scrolls; the edges that still hide part of it fade, a hint shows at first.
   --dg-l/-r: the view's insets (Edi's column, below); --dg-pad-t/-b: room to slide the drawing clear of what lies over
   the view (the scene badge, the caption, the subtitle, a landscape phone's controls). */
.diagram :is(.dg-view, .dg-edges) { position: absolute; inset: 0 var(--dg-r, 0px) 0 var(--dg-l, 0px); }
.diagram .dg-sheet { position: relative; width: 100%; height: 100%; }
.diagram.dg-pan { --dg-pad-t: 44px; --dg-pad-b: 56px; }
.diagram.dg-pan .dg-view { overflow: auto; overscroll-behavior-x: contain; scrollbar-width: thin; touch-action: pan-x pan-y; cursor: grab; }
.diagram.dg-pan .dg-view.pan-dragging { cursor: grabbing; }
.diagram.dg-pan .dg-sheet { box-sizing: content-box; width: var(--dg-w); height: var(--dg-h); margin: 0 auto; padding: var(--dg-pad-t) 0 var(--dg-pad-b); }
.diagram .dg-edges { z-index: 1; pointer-events: none; display: none;
  background: linear-gradient(to right, rgba(28, 26, 23, .2), rgba(28, 26, 23, 0)) left / var(--dg-el, 0px) 100% no-repeat,
    linear-gradient(to left, rgba(28, 26, 23, .2), rgba(28, 26, 23, 0)) right / var(--dg-er, 0px) 100% no-repeat,
    linear-gradient(rgba(28, 26, 23, .2), rgba(28, 26, 23, 0)) top / 100% var(--dg-et, 0px) no-repeat,
    linear-gradient(to top, rgba(28, 26, 23, .2), rgba(28, 26, 23, 0)) bottom / 100% var(--dg-eb, 0px) no-repeat; }
.diagram.dg-pan .dg-edges { display: block; }
.diagram.more-l { --dg-el: 22px; } .diagram.more-r { --dg-er: 22px; } .diagram.more-t { --dg-et: 22px; } .diagram.more-b { --dg-eb: 22px; }
.diagram .dg-hint { display: none; position: absolute; top: 46px; left: calc(var(--dg-l, 0px) + 12px); z-index: 2; max-width: calc(100% - 24px); padding: 4px 10px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .92); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 12.5px; font-weight: 600; color: var(--ink-2); pointer-events: none; transition: opacity .6s; }
.diagram.dg-pan .dg-hint { display: block; }
.diagram .dg-hint.fade { opacity: 0; }
/* Edi never stands on the drawing: the view leaves him a column on his side; the step's caption stays at the drawing's top
   right (phones in portrait: he steps out while the drawing takes the whole stage, see the 700 px container query) */
.stage-wrap.edi-on[data-scene="diagram"]:not([data-edi-mode="hidden"]) .diagram { --dg-room: calc(var(--edi-size) + 20px); --dg-r: var(--dg-room); }
.stage-wrap.edi-on[data-scene="diagram"][data-edi-side="left"]:not([data-edi-mode="hidden"]) .diagram { --dg-r: 0px; --dg-l: var(--dg-room); }
.stage-wrap.edi-on[data-scene="diagram"]:not([data-edi-mode="hidden"]) .diagram .caption { left: auto; right: calc(var(--dg-r) + 12px); }
.stage-wrap.immersive .diagram.dg-pan { --dg-pad-b: calc(var(--ctl-h, 92px) + 56px); }
.dnode rect { fill: #ffffff; stroke: var(--line-3); stroke-width: 1.5; transition: fill .4s, stroke .4s; }
.dnode text { fill: var(--ink); font-family: var(--font); font-weight: 600; pointer-events: none; }
.dnode .sub { fill: var(--dim); font-weight: 500; }
.dnode.kind-hazard rect { stroke: var(--danger-line); fill: #FFFBFA; }
.dnode.kind-control rect { stroke: #B9C3D4; }
.dnode.kind-output rect { stroke: #9CCFC4; }
.dnode.kind-result rect { stroke: #C4BBE6; }
.dnode.kind-action rect { stroke: #E3C98A; }
.dnode.hl rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 2px 8px rgba(255, 90, 31, .35)); }
.dnode.kind-hazard.hl rect { fill: var(--danger-soft); stroke: var(--danger); filter: drop-shadow(0 2px 8px rgba(180, 35, 24, .3)); }
.dnode.dim { opacity: .5; }
.dedge { fill: none; stroke: #B5AD9F; stroke-width: 2; }
.dedge.style-power { stroke: #CDA55A; }
.dedge.style-feedback { stroke-dasharray: 6 4; stroke: #6FA9A3; }
.dedge.style-signal { stroke: #9AA6C2; }
.dedge.active { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 10 8; animation: flow 0.9s linear infinite; }
.dedge.style-power.active { stroke: #D97706; }
@keyframes flow { to { stroke-dashoffset: -18; } }
.dedge-label { fill: var(--dim); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 3px; }
.sig-label { fill: var(--ink-2); font: 600 14px var(--mono); }
.sig-line { fill: none; stroke-width: 2.5; }
.sig-lane { stroke: var(--line); }
.sig-axis { fill: var(--dim); font: 11px var(--mono); }
.sig-hl .sig-label { fill: var(--ink); }

/* 3d */
.three-root { position: absolute; inset: 0; }
.three-root canvas { display: block; width: 100% !important; height: 100% !important; outline: none; touch-action: none; }
.three-tools { position: absolute; right: 12px; top: 12px; z-index: 32; display: flex; flex-direction: column; gap: 6px; background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid var(--line); box-shadow: var(--shadow-sm); border-radius: var(--r); padding: 8px 10px; font-size: 13px; font-weight: 600; min-width: 160px; }
.three-tools label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-2); min-height: 30px; }
.three-tools input[type=range] { width: 84px; height: 24px; accent-color: var(--accent); }   /* the track stays thin; 24 px to grab */
.three-tools .tbtn { min-height: var(--tap); padding: 5px 8px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--card); cursor: pointer; color: var(--ink-2); flex: 1; font-weight: 700; }
.three-tools .tbtn.on { color: var(--on-ink); background: var(--ink); border-color: var(--ink); }
.three-tools .row { display: flex; gap: 6px; }
.three-tools-toggle { display: none; position: absolute; right: 8px; top: 8px; z-index: 33; min-height: 40px; padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: rgba(255, 255, 255, .95); color: var(--ink); font-weight: 700; font-size: 13.5px; box-shadow: var(--shadow-sm); cursor: pointer; }
.tools-open .three-tools-toggle { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.three-labels { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.three-labels svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.three-labels .tag { position: absolute; transform: translate(-50%, -100%); font-size: 12px; font-weight: 700; white-space: nowrap; padding: 3px 9px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .95); border: 1px solid var(--line-2); color: var(--ink); box-shadow: 0 1px 3px rgba(28, 26, 23, .12); pointer-events: auto; cursor: pointer; max-width: 46cqw; overflow: hidden; text-overflow: ellipsis; }
.three-labels .tag.hl { border-color: var(--ink); color: var(--on-ink); background: var(--ink); }
.three-labels .tag.hazard { border-color: var(--danger-line); color: var(--danger-ink); background: #FFFBFA; }
.three-labels .tag.hazard.hl { color: var(--on-ink); background: var(--danger); border-color: var(--danger); }
.part-info { position: absolute; left: 12px; bottom: 12px; z-index: 33; width: min(360px, 46%); max-height: calc(100% - 24px); overflow-y: auto; background: rgba(255, 255, 255, .97); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--r); padding: 12px 40px 12px 14px; font-size: 13.5px; }
.part-info h4 { margin: 0 0 4px; font-family: var(--font-display); font-size: 15px; }
.part-info p { margin: 0 0 6px; color: var(--ink-2); }
.part-info .risk { color: var(--danger); font-size: 13px; font-weight: 600; }
.part-info .fail { color: var(--amber-ink); font-size: 13px; font-weight: 600; }
.part-info .close { position: absolute; top: 2px; right: 2px; width: var(--tap); height: var(--tap); background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 20px; border-radius: var(--r-sm); }
.three-hint { position: absolute; left: 12px; top: 46px; z-index: 31; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: rgba(255, 255, 255, .9); border: 1px solid var(--line); padding: 4px 10px; border-radius: var(--r-xs); transition: opacity .6s; pointer-events: none; }
.three-hint.fade { opacity: 0; }
/* Edi stands behind the model's labels, card, hint and tools, never on them (phones in portrait give him a place of his
   own under the model: see the 700 px container query) */
.stage-wrap[data-scene="3d"] .edi:not([data-mode="cheer"]) { z-index: 19; }

/* quiz / exercise overlay cards */
.interactive { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 48px 6% 9%; overflow-y: auto; }
.iq { width: 100%; max-width: 820px; margin: auto; background: rgba(255, 255, 255, .98); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow-lg); }
.iq .kicker { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: var(--track-caps); color: var(--accent-ink); margin-bottom: 6px; }
.iq h3 { font-size: clamp(15px, 1.8cqw, 20px); margin-bottom: 14px; }
.iq .opts { display: grid; gap: 8px; }
.iq .opt { text-align: left; min-height: var(--tap); padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card); cursor: pointer; font-size: clamp(14px, 1.4cqw, 15.5px); font-weight: 600; transition: border-color var(--dur-fast), background var(--dur-fast); }
.iq .opt:hover { border-color: var(--ink); }
.iq .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.iq .opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.iq .opt .fb { display: block; margin-top: 6px; font-size: .93em; font-weight: 500; color: var(--ink-2); }
.iq .opt.right .fb { color: var(--ok-ink); }
.iq .opt.wrong .fb { color: var(--danger-ink); }
.iq .foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 14px; gap: 10px; }
.iq .foot .btn { min-height: var(--tap); }
.iq .explain { color: var(--ink-2); font-size: 14px; flex: 1 1 260px; }
/* Activities: Edi waits in the stage's top corner (peek) and grows there on an answer (pop, ×1.05). The kicker and the
   question keep clear of him on his side: --edi-room is how far his popped portrait (10 px from the stage's edge) reaches
   past the card's edge and padding. One room for both modes, so the question never re-wraps when he pops. Here the
   desktop card (.interactive padding 6 %, card at most 820 px, padding 22 px); tablets and phones below. */
.stage-wrap.edi-on.interactive-scene .interactive > .iq { --edi-room: max(0px, calc(var(--edi-size) * 1.05 + 10px - 6cqw - max(0px, (88cqw - 820px) / 2) - 22px)); }
.stage-wrap.edi-on.interactive-scene .interactive > .iq > :is(.kicker, h3) { padding-right: var(--edi-room); }
.stage-wrap.edi-on.interactive-scene[data-edi-side="left"] .interactive > .iq > :is(.kicker, h3) { padding-right: 0; padding-left: var(--edi-room); }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.order-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1.5px solid var(--line-2); background: var(--card); border-radius: var(--r-sm); font-size: clamp(14px, 1.3cqw, 15px); font-weight: 600; }
.order-list li .n { font: 800 12px var(--font-display); color: var(--dim); width: 18px; flex: none; }
.order-list li .txt { flex: 1; min-width: 0; }
.order-list li button { flex: none; width: var(--tap); height: var(--tap); border-radius: var(--r-xs); border: 1px solid var(--line-2); background: var(--paper-2); cursor: pointer; font-size: 16px; }
.order-list li.ok { border-color: var(--ok); }
.order-list li.bad { border-color: var(--danger); }
.feedback { margin-top: 10px; padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; }
.feedback.ok { background: var(--ok-soft); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.feedback.bad { background: var(--danger-soft); color: var(--danger-ink); border: 1px solid var(--danger-line); }

/* connector SVG */
.conn24 { width: 100%; max-width: 560px; touch-action: manipulation; }
.conn24 .pin { cursor: pointer; }
.conn24 .pin rect.cell { fill: #1C1A17; stroke: #3A362F; stroke-width: 1.5; }
.conn24 .pin:hover rect.cell { stroke: var(--accent); }
.conn24 .pin.sel rect.cell { stroke: var(--amber); stroke-width: 3; }
.conn24 .pin.red rect.cell { stroke: #FF4D4D; stroke-width: 3; }
.conn24 .pin.black rect.cell { stroke: #E7E1D6; stroke-width: 3; stroke-dasharray: 4 2; }
.conn24 text { font: 11px var(--mono); fill: #A39B8E; pointer-events: none; }
.conn24 .num { fill: #F3EEE6; font-weight: 700; }
.conn24 text.legend { fill: var(--ink-2); font-size: 11.5px; font-family: var(--font); }

/* measurement */
.measure { position: absolute; inset: 0; display: grid; grid-template-columns: 1.05fr 1fr; gap: 14px; padding: 48px 16px 56px; overflow-y: auto; }
.measure .col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.measure .task { font-size: 14px; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); border: 1px solid var(--accent-soft-2); padding: 8px 12px; border-radius: var(--r-sm); }
.measure .states { display: flex; gap: 6px; flex-wrap: wrap; }
.measure .states button, .probe-sel button { min-height: var(--tap); font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--card); cursor: pointer; color: var(--ink-2); }
.measure .states button.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.probe-sel { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.probe-sel button.on.red { background: #C62828; color: #fff; border-color: #C62828; }
.probe-sel button.on.black { background: var(--ink); color: #fff; border-color: var(--ink); }
.dmm { background: linear-gradient(180deg, #FFC53D, #E5A41A); border-radius: var(--r-lg); padding: 12px; color: #1C1A17; box-shadow: var(--shadow); }
.dmm .lcd { background: #C5D1B0; border-radius: var(--r-xs); padding: 6px 12px; font: 700 clamp(26px, 3.6cqw, 44px) var(--mono); text-align: right; color: #1D2416; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .35); min-height: 1.4em; display: flex; justify-content: space-between; align-items: center; }
.dmm .lcd small { font-size: .38em; font-weight: 600; }
.dmm .lcd .unit { font-size: .45em; margin-left: 6px; }
.dmm .model { font: 800 11px var(--font-display); letter-spacing: .08em; margin: 2px 2px 8px; display: flex; justify-content: space-between; }
.dmm .dial { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.dmm .dial button { font: 600 12px var(--mono); min-height: var(--tap); padding: 6px 2px; border-radius: 7px; border: 1px solid #8A5A0A; background: #2A2722; color: #EEE; cursor: pointer; }
.dmm .dial button.on { background: #1C1A17; color: var(--amber); box-shadow: 0 0 0 2px #1C1A17; }
.dmm .jacks { display: flex; justify-content: space-around; margin-top: 8px; font: 600 10.5px var(--mono); }
.dmm .jacks span::before { content: "●"; margin-right: 4px; }
.dmm .jacks .r::before { color: #C62828; } .dmm .jacks .b::before { color: #1C1A17; }
.m-note { font-size: 13px; color: var(--ink-2); min-height: 1.2em; }
.m-warn { font-size: 13px; color: var(--amber-ink); font-weight: 600; }
.mlog { font: 12px var(--mono); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); max-height: 150px; overflow: auto; }
.mlog table { width: 100%; border-collapse: collapse; }
.mlog td, .mlog th { padding: 4px 8px; border-bottom: 1px solid var(--paper-2); text-align: left; white-space: nowrap; }
.mlog th { color: var(--dim); font-weight: 600; position: sticky; top: 0; background: var(--paper); }
.mlog .bad { color: var(--danger); } .mlog .good { color: var(--ok); }
.coverage { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; font-weight: 700; }
.coverage span { padding: 2px 9px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--dim); }
.coverage span.done { color: var(--ok-ink); border-color: var(--ok-line); background: var(--ok-soft); }

/* anatomy (interactive figure in a same-origin iframe) */
.anatomy-root { position: absolute; inset: 0; background: #fff; }
.anatomy-frame { position: absolute; inset: 0 0 28px 0; width: 100%; height: calc(100% - 28px); border: 0; background: #fff; }
.anatomy-hint { position: absolute; left: 14px; right: 14px; bottom: 5px; font-size: 12px; font-weight: 600; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Edi never stands on the figure (its readings, its controls): the frame leaves him a column on his side. On phones in
   portrait the figure keeps the whole stage and Edi steps out while it is on (anatomy.js, the player's ediAway, as for a
   diagram): a strip for him there lands under the floating Edi button on the first screen. The figure picks its layout
   from the scene's width, as before. */
.stage-wrap.edi-on[data-scene="anatomy"] .anatomy-root { --an-room: calc(var(--edi-size) + 20px); }
.stage-wrap.edi-on[data-scene="anatomy"] .anatomy-frame { width: calc(100% - var(--an-room)); }
.stage-wrap.edi-on[data-scene="anatomy"][data-edi-side="left"] .anatomy-frame { left: var(--an-room); }
.stage-wrap.edi-on[data-scene="anatomy"] .anatomy-hint { right: calc(var(--an-room) + 2px); }
.stage-wrap.edi-on[data-scene="anatomy"][data-edi-side="left"] .anatomy-hint { right: 14px; left: calc(var(--an-room) + 2px); }
@container stage (max-width: 700px) {
  .stage-wrap.edi-on[data-scene="anatomy"]:not(.immersive) .anatomy-frame { left: 0; width: 100%; }
  .stage-wrap.edi-on[data-scene="anatomy"]:not(.immersive) .anatomy-hint { left: 14px; right: 14px; }
}
/* «Explora la figura» panel under the player (the course's own figure when the lesson does not use it) */
#figurePanel { grid-column: 1 / -1; }
.figure-panel-text { margin: 0 0 10px; color: var(--ink-2); }
.figure-panel-box.open { position: relative; width: 100%; aspect-ratio: 1134 / 610; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #fff; }
.figure-panel-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 639px) { .figure-panel-box.open { aspect-ratio: auto; height: 560px; } }

/* Small stages (phones in portrait, narrow windows): collapse the 3D tools and quiet the overlays. */
@container stage (max-width: 700px) {
  .scene-badge { display: none; }
  .three-tools-toggle { display: inline-flex; align-items: center; }
  .three-tools { display: none; top: 56px; right: 8px; min-width: 180px; }
  .tools-open .three-tools { display: flex; }
  .three-tools label { min-height: 40px; }
  .three-tools input[type=range] { width: 96px; height: 28px; }
  .three-hint { top: auto; bottom: 8px; left: 8px; right: 8px; text-align: center; font-size: 12px; }
  .three-labels .tag { font-size: 10.5px; padding: 3px 7px; }   /* 24 px or more to tap (a label opens its part) */
  .part-info { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 50%; font-size: 13px; padding: 10px 40px 10px 12px; }
  /* phones in portrait: the model keeps its whole 16:9 view and, where the first screen has room under it (--stage-max-h
     less a margin for the subtitle band growing to four lines), the stage grows by an area in which the part's card and the
     hint sit beside Edi (at most 180 px). Without that room the card lies over the model's lower part, 45 % at most. The
     card stays clear of Edi's corner and above him (his z-index below): its close button is never under him. */
  .stage-wrap[data-scene="3d"]:not(.immersive) .stage { --three-info: clamp(0px, calc(var(--stage-max-h, 0px) - var(--band-slack, 44px) - 56.25cqw), 180px); aspect-ratio: auto; height: calc(56.25cqw + var(--three-info)); }
  .stage-wrap[data-scene="3d"]:not(.immersive) .three-root { bottom: auto; height: 56.25cqw; }
  .stage-wrap[data-scene="3d"]:not(.immersive) :is(.part-info, .three-hint) { top: auto; bottom: calc(8px - var(--three-info)); }
  .stage-wrap[data-scene="3d"]:not(.immersive) .part-info { max-height: max(calc(var(--three-info) - 16px), 45%); }
  .stage-wrap[data-scene="3d"]:not(.immersive) .tools-open .three-tools { z-index: 34; }   /* opened tools reach low: above the card */
  .stage-wrap.edi-on[data-scene="3d"]:not(.immersive) :is(.part-info, .three-hint) { left: 8px; right: calc(var(--edi-size) + 18px); text-align: left; }
  .stage-wrap.edi-on[data-scene="3d"][data-edi-side="left"]:not(.immersive) :is(.part-info, .three-hint) { left: calc(var(--edi-size) + 18px); right: 8px; }
  .diagram .caption { top: 8px; right: 8px; left: 8px; max-width: none; font-size: 12.5px; padding: 6px 10px; }
  /* diagrams on phones in portrait: the drawing takes the whole stage (Edi steps out meanwhile: scenes/diagram.js sets the
     player's ediAway, as a walkthrough's conversation does) and can slide below the step's caption */
  .stage-wrap:not(.immersive) .diagram.dg-pan { --dg-pad-t: 48px; --dg-pad-b: 0px; }
  .stage-wrap:not(.immersive) .diagram .dg-hint { top: auto; bottom: 8px; left: 8px; }
  .slide { padding: 5% 6% 7%; }
  .slide[data-fit] { padding-top: calc(5% * var(--fit, 1)); padding-bottom: calc(7% * var(--fit, 1)); }
  .big-play p { font-size: 14px; }
}

/* ======================================================================
   Immersive player: phones in landscape, real fullscreen, CSS pseudo-fullscreen (iPhone)
   ====================================================================== */
html.player-immersive, html.player-immersive body { overflow: hidden; overscroll-behavior: none; }
.stage-wrap.immersive { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 0; box-shadow: none; background: #0B0A09; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.stage-wrap.immersive .stage-box { width: min(100%, calc((100vh - var(--safe-t) - var(--safe-b)) * 16 / 9)); width: min(100%, calc((100dvh - var(--safe-t) - var(--safe-b)) * 16 / 9)); }
.stage-wrap.immersive .stage { aspect-ratio: 16 / 9; }
.stage-wrap.immersive .controls { position: absolute; left: 0; right: 0; bottom: 0; border: 0; color: #fff;
  padding: 28px max(12px, var(--safe-r)) max(6px, var(--safe-b)) max(12px, var(--safe-l));
  background: linear-gradient(rgba(11, 10, 9, 0), rgba(11, 10, 9, .62) 40%, rgba(11, 10, 9, .86)); }
.stage-wrap.immersive .ctl { color: #F3EEE6; }
.stage-wrap.immersive .ctl:hover, .stage-wrap.immersive .ctl:active { background: rgba(255, 255, 255, .14); }
.stage-wrap.immersive .ctl.on { color: #FFB38F; background: rgba(255, 90, 31, .18); }
.stage-wrap.immersive .ctl-play { background: var(--accent); color: #fff; }
.stage-wrap.immersive .ctl-tutor { display: inline-grid; }
.stage-wrap.immersive:fullscreen .ctl-tutor { display: none; }
.stage-wrap.immersive:-webkit-full-screen .ctl-tutor { display: none; }
.stage-wrap.immersive .time, .stage-wrap.immersive .now-title { color: #E7E1D6; }
.stage-wrap.immersive .timeline .track { background: rgba(255, 255, 255, .3); }
.stage-wrap.immersive .timeline .chap-mark { background: rgba(11, 10, 9, .7); }
.stage-wrap.immersive .subtitles { bottom: calc(var(--ctl-h) + 6px); transition: bottom .25s; }
.stage-wrap.immersive.controls-hidden .controls { opacity: 0; pointer-events: none; }
.stage-wrap.immersive.controls-hidden .subtitles { bottom: 14px; }
.stage-wrap.immersive.controls-hidden { cursor: none; }
.stage-wrap.immersive .popover { right: max(12px, var(--safe-r)); bottom: calc(var(--ctl-h) + 8px); max-height: calc(100% - var(--ctl-h) - 16px); }
/* phones held sideways: the settings take two columns, so every item is in view without scrolling (the voice and its
   note on the left, the switches and the credits on the right) */
@media (orientation: landscape) and (max-height: 500px) {
  .stage-wrap.immersive .settings-menu { width: min(560px, calc(100% - 24px)); display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-content: start; align-items: start; padding-top: 8px; padding-bottom: 10px; }
  .stage-wrap.immersive .settings-menu > .sheet-head { grid-column: 1 / -1; margin-bottom: 2px; }
  .stage-wrap.immersive .settings-menu > .field-label { grid-area: 2 / 1; margin: 2px 0 4px; }
  .stage-wrap.immersive .settings-menu > select { grid-area: 3 / 1; }
  .stage-wrap.immersive .settings-menu > .settings-row { grid-area: 4 / 1; margin-top: 4px; }
  .stage-wrap.immersive .settings-menu > .hint { grid-area: 5 / 1; margin-top: 4px; }
  .stage-wrap.immersive .settings-menu > .switch-row { grid-column: 2; grid-row: 2 / span 2; margin-top: 0; }
  .stage-wrap.immersive .settings-menu > .switch-row ~ .switch-row { grid-row: 4; margin-top: 4px; }
  .stage-wrap.immersive .settings-menu > .credits { grid-area: 5 / 2; margin-top: 4px; }
}
/* the landscape player's light control colour is for its dark bar: on a popover's white card the close button keeps ink */
.stage-wrap.immersive .popover .ctl { color: var(--ink-2); }
.stage-wrap.immersive .popover .ctl:hover { background: var(--paper-2); }
.stage-wrap.immersive .big-play { background: rgba(11, 10, 9, .35); }
.stage-wrap.immersive .big-play p { background: rgba(255, 255, 255, .92); }
.stage-wrap.immersive .three-hint { top: 8px; bottom: auto; left: 8px; right: auto; }
/* Landscape phones (and fullscreen): an activity's scroll area ends where the overlaid controls begin, so an option or
   «Comprobar» is either in view above them or scrolled out of view inside the card, never under them. */
.stage-wrap.immersive .interactive { bottom: var(--ctl-h, 64px); padding-bottom: 12px; align-items: flex-start; }
.stage-wrap.immersive .measure { bottom: var(--ctl-h, 64px); padding-bottom: 12px; }
body.tutor-open .stage-wrap.immersive { right: min(380px, 46vw); }
body.tutor-open .stage-wrap.immersive .ctl-tutor { color: #FFB38F; }
html.player-immersive .tutor-fab { display: none !important; }
html.player-immersive .tutor { position: fixed; z-index: 1001; top: var(--vvtop, 0px); right: 0; bottom: auto; left: auto; width: min(380px, 46vw); height: var(--vvh, 100vh);
  border-left: 1px solid var(--line); border-radius: 0; transform: translateX(105%); visibility: hidden; transition: transform .25s, visibility .25s; padding-right: var(--safe-r); }
html.player-immersive body.tutor-open .tutor { transform: none; visibility: visible; }
html.player-immersive .tutor-msgs { padding: 10px 14px; }
html.player-immersive .tutor-suggest { flex-wrap: nowrap; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (pointer: coarse) {
  .ctl { width: var(--tap); height: var(--tap); }
  .timeline { height: var(--tap); }
  .timeline .knob { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
  .btn-sm { min-height: var(--tap); }
  .measure .states button, .probe-sel button, .dmm .dial button { min-height: var(--tap); }
  .order-list li button { width: var(--tap); height: var(--tap); }
  .chapters button { min-height: var(--tap); }
}

/* tablets and phones: one column; the tutor becomes a sheet opened from a floating button */
@media (max-width: 1100px) {
  .player-layout, .player-layout.tutor-closed { display: block; }
  .player-main { --main-pad-b: 96px; padding: 12px max(16px, var(--safe-r)) var(--main-pad-b) max(16px, var(--safe-l)); }
  .tutor-toggle { display: none; }
  .below-player { grid-template-columns: 1fr; }

  .tutor-fab { display: inline-flex; align-items: center; gap: 8px; position: fixed; z-index: 1040; right: max(16px, var(--safe-r)); bottom: max(16px, calc(var(--safe-b) + 8px));
    min-height: 52px; padding: 0 20px 0 12px; border: 0; border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: 15px; cursor: pointer;
    box-shadow: 0 10px 28px -8px rgba(28, 26, 23, .55), 0 1px 3px rgba(28, 26, 23, .2); }
  .tutor-fab svg { width: 22px; height: 22px; }
  body:not(.player-offscreen) .tutor-fab { opacity: 0; transform: translateY(16px) scale(.9); pointer-events: none; visibility: hidden; }
  .tutor-fab { transition: opacity .2s, transform .2s, visibility .2s; }
  body.tutor-open .tutor-fab { display: none; }
  .stage-wrap .ctl-tutor { display: inline-grid; }
  body.tutor-open .ctl-tutor { color: var(--accent-ink); }
  body.tutor-open { overflow: hidden; }
  /* The floating button never lies over a control: when one would be under it, the page's scroll area ends above the
     button, which then sits on a strip of its own (body.fab-dock, static/js/tutor.js). */
  html:not(.player-immersive) body.fab-dock:not(.tutor-open) .player-main { height: calc(100% - var(--fab-dock-h, 76px)); }
  /* the strip only draws its edge (nothing of the page reaches it): low z-index, so point and medal toasts stay above */
  html:not(.player-immersive) body.fab-dock:not(.tutor-open)::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1; height: var(--fab-dock-h, 76px);
    background: var(--paper); box-shadow: 0 -1px 0 var(--line); pointer-events: none; }

  html:not(.player-immersive) .tutor { position: fixed; z-index: 1050; left: 0; right: 0; top: var(--sheet-top, 40vh); height: var(--sheet-h, 60vh);
    border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-up); background: var(--card);
    transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; }
  html:not(.player-immersive) body.tutor-open .tutor { transform: none; visibility: visible; }
  html:not(.player-immersive) .tutor-head { padding-top: 14px; position: relative; }
  html:not(.player-immersive) .tutor-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--line-2); }
  .tutor .composer { margin: 0 max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l)); }
  .tutor-suggest { flex-wrap: nowrap; }

  /* interactive scenes flow at their natural height instead of being squeezed into 16:9 (never shorter than the stage's
     own 16:9: cqw is its width; vw overshot it wherever the stage is narrower than the screen, e.g. tablets in landscape) */
  .stage-wrap.interactive-scene:not(.immersive) .stage { aspect-ratio: auto; min-height: 56.25cqw; }
  .stage-wrap.interactive-scene:not(.immersive) .scene-root { position: relative; inset: auto; }
  .stage-wrap.interactive-scene:not(.immersive) .scene-layer:not(.scene-leaving) { position: relative; inset: auto; }
  .stage-wrap.interactive-scene:not(.immersive) .interactive,
  .stage-wrap.interactive-scene:not(.immersive) .measure { position: relative; inset: auto; overflow: visible; }
  .stage-wrap.interactive-scene:not(.immersive) .interactive { padding: 52px 16px 20px; }
  .stage-wrap.interactive-scene:not(.immersive) .measure { padding: 52px 16px 20px; }
  /* the room Edi takes from the activity's question (see .iq above): padding 16 px, card at most 820 px, padding 22 px */
  .stage-wrap.edi-on.interactive-scene:not(.immersive) .interactive > .iq { --edi-room: max(0px, calc(var(--edi-size) * 1.05 - 28px - max(0px, (100cqw - 852px) / 2))); }
  /* a diagram drawn larger than its stage (scenes/diagram.js, --dg-need-h) makes the stage taller, up to the room the first
     screen leaves (--stage-max-h; phones keep a margin for the subtitle band growing to four lines): less to slide, and the
     player's bar stays in view */
  .stage-wrap[data-scene="diagram"]:not(.immersive) .stage { aspect-ratio: auto; }
  .stage-wrap[data-scene="diagram"]:not(.immersive) .scene-root,
  .stage-wrap[data-scene="diagram"]:not(.immersive) .scene-layer:not(.scene-leaving) { position: relative; inset: auto; }
  .stage-wrap[data-scene="diagram"]:not(.immersive) .scene-layer:not(.scene-leaving) > .diagram { position: relative; inset: auto;
    height: clamp(56.25cqw, calc(var(--dg-need-h, 0px) + var(--dg-pad-t, 0px) + var(--dg-pad-b, 0px)), calc(var(--stage-max-h, 100vh) - var(--band-slack, 0px))); }
}

/* Activities (the cards of quiz.js, exercise.js, practice.js, scenes/lang.js): the action row stays in view and the
   subtitle never lies over the card.
   - Computers and tablets: the foot with «Comprobar» sticks to the bottom of the card's scroll area (the stage on
     computers; on tablets the page, because the stage there only clips: overflow clip makes no scroll box) and what is
     above it scrolls under its fade. Phones in portrait: the page scrolls and a waiting card is brought into view
     (player.js revealCard).
   - While an activity's narration runs (.subs-room: player.js fitSubs, card-view.js subsRoomOn) the card keeps clear of
     the subtitle: on computers its scroll area ends above it while its content box keeps its place (a card that fits
     does not move); on tablets the stage grows under the card; in the immersive layout the scroll area ends above the
     subtitle as it does above the controls. Phones in portrait show the subtitle in a band under the stage. */
.stage-wrap { --subs-room: max(66px, calc(var(--subs-h, 50px) + 16px)); }   /* two lines at least; --subs-h: the scene's tallest subtitle */
/* a sticky box stops at its scroll area's padding: --foot-at (negative) takes the foot down to the area's visible bottom */
@media (min-width: 701px) {
  .stage-wrap:not(.immersive) .px > .foot, .stage-wrap[data-scene="exercise"]:not(.immersive) .iq > .foot { position: sticky; bottom: var(--foot-at, 0px); z-index: 2; padding-bottom: 10px; margin-bottom: -10px; background: var(--card); }
  .stage-wrap:not(.immersive) .px > .foot::before, .stage-wrap[data-scene="exercise"]:not(.immersive) .iq > .foot::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 14px; background: linear-gradient(rgba(255, 255, 255, 0), var(--card)); pointer-events: none; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .stage-wrap.interactive-scene:not(.immersive), .stage-wrap.interactive-scene:not(.immersive) .stage { overflow: clip; }
  .stage-wrap.interactive-scene:not(.immersive) { --foot-at: calc(-1 * var(--main-pad-b, 96px)); }   /* the page's own bottom padding */
  .stage-wrap.subs-room.interactive-scene:not(.immersive) .interactive { padding-bottom: max(20px, var(--subs-room)); }
}
@media (min-width: 1101px) {
  .stage-wrap:not(.immersive) { --foot-at: -9cqw; }   /* .interactive's bottom padding (9 % of the stage's width) */
  .stage-wrap.subs-room:not(.immersive) { --foot-at: calc(-1 * max(0px, 9cqw - var(--subs-room))); }
  .stage-wrap.subs-room:not(.immersive) .interactive { bottom: var(--subs-room); padding-bottom: max(0px, calc(9% - var(--subs-room))); }
}
.stage-wrap.immersive.subs-room .interactive { bottom: calc(var(--ctl-h, 64px) + var(--subs-room)); }

@media (max-width: 860px) {
  .topbar, .page-player { --topbar-h: 56px; }
  .nav-toggle { display: inline-flex; }
  .topnav { position: absolute; top: calc(100% + 6px); right: max(12px, var(--safe-r)); left: max(12px, var(--safe-l)); flex-direction: column; align-items: stretch; gap: 4px; padding: 8px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: none; animation: fadeUp .18s var(--ease); }
  .nav-open .topnav { display: flex; }
  .topnav > a:not(.btn) { min-height: var(--tap); display: flex; align-items: center; padding: 0 14px; border-radius: var(--r-sm); color: var(--ink); font-weight: 700; }
  .topnav > a:not(.btn):hover { background: var(--paper-2); text-decoration: none; }
  .topnav .btn { min-height: var(--tap); }
  .topnav .badge { align-self: flex-start; margin: 4px 12px 8px; }
}

/* phones */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .brand-long { display: none; }
  .page { padding-top: var(--s5); }

  /* intake */
  .chat-col { padding-top: 18px; }
  .msg { gap: 10px; margin-bottom: 18px; }
  .msg .avatar { flex-basis: 28px; height: 28px; font-size: 12px; }
  .msg.user .avatar { display: none; }
  .msg.user .bubble { max-width: 88%; }
  .cards { grid-template-columns: 1fr; gap: 8px; }
  .pcard { padding: 12px 14px; min-height: 52px; }
  .composer-hint { font-size: 12px; }

  /* player: edge-to-edge stage, compact header */
  .page-player .topbar { position: relative; }
  .player-main { padding: 0 0 96px; }
  .player-title { padding: 12px max(16px, var(--safe-r)) 10px max(16px, var(--safe-l)); margin: 0; }
  .player-title h1 { font-size: 17px; }
  .player-title small { font-size: 12.5px; }
  .stage-wrap:not(.immersive) { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .below-player { padding: 0 max(16px, var(--safe-r)) 0 max(16px, var(--safe-l)); }
  .controls { padding: 0 max(6px, var(--safe-r)) 4px max(6px, var(--safe-l)); }
  .timeline-row { padding: 0 6px; gap: 10px; }
  .buttons-row { gap: 0; }
  .now-title { visibility: hidden; padding: 0; }
  .ctl-mute { display: none; }
  .stage-wrap.immersive .ctl-mute { display: inline-grid; }

  /* subtitles become a caption band under the stage (never over the scene, never under the controls) */
  .stage-wrap:not(.immersive) .subtitles, .stage-wrap:not(.immersive).edi-on .subtitles { position: static; transform: none; width: 100% !important; max-width: none !important; min-height: 3.6em; padding: 8px 16px; display: flex; align-items: center; justify-content: center;
    background: var(--ink); border-top: 1px solid var(--ink); visibility: visible !important; }
  .stage-wrap:not(.immersive) .subtitles span { background: none; padding: 0; font-size: 15.5px; line-height: 1.45; }
  .stage-wrap:not(.immersive).interactive-scene .subtitles span { font-size: 14.5px; }
  .stage-wrap:not(.immersive) .subtitles.off { display: none; }
  /* while an activity waits for the learner the narration is over: the empty band gives its room back (player.js) */
  .stage-wrap.is-waiting:not(.immersive) .subtitles { display: none; }
  .stage-wrap { --band-slack: 44px; }   /* the band can grow by two lines after the first screen was sized (bindFit) */

  /* bottom sheets for settings and chapters */
  .stage-wrap:not(.immersive) .popover { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 78vh; max-height: 78dvh; z-index: 1100;
    border-radius: var(--r-xl) var(--r-xl) 0 0; border: 0; box-shadow: var(--shadow-up); font-size: 15px;
    padding: 10px max(18px, var(--safe-r)) max(18px, calc(var(--safe-b) + 10px)) max(18px, var(--safe-l)); animation: sheetUp .22s var(--ease); }
  .stage-wrap:not(.immersive) .sheet-backdrop { display: block; }
  .stage-wrap:not(.immersive) .sheet-backdrop.hidden { display: none !important; }
  .settings-menu select { min-height: var(--tap); font-size: 16px; }

  /* anatomy: taller stage, the figure stacks its controls and scrolls inside the frame */
  .stage-wrap[data-scene="anatomy"]:not(.immersive) .stage { aspect-ratio: auto; height: min(150vw, 70vh); height: min(150vw, 70dvh); }

  .measure { grid-template-columns: 1fr; }
  .stage-wrap.interactive-scene:not(.immersive) .interactive { padding: 48px 10px 16px; }
  .stage-wrap.interactive-scene:not(.immersive) .measure { padding: 48px 10px 16px; }
  /* while it waits, the activity starts below the wait banner, however many lines it takes (player.js: --wait-h) */
  .stage-wrap.is-waiting.interactive-scene:not(.immersive) :is(.interactive, .measure) { padding-top: max(48px, calc(var(--wait-h, 0px) + 18px)); }
  .stage-wrap.edi-on.interactive-scene:not(.immersive) .interactive > .iq { --edi-room: max(0px, calc(var(--edi-size) * 1.05 - 16px)); }   /* padding 10 px, card padding 16 px */
  .iq { padding: 16px; border-radius: var(--r); }
  .iq h3 { font-size: 17px; }
  .iq .opt { font-size: 15.5px; padding: 12px 14px; }
  .iq .foot .btn { flex: 1 1 auto; }
  .order-list li { font-size: 15px; }
  .dmm .dial { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dmm .dial button { font-size: 12.5px; }
  .measure .task, .m-note, .m-warn { font-size: 14px; }
  .wait-banner { top: 10px; font-size: 13.5px; }
}
@media (max-width: 380px) {
  .stage-wrap:not(.immersive) #prevBtn { display: none; }
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ======================================================================
   Next-session card (end of session)
   ====================================================================== */
.next-card { position: absolute; right: var(--s4, 16px); top: var(--s4, 16px); z-index: 41; width: min(320px, calc(100% - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.next-card.hidden { display: none; }
.next-kicker { font-size: 12px; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.next-title { line-height: 1.3; font-family: var(--font-display); }
.next-state { font-weight: 700; }
.next-state.ready { color: var(--ok-ink); }
.next-state.running { color: var(--info); }
.next-state.queued { color: var(--amber-ink); }
.next-note { margin: 0; color: var(--ink-2); font-size: 13px; }
.next-bar { height: 6px; border-radius: var(--r-pill); background: var(--paper-2); overflow: hidden; }
.next-bar i { display: block; height: 100%; background: var(--accent); transition: width .6s; }
.next-card .btn { align-self: flex-start; }
.adapted-note { margin: 8px 0 0; padding: 9px 12px; border-radius: var(--r-sm); background: var(--accent-soft); border: 1px solid var(--accent-soft-2); color: var(--accent-deep); font-size: var(--fs-sm); }
.adapted-note b { display: block; color: var(--accent-ink); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; }
.adapted-note ul { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 600px) { .next-card { right: 8px; left: 8px; top: 8px; width: auto; padding: 8px 10px; gap: 4px; } }

/* ======================================================================
   Accounts: header menu, auth pages, registration sheet, "Mis cursos"
   ====================================================================== */
.topbar-cta { display: none; }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 6px; border-radius: var(--r-pill); cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--paper-2); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-soft-2); }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; max-width: 300px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); display: grid; gap: 6px; z-index: 60; animation: fadeUp .15s var(--ease); }
.user-pop b { overflow-wrap: anywhere; font-family: var(--font-display); }
.user-pop small { color: var(--dim); overflow-wrap: anywhere; margin-top: -4px; }
.user-pop a { min-height: var(--tap); display: flex; align-items: center; color: var(--ink); font-weight: 600; }
.user-pop form { margin: 0; }
.user-pop .btn { width: 100%; }

.auth-page { max-width: var(--max); display: grid; gap: var(--s6); align-items: center; justify-items: center; }
.auth-promo { display: none; }
.auth-page .auth-card { width: 100%; max-width: 480px; }
@media (min-width: 980px) {
  .auth-page { grid-template-columns: minmax(0, 1.1fr) minmax(0, 480px); min-height: calc(100dvh - var(--topbar-h) - 150px); gap: 72px; justify-content: center; justify-items: stretch; }
  .auth-promo { display: flex; flex-direction: column; justify-content: center; gap: var(--s5); position: relative; overflow: hidden; align-self: stretch; padding: 48px; border-radius: var(--r-xl); background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-lg); }
  .auth-promo::before { content: ""; position: absolute; right: -18%; top: -30%; width: 75%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 90, 31, .55), transparent 65%); pointer-events: none; }
  .auth-promo > * { position: relative; }
  .auth-promo img { width: 56px; height: 56px; border-radius: 16px; }
  .auth-promo h2 { font-size: clamp(30px, 3vw, 42px); font-weight: 800; margin: 0; color: var(--on-ink); max-width: 15ch; }
  .auth-promo ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; color: var(--on-ink-2); font-weight: 600; }
  .auth-promo li { display: flex; gap: 10px; align-items: flex-start; }
  .auth-promo li::before { content: ""; flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 12.5l4 4 8-9' fill='none' stroke='%231C1A17' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 13px no-repeat; }
  .auth-page .auth-card { margin: 0; justify-self: center; }
}
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 32px 28px; margin: 8px auto 0; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head img { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto; box-shadow: var(--shadow-sm); }
.auth-head h1, .auth-head h2 { font-size: var(--fs-xl); margin: 14px 0 6px; font-weight: 800; }
.auth-head p { color: var(--ink-2); margin: 0; }
.auth-aside { margin: -4px 0 14px; text-align: right; font-size: 14.5px; }
.auth-aside a { display: inline-flex; min-height: var(--tap); align-items: center; font-weight: 600; }
.auth-switch { text-align: center; margin: 16px 0 0; color: var(--ink-2); }
.auth-switch a { font-weight: 700; }

body.sheet-open { overflow: hidden; }
.sheet-overlay { position: fixed; inset: 0; z-index: 1200; background: rgba(28, 26, 23, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); display: flex; align-items: flex-end; justify-content: center; }
.auth-sheet { position: relative; width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--card); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 22px 20px max(20px, var(--safe-b)); box-shadow: var(--shadow-up); animation: sheetUp .25s var(--ease); }
.sheet-x { position: absolute; right: 8px; top: 8px; width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; background: none; border-radius: 50%; color: var(--ink-2); cursor: pointer; }
.sheet-x:hover { background: var(--paper-2); }
@media (min-width: 640px) {
  .sheet-overlay { align-items: center; padding: 20px; }
  .auth-sheet { border-radius: var(--r-xl); padding: 28px 28px 26px; }
}

.my-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.my-head h1 { font-size: var(--fs-h1); margin: 0 0 4px; }
.my-head p { color: var(--ink-2); margin: 0; max-width: 560px; }
.my-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.my-course { display: flex; flex-direction: column; justify-content: space-between; gap: 18px; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); transition: transform var(--dur), box-shadow var(--dur); }
.my-course:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.my-course h2 { font-size: 22px; margin: 0 0 6px; font-weight: 800; }
.my-course > .btn { align-self: flex-start; }
.my-course h2 a { color: var(--ink); }
.my-meta { color: var(--dim); font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.my-next { margin: 10px 0 0; font-size: 14.5px; color: var(--ink-2); }
.my-next .tag { margin-left: 4px; }
.my-demo { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 32px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--ink); color: var(--on-ink); position: relative; overflow: hidden; }
.my-demo::before { content: ""; position: absolute; right: -10%; top: -80%; width: 50%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 90, 31, .5), transparent 65%); pointer-events: none; }
.my-demo > div { flex: 1; min-width: 200px; position: relative; }
.my-demo b { font-family: var(--font-display); font-size: 16px; }
.my-demo p { margin: 2px 0 0; color: var(--on-ink-2); font-size: 14.5px; }
.my-demo img { border-radius: 12px; position: relative; }
.my-demo .btn { position: relative; background: var(--accent); border-color: var(--accent); color: var(--ink); }
.my-demo .btn:hover { background: #F04E14; border-color: #F04E14; }

@media (max-width: 860px) {
  .topbar-cta { display: inline-flex; margin-left: auto; min-height: 38px; }
  .topnav .nav-secondary { display: flex; }
  .user-menu summary { padding: 0 12px; border-radius: var(--r-sm); }
  .user-menu[open] summary { background: var(--paper-2); }
  .user-pop { position: static; box-shadow: none; border: 0; padding: 6px 12px 4px; min-width: 0; max-width: none; animation: none; }
}
@media (max-width: 700px) {
  .my-course { padding: 18px; }
  .my-course > .btn { width: 100%; align-self: stretch; }
  .my-head > .btn { width: 100%; }
  .auth-card { padding: 24px 18px; border-radius: var(--r-lg); }
  .auth-page { padding-top: 16px; }
}
.page-chat .topbar-cta { display: none; }
.nav-account-m { display: none; }
@media (max-width: 860px) {
  .topnav .user-menu { display: none; }
  .nav-account-m { display: flex; align-items: center; gap: 10px; padding: 10px 12px 4px; margin-top: 4px; border-top: 1px solid var(--line); }
  .nav-account-who { flex: 1; min-width: 0; display: grid; }
  .nav-account-who b, .nav-account-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-account-who small { color: var(--dim); }
  .nav-account-m form { margin: 0; }
}

/* /my: "¿Cómo quieres que te llamemos?" */
.my-name { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0 18px; margin-top: var(--s4); box-shadow: var(--shadow-sm); }
.my-name > summary { list-style: none; cursor: pointer; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.my-name > summary::-webkit-details-marker { display: none; }
.my-name > summary::after { content: "+"; font-family: var(--font-display); font-size: 20px; color: var(--accent-ink); }
.my-name[open] > summary::after { content: "–"; }
.my-name form { padding: 0 0 18px; max-width: 560px; }
.my-name label { display: block; font-weight: 700; margin-bottom: 6px; }
.my-empty { text-align: center; padding: 48px 24px; background: var(--card); border: 1px dashed var(--line-3); border-radius: var(--r-xl); }
.my-empty img { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px; }
.my-empty h2 { font-size: var(--fs-xl); margin-bottom: 8px; }
.my-empty p { color: var(--ink-2); margin: 0 auto 18px; max-width: 46ch; }
.my-name-row { display: flex; gap: 8px; }
.my-name-row input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 14px; font-size: 16px; border: 1.5px solid var(--line-2); border-radius: var(--r-pill); background: var(--card); color: var(--ink); }
.my-name-row input:focus { border-color: var(--accent); box-shadow: var(--focus); }
.my-name-row input[aria-invalid="true"] { border-color: var(--danger); }

/* ======================================================================
   Shared footer, error pages, skeletons
   ====================================================================== */
.site-foot { border-top: 1px solid var(--line); padding: var(--s6) max(20px, var(--safe-r)) max(var(--s6), var(--safe-b)) max(20px, var(--safe-l)); color: var(--dim); font-size: 14px; }
.site-foot-in { max-width: var(--max); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-foot nav a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--ink-2); font-weight: 600; }
.err-page { min-height: calc(100dvh - var(--topbar-h) - 120px); display: grid; place-items: center; }
.err-card { position: relative; max-width: 620px; text-align: center; padding: 48px 28px; }
.err-code { font-family: var(--font-display); font-weight: 800; font-size: clamp(88px, 18vw, 148px); line-height: 1; letter-spacing: -.05em; color: var(--accent); margin: 0 0 8px; }
.err-card h1 { margin-bottom: 10px; }
.err-card p:not(.err-code) { color: var(--ink-2); margin: 0 auto var(--s5); max-width: 44ch; }
.err-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.skeleton-stack { display: grid; gap: var(--s4); }
.skeleton { border-radius: var(--r-lg); background: linear-gradient(100deg, var(--paper-2) 30%, var(--paper) 50%, var(--paper-2) 70%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton.h-lg { height: 180px; }
.skeleton.h-md { height: 96px; }
@keyframes shimmer { to { background-position: -220% 0; } }

/* ======================================================================
   Reduced motion
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ======================================================================
   Preparation progress by stage (pending course, player waiting state, course map)
   ====================================================================== */
.build-box { width: min(440px, 100%); margin: var(--s4) auto 0; text-align: left; }
.build-box.hidden, .st-start.hidden, .btn[hidden], .typing[hidden] { display: none; }
.build-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.build-pct { font-family: var(--font-display); color: var(--accent-ink); flex: none; }
.build-bar { height: 8px; margin-top: 6px; border-radius: var(--r-pill); background: var(--paper-3); overflow: hidden; }
.build-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur-slow) var(--ease); }
.build-steps { list-style: none; margin: var(--s4) 0 0; padding: 0; display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--dim); }
.build-steps li { display: flex; align-items: center; gap: var(--s2); }
.build-steps li::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-3); }
.build-steps li.st-active { color: var(--ink); font-weight: 700; }
.build-steps li.st-active::before { border-color: var(--accent); background: var(--accent); }
.build-steps li.st-done { color: var(--ok-ink); }
.build-steps li.st-done::before { border-color: var(--ok); background: var(--ok); }
.big-play .build-box { margin: 0; padding: 8px 12px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: var(--r-sm); }
.big-play button.hidden { display: none; }
.build-box.compact { display: block; margin: 8px 0 0; width: 100%; }
.build-box.compact .build-head { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.st-start { margin: 8px 0 0 66px; }
.timeline .chap-pending { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: repeating-linear-gradient(135deg, var(--line-2) 0 5px, var(--paper-2) 5px 10px); border-left: 2px solid var(--card); }
.stage-wrap.immersive .timeline .chap-pending { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .45) 0 5px, rgba(255, 255, 255, .15) 5px 10px); border-left-color: rgba(11, 10, 9, .7); }
.chapter.pending { opacity: .7; }
.chapter.pending .chapter-head { cursor: default; }
@media (max-width: 520px), (max-height: 500px) { .big-play .build-box { padding: 6px 10px; } .big-play p { font-size: 13px; padding: 4px 10px; } }
@media (min-width: 1280px) { .st-start { margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { .build-bar i { transition: none; } }

/* Markdown in chat answers (Edi, the intake chat, example answers): tables and headings. A wide table scrolls
   sideways inside its own box instead of widening the bubble. */
.md-table { max-width: 100%; overflow-x: auto; margin: .5em 0 .7em; -webkit-overflow-scrolling: touch; }
.md-table table { border-collapse: collapse; font-size: .93em; line-height: 1.4; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.md-table th { background: var(--paper-2); font-weight: 700; }
.md-h { margin: .7em 0 .25em; }
