@font-face {
  font-family: "Nirvanna";
  src: url("fonts/Nirvanna.otf") format("opentype");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Garamondt";
  src: url("fonts/Garamondt-Regular.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Garamondt";
  src: url("fonts/Garamondt-Italic.woff") format("woff");
  font-weight: normal; font-style: italic; font-display: swap;
}

:root {
  --paper: #fbf8f1;
  --ink: #1d1b18;
  --muted: #6f6a61;
  --soft: #e7e1d4;
  --accent: #ff5a3c;
  --hand: "Reenie Beanie", cursive;
  --ui: "Reenie Beanie", cursive;
  --canvas: 560px;
  --page-h: 700px;
  --head-h: 100px;
  --foot-h: 72px;
  --bstroke: 3px;
  --border: #ffffff;
  --strip-ink: #1d1b18;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 21px;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- shared bits ---------- */
.btn {
  border: 3px solid var(--ink);
  background: #fff;
  border-radius: 999px;
  padding: 9px 20px;
  font-weight: 800;
  font-size: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .12s, box-shadow .12s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-big { font-size: 22px; padding: 12px 48px; }
.btn-ghost { box-shadow: none; border-width: 2px; padding: 7px 16px; font-size: 21px; }
.btn-ghost:hover { background: var(--paper); }
.btn-ghost:active { transform: none; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.logo { font-family: var(--hand); font-weight: 400; letter-spacing: .05em; }
.logo-small { font-size: 30px; background: none; border: 0; padding: 0; line-height: 1; }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  border: 2px solid var(--ink); border-radius: 10px; background: #fff;
  display: grid; place-items: center; padding: 0;
}
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn svg, .tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.text-btn {
  border: 2px solid var(--ink); border-radius: 10px; background: #fff;
  padding: 0 12px; height: 38px; font-size: 21px; font-weight: 800;
}
.link-btn { background: none; border: 0; text-decoration: underline; font-weight: 700; color: var(--muted); margin-top: 22px; }

.cur-color { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; background: var(--ink); flex: none; }

/* ---------- home ---------- */
#home {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  position: relative; overflow: hidden;
  padding: 32px 16px;
}
.home-inner { position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; align-items: center; }
.home-inner .logo { font-size: clamp(72px, 16vw, 128px); line-height: .85; margin: 0; }
.tagline { font-family: var(--hand); font-size: 28px; margin: 6px 0 0; }
.sub { font-family: var(--hand); font-size: 22px; color: var(--muted); margin: 2px 0 22px; }
.title-card {
  margin-top: 34px;
  width: min(360px, 86vw); height: 190px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 0 6px 0 var(--ink);
  display: grid; place-items: center; padding: 16px;
}
.tc-content { display: flex; flex-direction: column; align-items: center; }
.tc-meta { font-size: 21px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tc-title { font-family: var(--hand); font-size: 36px; line-height: 1.05; margin: 8px 0 6px; }
.tc-hint { font-size: 21px; color: var(--muted); }

.morph {
  position: fixed; z-index: 100; margin: 0;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  display: grid; place-items: center; overflow: hidden; pointer-events: none;
}

.squiggles { position: absolute; inset: 0; pointer-events: none; }
.sq {
  position: absolute; width: 46px; height: 30px;
  fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  animation: wiggle 2.6s ease-in-out infinite alternate;
  opacity: .8;
}
@keyframes wiggle {
  from { transform: rotate(-7deg) translateY(0); }
  to   { transform: rotate(7deg) translateY(-5px); }
}

/* ---------- drawing ---------- */
#draw {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--paper);
}
.draw-top {
  flex: none; height: 60px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: calc(var(--canvas) + 284px + 40px); margin: 0 auto;
}
.dots { display: flex; gap: 8px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); transition: background .3s, transform .3s; }
.dots i.on { background: var(--ink); transform: scale(1.15); }
.dots i.past { background: var(--soft); }
.back-btn.off { visibility: hidden; }

#viewport { position: relative; overflow: hidden; flex: none; }
#track { will-change: transform; transition: transform .8s cubic-bezier(.65, 0, .35, 1); }
.page {
  height: var(--page-h);
  display: flex; justify-content: center; align-items: flex-start;
  transition: opacity .6s ease;
}
.page:not(.active) { opacity: .35; pointer-events: none; }
.page-inner { display: flex; flex-direction: column; }
.page-head {
  height: var(--head-h); width: var(--canvas);
  display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 12px;
}
.page-head h2 { font-family: var(--hand); font-weight: 400; font-size: 30px; line-height: 1.1; margin: 0; }
.pn { color: var(--accent); }
.desc {
  margin: 6px 0 0; padding: 6px 12px;
  background: #fff; border: 2px solid var(--ink); border-radius: 10px;
  font-size: 21px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.work { display: flex; gap: 24px; align-items: flex-start; }
.frame {
  position: relative; flex: none;
  width: var(--canvas); height: var(--canvas);
  background: #fff; overflow: hidden; border-radius: 2px;
  touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.frame::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--ink); pointer-events: none; z-index: 3; }
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.live { touch-action: none; cursor: crosshair; }
body.tool-fill .live { cursor: cell; }
.layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.tool-slot { width: 260px; height: var(--canvas); flex: none; }
.page-foot { height: var(--foot-h); width: var(--canvas); display: flex; align-items: center; justify-content: center; }

/* toolbar */
.toolbar {
  height: 100%; overflow-y: auto;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px; display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin;
}
.tb-group h4 {
  margin: 0 0 7px; font-size: 21px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); flex-wrap: wrap;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.tb-group h4 small { font-size: 21px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tool {
  border: 2px solid var(--ink); border-radius: 10px; background: #fff;
  padding: 6px 0 4px; font-size: 21px; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tool.on { background: var(--ink); color: #fff; }
.tb-row { display: flex; gap: 6px; align-items: center; margin-top: 7px; }
.tb-row .text-btn { margin-left: auto; }

.bubbles-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.bub-btn {
  aspect-ratio: 1; padding: 6px; background: #fff;
  border: 2px solid var(--soft); border-radius: 10px;
  touch-action: none; cursor: grab;
}
.bub-btn:hover { border-color: var(--ink); }
.bub-btn svg, .ghost svg { width: 100%; height: 100%; overflow: visible; }
.bub-btn path, .ghost path { fill: #fff; stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

.picker { position: relative; height: 112px; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; touch-action: none; cursor: crosshair; }
#svBox { width: 100%; height: 100%; }
.sv-knob {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--ink);
  transform: translate(-50%, -50%); pointer-events: none;
}
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; margin: 0; height: 22px; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--soft); border: 2px solid var(--ink); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--soft); border: 2px solid var(--ink); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.hue { margin: 8px 0 6px !important; }
.hue::-webkit-slider-runnable-track { height: 12px !important; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00) !important; }
.hue::-moz-range-track { height: 8px !important; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00) !important; }
.hue::-webkit-slider-thumb { margin-top: -6px !important; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.sw { aspect-ratio: 1; border-radius: 6px; border: 2px solid var(--ink); padding: 0; }
.sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.size-dot-wrap { width: 40px; height: 22px; display: grid; place-items: center; }
.size-dot { border-radius: 50%; background: var(--ink); }

/* bubbles on the panel */
.bubble { position: absolute; pointer-events: auto; touch-action: none; cursor: move; }
.bubble.snap { transition: left .2s ease, top .2s ease; }
.bubble svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bubble path.b-fill { fill: #fff; stroke: none; }
.bubble path.b-ink { fill: none; stroke: var(--ink); stroke-width: calc(var(--bstroke) * .75); vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.btext {
  position: absolute;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--hand); font-size: calc(var(--canvas) * .042); line-height: 1.15;
  color: var(--ink); outline: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text; cursor: move;
}
.btext:focus { cursor: text;
}
.btext:empty::before { content: attr(data-ph); color: #b3ada2; }
.bubble.sel::before { content: ""; position: absolute; inset: -3px; border: 2px dashed var(--accent); border-radius: 4px; pointer-events: none; }
.b-del, .b-flip, .rz { display: none; position: absolute; z-index: 2; }
.bubble.sel .b-del, .bubble.sel .b-flip, .bubble.sel .rz { display: grid; }
.b-del {
  top: 5px; right: 5px; width: 24px; height: 24px; padding: 0; place-items: center;
  border-radius: 50%; border: 2px solid var(--ink); background: var(--accent); color: #fff; font-weight: 800; font-size: 21px; line-height: 1;
}
.b-flip {
  top: 5px; left: 5px; width: 24px; height: 24px; padding: 0; place-items: center;
  border-radius: 50%; border: 2px solid var(--ink); background: #fff;
}
.b-flip svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
/* resize grips: anywhere along the dotted outline */
.rz { z-index: 3; touch-action: none; place-items: center; }
.rz-n, .rz-s { left: 10px; right: 10px; height: 14px; cursor: ns-resize; }
.rz-n { top: -10px; } .rz-s { bottom: -10px; }
.rz-e, .rz-w { top: 10px; bottom: 10px; width: 14px; cursor: ew-resize; }
.rz-e { right: -10px; } .rz-w { left: -10px; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 18px; height: 18px; }
.rz-ne { top: -12px; right: -12px; cursor: nesw-resize; }
.rz-sw { bottom: -12px; left: -12px; cursor: nesw-resize; }
.rz-nw { top: -12px; left: -12px; cursor: nwse-resize; }
.rz-se { bottom: -12px; right: -12px; cursor: nwse-resize; }
.rz::after { content: ""; width: 8px; height: 8px; border-radius: 2px; background: #fff; border: 2px solid var(--accent); }
.rz-n::after, .rz-s::after { width: 14px; height: 6px; }
.rz-e::after, .rz-w::after { width: 6px; height: 14px; }
.ghost { position: fixed; z-index: 200; pointer-events: none; opacity: .85; transform: translate(-50%, -50%); }

/* phone */
.mobile-bar { display: none; }
body.is-mobile .draw-top { height: 52px; padding: 0 12px; max-width: none; }
body.is-mobile .logo-small { font-size: 26px; }
body.is-mobile .tool-slot, body.is-mobile .page-foot { display: none; }
body.is-mobile .page-head h2 { font-size: 24px; }
body.is-mobile .desc { font-size: 21px; }
body.is-mobile .mobile-bar {
  display: flex; flex: none; gap: 8px; align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--soft); background: var(--paper);
}
.addons-btn { flex: 1; }
#mDone { min-width: 112px; }

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(29, 27, 24, .25); opacity: 0; transition: opacity .25s; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 74vh; max-height: 74dvh; overflow-y: auto;
  background: #fff; border-top: 3px solid var(--ink); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.3, .8, .3, 1);
}
.sheet.open .sheet-scrim { opacity: 1; }
.sheet.open .sheet-body { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 21px; }
.sheet-head, #sheetSlot { max-width: 460px; margin-left: auto; margin-right: auto; }
.sheet .toolbar { border: 0; padding: 0; height: auto; overflow: visible; border-radius: 0; }
.sheet .picker { height: 130px; }

/* ---------- result ---------- */
#result { min-height: 100vh; padding: 18px 16px 64px; }
.res-top { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.res-meta { font-size: 21px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.res-main { max-width: 1100px; margin: 22px auto 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 36px; }
.res-main > .custom { grid-column: 1; justify-self: end; }
.res-main > .dispenser { grid-column: 2; }
.res-main > .res-side { grid-column: 3; justify-self: start; }

.dispenser { --ps: 140px; --cols: 1; --sw: 176px; max-width: 100%; display: flex; flex-direction: column; align-items: center; }
.slot {
  width: calc(var(--sw) + 44px); max-width: 100%; height: 20px; position: relative; z-index: 2;
  background: var(--ink); border-radius: 10px;
  box-shadow: inset 0 -5px 0 #000;
}
.strip-clip { overflow: hidden; margin-top: -10px; padding: 0 22px 18px; max-width: 100%; }
.strip {
  width: var(--sw); max-width: 100%;
  background: var(--border); color: var(--strip-ink);
  border: 2px solid rgba(0, 0, 0, .12);
  padding: 22px 16px 12px; border-radius: 0 0 6px 6px;
  box-shadow: 0 10px 22px rgba(29, 27, 24, .18);
  transform: translateY(-104%);
}
.strip.out { transform: none; }
.strip.anim { transition: transform 2.6s cubic-bezier(.2, .75, .25, 1); }
.strip.swap { animation: swap .45s ease; }
@keyframes swap { 0% { opacity: 1; transform: scale(1); } 40% { opacity: 0; transform: scale(.96); } 100% { opacity: 1; transform: scale(1); } }
.strip-title {
  width: 100%; min-width: 0; border: 0; border-bottom: 2px dashed transparent; background: transparent;
  font-family: var(--hand); font-size: 26px; text-align: center; color: inherit;
  padding: 0 4px 6px; margin-bottom: 10px; outline: none;
}
.strip-title:hover, .strip-title:focus { border-bottom-color: currentColor; }
.strip-panels { display: grid; grid-template-columns: repeat(var(--cols), var(--ps)); gap: 12px; justify-content: center; }
.sp { aspect-ratio: 1; padding: 0; border: 3px solid var(--ink); background: #fff; cursor: zoom-in; overflow: hidden; }
.sp img { width: 100%; height: 100%; display: block; }
.strip-by { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-family: var(--hand); font-size: 22px; }
.strip-by input {
  flex: 1; min-width: 0; border: 0; border-bottom: 2px dashed currentColor; background: transparent;
  font-family: var(--hand); font-size: 22px; color: inherit; outline: none; padding: 0 2px;
}
.strip-by input::placeholder { color: inherit; opacity: .45; }

.custom {
  width: 230px; flex: none; margin-top: 30px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 16px;
}
.custom h3 { margin: 0 0 10px; font-family: var(--hand); font-weight: 400; font-size: 24px; }
.border-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.bsw { aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--ink); padding: 0; }
.bsw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.shape-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.shape-btn {
  border: 2px solid var(--soft); border-radius: 10px; background: #fff; padding: 8px 4px 6px;
  font-size: 21px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.shape-btn svg { height: 44px; width: auto; fill: none; stroke: var(--ink); stroke-width: 2; }
.shape-btn.on { border-color: var(--ink); background: var(--paper); }
.custom .btn { width: 100%; }

.res-side { width: 200px; flex: none; margin-top: 30px; opacity: 0; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease; pointer-events: none; }
.res-side.show { opacity: 1; transform: none; pointer-events: auto; }
.res-side .res-actions { margin: 0; align-items: stretch; }
.res-side .share { flex-direction: column; align-items: stretch; }
.res-side .share .btn, .res-side #customizeBtn { width: 100%; }
.res-after { opacity: 0; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease; pointer-events: none; }
.res-after.show { opacity: 1; transform: none; pointer-events: auto; }
.res-actions { max-width: 1040px; margin: 8px auto 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.share { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.share-label { font-family: var(--hand); font-size: 22px; margin-right: 4px; }

.recent { max-width: 1100px; margin: 56px auto 0; border-top: 3px solid var(--ink); padding-top: 18px; }
.recent h2 { font-family: var(--hand); font-weight: 400; font-size: 34px; margin: 0 0 4px; }
.recent-note { color: var(--muted); margin: 0 0 16px; font-size: 21px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.rc { background: none; border: 0; padding: 0; text-align: left; }
.rc-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 7px;
  border: 2px solid rgba(0, 0, 0, .14); border-radius: 6px; transition: transform .15s;
}
.rc:hover .rc-strip { transform: translateY(-3px); }
.rc-strip img { width: 100%; aspect-ratio: 1; display: block; border: 2px solid var(--ink); background: #fff; }
.rc-title { font-family: var(--hand); font-size: 21px; margin-top: 6px; line-height: 1.1; }
.rc-meta { font-size: 21px; color: var(--muted); }
.rc.current .rc-strip { outline: 3px solid var(--accent); outline-offset: 2px; }

.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(29, 27, 24, .82);
  display: grid; place-items: center; cursor: zoom-out; padding: 16px;
}
.lightbox img { width: min(88vmin, 760px); border: 4px solid var(--ink); background: #fff; animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 400;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-weight: 700; font-size: 21px; transition: opacity .25s, transform .25s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.is-mobile .toast { bottom: 84px; }

@media (max-width: 760px) {
  .res-main { display: flex; flex-direction: column; align-items: center; gap: 16px; }
  .custom { width: 100%; max-width: 360px; margin-top: 0; }
  .res-side { width: 100%; margin-top: 0; }
  .res-side .share { flex-direction: row; justify-content: center; }
  .res-side .share .btn { width: auto; }
  .res-side .res-actions { align-items: center; }
  .res-side #customizeBtn { width: auto; }
  .btn-ghost { padding: 7px 13px; font-size: 21px; }
  .share-label { width: 100%; text-align: center; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sq { animation: none; }
  #track { transition-duration: .01s; }
  .strip.anim { transition-duration: .4s; }
}

/* select / copy / paste */
.paste-btn { flex: 1; margin-left: 0 !important; }
.paste-btn:disabled { opacity: .35; cursor: default; }
.sel-box {
  position: absolute; z-index: 4; pointer-events: none;
  border: 2px dashed var(--accent); background: rgba(255, 90, 60, .06);
}
.sel-bar {
  position: absolute; left: -2px; bottom: calc(100% + 6px);
  display: flex; gap: 4px; pointer-events: auto; white-space: nowrap;
}
.bar-in > .sel-bar { bottom: auto; top: 4px; left: 4px; }
.sel-bar button {
  border: 2px solid var(--ink); background: #fff; border-radius: 999px;
  padding: 3px 12px; font-size: 21px; font-weight: 800; box-shadow: 0 2px 0 var(--ink);
}
.sel-bar .pp-place { background: var(--accent); color: #fff; }
.paste-piece { position: absolute; z-index: 4; touch-action: none; cursor: move; outline: 2px dashed var(--accent); outline-offset: 1px; }
.paste-piece > canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.paste-piece .rz { display: grid; }

/* photos */
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.photo-row .text-btn { display: flex; align-items: center; justify-content: center; gap: 6px; }
.photo-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.modal {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(29, 27, 24, .55);
  display: grid; place-items: center; padding: 16px;
}
.modal-card {
  width: min(680px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 16px;
  padding: 18px; animation: pop .2s ease;
}
.modal-card h3 { font-family: var(--hand); font-weight: 400; font-size: 28px; margin: 0; }
.modal-sub { margin: 4px 0 12px; font-size: 21px; color: var(--muted); }
.pe-stage, .cam-stage { display: grid; place-items: center; }
#peCanvas {
  touch-action: none; cursor: crosshair; border: 2px solid var(--ink);
  background-color: #fff;
  background-image: linear-gradient(45deg, #e7e1d4 25%, transparent 25%), linear-gradient(-45deg, #e7e1d4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e1d4 75%), linear-gradient(-45deg, transparent 75%, #e7e1d4 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.pe-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.pe-tools .tool { flex-direction: row; gap: 6px; padding: 6px 12px; }
.pe-size { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; font-size: 21px; font-weight: 800; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
#camVideo { width: 100%; max-height: 60vh; border: 2px solid var(--ink); border-radius: 8px; background: #000; transform: scaleX(-1); }

/* hand-drawn borders (drawn by app.js) */
.sk { border-color: transparent !important; }
.sk-svg { position: absolute; pointer-events: none; overflow: visible; z-index: 3; }
.sk-svg path { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
.frame.sk::after { display: none; }
.btn.sk, .title-card.sk { box-shadow: none; }
.tool-slot:not(:has(.toolbar)) > .sk-svg { display: none; }
.tool-slot .toolbar { border-color: transparent; }

/* placed photos sit under the drawing */
.frame .photos { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.frame .photos canvas { position: absolute; inset: auto; }
/* brush ring in the photo editor */
.pe-stage { position: relative; }
#peCanvas { cursor: none; }
.pe-cursor {
  position: absolute; pointer-events: none; border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--ink); box-shadow: 0 0 0 1.5px #fff, inset 0 0 0 1.5px #fff;
}
.pe-cursor.restore { border-color: var(--accent); }
/* let the sketchy border sit outside the photo window without adding a scrollbar */
.modal { overflow-y: auto; place-items: safe center; }
.modal-card { overflow: visible; max-height: none; }

/* freehand mode */
.free-btn { gap: 6px; }
.free-home { position: absolute; top: 18px; right: 18px; z-index: 2; }
.res-top-right { display: flex; align-items: center; gap: 14px; }
.free-result { opacity: 0; transform: translateY(-8px) scale(.85); pointer-events: none; }
.free-result.pop { animation: freePop .55s cubic-bezier(.3, 1.4, .5, 1) forwards; pointer-events: auto; }
@keyframes freePop {
  0% { opacity: 0; transform: translateY(-10px) scale(.8) rotate(-4deg); }
  70% { opacity: 1; transform: translateY(0) scale(1.06) rotate(2deg); }
  100% { opacity: 1; transform: none; }
}
.morph-label { font-family: var(--hand); font-size: 21px; white-space: nowrap; }
.top-mid { display: flex; align-items: center; gap: 10px; }
.mode-tag { display: none; font-family: var(--hand); font-size: 21px; padding: 1px 10px; border-radius: 999px; background: var(--ink); color: #fff; }
body.free .mode-tag { display: inline-block; }
body.free .plabel, body.free .pn-colon, body.free .desc { display: none; }
body.free .pn { color: var(--ink); }
.rc-strip { position: relative; }
.rc-tag {
  position: absolute; top: -8px; right: -8px; z-index: 1;
  font-family: var(--hand); font-size: 21px; padding: 1px 10px; border-radius: 999px;
  background: var(--ink); color: #fff; transform: rotate(4deg);
}
@media (max-width: 760px) {
  .free-home { top: 12px; right: 12px; }
  .res-top-right { gap: 8px; }
  .res-top-right .res-meta { display: none; }
}

/* gallery */
#galleryScreen { min-height: 100vh; padding: 18px 16px 64px; }
#galleryScreen .recent { margin-top: 18px; border-top: 0; padding-top: 0; }
.g-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.g-tab {
  font-family: var(--hand); font-size: 21px; padding: 4px 16px; border-radius: 999px;
  border: 2px solid var(--ink); background: #fff;
}
.g-tab.on { background: var(--ink); color: #fff; }
.g-more { display: block; margin: 20px auto 0; }
.posted { margin: 4px 0 0; font-size: 21px; color: var(--muted); }
.posted .link-btn { margin: 0; padding: 0; font-size: 21px; }
.res-side .posted { text-align: center; }
.view-only .strip-title, .view-only .strip-by input { cursor: default; }
.view-only .strip-title:hover { border-bottom-color: transparent; }
.view-only .strip-by input { border-bottom-style: solid; border-bottom-color: transparent; }
#galleryScreen .res-top { max-width: 1100px; }

/* Post to gallery */
.post-btn { background: #3bb273; color: #fff; }
.post-btn:disabled { opacity: .7; cursor: default; }
.res-side .post-btn { width: 100%; }
@media (max-width: 760px) { .res-side .post-btn { width: auto; } }

/* bigger labels need wider tool buttons in the side toolbar */
.tool-slot .tools { grid-template-columns: repeat(2, 1fr); }
.tool-slot .tool { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 0; }

/* hand-drawn pencil beside the home logo */
.home-logo { position: relative; }
/* hangs off the right so the word itself stays centred */
.logo-pencil { position: absolute; left: 100%; bottom: .02em; margin-left: .06em; height: .9em; width: auto; transform: rotate(8deg); pointer-events: none; }
