/* ============================================================
   DRAWING CANVAS — full-viewport board, pressure/speed brush.
   Tokens ported from the PWN-ALL design system (light enterprise palette).
   ============================================================ */
:root {
  /* surfaces */
  --surface-page:   #f6f8fc;
  --surface-card:   #ffffff;
  --surface-sunken: #eef2f8;
  /* text */
  --text-strong: #0b1220;
  --text-body:   #3a4a63;
  --text-muted:  #566480;
  --text-faint:  #7d8aa3;
  /* borders */
  --border-subtle:  #e2e8f1;
  --border-default: #d4dce8;
  --border-focus:   #2f6bff;
  /* accent (emerald) */
  --accent:      #00a878;
  --accent-text: #007152;
  --accent-soft: #e6faf2;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-sm: 0 6px 20px -12px rgba(11, 18, 32, 0.22);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
    --surface-page:   #16171a;
    --surface-card:   #1d1f23;
    --surface-sunken: #25282e;
    --text-strong: #e7e8ec;
    --text-body:   #9aa0aa;
    --text-muted:  #8c929c;
    --text-faint:  #6f757e;
    --border-subtle:  #2c2f36;
    --border-default: #383c44;
    --border-focus:   #9aa9d2;
    --accent:      #9aa9d2;
    --accent-text: #c3cde6;
    --accent-soft: #262b36;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 20px 48px -24px rgba(0, 0, 0, 0.6);
  }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-page:   #16171a;
    --surface-card:   #1d1f23;
    --surface-sunken: #25282e;
    --text-strong: #e7e8ec;
    --text-body:   #9aa0aa;
    --text-muted:  #8c929c;
    --text-faint:  #6f757e;
    --border-subtle:  #2c2f36;
    --border-default: #383c44;
    --border-focus:   #9aa9d2;
    --accent:      #9aa9d2;
    --accent-text: #c3cde6;
    --accent-soft: #262b36;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 20px 48px -24px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--surface-page); color: var(--text-strong); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-text); }
button, input { font: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; border-radius: 6px; }
.ico { width: 15px; height: 15px; flex: none; }

/* ---- Stage: full working area, canvas is always white (it IS the artwork) ---- */
.stage {
  position: relative;
  height: 100dvh; /* matches the JS-set height (theme.js hides the sticky bar), no layout jump */
  background: var(--surface-page); /* visible only past the board's growth cap */
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
/* touch-action on the canvases only: drawing never scrolls the page, but pans
   starting on the toolbar/panel still do — the FAQ stays reachable on phones */
.view { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#board {
  position: absolute; left: 0; top: 0; touch-action: none;
  box-shadow: 0 0 0 1px var(--border-default); /* marks the board edge when the growth cap is hit */
}
/* viewport-sized input surface + shape preview, above #view, below the toolbar/panel */
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* ---- Left toolbar ---- */
.toolbar {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); z-index: 5;
  max-height: calc(100% - 16px); overflow-y: auto;
}
.tool {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid transparent; background: none; border-radius: var(--radius-sm);
  color: var(--text-body); cursor: pointer; padding: 0;
}
.tool:hover { background: var(--surface-sunken); color: var(--text-strong); }
.tool.is-active { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.tool:disabled { opacity: 0.35; cursor: default; background: none; color: var(--text-body); }
.tool svg { width: 20px; height: 20px; }
.tb-div { height: 1px; margin: 4px 6px; background: var(--border-default); }

/* ---- Settings panel ---- */
.panel {
  /* below theme.js's floating theme/menu chrome (fixed top:20px right:20px) */
  position: absolute; top: 68px; right: 12px; z-index: 5; width: 244px;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  max-height: calc(100% - 80px); overflow-y: auto;
}
.panel > summary {
  list-style: none; cursor: pointer; padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px; color: var(--text-strong);
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary svg { width: 16px; height: 16px; color: var(--text-muted); }
.panel > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.8px solid var(--text-muted); border-bottom: 1.8px solid var(--text-muted); transform: rotate(45deg); transition: transform 0.15s; }
.panel[open] > summary::after { transform: rotate(-135deg); }
.panel-body { padding: 2px 14px 14px; display: grid; gap: 12px; }
.ctl { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
.ctl-row { display: flex; justify-content: space-between; align-items: baseline; }
.ctl output { font-family: var(--font-mono); font-size: 11px; color: var(--text-strong); }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
input[type="color"] {
  width: 100%; height: 36px; padding: 3px; cursor: pointer;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card);
}
.panel-actions { display: flex; gap: 8px; margin-top: 2px; }
.btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
  background: var(--surface-card); color: var(--text-body);
}
.btn:hover { background: var(--surface-sunken); color: var(--text-strong); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
/* brightness, not a token swap — theme.css overrides --accent/--accent-text to equal values */
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #ffffff; filter: brightness(1.15); }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary:hover { color: #16171a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-primary:hover { color: #16171a; }
}

/* ---- Inline text entry ---- */
.text-entry {
  position: absolute; z-index: 6; min-width: 40px;
  background: transparent; border: 1.5px dashed #8a94a8; border-radius: 4px;
  padding: 0 4px; font-family: var(--font-sans); line-height: 1.2; outline: none;
  user-select: text; -webkit-user-select: text; /* .stage disables selection — re-enable for editing */
}

/* ---- Info / FAQ (below the fold) ---- */
.info { width: min(980px, 100%); margin: 0 auto; padding: clamp(32px, 5vw, 56px) clamp(16px, 4vw, 24px) 64px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-text); }
.info h1 { margin: 0 0 10px; font-size: clamp(20px, 3vw, 26px); line-height: 1.25; }
.info-intro p { margin: 0; color: var(--text-body); max-width: 70ch; }
.faq { margin-top: 24px; display: grid; gap: 10px; }
.faq details { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 0 16px; box-shadow: var(--shadow-xs); }
.faq summary { cursor: pointer; padding: 13px 0; font-weight: 600; color: var(--text-strong); }
.faq details p { margin: 0 0 14px; color: var(--text-body); }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .toolbar { left: 8px; padding: 6px; gap: 2px; }
  .tool { width: 36px; height: 36px; }
  .tool svg { width: 18px; height: 18px; }
  .panel { top: 64px; right: 8px; width: 210px; }
}
