/* The page shell, loaded after studio.css: the slide is the hero (the cards are drawn on it),
   «دفتر الشرح» is a header button that opens the notebook review page.
   Everything here styles existing ids/classes; controllers keep setting
   hidden / aria-pressed / disabled on them. The v2 tokens (--ink, --pastel-*, …)
   belong to studio.css's :root (v2/look): they are used with fallbacks, never set here. */

/* ---------- shell tokens ---------- */
:root{
  --desk:#f4efe8;--sheet:#fffdf9;--line-warm:#e6ded3;--quiet:#f6f1ec;--accent-hover:#571947;
  --switch-off:#8b8289;
  --mic-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='13' rx='3'/%3E%3Cpath d='M5 10a7 7 0 0 0 14 0M12 17v5m-3 0h6'/%3E%3C/svg%3E"); /* the tray switch's off track: 3.7:1 on the tray's white (WCAG 1.4.11) */
  --font-ui:"Board UI","Readex Pro","Noto Sans Arabic Variable",system-ui,sans-serif;
  --font-hand:"Board Hand","Board UI","Noto Sans Arabic Variable",system-ui,sans-serif;
  --e1:0 0 0 1px var(--line-warm);
  --e2:0 2px 4px #3a2a2a0d,0 14px 36px -12px #3a2a2a2e;
  --e3:0 10px 30px -10px #3a2a2a40,0 2px 6px #3a2a2a14;
  --e4:0 24px 48px -16px #3a2a2a55,0 2px 8px #3a2a2a18;
  --ease-out:cubic-bezier(.23,1,.32,1);
}

/* ---------- the desk ---------- */
body{font-family:var(--font-ui);color:var(--ink,#30333a);
  background:radial-gradient(1200px 700px at 100% -10%,var(--glow-a) 0%,transparent 60%),radial-gradient(900px 700px at -10% 110%,var(--glow-b) 0%,transparent 60%),var(--desk)}
body::before{content:"";position:fixed;inset:0;pointer-events:none;z-index:0;opacity:var(--grain,.35);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .25 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")}
button,select,input{font-family:inherit}
.icon{width:20px;height:20px;stroke-width:1.8}
:is(button,select,input,summary,a):focus-visible{outline:3px solid var(--accent);outline-offset:2px}
@media(prefers-reduced-motion:no-preference){button:active:not(:disabled){transform:scale(.97);transition:transform .1s var(--ease-out)}}

/* ---------- header: logo + paging on the start side, «فتح ملف» + settings on the end ---------- */
header{position:relative;z-index:4;height:52px;flex:none;padding:0 16px;gap:12px;justify-content:flex-start;background:transparent;border:0}
h1{font-size:24px;font-weight:700;line-height:1.3;gap:10px;white-space:nowrap}
.wave{border:0;padding:0;height:22px;gap:3px}.wave i{height:9px}.wave i:nth-child(2){height:20px}.wave i:nth-child(3){height:15px}.wave i:nth-child(4){height:11px}
header .paging{gap:2px;padding:3px;border-radius:999px;background:color-mix(in srgb,var(--surface) 70%,transparent);border:1px solid var(--line-warm);font-size:14px;font-weight:500;color:var(--sub)}
header .paging button,#newPage{min-height:34px;min-width:34px;width:34px;height:34px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--ink,#30333a)}
header .paging button:hover:not(:disabled){background:var(--soft)}
header .paging .icon{width:18px;height:18px}
header .pagePicker{min-height:34px;border-radius:999px}
header .pagePicker:focus-within{outline:3px solid var(--accent);outline-offset:2px;border-radius:999px}
#page{min-width:56px;padding:0 4px;color:var(--ink,#30333a);font-variant-numeric:tabular-nums}
#newPage span{display:none}
.headerActions{margin-inline-start:auto;gap:4px}
#upload,#viewTools{min-height:40px;height:40px;border:0;background:transparent;border-radius:12px;font-size:14px;font-weight:500;padding:0 14px;color:var(--ink,#30333a)}
#viewTools{width:40px;min-width:40px;padding:0}#viewTools span{display:none}
#upload:hover:not(:disabled),#viewTools:hover{background:color-mix(in srgb,var(--surface) 70%,transparent)}
#viewTools[aria-expanded=true]{background:var(--soft);color:var(--accent)}
/* «دفتر الشرح»: a quiet pill; its count (#notebookCount, empty: no badge) comes when a slide's cards gather in it */
#notebookOpen{min-height:40px;height:40px;gap:8px;padding:0;padding-inline:14px 10px;border:1px solid var(--line-warm);border-radius:999px;background:color-mix(in srgb,var(--surface) 72%,transparent);color:var(--ink,#30333a);font-size:14px;font-weight:500;white-space:nowrap}
#notebookOpen .icon{color:var(--accent)}
#notebookOpen:hover{background:var(--surface)}
#notebookOpen[aria-expanded=true]{background:var(--soft);border-color:var(--accent)}
#notebookCount{min-width:22px;height:22px;padding-inline:6px;border-radius:11px;background:var(--accent);color:var(--on-accent);font-size:13px;font-weight:600;line-height:22px;text-align:center;font-variant-numeric:tabular-nums}
#notebookCount:empty{display:none}
#notebookOpen:has(#notebookCount:empty){padding-inline-end:14px}
/* the topic tabs (threads.js) sit between the paging and the actions, and scroll inside */
header>#threads{flex:1 1 auto;min-width:0;padding:0}
#threads .chip{background:var(--surface);border-color:var(--line-warm)}
#threads .chip button{min-height:32px;padding-block:2px;padding-inline:10px;font-size:13px;font-weight:500}
#threads .close{padding-block:2px;padding-inline:4px 8px}
/* The home has its own choices: no paging, no notebook and no second «فتح ملف» there. */
body:has(#empty:not([hidden])) :is(header .paging,#upload,#notebookOpen){visibility:hidden}

/* ---------- the stage: the slide fills it (placed by stage.js placeInk); the cards are drawn on it ---------- */
main{position:relative;display:block;flex:1;min-height:0;padding:0;gap:0;z-index:1;overflow:hidden}
#stage{position:absolute;inset:0;width:auto;max-width:none}
/* the zoomed scene never makes the page scrollable: it is cut at the stage (and at the frame, by placeInk's clip-path) */
#viewport{z-index:1;overflow:hidden}
#slide{border-radius:6px;box-shadow:var(--e2);background:#fff}

/* «نص الشريحة»: a sheet over the stage's inline-end side (a bottom sheet on a phone), so the slide keeps its size */
main>#reading{position:absolute;z-index:3;inset-block:8px;align-self:stretch;inset-inline-end:16px;width:min(400px,calc(100% - 32px));max-height:none;
  margin:0;padding:16px 20px;border:0;border-radius:16px;background:var(--surface);box-shadow:var(--e4)}
#reading h2{font-size:13px;font-weight:600;margin-bottom:8px}
#readingText{font-size:17px;line-height:1.8}

/* ---------- focus: the camera only zooms in, inside the slide's own frame ---------- */
#stage.focused{display:block}
.focused #viewport{position:absolute;inset:0;width:auto;height:auto;min-height:0;overflow:hidden;background:none;border-radius:0;box-shadow:none}
.focused #focusText{position:absolute;z-index:2;width:auto;border:0;border-radius:0 0 6px 6px;background:color-mix(in srgb,var(--sheet) 92%,transparent);box-shadow:0 -1px 0 var(--line-warm)}
/* placeInk's data-place: inside the frame's bottom (default), its top when the target is low, or under the slide where the stage has room */
.focused #focusText[data-place=top]{border-radius:6px 6px 0 0;box-shadow:0 1px 0 var(--line-warm)}
.focused #focusText[data-place=under]{border-radius:12px;background:var(--sheet);box-shadow:var(--e1),var(--e2)}
#focusText #caption{max-height:calc(4.5em + 16px);padding:8px 16px;font-size:clamp(15px,1.5vw,19px);line-height:1.5;text-align:center}
@media(prefers-reduced-motion:no-preference){.focused:not(.silent) #scene{transition:transform .2s var(--ease-out)}
  /* a lesson starting or ending: the slide moves once, smoothly, to keep the room beside it (stage.js placeInk) */
  #stage.reflow :is(#slide,#ink,#studentInk){transition:left .35s var(--ease-out),top .35s var(--ease-out),width .35s var(--ease-out),height .35s var(--ease-out)}}

/* ---------- footer: fixed rows, so nothing that comes and goes resizes the slide ---------- */
footer{position:relative;z-index:4;flex:none;width:100%;max-width:none;margin:0;padding:0 16px max(8px,env(safe-area-inset-bottom));
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:40px 64px 18px;grid-template-areas:"a" "dock" "line";row-gap:6px;justify-items:center}
footer>#caption,footer>#selection,footer>#gotIt,footer>#nextSteps,footer>.shareChips{grid-area:a;align-self:end;max-width:min(860px,100%)}
footer>.dock{grid-area:dock}
footer>.sessionLine{grid-area:line}
/* row A shows one thing at a time: the selection, then «تخطّى الباقي», then the next steps,
   the screen-share chips stay at its edge; the caption is the subtitle, it moves up over the desk
   when one of those takes the row. */
footer:has(>#selection:not([hidden]))>:is(#gotIt,#nextSteps){visibility:hidden}
footer:has(>#gotIt:not([hidden]))>#nextSteps{visibility:hidden}
footer:is(:has(>#selection:not([hidden])),:has(>#gotIt:not([hidden])),:has(>#nextSteps:not([hidden])))>#caption{transform:translateY(calc(-100% + -10px))}
/* the screen-share chips (a desktop browser only) keep the row's start edge, beside whatever is centred */
footer>.shareChips{justify-self:start}

footer>#caption{width:fit-content;margin:0;max-height:calc(3em + 10px);overflow:auto;padding:5px 16px;border-radius:20px;background:color-mix(in srgb,var(--surface) 95%,transparent);color:var(--ink,#30333a);
  box-shadow:var(--e1),0 6px 16px -8px #3a2a2a40;font-size:15px;font-weight:500;line-height:1.5;text-align:center;text-wrap:pretty}
#selection{display:flex;align-items:center;gap:6px;min-width:0;padding-block:3px;padding-inline:14px 4px;border-radius:999px;background:var(--ink,#30333a);color:var(--on-ink);font-size:14px;box-shadow:var(--e3)}
#selectionLabel{min-width:0;max-width:40ch;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
#askSelection{min-height:32px;height:32px;padding:0 14px;border:0;border-radius:999px;background:var(--on-ink);color:var(--ink,#30333a);font-size:13px;font-weight:600;white-space:nowrap}
#clearSelection{min-height:32px;min-width:32px;width:32px;height:32px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--on-ink)}
#clearSelection:hover{background:color-mix(in srgb,var(--on-ink) 15%,transparent)!important}#clearSelection .icon{width:16px;height:16px}
#gotIt,#nextSteps button,.shareChips button{min-height:34px;height:34px;padding:0 14px;border-radius:999px;border:1px solid var(--line-warm);background:color-mix(in srgb,var(--surface) 94%,transparent);font-size:14px;font-weight:500;white-space:nowrap;gap:6px}
#nextSlide{border-color:var(--accent)!important;color:var(--accent);background:var(--soft)!important}
#nextSteps{width:100%;justify-content:center;gap:6px;padding:0}
.shareChips{display:flex;gap:6px}.shareChips .icon{width:17px;height:17px}

/* ---------- the dock: one primary action, the question, the mic, «أدوات أكثر» ---------- */
.dock{width:min(760px,100%);height:64px;padding:8px;gap:8px;border:0;border-radius:22px;background:var(--surface);box-shadow:var(--e3)}
.dock button{border:0}
#study{flex:none;height:48px;min-height:48px;padding:0 22px;gap:10px;border-radius:16px;font-size:15px;font-weight:600;white-space:nowrap}
#study::before{content:"";width:11px;height:12px;background:currentColor;clip-path:polygon(0 0,100% 50%,0 100%);flex:none}
#study[aria-pressed=true]::before{width:11px;height:11px;border-radius:2px;clip-path:none}
#study:disabled{opacity:1;background:var(--disabled-bg);color:var(--disabled-ink)}
#ask{flex:1;min-width:0;height:48px;padding:0 4px;gap:4px;border:0;border-radius:16px;background:var(--quiet)}
#q{height:100%;padding:0 12px;font-size:15px}
#q::placeholder{color:var(--placeholder)}
#ask button{min-height:40px;min-width:40px;width:40px;height:40px;padding:0;border-radius:12px;color:var(--accent)}
#ask button:hover{background:color-mix(in srgb,var(--surface) 70%,transparent)}
#mic{flex:none;width:48px;height:48px;min-width:48px;padding:0;border-radius:50%;background:var(--soft);color:var(--accent);box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 8%,transparent)}
#mic[aria-pressed=true],#mic.on{background:var(--accent);color:var(--on-accent);box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 20%,transparent)}
#ptt{flex:none;height:48px;padding:0 16px;border-radius:16px;background:var(--soft);color:var(--accent);font-size:14px;white-space:nowrap}
#ptt.on{background:var(--accent);color:var(--on-accent)}
#stop{flex:none;width:48px;height:48px;min-width:48px;padding:0;border-radius:12px;background:var(--quiet);color:var(--ink,#30333a)}
#stop:disabled{display:none}
#stop .icon{width:18px;height:18px}
#more{flex:none;width:44px;height:48px;min-width:44px;padding:0;border-radius:12px;background:transparent;color:var(--ink,#30333a)}
#more .icon circle{fill:currentColor}
#more[aria-expanded=true]{background:var(--soft);color:var(--accent)}
.dock button:hover:not(:disabled):not(.primary):not(#mic[aria-pressed=true]){background:var(--soft)}
.dock .primary:hover:not(:disabled){background:var(--accent-hover)}

.sessionLine{min-height:18px;height:18px;gap:8px;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;max-width:100%;overflow:visible}
#claimHeard{min-height:22px;height:22px;padding:0 10px;font-size:12px}
/* pacing's speed control (pacing.css) sits in the line's flow here, beside the status: the line is only as wide as
   what it holds, so an absolute dock at its end would cover the status. On a phone it stays clear of the dock above. */
.sessionLine #speedDock{position:static;transform:none;flex:none}
@media(max-width:640px){.sessionLine #speedDock button{min-height:22px}}

/* ---------- the tray (#more): grows from the dock's end; Esc / outside click closes it ---------- */
footer>#tray{position:absolute;z-index:6;bottom:calc(max(8px,env(safe-area-inset-bottom)) + 18px + 6px + 64px + 8px);inset-inline-end:max(16px,calc(50% - 380px));
  width:340px;max-height:calc(100dvh - 190px);overflow:auto;display:flex;flex-direction:column;gap:2px;padding:10px;border-radius:20px;background:var(--surface);box-shadow:var(--e4)}
#tray:not([data-open]){visibility:hidden}
@keyframes trayIn{from{opacity:0}}
@media(prefers-reduced-motion:no-preference){#tray[data-open]{animation:trayIn .16s var(--ease-out)}}
.trayLabel{margin:8px 10px 2px;font-size:13px;font-weight:600;color:var(--sub)}
.trayLabel:first-child{margin-top:2px}
.trayLabel:not(:first-child){border-top:1px solid var(--rule);padding-top:10px}
.trayRows{display:flex;flex-direction:column;gap:2px}
#tray .switch,#tray .depth{display:flex;align-items:center;justify-content:flex-start;gap:12px;width:100%;min-height:44px;height:44px;padding:0 10px;border:0;border-radius:12px;background:transparent;color:var(--ink,#30333a);font-size:15px;font-weight:400;text-align:start}
#tray .switch .icon,#tray .depth .icon{color:var(--sub)}
#tray .switch:hover:not(:disabled),#tray .depth:hover{background:var(--quiet)}
#tray .switch::after{content:"";margin-inline-start:auto;flex:none;width:36px;height:22px;border-radius:999px;transition:background-color .16s var(--ease-out);
  background:radial-gradient(circle at calc(100% - 11px) 50%,var(--knob,#fff) 7.5px,transparent 8px),var(--switch-off)}
#tray .switch[aria-pressed=true]{color:var(--ink,#30333a);background:transparent}
#tray .switch[aria-pressed=true]::after{background:radial-gradient(circle at 11px 50%,var(--on-accent) 7.5px,transparent 8px),var(--accent)}
#tray .switch:disabled{opacity:.45}
#tray .depth{cursor:default}
#tray .depth select{margin-inline-start:auto;width:auto;height:34px;padding:0 12px;border:1px solid var(--line-warm);border-radius:999px;background:var(--quiet);font-size:14px;color:var(--ink,#30333a)}
.trayGrid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;padding:2px 2px 4px}
.trayGrid .penTools{display:contents}
.trayGrid button{flex-direction:column;gap:4px;min-height:66px;min-width:0;padding:8px 2px;border:0;border-radius:12px;background:transparent;color:var(--ink,#30333a);font-size:12px;font-weight:500;line-height:1.3;text-align:center}
.trayGrid button .icon{width:22px;height:22px;color:var(--accent)}
.trayGrid button:hover:not(:disabled){background:var(--quiet)}
.trayGrid button:is(.on,[aria-pressed=true]){background:var(--soft);color:var(--accent);border:0}
/* While the student draws or erases, the pen tools stay on the slide (its bottom inline-end corner), tray closed or open.
   The eraser hides #pen and shows #clearAll in its place (stage.js). */
.trayGrid .penTools:has(#pen.on,#penClear[aria-pressed=true]){visibility:visible;position:fixed;z-index:7;top:calc(var(--slide-t,72px) + var(--slide-h,300px) - 58px);left:calc(var(--slide-l,16px) + 10px);
  display:flex;gap:4px;padding:4px;border-radius:999px;background:var(--surface);box-shadow:var(--e4)}
.penTools:has(#pen.on,#penClear[aria-pressed=true]) button{min-height:40px;width:40px;height:40px;padding:0;border-radius:999px}
.penTools:has(#pen.on,#penClear[aria-pressed=true]) button span{display:none}

/* ---------- the home (#empty; the three choices are v2/topic's .homeChoices) ---------- */
#empty{gap:10px;padding:16px;text-align:center;overflow:auto}
#empty strong{font-size:40px;font-weight:600;line-height:1.3}
#empty>span{font-size:17px;color:var(--sub)}
#empty>#emptyOpen{min-height:48px;margin-top:14px;padding:0 24px;border:0;border-radius:16px;background:var(--accent);color:var(--on-accent)}
.homeChoices{grid-template-columns:repeat(3,minmax(0,240px));gap:16px;margin-top:22px}
.homeChoices button{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;gap:6px;min-height:168px;padding:20px;text-align:start;
  border:1px solid var(--surface);border-radius:20px;background:var(--surface);color:var(--ink,#30333a);box-shadow:var(--e2)}
.homeChoices button:hover{background:var(--surface);box-shadow:0 0 0 1px var(--line-warm),var(--e2)}
.homeChoices .icon{width:48px;height:48px;padding:11px;margin-bottom:10px;border-radius:12px;background:var(--soft);color:var(--accent)}
.homeChoices b{font-size:18px;font-weight:600;line-height:1.4}
.homeChoices small{font-size:14px;color:var(--sub);line-height:1.55}
.homeChoices #homeTopic{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.homeChoices #homeTopic:hover{background:var(--accent-hover)}
.homeChoices #homeTopic .icon{background:color-mix(in srgb,var(--on-accent) 15%,transparent);color:var(--on-accent)}
.homeChoices #homeTopic small{color:color-mix(in srgb,var(--on-accent) 85%,transparent)}

/* ---------- «دفتر الشرح»: the review page (#notebook, route #notebook), over the lesson under the header ---------- */
.notebook{position:fixed;z-index:50;top:60px;inset-inline:16px;bottom:14px;display:flex;flex-direction:column;overflow:hidden;border-radius:18px;color:var(--ink,#30333a);
  background:radial-gradient(var(--dots) 1px,transparent 1.2px) 11px 11px/22px 22px,var(--sheet);box-shadow:0 1px 0 color-mix(in srgb,var(--surface) 60%,transparent) inset,0 2px 6px #3a2a2a12,0 40px 90px -30px #3a2a2a66}
.notebookHead{display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding-block:16px 12px;padding-inline:26px;border-bottom:1px solid var(--line-warm);background:color-mix(in srgb,var(--sheet) 90%,transparent)}
.notebookTitle{flex:1;min-width:0}
.notebookKick{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--sub)}
.notebookKick .icon{width:16px;height:16px;color:var(--accent)}
.notebookHead h2{margin-top:2px;font:600 24px/1.3 var(--font-hand)}
.notebookActions{display:flex;gap:8px}
#notebookBack,#notebookSave{min-height:40px;height:40px;gap:8px;padding-inline:16px;border-radius:999px;font-size:14px;font-weight:500;white-space:nowrap}
#notebookBack .icon,#notebookSave .icon{width:17px;height:17px}
#notebookBack{border:1px solid var(--line-warm);background:var(--surface);color:var(--ink,#30333a)}
#notebookSave{border:0;background:var(--accent);color:var(--on-accent)}
#notebookSave:hover:not(:disabled){background:var(--accent-hover)}
#notebookSave:disabled{opacity:1;background:var(--disabled-bg);color:var(--disabled-ink)}
.notebookPages{flex:1;min-height:0;overflow:auto;padding-block:20px 6px;padding-inline:26px}
.notebookPages:empty{display:none}
.notebookEmpty{margin:auto;padding:24px;max-width:36ch;font-size:15px;line-height:1.7;color:var(--sub);text-align:center}
.notebookPages:not(:empty)~.notebookEmpty{display:none}
.notebookStatus{font-size:13px;color:var(--sub)}.notebookStatus:empty{display:none}
/* the pages (src/app/notebook.js): a page per slide, the slide (its pointing, numbered) beside its tidy cards */
.nbPage{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);align-items:start;gap:14px 28px;padding-block:4px 28px}
.nbPage+.nbPage{border-top:1px dashed var(--line-warm);padding-block-start:22px}
.nbPageHead{grid-column:1/-1;margin:0;font:600 21px/1.35 var(--font-hand);overflow-wrap:anywhere}
.nbPageHead small{font:400 14px/1 var(--font-ui);color:var(--sub,#625b67);margin-inline-start:10px;white-space:nowrap}
.nbSlide{margin:0;display:flex;flex-direction:column;gap:16px;position:sticky;top:0}
.nbSheet{position:relative;background:#fff;border-radius:8px;overflow:hidden;box-shadow:0 0 0 1px #3a2a2a12,0 12px 30px -14px #3a2a2a4d}
.nbSheet img,.nbSheet svg{position:absolute;inset:0;width:100%;height:100%;display:block}.nbSheet svg{overflow:visible}
/* dark slides: the notebook shows the slide as the stage does (studio.css), its cards dark (pieceSvg) */
.dark-slides .nbSheet{background:#1b1b1b}.dark-slides .nbSheet img{filter:invert(.9) hue-rotate(180deg) brightness(1.05)}
.nbLegend{list-style:none;margin:0;padding:0;padding-inline:4px;display:flex;flex-direction:column;gap:10px}
.nbLegend li{display:flex;gap:10px;align-items:flex-start;font-size:15px;line-height:1.6;color:var(--sub)}.nbLegend b{color:var(--ink,#30333a);font-weight:600;margin-inline-end:4px}
.nbBadge{flex:none;display:inline-grid;place-items:center;width:24px;height:24px;border-radius:50%;background:var(--c,var(--accent));color:#fff;font:600 13px/1 var(--font-ui);box-shadow:0 0 0 2px var(--sheet)}
.nbCards{display:flex;flex-direction:column;gap:18px;min-width:0}
.nbNote{position:relative;min-width:0}
.nbNote>.nbBadge{position:absolute;top:-9px;inset-inline-start:-7px;z-index:1}
.nbNote>svg{display:block;width:100%;height:auto;overflow:visible}
.nbSay{margin:8px 4px 0;padding-block-start:6px;border-top:1px dashed var(--dash)}
.nbSay p{margin:0 0 4px;font:400 15px/1.8 var(--font-ui);color:var(--ink,#30333a);overflow-wrap:anywhere}
.nbLtr{unicode-bidi:isolate}.nbLtr.keep{white-space:nowrap;overflow-wrap:normal}
header .paging[inert]{opacity:.4}
.nbNote.text .nbSay{margin:0;padding-block:10px;padding-inline:14px;border:1px dashed var(--dash);border-radius:12px;background:var(--paper)}
/* a gathered card on its way into the header's button; the button glows as it lands */
.nbFlyer{position:fixed;z-index:8;pointer-events:none;transform-origin:0 0}.nbFlyer svg{display:block;width:100%;height:100%;overflow:visible}
#notebookOpen.glow{background:var(--surface);box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 12%,transparent),0 6px 18px -8px color-mix(in srgb,var(--accent) 40%,transparent);transition:box-shadow .5s,background .5s}
@media(max-width:760px){.nbPage{grid-template-columns:minmax(0,1fr);gap:14px 20px}.nbSlide{position:static}}
/* the lesson waits behind the page (its controllers keep running) */
body:has(#notebook:not([hidden])) :is(main,footer,.notices){visibility:hidden}

/* ---------- notices (NoticeStack.vue): the file message floats under the header; what stays up is a row above the stage ---------- */
.toasts{position:fixed;z-index:60;top:60px;left:12px;right:12px;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}
.toasts>*{max-width:min(640px,100%)}
.toasts button{pointer-events:auto}
/* a slide that failed to load, the mode bar, «نكمل من وين وقفنا؟» and the presence notices push the stage down: they never cover the slide */
.notices{position:relative;z-index:3;flex:none;display:flex;flex-direction:column;align-items:center;gap:6px;padding-block:2px 6px;padding-inline:12px}
.notices:not(:has(>:not([hidden]))){display:none}
.notices>*{max-width:min(640px,100%)}
:is(.toasts,.notices)>:is(#fileStatus,#slideProblem,#sessionResume,#attention,#paused,#modeBar){position:static;inset:auto;margin:0;width:fit-content;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 10px;
  padding-block:7px;padding-inline:16px 8px;border-radius:20px;font-size:14px;font-weight:500;line-height:1.5;text-align:start;background:var(--surface);color:var(--ink,#30333a);border:1px solid var(--notice-line);box-shadow:var(--e4)}
.notices>:is(#slideProblem,#sessionResume,#attention,#paused,#modeBar){box-shadow:var(--e2)}
.toasts>#fileStatus{padding-inline-end:16px}
.toasts>#fileStatus.error,.notices>#slideProblem{background:var(--pastel-coral,#fde3e1);color:var(--err-ink);border-color:var(--err-line)}
.notices>#attention{background:var(--pastel-butter,#fff6cc);color:var(--warn-ink);border-color:var(--warn-line)}
.notices>#modeBar{background:var(--pastel-green,#ddf1e5);color:var(--ok-ink);border-color:var(--ok-line)}
:is(.toasts,.notices) button,.notices :is(#sessionResume,#attention,#paused) button{min-height:36px;height:36px;padding:0 14px!important;border-radius:999px;border:1px solid var(--line-warm)!important;background:var(--surface);color:var(--ink,#30333a)!important;font-size:13px;font-weight:600}
:is(.toasts,.notices) :is(#sessionContinue,#resumeHere,#stillHere,#retrySlide,#modeDone){border-color:var(--accent)!important;background:var(--accent);color:var(--on-accent)!important}
.notices #closePaused{width:36px;min-width:36px;padding:0!important;border:0!important;background:transparent!important}
.notices #closePaused .icon{width:16px;height:16px}

/* ---------- settings and «راجعني»: a popover under #viewTools, a bottom sheet on a phone ---------- */
#settings,#review{top:56px;inset-inline-end:16px;width:min(400px,calc(100% - 32px));padding:20px;border:0;border-radius:20px;background:var(--surface);box-shadow:var(--e4);z-index:61}
#settings .panelHead,#review .panelHead{margin-bottom:14px}
#settings h2,#review h2{font-size:20px;font-weight:600;line-height:1.3}
#closeSettings,#closeReview{border:0;background:transparent;border-radius:12px;min-height:40px;min-width:40px}
.fields{gap:12px}
.fields label{display:flex;flex-direction:column;gap:4px;font-size:13px;font-weight:500}
.fields select,#review select{height:42px;border:1px solid var(--line-warm);border-radius:12px;background:var(--quiet);padding:0 10px;font-size:14px;color:var(--ink,#30333a)}
.fields>button{min-height:42px;border:1px solid var(--line-warm);border-radius:12px;background:var(--surface);font-size:14px;font-weight:500}
#reviewChoices button,#reviewSelf button,.reviewActions button,#reviewShort button{border-radius:12px;border-color:var(--line-warm)}
#reviewShort{background:var(--quiet);border:0;border-radius:12px}

/* ---------- phones ---------- */
@media(max-width:640px){
  header{height:52px;padding:0 12px;gap:8px}
  h1{font-size:21px;gap:8px}
  .wave{height:20px}
  #upload{width:40px;min-width:40px;padding:0}
  #upload span{display:none}
  .headerActions{gap:2px}
  header .paging{padding:2px}
  header .paging button,#newPage{width:32px;min-width:32px;height:32px;min-height:32px}
  #page{min-width:44px;padding:0}
  #notebookOpen{gap:4px;padding-inline:9px}
  #notebookOpen:has(#notebookCount:empty){padding-inline:9px}
  #notebookOpen .label{display:none}
  /* a side topic open: its tabs take a second header row (they scroll inside) */
  header:has(>#threads:not([hidden])){flex-wrap:wrap;height:auto;row-gap:6px;padding-block:6px}
  header>#threads{order:9;flex-basis:100%}
  main>#reading{inset-block:auto 8px;inset-inline:8px;width:auto;align-self:end;max-height:min(60%,420px);overflow:auto;padding-block:14px;padding-inline:16px}
  .notebook{top:56px;inset-inline:8px;bottom:8px;border-radius:16px}
  .notebookHead{padding-block:12px 10px;padding-inline:16px;gap:10px}
  .notebookHead h2{font-size:20px}
  .notebookActions{width:100%}
  .notebookActions>*{flex:1;justify-content:center}
  .notebookPages{padding-inline:16px}
  /* «اضغط وتكلم» leaves the dock's row (the question box keeps its room): a round button
     above the dock's inline-end, and the context row keeps clear of it */
  #ptt{position:absolute;z-index:5;inset-inline-end:12px;bottom:calc(max(8px,env(safe-area-inset-bottom)) + 18px + 4px + 60px + 8px);
    width:52px;min-width:52px;height:52px;padding:0;border-radius:50%;font-size:0;background:var(--accent);color:var(--on-accent);box-shadow:var(--e3)}
  #ptt.on{background:var(--accent-hover);box-shadow:0 0 0 6px color-mix(in srgb,var(--accent) 20%,transparent),var(--e3)}
  #ptt::before{content:"";width:22px;height:22px;flex:none;background:currentColor;
    -webkit-mask:var(--mic-glyph) center/contain no-repeat;mask:var(--mic-glyph) center/contain no-repeat}
  footer:has(#ptt:not([hidden]))>:is(#caption,#selection,#gotIt){max-width:calc(100% - 128px)}
  footer:has(#ptt:not([hidden]))>#nextSteps{width:calc(100% - 64px);justify-self:start}
  footer{padding:0 12px max(8px,env(safe-area-inset-bottom));grid-template-rows:36px 60px 18px;row-gap:4px}
  .dock{flex-direction:row;align-items:center;height:60px;padding:6px;gap:6px;border-radius:20px}
  .dock .primary{flex:none}
  #ask{flex:1}
  #study{height:46px;min-height:46px;padding:0 14px;font-size:14px;border-radius:16px}
  #ask{height:46px}
  #q{padding:0 8px;font-size:14px}
  #mic{width:44px;height:44px;min-width:44px}
  #stop{width:44px;height:44px;min-width:44px}
  #more{width:36px;min-width:36px;height:46px}
  footer>#tray{left:12px;right:12px;width:auto;bottom:calc(max(8px,env(safe-area-inset-bottom)) + 18px + 4px + 60px + 8px);max-height:calc(100dvh - 170px)}
  footer>#caption{font-size:14px;padding:4px 12px}
  #nextSteps{justify-content:flex-start}
  #settings,#review{position:fixed;top:auto;bottom:calc(max(8px,env(safe-area-inset-bottom)) + 18px + 4px + 60px + 8px);left:8px;right:8px;inset-inline-end:8px;width:auto;max-height:calc(100dvh - 52px - 140px);padding:18px 16px}
  #empty strong{font-size:28px}
  #empty>span{font-size:15px}
  #empty{justify-content:flex-start;padding-top:32px}
  .homeChoices{grid-template-columns:minmax(0,1fr);width:100%;max-width:400px;gap:10px;margin-top:16px}
  .homeChoices button{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;column-gap:14px;row-gap:0;align-items:center;min-height:0;padding:14px 16px}
  .homeChoices .icon{grid-row:span 2;margin:0}
  .toasts{top:58px}
}
/* the dock on a narrow phone: «ابدأ المذاكرة» / «إنهاء المذاكرة» keep their names but show only their glyph.
   The question box keeps its width in every state (a reply's ⏹ beside it too): the send arrow shows once
   something is typed (the keyboard's Enter sends too), and the gaps are tighter. */
@media(max-width:480px){
  #study{width:46px;min-width:46px;padding:0;font-size:0;gap:0}
  .dock{gap:4px}
  #ask:has(#q:placeholder-shown) button{display:none}
  /* typing: the send arrow takes the mic's place. A live mic keeps its place (its control and its sign)
     beside the send arrow, and the tools («…») step aside until the question is sent or cleared. */
  .dock:has(#q:not(:placeholder-shown)) #mic:not([aria-pressed=true],.on){display:none}
  .dock:has(#q:not(:placeholder-shown)):has(#mic:is([aria-pressed=true],.on)) #more{display:none}
  header{gap:6px}
}
/* a blank board on a narrow phone: «صفحة جديدة» joins the paging, the logo drops its wave */
@media(max-width:420px){header:has(#newPage:not([hidden])) h1 .wave{display:none}}
/* a phone on its side: a slimmer header and context row */
@media(max-height:520px) and (orientation:landscape){
  header{height:44px}
  h1{font-size:20px}
  footer{grid-template-rows:28px 50px 14px;row-gap:3px;padding-bottom:max(4px,env(safe-area-inset-bottom))}
  .dock{height:50px;padding:4px}
  #study,#ask,#ptt{height:42px;min-height:42px}
  #mic,#stop{width:42px;height:42px;min-width:42px}
  #more{height:42px}
  footer>#tray{bottom:calc(max(4px,env(safe-area-inset-bottom)) + 14px + 3px + 50px + 6px);max-height:calc(100dvh - 110px)}
  #gotIt,#nextSteps button,.shareChips button{min-height:28px;height:28px}
  .sessionLine{height:14px;min-height:14px;line-height:14px;font-size:11px}
  #settings,#review{top:48px;max-height:calc(100dvh - 56px)}
  .toasts{top:48px}
}
/* studio.css hides some of these labels on narrow screens; in the tray they are the names */
#tray :is(#focusMode,#shareScreen,#photoQuestion,#blankBoard)>span{display:revert}
#tray .drawing{border:0;padding:2px 2px 4px;gap:4px}
