:root {
  --paper: #fbfbf8;
  --ui: #1f2430;
  --ui-2: #2b3140;
  --ui-text: #e9ecf2;
  --ui-dim: #9aa3b5;
  --accent: #5b9cff;
  --ok: #3ccf7a;
  --bad: #ff6b5b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); }
body { font: 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ui-text);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#board { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; display: block; cursor: crosshair; }
#board.pan { cursor: grab; }
#board.panning { cursor: grabbing; }
#board.erase { cursor: none; }

.bar { position: fixed; display: flex; gap: 8px; align-items: center; background: var(--ui);
  border-radius: var(--radius); padding: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.22); z-index: 2; }
.group { display: flex; gap: 4px; align-items: center; }
button { appearance: none; border: 0; background: transparent; color: var(--ui-text); font: inherit;
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; }
button:hover { background: var(--ui-2); }
button.on { background: var(--accent); color: #fff; }
button:disabled { opacity: .35; cursor: default; background: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; justify-content: space-between; padding: 6px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.ok { background: var(--ok); }
.board { font-weight: 600; letter-spacing: .02em; }
.board::after { content: "▾"; font-size: 10px; opacity: .7; }
.top .group:first-child { position: relative; }
.menu { position: absolute; top: 44px; left: -4px; width: min(300px, calc(100vw - 24px)); background: var(--ui); border-radius: var(--radius);
  padding: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 6px; }
.menu[hidden] { display: none; }
.newboard { justify-content: flex-start; background: var(--accent); color: #fff; }
.newboard:hover { background: var(--accent); filter: brightness(1.1); }
.hint { color: var(--ui-dim); font-size: 12px; line-height: 1.35; padding: 2px 4px; }
.recent { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.recent a { display: flex; justify-content: space-between; align-items: center; color: var(--ui-text); text-decoration: none; padding: 8px; border-radius: 8px; }
.recent a:hover { background: var(--ui-2); }
.recent a.current { background: var(--ui-2); }
.recent small { color: var(--ui-dim); }
.share { background: var(--accent); color: #fff; }
.share:hover { background: var(--accent); filter: brightness(1.1); }
.people { display: flex; }
.people span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: #fff; margin-left: -6px; border: 2px solid var(--ui); text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.name { background: var(--ui-2); color: var(--ui-text); border: 0; border-radius: 8px; height: 30px; padding: 0 8px; width: 120px; font: inherit; }

.zoombar { top: calc(64px + env(safe-area-inset-top)); right: 12px; padding: 4px; }
.zoombar button { min-width: 32px; height: 32px; font-variant-numeric: tabular-nums; }
#zoomLabel { min-width: 64px; }

.tools { bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); }
.tools .group + .group { border-left: 1px solid var(--ui-2); padding-left: 8px; }
#toolGroup button span { font-size: 12px; }
.swatch { width: 26px; height: 26px; min-width: 26px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); }
.swatch.on { outline: 2px solid #fff; outline-offset: 2px; background-clip: padding-box; }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.sizegroup input { width: 110px; accent-color: var(--accent); }
.sizepreview { width: 30px; height: 30px; display: grid; place-items: center; }
.sizepreview::after { content: ""; width: var(--d, 6px); height: var(--d, 6px); max-width: 30px; max-height: 30px; border-radius: 50%; background: var(--c, #fff); }

.toast { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ui); color: var(--ui-text);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 3; }
.toast.show { opacity: .95; }

@media (max-width: 700px) {
  #toolGroup button span { display: none; }
  .name { width: 84px; }
  .sizegroup input { width: 80px; }
  .tools { gap: 4px; }
  .tools .group + .group { padding-left: 4px; }
  .swatch { width: 22px; height: 22px; min-width: 22px; }
}
@media (max-width: 420px) {
  #people { display: none; }
  .zoombar #saveBtn { display: none; }
}
