/* ================================================================
   Duck AR — styles.css
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg:          #0A66C2;
  --clr-glass:       rgba(14, 14, 14, 0.88);
  --clr-border:      rgba(255,255,255,0.08);
  --clr-accent:      #F5C842;
  --clr-danger:      #ff4d4d;
  --clr-txt:         #f0f0f0;
  --clr-txt-muted:   rgba(240,240,240,0.42);
  --blur:            saturate(180%) blur(28px);
  --radius-sm:       8px;
  --radius-md:       14px;
  --radius-lg:       22px;
  --radius-xl:       32px;
  --font-ui:         'Outfit', sans-serif;
  --font-brand:      'BBH Bartle', 'Outfit', sans-serif;
  --safe-bottom:     env(safe-area-inset-bottom, 0px);
  --safe-top:        env(safe-area-inset-top, 0px);
  /* Splash circle — centred at ~40% height, radius 130px */
  --circle-cx:       50%;
  --circle-cy:       42%;
  --circle-r:        130px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--clr-bg);
  color: var(--clr-txt);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  user-select: none;
}

button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ── Page backdrop (always behind everything) ─────────────────── */
body { background: #0A66C2; }

.splash-bg-layer {
  position: fixed; inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 80% 60% at var(--circle-cx) var(--circle-cy), rgba(245,200,66,.13) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(245,200,66,.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── WebGL Canvas ─────────────────────────────────────────────── */
#glCanvas {
  position: fixed; inset: 0;
  width: 100% !important; height: 100% !important;
  display: block;
  touch-action: none;
  /* Default: invisible until splash-mode or ar-mode applied */
  opacity: 0;
  z-index: 3;
}

/* During splash: circle clip, raised above backdrop, below splash content */
#glCanvas.splash-mode {
  opacity: 1;
  z-index: 5;
  clip-path: none;
  transition: none;
}

/* Expanding: animate circle opening to fill screen */
#glCanvas.expanding {
  opacity: 1;
  z-index: 5;
  clip-path: none;
  transition: none;
}

/* Final AR state: full screen, z-index below ar-ui */
#glCanvas.ar-mode {
  opacity: 1;
  z-index: 3;
  clip-path: none;
  transition: none;
}

/* ── Splash Overlay ───────────────────────────────────────────── */
.splash-overlay {
  position: fixed; inset: 0;
  z-index: 10;          /* above canvas (5) but content sits here */
  pointer-events: none; /* let canvas receive events for future; content re-enables */
  background: transparent; /* dark comes from body + splash-bg-layer behind canvas */
}

.splash-unicorn-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0.78;
  pointer-events: none;
}

/* Decorative ring around the 3D duck circle */
.splash-circle-ring {
  position: absolute;
  left: var(--circle-cx);
  top:  var(--circle-cy);
  transform: translate(-50%, -50%);
  width:  calc(var(--circle-r) * 2 + 6px);
  height: calc(var(--circle-r) * 2 + 6px);
  border-radius: 50%;
  border: 1.5px solid rgba(245,200,66,0.3);
  box-shadow:
    0 0 40px rgba(245,200,66,0.12),
    inset 0 0 40px rgba(0,0,0,0.6);
  animation: ringPulse 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ringPulse {
  0%,100% { box-shadow: 0 0 30px rgba(245,200,66,0.1), inset 0 0 40px rgba(0,0,0,0.6); }
  50%      { box-shadow: 0 0 60px rgba(245,200,66,0.22), inset 0 0 40px rgba(0,0,0,0.6); }
}

.splash-content {
  position: relative;
  z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  width: 100%; height: 100%;
  padding: 0 32px;
  pointer-events: none;
}

/* Re-enable pointer events only on the interactive footer */
.splash-footer { pointer-events: auto; }

.splash-header {
  position: absolute;
  /* sits above the circle: circle top = cy - r */
  bottom: calc(100% - var(--circle-cy) + var(--circle-r) + 28px);
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}

/* Correct positioning with absolute values */
.splash-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  /* end at: circle top edge = cy - r */
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
  height: calc(var(--circle-cy) - var(--circle-r) - 4px);
  padding-top: clamp(6px, 2.2vh, 22px);
  text-align: center;
}

.splash-footer {
  position: absolute;
  top: auto;
  bottom: calc(var(--safe-bottom) + 38px);
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

.splash-wordmark {
  width: min(98vw, 1500px);
  height: auto;
  display: block;
  filter: drop-shadow(0 0 32px rgba(245,200,66,.38));
}

.splash-sub {
  margin: 0 0 clamp(6px, 1.2vh, 12px);
  font-size: clamp(11px, 2.6vw, 16px);
  color: #ffffff;
  letter-spacing: .08em;
  text-align: center;
  text-transform: lowercase;
}

.splash-footer .btn-primary {
  padding: 16px 32px;
  font-size: 16px;
  border-radius: 50px;
}

.splash-footer .btn-primary span {
  display: inline-block;
  transform: translateY(-1px);
  text-transform: lowercase;
}

.splash-note { font-size: 12px; color: rgba(255,255,255,.2); }

/* Fade out splash content on transition */
.splash-overlay.fading-out .splash-header,
.splash-overlay.fading-out .splash-footer,
.splash-overlay.fading-out .splash-circle-ring {
  animation: fadeOut 0.3s ease-out forwards;
}

.splash-overlay.fading-out .splash-bg {
  animation: fadeOut 0.6s ease-out forwards;
}

@keyframes fadeOut {
  to { opacity: 0; pointer-events: none; }
}

/* Hidden once transition complete */
.splash-overlay.hidden {
  display: none;
}

/* ── AR UI Layer ──────────────────────────────────────────────── */
.ar-ui {
  position: fixed; inset: 0;
  z-index: 20;
  pointer-events: none; /* children re-enable as needed */
  text-transform: lowercase;
}
.ar-ui > * { pointer-events: auto; }

.ar-ui .ctrl-label { text-transform: lowercase; }

.ar-ui.hidden { display: none; }

/* ── Capture Flash ────────────────────────────────────────────── */
.capture-flash {
  position: fixed; inset: 0; z-index: 90;
  background: #fff; opacity: 0; pointer-events: none;
}
.capture-flash.flash { animation: flashAnim .4s ease-out forwards; }
@keyframes flashAnim { 0% { opacity: .85; } 100% { opacity: 0; } }

/* ── Top Bar ─────────────────────────────────────────────────── */
.bar-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,.55) 0%, transparent 100%);
  /* Animate in from top */
  transform: translateY(-100%);
  opacity: 0;
}
.ar-ui.visible .bar-top {
  animation: slideDown 0.5s cubic-bezier(0.34, 1.3, 0.64, 1) 0.15s forwards;
}
@keyframes slideDown {
  to { transform: translateY(0); opacity: 1; }
}

.overlay-layer-island {
  position: absolute;
  top: calc(var(--safe-top) + 72px);
  right: 10px;
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-radius: 28px;
  background: rgba(14, 14, 14, 0.84);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 10px 28px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(.94);
  transform-origin: top right;
  transition: opacity .2s ease, transform .24s cubic-bezier(.34,1.3,.64,1);
}

.overlay-layer-island.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.overlay-layer-island.hidden {
  display: none;
}

.layer-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.82);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;
}

.layer-icon-btn:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 0 18px rgba(255,255,255,.06);
}

.layer-icon-btn:active {
  transform: scale(.96);
}

/* Logo */
.logo-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .22em;
  color: var(--clr-accent);
  text-shadow: 0 0 20px rgba(245,200,66,.5);
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: background .15s, text-shadow .15s;
}
.logo-icon {
  width: 28px;
  height: 28px;
  display: block;
}
.logo-btn:hover  { background: rgba(245,200,66,.08); text-shadow: 0 0 28px rgba(245,200,66,.8); }
.logo-btn:active { transform: scale(.95); }

/* Restore duck */
.restore-duck-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  background: rgba(245,200,66,.15);
  border: 1px solid rgba(245,200,66,.4);
  color: var(--clr-accent);
  backdrop-filter: blur(12px);
  transition: background .15s, transform .1s;
  animation: fadeSlideIn .25s ease-out;
}
.restore-duck-btn:hover  { background: rgba(245,200,66,.25); }
.restore-duck-btn:active { transform: scale(.94); }
.restore-duck-btn.hidden { display: none; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Trash Bin ───────────────────────────────────────────────── */
.trash-btn {
  position: relative;
  background: var(--clr-accent);
  border-color: var(--clr-accent);
  color: #0a0800;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.2s ease,
              color 0.2s ease,
              border-color 0.2s ease,
              box-shadow 0.2s ease;
}

/* As soon as ANY drag starts: scale up + turn red, ready to receive */
.trash-btn.drag-active {
  transform: scale(1.25) !important;
  color: #0a0800 !important;
  background: var(--clr-accent) !important;
  border-color: var(--clr-accent) !important;
  box-shadow: 0 0 20px rgba(245,200,66,0.42) !important;
}

/* When pointer is directly over it: full glow + stronger orange */
.trash-btn.drag-over {
  transform: scale(1.35) !important;
  background: rgba(245,200,66,0.46) !important;
  border-color: rgba(245,200,66,0.95) !important;
  box-shadow: 0 0 32px rgba(245,200,66,0.62) !important;
  animation: trashPulse 0.4s ease-in-out infinite alternate;
}
@keyframes trashPulse {
  from { box-shadow: 0 0 20px rgba(245,200,66,0.45); }
  to   { box-shadow: 0 0 40px rgba(245,200,66,0.75); }
}

/* ── Icon Buttons ─────────────────────────────────────────────── */
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
  border: 1px solid var(--clr-border);
  color: var(--clr-txt);
  transition: background .15s, transform .1s;
}
.icon-btn:hover  { background: rgba(255,255,255,.18); }
.icon-btn:active { transform: scale(.92); }

/* ── Bottom Toolbar ───────────────────────────────────────────── */
.toolbar-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 16px 24px calc(var(--safe-bottom) + 24px);
  display: flex; align-items: center; justify-content: center; gap: 32px;
  background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 100%);
  /* Animate in from bottom */
  transform: translateY(100%);
  opacity: 0;
}
.ar-ui.visible .toolbar-bottom {
  animation: slideUp 0.5s cubic-bezier(0.34, 1.3, 0.64, 1) 0.28s forwards;
}
@keyframes slideUp {
  to { transform: translateY(0); opacity: 1; }
}

/* Tool buttons */
.tool-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 0;
  padding: 0; border-radius: 50%;
  color: #101010;
  background: var(--clr-accent);
  border: 1px solid var(--clr-accent);
  backdrop-filter: blur(12px);
  width: 56px;
  min-width: 56px;
  height: 56px;
  transition: background .15s, border-color .15s, transform .1s;
}
.tool-btn:hover  { background: #f9d45a; border-color: #f9d45a; }
.tool-btn:active { transform: scale(.94); }
.tool-btn.active {
  background: #f9d45a;
  border-color: #f9d45a;
  color: #101010;
}
.tool-label { display: none; }

/* Capture button */
.capture-btn {
  width: 72px; height: 72px; border-radius: 50%;
  position: relative; display: flex; align-items: center; justify-content: center;
  background: transparent; transition: transform .12s;
}
.capture-btn:active { transform: scale(.9); }
.capture-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid #fff; transition: opacity .15s;
}
.capture-btn:active .capture-ring { opacity: .7; }
.capture-inner {
  width: 56px; height: 56px; border-radius: 50%;
  background: #fff; transition: transform .12s;
}
.capture-btn:active .capture-inner { transform: scale(.88); }

/* ── Panels ──────────────────────────────────────────────────── */
.panel {
  position: fixed; /* fixed instead of absolute — anchors to viewport regardless of ar-ui */
  bottom: 0; left: 0; right: 0; z-index: 30;
  pointer-events: auto;
  background: var(--clr-glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--clr-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 0 20px calc(var(--safe-bottom) + 24px);
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,.72,0,1);
  max-height: 75vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.panel.open { transform: translateY(0); }

.panel-top {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--clr-glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  margin: 0 -20px;
  padding: 8px 20px 12px;
}
.panel-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.2); margin: 14px auto 0;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px;
}

/* Panel tabs */
.panel-tabs { display: flex; gap: 4px; }
.tab-btn {
  padding: 7px 18px; border-radius: 20px;
  font-size: 14px; font-weight: 600;
  color: #fff;
  background: transparent;
  border: 1px solid #fff;
  transition: all .15s;
}
.tab-btn.active {
  color: #181818;
  background: #fff;
  border-color: #fff;
}
.panel-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.1); color: var(--clr-txt-muted);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.panel-close:hover { background: rgba(255,255,255,.18); }

.tab-pane { display: none; padding-top: 0; }
.tab-pane.active { display: block; }

/* ── Sticker Grid ────────────────────────────────────────────── */
.sticker-categories {
  display: flex; gap: 8px; overflow-x: auto;
  scrollbar-width: none;
  padding: 6px 0 12px;
  background: transparent;
}
.panel-top:has(.tab-btn[data-tab="text"].active) .sticker-categories {
  display: none;
}
.sticker-categories::-webkit-scrollbar { display: none; }
.cat-btn {
  flex-shrink: 0; padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  color: var(--clr-txt-muted);
  background: rgba(255,255,255,.07); border: 1px solid var(--clr-border);
  transition: all .15s;
}
.cat-btn.active { color: var(--clr-bg); background: var(--clr-accent); border-color: var(--clr-accent); }
.sticker-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 8px; padding-bottom: 8px; }
.sticker-btn {
  aspect-ratio: 1; font-size: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.05); border: 1px solid transparent;
  transition: background .1s, transform .1s; line-height: 1;
}
.sticker-btn:hover  { background: rgba(255,255,255,.12); }
.sticker-btn:active { transform: scale(.88); }
.sticker-btn--image { padding: 4px; font-size: 0; }
.sticker-btn--image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Text Controls ───────────────────────────────────────────── */
.text-controls { display: flex; flex-direction: column; gap: 16px; }
.ctrl-group { display: flex; flex-direction: column; gap: 8px; }
.ctrl-group--half { flex: 1; }
.ctrl-row { display: flex; gap: 12px; }
.ctrl-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--clr-txt-muted); }
.text-input {
  width: 100%; background: rgba(255,255,255,.07);
  border: 1px solid var(--clr-border); border-radius: var(--radius-md);
  padding: 12px 14px; color: var(--clr-txt); font-size: 15px;
  resize: none; outline: none; transition: border-color .15s;
}
.text-input:focus { border-color: rgba(245,200,66,.5); }
.text-input::placeholder { color: var(--clr-txt-muted); }
.font-options { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.font-options::-webkit-scrollbar { display: none; }
.font-opt {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px;
  font-size: 14px; color: var(--clr-txt-muted);
  background: rgba(255,255,255,.07); border: 1px solid var(--clr-border);
  white-space: nowrap; transition: all .15s;
}
.font-opt.active { color: var(--clr-accent); background: rgba(245,200,66,.1); border-color: rgba(245,200,66,.4); }
.slider { width: 100%; -webkit-appearance: none; height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); outline: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--clr-accent); cursor: pointer; box-shadow: 0 0 0 2px rgba(245,200,66,.3); }
.slider--sm { width: 80px; }
.toggle-row { display: flex; gap: 8px; }
.style-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.07); border: 1px solid var(--clr-border);
  color: var(--clr-txt-muted); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.style-toggle[data-active="true"] { color: var(--clr-accent); background: rgba(245,200,66,.12); border-color: rgba(245,200,66,.4); }
.color-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-pick { -webkit-appearance: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--clr-border); padding: 0; cursor: pointer; background: none; overflow: hidden; }
.color-pick::-webkit-color-swatch-wrapper { padding: 0; border-radius: 50%; }
.color-pick::-webkit-color-swatch { border: none; border-radius: 50%; }
.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s, border-color .1s; flex-shrink: 0; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: #fff; }
/* Custom (rainbow) swatch */
.swatch--custom {
  background: linear-gradient(135deg, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%));
  position: relative;
}
/* Color picker panel */
.color-picker-wrap {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .25s ease, opacity .2s ease;
  margin-top: 0;
}
.color-picker-wrap.open {
  max-height: 260px;
  opacity: 1;
  margin-top: 10px;
}
hex-color-picker {
  width: 100%;
  --cp-border-radius: 10px;
  --cp-color: #fff;
}
.align-row { display: flex; gap: 8px; }
.align-btn { width: 40px; height: 36px; border-radius: var(--radius-sm); background: rgba(255,255,255,.07); border: 1px solid var(--clr-border); color: var(--clr-txt-muted); display: flex; align-items: center; justify-content: center; transition: all .15s; }
.align-btn.active { color: var(--clr-accent); background: rgba(245,200,66,.12); border-color: rgba(245,200,66,.4); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border-radius: var(--radius-lg);
  background: var(--clr-accent); color: #0a0800;
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 24px rgba(245,200,66,.35);
}
.btn-primary:hover  { background: #f9d45a; box-shadow: 0 6px 32px rgba(245,200,66,.5); }
.btn-primary:active { transform: scale(.96); }
.btn-primary:disabled { opacity: 0.55; cursor: default; box-shadow: none; }
.btn-primary:disabled:hover { background: var(--clr-accent); box-shadow: none; }
.btn-full { width: 100%; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-lg);
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: var(--clr-txt); font-weight: 600; font-size: 14px;
  backdrop-filter: blur(12px); transition: background .15s, transform .1s;
}
.btn-secondary:hover  { background: rgba(255,255,255,.18); }
.btn-secondary:active { transform: scale(.96); }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-lg);
  background: var(--clr-accent); color: #0a0800;
  font-weight: 700; font-size: 14px;
  transition: background .15s, transform .1s;
  box-shadow: 0 4px 20px rgba(245,200,66,.45);
}
.btn-danger:hover  { background: #f9d45a; }
.btn-danger:active { transform: scale(.96); }
.btn-ghost { padding: 10px; font-size: 14px; color: var(--clr-txt-muted); text-align: center; width: 100%; transition: color .15s; }
.btn-ghost:hover { color: var(--clr-txt); }

/* ── Modals ──────────────────────────────────────────────────── */
.modal { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(8px); }
.modal-card {
  position: relative; width: min(92vw, 420px);
  background: var(--clr-glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border); border-radius: var(--radius-xl);
  overflow: hidden; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  animation: modalIn .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.88) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-img-wrap { width: 100%; border-radius: var(--radius-md); overflow: hidden; background: #000; }
.modal-img-wrap img { width: 100%; height: auto; display: block; max-height: 62vh; object-fit: contain; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn-secondary, .modal-actions .btn-primary { padding: 12px 22px; }
.confirm-card {
  position: relative; width: min(88vw, 360px);
  background: var(--clr-glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border); border-radius: var(--radius-xl);
  padding: 28px 24px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  animation: modalIn .28s cubic-bezier(.34,1.56,.64,1);
}
.confirm-icon  {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--clr-accent);
}
.confirm-title { font-size: 18px; font-weight: 700; }
.confirm-body  { font-size: 14px; color: var(--clr-txt-muted); line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; width: 100%; margin-top: 4px; }
.confirm-actions .btn-secondary, .confirm-actions .btn-danger { flex: 1; justify-content: center; }

/* ── Scrollbar ───────────────────────────────────────────────── */
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

/* ── Panel Overlay (click outside to close) ─────────────────── */
.panel-overlay {
  position: fixed; inset: 0; z-index: 29;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s cubic-bezier(.32,.72,0,1);
}
.panel-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 720px) {
  .overlay-layer-island {
    right: 6px;
    top: calc(var(--safe-top) + 68px);
  }
}

/* ── Sticker transform handles (desktop) ─────────────────────── */
.sticker-handles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}

.handle-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1.5px solid rgba(0,0,0,0.35);
  border-radius: 3px;
  transform: translate(-50%, -50%);
  pointer-events: all;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}
.handle-corner[data-corner="tl"] { cursor: nw-resize; }
.handle-corner[data-corner="tr"] { cursor: ne-resize; }
.handle-corner[data-corner="bl"] { cursor: sw-resize; }
.handle-corner[data-corner="br"] { cursor: se-resize; }

.handle-rotate {
  position: absolute;
  width: 24px;
  height: 24px;
  background: #fff;
  border: 1.5px solid rgba(0,0,0,0.35);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: all;
  cursor: grab;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}
.handle-rotate:active { cursor: grabbing; }

/* Hide handles on touch-only devices */
@media (hover: none) {
  .sticker-handles { display: none !important; }
}
