/* Drawing canvas, toolbar, pen palette. Palette tokens: the first one follows the theme ink (dark on light, light on dark);
   the rest are tuned per theme. Drafted by Antigravity (sketches/myday/note-editor.css), reworked here. */
:root {
  --dw-ink: var(--ink);
  --dw-red: light-dark(#C62828, #FF8A80);
  --dw-orange: light-dark(#C2570C, #FFB067);
  --dw-green: light-dark(#2E7D32, #7FD18A);
  --dw-blue: light-dark(#1565C0, #8DBBFF);
  --dw-violet: light-dark(#6B3FA0, #B99CEA);
}
.dw-probe { position: absolute; visibility: hidden; pointer-events: none; width: 0; height: 0; }

.dw { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }

.dw-bar {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface);
}
.dw-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; }
.dw-bar .dw-group:first-child { padding-left: 0; }
.dw-group + .dw-group { border-left: 1px solid var(--line-soft); }
/* Phone: no hidden scrolling. Row 1 tools + undo/redo/clear, row 2 colours, row 3 width. */
@media (max-width: 720px) {
  .dw-bar { padding: 4px; gap: 2px 8px; justify-content: space-between; }
  .dw-group { padding: 0; }
  .dw-group + .dw-group { border-left: 0; }
  .dw-bar .dw-group:nth-child(1) { order: 1; }
  .dw-bar .dw-group:nth-child(4) { order: 2; }
  .dw-bar .dw-colors { order: 3; flex: 1 1 100%; justify-content: space-between; border-top: 1px solid var(--line-soft); padding-top: 2px; }
  .dw-bar .dw-width { order: 4; flex: 1 1 100%; border-top: 1px solid var(--line-soft); }
  .dw-width .dw-range { flex: 1; width: auto; min-width: 0; }
}

.dw-tool {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid transparent; color: var(--ink-2); transition: background-color 0.12s, border-color 0.12s;
}
.dw-tool:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.dw-tool[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

.dw-colors { gap: 0; }
/* 40 px hit area; the 28 px colour dot is ::before. */
.dw-swatch { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; }
.dw-swatch::before {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--sw, var(--dw-ink));
}
.dw-swatch[data-c="ink"] { --sw: var(--dw-ink); }
.dw-swatch[data-c="red"] { --sw: var(--dw-red); }
.dw-swatch[data-c="orange"] { --sw: var(--dw-orange); }
.dw-swatch[data-c="green"] { --sw: var(--dw-green); }
.dw-swatch[data-c="blue"] { --sw: var(--dw-blue); }
.dw-swatch[data-c="violet"] { --sw: var(--dw-violet); }
.dw-swatch[aria-checked="true"]::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

.dw-width { gap: 8px; }
.dw-range { width: 88px; min-height: 40px; accent-color: var(--accent); }
.dw-width-val { min-width: 2ch; font-size: 13px; color: var(--ink-2); text-align: right; }

/* Zoom: a small overlay in the corner of the canvas (also the only control of the read-only preview). */
.dw-zoom {
  position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 2px; gap: 0; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.dw-zoom.dw-group + .dw-group { border-left: 1px solid var(--line); }
.dw-zoom-val { min-width: 54px; min-height: 40px; padding: 0 6px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; }
.dw-zoom-val:hover { background: var(--surface-2); color: var(--ink); }

.dw-stage {
  position: relative; flex: 1; min-height: 240px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-m);
  background-color: var(--surface-2);
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.2px); background-size: 22px 22px;
}
.dw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.dw-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.dw-stage[data-tool="eraser"] .dw-canvas { cursor: cell; }
.dw-stage[data-tool="hand"] .dw-canvas { cursor: grab; }
.dw-stage[data-panning] .dw-canvas { cursor: grabbing; }
.dw-hint { position: absolute; left: 12px; top: 10px; right: 12px; font-size: 12.5px; color: var(--muted); pointer-events: none; }
