@font-face {
  font-family: "Fredoka";
  src: url("fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* Puddle Paint's own colors: the paints the mascot comes in */
  --coral: #ff6b5b;
  --sun: #ffc83d;
  --sky: #4aa8ff;
  --mint: #3ccf91;
  --lilac: #a678f0;
  --peach: #ff9f5a;
  --pink: #ff7eb6;
  --bg: #ffffff;
  --desk: #f6f6f7;      /* around the page while painting: just off white so the page reads */
  --ink: #1d1d1f;
  --muted: #8a8a8f;
  --line: #ededf0;
  --soft: #f4f4f6;      /* quiet fills: chips, search box, calendar days */
  --card: #ffffff;
  --red: #e8584a;
  --red-deep: #b9392d;
  --blue: #2f5be0;
  --lime: #d9f53b;
  --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ui: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* an app, not a document: no text selection or long-press callouts except where you type */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, label { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ library */

#library {
  min-height: 100%;
  padding: calc(var(--safe-t) + 0px) calc(var(--safe-r) + 0px) calc(var(--safe-b) + 48px) calc(var(--safe-l) + 0px);
}
/* the library scrolls on its own, so the page itself never rubber-bands and the menu stays put */
#library {
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(var(--safe-b) + 84px);
}
#library.behind { visibility: hidden; } /* under an open picture: kept laid out to keep its scroll position */
.zoom-ghost { position: fixed; z-index: 60; margin: 0; pointer-events: none; transform-origin: 0 0; box-shadow: 0 20px 40px -24px rgba(0,0,0,.35); }

/* the quick palette (Apple Pencil squeeze, or double-tap set to show the palette) */
.quick {
  position: absolute; z-index: 8; display: grid; gap: 10px; padding: 12px;
  max-width: min(420px, calc(100% - 16px));
  background: rgba(255,255,255,.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 18px 40px -18px rgba(0,0,0,.35);
}
.quick[hidden] { display: none; }
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quick .swatch { width: 34px; height: 34px; }
.quick .swatch.num { width: 44px; height: 44px; }
.quick-tool { width: 52px; height: 52px; border: 0; border-radius: 14px; background: none; color: var(--muted); display: grid; place-items: center; }
.quick-tool svg { width: 36px; height: 36px; stroke-width: 1.4; }
.quick-tool .tip { fill: var(--tool-color, var(--coral)); }
.quick-tool[aria-pressed="true"] { background: var(--soft); color: var(--ink); }
.view { max-width: 1180px; margin: 0 auto; padding-top: calc(var(--safe-t) + 8px); }

/* bottom menu */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  padding: 6px max(8px, var(--safe-l)) calc(var(--safe-b) + 6px);
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  position: relative; flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 4px; border: 0; background: none; color: #a3a3a8;
  font-size: 12px; font-weight: 500;
}
.tabbar svg { position: relative; z-index: 1; width: 25px; height: 25px; stroke-width: 1.7; }
.tabbar button::before {
  content: ""; position: absolute; top: 1px; left: 50%; width: 50px; height: 34px; margin-left: -25px;
  border-radius: 58% 42% 52% 48% / 62% 54% 46% 38%; background: var(--tc);
  opacity: 0; transform: scale(.3) rotate(-14deg);
  transition: transform .45s cubic-bezier(.3,1.7,.45,1), opacity .2s;
}
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar button[aria-current="page"]::before { opacity: .3; transform: scale(1) rotate(0); }
.tabbar button[aria-current="page"] svg { stroke-width: 2.1; animation: tab-pop .45s cubic-bezier(.3,1.7,.45,1); }
@keyframes tab-pop { 0% { transform: scale(.8) translateY(2px); } 100% { transform: none; } }
.tabbar [data-tab="studio"] { --tc: var(--coral); }
.tabbar [data-tab="daily"] { --tc: var(--sun); }
.tabbar [data-tab="library"] { --tc: var(--sky); }
.tabbar [data-tab="search"] { --tc: var(--mint); }
.tabbar [data-tab="more"] { --tc: var(--lilac); }

/* category and filter chips */
.chips {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: calc(var(--safe-t) + 10px) 24px 10px; margin-top: calc(-1 * (var(--safe-t) + 8px));
  background: var(--bg);
}
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { position: static; flex-wrap: wrap; margin-top: 0; padding-top: 4px; }
.chips:empty { display: none; }
.chips button {
  flex: none; padding: 7px 15px; border-radius: 20px 17px 21px 16px / 17px 21px 16px 20px; border: 0;
  background: none; font-weight: 500; font-size: 16px; color: var(--muted);
  transition: background .2s, color .2s, transform .3s cubic-bezier(.3,1.7,.45,1);
}
.chips button[aria-pressed="true"] { background: color-mix(in srgb, var(--cc, #8a8a8f) 24%, #fff); color: var(--ink); font-weight: 600; }
.chips button:active { transform: scale(.94); }
.chips.wrap button { background: color-mix(in srgb, var(--cc, #8a8a8f) 16%, #fff); color: var(--ink); }

/* Daily */
.daily { display: grid; gap: 22px; padding: 12px 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.today-card .card { gap: 0; }
.today-label { margin: 0 0 12px 2px; display: grid; line-height: 1.15; }
.today-label small { font-size: 15px; color: var(--muted); }
.today-label span { font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.cal { padding: 0 0 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h3 { margin: 0; font-size: 19px; font-weight: 600; text-transform: capitalize; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; text-align: center; }
.cal-week { margin: 6px 0 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.cal-cell {
  position: relative; aspect-ratio: 1; border-radius: 14px 12px 15px 11px; border: 0; padding: 0;
  background: var(--lines, none) center / cover no-repeat, var(--img, none) center / cover no-repeat, var(--soft);
  background-blend-mode: multiply; font-weight: 500; font-size: 14px; color: var(--ink);
}
.cal-cell.pad { background: none; }
.cal-cell:disabled { color: #c7c7cc; background: none; }
.cal-cell.today { background-color: color-mix(in srgb, var(--sun) 30%, #fff); box-shadow: inset 0 0 0 2px var(--sun); font-weight: 600; }
.cal-cell.started b, .cal-cell.done b { position: absolute; left: 3px; top: 2px; font-size: 10px; background: rgba(255,255,255,.85); border-radius: 6px; padding: 0 3px; }
.cal-cell.started, .cal-cell.done { border-radius: 2px; } /* a picture preview: keep its corners */
.cal-cell.done::after {
  content: "✓"; position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--mint); color: #fff; font-size: 10px; line-height: 16px;
}

/* Search */
.search-bar {
  display: flex; align-items: center; gap: 10px; margin: 6px 24px 4px; padding: 0 14px;
  height: 46px; border-radius: 12px; background: var(--soft); border: 0;
}
.search-bar svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font: inherit; font-size: 18px; }
.empty-line { margin: 30px 24px; display: grid; justify-items: center; gap: 10px; text-align: center; color: var(--muted); font-size: 17px; }
.empty-line .mascot, .empty .mascot { width: 120px; height: auto; }

/* Studio empty state */
.empty { display: grid; justify-items: center; gap: 14px; padding: 60px 24px; color: var(--muted); text-align: center; }
.empty p { margin: 0; font-size: 17px; }

/* More */
.settings { margin: 12px 24px; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.settings .row {
  width: 100%; display: flex; align-items: center; gap: 14px;
  min-height: 58px; padding: 0 14px; border: 0; background: none; text-align: left;
  font-size: 17px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.settings .row > span:not(.tile) { flex: 1; }
.settings .row + .row { border-top: 1px solid var(--line); }
.tile {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 13px 10px 12px 9px; background: color-mix(in srgb, var(--cc) 26%, #fff);
}
.tile svg { width: 20px; height: 20px; stroke-width: 2; color: color-mix(in srgb, var(--cc) 70%, #1d1d1f); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 50px; height: 30px; border-radius: 999px; background: #e3e3e8; transition: background .2s; cursor: pointer; margin: 0;
}
.switch::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch:checked { background: var(--mint); }
.switch:checked::after { transform: translateX(20px); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num-icon { font-size: 13px; font-weight: 900; letter-spacing: -.02em; }

.grid {
  padding: 8px 24px 18px;
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.grid:empty { display: none; }
.card-wrap { position: relative; }
.card {
  position: relative; width: 100%;
  display: flex; flex-direction: column; gap: 10px;
  padding: 0; border: 0; background: none; text-align: left;
}
.thumb {
  position: relative; aspect-ratio: 1; overflow: hidden;
  background: #fff;
  border: 1px solid var(--line); border-radius: 0; /* square like the page: rounding would cut the drawing's corners */
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .3s cubic-bezier(.3,1.6,.45,1), box-shadow .2s ease;
}
.card:hover .thumb, .card:focus-visible .thumb { transform: translateY(-3px) rotate(-.8deg); box-shadow: 0 14px 28px -20px rgba(0,0,0,.3); }
.card:active .thumb { transform: scale(.96); }
.card:focus-visible { outline: none; }
.card:focus-visible .thumb { outline: 3px solid var(--blue); outline-offset: 3px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.thumb img.lines { mix-blend-mode: multiply; }
.chip {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .06em;
  padding: 4px 8px; border-radius: 999px; background: var(--lime); color: var(--ink);
}
.card-del {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.92);
  display: grid; place-items: center;
}
.card-del svg { width: 16px; height: 16px; }
.import-card .thumb {
  display: grid; place-items: center; align-content: center; gap: 10px;
  border: 1.5px dashed #dcdce0; background: #fff; color: var(--muted); box-shadow: none;
  text-align: center; padding: 18px; font-size: 15px; line-height: 1.35;
}
.import-card .thumb svg { width: 34px; height: 34px; color: #a3a3a8; stroke-width: 1.6; }
.import-card { display: block; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 0;
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-ghost { background: var(--soft); border: 0; cursor: pointer; }
.btn-ghost:hover { background: #ececef; }

/* ------------------------------------------------------------- studio */

#studio {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "tools stage" "dock dock";
  background: var(--desk);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

.top {
  grid-area: top; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top h2 {
  flex: 1; min-width: 0; margin: 0;
  font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.top-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 44px; padding: 0 8px;
  border: 0; border-radius: 12px; background: transparent;
}
.icon-btn svg { width: 23px; height: 23px; stroke-width: 1.8; }
.icon-btn:hover { background: var(--soft); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.back { font-weight: 700; padding-right: 12px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px; margin: 0 4px;
  border: 0; border-radius: 999px; background: var(--soft);
  font-weight: 600; font-size: 14px; color: var(--muted);
}
.toggle svg { width: 20px; height: 20px; }
.toggle[aria-pressed="true"] { background: #e8f8ec; color: #1f7a35; }
.toggle:disabled { opacity: .4; cursor: default; }

.tools {
  grid-area: tools; min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 8px;
  background: var(--bg); border-right: 1px solid var(--line);
  overflow-y: auto;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 72px; padding: 8px 4px 6px;
  border: 0; border-radius: 14px; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.tool svg { width: 40px; height: 40px; stroke-width: 1.4; }
.tool .tip { fill: var(--tool-color, var(--red)); }
.tool:hover { background: var(--soft); }
.tool[aria-pressed="true"] { background: var(--soft); color: var(--ink); }

.stage { grid-area: stage; position: relative; overflow: hidden; touch-action: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
/* The page's lines and numbers are drawn as vectors over the paint, so they stay sharp at any zoom.
   Multiply lets the white inside the shapes show the paint underneath. */
.vec { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
#ink-layer { mix-blend-mode: multiply; }
/* the page-wide `svg` icon rule must not reach the art or the numbers: it would outline them */
.vec, .vec svg { stroke: none; stroke-width: 0; }
.vec text { font-family: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; fill: #9a9aa0; font-weight: 500; }
.vec text.on { fill: #1d1d1f; font-weight: 650; stroke: #fff; stroke-linejoin: round; paint-order: stroke; }
.fit-btn {
  position: absolute; right: 14px; bottom: 14px;
  padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; box-shadow: 0 4px 14px -8px rgba(0,0,0,.18);
}
.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 16px; color: var(--muted);
}
.loading .mascot { width: 110px; height: auto; overflow: visible; }
.loading .mascot-body { transform-origin: 50% 88%; animation: squish .9s ease-in-out infinite; }
.loading .mascot-drop { animation: drip .9s ease-in infinite; }
@keyframes squish { 0%, 100% { transform: scale(1.06, .94); } 50% { transform: scale(.95, 1.06) translateY(-5px); } }
@keyframes drip { 0% { transform: translateY(-6px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }

.dock {
  grid-area: dock; min-width: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px;
  background: var(--bg); border-top: 1px solid var(--line);
}
.sizes { display: flex; align-items: center; gap: 4px; padding-right: 14px; border-right: 1px solid var(--line); }
.size {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center;
}
.size i { display: block; border-radius: 50%; background: var(--ink); }
.size[aria-pressed="true"] { background: var(--soft); }

.palette {
  flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 11px 12px; margin: -11px -12px; /* room for the picked swatch's growth and ring */
}
.swatch {
  position: relative;
  width: 40px; height: 40px; flex: none; border-radius: var(--shape, 50%);
  border: 1px solid rgba(0,0,0,.08);
  /* a dab of wet paint: a slightly uneven blob with a shine */
  background:
    radial-gradient(ellipse 22% 14% at 32% 26%, rgba(255,255,255,.75), rgba(255,255,255,0) 100%),
    var(--c);
  transition: transform .25s cubic-bezier(.3,1.7,.45,1), border-radius .35s ease;
}
.swatch:active { transform: scale(.9); }
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { transform: scale(1.14) rotate(-4deg); border-radius: var(--shape2, 50%); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.swatch.rainbow { background: conic-gradient(#ff4d4d, #ffb03b, #ffe14d, #4ad66d, #3bb8ff, #7a5cff, #ff4dd2, #ff4d4d); }
.swatch.custom { background: conic-gradient(from 90deg, #fff 0 25%, #ddd 0 50%, #fff 0 75%, #ddd 0); overflow: hidden; }
.swatch.custom::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: var(--ink); }
.swatch.custom.has-color { background: var(--c); }
.swatch.custom.has-color::after { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.swatch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 12px;
  background: rgba(29,29,31,.9); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 10px 30px -14px rgba(0,0,0,.35);
  z-index: 10;
}

#print-sheet { display: none; }

/* ---------------------------------------------------- color by number */

.badge-done {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--mint); color: #fff; box-shadow: 0 0 0 2px #fff;
}
.badge-done svg { width: 18px; height: 18px; stroke-width: 3; }
.thumb-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.12); overflow: hidden; }
.thumb-bar i { display: block; height: 100%; background: var(--mint); border-radius: 3px; }
.badge-free {
  position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.badge-free svg { width: 26px; height: 26px; }

.top { position: relative; }
#page-progress { color: var(--muted); font-family: var(--ui); font-size: .8em; font-weight: 700; }
.progress-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--line); }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--mint); border-radius: 0 3px 3px 0; transition: width .35s ease; }

.num-palette { display: none; }
#studio.numbers .tools, #studio.numbers .sizes, #studio.numbers #palette, #studio.numbers #inside-btn { display: none; }
#studio.numbers .num-palette { display: flex; }
#studio.numbers { grid-template-areas: "top top" "stage stage" "dock dock"; }
.swatch.num { width: 52px; height: 52px; display: grid; place-items: center; }
.swatch.num b { position: relative; font-size: 20px; font-weight: 600; color: var(--on); }
.swatch.num.complete { opacity: .45; }
.swatch.num.complete b { font-size: 0; }
.swatch.num.complete b::after { content: "✓"; font-size: 22px; }
.swatch.nudge { animation: nudge .5s ease; }
@keyframes nudge {
  0%, 100% { transform: scale(1.12) translateY(0); }
  30% { transform: scale(1.2) translateY(-3px); }
  60% { transform: scale(1.1) translateY(0); }
}
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* how much of each color is done: a ring inside the swatch edge */
.swatch.num::before {
  content: ""; position: absolute; inset: 2px; border-radius: inherit; pointer-events: none;
  background: conic-gradient(var(--on) calc(var(--p, 0) * 1%), rgba(127,127,127,.28) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  opacity: .75; transition: opacity .2s;
}
.swatch.num.complete::before { opacity: 0; }
.swatch.done-pop { animation: done-pop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes done-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.24) rotate(-8deg); }
  100% { transform: scale(1); }
}
.vec text.fade { animation: num-fade .35s ease forwards; }
@keyframes num-fade { to { opacity: 0; } }

.sound .mute { display: none; }
.sound[aria-pressed="false"] .wave { display: none; }
.sound[aria-pressed="false"] .mute { display: inline; }
#replay-btn svg path, .finish-actions svg path { fill: currentColor; }

/* "Find" hint, numbers pages only */
.find-btn {
  position: absolute; left: 14px; bottom: 14px; display: none; align-items: center; gap: 6px;
  padding: 10px 16px 10px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 4px 14px -8px rgba(0,0,0,.18);
}
.find-btn svg { width: 20px; height: 20px; stroke-width: 2; }
.find-btn:active { transform: scale(.96); }
#studio.numbers .find-btn { display: inline-flex; }
#studio.numbers.finished .find-btn { display: none; }
/* in the studio, messages sit above the page, clear of the Find and Fit buttons */
body:has(#studio:not([hidden])) .toast { bottom: auto; top: calc(var(--safe-t) + 84px); }

/* the card that shows when a numbers page is finished */
.finish {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(255,255,255,.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: finish-in .35s ease;
}
.finish[hidden] { display: none; }
.finish-card {
  position: relative; width: min(380px, 100%); padding: 28px 24px 22px; text-align: center;
  background: #fff; border-radius: 24px; border: 1px solid var(--line);
  box-shadow: 0 30px 70px -24px rgba(0,0,0,.28);
  animation: card-in .5s cubic-bezier(.3,1.5,.5,1);
}
.finish-burst { width: 130px; margin: -86px auto 4px; }
.finish-burst .mascot { width: 100%; height: auto; overflow: visible; }
.finish-burst .mascot-body { transform-origin: 50% 85%; animation: jiggle 1.1s cubic-bezier(.3,1.5,.5,1) .15s both; }
@keyframes jiggle {
  0% { transform: scale(.2, .2) translateY(30px); }
  35% { transform: scale(1.15, .85); }
  55% { transform: scale(.92, 1.1) translateY(-6px); }
  75% { transform: scale(1.04, .97); }
  100% { transform: none; }
}
.finish-card h3 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.01em; }
.finish-card p { margin: 6px 0 18px; color: var(--muted); }
.finish-actions { display: grid; gap: 8px; }
.finish-actions .btn { justify-content: center; cursor: pointer; }
.btn-solid { background: var(--coral); color: #fff; box-shadow: 0 6px 16px -8px rgba(255,107,91,.7); }
.btn-solid:active { transform: scale(.97); }
.finish-close { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 24px; color: var(--muted); }
@keyframes finish-in { from { opacity: 0; } }
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.92); } }

/* a card over the whole screen (Privacy) */
.sheet {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  padding: calc(var(--safe-t, 0px) + 16px) 16px calc(var(--safe-b, 0px) + 16px);
  background: rgba(255,255,255,.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: finish-in .25s ease;
}
.sheet[hidden] { display: none; }
.sheet-card {
  position: relative; width: min(440px, 100%); max-height: 100%; overflow-y: auto; padding: 24px 22px 20px;
  background: #fff; border-radius: 24px; border: 1px solid var(--line); box-shadow: 0 30px 70px -24px rgba(0,0,0,.28);
  animation: card-in .4s cubic-bezier(.3,1.4,.5,1);
}
.sheet-card h3 { margin: 0 0 10px; font-size: 26px; font-weight: 600; }
.sheet-card p { margin: 0 0 12px; font-size: 16px; line-height: 1.45; color: var(--ink); }
.sheet-card .fine { margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.sheet-card a { color: inherit; }
.sheet-close { position: absolute; right: 6px; top: 6px; width: 48px; height: 48px; border: 0; border-radius: 50%; background: transparent; font-size: 26px; color: var(--muted); cursor: pointer; }

/* who's coloring (More) */
.section-title { margin: 8px 24px 2px; font-size: 15px; font-weight: 600; color: var(--muted); }
.profiles { display: flex; gap: 6px; overflow-x: auto; padding: 6px 18px 4px; scrollbar-width: none; }
.profiles::-webkit-scrollbar { display: none; }
.profile {
  flex: none; width: 84px; display: grid; justify-items: center; gap: 4px; padding: 8px 4px 6px;
  border: 0; border-radius: 16px; background: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.profile .mascot { width: 58px; height: auto; }
.profile span { max-width: 100%; overflow: hidden; line-height: 1.15; text-align: center; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.profile[aria-pressed="true"] { background: var(--soft); color: var(--ink); font-weight: 600; }
.profile:active { transform: scale(.95); }
.profile.add .plus {
  width: 46px; height: 46px; margin: 2px 0 1px; display: grid; place-items: center; border-radius: 50%;
  border: 2px dashed #d3d3d8; font-size: 26px; font-weight: 400; color: #a3a3a8;
}
.row-note { margin-left: auto; font-size: 15px; color: var(--muted); font-weight: 500; }
.select {
  appearance: none; -webkit-appearance: none; margin-left: auto; max-width: 52%; border: 0; border-radius: 10px;
  padding: 8px 28px 8px 12px; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%238a8a8f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 8px center / 16px no-repeat;
}
/* kid profiles: no grown-up things (Community, links out); grown-ups don't see the kid-only text */
.kid .grown-up { display: none !important; }
.kid-only { display: none; }
.kid .kid-only { display: inline; }

/* a view with its own back button (Community) */
.view-head { display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.view-head h3 { margin: 0; font-size: 24px; font-weight: 600; }
.more-btn { display: block; margin: 4px auto 24px; cursor: pointer; }

/* Daily: days in a row */
.streak {
  display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--peach) 18%, #fff); color: var(--ink);
}
.streak svg { width: 22px; height: 22px; fill: var(--peach); stroke: color-mix(in srgb, var(--peach) 60%, #1d1d1f); stroke-width: 1.6; stroke-linejoin: round; }
.streak b { font-weight: 600; font-size: 16px; }
.streak small { margin-left: auto; color: var(--muted); font-size: 14px; }

/* tiles: new, and colored with someone's colors */
.badge-new { position: absolute; right: 9px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px #fff; }
.badge-tpl {
  position: absolute; left: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pink); box-shadow: 0 0 0 2px #fff;
}
.badge-tpl svg, .post-likes svg { width: 16px; height: 16px; fill: #fff; }
.post-likes {
  position: absolute; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px;
  border-radius: 999px; background: rgba(255,255,255,.92); font-size: 13px; font-weight: 600; color: var(--ink);
  box-shadow: 0 2px 8px -4px rgba(0,0,0,.3);
}
.post-likes svg { fill: none; stroke: var(--pink); stroke-width: 2.4; }
.post-likes.on svg { fill: var(--pink); }

/* finish card: a new sticker */
.finish-sticker { display: flex; align-items: center; gap: 10px; margin: -6px 0 16px; padding: 8px 12px; border-radius: 14px; background: color-mix(in srgb, var(--sun) 22%, #fff); text-align: left; font-weight: 600; }
.finish-sticker[hidden] { display: none; }
.finish-sticker .mascot { width: 54px; height: auto; flex: none; }

/* sheets' contents */
.sheet-card:focus { outline: none; }
.sheet-card.wide { width: min(560px, 100%); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { cursor: pointer; }
.btn.danger, .link.danger { color: var(--red-deep); }
.sheet-actions .btn.danger { margin-right: auto; }
.gate-card { text-align: center; width: min(340px, 100%); }
.gate-card #gate-ask { font-size: 26px; font-weight: 600; margin: 10px 0 14px; }
.gate-card input {
  width: 120px; padding: 10px; border: 2px solid var(--line); border-radius: 14px; text-align: center;
  font: inherit; font-size: 26px; font-weight: 600; color: var(--ink); outline: none;
}
.gate-card input:focus { border-color: var(--sky); }
.gate-card .sheet-actions { justify-content: center; }
.field { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.field input {
  padding: 11px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; font-size: 17px; font-weight: 500; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--sky); }
.profile-preview { display: grid; justify-items: center; }
.profile-preview .mascot { width: 110px; height: auto; }
.color-dots { display: flex; flex-wrap: wrap; gap: 10px; }
.color-dot { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--dot); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); }
.color-dot[aria-pressed="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.row-inline { display: flex; align-items: center; gap: 14px; margin: 14px 0 0; }
.row-inline span { flex: 1; display: grid; gap: 3px; }
.row-inline b { font-weight: 600; font-size: 16px; }
.row-inline small { color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.row-inline[hidden] { display: none; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-top: 12px; }
.sticker { display: grid; justify-items: center; align-content: start; gap: 3px; padding: 10px 6px; border-radius: 16px; background: var(--soft); text-align: center; }
.sticker .mascot { width: 84px; height: auto; }
.sticker b { font-size: 14px; font-weight: 600; }
.sticker small { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.sticker.locked b { color: var(--muted); }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.choice { display: grid; gap: 8px; justify-items: center; padding: 10px 6px; border: 0; border-radius: 14px; background: var(--soft); font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.choice[hidden] { display: none; }
.choice img { width: 100%; aspect-ratio: 2480 / 3508; object-fit: contain; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px -4px rgba(0,0,0,.25); }
.choice:active { transform: scale(.96); }
.share-preview { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; margin: 6px 0 10px; border-radius: 10px; background: var(--soft); }
.post-actions { display: flex; align-items: center; gap: 10px; }
.post-actions .btn { flex: 1; justify-content: center; cursor: pointer; }
.like {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; border-radius: 999px; background: var(--soft);
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
}
.like svg { width: 22px; height: 22px; fill: none; stroke: var(--pink); stroke-width: 2.2; }
.like[aria-pressed="true"] svg { fill: var(--pink); }
.like:active { transform: scale(.94); }
.post-small { display: flex; justify-content: space-between; margin-top: 12px; }
.link { border: 0; background: none; padding: 6px 0; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.version { margin: 28px 0 0; display: grid; justify-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.version .mascot { width: 54px; height: auto; }

/* -------------------------------------------------------- small screens */

@media (max-width: 760px) {
  .grid { padding: 6px 16px 16px; gap: 12px; grid-template-columns: repeat(2, 1fr); }
  .chips { padding-left: 16px; padding-right: 16px; }
  .daily { grid-template-columns: minmax(0, 1fr); padding: 8px 16px; gap: 16px; }
  .search-bar, .settings { margin-left: 16px; margin-right: 16px; }

  #studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "stage" "tools" "dock";
  }
  .top { padding: 4px 6px; gap: 2px; }
  .top h2 { font-size: 17px; }
  .back span, .toggle span { display: none; }
  .toggle { padding: 0 10px; margin: 0 2px; }
  .icon-btn { min-width: 40px; padding: 0 6px; }
  .tools {
    flex-direction: row; justify-content: space-between;
    padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line);
    overflow: visible;
  }
  .tool { width: auto; flex: 1; padding: 4px 2px; }
  .tool svg { width: 32px; height: 32px; }
  .dock { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 10px; }
  .sizes { justify-content: center; border-right: 0; padding-right: 0; }
  /* a sideways-scrolling bar clips whatever sticks out of it: leave room for the picked swatch's growth and ring */
  .palette { flex-wrap: nowrap; overflow-x: auto; padding: 12px 14px; margin: -6px -10px; scroll-padding-inline: 14px; scrollbar-width: none; }
  .palette::-webkit-scrollbar { display: none; }
  .swatch { width: 38px; height: 38px; }
  .swatch.num { width: 46px; height: 46px; }
  #studio.numbers { grid-template-areas: "top" "stage" "stage" "dock"; }
      #page-progress { display: block; font-size: 12px; }
}
#overflow-btn { display: none; }
@media (max-width: 400px) {
  /* no room for every button: Print and Start over go under ⋯ */
  #print-btn, #clear-btn { display: none; }
  #overflow-btn { display: inline-flex; }
}
.menu-card { width: min(320px, 100%); padding: 8px; align-self: end; }
.menu-row {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 12px; border: 0; border-radius: 12px; background: none;
  font: inherit; font-size: 17px; font-weight: 500; color: var(--ink); cursor: pointer; text-align: left;
}
.menu-row:active { background: var(--soft); }
.menu-row svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- print */

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .screen, .toast { display: none !important; }
  #print-sheet { display: flex !important; align-items: center; justify-content: center; height: 100vh; }
  #print-img { max-width: 100%; max-height: 100%; }
}
