/* ============================================================================
   Scratchy — design tokens & chrome
   Calm, professional dark chrome; the playfulness lives in the canvas.
   Gradient appears in exactly two places: active tool pill + primary CTAs.
   ========================================================================== */
:root {
  --bg0: #0b0b10;
  --surface: #14141c;
  --surface-2: #1c1c26;
  --surface-3: #262633;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --ink: #eceef6;
  --muted: #8d90a8;
  --accent: #7c5cff;
  --accent-2: #38d6ff;
  --accent-grad: linear-gradient(135deg, #7c5cff, #38b6ff);
  --accent-tint: rgba(124, 92, 255, 0.16);
  --good: #35d99a;
  --danger: #ff5470;
  --radius: 14px;
  --radius-lg: 20px;
  --touch: 48px;
  --bar-h: 56px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --font-display: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", system-ui, sans-serif;
  --font-ui: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.3, 0.9, 0.4, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%;
  overflow: hidden; overscroll-behavior: none;
  background: var(--bg0); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* iOS long-press callout would cancel spiral holds */
  position: fixed; inset: 0;
}
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.icn { display: block; flex: none; }

/* ---------------------------------------------------------------- stage */
#backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(1100px 760px at 50% 38%, #14141d 0%, var(--bg0) 72%);
}
#stage { position: absolute; inset: 0; overflow: hidden; }
#board {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0; will-change: transform;
  box-shadow: 0 16px 70px rgba(0, 0, 0, 0.65);
  border-radius: 2px;
}
#board canvas { position: absolute; top: 0; left: 0; display: block; touch-action: none; }
#reveal { z-index: 1; } #scratch { z-index: 2; } #overlay { z-index: 3; pointer-events: none; }

#stencilLayer { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#stencilControls {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  display: flex; gap: 10px; pointer-events: auto;
}

/* desktop brush cursor ring */
#cursorRing {
  position: absolute; left: 0; top: 0; z-index: 15; pointer-events: none;
  border: 1.5px solid rgba(255, 255, 255, 0.85); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  will-change: transform; /* positioned via transform from JS */
}

/* first-scratch shimmer hint */
#hint {
  position: absolute; z-index: 14; left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px;
  color: rgba(255, 255, 255, 0.85); font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: 0.2px;
  pointer-events: none;
  animation: hintPulse 2.2s var(--ease) infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}

/* transient zoom chip */
#zoomChip {
  position: absolute; z-index: 40; top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 10px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); font-weight: 600; font-size: 13px; padding: 7px 14px;
  cursor: pointer; font-variant-numeric: tabular-nums;
  transition: opacity 0.2s;
}

/* ---------------------------------------------------------------- top bar */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 10px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: color-mix(in srgb, var(--bg0) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar-group { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-group.center { flex: 1; justify-content: center; }

#logo {
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  letter-spacing: 0.3px; color: var(--muted); padding: 0 6px;
}

.bar-btn {
  display: flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px; border: 0; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: transform 0.12s var(--ease), background 0.15s;
}
.bar-btn:active { transform: scale(0.96); background: var(--surface-3); }

.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s;
}
.icon-btn:active { transform: scale(0.94); background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
@media (hover: hover) {
  .icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
  .bar-btn:hover { background: var(--surface-3); }
}

/* tool switcher — sliding pill */
#toolSwitcher {
  position: relative; display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 3px; border-radius: 999px;
}
#toolPill {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: 48px;
  border-radius: 999px; background: var(--accent-grad);
  box-shadow: 0 2px 12px rgba(124, 92, 255, 0.45);
  transition: transform 0.2s var(--ease), width 0.2s var(--ease);
}
.tool-btn {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; min-width: 48px; padding: 0 13px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600;
  transition: color 0.15s;
}
.tool-btn.active { color: #fff; }
.tool-btn .lbl { display: none; }
@media (min-width: 900px) { .tool-btn .lbl { display: inline; } }

/* current pattern dot */
#patternDot {
  width: 26px; height: 26px; border-radius: 50%;
  background-size: cover; background-position: center;
  border: 2px solid var(--line-strong); display: block;
}
#patternBtn[data-open="1"] #patternDot, .icon-btn[data-open="1"] { border-color: var(--accent); }

/* premium locks */
[data-locked="1"] { position: relative; }
.lock-badge {
  position: absolute; top: -3px; right: -3px; z-index: 2;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  display: grid; place-items: center; color: var(--muted);
  pointer-events: none;
}

/* responsive top bar */
.show-sm { display: none; }
@media (max-width: 599px) {
  #logo { display: none; }
  .hide-sm { display: none; }
  .show-sm { display: flex; }
  .bar-btn .lbl { display: none; }
  .bar-btn { padding: 0 12px; }
}

/* ---------------------------------------------------------------- popovers */
.popover {
  position: absolute; z-index: 45;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 12px;
  box-shadow: var(--shadow);
  transform-origin: top right;
  animation: popIn 0.16s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.popover h3 {
  margin: 2px 4px 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase;
}
#patternPopover { top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 8px); right: 10px; }
#patternGrid { display: grid; grid-template-columns: repeat(3, 84px); gap: 8px; }
.pattern-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; cursor: pointer; font-size: 12px; color: var(--muted);
  transition: background 0.15s, border-color 0.15s, transform 0.12s var(--ease);
}
.pattern-cell:active { transform: scale(0.95); }
.pattern-cell .dot {
  width: 44px; height: 44px; border-radius: 50%;
  background-size: cover; background-position: center;
  border: 2px solid var(--line-strong);
  display: grid; place-items: center; color: var(--ink);
}
.pattern-cell.active { background: var(--accent-tint); border-color: var(--accent); color: var(--ink); }
.pattern-cell.active .dot { border-color: var(--accent); }

.popover.menu { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
#morePopover { top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 8px); right: 10px; }
.menu-row {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--touch); padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 500; color: var(--ink); text-align: left;
  transition: background 0.12s;
}
.menu-row:active { background: var(--surface-3); }
@media (hover: hover) { .menu-row:hover { background: var(--surface-2); } }
.menu-row.active { background: var(--accent-tint); color: var(--ink); }
.menu-row.active .icn { color: var(--accent-2); }

/* phone: popovers become bottom sheets */
@media (max-width: 599px) {
  #patternPopover, #morePopover {
    top: auto; right: 0; left: 0;
    bottom: 0; border-radius: 22px 22px 0 0;
    padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    transform-origin: bottom center;
    animation: sheetUp 0.22s var(--ease);
  }
  #patternGrid { grid-template-columns: repeat(3, 1fr); }
}
@keyframes sheetUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- sidebar */
#sidebar {
  position: absolute; z-index: 30;
  left: calc(env(safe-area-inset-left, 0px) + 10px); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 12px 7px; border-radius: 24px;
  box-shadow: var(--shadow);
}
#brushSlider { height: 168px; width: 40px; display: grid; place-items: center; touch-action: none; margin-bottom: 4px; }
#brushTrack { position: relative; width: 10px; height: 100%; background: var(--surface-3); border-radius: 999px; }
#brushFill { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 999px; background: var(--accent); opacity: 0.8; }
#brushThumb {
  position: absolute; left: 50%; transform: translate(-50%, 50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.side-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; cursor: pointer; color: var(--ink);
  transition: transform 0.12s var(--ease), background 0.15s, color 0.15s;
}
.side-btn:active { transform: scale(0.94); background: var(--surface-2); }
@media (hover: hover) { .side-btn:hover { background: var(--surface-2); border-color: var(--line); } }
.side-btn.on { background: var(--accent-tint); color: var(--accent-2); border-color: var(--accent); }
.side-btn:disabled { opacity: 0.32; cursor: default; }

#brushPreview {
  position: absolute; z-index: 31; pointer-events: none;
  left: calc(env(safe-area-inset-left, 0px) + 76px); top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 12px;
}
#brushPreviewDot { border-radius: 50%; background: radial-gradient(circle, #fff, #cfd3ff); box-shadow: 0 0 22px rgba(124, 92, 255, 0.55); }
#brushPreviewVal {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
}

#sidePill {
  position: absolute; z-index: 40; pointer-events: none;
  left: calc(env(safe-area-inset-left, 0px) + 76px); top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity 0.15s;
}
#sidePill.show { opacity: 1; }
#symmetryTray { left: calc(env(safe-area-inset-left, 0px) + 74px); top: 50%; transform: translateY(-50%); transform-origin: left center; }

/* ---------------------------------------------------------------- trays */
.tray {
  position: absolute; z-index: 29;
  left: 50%; transform: translateX(-50%);
  top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 8px);
  /* multi-row sideways-scrolling grid: see many shapes at once */
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto);
  gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 8px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 20px); overflow-x: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-x; /* global touch-action:none would make the tray unscrollable */
  animation: popIn 0.16s var(--ease);
}
#spiralTray { grid-template-rows: repeat(3, auto); }
.tray .tray-divider { grid-row: 1 / -1; }
/* right-edge fade hints that more shapes are off-screen */
.tray.overflowing {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent);
}
.tray-item {
  width: 62px; min-width: 62px; height: 56px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; cursor: pointer; color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.12s var(--ease), border-color 0.15s;
}
.tray-item:active { transform: scale(0.93); }
@media (hover: hover) { .tray-item:hover { background: var(--surface-2); } }
.tray-item.active { background: var(--accent-tint); color: var(--ink); border-color: var(--accent); }
.tray.shapes svg { width: 40px; height: 40px; }
.tray-item.emoji { font-size: 30px; line-height: 1; }
.tray-divider { width: 1px; min-width: 1px; align-self: stretch; margin: 2px 3px; background: var(--line-strong); }
.tray-item.any-emoji {
  border: 1.5px dashed var(--accent); color: var(--accent-2);
  display: flex; flex-direction: column; gap: 2px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.2px;
}
#emojiInput {
  width: 100%; box-sizing: border-box; margin: 4px 0 16px;
  font-size: 44px; text-align: center; padding: 10px; min-height: 76px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 14px; color: var(--ink);
}
#emojiInput::placeholder { font-size: 15px; color: var(--muted); font-family: var(--font-ui); }
#emojiInput:focus { outline: 2px solid var(--accent); }

/* ---------------------------------------------------------------- canvas maker */
.maker-body {
  display: flex; gap: 20px; flex-wrap: wrap;
  max-width: 720px; margin: 0 auto; justify-content: center;
}
.maker-preview-wrap { flex: none; display: flex; flex-direction: column; gap: 8px; max-width: min(300px, 46vw); }
#makerPreview {
  width: 100%; border-radius: 12px;
  border: 1px solid var(--line-strong); background: #000;
  touch-action: none; cursor: crosshair; /* paintable in Paint style */
}
#makerHint { margin: 0; text-align: center; }
.maker-controls { flex: 1; min-width: 260px; max-width: 380px; }
.maker-controls h4 { margin: 4px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
#makerPalette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pal-dot {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; padding: 0;
  transition: transform 0.12s var(--ease), border-color 0.12s;
}
.pal-dot.on { border-color: #fff; transform: scale(1.12); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.style-chip {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.style-chip.on { background: var(--accent-tint); border-color: var(--accent); color: var(--ink); }
.maker-slider { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.maker-slider input {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; background: transparent; display: block;
  touch-action: pan-x; /* global touch-action:none would break the drag */
}
.maker-slider input::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px; background: var(--surface-3);
}
.maker-slider input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); margin-top: -10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.maker-slider input::-moz-range-track { height: 8px; border-radius: 999px; background: var(--surface-3); }
.maker-slider input::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
}
.maker-controls .row { margin-bottom: 8px; }
.save-strong { border-color: var(--accent) !important; color: var(--accent-2) !important; }
#makerShuffle:active .icn { animation: wiggle 0.3s var(--ease); }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-18deg) scale(1.2); }
  65% { transform: rotate(14deg) scale(1.15); }
}
#makerSaved { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.saved-canvas { position: relative; }
.saved-canvas canvas { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--line-strong); display: block; }
.saved-canvas .del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid var(--line-strong); cursor: pointer;
  background: var(--surface-3); color: var(--muted); display: grid; place-items: center;
}
.tray.shapes svg path, .tray.shapes svg circle { fill: none; stroke: currentColor; stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; }
.tray.shapes .tray-item.active svg { color: var(--accent-2); }

.chip-btn {
  display: flex; align-items: center; gap: 8px;
  border: 0; cursor: pointer; font-weight: 700; font-size: 16px;
  padding: 0 20px; height: var(--touch); border-radius: 999px;
  box-shadow: var(--shadow); color: #0b0b10;
  transition: transform 0.12s var(--ease);
}
.chip-btn.done { background: var(--good); }
.chip-btn.fill { background: linear-gradient(135deg, #ffd23a, #ff9d3a); }
.chip-btn:active { transform: scale(0.95); }

/* ---------------------------------------------------------------- toasts */
.toast {
  position: absolute; z-index: 60; left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%) translateY(6px);
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0;
  transition: opacity 0.18s, transform 0.18s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sync-status {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  right: 12px; z-index: 40;
  font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px;
}

/* ---------------------------------------------------------------- sheets */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 70;
  background: rgba(5, 5, 10, 0.62);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 20px;
}
.sheet {
  position: relative; width: min(430px, 92vw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 26px;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.65);
  animation: popIn 0.18s var(--ease);
}
.sheet.small { width: min(350px, 90vw); text-align: center; }
.sheet h2 {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); margin: 0 0 6px; font-size: 24px;
}
.sheet .sub { color: var(--muted); margin: 0 0 16px; font-size: 14.5px; line-height: 1.45; }
.sheet .sub.warn { color: var(--danger); font-weight: 600; }
.sub2 { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.sheet-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 50%; cursor: pointer;
}
#deleteThumb {
  width: 92px; height: 118px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line-strong);
  margin: 0 auto 12px; display: block; background: #000;
}
#videoPreview {
  width: 100%; max-height: 240px; object-fit: contain;
  border-radius: 12px; border: 1px solid var(--line-strong);
  margin: 4px 0 12px; display: block; background: #000;
}
#videoSave { display: flex; align-items: center; justify-content: center; gap: 4px; }
.replay-controls.recording #replayProgressFill { background: var(--danger); }
#recLabel {
  color: var(--danger); font-weight: 700; font-size: 13px;
  padding: 0 4px 0 10px; letter-spacing: 0.3px;
}
#photoPreview {
  width: 100%; max-height: 190px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line-strong);
  margin: 4px 0 6px; display: block; background: #000;
}
#photoPreview.pop { filter: saturate(1.6) brightness(1.1); }

.coach-row { display: flex; gap: 14px; align-items: center; text-align: left; padding: 10px 2px; }
.coach-ic {
  width: 50px; height: 50px; flex: none; display: grid; place-items: center;
  border-radius: 14px; background: var(--accent-tint); color: var(--accent-2);
}
#coachGo { margin-top: 14px; width: 100%; }

.benefits { list-style: none; padding: 0; margin: 0 0 16px; }
.benefits li { padding: 7px 0 7px 26px; position: relative; font-size: 15px; }
.benefits li::before { content: ""; position: absolute; left: 2px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-grad); }
.price-row { display: flex; gap: 10px; margin-bottom: 16px; }
.price-opt { flex: 1; border: 1.5px solid var(--line-strong); border-radius: 14px; padding: 13px; text-align: center; cursor: pointer; }
.price-opt.active { border-color: var(--accent); background: var(--accent-tint); }
.price-opt b { display: block; font-size: 18px; }
.price-opt small { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 12px 0 0; }
.toggle-row { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 16px; margin: 8px 0 16px; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.row { display: flex; gap: 10px; }
.big-btn {
  flex: 1; border: 0; cursor: pointer; font-weight: 700; font-size: 16px;
  padding: 14px; border-radius: 14px; min-height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
  transition: transform 0.12s var(--ease), filter 0.15s;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.primary { background: var(--accent-grad); color: #fff; }
.big-btn.danger { background: var(--danger); color: #fff; }
.big-btn.ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.big-btn.hold { position: relative; overflow: hidden; }
.big-btn.hold::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 100%;
  width: var(--hold, 0%); background: rgba(255, 255, 255, 0.28);
  transition: width 0.1s linear;
}

/* ---------------------------------------------------------------- gallery */
.fullscreen {
  position: absolute; inset: 0; z-index: 65; background: var(--bg0);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 24px;
  overflow-y: auto;
}
.screen-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.screen-head h1 { font-family: var(--font-display); font-size: 26px; margin: 4px 0; }
.screen-head .icon-btn { border-color: var(--line); background: var(--surface); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden;
  transition: transform 0.12s var(--ease), border-color 0.15s;
}
@media (hover: hover) { .card:hover { border-color: var(--line-strong); transform: translateY(-2px); } }
.card .thumb { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #000; display: block; cursor: pointer; }
.card.new-card {
  display: grid; place-items: center; aspect-ratio: auto;
  min-height: 220px; cursor: pointer; color: var(--muted);
  border: 1.5px dashed var(--line-strong); background: transparent;
}
.card.new-card .inner { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; }
.card.new-card .inner .icn { color: var(--accent-2); }
@media (hover: hover) { .card.new-card:hover { border-color: var(--accent); color: var(--ink); } }
.card .meta { padding: 8px 10px 2px; display: flex; align-items: center; gap: 6px; }
.card .title { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .title[contenteditable="true"]:focus { outline: 1px solid var(--accent); border-radius: 4px; white-space: normal; }
.card .rename-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; display: grid; place-items: center; }
.card .date { color: var(--muted); font-size: 11.5px; padding: 0 10px; }
.card .card-actions { display: flex; gap: 4px; padding: 8px; }
.card .card-actions button {
  flex: 1; height: 38px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; cursor: pointer; transition: color 0.15s, background 0.15s;
}
.card .card-actions button:active { background: var(--surface-3); color: var(--ink); }
@media (hover: hover) { .card .card-actions button:hover { color: var(--ink); } }
.card.readonly .thumb { opacity: 0.75; }
.card .lock-note {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 11px; padding: 0 10px 6px;
}
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--muted); text-align: center; margin-top: 60px; line-height: 1.5;
}

/* ---------------------------------------------------------------- replay */
#replayOverlay { position: absolute; inset: 0; z-index: 55; }
.replay-controls {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px; border-radius: 999px;
  box-shadow: var(--shadow);
}
#replayProgress {
  width: min(34vw, 220px); height: 4px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden; margin: 0 6px;
}
#replayProgressFill { height: 100%; width: 0%; background: var(--accent-grad); border-radius: 999px; }
#replaySpeed { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- install / update */
.install-hint, .update-toast {
  position: absolute; z-index: 62; border: 1px solid var(--line); cursor: pointer;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); right: 16px;
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  padding: 11px 17px; border-radius: 999px; box-shadow: var(--shadow);
}
.update-toast {
  background: var(--accent-grad); color: #fff; border: 0;
  left: 50%; right: auto; transform: translateX(-50%);
}

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  #hint { animation: none; opacity: 0.85; }
}

[hidden] { display: none !important; }
