:root {
  --ink: #1c2330;
  --muted: #5b6577;
  --line: #d5dae3;
  --desk: #e9ecf2;
  --accent: #1d6fe0;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--desk); color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.bar {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.group { display: flex; align-items: center; gap: 6px; }
button {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; cursor: pointer;
}
button:hover { background: #f2f5fa; }
button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #165bbd; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.swatch {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.stage {
  position: relative; flex: 1; min-height: 0; padding: 14px;
  display: flex; align-items: center; justify-content: center;
}
#board {
  max-width: 100%; max-height: 100%; background: #fff;
  box-shadow: 0 2px 12px rgba(20, 30, 50, .15); touch-action: none; user-select: none;
}
#board.t-pen, #board.t-rect, #board.t-circle { cursor: crosshair; }
#board.t-text { cursor: text; }
#layer g { cursor: move; }
#board:not(.t-select) #layer g { cursor: inherit; }
#layer g.sel { filter: drop-shadow(0 0 3px #1d6fe0) drop-shadow(0 0 1px #1d6fe0); }
#textInput {
  position: absolute; z-index: 5; margin: 0; padding: 0 2px;
  border: 1px dashed var(--accent); background: rgba(255,255,255,.85);
  font-family: "Comic Sans MS", "Segoe Print", "Marker Felt", cursive; outline: none; min-width: 120px;
}
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #b3261e; }
