/* MwalimuAI design system -- one small stylesheet shared by the learner
   portal, the lesson room and the tutor studio. No web fonts, no framework:
   it has to load fast on an entry-level phone over a slow link.
   Light + dark via tokens; every colour below comes from one. */

:root {
  color-scheme: light;
  --ink: #16324f;          /* brand navy */
  --ink-2: #0e2338;
  --on-ink: #ffffff;
  --accent: #d98f1f;       /* marigold */
  --accent-ink: #231500;
  --accent-soft: #fbefd9;
  --bg: #f7f5f0;           /* warm paper */
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --surface-3: #e9e6dd;
  --text: #1d2430;
  --text-2: #5b6472;
  --line: #e4e0d6;
  --line-2: #d3cec1;
  --ok: #1e7d34;   --ok-bg: #e3f4e7;
  --warn: #9a6300; --warn-bg: #fff2dc;
  --bad: #b3261e;  --bad-bg: #fde8e7;
  --info-bg: #e6eef7;
  --face-bg: #cfe0ef;
  --shadow-sm: 0 1px 2px rgba(22, 50, 79, .06);
  --shadow: 0 1px 2px rgba(22, 50, 79, .05), 0 8px 24px rgba(22, 50, 79, .07);
  --shadow-lg: 0 2px 4px rgba(22, 50, 79, .06), 0 18px 48px rgba(22, 50, 79, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;             /* minimum touch target */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #9cc3e6; --ink-2: #c6ddf2; --on-ink: #0d1722;
    --accent: #f0b252; --accent-ink: #231500; --accent-soft: #3a2d17;
    --bg: #11161d; --surface: #19202a; --surface-2: #212a36; --surface-3: #2a3442;
    --text: #e7ebf0; --text-2: #a3adba; --line: #2c3644; --line-2: #3a4657;
    --ok: #7fd49a; --ok-bg: #173323; --warn: #f0c070; --warn-bg: #3a2d17;
    --bad: #f39b94; --bad-bg: #3d1d1b; --info-bg: #1d2c3d; --face-bg: #2b4560;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 48px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; }
a { color: var(--ink); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); color: var(--text); line-height: 1.2; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1rem; }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* -- top bar ------------------------------------------------------------ */
.topbar { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); font-family: var(--serif); font-weight: 700; font-size: 1.2rem; margin-right: auto; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--ink), var(--ink-2)); color: var(--on-ink);
  display: grid; place-items: center; font: 700 1.05rem var(--serif); box-shadow: inset 0 -3px 0 var(--accent); }
.nav { display: flex; gap: .15rem; align-items: center; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--text-2); text-decoration: none; font-size: .93rem; font-weight: 500; padding: .45rem .8rem; border-radius: 999px; white-space: nowrap; transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--info-bg); font-weight: 650; }
.nav form { margin: 0 0 0 .35rem; }
.studio-note { background: var(--accent-soft); color: var(--warn); font: 700 .68rem var(--sans); text-transform: uppercase; letter-spacing: .07em; padding: .2rem .55rem; border-radius: 999px; }

/* -- layout -------------------------------------------------------------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.75rem 16px 3rem; }
.wrap.narrow { max-width: 760px; }
.wrap.room-wrap { max-width: 1040px; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.footer { color: var(--text-2); font-size: .82rem; text-align: center; padding: 1.5rem 16px 2rem; border-top: 1px solid var(--line); }
.footer a { color: var(--text-2); }

/* -- hero + page heads ------------------------------------------------------ */
.hero { background: radial-gradient(120% 140% at 0% 0%, var(--ink) 0%, var(--ink-2) 70%); color: #fff; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -6rem; top: -6rem; width: 22rem; height: 22rem; border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 143, 31, .28), transparent 65%); pointer-events: none; }
.hero .wrap { padding-top: 2.75rem; padding-bottom: 3rem; position: relative; z-index: 1; display: flex; gap: 2rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hero h1 { color: #fff; max-width: 20ch; font-size: clamp(1.9rem, 5vw, 2.7rem); }
.hero p { color: #d3e1ee; max-width: 52ch; font-size: 1.05rem; }
.hero .eyebrow { color: #f0b252; }
.hero .btn.secondary { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .3); }
.hero .btn.secondary:hover { background: rgba(255, 255, 255, .18); border-color: #fff; }
.hero-tutors { display: flex; flex-direction: column; gap: .6rem; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius); padding: 1rem 1.15rem; min-width: min(100%, 250px); }
.hero-tutors .label { font: 700 .7rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: #f0b252; }
.hero-tutor { display: flex; align-items: center; gap: .7rem; color: #fff; }
.hero-tutor .name { font-weight: 650; line-height: 1.2; }
.hero-tutor .bio { font-size: .8rem; color: #c3d3e2; line-height: 1.25; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: radial-gradient(120% 140% at 0% 0%, #16324f, #0b1420 70%); } }
.eyebrow { font: 700 .72rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: .4rem; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1, .page-head h2 { margin-bottom: .35rem; }
.page-head p { color: var(--text-2); max-width: 62ch; margin-bottom: 0; }
.page-head p + .row, .page-head p + .btn { margin-top: 1rem; }
.page-head .title-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--text-2); margin-bottom: .75rem; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { opacity: .5; }

/* -- cards ----------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.35rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.card h2, .card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flat { box-shadow: none; }
.card.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); box-shadow: none; background: transparent; }
a.card { display: block; text-decoration: none; color: inherit; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: var(--shadow-lg); }
.course-card { display: flex; flex-direction: column; gap: .5rem; }
.course-card .meta { color: var(--text-2); font-size: .85rem; margin-top: auto; padding-top: .5rem; }
.course-card .cover { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--ink)); margin-bottom: .5rem; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat .num { font: 600 2rem/1.1 var(--serif); color: var(--text); }
.stat .sub { color: var(--text-2); font-size: .85rem; }

/* numbered lesson list */
.lesson-list { list-style: none; margin: 0; padding: 0; counter-reset: lesson; }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-list a { counter-increment: lesson; display: flex; align-items: center; gap: 1rem; padding: .85rem .25rem; min-height: var(--tap); text-decoration: none; color: var(--text); border-radius: 8px; }
.lesson-list a::before { content: counter(lesson); flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font: 700 .9rem var(--serif); transition: background .15s, color .15s; }
.lesson-list a:hover::before { background: var(--ink); color: var(--on-ink); }
.lesson-list .title { flex: 1; font-weight: 600; }
.lesson-list .go { color: var(--text-2); font-size: .85rem; white-space: nowrap; transition: transform .15s, color .15s; }
.lesson-list a:hover .go { color: var(--ink); transform: translateX(3px); }

/* -- tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; margin: 0 -.35rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
th { color: var(--text-2); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* -- badges ------------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--text-2); }
.badge.accent { background: var(--accent-soft); color: var(--warn); }
.badge.busy { background: var(--info-bg); color: var(--ink); }
.badge.busy::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }

/* -- forms ------------------------------------------------------------------- */
label { display: block; margin-bottom: .95rem; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=number], textarea, select {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: .97rem; margin-top: .3rem; min-height: var(--tap);
  transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--text-2) 70%, transparent); }
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--info-bg); }
select { width: auto; max-width: 100%; }
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: .85rem; }
input[type=file] { font: inherit; font-size: .9rem; margin-top: .3rem; max-width: 100%; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); flex: none; }
.hint { color: var(--text-2); font-size: .82rem; font-weight: 400; }
label .hint { display: block; margin-top: .15rem; }
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.fields.tight { grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .25rem; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form select, .inline-form input { margin-top: 0; }
.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 400; background: var(--surface-2); border-radius: var(--radius-sm); padding: .8rem .9rem; }
.check input { margin-top: .2rem; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; background: var(--ink); color: var(--on-ink);
  border: 1px solid transparent; padding: .6rem 1.15rem; border-radius: 999px; cursor: pointer; min-height: 40px;
  font: 600 .92rem var(--sans); text-decoration: none; line-height: 1.2; white-space: nowrap;
  transition: filter .15s, background .15s, border-color .15s, transform .08s; -webkit-tap-highlight-color: transparent; }
button:hover, .btn:hover { filter: brightness(1.12); }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-2); }
button.secondary:hover, .btn.secondary:hover { border-color: var(--ink); filter: none; }
button.accent, .btn.accent { background: var(--accent); color: var(--accent-ink); }
button.danger, .btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
button.danger:hover, .btn.danger:hover { background: var(--bad); color: #fff; filter: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--text-2); border-color: transparent; padding-inline: .7rem; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); filter: none; }
button.small, .btn.small { padding: .35rem .8rem; font-size: .82rem; min-height: 32px; }
button.large, .btn.large { padding: .85rem 1.9rem; font-size: 1.02rem; min-height: 52px; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
button.is-busy { cursor: progress; opacity: .85; }
button.is-busy::before, .spinner { content: ""; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; flex: none; display: inline-block; }
.icon-btn { width: var(--tap); height: var(--tap); padding: 0; border-radius: 50%; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* -- feedback ------------------------------------------------------------------ */
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .92rem; background: var(--info-bg); color: var(--ink); border-left: 4px solid var(--ink); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.empty { text-align: center; color: var(--text-2); padding: 2.5rem 1rem; }
.empty .btn { margin-top: .75rem; }
.muted { color: var(--text-2); font-size: .87rem; }
pre.log { background: #10141a; color: #d6f0d6; padding: .9rem 1rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .8rem; white-space: pre-wrap; margin: 1rem 0 0; }
a.id-link { text-decoration: none; color: var(--ink); font-weight: 600; }
a.id-link:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
details > summary { cursor: pointer; font-weight: 600; color: var(--text-2); font-size: .9rem; padding: .25rem 0; }
details[open] > summary { margin-bottom: .75rem; }
.plain-list { margin: 0 0 1rem; padding-left: 1.2rem; }
.plain-list li { margin-bottom: .35rem; }

/* -- avatar: the tutor's face, wherever the tutor speaks ------------------------ */
.avatar { --size: 40px; position: relative; display: inline-block; flex: none; width: var(--size); height: var(--size);
  border-radius: 50%; background: var(--face-bg); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2); isolation: isolate; }
.avatar-inner { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; display: block; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; max-width: none; display: block; }
.avatar img.face { inset: auto; height: auto; object-fit: fill; }  /* cropped to the face: width/left/top set inline */
.avatar svg.face-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.avatar-xs { --size: 28px; } .avatar-sm { --size: 36px; } .avatar-md { --size: 44px; } .avatar-lg { --size: 72px; } .avatar-xl { --size: 120px; }
.avatar-lg, .avatar-xl { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.face-svg .f-bg { fill: var(--face-bg); }
.face-svg .f-eyes, .face-svg .f-mouth { fill: var(--ink-2); }
.face-svg .f-cheek { fill: var(--accent); opacity: .28; }
.face-svg .f-smile { stroke: var(--ink-2); fill: none; stroke-width: 5; stroke-linecap: round; }
.face-svg .f-eyes { transform-origin: 50px 43px; animation: blink 5.5s infinite; }
.face-svg .f-mouth { transform-origin: 50px 66px; opacity: 0; }
.speaking .face-svg .f-smile { opacity: 0; }
.speaking .face-svg .f-mouth { opacity: 1; animation: mouth-flap 220ms ease-in-out infinite alternate; }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes mouth-flap { from { transform: scaleY(.25); } to { transform: scaleY(1); } }
/* speaking: a marigold ring breathes, and a small equaliser sits on the rim */
.avatar.speaking { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); animation: ring 1.4s ease-out infinite; }
.avatar .eq { position: absolute; right: -4px; bottom: -4px; z-index: 2; display: none; align-items: flex-end; justify-content: center; gap: 2px;
  width: 18px; height: 18px; padding: 4px 3px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.avatar.speaking .eq { display: flex; }
.avatar .eq i { width: 2px; background: var(--accent-ink); border-radius: 2px; height: 30%; animation: eq .7s ease-in-out infinite alternate; }
.avatar .eq i:nth-child(2) { animation-delay: -.35s; } .avatar .eq i:nth-child(3) { animation-delay: -.55s; }
@keyframes eq { from { height: 25%; } to { height: 100%; } }
@keyframes ring { 0% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent), 0 0 0 12px transparent; } }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -10px; }

/* -- conversation: tutor responses carry the tutor's avatar ----------------------- */
.chat { display: flex; flex-direction: column; gap: .3rem; }
.msg { display: flex; gap: .6rem; align-items: flex-start; max-width: 100%; animation: rise .22s ease-out both; }
.msg + .msg { margin-top: .55rem; }
.msg.grouped { margin-top: 0; }
.msg-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; max-width: min(88%, 38rem); }
.msg-who { font-size: .76rem; font-weight: 650; color: var(--text-2); padding-left: .2rem; display: flex; gap: .4rem; align-items: center; }
.msg.grouped .msg-who { display: none; }
.msg.grouped > .avatar { visibility: hidden; }
.msg.grouped.speaking > .avatar { visibility: visible; }
.bubble { padding: .7rem .95rem; border-radius: 18px; font-size: .97rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg.tutor .bubble { background: var(--surface-2); border: 1px solid var(--line); border-top-left-radius: 6px; transition: border-color .2s, box-shadow .2s, background .2s; }
.msg.tutor.speaking .bubble { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.msg.learner { justify-content: flex-end; }
.msg.learner .msg-body { align-items: flex-end; }
.msg.learner .bubble { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 6px; }
.msg.error .bubble { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.bubble .text { white-space: pre-wrap; }
.bubble .question { margin-top: .55rem; padding-top: .55rem; border-top: 1px dashed var(--line-2); font-weight: 650; }
.bubble .badges { margin-top: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.bubble .word { transition: background-color 120ms ease, color 120ms ease; border-radius: 4px; padding: 0 1px; margin: 0 -1px; }
.bubble .word-read { color: var(--text-2); }
.bubble .word-current { background: var(--accent); color: var(--accent-ink); }
.msg.tutor .msg-body { position: relative; }
/* "listen again": beside the bubble, so it costs no height between responses */
.msg-tools { position: absolute; left: 100%; bottom: .1rem; margin-left: .2rem; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: .75; } }
.msg-tools button { background: none; border: none; color: var(--text-2); padding: 0; width: 32px; height: 32px; min-height: 0; border-radius: 50%; }
.msg-tools button:hover { background: var(--surface-2); color: var(--ink); filter: none; }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 1.5em; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); animation: typing 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.composer { display: flex; gap: .5rem; align-items: center; padding: .75rem; background: var(--surface); border-top: 1px solid var(--line); }
.composer input[type=text] { flex: 1; margin: 0; border-radius: 999px; padding: .7rem 1.1rem; min-width: 0; background: var(--surface-2); border-color: transparent; }
.composer input[type=text]:focus { background: var(--surface); border-color: var(--ink); }
.composer.hidden { display: none; }
.mic-btn { background: var(--surface-2); color: var(--ink); }
.mic-btn.listening { background: var(--bad); color: #fff; animation: ring-bad 1.2s ease-out infinite; }
@keyframes ring-bad { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 50%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }

/* -- lesson room (learner player + studio preview) ------------------------------- */
.gate { text-align: center; padding: 2.5rem 1.25rem 2rem; display: flex; flex-direction: column; align-items: center; }
.gate h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); margin: .2rem 0 .35rem; max-width: 24ch; }
.gate .lede { color: var(--text-2); margin: 0 0 1.5rem; max-width: 44ch; }
.gate .avatar-xl { margin-bottom: 1.1rem; }
.gate-section { width: 100%; max-width: 34rem; margin-bottom: 1.4rem; }
.gate-section h2 { font: 700 .72rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--text-2); margin: 0 0 .65rem; }
.resumed-note { background: var(--info-bg); color: var(--ink); border-radius: 999px; padding: .4rem .9rem; font-size: .85rem; display: inline-block; margin: 0 0 1rem; }
.learner-code-note { font-size: .8rem; color: var(--text-2); margin: 1.25rem 0 0; max-width: 40ch; }
.tutor-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .65rem; }
.tutor-card { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .45rem; padding: .9rem .6rem .8rem; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: normal; min-height: 0; line-height: 1.25; }
.tutor-card:hover { border-color: var(--line-2); filter: none; background: var(--surface-2); }
.tutor-card[aria-pressed="true"] { border-color: var(--ink); background: var(--info-bg); color: var(--ink); }
.tutor-card[aria-pressed="true"] .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.tutor-card .tutor-bio { font-weight: 400; font-size: .76rem; color: var(--text-2); }
.avatar-picker { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }
.avatar-choice { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; margin: 0; border: 1.5px solid var(--line-2); border-radius: 999px;
  font-size: .86rem; font-weight: 500; cursor: pointer; color: var(--text-2); background: var(--surface); min-height: 40px; transition: border-color .15s, background .15s; }
.avatar-choice:hover { border-color: var(--ink); }
.avatar-choice:has(input:checked) { border-color: var(--ink); background: var(--info-bg); color: var(--ink); font-weight: 650; }
.avatar-choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.avatar-choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.room { display: none; }
.room.show { display: grid; grid-template-columns: minmax(0, 1fr); }
.room-card { padding: 0; overflow: hidden; }
.room-side { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1.25rem 1rem 1rem; text-align: center;
  background: linear-gradient(180deg, var(--info-bg), var(--surface)); border-bottom: 1px solid var(--line); }
.side-text { display: flex; flex-direction: column; align-items: center; gap: .45rem; min-width: 0; }
.stage-name { font: 600 1.05rem var(--serif); line-height: 1.2; }
.stage-bio { font-size: .8rem; color: var(--text-2); margin-top: -.3rem; }
.status-pill { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 650; padding: .25rem .75rem; border-radius: 999px; background: var(--surface); color: var(--text-2); border: 1px solid var(--line); }
.status-pill .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--line-2); }
.status-pill[data-state="speaking"] { color: var(--warn); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--accent-soft); }
.status-pill[data-state="speaking"] .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.status-pill[data-state="thinking"] .dot { background: var(--ink); animation: pulse 1s ease-in-out infinite; }
.status-pill[data-state="turn"] { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.status-pill[data-state="turn"] .dot { background: var(--ok); }
.status-pill[data-state="done"] { color: var(--ok); }
.status-pill[data-state="done"] .dot { background: var(--ok); }
.avatar-source { display: inline-block; padding: .12rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: .72rem; font-weight: 600; }
.avatar-note { font-size: .76rem; color: var(--text-2); max-width: 26ch; }
.avatar-note:empty { display: none; }

.avatar-stage { flex: none; width: 112px; height: 112px; border-radius: 50%; overflow: hidden; background: var(--face-bg); position: relative;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--line-2), var(--shadow); transition: box-shadow .25s, width .25s, height .25s; }
.avatar-stage video, .avatar-stage svg, .avatar-stage .avatar-3d, .avatar-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar-stage svg { display: block; }
.avatar-stage video, .avatar-stage .avatar-3d, .avatar-stage canvas { display: none; }
.avatar-stage video { object-fit: cover; }
.avatar-stage.large { width: min(200px, 48vw); height: min(200px, 48vw); }
.avatar-stage.photo-live svg, .avatar-stage.video-live svg, .avatar-stage.talkinghead-live svg { display: none; }
.avatar-stage.photo-live canvas { display: block; }
.avatar-stage.video-live video { display: block; }
.avatar-stage.talkinghead-live .avatar-3d { display: block; }
.avatar-stage.speaking { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--accent), 0 0 0 14px var(--accent-soft), var(--shadow); }

.room-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.room-head { display: flex; align-items: flex-start; gap: .75rem; padding: .9rem 1.1rem .8rem; border-bottom: 1px solid var(--line); }
.room-progress { flex: 1; min-width: 0; }
.obj-count { font: 700 .7rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.obj-text { font-weight: 600; font-size: .95rem; line-height: 1.35; margin: .1rem 0 .55rem; }
progress.play-progress { display: block; width: 100%; height: 6px; border: none; border-radius: 99px; overflow: hidden; background: var(--surface-3); appearance: none; -webkit-appearance: none; }
progress.play-progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
progress.play-progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--ink)); border-radius: 99px; transition: width .5s ease; }
progress.play-progress::-moz-progress-bar { background: var(--ink); border-radius: 99px; }
.bookmark-btn { background: var(--surface); color: var(--text-2); border-color: var(--line-2); width: 40px; height: 40px; }
.bookmark-btn:hover { color: var(--ink); border-color: var(--ink); filter: none; }
.bookmark-btn.saved { background: var(--accent-soft); color: var(--warn); border-color: var(--accent); }
.bookmark-btn.saved .icon { fill: currentColor; }
.room .chat { padding: 1.1rem; overflow-y: auto; flex: 1; min-height: 14rem; max-height: 52vh; max-height: 52dvh; scroll-behavior: smooth; overscroll-behavior: contain; }
.completion-card { display: none; padding: 1.5rem 1.25rem; text-align: center; border-top: 1px solid var(--line); background: var(--ok-bg); }
.completion-card.show { display: block; }
.completion-card h2 { color: var(--ok); margin-bottom: .25rem; }
.completion-card p { color: var(--text-2); margin-bottom: 1rem; }
.completion-card .tick { width: 3rem; height: 3rem; border-radius: 50%; background: var(--ok); color: var(--ok-bg); display: inline-grid; place-items: center; margin-bottom: .6rem; }
.completion-card .tick .icon { width: 1.5rem; height: 1.5rem; stroke-width: 3; }
.error-card { padding: 2.5rem 1.5rem; text-align: center; }

@media (min-width: 860px) {
  .room.show { grid-template-columns: 290px minmax(0, 1fr); height: calc(100vh - 8.5rem); height: calc(100dvh - 8.5rem); min-height: 30rem; max-height: 52rem; }
  .room-side { border-bottom: none; border-right: 1px solid var(--line); justify-content: center; padding: 1.5rem 1.25rem; gap: .65rem; }
  .avatar-stage { width: 148px; height: 148px; }
  .avatar-stage.large { width: 220px; height: 220px; }
  .room .chat { max-height: none; padding: 1.25rem 1.4rem; }
  .stage-name { font-size: 1.2rem; }
}
/* studio preview: a compact room (voice only, with the grounding badges) */
.room.preview.show { grid-template-columns: minmax(0, 1fr); height: auto; max-height: none; min-height: 0; }
.room.preview .chat { max-height: 56vh; max-height: 56dvh; }

/* -- ask ------------------------------------------------------------------------- */
.ask-box { display: flex; flex-direction: column; gap: .75rem; }
.ask-box textarea { min-height: 5.5rem; font-size: 1.02rem; margin-top: 0; }
.ask-thread { margin: 1.25rem 0; }
.ask-thread .msg { animation: none; }
.ask-thread .msg-body { max-width: 100%; }
.ask-thread .msg.tutor .msg-body { flex: 1; }
.answer .body { font-size: 1.05rem; line-height: 1.6; white-space: pre-wrap; }
.answer .lead { font-size: .8rem; color: var(--text-2); margin-bottom: .35rem; }
.ask-thread .msg.tutor .bubble.answer { background: var(--surface); border-left: 4px solid var(--accent); box-shadow: var(--shadow-sm); }
.more-sources { margin-top: .9rem; }
.more-sources:target, .more-sources:has(:target) { }
a.cite { text-decoration: none; font-weight: 700; color: var(--ink); background: var(--info-bg); border-radius: 5px; padding: 0 .25em; margin-left: 1px; }
a.cite sup { font-size: .72em; vertical-align: .25em; line-height: 0; }
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.sources li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .75rem .9rem; font-size: .9rem; color: var(--text-2); scroll-margin-top: 5rem; }
.sources li:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sources .src { font-weight: 600; color: var(--ink); font-size: .84rem; margin-bottom: .25rem; display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.sources li.cited { box-shadow: inset 3px 0 0 var(--accent); }
.sources .n { background: var(--ink); color: var(--on-ink); border-radius: 6px; padding: 0 .4rem; font-size: .75rem; }

/* -- materials + bookmarks ------------------------------------------------------- */
.doc { display: flex; gap: 1rem; align-items: center; }
.doc-icon { flex: none; width: 44px; height: 52px; border-radius: 8px; background: var(--accent-soft); color: var(--warn); display: grid; place-items: center; font: 700 .7rem var(--sans); text-transform: uppercase; }
.doc .info { flex: 1; min-width: 0; }
.doc .info h3 { margin: 0 0 .1rem; overflow-wrap: anywhere; }
.bookmark-row { display: flex; align-items: center; justify-content: space-between; padding: .8rem 0; border-bottom: 1px solid var(--line); gap: .75rem; }
.bookmark-row:first-child { padding-top: 0; } .bookmark-row:last-child { border-bottom: none; padding-bottom: 0; }
.bookmark-row a { color: var(--ink); font-weight: 600; text-decoration: none; }
.bookmark-row a:hover { text-decoration: underline; }
.code-chip { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: 8px; padding: .25rem .6rem; user-select: all; }

/* -- studio: steps, cluster activity, uploads --------------------------------------- */
.steps { display: flex; gap: .4rem; list-style: none; margin: 0 0 1.25rem; padding: 0; flex-wrap: wrap; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: .5rem; padding: .4rem .85rem .4rem .45rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .86rem; font-weight: 600; color: var(--text-2); }
.steps li::before { content: counter(step); width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .78rem; }
.steps li.done { color: var(--ok); } .steps li.done::before { content: "✓"; background: var(--ok-bg); }
.steps li.current { color: var(--ink); border-color: var(--ink); background: var(--info-bg); } .steps li.current::before { background: var(--ink); color: var(--on-ink); }
.steps a { color: inherit; text-decoration: none; }
.step-num { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--ink); color: var(--on-ink); font: 700 .85rem var(--sans); margin-right: .5rem; vertical-align: .1em; }

.job { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.1rem; background: var(--surface-2); margin: .5rem 0 1rem; }
.job[data-tone="busy"] { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); background: var(--info-bg); }
.job[data-tone="ok"] { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-bg); }
.job[data-tone="bad"] { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-bg); }
.job[data-tone="warn"] { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-bg); }
.job-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-weight: 650; }
.job-head .elapsed { font-weight: 500; color: var(--text-2); font-size: .85rem; font-variant-numeric: tabular-nums; margin-left: auto; }
.job-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--line-2); flex: none; }
[data-tone="busy"] .job-dot { background: var(--ink); animation: pulse 1.1s ease-in-out infinite; }
[data-tone="ok"] .job-dot { background: var(--ok); } [data-tone="bad"] .job-dot { background: var(--bad); } [data-tone="warn"] .job-dot { background: var(--warn); }
.job-detail { margin: .35rem 0 0; font-size: .9rem; color: var(--text-2); }
.job-steps { list-style: none; display: flex; margin: .9rem 0 .2rem; padding: 0; }
.job-steps li { flex: 1; text-align: center; font-size: .74rem; font-weight: 650; color: var(--text-2); position: relative; padding-top: 1.35rem; }
.job-steps li::before { content: ""; position: absolute; top: .25rem; left: 50%; width: .8rem; height: .8rem; margin-left: -.4rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); z-index: 1; }
.job-steps li::after { content: ""; position: absolute; top: .58rem; left: -50%; width: 100%; height: 2px; background: var(--line-2); }
.job-steps li:first-child::after { display: none; }
.job-steps li.done { color: var(--text); } .job-steps li.done::before { background: var(--ok); border-color: var(--ok); } .job-steps li.done::after, .job-steps li.current::after, .job-steps li.failed::after { background: var(--ok); }
.job-steps li.current { color: var(--ink); } .job-steps li.current::before { border-color: var(--ink); background: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 22%, transparent); animation: pulse 1.1s ease-in-out infinite; }
.job-steps li.failed { color: var(--bad); } .job-steps li.failed::before { border-color: var(--bad); background: var(--bad); }
.meter { margin-top: .7rem; }
.meter-label { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; margin-bottom: .25rem; font-variant-numeric: tabular-nums; }
.meter-label span:last-child { color: var(--text-2); font-weight: 500; }
.meter progress, progress.bar { display: block; width: 100%; height: 8px; border: none; border-radius: 99px; overflow: hidden; background: var(--surface); appearance: none; -webkit-appearance: none; }
.meter progress::-webkit-progress-bar, progress.bar::-webkit-progress-bar { background: var(--surface); border-radius: 99px; }
.meter progress::-webkit-progress-value, progress.bar::-webkit-progress-value { background: var(--ink); border-radius: 99px; transition: width .6s ease; }
.meter progress::-moz-progress-bar, progress.bar::-moz-progress-bar { background: var(--ink); border-radius: 99px; }
.job-foot { display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; margin: .85rem 0 0; font-size: .8rem; color: var(--text-2); }
.job-foot .spinner { width: .8em; height: .8em; }
.job-error { margin: .6rem 0 0; font-size: .9rem; color: var(--bad); }
.job-list { display: grid; gap: .6rem; }
.job-list .job { margin: 0; }
.job-list .job-link { display: block; text-decoration: none; color: inherit; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin-bottom: .4rem; }
.job-list .job-link:hover { color: var(--ink); }

.drops { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); margin-bottom: 1rem; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem; margin: 0; padding: 1.25rem .9rem 1rem;
  border: 2px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; font-weight: 400; transition: border-color .15s, background .15s; min-height: 11.5rem; }
.drop:hover, .drop.over { border-color: var(--ink); background: var(--info-bg); }
.drop:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--info-bg); }
.drop.filled { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; }
.drop .drop-icon { width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--surface); color: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.drop .drop-icon .icon { width: 1.3rem; height: 1.3rem; }
.drop .drop-title { font-weight: 700; font-size: .98rem; }
.drop .drop-req { font: 700 .66rem var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--warn); }
.drop .drop-req.optional { color: var(--text-2); }
.drop .drop-hint { font-size: .8rem; color: var(--text-2); line-height: 1.35; }
.drop .drop-file { font-size: .82rem; font-weight: 650; color: var(--ok); overflow-wrap: anywhere; }
.drop .drop-preview { width: 100%; max-height: 9rem; border-radius: 8px; object-fit: contain; position: relative; z-index: 1; background: #000; }
.drop audio.drop-preview { background: none; height: 2.2rem; }
.drop img.drop-preview { width: 6rem; height: 6rem; border-radius: 50%; object-fit: cover; background: none; pointer-events: none; }
.upload-progress { margin: .25rem 0 1rem; }
.checklist { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); font-size: .88rem; color: var(--text-2); }
.checklist li { display: flex; gap: .5rem; align-items: flex-start; }
.checklist li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: none; }

.tutor-tile { display: flex; flex-direction: column; gap: .75rem; }
.tutor-tile .who { display: flex; gap: .85rem; align-items: center; }
.tutor-tile .who h3 { margin: 0; }
.tutor-tile .counts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; font-size: .82rem; color: var(--text-2); }
.tutor-tile .counts strong { display: block; font: 600 1.25rem var(--serif); color: var(--text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
.media-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-top: 1rem; }
.media-row video { max-width: min(100%, 22rem); border-radius: var(--radius-sm); }
.sheet { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }
.login-card { max-width: 380px; margin: 8vh auto 0; }

@media (max-width: 560px) {
  .topbar-inner { gap: .35rem .5rem; padding: .5rem 12px; }
  .brand { font-size: 1.05rem; }
  .nav { margin: 0 -12px; padding: 0 12px; width: calc(100% + 24px); max-width: none; }
  .nav a { padding: .4rem .7rem; font-size: .88rem; }
  .wrap { padding: 1.25rem 12px 2.5rem; }
  .wrap.room-wrap { padding: .75rem 8px 1rem; }
  .card { padding: 1rem; border-radius: 14px; }
  .room-card { padding: 0; }
  .hero .wrap { padding-top: 2rem; padding-bottom: 2.25rem; }
  .room-side { flex-direction: row; text-align: left; align-items: center; gap: .85rem; padding: .85rem 1rem; }
  .room-side .side-text { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; min-width: 0; }
  .avatar-stage { width: 72px; height: 72px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }
  .avatar-stage.large { width: 116px; height: 116px; }
  .avatar-stage.speaking { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent), 0 0 0 9px var(--accent-soft); }
  .stage-bio { margin-top: 0; }
  .room .chat { padding: .9rem .75rem; }
  .msg-body { max-width: calc(100% - 5.2rem); }
  .msg.learner .msg-body { max-width: 86%; }
  .composer { padding: .6rem; }
  /* Once a lesson starts, the room is the whole screen: the tutor stays in
     view at the top, the conversation scrolls in the middle, the answer bar
     stays at the bottom. */
  body.lesson-live { height: 100vh; height: 100dvh; overflow: hidden; }
  body.lesson-live .nav { display: none; }
  body.lesson-live main { display: flex; flex-direction: column; min-height: 0; }
  body.lesson-live .room-card { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }
  body.lesson-live .room.show { flex: 1; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  body.lesson-live .room .chat { max-height: none; min-height: 0; }
  .job-steps li { font-size: .68rem; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Songs (song_detail.html): the melody bar by bar, and each tutor's take. */
.song-sheet { width: 100%; height: 70vh; margin-top: .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); object-fit: contain; }
.song-bars { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.song-bar { display: flex; gap: .15rem; align-items: stretch; padding: .3rem .45rem; border-left: 2px solid var(--line); }
.song-bar-no { font-size: .7rem; color: var(--text-2); margin-right: .2rem; }
.song-note { display: flex; flex-direction: column; align-items: center; min-width: 2.2rem; padding: .15rem .25rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.song-note .syl { font-weight: 600; }
.song-note .pitch { font-size: .72rem; color: var(--text-2); }
.song-note.hold { background: transparent; }
.song-note.hold .syl { color: var(--text-2); font-weight: 400; }
.song-singers { display: grid; gap: 1rem; }
.song-singer { border-top: 1px solid var(--line); padding-top: 1rem; }
.song-singer .job { margin-top: .75rem; }
.song-video { display: block; width: min(100%, 28rem); margin-top: .75rem; border-radius: var(--radius-sm); }
.song-voices { display: grid; gap: .5rem; margin-top: 1rem; }
.song-voice { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .85rem; }
.song-voice summary { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; cursor: pointer; }
.song-voice-name { min-width: 5.5rem; }
.song-choir { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; }
.song-video.wide { width: min(100%, 48rem); }

/* -- authoring: lesson builder, new lesson, courses (editor.js) ------------------ */
.section-title { margin: 1.5rem 0 .75rem; }
.section-head { margin: 1.5rem 0 .75rem; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg a { padding: .4rem 1rem; border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .88rem; }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
details.card > summary { color: var(--text); font-size: 1rem; }

.choices { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 1rem; }
.choice { position: relative; display: flex; flex-direction: column; gap: .3rem; margin: 0; padding: 1rem 1.1rem; border: 1.5px solid var(--line-2);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 400; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice:hover { border-color: var(--ink); }
.choice:has(input:checked) { border-color: var(--ink); background: var(--info-bg); box-shadow: var(--shadow); }
.choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice-icon { width: 2.2rem; height: 2.2rem; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); }
.choice:has(input:checked) .choice-icon { background: var(--ink); color: var(--on-ink); }
.choice-title { font-weight: 650; color: var(--text); }
.choice-text { font-size: .85rem; color: var(--text-2); }

.ob-guide { margin: 0 0 1rem; padding: 0 .25rem; }
.ob { scroll-margin-top: 5rem; }
.ob-head, .sec-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.ob-head { margin-bottom: .85rem; }
.ob-head h2 { margin: 0; display: flex; align-items: center; }
.tools { display: inline-flex; gap: .15rem; }
.tools button { min-height: 32px; padding: .25rem .6rem; }
.tools button:disabled { opacity: .3; }
.secs { display: flex; flex-direction: column; gap: .75rem; }
.sec { --kind: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--kind); border-radius: var(--radius-sm); padding: .75rem .9rem .5rem; background: var(--surface-2); }
.sec[data-kind="example"] { --kind: var(--ok); }
.sec[data-kind="misconception"] { --kind: var(--bad); }
.sec[data-kind="question"] { --kind: var(--accent); }
.sec label { margin-bottom: .5rem; }
.sec-kind { margin: 0 !important; }
.sec-kind select { width: auto; min-width: 11rem; margin: 0; padding-block: .4rem; font-weight: 600; color: var(--kind); background-color: var(--surface); }
.sec .kind-hint { margin: .35rem 0 .5rem; }
.sec textarea { min-height: 6.5rem; resize: vertical; background: var(--surface); }
.sec input[type=text] { background: var(--surface); font-weight: 600; }
.sec-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; min-height: 2rem; }
.wc { font-size: .78rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.wc.short { color: var(--bad); } .wc.long { color: var(--warn); } .wc.good { color: var(--ok); }
.video-pick { display: inline-flex; align-items: center; gap: .4rem; margin: 0 !important; color: var(--text-2); }
.video-pick select { width: auto; margin: 0; padding-block: .3rem; font-size: .85rem; }
.add-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .85rem; padding-top: .85rem; border-top: 1px dashed var(--line-2); }
.add-objective { display: flex; justify-content: center; padding: .5rem 0 1rem; }
.add-objective button { border-style: dashed; padding-inline: 1.6rem; }
.save-bar { --gutter: 16px; position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: 1rem calc(-1 * var(--gutter)) 0; padding: .75rem var(--gutter); background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.card .save-bar { margin: 1rem -1.35rem -1.25rem; padding-inline: 1.35rem; border-radius: 0 0 var(--radius) var(--radius); }
.save-state { margin-right: auto; }

.course-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.course-card h3 { margin: 0; }
.course-card p { margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ready-bar { display: block; height: 4px; border-radius: 99px; background: var(--surface-3); margin-top: .45rem; overflow: hidden; }
.ready-bar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.ok-text { color: var(--ok); font-weight: 600; } .warn-text { color: var(--warn); font-weight: 600; }

.course-lessons { list-style: none; margin: 0 0 1rem; padding: 0; }
.course-lessons li { display: flex; align-items: center; gap: .85rem; padding: .7rem .25rem; }
.course-lessons li + li { border-top: 1px solid var(--line); }
.course-lessons .num { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font: 700 .9rem var(--serif); }
.course-lessons .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.course-lessons .title { font-weight: 650; text-decoration: none; color: var(--text); }
.course-lessons .title:hover { text-decoration: underline; }
.add-lesson { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding-top: .85rem; border-top: 1px dashed var(--line-2); }
.add-lesson select { flex: 1; min-width: min(100%, 16rem); width: auto; margin: 0; }

.filter-box { margin: 0 0 .85rem; }
.num-col { text-align: right; }
.lesson-table td.row { display: table-cell; }
.lesson-table td.row .badge { margin: 0 .2rem .2rem 0; }
.fields select, label > select { width: 100%; display: block; }
.sec-kind select, .video-pick select, .inline-form select { width: auto; display: inline-block; }
a.badge { text-decoration: none; } a.badge:hover { filter: brightness(.96); text-decoration: underline; }
@media (max-width: 560px) { .save-bar { --gutter: 12px; } }

/* -- learner accounts (accounts.py) ------------------------------------------------ */
.auth-wrap { max-width: 460px; }
.auth-card { padding: 2rem 1.75rem; margin-top: 1.5rem; }
.auth-card h1 { font-size: 1.7rem; }
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; font-size: 1.5rem; margin-bottom: 1rem; }
.auth-switch { text-align: center; margin: 1.25rem 0 .5rem; }
.center { text-align: center; }
button.wide, .btn.wide { width: 100%; margin-top: .5rem; }
.nav a.who { color: var(--ink); font-weight: 650; }
.course-progress { margin: .5rem 0 1rem; max-width: 32rem; }
.ready-bar.big { height: 8px; }
.enrol-card { margin-top: 1rem; background: var(--info-bg); border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.lesson-list a.locked { cursor: default; color: var(--text-2); }
.lesson-list a.locked::before { background: var(--surface-3); color: var(--text-2); }
.lesson-list .badge .icon { width: .9em; height: .9em; }

/* -- studio: students + rosters ------------------------------------------------------ */
.choices.compact { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: .5rem; margin-bottom: .75rem; }
.choices.compact .choice { padding: .65rem .85rem; }
.enrol-settings { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px dashed var(--line-2); }
.key-input { width: 12rem !important; font-family: var(--mono); margin: 0; }
.grid.stats.mini { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.grid.stats.mini .stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.grid.stats.mini .num { font-size: 1.5rem; }
.funnel { margin: 0 0 1rem; }
.funnel-table td, .funnel-table th { padding: .4rem .5rem; font-size: .88rem; }
.bar-col { width: 30%; }
.duo-bar { position: relative; display: block; height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.duo-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.duo-bar i.s { background: color-mix(in srgb, var(--ink) 35%, transparent); }
.duo-bar i.f { background: var(--ok); }
.prog-cell { min-width: 12rem; }
.prog-cell .ready-bar { margin: .3rem 0; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-3); }
.dots i.in-progress { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.dots i.finished { background: var(--ok); }
.big-code { font-size: 1.05rem; padding: .2em .5em; }
.transcript { display: flex; flex-direction: column; gap: .85rem; }
.t-msg { max-width: 85%; padding: .65rem .9rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.t-msg.learner { align-self: flex-end; background: var(--info-bg); }
.t-who { font-size: .78rem; font-weight: 700; color: var(--text-2); margin-bottom: .2rem; display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.t-text { white-space: pre-wrap; }
.add-lesson input[type=email] { flex: 1; width: auto; min-width: min(100%, 16rem); margin: 0; }

/* rating fields under a check question / misconception (lesson_edit.html) */
.rating { display: none; margin: .25rem 0 .5rem; padding: .6rem .75rem .1rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--kind) 8%, var(--surface)); border: 1px dashed color-mix(in srgb, var(--kind) 40%, var(--line)); }
.sec[data-kind="question"] .rating-question, .sec[data-kind="misconception"] .rating-misconception { display: block; }
.rating label { font-size: .85rem; }
.rating input[type=text] { font-weight: 500 !important; }

/* lesson room: rated answers + raising a hand (learn.js) */
.bubble .rating-badge { display: inline-flex; align-items: center; gap: .3rem; margin-top: .5rem; padding: .15rem .65rem;
  border-radius: 999px; font-size: .78rem; font-weight: 700; }
.rating-badge.correct { background: var(--ok-bg); color: var(--ok); }
.rating-badge.partially_correct { background: var(--warn-bg); color: var(--warn); }
.rating-badge.incorrect { background: var(--bad-bg); color: var(--bad); }
.score-line { font-weight: 650; color: var(--ink); }
.hand-btn { flex: none; min-height: var(--tap); padding: 0 .9rem; border-radius: 999px; background: var(--surface-2);
  color: var(--text); border: 1px solid var(--line-2); font-weight: 650; }
.hand-btn:hover { border-color: var(--ink); filter: none; }
.hand-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hand-btn.resume { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.msg.tutor.aside .bubble { border-style: dashed; }
.msg.learner.aside .bubble::before { content: "Question · "; font-weight: 700; opacity: .7; }
.status-pill[data-state="listening"] { background: var(--accent-soft); color: var(--warn); }
.status-pill[data-state="listening"] .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@media (max-width: 560px) { .hand-btn .hand-label { display: none; } .hand-btn { padding: 0 .7rem; } }
.t-msg.aside { border: 1px dashed var(--line-2); }
.tutor-tile.inactive .avatar { filter: grayscale(1); opacity: .7; }
.tutor-switch { margin-top: .5rem; }
.bubble .aside-note { margin-top: .45rem; font-size: .82rem; font-style: italic; color: var(--text-2); }
.mic-btn.unavailable { opacity: .45; }
.mic-btn.listening { animation: pulse 1s ease-in-out infinite; }
.gate .hands-free { max-width: 26rem; margin: 0 auto 1rem; text-align: left; font-size: .9rem; }
.tools .move-to { width: auto; min-height: 32px; margin: 0 0 0 .25rem; padding: .2rem .5rem; font-size: .8rem; }
