/* Playpen Sans, hosted on sketch.new itself (no Google Fonts), from Fontsource. SIL Open Font License, see /font/LICENSE.txt */
@font-face {
  font-family: 'Playpen Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/font/playpen-sans-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Playpen Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/font/playpen-sans-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Playpen Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/font/playpen-sans-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Playpen Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/font/playpen-sans-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --paper: #f6f4ef;
  --dot: #d9d5cb;
  --ink: #1c1b19;
  --bar: rgba(255,255,255,0.94);
  --bar-border: rgba(28,27,25,0.08);
  --muted: #8a867d;
  --active: #1c1b19;
  --active-fg: #f6f4ef;
  --hover: #f2f2f0;   /* solid, so every hover is the same gray whatever is behind it */
  --accent: #06b6d4;
  --swatch-ring: rgba(0,0,0,0.12);
  --black: #1c1b19;   /* how the first color, black, is shown */
  --toast-bg: #1c1b19;
  --toast-fg: #f6f4ef;
}
/* Dark mode follows the system: a black page, and black ink shown as white */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121211;
    --dot: #353430;
    --black: #f2f1ee;
    --toast-bg: #f2f1ee;
    --toast-fg: #1c1b19;
    --ink: #f2f1ee;
    --bar: rgba(38,37,35,0.94);
    --bar-border: rgba(255,255,255,0.09);
    --muted: #a19d94;
    --active: #f2f1ee;
    --active-fg: #1c1b19;
    --hover: #4d4b47;
    --swatch-ring: rgba(255,255,255,0.28);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;   /* no iOS long-press callout (Save Image, Copy, etc.) */
}
/* The dot grid: drawn by app.js as real circles, behind the drawing canvas */
canvas#grid {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  transition: opacity .18s ease-out;
}
canvas#grid.zooming { opacity: 0; transition-duration: .08s; }   /* hidden while zooming */
/* The canvas fills exactly the visible area; app.js matches its pixel buffer
   to this measured size so nothing is ever stretched (phones change the visible
   height as the browser's address bar shows and hides) */
canvas#c {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* While the privacy card is open, only the card and the (i) show */
body.info-open .toolbar, body.info-open .ctxbar, body.info-open .popover { opacity: 0; visibility: hidden; pointer-events: none; }

.bar {
  position: fixed; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 6px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(28,27,25,0.10), 0 1px 3px rgba(28,27,25,0.06);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  max-width: calc(100vw - 24px);
  overflow-x: auto; scrollbar-width: none;
}
.bar::-webkit-scrollbar { display: none; }
.toolbar { bottom: max(16px, env(safe-area-inset-bottom)); }
.ctxbar {
  top: max(12px, env(safe-area-inset-top)); transition: opacity .15s ease, transform .15s ease;
  /* centered with margins rather than a 50% shift, so it can use the full width before it
     wraps; kept clear of the (i) button */
  left: 0; right: 0; margin: 0 auto; width: fit-content; transform: none;
  max-width: calc(100vw - 112px); flex-wrap: wrap; overflow: visible;
}
.ctxbar.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px); }

.sep { width: 1px; height: 24px; background: var(--bar-border); margin: 0 4px; flex: none; }
/* starts a new row in a wrapped bar (added by the app where a group of buttons must not join the row above) */
.rowbreak { flex: 0 0 100%; height: 0; margin-top: -4px; }

button {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ink);
  cursor: pointer; padding: 0;
  transition: background .12s ease, transform .08s ease;
}
button:hover { background: var(--hover); }
button:active { transform: scale(0.94); }
button.on { background: var(--active); color: var(--active-fg); }
button:disabled { opacity: .3; cursor: default; background: transparent; }
button svg { width: 20px; height: 20px; }
button.danger:hover { background: rgba(225,29,72,0.1); color: #e11d48; }

#shapeBtn { width: 48px; display: flex; gap: 1px; justify-content: center; align-items: center; }
#shapeBtn svg.caret { width: 10px; height: 10px; }

.swatch { width: 30px; height: 30px; border-radius: 50%; position: relative; }
.swatch i {
  width: 20px; height: 20px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
}
.swatch.on { background: transparent; box-shadow: 0 0 0 2px var(--ink); }
.custom { position: relative; overflow: hidden; }
.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.custom i { background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #3b82f6, #a855f7, #f43f5e); }

.size i, .osize i { background: var(--ink); border-radius: 50%; display: block; }
.size.on i, .osize.on i { background: var(--active-fg); }
.osize { width: 32px; }

.popover {
  position: fixed;
  display: grid; grid-template-columns: repeat(5, 40px); gap: 4px;
  padding: 8px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(28,27,25,0.14);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transform: translateX(-50%);
}
.popover[hidden] { display: none; }
.popover button { width: 40px; height: 40px; }

/* Privacy (i) button and card */
.info-btn {
  position: fixed; z-index: 6;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bar); color: var(--ink);
  border: 1px solid var(--bar-border);
  box-shadow: 0 2px 10px rgba(28,27,25,0.08);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.info-btn svg { width: 18px; height: 18px; }
.info-btn { transition: transform .08s ease; }   /* keep the click squish, no hover fade */
.info-btn:hover { background: var(--hover); border-color: var(--hover); }
.info-btn.on { z-index: 31; background: var(--active); color: var(--active-fg); border-color: var(--active); }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 16px;
  background: rgba(28,27,25,0.18);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: min(440px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto;
  padding: 22px 24px 18px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(28,27,25,0.18), 0 1px 3px rgba(28,27,25,0.06);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 14px; line-height: 1.5; color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.modal-logo { display: block; height: 64px; width: auto; max-width: 100%; margin: 6px auto 20px; }
.modal h2 { margin: 0 0 8px; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.modal p { margin: 0 0 10px; }
.modal ul { margin: 0 0 12px; padding-left: 18px; }
.modal li { margin-bottom: 7px; }
.modal a { color: var(--ink); }
.support-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 16px 0 4px; padding: 11px 16px; border-radius: 12px;
  background: var(--active); color: var(--active-fg) !important;
  font-weight: 600; text-decoration: none;
  transition: transform .08s ease, opacity .12s ease;
}
.support-btn:hover { opacity: .88; }
.support-btn:active { transform: scale(0.98); }
.support-btn svg { width: 18px; height: 18px; flex: none; }
.modal .fine { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; color: var(--ink); }
.modal-close svg { width: 18px; height: 18px; }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translate(-50%, -8px);
  background: var(--toast-bg); color: var(--toast-fg);
  padding: 8px 14px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .2s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dropzone {
  position: fixed; inset: 12px; border: 2px dashed var(--accent); border-radius: 20px;
  background: rgba(6,182,212,0.06); pointer-events: none;
  display: grid; place-items: center; color: var(--accent); font-weight: 600; font-size: 18px;
  opacity: 0; transition: opacity .15s ease;
}
.dropzone.show { opacity: 1; }

.swatches { display: flex; gap: 2px; align-items: center; }
/* the color row is as tall as a row of buttons, so a wrapped edit bar keeps even rows */
#colorGroup { min-height: 38px; }

/* Collapsible groups: invisible wrappers on larger screens, expanding pickers on phones */

/* In-place text editor laid over a text box while typing */
#textEditor {
  position: fixed; margin: 0; border: 0; outline: none; padding: 0;
  background: transparent; resize: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere; text-align: center;
  font-family: 'Playpen Sans', system-ui, sans-serif; font-weight: 400;
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 2px 1.5px rgba(255,255,255,0.85); border-radius: 2px;
  transform-origin: center center;
  -webkit-user-select: text; user-select: text;
  z-index: 5;
}
#textEditor[hidden] { display: none; }
.tb-group { display: flex; align-items: center; gap: 4px; flex: none; }


@media (max-width: 640px) {
  .hide-sm { display: none; }
  button { width: 36px; height: 36px; }
  #colorGroup { min-height: 36px; }
}

/* Phones in portrait: vertical toolbar on the right edge. (Phones turned sideways are wide
   enough for the regular layout: toolbar along the bottom, edit bar centered at the top.) */
@media (max-width: 640px) {
  .toolbar {
    left: auto; bottom: auto;
    right: max(8px, env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-x: hidden; overflow-y: auto;
    padding: 5px;
    gap: 2px;
  }
  .toolbar .sep { width: 24px; height: 1px; margin: 4px 0; }
  /* short phones (e.g. iPhone SE): slightly smaller buttons so the whole toolbar fits */
  @media (max-height: 740px) {
    .toolbar { padding: 4px; gap: 1px; }
    body .toolbar .tb-group { gap: 1px; }
    .toolbar button { width: 31px; height: 31px; }
    .toolbar button svg { width: 18px; height: 18px; }
    .toolbar .sep { margin: 2px 0; }
    body .toolbar #shapeBtn { width: 31px; }
  }
  .toolbar .tb-group { flex-direction: column; gap: 2px; }

  .toolbar #shapeBtn { width: 36px; }
  .toolbar #shapeBtn svg.caret { display: none; }

  /* keep the top bar clear of the toolbar */
  .ctxbar { left: 12px; right: auto; margin: 0; transform: none; max-width: calc(100vw - 84px); flex-wrap: wrap; overflow: visible; }
  .ctxbar.hidden { transform: translateY(-6px); }
  /* messages slide up from the bottom on phones, where the edit bar would cover them at the top */
  .toast { max-width: calc(100vw - 96px); white-space: normal; text-align: center; left: calc(50% - 30px);
           top: auto; bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); transform: translate(-50%, 8px); }
  .toast.show { transform: translate(-50%, 0); }
}