*{box-sizing:border-box;margin:0;padding:0}
body{font-family:Arial,sans-serif;background:#F5F2EE;color:#1a1a1a;height:100vh;display:flex;flex-direction:column;overflow:hidden}
.top{background:#fff;border-bottom:1.5px solid #E0DDD8;padding:7px 16px;display:flex;align-items:center;justify-content:space-between;flex:0 0 auto}
.top img{height:30px;vertical-align:middle}
.top .ti{font-size:14px;color:#6B6862;font-style:italic}
/* OneNote-style tabbed toolbar (Mathedup59): Teach / Draw / Board tabs — one tab's tools visible
   at a time — plus an always-on PINNED strip (slide arrows · undo · current pen · Answer · Present).
   Decks open on the Draw tab (owner choice). */
.toolbar{background:#fff;border-bottom:1px solid #E0DDD8;display:flex;flex-direction:column;align-items:center;padding:6px 14px 8px;flex:0 0 auto}
.tabwrap{width:min(1600px,100%)}
.tabs{display:flex;gap:2px;margin-left:6px}
.tab{font-family:Arial,sans-serif;font-size:12.5px;font-weight:bold;letter-spacing:.02em;padding:6px 18px 5px;border-radius:10px 10px 0 0;border:1px solid transparent;background:transparent;color:#6B6862;cursor:pointer}
.tab:hover{color:#DC2626}
.tab.on{background:#FAF8F5;border:1px solid #ECE8E2;border-bottom-color:#FAF8F5;color:#DC2626;position:relative;top:1px}
.tabrow{display:flex;align-items:center;gap:7px;background:#FAF8F5;border:1px solid #ECE8E2;border-radius:0 14px 14px 14px;padding:7px 10px;min-height:58px}
.tsec{display:none;align-items:center;gap:7px;min-width:0}
.tsec.on{display:flex}
.tsec .sep{width:1px;height:26px;background:#E0DDD8;margin:0 2px;flex:0 0 auto}
.nav .navarrow{width:38px;height:38px}
.pin{display:flex;align-items:center;gap:7px;margin-left:auto;border-left:1.5px dashed #E0DDD8;padding-left:12px;flex:0 0 auto}
.ic.wide{gap:7px;white-space:nowrap}
#pens{display:flex;gap:7px;align-items:center}
#hidbtns{display:none}
.penbtn .pcol{width:20px;height:20px;border-radius:50%;background:#1a1a1a;box-shadow:0 0 0 1.5px rgba(255,255,255,.9) inset}
.ic.dim{opacity:.35}
.stg{visibility:hidden}.stg.in{visibility:visible}
#mid{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
body.dock-bottom #mid{flex-direction:column-reverse}
body.dock-left #mid{flex-direction:row}
body.dock-right #mid{flex-direction:row-reverse}
body.dock-left .toolbar,body.dock-right .toolbar{justify-content:flex-start;overflow-y:auto;border-bottom:none;padding:10px 7px;flex:0 0 auto}
body.dock-left .toolbar{border-right:1px solid #E0DDD8}
body.dock-right .toolbar{border-left:1px solid #E0DDD8}
body.dock-left .tabwrap,body.dock-right .tabwrap{width:auto}
body.dock-left .tabs,body.dock-right .tabs{margin-left:0;justify-content:center}
body.dock-left .tab,body.dock-right .tab{padding:5px 9px 4px;font-size:11px}
body.dock-left .tabrow,body.dock-right .tabrow{flex-direction:column;border-radius:14px;padding:8px 6px;width:132px}
body.dock-left .tsec.on,body.dock-right .tsec.on{flex-wrap:wrap;justify-content:center}
body.dock-left .pin,body.dock-right .pin{margin-left:0;margin-top:8px;border-left:none;border-top:1.5px dashed #E0DDD8;padding-left:0;padding-top:10px;flex-wrap:wrap;justify-content:center}
body.dock-left .toolbar .ic,body.dock-right .toolbar .ic{width:38px;height:38px}
body.dock-left .toolbar .ic.wide,body.dock-right .toolbar .ic.wide{width:auto;font-size:11.5px}
body.dock-left .toolbar .ic svg,body.dock-right .toolbar .ic svg{width:18px;height:18px}
body.dock-left .toolbar .swatch,body.dock-right .toolbar .swatch{width:23px;height:23px}
body.dock-left .toolbar .hi,body.dock-right .toolbar .hi{width:28px;height:18px}
body.dock-bottom .toolbar{border-bottom:none;border-top:1px solid #E0DDD8}
.swatch{display:inline-block;vertical-align:middle;width:28px;height:28px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1.5px #c9c4bd;cursor:pointer;transition:transform .1s}
.swatch:hover,.hi:hover{transform:translateY(-2px)}
.hi{display:inline-block;vertical-align:middle;width:34px;height:21px;border-radius:6px;border:2px solid #fff;box-shadow:0 0 0 1.5px #c9c4bd;cursor:pointer;transition:transform .1s}
.swatch.active,.hi.active{box-shadow:0 0 0 3px #1a1a1a}
.ic{width:42px;height:42px;border-radius:12px;border:1.5px solid #E5E1DB;background:#fff;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:#1a1a1a;transition:all .12s}
.ic:hover{background:#F5F2EE;border-color:#DC2626;color:#DC2626;transform:translateY(-1px)}
.ic:active{transform:translateY(1px)}
.ic.on{background:#DC2626;border-color:#DC2626;color:#fff}
.ic svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ic.big{width:48px;height:48px}.ic.big svg{width:24px;height:24px}
.ic.sel{background:#1a1a1a;border-color:#1a1a1a;color:#fff}
.ic.wide{width:auto;padding:0 12px;font-size:13px;font-weight:bold}
.ic svg.dot circle{fill:currentColor;stroke:none}
#ecursor{position:absolute;border:1.5px solid #8a8a8a;background:#fff;border-radius:50%;pointer-events:none;display:none;transform:translate(-50%,-50%);z-index:5}
.top,.toolbar,.nav{position:relative;z-index:40}
.pop,.menu{position:fixed;background:#fff;border:1px solid #E0DDD8;border-radius:14px;box-shadow:0 8px 24px rgba(0,0,0,.2);padding:8px;display:none;z-index:70}
.pop.open,.menu.open{display:block}
.popgrid{display:flex;gap:8px;align-items:center;justify-content:center}
.popcol{display:flex;flex-direction:column;gap:8px}
.menu button{display:block;width:100%;text-align:left;padding:9px 14px;background:#fff;border:none;border-radius:8px;font-size:14px;cursor:pointer;font-family:Arial,sans-serif;white-space:nowrap}
.menu button:hover{background:#F5F2EE}
#bg{position:absolute;inset:0;z-index:0;border-radius:14px}
.bg-grid{background-image:linear-gradient(#dbe6f0 1px,transparent 1px),linear-gradient(90deg,#dbe6f0 1px,transparent 1px);background-size:40px 40px}
.bg-sq{background-image:linear-gradient(#ece6dd 1px,transparent 1px),linear-gradient(90deg,#ece6dd 1px,transparent 1px);background-size:24px 24px}
.bg-iso{background-image:radial-gradient(#d8d2c8 1.4px,transparent 1.8px),radial-gradient(#d8d2c8 1.4px,transparent 1.8px);background-size:28px 48px;background-position:0 0,14px 24px}
.bgsw{width:26px;height:26px;border-radius:8px;border:1.5px solid #E0DDD8;cursor:pointer;display:inline-block}
.bgsw.active{border-color:#DC2626;border-width:2px}
.bglab{font-size:11.5px;font-weight:bold;color:#6B6862;text-transform:uppercase;letter-spacing:.03em;padding:2px 4px 0}
.spot{position:fixed;inset:0;z-index:30;display:none;pointer-events:none;background:radial-gradient(circle 120px at var(--mx,50%) var(--my,50%),rgba(0,0,0,0) 0,rgba(0,0,0,0) 105px,rgba(0,0,0,.72) 150px)}
.timerchip{position:fixed;right:18px;bottom:78px;z-index:50;background:#1a1a1a;color:#fff;font-weight:bold;font-size:22px;padding:8px 16px;border-radius:12px;cursor:pointer;font-family:Arial,sans-serif}
.timerchip.done{background:#DC2626;animation:tflash .6s steps(2,end) infinite}
@keyframes tflash{50%{opacity:.35}}
.stage{flex:1 1 auto;display:flex;align-items:stretch;justify-content:center;padding:14px;min-height:0}
.card{position:relative;overflow:hidden;background:#fff;border-radius:14px;box-shadow:0 1px 8px rgba(0,0,0,.12);width:min(1600px,97%);height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding:26px 28px 18px}
/* stagewrap holds the content AND the ink canvas, so a single transform zooms both
   together (ink stays glued to the text). In scroll mode it grows past the card and the
   card scrolls; the ink canvas scrolls with it because it lives inside the wrapper. */
#stagewrap{position:relative;width:100%;flex:1 1 auto;min-height:0;transform-origin:top center;transition:transform .12s}
#qbody{position:relative;z-index:1;width:100%;display:flex;flex-direction:column;align-items:center}
/* ink canvas extends beyond the content so there's room to draw when the board is panned;
   the card clips it to the viewport until you pan. */
canvas#ink{position:absolute;top:-45%;left:-45%;width:190%;height:190%;z-index:3;touch-action:none;cursor:crosshair;border-radius:12px}
body.scroll-on .card{overflow-y:auto;overflow-x:hidden}
body.scroll-on #stagewrap{flex:0 0 auto;min-height:100%}
.phase{position:absolute;top:12px;left:18px;color:#9a6b4f;font-weight:bold;text-transform:uppercase;font-size:12px;letter-spacing:.04em}
.qnum{position:absolute;top:12px;right:18px;color:#DC2626;font-weight:bold;font-size:14px}
.prompt{font-size:clamp(20px,2.4vw,30px);line-height:1.5;text-align:center;max-width:940px;margin-top:18px}
.prompt .ask{display:block;margin-top:.55em;font-weight:bold}
#qfig{margin-top:10px;text-align:center}
#qfig svg{width:min(96%,680px);height:auto}
.answer{margin-top:14px;color:#15803d;font-weight:bold;font-size:clamp(20px,2.2vw,28px);border-top:2px solid #DC2626;padding-top:10px;display:none}
.answer.show{display:block}
#single{display:flex;flex-direction:column;align-items:center;width:100%}
#eyt{display:none;width:100%;gap:26px;align-items:flex-start;justify-content:center}
.eytcol{flex:1 1 0;min-width:0;max-width:540px;display:flex;flex-direction:column;align-items:center}
.eythead{font-weight:bold;text-transform:uppercase;letter-spacing:.05em;font-size:15px;margin-bottom:2px;color:#9a6b4f}
.eythead.yt{color:#DC2626}
.eytcol.ythid .prompt,.eytcol.ythid .qfig,.eytcol.ythid .answer{visibility:hidden}
.eytcol .prompt{font-size:clamp(16px,1.7vw,22px);max-width:100%;margin-top:8px}
.eytcol .qfig{margin-top:8px;text-align:center}
.eytcol .qfig svg{width:min(96%,320px);height:auto}
.eytcol .answer{font-size:clamp(16px,1.6vw,22px)}
.ic.eyeex{color:#9a6b4f}.ic.eyeyt{color:#DC2626}
.ic.eyeex.on,.ic.eyeyt.on{color:#fff}
#pgrid{display:none;width:100%;gap:12px 16px}
.pgcell{border:1.5px solid #EDE9E3;border-radius:12px;padding:8px 12px 10px;display:flex;flex-direction:column;align-items:center;min-width:0;background:#fff}
.pgnum{align-self:flex-start;font-weight:bold;color:#DC2626;font-size:13px}
.pgcell .prompt{font-size:clamp(13px,1.25vw,18px);margin-top:2px;max-width:100%;line-height:1.35}
.pgcell .qfig{margin-top:6px;text-align:center}
.pgcell .qfig svg{width:min(92%,230px);height:auto}
.pgcell .answer{font-size:clamp(13px,1.15vw,17px);margin-top:8px;padding-top:6px}
.pchooser{width:340px;max-height:62vh;overflow:auto;font-family:Arial,sans-serif}
.pcrow{display:flex;align-items:center;gap:8px;padding:4px 6px;border-radius:8px}
.pcrow:hover{background:#F5F2EE}
.pcname{flex:1;font-size:13.5px;cursor:pointer}
button.pcbtn{width:26px;height:26px;border:1.5px solid #E0DDD8;background:#fff;border-radius:8px;cursor:pointer;font-weight:bold;font-size:15px;line-height:1}
button.pcbtn:disabled{color:#C9C4BC;cursor:default}
.pccount{min-width:18px;text-align:center;font-weight:bold;font-size:14px}
.pcfoot{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 6px 2px;border-top:1px solid #EDE9E3;margin-top:6px}
button.pcbuild{background:#DC2626;color:#fff;border:none;border-radius:9px;padding:8px 16px;font-weight:bold;font-size:13.5px;cursor:pointer}
button.pcbuild:disabled{background:#E0DDD8;cursor:default}
.pctotal{font-weight:bold;font-size:13px;color:#6B6862}
.nav{flex:0 0 auto;background:#fff;border-top:1px solid #E0DDD8;display:flex;align-items:center;justify-content:center;gap:16px;padding:9px}
select.jump{padding:8px 10px;border:1.5px solid #E5E1DB;border-radius:10px;font-family:Arial,sans-serif;font-size:13px;max-width:340px;background:#fff;cursor:pointer}
.count{font-weight:bold;min-width:78px;text-align:center;color:#6B6862}
.katex{white-space:nowrap}
.tin{position:absolute;z-index:6;font:bold 22px Arial,sans-serif;background:rgba(255,255,255,.85);border:1.5px dashed #DC2626;border-radius:6px;padding:2px 6px;min-width:60px;outline:none}
.instr{position:absolute;z-index:4;cursor:move;touch-action:none;user-select:none}
.instr svg{pointer-events:auto}
.instr .ix{position:absolute;top:-10px;right:-10px;width:24px;height:24px;border-radius:50%;border:none;background:#1a1a1a;color:#fff;font-size:14px;font-weight:bold;cursor:pointer;line-height:1}
.instr .irot{position:absolute;right:-13px;bottom:8px;width:24px;height:24px;border-radius:50%;background:#DC2626;border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.3);cursor:grab}
.ovl{position:fixed;inset:0;background:rgba(15,15,15,.55);z-index:80;display:none;overflow:auto;padding:44px 30px}
.ovl.open{display:block}
.ovgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;max-width:1100px;margin:0 auto}
.ovc{background:#fff;border:2.5px solid transparent;border-radius:12px;padding:16px 10px;cursor:pointer;display:flex;flex-direction:column;gap:6px;align-items:center;font-family:Arial,sans-serif}
.ovc:hover{transform:translateY(-2px)}
.ovc.cur{border-color:#DC2626}
.ovn{font-weight:bold;color:#DC2626;font-size:16px}.ovp{font-size:12px;color:#6B6862;text-align:center}
/* owner-only flag (raise toolbar/UI issues from any deck) — injected only for the owner */
#ptflag{position:fixed;left:12px;bottom:12px;z-index:85;display:none;width:40px;height:40px;border-radius:50%;border:none;background:#d97706;color:#fff;font-size:18px;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.28);align-items:center;justify-content:center}
body.pt-owner #ptflag{display:flex}
#ptflagpanel{position:fixed;left:12px;bottom:60px;z-index:85;width:300px;background:#fff;border:1px solid #E0DDD8;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.22);padding:12px;display:none;font-family:Arial,sans-serif}
#ptflagpanel.open{display:block}
#ptflagpanel textarea{width:100%;min-height:66px;border:1px solid #E0DDD8;border-radius:8px;padding:8px;font:inherit;font-size:13px;resize:vertical;box-sizing:border-box}
#ptflagpanel .ctx{font-size:11.5px;color:#6B6862;margin-bottom:6px}
#ptflagpanel .row{display:flex;justify-content:space-between;align-items:center;margin-top:8px;gap:8px}
#ptflagpanel button.send{background:#DC2626;color:#fff;border:none;border-radius:8px;padding:7px 14px;font-weight:bold;cursor:pointer}
#ptflagpanel .msg{font-size:12px}
