:root {
  --bg: #fff; --ink: #1f2328; --muted: #6b7280; --line: #d9dde3; --panel: rgba(255,255,255,.96);
  --accent: #1e88e5; --link: #1565c0; --shadow: 0 2px 10px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) { :root { --panel: rgba(38,40,44,.96); --ink: #eceff3; --line: #4a4f57; --muted: #9aa3ae; --link: #8ab4f8; } }
* { box-sizing: border-box; }
#modalbox a:not([class]) { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff; font-family: Roboto, system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; }
#board { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; cursor: crosshair; display: block; }
#board.hand { cursor: grab; } #board.select { cursor: default; } #board.view { cursor: grab; }

#topleft { position: fixed; top: 10px; left: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
#topleft button, #topleft #notewrap, #topleft #markwrap { pointer-events: auto; }
#notewrap { position: relative; }
#boardname { font-family: 'Permanent Marker', cursive; font-size: 18px; color: #444; }
#status { font-size: 12px; color: var(--muted); }
#topright { position: fixed; top: 8px; right: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 20px); }
.pill { font: 500 13px Roboto, sans-serif; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
.pill:hover { border-color: var(--accent); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill[hidden] { display: none; }
.pill img { width: 18px; height: 18px; border-radius: 50%; vertical-align: -4px; margin-right: 6px; }

#toolbar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 16px); overflow-x: auto; }
#toolbar .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; flex: none; }
#toolbar button { flex: none; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 9px; background: none; color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0; }
#toolbar button:hover { background: rgba(127,127,127,.15); }
#toolbar button.on { border-color: var(--accent); background: rgba(30,136,229,.14); }
#toolbar button:disabled { opacity: .35; cursor: default; }
#toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toolbar .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
#toolbar button.swb { width: 32px; height: 32px; }
#toolbar button.swb.on .sw { box-shadow: 0 0 0 2px var(--accent); }
#toolbar .dot { background: currentColor; border-radius: 50%; }
#toolbar input[type=color] { width: 28px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
#toolbar.viewonly > :not(.keep) { display: none; }

#texted { position: fixed; display: none; margin: 0; padding: 0; border: 1px dashed var(--accent); outline: none; background: rgba(255,255,255,.6); resize: none; overflow: hidden; white-space: pre; font-family: 'Permanent Marker', cursive; min-width: 40px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 10; }
#modal[hidden], #toast[hidden] { display: none; }
#modalbox { background: var(--panel); color: var(--ink); border-radius: 14px; padding: 20px; width: min(420px, calc(100vw - 24px)); max-height: 85vh; overflow: auto; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
#modalbox h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }
#modalbox p { margin: 6px 0 12px; color: var(--muted); font-size: 13px; }
#modalbox .row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
#modalbox input[type=text], #modalbox input[type=password], #modalbox input[type=email], #modalbox select { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; min-width: 0; }
#modalbox .btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
#modalbox .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
#modalbox .btn.wide { width: 100%; }
#modalbox hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
#modalbox .board { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; cursor: pointer; }
#modalbox .board:hover { background: rgba(127,127,127,.14); }
#modalbox .board.cur { outline: 1px solid var(--accent); }
#modalbox .board .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modalbox .board .m { font-size: 12px; color: var(--muted); }
#modalbox .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; }
#toast { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 20; }

#imgbar { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
#imgbar[hidden], #shapebar[hidden] { display: none; }
#imgbar input[type=range] { width: 110px; }

#people { position: fixed; top: 36px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60vw; pointer-events: none; }
#people .chip { font-size: 12px; padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px; }
#people .chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
#modalbox label.row input[type=checkbox] { width: 18px; height: 18px; flex: none; }

/* top-right: handwritten logo above the action buttons */
#topright { flex-direction: column; align-items: flex-end; gap: 6px; }
#actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#logo { font-family: 'Permanent Marker', cursive; font-size: 28px; line-height: 1; text-decoration: none; transform: rotate(-0.7deg); transform-origin: right center; margin: 2px 4px 0 0; letter-spacing: .5px; text-shadow: 0 0 1px rgba(0,0,0,.25); }
#logo .cloud { color: #8a8f98; }
#logo .com { color: #111; }
@media (max-width: 560px) { #logo { font-size: 20px; } }

.tagrow { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(127,127,127,.18); color: var(--ink); white-space: nowrap; }
.tag.btn { cursor: pointer; font-size: 12px; border: 1px solid transparent; }
.tag.btn:hover { border-color: var(--accent); }
.tag.btn.on { background: var(--accent); color: #fff; }
/* the boards list: a wide pop-up with a scrolling, sortable table and the buttons fixed below it */
#modalbox.boardswide { width: min(1040px, calc(100vw - 24px)); display: flex; flex-direction: column; overflow: hidden; height: min(760px, 88vh); max-height: 88vh; }
#modalbox.boardswide .btable { flex: 1 1 auto; min-height: 120px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
#modalbox.boardswide .tagrow.filters { max-height: 74px; overflow: auto; flex: none; gap: 4px; }
#modalbox.boardswide .tagrow.filters .tag.btn { font-size: 11px; padding: 1px 8px; color: var(--muted); border: 1px solid var(--line); background: transparent; }
#modalbox.boardswide .tagrow.filters .tag.btn:hover { border-color: var(--accent); color: var(--ink); }
#modalbox.boardswide .tagrow.filters .tag.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 0 0 2px rgba(127,127,127,.35); }
#modalbox.boardswide .tagrow.filters .tag.btn.clear { border-style: dashed; }
.btable table { width: 100%; border-collapse: collapse; }
.btable th { position: sticky; top: 0; z-index: 1; background: var(--panel); text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.btable th.sortable { cursor: pointer; user-select: none; }
.btable th.sortable:hover { color: var(--ink); }
.btable th.sortable.on { color: var(--ink); font-weight: 700; }
.btable td { padding: 7px 10px; vertical-align: top; }
.btable tbody tr:nth-child(even) { background: rgba(127,127,127,.075); }
.btable tbody tr.brow { cursor: pointer; }
.btable tbody tr.brow:hover { background: rgba(127,127,127,.2); }
.btable tbody tr.cur { outline: 1px solid var(--accent); outline-offset: -1px; }
.btable td.nm { width: 100%; max-width: 0; }
.btable td.nm .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btable td.nm .desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btable td.dt, .btable td.m { font-size: 12px; color: var(--muted); white-space: nowrap; }
.btable td.acts { white-space: nowrap; text-align: right; }
.btable tr.edit td { padding: 10px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 8px; flex: none; }
.pager:empty { display: none; }
.boardfoot { display: flex; gap: 8px; margin-top: 12px; flex: none; }
.boardfoot .btn { flex: 1; }
@media (max-width: 640px) { .btable .cr, .btable td.m { display: none; } }

#cta { position: fixed; left: 12px; bottom: 14px; font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; z-index: 2; }
#cta[hidden] { display: none; }
#cta:hover { border-color: var(--accent); }
@media (max-width: 640px) { #cta { bottom: 70px; left: 50%; transform: translateX(-50%); white-space: nowrap; } }

#shapebar { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; }
#shapebar input[type=color] { width: 30px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
#shapebar .muted { color: var(--muted); }
#modalbox.wide { width: min(880px, calc(100vw - 24px)); }
#modalbox .tabs { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
#modalbox .tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
#modalbox .tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#modalbox .lib h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#modalbox .cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
#modalbox .cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 1px solid transparent; border-radius: 10px; background: #fff; color: #333; cursor: pointer; font: 11px Roboto, sans-serif; }
#modalbox .cell:hover { border-color: var(--accent); }
#modalbox .cards2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
#modalbox .card2 { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
#modalbox .card2:hover { border-color: var(--accent); }
#modalbox .card2 canvas { border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
#modalbox .card2 span { color: var(--muted); font-size: 12px; }
#modalbox textarea { width: 100%; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); resize: vertical; }
#modalbox pre.errs { color: #e53935; white-space: pre-wrap; margin: 6px 0; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; }

#modalbox .board .desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the assistant: a tall text-message thread docked bottom-right (full width on a phone) */
#aibar { position: fixed; right: 12px; bottom: 128px; width: min(470px, calc(100vw - 16px)); height: min(680px, calc(100vh - 240px)); min-height: 300px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow); z-index: 3; overflow: hidden; }
#aibar[hidden] { display: none; }
#aibar .aihead { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); }
#aibar .aihead b { font-size: 14px; }
#aibar .aihead .aimeta { flex: 1; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#aibar .aithread { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
#aibar .aimsg { max-width: 88%; padding: 8px 12px; border-radius: 16px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
#aibar .aimsg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
#aibar .aimsg.bot { align-self: flex-start; background: rgba(127,127,127,.14); border-bottom-left-radius: 4px; }
#aibar .aimsg.note { align-self: center; max-width: 100%; background: none; color: var(--muted); font-size: 12px; padding: 2px 6px; }
#aibar .aitext.err { color: #e53935; }
#aibar .aiextra { font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#aibar .aimsg .aiextra { margin-top: 6px; }
#aibar .aimsg .aiextra:empty { display: none; }
#aibar .aiextra .pill { padding: 3px 10px; font-size: 12px; }
#aibar .aistrip { padding: 0 12px; }
#aibar .aistrip:not(:empty) { padding: 6px 12px 0; }
#aibar .aistatus { padding: 0 12px; font-size: 12px; color: var(--muted); }
#aibar .aistatus:not(:empty) { padding: 4px 12px 0; }
#aibar .airow { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px 10px; }
#aibar textarea { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; line-height: 1.35; resize: none; overflow-y: auto; max-height: 120px; }
#aibar .aix { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 6px; }
#aibar .aisug { width: 100%; }
#aibar .aimeta { margin-top: 6px; font-size: 11px; color: var(--muted); }
#aibar .aiprog { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 4px; min-width: 220px; }
#aibar .aiprog > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
@media (max-width: 560px) { #aibar { right: 8px; left: 8px; width: auto; bottom: 70px; height: calc(100vh - 150px); } }

#modalbox .card2.static { cursor: default; }
#modalbox .card2.static:hover { border-color: var(--line); }
#modalbox .card2 .row { margin: 6px 0 0; }

#btnAi.locked { border-style: dashed; opacity: .9; }

/* ---- slides: editor strip + play mode ---- */
#slidebar { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); width: min(980px, calc(100vw - 16px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px; z-index: 6; }
#slidebar[hidden] { display: none; }
#slidebar .strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
#slidebar .slide { position: relative; flex: none; width: 150px; height: 84px; padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden; }
#slidebar .slide.on { border-color: #8e24aa; }
#slidebar .slide canvas { width: 100%; height: 100%; display: block; }
#slidebar .slide .num { position: absolute; left: 4px; top: 3px; background: #8e24aa; color: #fff; border-radius: 5px; font: 500 11px Roboto, sans-serif; padding: 1px 6px; }
#slidebar .slide .ttl { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font: 11px Roboto, sans-serif; padding: 2px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#slidebar .slide .cut { position: absolute; right: 4px; top: 3px; background: #222; color: #fff; border-radius: 5px; font: 10px Roboto, sans-serif; padding: 1px 5px; }
#slidebar .ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
#slidebar .ctl .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
#slidebar .ctl input[type=text] { width: 170px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; }
#slidebar .ctl select { padding: 5px 6px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; }
#slidebar .ctl .btn:disabled { opacity: .35; }
#slidebar .muted { color: var(--muted, #888); }
body.playing #hero, body.playing #toolbar, body.playing #topleft, body.playing #topright, body.playing #people, body.playing #cta, body.playing #imgbar,
body.playing #shapebar, body.playing #aibar, body.playing #slidebar { display: none !important; }
#play { position: fixed; inset: 0; z-index: 40; cursor: default; touch-action: none; user-select: none; }
#play[hidden] { display: none; }
#play .hudtop, #play .side { opacity: 0; transition: opacity .25s; }
#play.hud .hudtop, #play.hud .side { opacity: 1; }
#play .hudtop { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: linear-gradient(rgba(0,0,0,.35), transparent); color: #fff; font: 500 14px Roboto, sans-serif; }
#play .grow { flex: 1; }
#play button { background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 999px; cursor: pointer; font-size: 18px; width: 38px; height: 38px; }
#play .side { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px; line-height: 1; }
#play .side.left { left: 12px; } #play .side.right { right: 12px; }
@media (max-width: 700px) { #slidebar { bottom: 66px; } #slidebar .slide { width: 110px; height: 62px; } }
body.playing #toast { z-index: 60; }
#slidebar .btn { padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
#slidebar .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
#slidebar .slide .zoomn { position: absolute; right: 4px; bottom: 3px; background: #8e24aa; color: #fff; border-radius: 5px; font: 500 10px Roboto, sans-serif; padding: 1px 5px; }
#slidebar .slide .ttl ~ .zoomn { bottom: 20px; }
#fontbar { position: fixed; z-index: 7; display: block; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
#fontbar[hidden] { display: none; }
#fontbar .ffgrid { display: grid; grid-template-columns: repeat(7, 40px); gap: 4px; }
#fontbar .sizerow { display: flex; align-items: center; gap: 4px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
#fontbar .szlabel { font-size: 11px; color: var(--muted); width: 32px; text-align: center; }
#fontbar .szb { flex: 1; height: 34px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; font-family: Roboto, sans-serif; font-weight: 500; }
#fontbar .szb:hover { background: rgba(127,127,127,.15); }
#fontbar .szb.on { border-color: var(--accent); background: rgba(30,136,229,.14); }
#fontbar .ffb { width: 40px; height: 34px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); font-size: 18px; cursor: pointer; }
#fontbar .ffb:hover { background: rgba(127,127,127,.15); }
#fontbar .ffb.on { border-color: var(--accent); background: rgba(30,136,229,.14); }
body.playing #fontbar { display: none !important; }
#btnUnlock { pointer-events: auto; cursor: pointer; background: #fb8c00; color: #fff; border: 0; }
#btnUnlock[hidden] { display: none; }
#slidebar .cnt { color: var(--muted); font-size: 12px; } #slidebar .cnt.full { color: #e53935; font-weight: 500; }
#slidebar .more { font-size: 12px; color: var(--accent); }
#nudge { position: fixed; left: 14px; bottom: 74px; z-index: 8; width: min(300px, calc(100vw - 28px)); padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
#nudge[hidden] { display: none; }
#nudge p { margin: 6px 0 10px; color: var(--muted); }
#nudge .x { position: absolute; right: 6px; top: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
#nudge .row { display: flex; gap: 8px; }
#nudge .btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
#nudge .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
body.playing #nudge { display: none !important; }
#playend { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); }
#playend[hidden] { display: none; }
#playend .card { max-width: 420px; margin: 16px; padding: 22px 24px; background: #fff; color: #1f2328; border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.4); text-align: center; }
#playend h2 { margin: 0 0 6px; font-family: 'Permanent Marker', cursive; font-weight: 400; }
#playend .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
#playend .go { background: #1e88e5; color: #fff; text-decoration: none; padding: 10px 18px; border-radius: 999px; font-weight: 500; }
#playend button { width: auto; height: auto; padding: 10px 16px; border-radius: 999px; background: #eceff3; color: #1f2328; font-size: 15px; }
#inkbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: rgba(0,0,0,.6); border-radius: 999px; opacity: 0; transition: opacity .25s; }
#play.hud #inkbar, #inkbar.on { opacity: 1; }
#inkbar button { width: 34px; height: 34px; font-size: 17px; padding: 0; background: transparent; border-radius: 50%; }
#inkbar button.sel { background: rgba(255,255,255,.28); }
#inkbar .sw { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; flex: none; }
#inkbar .sw.sel { border-color: #fff; }

#modalbox .planf { display: block; margin: 6px 0; }
#modalbox .planf span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
#modalbox .planf input, #modalbox .planf textarea, #modalbox .planf select { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; }
#modalbox .stylerow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 4px; }
#modalbox .sw { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(127,127,127,.5); }
#modalbox .lookprev { position: relative; width: 200px; height: 112px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
#modalbox .lookprev > div { position: absolute; }
#modalbox .looktitle { white-space: nowrap; overflow: hidden; line-height: 1.1; padding: 0 2px; }
#modalbox .logoph { border: 1px dashed rgba(127,127,127,.7); color: rgba(127,127,127,.9); font-size: 9px; display: flex; align-items: center; justify-content: center; }
#modalbox .lookpic { inset: 0; background: repeating-linear-gradient(45deg, rgba(127,127,127,.25), rgba(127,127,127,.25) 6px, rgba(127,127,127,.1) 6px, rgba(127,127,127,.1) 12px); }
#modalbox .lookcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 10px 0; }
#modalbox .lookcard select { width: 100%; }
#modalbox .stylecols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { #modalbox .stylecols { grid-template-columns: 1fr; } }
#modalbox .colorrow { display: flex; gap: 6px; align-items: center; }
#modalbox .colorrow input[type=color] { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; flex: none; }
#modalbox .colorrow input[type=text] { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
#modalbox .briefbody h3 { font-size: 14px; margin: 14px 0 4px; }
#modalbox .briefchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#modalbox .briefchips.vert { flex-direction: column; align-items: stretch; }
#modalbox .briefchips.vert .pill { text-align: left; border-radius: 10px; white-space: normal; }
#modalbox .briefchips .pill[disabled], #modalbox .briefbody .btn[disabled] { opacity: .6; cursor: default; }
#modalbox .plancards { margin: 10px 0; display: grid; gap: 10px; }
#modalbox .plancard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
#modalbox .planfig { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
#modalbox .planfig select { max-width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 13px; }
#modalbox .planimg { max-width: 100%; max-height: 150px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#modalbox .planhead { display: flex; gap: 6px; align-items: center; }
#modalbox .planhead b { width: 22px; text-align: center; color: var(--muted); }
#modalbox .plancard textarea, #modalbox .plancard input[type=text] { width: 100%; box-sizing: border-box; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 13px; resize: vertical; }
#modalbox .planstate { font-size: 13px; color: var(--muted); }

/* offline presentation (a downloaded copy): just the board and a Present button */
body.offline #topleft, body.offline #people, body.offline #logo, body.offline #toolbar, body.offline #btnAi, body.offline #btnLive,
body.offline #btnBoards, body.offline #btnShare, body.offline #btnJpg, body.offline #btnSignin, body.offline #btnUser, body.offline #cta,
body.offline #slidebar, body.offline #nudge { display: none !important; }
body.offline #topright { top: 10px; right: 10px; }

/* the Download menu */
#dlmenu { position: fixed; z-index: 6; min-width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
#dlmenu .dlitem { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); cursor: pointer; font: inherit; padding: 9px 12px; border-radius: 8px; }
#dlmenu .dlitem:hover { background: rgba(30,136,229,.10); }
#dlmenu .dlitem b { display: block; font-weight: 500; }
#dlmenu .dlitem span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
body.playing #dlmenu, body.offline #dlmenu { display: none; }

/* notes: fixed-size sticky boxes over the board (not drawn on the canvas) */
#notes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
body.playing #notes { z-index: 45; }
.note { position: absolute; left: 0; top: 0; width: 200px; background: rgba(255,241,118,.82); color: #222; border: 1px solid rgba(0,0,0,.18); border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.22); font: 13px/1.35 Roboto, sans-serif; pointer-events: auto; }
.note .nhead { display: flex; align-items: center; justify-content: space-between; height: 18px; padding: 0 4px 0 8px; cursor: grab; touch-action: none; color: rgba(0,0,0,.4); font-size: 10px; letter-spacing: 1px; user-select: none; }
.note .ndel { border: 0; background: none; color: rgba(0,0,0,.45); cursor: pointer; font-size: 12px; padding: 0 2px; }
.note .ndel:hover { color: #c62828; }
.note textarea { display: block; width: 100%; border: 0; background: transparent; resize: none; font: inherit; color: inherit; padding: 0 8px 8px; outline: none; overflow: hidden; min-height: 2.6em; }
.note.ro .nhead { cursor: default; }
.note.ro .ngrip, .note.ro:not(.cdel) .ndel { display: none; }
.note.ro.nodate .nhead { display: none; }
.note .ndate { flex: 1; padding: 0 6px; letter-spacing: 0; font-size: 10px; color: rgba(0,0,0,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.note.ro textarea { padding-top: 6px; cursor: default; }
body.playing .note { pointer-events: none; }
#btnNotes.on { border-color: var(--accent); }
#notelist { position: absolute; top: 100%; left: 0; z-index: 9; min-width: 220px; max-width: min(320px, 80vw); max-height: 50vh; overflow-y: auto; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
#notelist[hidden] { display: none; }
#notelist .nitem { display: flex; width: 100%; gap: 8px; justify-content: space-between; align-items: baseline; text-align: left; border: 0; background: none; color: var(--ink); font: 13px/1.3 Roboto, sans-serif; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
#notelist .nitem:hover { background: rgba(127,127,127,.15); }
#notelist .nitem i { flex: none; font-style: normal; font-size: 11px; color: var(--muted); }
#dlmenu .dlopt { display: flex; gap: 8px; align-items: center; padding: 6px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }

/* the Animate dialog: two labelled boxes, lined up */
#modalbox .animgrid { display: grid; grid-template-columns: 1fr 110px; gap: 12px 16px; align-items: center; margin: 14px 0 10px; }
#modalbox .animgrid label { margin: 0; font-weight: 500; font-size: 15px; }
#modalbox .animgrid label small { display: block; margin-top: 1px; color: var(--muted); font-weight: 400; font-size: 12px; }
#modalbox .animgrid input { width: 100%; padding: 9px 8px; text-align: center; font: 500 18px Roboto, sans-serif; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
#modalbox .animgrid input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#modalbox p.animwarn { color: #e65100; margin: 4px 0; }

/* grid options */
#gridmenu { position: fixed; z-index: 7; width: 240px; padding: 10px 12px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
#gridmenu .gridrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
#gridmenu .gridseg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#gridmenu .gridopt { border: 0; background: none; color: var(--ink); padding: 6px 10px; font: 13px Roboto, sans-serif; cursor: pointer; }
#gridmenu .gridopt + .gridopt { border-left: 1px solid var(--line); }
#gridmenu .gridopt.on { background: rgba(30,136,229,.16); color: var(--accent); font-weight: 500; }
#gridmenu small { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
body.playing #gridmenu { display: none; }
#gridmenu .gridhead { display: flex; align-items: center; justify-content: space-between; }
#gridmenu .gridx { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; margin: -2px -4px 0 0; border-radius: 6px; }
#gridmenu .gridx:hover { background: rgba(127,127,127,.18); color: var(--ink); }
#gridmenu .gridsnap { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; cursor: pointer; }
#gridmenu .gridsnap input { margin: 2px 0 0; width: 16px; height: 16px; flex: none; }
#gridmenu .gridsnap small { margin-top: 1px; }
#shapebar .fillsw { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; flex: none; }
#shapebar .fillsw:hover { transform: scale(1.12); }
#shapebar .fillsw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
#shapebar .pill.on { border-color: var(--accent); background: rgba(30,136,229,.14); }

/* presentation markings: the page after the last slide, and the saved-markings list on the board */
body.playing #modal { z-index: 55; }
#playmarks { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); z-index: 3; }
#playmarks[hidden] { display: none; }
#playmarks .card { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--panel); color: var(--ink); border-radius: 14px; padding: 18px 20px; box-shadow: 0 6px 30px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 10px; }
#playmarks h2 { margin: 0; font-size: 20px; font-weight: 500; }
#playmarks p { margin: 0; font-size: 14px; color: var(--muted); }
#playmarks input[type=text] { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; }
#playmarks .btn { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: 500 14px Roboto, sans-serif; cursor: pointer; width: auto; height: auto; }
#playmarks .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
#playmarks .btn.wide { width: 100%; }
#playmarks .btn:disabled { opacity: .5; cursor: default; }
#playmarks .row { display: flex; gap: 8px; flex-wrap: wrap; }
#playmarks .marksmsg { min-height: 1.2em; color: var(--ink); }
#btnMarks.on { border-color: var(--accent); }
#markwrap { position: relative; }
#markmenu { position: fixed; z-index: 9; width: min(430px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
#markmenu .markhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
#markmenu .mkrow { padding: 8px 0; border-top: 1px solid var(--line); }
#markmenu .mktitle { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
#markmenu .mktitle small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
#markmenu .mkbtns { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0 24px; }
#markmenu .mkbtns .pill { padding: 3px 10px; font-size: 12px; box-shadow: none; }
#markmenu .mkbtns .pill.on { border-color: var(--accent); background: rgba(30,136,229,.14); }
#markmenu > small { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
#markmenu .gridx { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }

/* private links, the inbox bell, and the "this board is private" door */
#btnBell { position: relative; }
#bellcount { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 9px; background: #e53935; color: #fff; font: 600 11px/18px Roboto, sans-serif; text-align: center; }
#bellcount[hidden] { display: none; }
body.playing #btnBell { display: none !important; }
#modalbox .accrow { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
#modalbox .accrow > span:first-child { min-width: 92px; font-weight: 500; }
#modalbox .accrow select { flex: 1; min-width: 180px; }
#modalbox textarea.acclist { width: 100%; box-sizing: border-box; min-height: 96px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
#modalbox .reqrow, #modalbox .notecard { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 6px 0; display: grid; gap: 4px; }
#modalbox .reqrow .who, #modalbox .notecard .who { font-weight: 500; overflow-wrap: anywhere; }
#modalbox .reqbtns { display: flex; gap: 6px; flex-wrap: wrap; }
#modalbox .lockhint { font-size: 12px; color: var(--muted); margin: 4px 0; }

/* the Arrange menu (right-click on an object, or the toolbar's Arrange button) */
.ctxmenu { position: fixed; z-index: 20; min-width: 210px; padding: 4px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
.ctxitem { display: flex; justify-content: space-between; gap: 18px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ctxsep { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.warn { padding: 8px 10px; border-left: 3px solid #e8a317; background: rgba(232,163,23,.12); border-radius: 4px; }
.ctxitem:hover:not(:disabled) { background: rgba(127,127,127,.18); }
.ctxitem:disabled { opacity: .4; cursor: default; }
.ctxitem .keys { color: var(--muted); font-size: 11px; white-space: nowrap; }

#selcount { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 4px 12px; background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 500; box-shadow: var(--shadow); pointer-events: none; }
#selcount[hidden] { display: none; }
body.playing #selcount { display: none !important; }
/* the one-liner for someone who has never seen the tool (a logged-out visitor on their own scratch board); it sits first in the top-left row,
   pushing the status text to its right, and never blocks drawing */
#hero { --h-bg1: #fffaf0; --h-bg2: #edf5ff; --h-edge: rgba(30,136,229,.28); --h-ink: #2a3446; --h-mark: #e8553d; --h-sub: #1f7a6a; --h-muted: #7b8798;
  flex: none; max-width: min(360px, calc(100vw - 24px)); pointer-events: none; }
@media (prefers-color-scheme: dark) { #hero { --h-bg1: #2d303b; --h-bg2: #232a3d; --h-edge: rgba(255,255,255,.14); --h-ink: #eceff3; --h-mark: #ff8a65; --h-sub: #7fd1bf; --h-muted: #9aa3ae; } }
#hero[hidden] { display: none; }
#hero .card { position: relative; pointer-events: none; padding: 11px 30px 11px 16px; background: linear-gradient(135deg, var(--h-bg1), var(--h-bg2)); border: 1px solid var(--h-edge); border-left: 4px solid var(--accent);
  border-radius: 14px; box-shadow: 0 1px 2px rgba(20,30,60,.12), 0 10px 24px rgba(30,60,120,.16); font-size: 15px; line-height: 1.4; color: var(--h-ink); transform: rotate(-.5deg); transform-origin: left top; }
#hero .card b { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 17px; color: var(--h-mark); white-space: nowrap; letter-spacing: .3px; }
#hero .sub { display: block; min-height: 1.4em; margin-top: 4px; color: var(--h-sub); font-size: 13px; font-weight: 500; transition: opacity .35s; }
#hero .sub.fade { opacity: 0; }
#hero .row { display: flex; gap: 8px; margin-top: 9px; }
#hero .go { pointer-events: auto; display: inline-block; padding: 6px 13px; border-radius: 9px; background: linear-gradient(180deg, #2f95ee, #1565c0); color: #fff; border: 0; text-decoration: none; font-size: 13px; font-weight: 500;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 3px 8px rgba(21,101,192,.35); transition: transform .12s, box-shadow .12s; }
#hero .more { pointer-events: auto; display: inline-block; padding: 5px 12px; border-radius: 9px; border: 1px solid var(--h-edge); background: rgba(255,255,255,.55); color: var(--h-ink); text-decoration: none; font-size: 13px; font-weight: 500; cursor: pointer; transition: transform .12s, border-color .12s; }
#hero .more:hover { transform: translateY(-1px); border-color: var(--accent); }
@media (prefers-color-scheme: dark) { #hero .more { background: rgba(255,255,255,.08); } }
#hero .go:hover { transform: translateY(-1px); box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 6px 12px rgba(21,101,192,.4); }
#hero .x { position: absolute; right: 5px; top: 4px; pointer-events: auto; border: 0; background: none; color: var(--h-muted); cursor: pointer; font-size: 14px; padding: 2px 5px; border-radius: 6px; }
#hero .x:hover { color: var(--h-ink); }
#hero .minipill { pointer-events: auto; border: 1px solid var(--h-edge); background: linear-gradient(135deg, var(--h-bg1), var(--h-bg2)); color: var(--h-ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; box-shadow: 0 1px 2px rgba(20,30,60,.12), 0 4px 10px rgba(30,60,120,.14); }
#hero .minipill:hover { border-color: var(--accent); }
#topleft.hero { align-items: flex-start; }
#topleft.hero #status { margin-top: 12px; }
#topleft.hero.pilled #status { margin-top: 7px; }
@media (max-width: 560px) { #topleft.hero { flex-wrap: wrap; max-width: calc(100vw - 24px); } #topleft.hero #status { margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { #hero .sub, #hero .go, #hero .more { transition: none; } }

#modalbox .seqwin { display: flex; gap: 14px; align-items: flex-start; }
#modalbox .seqleft { flex: 1 1 52%; min-width: 0; max-height: 62vh; overflow: auto; }
#modalbox .seqright { flex: 1 1 48%; min-width: 0; position: sticky; top: 0; }
#modalbox .seqprev canvas { border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
#modalbox .seqrow { cursor: default; margin: 0 0 8px; width: 100%; box-sizing: border-box; }
#modalbox .seqrow input[type=text] { flex: 1 1 8em; min-width: 0; }
#modalbox .seqrow .row { flex-wrap: wrap; width: 100%; }
#modalbox .chartgrid { overflow: auto; max-height: 40vh; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 8px; }
#modalbox .chartgrid table { border-collapse: collapse; width: max-content; min-width: 100%; }
#modalbox .chartgrid th, #modalbox .chartgrid td { padding: 2px; border-bottom: 1px solid var(--line); white-space: nowrap; }
#modalbox .chartgrid th { position: sticky; top: 0; background: var(--panel); z-index: 1; text-align: left; }
#modalbox .chartgrid th.cat input { border-color: var(--accent); }
#modalbox .chartgrid input { width: 7em; box-sizing: border-box; padding: 4px 6px; }
#modalbox .chartgrid input.hd { font-weight: 600; }
#modalbox .chartgrid input.bad { border-color: #e53935; background: rgba(229,57,53,.12); }
#modalbox .chartgrid .rn { color: var(--muted); font-size: 11px; text-align: right; padding-right: 4px; }
#modalbox .chartgrid .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 4px; }
@media (max-width: 700px) { #modalbox .seqwin { flex-direction: column; } #modalbox .seqleft { max-height: none; } }
