/* ============================================================
   Sticker Forge — sticker.riti.dev
   Dark theme · one accent gradient · transform/opacity animations
   ============================================================ */

:root {
  /* palette */
  --bg: #0b0b12;
  --bg-soft: #11111c;
  --card: rgba(22, 22, 34, 0.78);
  --card-solid: #161622;
  --line: #272739;
  --line-bright: #3b3b56;
  --text: #ecedf4;
  --muted: #9a9ab2;
  --faint: #6c6c86;

  /* the one accent gradient + solid accents pulled from it */
  --grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 55%, #f97316 110%);
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --pink: #ec4899;
  --ok: #34d399;
  --danger: #f87171;

  /* spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;

  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
          "Segoe UI Emoji", "Noto Color Emoji";
}

* { box-sizing: border-box; }

/* the hidden attribute must always win, even over display:grid/flex rules */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;  /* fallback */
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* keep content clear of notches / home indicators */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* custom :active / focus states everywhere — kill the grey tap flash */
a, button, input, label, summary, .dropzone {
  -webkit-tap-highlight-color: transparent;
}

/* text inputs are >= 16px so iOS never auto-zooms on focus
   (zero-specificity floor; component rules may set larger sizes) */
:where(input, textarea, select) { font-size: max(1rem, 16px); }

::selection { background: rgba(139, 92, 246, 0.45); }

:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 6px;
}

button { font-family: inherit; cursor: pointer; }
input, output { font-family: inherit; }

/* ------------------------------------------------------------
   Aurora background (transform/opacity only, GPU friendly)
   ------------------------------------------------------------ */
.aurora {
  position: fixed;
  inset: -20%;
  z-index: -3;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.32;
  will-change: transform;
}

.b1 {
  background: radial-gradient(circle at 30% 30%, #7c3aed, transparent 65%);
  top: -10%; left: -8%;
  animation: drift1 38s ease-in-out infinite alternate;
}
.b2 {
  background: radial-gradient(circle at 60% 40%, #db2777, transparent 65%);
  top: 20%; right: -15%;
  animation: drift2 46s ease-in-out infinite alternate;
}
.b3 {
  background: radial-gradient(circle at 50% 50%, #0ea5e9, transparent 65%);
  bottom: -18%; left: 18%;
  opacity: 0.22;
  animation: drift3 52s ease-in-out infinite alternate;
}
.b4 {
  background: radial-gradient(circle at 50% 50%, #f59e0b, transparent 60%);
  bottom: 5%; right: 22%;
  width: 34vmax; height: 34vmax;
  opacity: 0.14;
  animation: drift1 60s ease-in-out infinite alternate-reverse;
}

@keyframes drift1 {
  from { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  to   { transform: translate3d(9vw, 7vh, 0) rotate(40deg) scale(1.15); }
}
@keyframes drift2 {
  from { transform: translate3d(0, 0, 0) rotate(0deg) scale(1.1); }
  to   { transform: translate3d(-10vw, -6vh, 0) rotate(-35deg) scale(0.92); }
}
@keyframes drift3 {
  from { transform: translate3d(0, 0, 0) scale(0.95); }
  to   { transform: translate3d(7vw, -9vh, 0) scale(1.18); }
}

/* faint vignette to keep content readable */
.grain {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, transparent 55%, rgba(5, 5, 10, 0.75) 100%),
    linear-gradient(180deg, rgba(11, 11, 18, 0.25), rgba(11, 11, 18, 0.85));
}

/* ------------------------------------------------------------
   Floating decorative emojis with parallax drift
   ------------------------------------------------------------ */
.floaties {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.fl {
  position: absolute;
  font-size: 30px;
  opacity: 0.5;
  transform: translate(calc(var(--mx, 0) * var(--d, 10) * 1px),
                       calc(var(--my, 0) * var(--d, 10) * 1px));
  transition: transform 0.5s cubic-bezier(0.2, 0.6, 0.3, 1);
  will-change: transform;
}

.fl em {
  display: block;
  font-style: normal;
  animation: floaty 7s ease-in-out infinite alternate;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
}

.f1 { top: 12%; left: 7%;  font-size: 36px; }
.f2 { top: 22%; right: 9%; font-size: 30px; }  .f2 em { animation-delay: -2s; animation-duration: 9s; }
.f3 { top: 58%; left: 4%;  font-size: 26px; }  .f3 em { animation-delay: -4s; }
.f4 { top: 72%; right: 6%; font-size: 32px; }  .f4 em { animation-delay: -1s; animation-duration: 8s; }
.f5 { top: 40%; left: 13%; font-size: 22px; opacity: 0.35; } .f5 em { animation-delay: -5s; }
.f6 { top: 8%;  right: 24%; font-size: 22px; opacity: 0.4; } .f6 em { animation-delay: -3s; animation-duration: 10s; }
.f7 { top: 84%; left: 20%; font-size: 28px; } .f7 em { animation-delay: -6s; }

@keyframes floaty {
  from { transform: translate3d(0, -10px, 0) rotate(-6deg); }
  to   { transform: translate3d(0, 14px, 0) rotate(8deg); }
}

/* ------------------------------------------------------------
   Hero
   ------------------------------------------------------------ */
.hero {
  text-align: center;
  padding: var(--s8) var(--s4) var(--s6);
  max-width: 760px;
  margin: 0 auto;
}

.brand-mark {
  font-size: 52px;
  line-height: 1;
  margin-bottom: var(--s3);
  animation: markIn 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 10px 25px rgba(236, 72, 153, 0.35));
}

@keyframes markIn {
  from { opacity: 0; transform: scale(0.4) rotate(-25deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.brand {
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  animation: riseIn 0.7s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: var(--s1) 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: var(--faint);
  animation: riseIn 0.7s 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tagline {
  margin: var(--s4) auto 0;
  max-width: 34em;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  color: var(--muted);
  animation: riseIn 0.7s 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 var(--s4) var(--s7);
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s4);
}

/* ------------------------------------------------------------
   Drop zone
   ------------------------------------------------------------ */
.dropzone {
  position: relative;
  border-radius: var(--radius-lg);
  padding: var(--s7) var(--s5);
  text-align: center;
  cursor: pointer;
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
  animation: riseIn 0.7s 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  -webkit-tap-highlight-color: transparent;
}

.dz-border {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px dashed var(--line-bright);
  pointer-events: none;
  transition: border-color 0.25s ease;
}

@media (hover: hover) {
  .dropzone:hover { transform: translateY(-2px); }
  .dropzone:hover .dz-border { border-color: #5b5b84; }
}

.dropzone.dragover {
  transform: scale(1.025);
  box-shadow: 0 0 0 5px var(--accent-soft), 0 18px 50px rgba(139, 92, 246, 0.3);
}

.dropzone.dragover .dz-border {
  border-color: var(--accent);
  animation: dashPulse 1.1s ease-in-out infinite;
}

@keyframes dashPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.dz-icon {
  font-size: 46px;
  line-height: 1;
  margin-bottom: var(--s3);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dropzone.dragover .dz-icon { transform: scale(1.25) rotate(-8deg); }

.dz-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 var(--s2);
}

.dz-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.dz-link {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ------------------------------------------------------------
   Sticker grid
   ------------------------------------------------------------ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.section-head .hint {
  margin: 0;
  /* this line is the only discoverability cue for reordering + emoji
     editing — keep it comfortably above 4.5:1 on the dark backdrop */
  color: var(--muted);
  font-size: 0.85rem;
}

.count-pill {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.5em;
  margin-left: var(--s1);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c4b5fd;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  vertical-align: 2px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--s4);
}

.card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-3px);
    border-color: var(--line-bright);
    box-shadow: var(--shadow);
  }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.75) translateY(16px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.card.leaving {
  animation: popOut 0.32s cubic-bezier(0.55, 0, 0.68, 0.2) both;
  pointer-events: none;
}

@keyframes popOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.7) translateY(12px); }
}

.card.dragging { opacity: 0.35; }

/* checkerboard transparency backing */
.checker {
  background-color: #1b1b26;
  background-image: conic-gradient(#262633 25%, #1b1b26 0 50%, #262633 0 75%, #1b1b26 0);
  background-size: 18px 18px;
}

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: grab;
}

.thumb:active { cursor: grabbing; }

.thumb img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.45));
  -webkit-user-drag: none;
  user-select: none;
}

.thumb img.swap-in { animation: swapIn 0.5s ease both; }

@keyframes swapIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* shimmer / skeleton overlay while cutout is processing */
.shimmer {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  background: rgba(12, 12, 20, 0.55);
  backdrop-filter: blur(2px);
}

.card.processing .shimmer { display: block; }
.card.processing .actions button { pointer-events: none; opacity: 0.45; }

.shimmer::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 55%;
  transform: translateX(-140%) skewX(-14deg);
  background: linear-gradient(90deg, transparent,
              rgba(196, 181, 253, 0.28), transparent);
  animation: shimmerSlide 1.15s ease-in-out infinite;
}

@keyframes shimmerSlide {
  to { transform: translateX(320%) skewX(-14deg); }
}

.shimmer .scissors {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  animation: snip 1s ease-in-out infinite alternate;
}

@keyframes snip {
  from { transform: scale(0.9) rotate(-12deg); }
  to   { transform: scale(1.1) rotate(10deg); }
}

.meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3) 0;
}

.fname {
  flex: 1;
  min-width: 0;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emoji-input {
  width: 46px;
  flex: none;
  text-align: center;
  font-size: 1.15rem;
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease;
}

@media (hover: hover) {
  .emoji-input:hover { border-color: var(--line-bright); }
}
.emoji-input:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.actions {
  display: flex;
  gap: var(--s1);
  padding: var(--s2) var(--s3) var(--s3);
}

.btn {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 4px;
  border-radius: 10px;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
}

@media (hover: hover) {
  .btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--line-bright); }
}
.btn:active { transform: scale(0.95); }

.btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #d6c8ff;
}

.btn.icon {
  flex: 0 0 34px;
  font-size: 0.9rem;
  padding: 7px 0;
}

@media (hover: hover) {
  .btn.icon.danger:hover {
    background: rgba(248, 113, 113, 0.12);
    border-color: var(--danger);
    color: var(--danger);
  }
}

/* Touch devices: no hover affordances exist, so card actions stay visible
   (they are never hover-gated) and every tappable control hits 44x44. */
@media (hover: none), (max-width: 640px) {
  .card .actions { display: flex; }
  .btn { min-height: 44px; padding: 10px 6px; font-size: 0.82rem; }
  .btn.icon { flex: 0 0 44px; min-width: 44px; }
  .emoji-input { min-width: 52px; min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .seg-btn { min-height: 44px; padding: 10px 18px; }
  .ghost-btn { min-height: 44px; }
  .cta.small { min-height: 44px; }
  .result summary { padding-top: var(--s4); padding-bottom: var(--s4); }
}

/* ------------------------------------------------------------
   Panels (pack details + result)
   ------------------------------------------------------------ */
.panel {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  box-shadow: var(--shadow-soft);
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.field { display: flex; flex-direction: column; gap: var(--s2); }

.field span {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease;
}

@media (hover: hover) {
  .field input:hover { border-color: var(--line-bright); }
}
.field input:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.create-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
}

/* the big gradient CTA */
.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  border: 0;
  border-radius: 16px;
  padding: 15px 30px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: var(--grad);
  background-size: 160% 160%;
  box-shadow: 0 8px 26px rgba(190, 60, 160, 0.35);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease, background-position 0.4s ease;
  text-decoration: none;
}

@media (hover: hover) {
  .cta:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 38px rgba(216, 70, 170, 0.55);
    background-position: 80% 50%;
  }
}

.cta:active:not(:disabled) { transform: scale(0.97); }

.cta:disabled {
  opacity: 0.55;
  cursor: progress;
  box-shadow: none;
}

.cta .cta-arrow { transition: transform 0.25s ease; }
@media (hover: hover) {
  .cta:hover:not(:disabled) .cta-arrow { transform: translateX(4px); }
}

.cta.small { padding: 9px 20px; font-size: 0.9rem; border-radius: 12px; }

/* signal status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
}

.badge.on { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.4); }

/* cutout-status pill: amber warning while stickers still have backgrounds */
.badge.warn {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}

.badge .dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.75); }
}

/* indeterminate progress */
.progress { margin-top: var(--s5); }

.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

/* indeterminate: light the FULL track and sweep a bright band across it.
   A frozen frame always shows a complete glowing bar — never an empty
   track with a small detached pill stuck at one end. */
.bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg,
      rgba(139, 92, 246, 0.35) 0%,
      #8b5cf6 35%,
      #ec4899 50%,
      #f97316 62%,
      rgba(139, 92, 246, 0.35) 100%);
  background-size: 200% 100%;
  animation: barSweep 1.4s linear infinite;
}

@keyframes barSweep {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.status-msg {
  margin: var(--s3) 0 0;
  font-size: 0.9rem;
  font-weight: 500;
  /* the only feedback during the slowest step — must clear WCAG 4.5:1
     on the near-black panel (≈11:1 here) */
  color: #c5c5dd;
  animation: statusFade 0.4s ease both;
}

@keyframes statusFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   Result panel
   ------------------------------------------------------------ */
.result {
  animation: resultIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  scroll-margin-top: var(--s4); /* breathing room when scrolled into view */
}

@keyframes resultIn {
  from { opacity: 0; transform: scale(0.94) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.result h2 { font-size: 1.5rem; }

.result .summary { color: var(--muted); margin: 0 0 var(--s4); }

.result .note {
  margin: var(--s4) 0;
  padding: var(--s3) var(--s4);
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  color: #fcd34d;
  font-size: 0.9rem;
}

.result-actions {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
  align-items: center;
  margin: var(--s4) 0;
}

.ghost-btn {
  border: 1px solid var(--line-bright);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 12px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

@media (hover: hover) {
  .ghost-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); border-color: #55557c; }
}
.ghost-btn:active:not(:disabled) { transform: scale(0.96); }
.ghost-btn:disabled { opacity: 0.4; cursor: default; }

.result details {
  margin-top: var(--s4);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.result summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--s3) var(--s4);
  list-style: none;
  transition: background 0.2s ease;
}

.result summary::-webkit-details-marker { display: none; }
.result summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--s2);
  color: #c4b5fd;
  transition: transform 0.25s ease;
}

.result details[open] summary::before { transform: rotate(90deg); }
@media (hover: hover) {
  .result summary:hover { background: rgba(255, 255, 255, 0.04); }
}

/* friendly informational tip (zip mode) */
.result .tip {
  margin: var(--s3) 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.result details ol {
  margin: 0;
  padding: var(--s2) var(--s5) var(--s4) calc(var(--s5) + 1.2em);
  color: var(--muted);
  font-size: 0.92rem;
}

.result details li { margin-bottom: var(--s2); }
.result details code {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.85em;
}

/* ------------------------------------------------------------
   Refine editor modal
   ------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--s4);
  /* don't let touch scrolling chain to the (locked) page behind */
  overscroll-behavior: contain;
}

.modal-backdrop {
  /* full-viewport, viewport-fixed: the page behind the editor is always
     covered even if anything ever scrolls underneath */
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 12, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: min(820px, 100%);
  max-height: calc(100vh - 32px);  /* fallback */
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  min-width: 0;
}

.ed-name {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease;
}

@media (hover: hover) {
  .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 200px;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}

#edCanvas {
  max-width: 100%;
  max-height: min(58vh, 560px);  /* fallback */
  max-height: min(58dvh, 560px);
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.brush-cursor {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.6), inset 0 0 0 1.5px rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  overflow: hidden;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 16px;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--line-bright); }

.seg-btn.active {
  background: var(--accent-soft);
  color: #d6c8ff;
}

.size-ctl {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: 0.85rem;
  color: var(--muted);
}

.size-ctl input[type="range"] {
  width: 130px;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  height: 32px;
  background: transparent;
  cursor: pointer;
}

/* big friendly thumb — easy to grab with a finger */
.size-ctl input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.size-ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.size-ctl input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.size-ctl input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.size-ctl output {
  min-width: 2.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ed-actions {
  display: flex;
  gap: var(--s2);
  margin-left: auto;
  flex-wrap: wrap;
}

/* full scroll lock while the editor modal is open: position:fixed is
   needed because iOS Safari ignores overflow:hidden on body. JS saves
   the scroll offset (body.style.top) and restores it on close. */
body.no-scroll {
  overflow: hidden;
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

/* ------------------------------------------------------------
   Toasts
   ------------------------------------------------------------ */
.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: min(380px, calc(100vw - 32px));
  /* toasts are purely informational — never intercept taps meant
     for the content (or the sticky action bar) underneath */
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: var(--s3) var(--s4);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.toast.out { animation: toastOut 0.3s ease both; }

.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
.toast.info    { border-left-color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* ------------------------------------------------------------
   Confetti
   ------------------------------------------------------------ */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  border-radius: 2px;
  will-change: transform, opacity;
}

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
.foot {
  text-align: center;
  padding: var(--s5) var(--s4) var(--s6);
  color: var(--faint);
  font-size: 0.82rem;
}

/* ------------------------------------------------------------
   Sticky bottom action bar (small screens only)
   ------------------------------------------------------------ */
.mobile-bar { display: none; }

/* ------------------------------------------------------------
   Responsive — phones first: single column, thumb reach, calm GPU
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .hero { padding-top: var(--s7); }
  .fields { grid-template-columns: 1fr; }
  .toolbar { gap: var(--s3); }
  .ed-actions { margin-left: 0; width: 100%; }
  .ed-actions .cta.small { flex: 2; min-height: 48px; font-size: 1rem; }
  .ed-actions .ghost-btn { flex: 1; min-height: 48px; }

  /* two compact columns of sticker cards: a realistic 20-sticker pack
     stays a short scroll instead of a multi-thousand-pixel column, and
     the Pack details form stays within reach */
  .grid { grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
  /* cap preview height so thumbnails stay small (~180px max) */
  .thumb { max-height: 180px; }
  /* compact card chrome to match the narrower cards */
  .meta { padding: var(--s2) var(--s2) 0; }
  .actions { flex-wrap: wrap; gap: var(--s1); padding: var(--s2); }
  .actions .btn,
  .actions .btn.icon { flex: 1 1 calc(50% - var(--s1)); min-width: 0; }
  .btn { font-size: 0.78rem; padding: 10px 2px; }
  .cta { width: 100%; }
  .dropzone { padding: var(--s6) var(--s4); }

  /* sticky bottom action bar: create + count always within thumb reach */
  .mobile-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
    background: rgba(13, 13, 21, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .mb-count {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    min-width: 56px;
  }
  .mb-count strong { font-size: 1.15rem; }
  .mb-count-label {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .mb-cta { flex: 1; width: auto; min-height: 52px; padding: 12px 18px; }

  /* NOTE: there is no hidden duplicate CTA — app.js moves the single
     #createBtn into the bar at this breakpoint and back out above it */

  /* keep scrolled content clear of the fixed bar: --mobile-bar-h is the
     measured bar height set by JS (it already includes the bar's
     safe-area padding), so the bar never covers the last card's
     Cutout/Refine controls or the pack/result panels */
  body.has-mobile-bar main {
    padding-bottom: calc(var(--mobile-bar-h, 96px) + var(--s6));
  }
  body.has-mobile-bar .foot {
    padding-bottom: calc(var(--mobile-bar-h, 96px) + var(--s5));
  }
  /* scrollIntoView / anchor scrolls also stop clear of the bar */
  html {
    scroll-padding-bottom: calc(var(--mobile-bar-h, 0px) + var(--s4));
  }

  /* toasts: full width, above the action bar */
  .toasts {
    left: var(--s4);
    right: var(--s4);
    bottom: calc(var(--s4) + env(safe-area-inset-bottom));
    max-width: none;
  }
  body.has-mobile-bar .toasts { bottom: calc(var(--mobile-bar-h, 96px) + var(--s3)); }

  /* full-screen refine editor */
  .modal { padding: 0; place-items: stretch; }
  .modal-card {
    width: 100%;
    height: 100vh;  /* fallback */
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  .modal-head { padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3); }
  .canvas-wrap { min-height: 0; }
  #edCanvas { max-height: 100%; }
  .toolbar {
    padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  }
  .seg { display: flex; width: 100%; }
  .seg-btn { flex: 1; }
  .size-ctl { width: 100%; }
  .size-ctl input[type="range"] { flex: 1; width: auto; }

  /* lighter aurora on phones: half the blobs, gentler blur, no floaties */
  .b3, .b4 { display: none; }
  .blob { filter: blur(48px); opacity: 0.28; }
  .fl { display: none; }
}

/* ------------------------------------------------------------
   Reduced motion: keep it calm
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .blob, .fl, .fl em { animation: none !important; }
  .fl { transition: none; }
  .bar-fill {
    animation: none !important;
    background-position: 50% 0;
    opacity: 0.7;
  }
  .shimmer::after { animation: none !important; }
}
