:root{
  color-scheme: dark;
  --bg:#0B1020; --panel:#141B30; --panel2:#101629; --line:#243049;
  --txt:#E8ECF4; --mut:#8B95AD; --pos:#2DD4BF; --neg:#FB7185; --amb:#FBBF24; --vio:#A78BFA; --blu:#60A5FA;
  --display:"Outfit","Avenir Next",system-ui,sans-serif;
  --body:"IBM Plex Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,"SFMono-Regular",Menlo,monospace;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--txt)}
[hidden]{display:none!important}
body{font-family:var(--body);font-size:15px;line-height:1.5}
.wrap{max-width:1320px;margin:0 auto;padding-inline:16px;padding-block:20px 40px}
.top{display:flex;gap:16px;align-items:flex-end;justify-content:space-between;flex-wrap:wrap;margin-bottom:16px}
h1{font-family:var(--display);font-weight:800;font-size:clamp(24px,3.2vw,34px);letter-spacing:-.01em;margin:0}
.sub{color:var(--mut);margin:4px 0 0;max-width:66ch}
.pill{font:600 12px/1 var(--body);letter-spacing:.04em;padding:8px 12px;border-radius:999px;border:1px solid var(--line);color:var(--mut)}
.pill.ready{color:var(--pos);border-color:rgba(45,212,191,.45);background:rgba(45,212,191,.08)}
.pill.busy{color:var(--amb);border-color:rgba(251,191,36,.45)}
.pill.err{color:var(--neg);border-color:rgba(251,113,133,.45)}
.mic-pick{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
.mic-select{font:500 12px/1.2 var(--body);color:var(--mut);background:transparent;border:1px solid var(--line);border-radius:8px;padding:5px 8px;max-width:220px;cursor:pointer}
.mic-select:hover,.mic-select:focus{color:var(--txt);border-color:var(--mut)}
.mic-select option{background:var(--panel,#111);color:var(--txt)}
.grid{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:20px;align-items:start}
@media (max-width:980px){.grid{grid-template-columns:minmax(0,1fr)}}
.stage-card{position:relative;background:var(--panel2);border:1px solid var(--line);border-radius:14px;overflow:hidden}
.board{display:block;width:100%;aspect-ratio:1000/560;border:0;background:var(--panel2)}
.overlay{position:absolute;inset:0;display:flex;flex-direction:column;gap:10px;align-items:center;justify-content:center;background:rgba(11,16,32,.55);backdrop-filter:blur(2px);text-align:center;padding:16px}
.overlay p{margin:0;color:var(--mut);font-size:14px}
.btn{font:600 14px/1 var(--body);color:var(--txt);background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:11px 14px;cursor:pointer;display:inline-flex;gap:8px;align-items:center;transition:background .15s,border-color .15s}
.btn:hover{border-color:#3a4a6e;background:#18213a}
.btn:focus-visible,.chip:focus-visible,.chap button:focus-visible,input:focus-visible{outline:2px solid var(--amb);outline-offset:2px}
.btn.primary{background:var(--amb);border-color:var(--amb);color:#1a1405}
.btn.primary:hover{background:#fcc944}
.btn.big{font-size:17px;padding:14px 22px;border-radius:12px}
.btn[disabled]{opacity:.45;cursor:not-allowed}
.btn.hand{font-size:16px;padding:12px 18px;background:var(--amb);border-color:var(--amb);color:#1a1405}
.btn.hand:hover{background:#fcc944}
.btn.hand.listening{background:var(--pos);border-color:var(--pos)}
.btn.hand svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.btn.hand kbd{font:500 11px var(--mono);border:1px solid rgba(26,20,5,.35);border-radius:4px;padding:2px 5px}
.caption-row{margin-top:12px}
.caption{position:relative;min-height:70px;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:10px 14px;overflow:hidden}
.who{display:inline-block;font:600 11px/1 var(--body);letter-spacing:.08em;text-transform:uppercase;color:var(--mut)}
.who.live{color:var(--vio)} .who.prep{color:var(--pos)} .who.you{color:var(--amb)}
#caption{margin:6px 0 0;font-size:17px;line-height:1.45}
.follow{position:absolute;left:0;right:0;bottom:0;height:3px;background:#0f1528}
.hint{margin:8px 2px 0;font:500 13px/1.4 var(--body);color:var(--mut);opacity:0;transition:opacity .4s ease}
.hint.on{opacity:1}
.follow i{position:absolute;inset:0 auto 0 0;width:100%;background:var(--pos)}
.follow.run i{animation:drain var(--follow-ms,7000ms) linear forwards}
@keyframes drain{to{width:0}}
.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.ask{display:flex;gap:8px;margin-top:12px}
.ask input{flex:1;min-width:0;font:15px var(--body);color:var(--txt);background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:10px 14px}
.ask input::placeholder{color:#6b7591}
.chips{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.chip{font:500 14px/1.2 var(--body);color:var(--txt);background:transparent;border:1px solid var(--line);border-radius:999px;padding:8px 12px;cursor:pointer;display:inline-flex;gap:8px;align-items:center}
.chip:hover{background:var(--panel)}
.tag{font:600 10px/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 6px;border-radius:5px}
.tag.inst{background:rgba(45,212,191,.14);color:var(--pos)}
.tag.live{background:rgba(167,139,250,.16);color:var(--vio)}
.note{color:var(--amb);font-size:14px;margin:10px 0 0}
.side{display:flex;flex-direction:column;gap:16px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 16px}
.card h2,.card summary{font:700 13px/1 var(--body);letter-spacing:.08em;text-transform:uppercase;color:var(--mut);margin:2px 0 12px}
.card summary{cursor:pointer;margin:0}
.muted{color:var(--mut);font-size:14px;margin:0}
.foot{color:var(--mut);font-size:12.5px;margin:12px 0 0;line-height:1.45}
.c-pos{color:var(--pos)}
ol.chap{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
.chap button{width:100%;display:flex;gap:10px;align-items:center;text-align:left;font:500 14px/1.3 var(--body);color:var(--mut);background:transparent;border:0;border-radius:8px;padding:7px 8px;cursor:pointer}
.chap button:hover{background:#18213a;color:var(--txt)}
.chap .n{font:500 12px/1 var(--mono);width:18px;color:#5d6887}
.chap li.cur button{color:var(--txt);background:#1a2340}
.chap li.cur .n{color:var(--amb)}
.lat-rows{display:flex;flex-direction:column;gap:10px}
.lat-q{margin:0 0 2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lrow{display:grid;grid-template-columns:1fr auto;gap:2px 10px;font-size:13px}
.lrow .v{font:500 13px var(--mono);font-variant-numeric:tabular-nums;text-align:right}
.lbar{grid-column:1/3;position:relative;height:6px;background:#0f1528;border-radius:3px;overflow:hidden}
.lbar i{position:absolute;inset:0 auto 0 0;border-radius:3px}
.lbar b{position:absolute;top:-2px;bottom:-2px;width:2px;background:var(--mut);opacity:.7}
ul.hist{list-style:none;margin:12px 0 0;padding:10px 0 0;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:6px}
ul.hist li{display:grid;grid-template-columns:auto 1fr auto;gap:8px;align-items:center;font-size:13px}
ul.hist .q{color:var(--mut);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
ul.hist .t{font:500 12.5px var(--mono);font-variant-numeric:tabular-nums}
.log ol{list-style:none;margin:10px 0 0;padding:0;max-height:260px;overflow:auto;font:12px/1.5 var(--mono);color:var(--mut)}
.log li b{color:var(--txt);font-weight:500}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@media (prefers-reduced-motion: reduce){.btn,.chip{transition:none}.follow.run i{animation:none}}

/* ---------------------------------------------------------------- views */
body[data-view="home"] #lessonView, body[data-view="lesson"] #homeView{display:none}
.brand{all:unset;cursor:pointer}
.brand:focus-visible{outline:2px solid var(--amb);outline-offset:4px;border-radius:4px}

/* ---------------------------------------------------------------- the access card (a private beta) */
.gate{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(11,16,32,.97)}
.gate-card{width:min(420px,100%);display:flex;flex-direction:column;gap:12px;padding:20px}
.card.gate-card #gateHead{font:700 clamp(22px,2.6vw,28px)/1.2 var(--display);letter-spacing:0;text-transform:none;color:var(--txt);margin:0}
.gate-card input{font:17px var(--body);color:var(--txt);background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:14px 16px;min-width:0}
.gate-card input::placeholder{color:#6b7591}
.gate-card .note{margin:0}
.sign-out{padding:6px 10px;font-size:12px}

/* ---------------------------------------------------------------- home */
.home{max-width:860px}
.request{display:flex;flex-direction:column;gap:12px;margin-top:8px}
.big-label{font:700 clamp(22px,2.6vw,30px)/1.2 var(--display)}
.request-row{display:flex;gap:8px}
.request-row input{flex:1;min-width:0;font:17px var(--body);color:var(--txt);background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px}
.request-row input::placeholder{color:#6b7591}
/* the conversation at home */
.talk{display:flex;flex-direction:column;gap:12px;margin:14px 0 6px}
.talk-row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;min-height:52px}
.talk-btn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.talk-live{display:flex;gap:10px 16px;align-items:center;justify-content:space-between;flex-wrap:wrap;width:100%;max-width:640px}
.talk-now{display:flex;gap:12px;align-items:center}
.talk-ctl{display:flex;gap:8px}
.talk-state{font:600 16px/1.2 var(--body)}
.talk-live kbd{font:500 11px var(--mono);border:1px solid var(--line);border-radius:4px;padding:2px 5px;color:var(--mut)}
.btn.quiet{background:transparent}
.orb{width:22px;height:22px;border-radius:50%;flex:none;background:var(--pos);box-shadow:0 0 0 0 rgba(45,212,191,.5)}
.orb[data-state="listening"]{animation:breathe 2.4s ease-in-out infinite}
.orb[data-state="hearing"]{background:var(--amb);transform:scale(calc(1 + var(--lv,0) * .5));transition:transform .08s}
.orb[data-state="thinking"]{background:var(--vio);animation:breathe 1s ease-in-out infinite}
.orb[data-state="speaking"]{background:var(--pos);animation:talk .5s ease-in-out infinite alternate}
.orb[data-state="muted"],.orb[data-state="typing"]{background:#3a4560;animation:none}
.orb[data-state="connecting"]{background:var(--amb);animation:breathe 1s ease-in-out infinite}
@keyframes breathe{0%,100%{box-shadow:0 0 0 0 rgba(45,212,191,.35)}50%{box-shadow:0 0 0 8px rgba(45,212,191,0)}}
@keyframes talk{from{transform:scale(.85)}to{transform:scale(1.12)}}
@media (prefers-reduced-motion:reduce){.orb{animation:none!important;transition:none}}
.home-caption{min-height:0}
.home-caption p{margin:6px 0 0;font-size:17px;line-height:1.45}
.status{color:var(--amb);margin:14px 0 0;font-size:15px}
.status::before{content:"";display:inline-block;width:10px;height:10px;margin-right:10px;border-radius:50%;background:var(--amb);animation:blink 1s ease-in-out infinite alternate;vertical-align:middle}
@keyframes blink{from{opacity:.25}to{opacity:1}}
.intake{margin-top:18px;display:flex;flex-direction:column;gap:12px}
.intake .lead{margin:0;color:var(--mut)}
.q-card{border:1px solid var(--line);border-radius:12px;background:var(--panel);padding:12px 14px 14px;margin:0}
.q-card legend{font:600 16px var(--body);padding:0 4px}
.choices{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0 10px}
.choice{font:500 14px/1.2 var(--body);color:var(--txt);background:transparent;border:1px solid var(--line);border-radius:999px;padding:8px 14px;cursor:pointer}
.choice:hover{background:var(--panel2)}
.choice[aria-pressed="true"]{background:var(--amb);border-color:var(--amb);color:#1a1405}
.choice:focus-visible,.back:focus-visible{outline:2px solid var(--amb);outline-offset:2px}
.own{width:100%;font:14px var(--body);color:var(--txt);background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:8px 12px}
.q-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.guess{color:var(--mut);font-size:13px}
.library{margin-top:34px}
.library h2{font:700 13px/1 var(--body);letter-spacing:.08em;text-transform:uppercase;color:var(--mut);margin:0 0 12px}
.lib{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
.lib-item{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.lib-main{min-width:0;flex:1}
.lib-main h3{margin:0;font:600 16px var(--body)}
.lib-main p{margin:2px 0 0;font-size:13.5px}
.lib-acts{display:flex;gap:6px}
.btn.quiet{background:transparent;color:var(--mut)}

/* ---------------------------------------------------------------- lesson */
.back{all:unset;cursor:pointer;color:var(--mut);font-size:13px;margin-bottom:10px;display:inline-block}
.back:hover{color:var(--txt)}
.lesson-title{font:700 20px/1.25 var(--display)!important;letter-spacing:0!important;text-transform:none!important;color:var(--txt)!important;margin:2px 0 4px!important}
.adapted{color:var(--vio);font-size:13px;margin:8px 0 0}
.chap{margin-top:12px!important}
.chap .t{flex:1}
.chap li.done .n{color:var(--pos)}
.chap li.done .n::after{content:" ✓"}
.chap li.adapted button{color:var(--txt)}
.mic-level{display:inline-flex;gap:3px;align-items:center;height:14px;margin-left:10px;vertical-align:middle;--lv:0}
.mic-level i{display:block;width:4px;border-radius:2px;background:var(--pos);height:calc(4px + var(--lv) * 10px)}
.mic-level i:nth-child(2),.mic-level i:nth-child(4){height:calc(4px + var(--lv) * 14px)}
.mic-level i:nth-child(3){height:calc(4px + var(--lv) * 16px)}

/* ---------------------------------------------------------------- the board bar (like a video player's) and full screen */
.board{pointer-events:none}   /* (nothing on the board is clicked) */
.board-bar{flex:none;height:36px;display:flex;align-items:center;gap:6px;padding:2px 6px;background:rgba(11,16,32,.92);border-top:1px solid var(--line)}   /* (its own row below the board, always shown, on every device: never over the drawing) */
.bar-btn{flex:none;min-width:32px;height:32px;padding:0 8px;font:600 14px/1 var(--body);color:var(--txt);background:transparent;border:1px solid transparent;border-radius:8px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;white-space:nowrap}
.bar-btn:hover{background:rgba(255,255,255,.1)}
.bar-btn:focus-visible{outline:2px solid var(--amb);outline-offset:1px}
.mark:focus-visible{outline:2px solid var(--amb);outline-offset:-3px}   /* (inside the mark: the strip scrolls, so it clips what overflows it) */
.bar-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.bar-btn .leave,.bar-btn[aria-pressed="true"] .enter{display:none}
.bar-btn[aria-pressed="true"] .leave{display:block}
.bar-btn.live{color:#1a1405;background:var(--amb);border-color:var(--amb)}
.bar-btn.live:hover{background:#fcc944}
.bar-btn .short{display:none}
@media (max-width:520px){.bar-btn .long{display:none}.bar-btn .short{display:inline}}   /* (room on a phone: the strip needs it) */
.beat-strip{flex:1;min-width:0;position:relative;display:flex;align-items:center;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}   /* (marks keep 24 px or more: when they do not fit, the strip scrolls) */
.beat-strip::-webkit-scrollbar{display:none}
.mark:first-child{margin-left:auto}.mark:last-child{margin-right:auto}   /* (centred while they fit: auto margins, since centring would cut off the start of a scrolling row) */
.mark{flex:1 0 24px;max-width:32px;height:32px;padding:0;border:0;border-radius:6px;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center}
.mark::before{content:"";width:10px;height:10px;border-radius:50%;background:var(--mut)}
.mark:hover:not(:disabled)::before{background:var(--txt)}
.mark:disabled{cursor:default}
.mark:disabled::before{background:transparent;box-shadow:inset 0 0 0 1.5px var(--mut);opacity:.5}   /* not heard yet: hollow and dim */
.mark.cur::before{width:14px;height:14px;background:var(--amb);box-shadow:0 0 0 3px rgba(251,191,36,.28)}   /* playing now: larger, ringed */

/* full screen (the browser's, or the page expanded where it has none): the board fills the room left by the caption, the
   buttons and its own bar. A lesson written for the 1000 x 560 board is drawn letterboxed inside it, centred, on the board's
   own colour; a board laid out at the frame's real size fills it. */
body.expanded{overflow:hidden}
:is(#stage:fullscreen,body.expanded #stage){position:fixed;inset:0;z-index:50;display:flex;flex-direction:column;gap:10px;padding:12px;background:var(--bg)}
:is(#stage:fullscreen,body.expanded #stage) .stage-card{flex:1;min-height:0;display:flex;flex-direction:column}
:is(#stage:fullscreen,body.expanded #stage) .board{flex:1 1 0;min-height:0;width:100%;height:100%;aspect-ratio:auto;max-height:none}
:is(#stage:fullscreen,body.expanded #stage) .caption-row,:is(#stage:fullscreen,body.expanded #stage) .actions{margin-top:0}
:is(#stage:fullscreen,body.expanded #stage) .caption{min-height:0;padding:8px 14px}
/* (the buttons, the typed question and the note are the stage's too: they keep their room under the caption; on a short screen
   (a phone held sideways) the typed question sits beside the buttons, where it costs the board nothing) */
:is(#stage:fullscreen,body.expanded #stage) .controls{display:flex;flex-direction:column;gap:10px}
:is(#stage:fullscreen,body.expanded #stage) :is(.ask,.note){margin:0}
:is(#stage:fullscreen,body.expanded #stage) .ask input{padding:7px 12px}
:is(#stage:fullscreen,body.expanded #stage) .ask .btn{padding:8px 14px}
@media (max-height:500px){
  :is(#stage:fullscreen,body.expanded #stage) .controls{flex-direction:row;flex-wrap:wrap;align-items:center}
  :is(#stage:fullscreen,body.expanded #stage) .ask{flex:1 1 220px;min-width:0}
}
/* a short, wide screen (a phone held sideways, about 740 x 360) lays the stage out as a row: stacked, the caption, the buttons, the typed
   question and the note left the board 100 to 160 px, a smaller board than the page's own. The card (the board and its bar) takes the
   full height and the remaining width; a column at its right (the width of a phone's thumb reach: 220 to 320 px) holds, top to bottom,
   the caption, the buttons (they wrap in it), the typed question (the column's width) and the note. A long sentence scrolls in its own
   box: it takes what the buttons, the box and the note leave, and never pushes them off the screen. (The stage's padding is 8 px here,
   not 12: the board's frame is the screen's height less the padding, the card's border and its 36 px bar, and 300 px is its worth at 360.) */
@media (max-height:500px) and (orientation:landscape){
  :is(#stage:fullscreen,body.expanded #stage){display:grid;grid-template-columns:minmax(0,1fr) clamp(220px,32vw,320px);grid-template-rows:minmax(0,auto) auto auto 1fr;column-gap:10px;row-gap:0;padding:8px}
  :is(#stage:fullscreen,body.expanded #stage) .stage-card{grid-column:1;grid-row:1 / 5}
  :is(#stage:fullscreen,body.expanded #stage) .caption-row{grid-column:2;grid-row:1;display:flex;flex-direction:column;min-height:0;margin-bottom:10px}
  :is(#stage:fullscreen,body.expanded #stage) .caption{flex:0 1 auto;min-height:0;display:grid;grid-template-columns:auto auto 1fr;grid-template-rows:auto minmax(0,1fr);align-items:center}
  :is(#stage:fullscreen,body.expanded #stage) .caption #caption{grid-column:1 / -1;grid-row:2;align-self:stretch;min-height:0;overflow-y:auto;overscroll-behavior:contain}
  :is(#stage:fullscreen,body.expanded #stage) .controls{grid-column:2;grid-row:2;flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:8px}
  :is(#stage:fullscreen,body.expanded #stage) .ask{flex:none}
  :is(#stage:fullscreen,body.expanded #stage) .note{grid-column:2;grid-row:3;margin-top:8px}
}

/* a board laid out at the frame's real size (a "v2" chapter, marked on the card by the page) has a taller area on a phone held upright:
   the shape of the smallest standard screen, 360 x 560, not a wide picture */
@media (max-width:600px) and (orientation:portrait){
  .stage-card.v2 .board{aspect-ratio:360/560;max-height:78vh}
}
