.toolbar { margin: 18px 0 10px; gap: 8px 12px; font-size: 14px; }
.toolbar button, .toolbar select { font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg > * { border: 0; border-radius: 0; background: var(--card); color: var(--fg); padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.seg > * + * { border-left: 1px solid var(--line); }
.seg output { font: 13px var(--mono); min-width: 4ch; display: inline-block; text-align: center; }
.ctl { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.ctl select { font: inherit; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); }

.board-stage { scroll-margin-top: 64px; position: relative; height: min(calc(100vh - 150px), 760px); height: min(calc(100svh - 150px), 760px); min-height: 420px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #e9e5db; }
.board-stage:fullscreen { border-radius: 0; border: 0; height: 100vh; }
.board-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; overflow-anchor: none; outline-offset: -3px; }
.board-stage canvas.panning { cursor: grabbing; }
.board-stage .hud { position: absolute; left: 8px; bottom: 8px; font: 11px/1.5 var(--mono); color: #4a463f; background: #fffdf7d9; padding: 2px 8px; border-radius: 6px; pointer-events: none; white-space: pre; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }

/* ?embed=1: the board is the whole page (used for "this board, inside itself"). */
body.embed main { max-width: none; padding: 0; }
body.embed #site-nav { display: none; }
body.embed main > :not(.board-stage) { display: none; }
body.embed .board-stage { height: 100vh; border: 0; border-radius: 0; }

/* Plain fallback: the tiles as an ordinary flowing page. */
.plain { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.plain .tile { position: static; width: auto !important; }

/* ---------- Tiles: real elements, children of the canvas ---------- */
.tile { position: absolute; left: 0; top: 0; box-sizing: border-box; display: flex; flex-direction: column; background: #fff; color: #1d1c1a; border: 1px solid #c9c2b2; border-radius: 10px; overflow: hidden; font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
.tile * { box-sizing: border-box; }
.tile.active { border-color: #d2491f; box-shadow: inset 0 0 0 2px #d2491f; }
.tile:focus-within { border-color: #d2491f; }
.tile .bar { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; background: #efeadf; border-bottom: 1px solid #ddd6c6; font-size: 13px; font-weight: 600; cursor: grab; user-select: none; touch-action: none; flex: none; }
.tile .bar .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .bar .kind { font: 500 11px ui-monospace, Menlo, monospace; color: #8a857c; }
.tile .bar button { font: inherit; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #6b6760; cursor: pointer; line-height: 1; }
.tile .bar button:hover { background: #d9d2c2; color: #1d1c1a; }
.tile .body { position: relative; flex: 1; min-height: 0; }
.tile .grip { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 50%, #b9b1a0 50%, #b9b1a0 60%, transparent 60%, transparent 72%, #b9b1a0 72%, #b9b1a0 82%, transparent 82%); }

.tile.note { background: var(--paper, #fff3a8); border-color: color-mix(in srgb, var(--paper, #fff3a8) 70%, #000); }
.tile.note .bar { background: color-mix(in srgb, var(--paper, #fff3a8) 88%, #000); border-bottom-color: color-mix(in srgb, var(--paper, #fff3a8) 78%, #000); }
.tile.note .text { height: 100%; overflow: auto; padding: 10px 14px 16px; font: 17px/1.45 Georgia, 'Times New Roman', serif; outline: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.tile.frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.tile.frame .cover { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; }
.tile.frame .cover span { font: 12px ui-monospace, Menlo, monospace; background: #1d1c1ae0; color: #fff; padding: 3px 9px; border-radius: 99px; opacity: 0; transition: opacity 0.15s; }
.tile.frame .cover:hover span, .tile.frame .cover:focus-visible span { opacity: 1; }
.tile.frame .cover:focus-visible { outline: 3px solid #d2491f; outline-offset: -3px; }
.tile.frame.active .cover { display: none; }

.tile.probe .body { background: #fff; }
