/* Kwantum whiteboard. Same tokens as tools.css. */
:root {
  --bg: #F4F6F9; --surface: #FFFFFF; --ink: #0F1726; --muted: #4A5568; --line: #D9DEE6;
  --chip: #E9EDF3; --hover: #EEF2F7; --accent: #155E75; --accent-ink: #FFFFFF;
  --bar: rgba(255,255,255,.94); --shadow: 0 6px 24px rgba(15,23,38,.16);
  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B111C; --surface: #121A28; --ink: #E9EDF4; --muted: #A4AEC0; --line: #263247;
    --chip: #1B2536; --hover: #1B2638; --accent: #5EC4DE; --accent-ink: #06222B;
    --bar: rgba(18,26,40,.94); --shadow: 0 6px 24px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B111C; --surface: #121A28; --ink: #E9EDF4; --muted: #A4AEC0; --line: #263247;
  --chip: #1B2536; --hover: #1B2638; --accent: #5EC4DE; --accent-ink: #06222B;
  --bar: rgba(18,26,40,.94); --shadow: 0 6px 24px rgba(0,0,0,.45);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.35;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wb-stage { position: fixed; inset: 0; touch-action: none; overflow: hidden; }
.wb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#live { cursor: crosshair; }
body[data-tool="hand"] #live, body[data-tool="grid"] #live { cursor: grab; }
body[data-tool="select"] #live { cursor: default; }
body[data-tool="text"] #live { cursor: text; }
body.panning #live { cursor: grabbing; }

/* toolbar */
.wb-bar { position: fixed; z-index: 20; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px; width: max-content; max-width: calc(100vw - 16px);
  padding: 5px; border-radius: 16px; background: var(--bar); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.wb-bar .sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.tb { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 42px; height: 42px; padding: 0 9px;
  border: 0; border-radius: 11px; background: transparent; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 13px; }
.tb:hover { background: var(--hover); }
.tb[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.tb[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.tb svg { width: 21px; height: 21px; flex: none; }
.tb .more { position: absolute; right: 2px; bottom: 2px; width: 0; height: 0; border-left: 5px solid transparent; border-bottom: 5px solid currentColor; opacity: .55; }
.tb:disabled { opacity: .35; cursor: default; }
.tb .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); box-shadow: inset 0 0 0 2px var(--surface); }
.tb.col[aria-pressed="true"] { background: var(--chip); color: var(--ink); }
.tb.col[aria-pressed="true"] .dot { border-color: var(--ink); }
.tb .pg { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .tb { min-width: 38px; height: 38px; padding: 0 6px; } .tb .lbl, .wb-bar .opt { display: none; } .wb-bar .sep { margin: 0 1px; } }

/* popovers */
.wb-pop { position: fixed; z-index: 30; max-width: min(440px, calc(100vw - 16px)); max-height: calc(100vh - 80px); overflow: auto; padding: 12px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.wb-pop h3 { margin: 10px 2px 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.wb-pop h3:first-child { margin-top: 0; }
.wb-pop .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.wb-pop .grid.wide { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.pb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 46px; padding: 5px; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--chip); cursor: pointer; font-size: 12px; font-weight: 600; text-align: center; color: var(--ink); }
.pb:hover { border-color: var(--line); }
.pb[aria-pressed="true"] { border-color: var(--accent); background: var(--hover); box-shadow: inset 0 0 0 1px var(--accent); }
.pb svg { width: 26px; height: 26px; }
.pb.row { flex-direction: row; justify-content: flex-start; gap: 9px; padding: 6px 10px; text-align: left; }
.pb .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(127,127,127,.35); }
.pb .wd { display: block; border-radius: 99px; background: currentColor; width: 26px; }
.pb .thumb { width: 44px; height: 30px; border-radius: 5px; border: 1px solid var(--line); flex: none; }
.wb-pop .tgl { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; font-weight: 500; }
.wb-pop .tgl input { width: 20px; height: 20px; accent-color: var(--accent); }
.wb-pop .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-pop .acts .pb { flex: 1 1 130px; flex-direction: row; gap: 8px; }
.wb-pop .acts .pb svg { width: 20px; height: 20px; }
.wb-pop .note { font-size: 13px; color: var(--muted); margin: 8px 2px 0; line-height: 1.45; }
.wb-pop .note b { color: var(--ink); }
.wb-pop input[type="color"] { width: 46px; height: 46px; padding: 0; border: 0; background: none; cursor: pointer; }
.wb-pop .warn { color: #B4232A; }

/* zoom + selection + toast */
.wb-zoom { position: fixed; z-index: 15; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 12px; background: var(--bar); border: 1px solid var(--line); box-shadow: var(--shadow); }
.wb-zoom .tb { min-width: 36px; height: 36px; }
.wb-zoom .z { min-width: 54px; font-variant-numeric: tabular-nums; }
.wb-sel { position: fixed; z-index: 16; display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--bar); border: 1px solid var(--line); box-shadow: var(--shadow); transform: translate(-50%, -100%); }
.wb-sel .tb { height: 36px; }
.wb-toast { position: fixed; z-index: 40; left: 50%; bottom: max(64px, calc(env(safe-area-inset-bottom) + 64px)); transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); text-align: center; }
.wb-text { position: fixed; z-index: 18; min-width: 120px; min-height: 1.3em; margin: 0; padding: 2px 4px; border: 2px dashed var(--accent); border-radius: 6px; background: transparent;
  outline: none; resize: none; overflow: hidden; line-height: 1.25; font-family: var(--font); font-weight: 500; white-space: pre; -webkit-user-select: text; user-select: text; }
