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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-size: 100% 100%;
    background-repeat: no-repeat;

}

body.busy {
  cursor: progress;
}

#overlaysContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

.overlay-textbox {
  position: absolute;
  pointer-events: all;
  background: transparent; /* overridden inline by JS with sampled background color */
  border: 1px solid rgba(66, 133, 244, 0.5);
  border-radius: 45px;
  resize: none;
  outline: none;
  font-family: 'Times New Roman', Times, serif;
  font-weight: bold;
  font-style: italic;
  font-size: 14px;
  padding: 4px 40px;
  box-sizing: border-box;
  text-align: center;
}

.overlay-textbox::placeholder {
  color: currentColor;
  opacity: 0.4;
}

.overlay-textbox:focus {
  border-color: rgba(66, 133, 244, 0.9);
}

#clickSpinner {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  pointer-events: none;
  z-index: 999999;
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Pending click indicator ───────────────────────────────────────────── */

.click-pending {
  position: fixed;
  pointer-events: none;
  z-index: 999989;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.click-pending::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.92), transparent 40%),
    radial-gradient(circle at 30% 48%, rgba(255, 255, 255, 0.78),  transparent 42%);
  filter: blur(4px);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.95), 0 0 42px rgba(255, 255, 255, 0.55);
  animation: pendingBreathe 2s ease-in-out infinite;
}

.click-pending::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 48% 52% 52% 48% / 48% 42% 58% 52%;
  border-top: 1px solid rgba(255, 255, 255, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.88);
  animation: pendingRing 2s ease-in-out infinite;
}

@keyframes pendingBreathe {
  0%, 100% { opacity: 0.45; transform: scale(0.88); }
  50%       { opacity: 1;    transform: scale(1.08); }
}

@keyframes pendingRing {
  0%, 100% { opacity: 0.3;  transform: rotate(-5deg) scaleX(0.9); }
  50%       { opacity: 0.78; transform: rotate(6deg)  scaleX(1.08); }
}

/* ─── Loading text ───────────────────────────────────────────────────────── */

#loadingText {
  position: fixed;
  pointer-events: none;
  z-index: 999990;
  display: none;
  color: rgba(247, 255, 252, 0.82);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow:
    0 0 12px rgba(186, 255, 238, 0.45),
    0 1px 8px rgba(7, 23, 27, 0.5);
  transform: translate(-50%, -50%);
  animation: loadingPopoverIn 120ms ease forwards;
}

.loading-cursor {
  display: inline-block;
  width: 1.5px;
  height: 1em;
  background: rgba(255, 255, 255, 0.88);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: loadingBlink 0.8s step-end infinite;
}

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

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

/* ─── Custom cursor & click effects ─────────────────────────────────────── */

body.custom-cursor {
  cursor: none;
}

.effect-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 350;
}

.cursor-hint {
  position: fixed;
  --pointer-size: 56px;
  width: var(--pointer-size);
  height: var(--pointer-size);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  transition:
    opacity 120ms ease,
    width 180ms ease,
    height 180ms ease;
  z-index: 9999;
}

.cursor-hint::before,
.cursor-hint::after,
.pointer-mark,
.pointer-trail,
.dust-mote,
.cursor-hint .thought-thread {
  content: "";
  position: absolute;
  pointer-events: none;
}

.cursor-hint::before,
.cursor-hint::after,
.pointer-mark {
  inset: 0;
  border-radius: inherit;
}

.pointer-trail,
.dust-mote,
.cursor-hint .thought-thread {
  opacity: 0;
}

/* Pointer: Soft Focus */
.pointer-focus {
  --pointer-size: 58px;
  border-radius: 50%;
}

.pointer-focus::before {
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(21, 23, 22, 0.2),
    0 0 26px rgba(255, 255, 255, 0.46);
  animation: pointerBreathe 1500ms ease-in-out infinite;
}

.pointer-focus::after {
  inset: 13px;
  border: 1px solid rgba(21, 154, 156, 0.55);
  opacity: 0.74;
}

/* Pointer: AI Brush */
.pointer-brush {
  --pointer-size: 34px;
  border-radius: 42% 58% 52% 48% / 48% 44% 56% 52%;
  transform: translate(-45%, -35%) rotate(-28deg);
}

.pointer-brush::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(21, 154, 156, 0.32));
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: 0 0 18px rgba(21, 154, 156, 0.28);
}

.pointer-brush .pointer-trail {
  left: 4px;
  top: 34px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 10px rgba(21, 154, 156, 0.42);
  opacity: 1;
  animation: brushTrail 900ms ease-in-out infinite;
}

.pointer-brush .trail-two {
  left: -7px;
  top: 42px;
  width: 5px;
  height: 5px;
  animation-delay: 140ms;
}

.pointer-brush .trail-three {
  left: -16px;
  top: 49px;
  width: 4px;
  height: 4px;
  animation-delay: 260ms;
}

/* Pointer: Target Lens */
.pointer-lens {
  --pointer-size: 64px;
  border-radius: 50%;
  backdrop-filter: brightness(1.14) saturate(1.18);
}

.pointer-lens::before {
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), rgba(21, 154, 156, 0.12) 56%, transparent 57%);
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.22),
    0 0 24px rgba(21, 154, 156, 0.28);
}

.pointer-lens::after {
  left: 64%;
  top: 64%;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  transform: rotate(45deg);
}

/* Pointer: Dust Magnet */
.pointer-dust {
  --pointer-size: 70px;
  border-radius: 50%;
}

.pointer-dust::before {
  inset: 14px;
  border: 1px solid rgba(248, 214, 107, 0.7);
  box-shadow: 0 0 22px rgba(248, 214, 107, 0.42);
  animation: pointerBreathe 1200ms ease-in-out infinite;
}

.pointer-dust .dust-mote {
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #fff2a6;
  box-shadow:
    0 0 9px rgba(255, 242, 166, 0.9),
    0 0 18px rgba(213, 161, 30, 0.6);
  opacity: 1;
  animation: pointerDust 1500ms ease-in-out infinite;
}

.pointer-dust .mote-one   { --orbit: 22px; --angle: 0deg; }
.pointer-dust .mote-two   { --orbit: 31px; --angle: 72deg;  animation-delay: 120ms; }
.pointer-dust .mote-three { --orbit: 27px; --angle: 145deg; animation-delay: 220ms; }
.pointer-dust .mote-four  { --orbit: 34px; --angle: 222deg; animation-delay: 90ms;  }
.pointer-dust .mote-five  { --orbit: 25px; --angle: 305deg; animation-delay: 180ms; }

/* Pointer: Living Blob */
.pointer-blob {
  --pointer-size: 66px;
  border-radius: 43% 57% 54% 46% / 54% 42% 58% 46%;
}

.pointer-blob::before {
  border: 1px solid rgba(255, 255, 255, 0.84);
  background: rgba(21, 154, 156, 0.12);
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.2),
    0 0 24px rgba(21, 154, 156, 0.34);
  animation: blobPointer 1800ms ease-in-out infinite;
}

.pointer-blob::after {
  inset: 16px;
  border: 1px solid rgba(248, 214, 107, 0.56);
  border-radius: 45% 55% 48% 52% / 48% 44% 56% 52%;
  animation: blobPointer 1800ms ease-in-out infinite reverse;
}

/* Pointer: Crosshair */
.pointer-crosshair {
  --pointer-size: 78px;
  border-radius: 50%;
}

.pointer-crosshair::before {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.9) 49% 51%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255, 255, 255, 0.9) 49% 51%, transparent 52%);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.28);
}

.pointer-crosshair::after {
  inset: 30px;
  border-radius: 50%;
  background: rgba(21, 154, 156, 0.82);
  box-shadow: 0 0 10px rgba(21, 154, 156, 0.62);
}

/* Pointer: Thought Field */
.pointer-thought {
  --pointer-size: 78px;
  border-radius: 50%;
  mix-blend-mode: normal;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.pointer-thought::before {
  inset: 5px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.92), transparent 40%),
    radial-gradient(circle at 30% 48%, rgba(255, 255, 255, 0.78), transparent 42%);
  filter: blur(3px);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.96), 0 0 50px rgba(255, 255, 255, 0.58);
  animation: thoughtPointerBreathe 2600ms ease-in-out infinite;
}

.pointer-thought::after {
  inset: 14px;
  border-radius: 48% 52% 52% 48% / 48% 42% 58% 52%;
  border-top: 1px solid rgba(255, 255, 255, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.92);
  transform: rotate(-5deg);
  animation: thoughtPointerRing 2400ms ease-in-out infinite;
}

.pointer-thought .thought-thread {
  left: 50%;
  top: 50%;
  width: 74%;
  height: 42%;
  border-radius: 999px;
  border-top: 1px solid rgba(255, 255, 255, 1);
  border-left: 1px solid rgba(255, 255, 255, 0.88);
  opacity: 0.88;
  transform: translate(-50%, -50%) rotate(var(--thread-tilt));
  animation: pointerThoughtThread 2100ms ease-in-out infinite;
}

.pointer-thought .thread-1 { --thread-tilt: -12deg; --thread-mid: 7deg; }
.pointer-thought .thread-2 { --thread-tilt: 8deg;  --thread-mid: -5deg; width: 64%; height: 58%; animation-delay: -700ms; }
.pointer-thought .thread-3 { --thread-tilt: 18deg; --thread-mid: -9deg; width: 88%; height: 70%; animation-delay: -1200ms; }

.pointer-thought .dust-mote {
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 12px rgba(255, 255, 255, 1), 0 0 24px rgba(255, 255, 255, 0.72);
  opacity: 1;
  animation: thoughtPointerParticle 2500ms ease-in-out infinite;
}

.pointer-thought .mote-one   { --orbit: 22px; --angle: 28deg;  }
.pointer-thought .mote-two   { --orbit: 30px; --angle: 112deg; animation-delay: -400ms;  }
.pointer-thought .mote-three { --orbit: 24px; --angle: 204deg; animation-delay: -900ms;  }
.pointer-thought .mote-four  { --orbit: 34px; --angle: 282deg; animation-delay: -1300ms; }
.pointer-thought .mote-five  { --orbit: 18px; --angle: 338deg; animation-delay: -1700ms; }

/* ─── Effect layer (fx) ──────────────────────────────────────────────────── */

.fx {
  --x: 50%;
  --y: 50%;
  --size: 160px;
  --image: none;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
}

.fx::before,
.fx::after,
.spark {
  content: "";
  position: absolute;
  pointer-events: none;
}

.patch {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--image);
  background-repeat: no-repeat;
  background-size: var(--stage-w) var(--stage-h);
  background-position: var(--bg-x) var(--bg-y);
  opacity: 0;
}

/* iris */
.iris .patch {
  filter: saturate(1.28) contrast(1.08) brightness(1.06);
  clip-path: circle(0 at 50% 50%);
  animation: irisPatch 1380ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.iris::before {
  inset: -14px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow:
    0 0 0 1px rgba(21, 154, 156, 0.26),
    0 0 34px rgba(21, 154, 156, 0.34),
    inset 0 0 38px rgba(255, 255, 255, 0.26);
  animation: irisRing 1380ms ease-out forwards;
}
.iris::after {
  inset: 22%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 20%, rgba(255, 255, 255, 0.95) 21% 23%, transparent 24% 55%, rgba(236, 119, 95, 0.75) 56% 59%, transparent 60%);
  mix-blend-mode: screen;
  animation: irisSpin 980ms ease-out forwards;
}

/* loom */
.loom { border-radius: 12px; }
.loom .patch {
  border-radius: 12px;
  filter: saturate(1.35) contrast(1.12) hue-rotate(5deg);
  -webkit-mask-image: linear-gradient(90deg, transparent 0 18%, #000 42% 58%, transparent 82% 100%);
  -webkit-mask-size: 260% 100%;
  mask-image: linear-gradient(90deg, transparent 0 18%, #000 42% 58%, transparent 82% 100%);
  mask-size: 260% 100%;
  animation: loomPatch 1500ms ease-out forwards;
}
.loom::before {
  inset: 0;
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.75) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(0deg, rgba(21, 154, 156, 0.5) 0 1px, transparent 1px 9px);
  mix-blend-mode: screen;
  clip-path: inset(0 100% 0 0);
  animation: loomGrid 1500ms ease-out forwards;
}
.loom::after {
  left: 0; top: 0; width: 2px; height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.8);
  animation: loomScanner 1500ms ease-out forwards;
}

/* petal */
.petal .patch {
  filter: saturate(1.22) brightness(1.08);
  clip-path: polygon(50% 50%, 56% 42%, 68% 50%, 56% 58%);
  animation: petalPatch 1420ms ease-out forwards;
}
.petal::before {
  inset: -10px;
  border-radius: 44% 56% 52% 48% / 52% 44% 56% 48%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  background: conic-gradient(from 0deg, rgba(236, 119, 95, 0.36), transparent 20%, rgba(21, 154, 156, 0.3), transparent 48%, rgba(213, 161, 30, 0.3), transparent 72%, rgba(110, 141, 67, 0.28));
  mix-blend-mode: screen;
  animation: petalRing 1420ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.petal::after {
  inset: 28%;
  border-radius: 40% 60% 42% 58% / 55% 42% 58% 45%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  animation: petalCore 1420ms ease-out forwards;
}

/* pulse */
.pulse .patch {
  filter: saturate(1.18) brightness(1.04);
  animation: pulsePatch 1120ms ease-out forwards;
}
.pulse::before {
  inset: 8px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(21, 23, 22, 0.12), 0 0 30px rgba(255, 255, 255, 0.48);
  animation: pulseRing 1120ms ease-out forwards;
}
.pulse::after {
  inset: 28px; border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.76);
  animation: pulseDash 1120ms ease-out forwards;
}

/* prism */
.prism .patch {
  filter: saturate(1.42) contrast(1.08) brightness(1.08);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  animation: prismPatch 1320ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.prism::before {
  inset: -4px; border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.46), transparent 38%, rgba(123, 105, 201, 0.24) 58%, transparent);
  mix-blend-mode: screen;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  animation: prismShell 1320ms ease-out forwards;
}
.prism::after {
  left: 50%; top: 6%; width: 2px; height: 88%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: -18px 12px 18px rgba(236, 119, 95, 0.42), 18px -12px 18px rgba(21, 154, 156, 0.42);
  animation: prismGlint 980ms ease-out forwards;
}

/* thread */
.thread { border-radius: 30% 70% 62% 38% / 46% 35% 65% 54%; }
.thread .patch {
  filter: saturate(1.2) contrast(1.1) brightness(1.03);
  clip-path: ellipse(0 0 at 50% 50%);
  animation: threadPatch 1550ms ease-out forwards;
}
.thread::before {
  inset: 12px; border-radius: inherit;
  border: 2px solid transparent;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(21, 154, 156, 0.72), rgba(236, 119, 95, 0.62)) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  animation: threadLoop 1550ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.thread::after {
  left: 15%; top: 52%; width: 70%; height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.96), rgba(21, 154, 156, 0.84), transparent);
  transform-origin: left center;
  animation: threadLine 1550ms ease-out forwards;
}

/* halo */
.halo .patch {
  filter: saturate(1.18) brightness(1.08);
  clip-path: circle(0 at 50% 50%);
  animation: haloPatch 1480ms ease-out forwards;
}
.halo::before {
  inset: -16px; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 33%, rgba(255, 255, 255, 0.72) 34% 35%, transparent 36% 46%, rgba(21, 154, 156, 0.42) 47% 48%, transparent 49% 57%, rgba(236, 119, 95, 0.36) 58% 59%, transparent 60%),
    conic-gradient(from 0deg, transparent, rgba(255, 255, 255, 0.46), transparent 24%, rgba(213, 161, 30, 0.34), transparent 58%, rgba(123, 105, 201, 0.32), transparent);
  mix-blend-mode: screen;
  animation: haloRings 1480ms ease-out forwards;
}
.halo::after {
  inset: 22%; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.26);
  animation: haloCore 1480ms ease-out forwards;
}

/* grain */
.grain .patch {
  filter: saturate(1.1) contrast(1.16) brightness(1.05);
  clip-path: circle(46% at 50% 50%);
  animation: grainPatch 1650ms ease-out forwards;
}
.grain::before {
  inset: 0; border-radius: inherit;
  background:
    radial-gradient(circle at 20% 22%, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 35% 70%, rgba(21, 154, 156, 0.72) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 36%, rgba(236, 119, 95, 0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 64% 78%, rgba(213, 161, 30, 0.7) 0 1px, transparent 2px),
    repeating-radial-gradient(circle, rgba(255, 255, 255, 0.34) 0 1px, transparent 1px 8px);
  mix-blend-mode: screen;
  animation: grainCloud 1650ms ease-out forwards;
}
.grain::after {
  inset: 24px;
  border-radius: 44% 56% 48% 52% / 50% 43% 57% 50%;
  border: 1px dotted rgba(255, 255, 255, 0.78);
  animation: grainBoundary 1650ms ease-out forwards;
}

/* stardust */
.stardust .patch {
  filter: saturate(1.26) contrast(1.06) brightness(1.12) sepia(0.08);
  clip-path: circle(0 at 50% 50%);
  animation: stardustPatch 1720ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.stardust::before {
  inset: -18px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 246, 190, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 33%, rgba(248, 214, 107, 0.92) 0 2px, transparent 3px),
    radial-gradient(circle at 74% 74%, rgba(213, 161, 30, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 24% 68%, rgba(255, 242, 166, 0.88) 0 2px, transparent 3px),
    radial-gradient(circle at 24% 28%, rgba(248, 214, 107, 0.9) 0 1px, transparent 3px),
    conic-gradient(from 0deg, transparent, rgba(255, 236, 151, 0.42), transparent 28%, rgba(213, 161, 30, 0.32), transparent 62%, rgba(255, 248, 217, 0.38), transparent);
  mix-blend-mode: screen;
  animation: stardustOrbit 1720ms ease-out forwards;
}
.stardust::after {
  left: 50%; top: 50%; width: 72%; height: 72%;
  border-radius: 50%;
  border: 1px solid rgba(255, 236, 151, 0.88);
  box-shadow: 0 0 18px rgba(248, 214, 107, 0.54), inset 0 0 24px rgba(255, 248, 217, 0.28);
  transform: translate(-50%, -50%);
  animation: stardustHalo 1720ms ease-out forwards;
}
.stardust .spark {
  width: 4px; height: 4px; border-radius: 1px;
  background: #fff4ad;
  box-shadow: 0 0 9px rgba(255, 244, 173, 0.95), 0 0 20px rgba(213, 161, 30, 0.7);
  animation-name: starDustFly;
}
.stardust .spark:nth-child(4n) {
  width: 7px; height: 7px;
  clip-path: polygon(50% 0, 60% 38%, 100% 50%, 60% 62%, 50% 100%, 40% 62%, 0 50%, 40% 38%);
}

/* portal */
.portal { border-radius: 50%; perspective: 620px; }
.portal .patch {
  filter: saturate(1.24) contrast(1.06) brightness(1.03) sepia(0.08) hue-rotate(2deg);
  clip-path: ellipse(0 0 at 50% 50%);
  animation: portalPatch 3400ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.portal::before {
  inset: -10px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 17%, rgba(204, 249, 255, 0.68) 0 1px, transparent 3px),
    radial-gradient(circle at 82% 43%, rgba(117, 230, 242, 0.5) 0 1px, transparent 3px),
    radial-gradient(circle at 28% 74%, rgba(255, 132, 180, 0.38) 0 1px, transparent 3px),
    radial-gradient(circle at 50% 50%, rgba(7, 13, 35, 0.18) 0 18%, transparent 19% 31%, rgba(126, 238, 247, 0.42) 32% 34%, rgba(255, 255, 255, 0.34) 35% 36%, transparent 37% 52%),
    radial-gradient(circle at 50% 50%, transparent 0 42%, rgba(126, 238, 247, 0.18) 43% 47%, transparent 48% 62%);
  mix-blend-mode: screen;
  transform: rotate(0deg);
  animation: portalRim 3400ms ease-out forwards;
}
.portal::after {
  left: 50%; top: 50%; width: 58%; height: 58%;
  border-radius: 50%;
  border: 1px solid rgba(204, 249, 255, 0.58);
  background:
    radial-gradient(circle at 54% 48%, rgba(1, 4, 16, 0.68) 0 13%, rgba(5, 12, 31, 0.38) 14% 22%, transparent 23%),
    radial-gradient(circle at 50% 50%, transparent 0 26%, rgba(126, 238, 247, 0.12) 27% 34%, transparent 35% 45%, rgba(239, 67, 119, 0.08) 46% 51%, transparent 52%),
    repeating-radial-gradient(circle at 50% 50%, rgba(204, 249, 255, 0.06) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, rgba(20, 77, 194, 0.14), rgba(117, 230, 242, 0.16), rgba(239, 67, 119, 0.1));
  box-shadow:
    0 0 14px rgba(126, 238, 247, 0.28),
    0 0 28px rgba(20, 77, 194, 0.2),
    inset 0 0 20px rgba(1, 4, 16, 0.48),
    inset 0 0 34px rgba(126, 238, 247, 0.14);
  transform: translate(-50%, -50%);
  animation: portalGate 3400ms ease-out forwards;
}
.portal .spark {
  width: 4px; height: 4px; border-radius: 1px;
  background: #ccf9ff;
  box-shadow: 0 0 7px rgba(204, 249, 255, 0.68), 0 0 14px rgba(117, 230, 242, 0.34);
  animation-name: portalParticle;
  animation-duration: 3000ms;
}
.portal .spark:nth-child(3n) {
  background: #ff84b4; border-radius: 50%;
  box-shadow: 0 0 7px rgba(255, 132, 180, 0.46), 0 0 15px rgba(239, 67, 119, 0.25);
}
.portal .spark:nth-child(5n) {
  width: 6px; height: 6px;
  clip-path: polygon(50% 0, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0 50%, 39% 35%);
}

/* wormhole */
.wormhole { border-radius: 50%; }
.wormhole .patch {
  filter: saturate(1.48) contrast(1.12) brightness(0.92) hue-rotate(7deg);
  clip-path: circle(0 at 50% 50%);
  animation: wormholePatch 3400ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.wormhole::before {
  inset: -26px; border-radius: 50%;
  background:
    radial-gradient(circle at 58% 48%, rgba(1, 4, 16, 0.86) 0 8%, rgba(5, 12, 39, 0.7) 9% 14%, transparent 15%),
    conic-gradient(from -28deg, rgba(7, 15, 60, 0.46) 0 7%, rgba(40, 130, 238, 0.54) 8% 18%, rgba(110, 238, 248, 0.75) 19% 31%, rgba(220, 252, 255, 0.68) 32% 38%, rgba(20, 44, 150, 0.52) 39% 52%, rgba(232, 53, 110, 0.62) 53% 65%, rgba(87, 40, 160, 0.4) 66% 75%, rgba(75, 220, 240, 0.58) 76% 89%, rgba(7, 15, 60, 0.48) 90% 100%),
    radial-gradient(circle at 50% 50%, transparent 0 28%, rgba(93, 226, 244, 0.28) 29% 34%, transparent 35% 48%, rgba(232, 53, 110, 0.18) 49% 54%, transparent 55% 70%);
  mix-blend-mode: screen;
  filter: blur(0.4px);
  animation: wormholeTunnel 3400ms ease-out forwards;
}
.wormhole::after {
  left: 50%; top: 50%; width: 70%; height: 70%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 62% 49%, rgba(0, 2, 12, 0.95) 0 11%, rgba(5, 12, 39, 0.72) 12% 18%, transparent 19%),
    conic-gradient(from 35deg, rgba(0, 8, 44, 0.7) 0 10%, rgba(84, 224, 242, 0.62) 11% 24%, rgba(235, 252, 255, 0.58) 25% 30%, rgba(12, 32, 114, 0.68) 31% 48%, rgba(239, 67, 119, 0.58) 49% 63%, rgba(54, 52, 150, 0.54) 64% 78%, rgba(114, 229, 242, 0.5) 79% 90%, rgba(0, 8, 44, 0.72) 91% 100%),
    repeating-radial-gradient(circle at 52% 50%, rgba(204, 249, 255, 0.16) 0 1px, transparent 1px 8px);
  box-shadow:
    0 0 22px rgba(84, 224, 242, 0.58),
    0 0 52px rgba(20, 77, 194, 0.34),
    inset 0 0 28px rgba(0, 2, 12, 0.78),
    inset 0 0 46px rgba(84, 224, 242, 0.22);
  transform: translate(-50%, -50%);
  animation: wormholeCore 3400ms ease-out forwards;
}
.wormhole .spark {
  width: 3px; height: 8px; border-radius: 999px;
  background: rgba(222, 252, 255, 0.9);
  box-shadow: 0 0 8px rgba(204, 249, 255, 0.78), 0 0 20px rgba(84, 224, 242, 0.46);
  animation-name: wormholeStar;
  animation-duration: 3000ms;
}
.wormhole .spark:nth-child(3n) {
  background: rgba(255, 117, 165, 0.82);
  box-shadow: 0 0 8px rgba(255, 117, 165, 0.55), 0 0 18px rgba(239, 67, 119, 0.38);
}

/* thought */
.thought {
  border-radius: 50%;
  mix-blend-mode: normal;
  filter:
    drop-shadow(0 2px 7px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 18px rgba(178, 255, 235, 0.28));
}
.thought .patch {
  filter: saturate(1.2) contrast(1.04) brightness(1.08);
  clip-path: circle(0 at 50% 50%);
  animation: thoughtPatch 3400ms ease forwards;
}
.thought-ether {
  position: absolute;
  inset: -30px -34px;
  z-index: 4;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  animation: thoughtEther 3400ms ease forwards;
}
.thought-ether::before,
.thought-ether::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.thought-ether::before {
  width: 88%; height: 72%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.92), transparent 38%),
    radial-gradient(circle at 28% 48%, rgba(255, 255, 255, 0.78), transparent 38%);
  filter: blur(16px);
}
.thought-ether::after {
  width: 84%; height: 58%;
  border-top: 1px solid rgba(255, 255, 255, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.88);
  transform: translate(-50%, -50%) rotate(-4deg);
  animation: thoughtEtherRing 2800ms ease-in-out infinite;
}
.thought .thought-thread {
  position: absolute;
  left: 50%; top: 50%;
  width: 88%; height: 50%;
  border-radius: 999px;
  border-top: 1px solid rgba(255, 255, 255, 1);
  border-left: 1px solid rgba(255, 255, 255, 0.88);
  transform: translate(-50%, -50%) rotate(var(--thread-tilt));
  opacity: 0.82;
  animation: thoughtThread 2200ms ease-in-out infinite;
}
.thought .thread-1 { --thread-tilt: -9deg;  --thread-mid: 5deg;  }
.thought .thread-2 { --thread-tilt: 7deg;   --thread-mid: -4deg; width: 72%; height: 68%; animation-delay: -600ms;  }
.thought .thread-3 { --thread-tilt: 16deg;  --thread-mid: -7deg; width: 96%; height: 82%; animation-delay: -1100ms; }
.thought .thread-4 { --thread-tilt: -18deg; --thread-mid: 8deg;  width: 64%; height: 40%; animation-delay: -1500ms; }
.thought .spark {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 14px rgba(255, 255, 255, 1), 0 0 28px rgba(255, 255, 255, 0.72);
  animation-name: thoughtParticleLift;
  animation-duration: 3200ms;
}

/* Generic spark */
.spark {
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%) rotate(var(--a)) translateX(18px);
  animation: sparkFly 900ms ease-out forwards;
}

/* ─── Zoom depth-bloom effect ────────────────────────────────────────────── */

.zoom-bloom {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--zoom-size);
  height: var(--zoom-size);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
}

.zoom-bloom-well {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(9, 12, 23, 0.18) 0 36%, transparent 37%),
    radial-gradient(circle, transparent 0 42%, rgba(255, 255, 255, 0.72) 43% 44%, transparent 45%),
    radial-gradient(circle, transparent 0 55%, rgba(123, 105, 201, 0.24) 56% 60%, transparent 61%);
  mix-blend-mode: screen;
  opacity: 0;
}

.zoom-bloom-patch {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image: var(--image);
  background-repeat: no-repeat;
  background-size: var(--zoom-stage-w) var(--zoom-stage-h);
  background-position: var(--zoom-bg-x) var(--zoom-bg-y);
  filter: saturate(1.22) contrast(1.08) brightness(0.98);
  opacity: 0;
}

@keyframes zoomWellIntro {
  0%   { opacity: 0;    transform: scale(0.52) rotate(0deg); }
  30%  { opacity: 0.82; }
  100% { opacity: 0.82; transform: scale(1) rotate(27deg); }
}

@keyframes zoomWellOutro {
  0%   { opacity: 0.82; transform: scale(1) rotate(27deg); }
  100% { opacity: 0;    transform: scale(1.32) rotate(90deg); }
}

@keyframes zoomPatchIntro {
  0%   { opacity: 0;   clip-path: circle(0 at 50% 50%);    transform: scale(0.78); }
  100% { opacity: 0.7; clip-path: circle(46% at 50% 50%);  transform: scale(1); }
}

@keyframes zoomPatchOutro {
  0%   { opacity: 0.7; clip-path: circle(46% at 50% 50%); transform: scale(1); }
  100% { opacity: 0;   clip-path: circle(20% at 50% 50%); transform: scale(0.9); }
}

/* ─── Keyframes ──────────────────────────────────────────────────────────── */

@keyframes pointerBreathe {
  0%, 100% { transform: scale(0.94); opacity: 0.68; }
  50%       { transform: scale(1.05); opacity: 1; }
}

@keyframes brushTrail {
  0%, 100% { transform: translate(0, 0) scale(0.72); opacity: 0.34; }
  50%       { transform: translate(-3px, 4px) scale(1); opacity: 0.95; }
}

@keyframes pointerDust {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--orbit)) scale(0.72) rotate(0deg); opacity: 0.55; }
  50%       { transform: translate(-50%, -50%) rotate(calc(var(--angle) + 52deg)) translateX(calc(var(--orbit) - 7px)) scale(1.08) rotate(140deg); opacity: 1; }
}

@keyframes blobPointer {
  0%, 100% { border-radius: 43% 57% 54% 46% / 54% 42% 58% 46%; transform: scale(0.96) rotate(0deg); }
  50%       { border-radius: 55% 45% 44% 56% / 42% 58% 42% 58%; transform: scale(1.05) rotate(8deg); }
}

@keyframes thoughtPointerBreathe {
  0%, 100% { opacity: 0.72; transform: scale(0.92) translateY(2px); }
  50%       { opacity: 1;    transform: scale(1.05) translateY(-3px); }
}

@keyframes thoughtPointerRing {
  0%, 100% { opacity: 0.36; transform: rotate(-5deg) scaleX(0.9); }
  50%       { opacity: 0.78; transform: rotate(6deg) scaleX(1.08); }
}

@keyframes pointerThoughtThread {
  0%, 100% { opacity: 0.24; transform: translate(-50%, -50%) rotate(var(--thread-tilt)) scaleX(0.9) translateY(4px); }
  48%       { opacity: 0.7;  transform: translate(-50%, -50%) rotate(var(--thread-mid)) scaleX(1.08) translateY(-4px); }
}

@keyframes thoughtPointerParticle {
  0%, 100% { opacity: 0.26; transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--orbit)) scale(0.6); filter: blur(2px); }
  50%       { opacity: 0.9;  transform: translate(-50%, -50%) rotate(calc(var(--angle) + 42deg)) translateX(calc(var(--orbit) - 5px)) scale(1.05); filter: blur(0); }
}

@keyframes irisPatch {
  0%       { opacity: 0; clip-path: circle(0 at 50% 50%); transform: scale(0.96); }
  22%, 70% { opacity: 0.72; clip-path: circle(46% at 50% 50%); transform: scale(1.02); }
  100%     { opacity: 0; clip-path: circle(52% at 50% 50%); transform: scale(1); }
}
@keyframes irisRing {
  0%   { opacity: 0; transform: scale(0.5); }
  28%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.34); }
}
@keyframes irisSpin {
  0%   { opacity: 0; transform: scale(0.4) rotate(0deg); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.75) rotate(180deg); }
}

@keyframes loomPatch {
  0%       { opacity: 0; -webkit-mask-position: 140% 0; mask-position: 140% 0; }
  20%, 72% { opacity: 0.78; }
  100%     { opacity: 0; -webkit-mask-position: -45% 0; mask-position: -45% 0; }
}
@keyframes loomGrid {
  0%       { opacity: 0; clip-path: inset(0 100% 0 0); }
  24%, 66% { opacity: 0.9; clip-path: inset(0 0 0 0); }
  100%     { opacity: 0; clip-path: inset(0 0 0 100%); }
}
@keyframes loomScanner {
  0%   { opacity: 0; transform: translateX(0); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(var(--size)); }
}

@keyframes petalPatch {
  0%       { opacity: 0; clip-path: polygon(50% 50%, 56% 42%, 68% 50%, 56% 58%); }
  30%, 72% { opacity: 0.68; clip-path: polygon(50% 2%, 68% 30%, 98% 50%, 68% 70%, 50% 98%, 32% 70%, 2% 50%, 32% 30%); }
  100%     { opacity: 0; clip-path: polygon(50% 0, 72% 26%, 100% 50%, 72% 74%, 50% 100%, 28% 74%, 0 50%, 28% 26%); }
}
@keyframes petalRing {
  0%   { opacity: 0; transform: scale(0.42) rotate(0deg); }
  26%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.28) rotate(95deg); }
}
@keyframes petalCore {
  0%   { opacity: 0; transform: scale(0.4) rotate(0deg); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: scale(2.1) rotate(-70deg); }
}

@keyframes pulsePatch {
  0%       { opacity: 0; transform: scale(0.9); }
  18%, 62% { opacity: 0.52; transform: scale(1.01); }
  100%     { opacity: 0; transform: scale(1.08); }
}
@keyframes pulseRing {
  0%   { opacity: 0; transform: scale(0.55); }
  22%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.5); }
}
@keyframes pulseDash {
  0%   { opacity: 0; transform: scale(0.6) rotate(0deg); }
  35%  { opacity: 0.75; }
  100% { opacity: 0; transform: scale(1.55) rotate(120deg); }
}

@keyframes prismPatch {
  0%       { opacity: 0; transform: scale(0.74) rotate(-10deg) skew(-3deg, 2deg); }
  24%, 70% { opacity: 0.66; transform: scale(1.02) rotate(0deg) skew(0deg, 0deg); }
  100%     { opacity: 0; transform: scale(1.1) rotate(8deg); }
}
@keyframes prismShell {
  0%   { opacity: 0; transform: scale(0.62) rotate(-18deg); }
  28%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.24) rotate(18deg); }
}
@keyframes prismGlint {
  0%   { opacity: 0; transform: translateX(-44px) rotate(28deg) scaleY(0.55); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(44px) rotate(28deg) scaleY(1.1); }
}

@keyframes threadPatch {
  0%       { opacity: 0; clip-path: ellipse(0 0 at 50% 50%); }
  28%, 72% { opacity: 0.62; clip-path: ellipse(47% 38% at 50% 50%); }
  100%     { opacity: 0; clip-path: ellipse(52% 42% at 50% 50%); }
}
@keyframes threadLoop {
  0%   { opacity: 0; transform: scale(0.55) rotate(-44deg); }
  34%  { opacity: 1; transform: scale(1) rotate(6deg); }
  100% { opacity: 0; transform: scale(1.22) rotate(62deg); }
}
@keyframes threadLine {
  0%       { opacity: 0; transform: scaleX(0) rotate(-28deg); }
  28%, 58% { opacity: 1; transform: scaleX(1) rotate(16deg); }
  100%     { opacity: 0; transform: scaleX(0.34) rotate(54deg); }
}

@keyframes haloPatch {
  0%       { opacity: 0; clip-path: circle(0 at 50% 50%); }
  24%, 76% { opacity: 0.56; clip-path: circle(42% at 50% 50%); }
  100%     { opacity: 0; clip-path: circle(50% at 50% 50%); }
}
@keyframes haloRings {
  0%       { opacity: 0; transform: scale(0.42) rotate(0deg); }
  26%, 66% { opacity: 1; }
  100%     { opacity: 0; transform: scale(1.22) rotate(115deg); }
}
@keyframes haloCore {
  0%   { opacity: 0; transform: scale(0.44); }
  40%  { opacity: 0.86; }
  100% { opacity: 0; transform: scale(1.8); }
}

@keyframes grainPatch {
  0%       { opacity: 0; transform: scale(0.94); }
  24%, 76% { opacity: 0.48; transform: scale(1.01); }
  100%     { opacity: 0; transform: scale(1.04); }
}
@keyframes grainCloud {
  0%       { opacity: 0; transform: scale(1.24) rotate(0deg); filter: blur(5px); }
  30%, 70% { opacity: 1; filter: blur(0); }
  100%     { opacity: 0; transform: scale(0.82) rotate(35deg); filter: blur(2px); }
}
@keyframes grainBoundary {
  0%   { opacity: 0; transform: scale(1.24) rotate(0deg); }
  32%  { opacity: 0.8; }
  100% { opacity: 0; transform: scale(0.82) rotate(-38deg); }
}

@keyframes stardustPatch {
  0%       { opacity: 0; clip-path: circle(0 at 50% 50%); transform: scale(0.92); }
  26%, 72% { opacity: 0.58; clip-path: circle(43% at 50% 50%); transform: scale(1.01); }
  100%     { opacity: 0; clip-path: circle(50% at 50% 50%); transform: scale(1.04); }
}
@keyframes stardustOrbit {
  0%       { opacity: 0; transform: scale(0.42) rotate(-35deg); filter: blur(2px); }
  30%, 70% { opacity: 1; filter: blur(0); }
  100%     { opacity: 0; transform: scale(1.18) rotate(130deg); filter: blur(1px); }
}
@keyframes stardustHalo {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.44) rotate(0deg); }
  34%  { opacity: 0.92; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.82) rotate(80deg); }
}
@keyframes starDustFly {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(92px) scale(0.2) rotate(0deg); }
  28%  { opacity: 1; }
  74%  { opacity: 0.86; transform: translate(-50%, -50%) rotate(var(--a)) translateX(34px) scale(1) rotate(120deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(var(--d)) scale(0.08) rotate(220deg); }
}

@keyframes portalPatch {
  0%   { opacity: 0; clip-path: ellipse(0 0 at 50% 50%); transform: scale(0.82) rotate(-8deg); }
  30%  { opacity: 0.46; clip-path: ellipse(38% 22% at 50% 50%); transform: scale(1.01) rotate(0deg); }
  68%  { opacity: 0.5; clip-path: ellipse(39% 23% at 50% 50%); transform: scale(0.99) rotate(-1deg); }
  86%  { opacity: 0.22; clip-path: ellipse(24% 13% at 50% 50%); transform: scale(0.96) rotate(2deg); }
  100% { opacity: 0; clip-path: ellipse(0 0 at 50% 50%); transform: scale(0.82) rotate(10deg); }
}
@keyframes portalRim {
  0%   { opacity: 0; transform: scale(0.28) rotate(-12deg); filter: blur(3px); }
  28%  { opacity: 0.56; transform: scale(0.98) rotate(34deg); filter: blur(0); }
  68%  { opacity: 0.48; transform: scale(0.94) rotate(84deg); }
  86%  { opacity: 0.2; transform: scale(0.5) rotate(118deg); }
  100% { opacity: 0; transform: scale(0.18) rotate(140deg); filter: blur(2px); }
}
@keyframes portalGate {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.18) rotate(-24deg); }
  28%  { opacity: 0.5; transform: translate(-50%, -50%) scale(0.96) rotate(28deg); }
  68%  { opacity: 0.46; transform: translate(-50%, -50%) scale(0.9) rotate(86deg); }
  86%  { opacity: 0.18; transform: translate(-50%, -50%) scale(0.48) rotate(126deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.14) rotate(150deg); }
}
@keyframes portalParticle {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(94px) scale(0.12) rotate(0deg); }
  28%  { opacity: 0.58; }
  70%  { opacity: 0.64; transform: translate(-50%, -50%) rotate(var(--a)) translateX(36px) scale(0.72) rotate(120deg); }
  88%  { opacity: 0.28; transform: translate(-50%, -50%) rotate(var(--a)) translateX(18px) scale(0.42) rotate(180deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(8px) scale(0.08) rotate(220deg); }
}

@keyframes wormholePatch {
  0%   { opacity: 0; clip-path: circle(0 at 50% 50%); transform: scale(0.7) rotate(-18deg); }
  24%  { opacity: 0.62; clip-path: circle(42% at 50% 50%); transform: scale(1.04) rotate(0deg); }
  70%  { opacity: 0.66; clip-path: circle(44% at 50% 50%); transform: scale(1) rotate(-3deg); }
  88%  { opacity: 0.24; clip-path: circle(24% at 50% 50%); transform: scale(0.84) rotate(6deg); }
  100% { opacity: 0; clip-path: circle(0 at 50% 50%); transform: scale(0.68) rotate(12deg); }
}
@keyframes wormholeTunnel {
  0%   { opacity: 0; transform: scale(0.18) rotate(-70deg); filter: blur(5px); }
  24%  { opacity: 0.96; transform: scale(1.04) rotate(10deg); filter: blur(0.4px); }
  70%  { opacity: 0.9; transform: scale(0.98) rotate(210deg); }
  88%  { opacity: 0.34; transform: scale(0.5) rotate(286deg); filter: blur(1px); }
  100% { opacity: 0; transform: scale(0.16) rotate(330deg); filter: blur(4px); }
}
@keyframes wormholeCore {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.12) rotate(-90deg); }
  24%  { opacity: 0.94; transform: translate(-50%, -50%) scale(1) rotate(20deg); }
  70%  { opacity: 0.9; transform: translate(-50%, -50%) scale(0.94) rotate(260deg); }
  88%  { opacity: 0.28; transform: translate(-50%, -50%) scale(0.42) rotate(340deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.1) rotate(390deg); }
}
@keyframes wormholeStar {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(130px) scale(0.1) rotate(80deg); }
  18%  { opacity: 0.92; }
  72%  { opacity: 0.9; transform: translate(-50%, -50%) rotate(var(--a)) translateX(42px) scale(1) rotate(160deg); }
  90%  { opacity: 0.34; transform: translate(-50%, -50%) rotate(var(--a)) translateX(20px) scale(0.55) rotate(230deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(8px) scale(0.08) rotate(300deg); }
}

@keyframes thoughtPatch {
  0%        { opacity: 0; clip-path: circle(0 at 50% 50%); filter: blur(10px) saturate(1.2) brightness(1.08); transform: scale(0.94); }
  12%, 100% { opacity: 0.78; clip-path: circle(42% at 50% 50%); filter: blur(0) saturate(1.2) brightness(1.08); transform: scale(1); }
}
@keyframes thoughtEther {
  0%        { opacity: 0; transform: translateY(8px) scale(0.84); filter: blur(10px); }
  10%, 100% { opacity: 0.92; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes thoughtEtherRing {
  0%, 100% { opacity: 0.38; transform: translate(-50%, -50%) rotate(-4deg) scaleX(0.94); }
  50%      { opacity: 0.72; transform: translate(-50%, -50%) rotate(6deg) scaleX(1.05); }
}
@keyframes thoughtThread {
  0%, 100% { opacity: 0.22; transform: translate(-50%, -50%) rotate(var(--thread-tilt)) scaleX(0.92) translateY(4px); }
  48%      { opacity: 0.66; transform: translate(-50%, -50%) rotate(var(--thread-mid)) scaleX(1.08) translateY(-4px); }
}
@keyframes thoughtParticleLift {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(18px) scale(0.4); filter: blur(5px); }
  18%  { opacity: 0.88; }
  68%  { opacity: 0.48; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(var(--d)) translateY(-40px) scale(1.2); filter: blur(9px); }
}

@keyframes sparkFly {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(18px) scale(0.4); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateX(var(--d)) scale(0.1); }
}

/* ─── Topbar & draw tool ─────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  z-index: 200;
  top: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scene-pill-wrapper {
  position: relative;
}

.scene-pill-wrapper::before {
  position: absolute;
  z-index: -1;
  inset: -8px -14px -6px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 18% 50%, rgba(255, 255, 255, 0.28), transparent 62%),
    linear-gradient(90deg, rgba(238, 239, 236, 0.18), rgba(184, 190, 198, 0.08));
  filter: blur(0.2px);
  backdrop-filter: blur(12px) saturate(112%);
  content: "";
}

.scene-pill-wrapper::after {
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 4px;
  height: 1px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(232, 205, 141, 0.88), rgba(222, 226, 230, 0.72), rgba(232, 205, 141, 0));
  content: "";
}

.topbar h1 {
  margin: 0;
  padding: 8px 11px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(220px, calc(50vw - 90px));
  color: rgba(248, 248, 247, 0.94);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.15vw, 17px);
  font-weight: 500;
  line-height: 1.05;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(19, 24, 31, 0.42);
}

.scene-tooltip {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  padding: 8px 20px;
  border: 1px solid rgba(239, 255, 249, 0.28);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.46), transparent 72%),
    linear-gradient(135deg, rgba(245, 251, 250, 0.48), rgba(179, 231, 222, 0.18));
  box-shadow:
    0 15px 42px rgba(11, 28, 34, 0.18),
    0 0 28px rgba(173, 255, 235, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  color: rgba(247, 255, 252, 0.88);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 1px 10px rgba(7, 23, 27, 0.42), 0 0 16px rgba(186, 255, 238, 0.2);
  backdrop-filter: blur(18px) saturate(118%);
  pointer-events: none;
  opacity: 0;
  filter: blur(7px);
  transition: opacity 280ms ease, filter 280ms ease;
  z-index: 300;
}

.scene-tooltip.visible,
.scene-pill-wrapper:hover .scene-tooltip {
  opacity: 1;
  filter: blur(0);
}

.topbar-pill {
  position: fixed;
  z-index: 200;
  top: 16px;
  right: 18px;
  margin: 0;
  padding: 8px 11px 10px;
  border: none;
  background: transparent;
  color: rgba(248, 248, 247, 0.94);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.15vw, 17px);
  font-weight: 500;
  line-height: 1.05;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(19, 24, 31, 0.42);
  cursor: pointer;
}

.topbar-pill::before {
  position: absolute;
  z-index: -1;
  inset: -8px -14px -6px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 18% 50%, rgba(255, 255, 255, 0.28), transparent 62%),
    linear-gradient(90deg, rgba(238, 239, 236, 0.18), rgba(184, 190, 198, 0.08));
  filter: blur(0.2px);
  backdrop-filter: blur(12px) saturate(112%);
  content: "";
}

.topbar-pill::after {
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 4px;
  height: 1px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(232, 205, 141, 0.88), rgba(222, 226, 230, 0.72), rgba(232, 205, 141, 0));
  content: "";
}

.tool-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(233, 235, 235, 0.42);
  border-radius: 999px;
  background: rgba(245, 247, 248, 0.26);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.14);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tool-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.42);
}

.tool-button.is-locked {
  filter: grayscale(1);
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 0 0 4px rgba(235, 236, 238, 0.18), 0 10px 24px rgba(17, 24, 39, 0.18);
}

.tool-button svg {
  width: 21px;
  height: 21px;
}

#newImageTool {
  position: fixed;
  z-index: 200;
  bottom: 24px;
  left: 18px;
  display: none;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

@media (pointer: coarse) {
  #newImageTool {
    display: grid;
  }
}

/* ─── Inpaint canvas ─────────────────────────────────────────────────────── */

#inpaintCanvas {
  position: fixed;
  z-index: 150;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  pointer-events: none;
}

body.is-drawing #inpaintCanvas {
  pointer-events: auto;
  cursor: crosshair;
}

/* ─── Chat panel ─────────────────────────────────────────────────────────── */

.chat-panel {
  position: fixed;
  z-index: 200;
  width: min(520px, calc(100vw - 28px));
  padding: 15px;
  border: 1px solid rgba(236, 238, 240, 0.5);
  border-radius: 16px;
  background: rgba(247, 248, 249, 0.66);
  box-shadow: 0 18px 54px rgba(26, 31, 38, 0.16);
  backdrop-filter: blur(18px) saturate(116%);
}

.chat-panel__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(44, 44, 46, 0.45);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-panel__close:hover {
  background: rgba(0, 0, 0, 0.07);
  color: rgba(44, 44, 46, 0.8);
}

.chat-panel__label {
  margin: 0 0 10px;
  color: rgba(38, 40, 43, 0.66);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.18vw, 15px);
  font-weight: 450;
}

.chat-panel textarea {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid rgba(176, 181, 187, 0.44);
  border-radius: 12px;
  outline: 0;
  background: rgba(255, 255, 255, 0.48);
  color: rgba(29, 31, 34, 0.82);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.12vw, 15px);
  line-height: 1.38;
}

.chat-panel textarea::placeholder { color: rgba(62, 64, 68, 0.5); }

.chat-panel textarea:focus {
  border-color: rgba(122, 132, 145, 0.56);
  box-shadow: 0 0 0 3px rgba(130, 142, 158, 0.14);
}

.chat-panel__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.chat-panel button {
  min-width: 82px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  cursor: pointer;
  font-size: clamp(12px, 1vw, 14px);
  font-weight: 450;
  white-space: nowrap;
}

.chat-panel button:disabled { cursor: default; opacity: 0.58; }

.chat-panel .secondary {
  border: 1px solid rgba(176, 181, 187, 0.52);
  background: rgba(255, 255, 255, 0.34);
  color: rgba(45, 48, 52, 0.72);
}

.chat-panel .primary {
  border: 1px solid rgba(24, 26, 28, 0.82);
  background: rgba(25, 26, 28, 0.88);
  color: rgba(255, 255, 255, 0.92);
}

/* ─── Inpaint panel textarea — transparent style matching global edit ───── */

#inpaintPanel textarea {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: rgba(20, 23, 27, 0.78);
  font-size: clamp(14px, 1.05vw, 20px);
}

#inpaintPanel textarea::placeholder {
  color: rgba(22, 24, 28, 0.42);
}

#inpaintPanel textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

/* ─── New image panel (global edit) ─────────────────────────────────────── */

.global-edit-panel {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 30px;
  width: min(68vw, 1180px);
  min-height: 156px;
  padding: 18px 22px 17px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 26px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.42), rgba(248, 247, 242, 0.28)),
    radial-gradient(circle at 52% 20%, rgba(228, 214, 186, 0.14), transparent 38%);
  box-shadow:
    0 22px 86px rgba(28, 31, 34, 0.11),
    0 0 48px rgba(255, 255, 255, 0.28);
  transform: translateX(-50%);
  backdrop-filter: blur(28px) saturate(116%);
}

.global-edit-panel__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(44, 44, 46, 0.45);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: unset;
  min-height: unset;
}

.global-edit-panel__close:hover {
  background: rgba(0, 0, 0, 0.07);
  color: rgba(44, 44, 46, 0.8);
}

.global-edit-panel__hint {
  margin: 0 0 12px;
  color: rgba(70, 72, 75, 0.58);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 450;
}

.global-edit-panel__hint span {
  display: inline-flex;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  border-radius: 999px;
  background: rgba(212, 212, 208, 0.46);
  color: rgba(44, 44, 46, 0.72);
  font-weight: 560;
}

.global-edit-panel textarea {
  width: 100%;
  min-height: 76px;
  resize: none;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: rgba(20, 23, 27, 0.78);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(14px, 1.05vw, 20px);
  line-height: 1.28;
}

.global-edit-panel textarea::placeholder {
  color: rgba(22, 24, 28, 0.42);
}

.global-edit-panel__footer {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 16px;
}

.global-edit-panel__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.global-edit-panel button {
  min-width: 92px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 560;
}

.global-edit-panel button:disabled {
  cursor: default;
  opacity: 0.58;
}

.global-edit-panel .secondary {
  border: 1px solid rgba(176, 181, 187, 0.52);
  background: rgba(255, 255, 255, 0.22);
  color: rgba(45, 48, 52, 0.72);
}

.global-edit-panel .primary {
  border: 1px solid rgba(24, 26, 28, 0.82);
  background: rgba(25, 26, 28, 0.78);
  color: rgba(255, 255, 255, 0.92);
}

/* ─── Drawing hint ───────────────────────────────────────────────────────── */

.hint {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  padding: 9px 20px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 18% 50%, rgba(255, 255, 255, 0.22), transparent 62%),
    linear-gradient(90deg, rgba(238, 239, 236, 0.14), rgba(184, 190, 198, 0.06));
  backdrop-filter: blur(12px) saturate(112%);
  color: rgba(248, 248, 247, 0.88);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.1vw, 15px);
  font-weight: 500;
  text-shadow: 0 1px 8px rgba(19, 24, 31, 0.42);
  white-space: nowrap;
  pointer-events: none;
}

/* ─── AI Interpretation Popup ────────────────────────────────────────────── */

#aiToast {
  display: none;
  position: fixed;
  width: min(580px, calc(100vw - 32px));
  padding: 8px 20px;
  border: 1px solid rgba(239, 255, 249, 0.28);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.46), transparent 72%),
    linear-gradient(135deg, rgba(245, 251, 250, 0.48), rgba(179, 231, 222, 0.18));
  box-shadow:
    0 15px 42px rgba(11, 28, 34, 0.18),
    0 0 28px rgba(173, 255, 235, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  color: rgba(247, 255, 252, 0.88);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 18px));
  text-align: center;
  text-shadow: 0 1px 10px rgba(7, 23, 27, 0.42), 0 0 16px rgba(186, 255, 238, 0.2);
  backdrop-filter: blur(18px) saturate(118%);
  z-index: 99999;
  overflow: visible;
  opacity: 0;
  filter: blur(7px);
  transition: opacity 280ms ease, filter 280ms ease;
}

#aiToast::before,
#aiToast::after {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  pointer-events: none;
  content: "";
}

#aiToast::before {
  z-index: -1;
  width: calc(100% + 34px);
  height: calc(100% + 28px);
  border-top: 1px solid rgba(234, 255, 249, 0.42);
  border-bottom: 1px solid rgba(177, 245, 231, 0.18);
  transform: translate(-50%, -50%) rotate(-4deg);
  animation: areaDescriptionRing 1900ms ease-in-out infinite;
}

#aiToast::after {
  z-index: -2;
  width: calc(100% + 62px);
  height: calc(100% + 48px);
  background:
    radial-gradient(ellipse at 48% 50%, rgba(180, 255, 236, 0.18), transparent 58%),
    radial-gradient(ellipse at 30% 48%, rgba(255, 255, 255, 0.11), transparent 48%);
  filter: blur(13px);
  transform: translate(-50%, -50%);
  animation: areaDescriptionBreathe 1700ms ease-in-out infinite;
}

#aiToast.visible {
  opacity: 1;
  filter: blur(0);
}

#aiToast.hiding {
  opacity: 0;
  transform: translate(-50%, calc(-100% - 48px)) scale(1.05);
  filter: blur(13px);
  transition: opacity 600ms ease, transform 600ms ease, filter 600ms ease;
}

@keyframes areaDescriptionRing {
  0%, 100% { opacity: 0.3;  transform: translate(-50%, -50%) rotate(-4deg) scaleX(0.94); }
  50%       { opacity: 0.68; transform: translate(-50%, -50%) rotate(6deg)  scaleX(1.06); }
}

@keyframes areaDescriptionBreathe {
  0%, 100% { opacity: 0.52; transform: translate(-50%, -50%) scale(0.94); }
  50%       { opacity: 0.88; transform: translate(-50%, -50%) scale(1.08); }
}

/* ─── Consent Popup ──────────────────────────────────────────────────────── */

#consentPopup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 260ms ease;
}

#consentPopup:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

#consentPopup.visible {
  opacity: 1;
}

#consentPopupInner {
  position: relative;
  width: min(480px, calc(100vw - 40px));
  padding: 28px 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 26px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.42), rgba(248, 247, 242, 0.28)),
    radial-gradient(circle at 52% 20%, rgba(228, 214, 186, 0.14), transparent 38%);
  box-shadow:
    0 22px 86px rgba(28, 31, 34, 0.11),
    0 0 48px rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(28px) saturate(116%);
  text-align: center;
  transform: scale(0.94);
  opacity: 0;
  transition:
    transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 260ms ease;
}

#consentPopup.visible #consentPopupInner {
  transform: scale(1);
  opacity: 1;
}

#consentPopupMsg {
  margin: 0;
  color: rgba(20, 23, 27, 0.78);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.05vw, 15px);
  font-weight: 450;
  line-height: 1.55;
}

/* ─── Compliance Error Popup ─────────────────────────────────────────────── */

#compliancePopup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 18, 0.32);
  backdrop-filter: blur(6px) saturate(80%);
  opacity: 0;
  transition: opacity 260ms ease;
}

#compliancePopup:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

#compliancePopup.visible {
  opacity: 1;
}

#compliancePopupInner {
  position: relative;
  overflow: visible;
  width: min(520px, calc(100vw - 40px));
  padding: 28px 28px 22px;
  border: 1px solid rgba(239, 255, 249, 0.28);
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.46), transparent 72%),
    linear-gradient(135deg, rgba(245, 251, 250, 0.48), rgba(179, 231, 222, 0.18));
  box-shadow:
    0 15px 42px rgba(11, 28, 34, 0.18),
    0 0 28px rgba(173, 255, 235, 0.20),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px) saturate(118%);
  text-align: center;
  transform: scale(0.92);
  filter: blur(7px);
  opacity: 0;
  transition:
    transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 280ms ease,
    opacity 260ms ease;
}

#compliancePopup.visible #compliancePopupInner {
  transform: scale(1);
  filter: blur(0);
  opacity: 1;
}

#compliancePopupInner::before {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: calc(100% + 34px);
  height: calc(100% + 28px);
  border-radius: 999px;
  border-top: 1px solid rgba(234, 255, 249, 0.42);
  border-bottom: 1px solid rgba(177, 245, 231, 0.18);
  transform: translate(-50%, -50%) rotate(-4deg);
  animation: areaDescriptionRing 1900ms ease-in-out infinite;
  content: "";
  pointer-events: none;
}

#compliancePopupInner::after {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -2;
  width: calc(100% + 62px);
  height: calc(100% + 48px);
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 48% 50%, rgba(180, 255, 236, 0.18), transparent 58%),
    radial-gradient(ellipse at 30% 48%, rgba(255, 255, 255, 0.11), transparent 48%);
  filter: blur(13px);
  transform: translate(-50%, -50%);
  animation: areaDescriptionBreathe 1700ms ease-in-out infinite;
  content: "";
  pointer-events: none;
}

#compliancePopup.variant-app #compliancePopupInner {
  border-color: rgba(255, 220, 80, 0.32);
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 240, 140, 0.32), transparent 72%),
    linear-gradient(135deg, rgba(250, 240, 180, 0.42), rgba(220, 190, 80, 0.14));
  box-shadow:
    0 15px 42px rgba(28, 22, 4, 0.20),
    0 0 28px rgba(255, 220, 60, 0.18),
    inset 0 0 0 1px rgba(255, 230, 100, 0.16);
}

#compliancePopup.variant-app #compliancePopupInner::before {
  border-top-color: rgba(255, 240, 160, 0.42);
  border-bottom-color: rgba(230, 205, 90, 0.18);
}

#compliancePopup.variant-app #compliancePopupInner::after {
  background:
    radial-gradient(ellipse at 48% 50%, rgba(255, 230, 100, 0.22), transparent 58%),
    radial-gradient(ellipse at 30% 48%, rgba(255, 245, 180, 0.14), transparent 48%);
}

#compliancePopup.variant-oxigen #compliancePopupInner {
  border-color: rgba(255, 140, 120, 0.32);
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 130, 100, 0.30), transparent 72%),
    linear-gradient(135deg, rgba(255, 100, 80, 0.22), rgba(200, 60, 40, 0.10));
  box-shadow:
    0 15px 42px rgba(30, 8, 4, 0.26),
    0 0 32px rgba(255, 100, 60, 0.22),
    inset 0 0 0 1px rgba(255, 120, 80, 0.18);
}

#compliancePopup.variant-oxigen #compliancePopupInner::before {
  border-top-color: rgba(255, 200, 180, 0.42);
  border-bottom-color: rgba(255, 160, 140, 0.18);
}

#compliancePopup.variant-oxigen #compliancePopupInner::after {
  background:
    radial-gradient(ellipse at 48% 50%, rgba(255, 160, 120, 0.20), transparent 58%),
    radial-gradient(ellipse at 30% 48%, rgba(255, 200, 180, 0.12), transparent 48%);
}

#compliancePopupMsg {
  margin: 0 0 22px;
  color: rgba(247, 255, 252, 0.90);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
  text-shadow: 0 1px 10px rgba(7, 23, 27, 0.42), 0 0 16px rgba(186, 255, 238, 0.20);
}

#compliancePopupClose {
  padding: 7px 26px;
  border: 1px solid rgba(239, 255, 249, 0.30);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  color: rgba(247, 255, 252, 0.86);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, transform 120ms ease;
  text-shadow: 0 1px 8px rgba(7, 23, 27, 0.38);
}

#compliancePopupClose:hover {
  background: rgba(255, 255, 255, 0.20);
  transform: scale(1.04);
}

/* ─── Job Queue Popup ────────────────────────────────────────────────────── */

#jobQueuePopup {
  position: fixed;
  z-index: 200;
  bottom: 20px;
  right: 20px;
  transform: translateY(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
}

#jobQueuePopup.jq-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.jq-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 14px 11px;
  color: rgba(248, 248, 247, 0.94);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(13px, 1.15vw, 17px);
  font-weight: 500;
  text-shadow: 0 1px 8px rgba(19, 24, 31, 0.42);
  white-space: nowrap;
}

.jq-pill::before {
  position: absolute;
  z-index: -1;
  inset: -8px -14px -6px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 18% 50%, rgba(255, 255, 255, 0.28), transparent 62%),
    linear-gradient(90deg, rgba(238, 239, 236, 0.18), rgba(184, 190, 198, 0.08));
  filter: blur(0.2px);
  backdrop-filter: blur(12px) saturate(112%);
  content: "";
}

.jq-pill::after {
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 4px;
  height: 1px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(232, 205, 141, 0.88), rgba(222, 226, 230, 0.72), rgba(232, 205, 141, 0));
  content: "";
}

.jq-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jq-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.72);
  flex-shrink: 0;
  animation: jqDotPulse 1.4s ease-in-out infinite;
}

@keyframes jqDotPulse {
  0%, 100% { opacity: 0.48; transform: scale(0.8); }
  50%       { opacity: 1;    transform: scale(1.18); }
}

.jq-label { /* inherits font from .jq-pill */ }

.jq-time {
  font-size: clamp(11px, 0.96vw, 14px);
  font-weight: 400;
  color: rgba(248, 248, 247, 0.52);
  letter-spacing: 0.01em;
}

.jq-bar-track {
  height: 1.5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  overflow: hidden;
  margin: 0 1px;
}

.jq-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(232, 205, 141, 0.9), rgba(222, 226, 230, 0.8));
  transition: width 1s linear;
}

.jq-error {
  font-size: clamp(11px, 0.9vw, 13px);
  font-weight: 400;
  color: rgba(255, 190, 175, 0.82);
  text-shadow: 0 1px 6px rgba(19, 24, 31, 0.42);
}

#jobQueuePopup.jq-done .jq-dot {
  animation: none;
  background: rgba(186, 255, 238, 0.9);
  box-shadow: 0 0 7px rgba(180, 255, 235, 0.7);
}

#jobQueuePopup.jq-done .jq-bar-fill {
  background: linear-gradient(90deg, rgba(180, 255, 235, 0.8), rgba(222, 226, 230, 0.72));
}

#jobQueuePopup.jq-fail .jq-dot {
  animation: none;
  background: rgba(255, 160, 145, 0.88);
  box-shadow: 0 0 7px rgba(255, 140, 120, 0.6);
}

/* ─── Mobile responsive ──────────────────────────────────────────────────── */

@media (max-width: 680px) {
  .topbar {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    justify-content: flex-start;
    gap: 8px;
  }

  .scene-pill-wrapper {
    flex: 0 1 auto;
  }

  .topbar h1 {
    padding-inline: 11px;
    max-width: min(140px, calc(50vw - 70px));
  }

  .tool-button {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
  }

  .chat-panel {
    padding: 14px;
  }

  .chat-panel textarea {
    min-height: 52px;
    padding: 11px 13px;
  }

  .chat-panel__actions {
    gap: 8px;
    margin-top: 12px;
  }

  .chat-panel button {
    min-width: 0;
    min-height: 40px;
    padding-inline: 14px;
  }

  .global-edit-panel {
    width: calc(100vw - 26px);
    bottom: 12px;
    min-height: 146px;
    padding: 16px;
    border-radius: 22px;
  }

  .global-edit-panel textarea {
    font-size: 14px;
  }

  .global-edit-panel__footer {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .global-edit-panel button {
    min-height: 40px;
    font-size: 13px;
  }

  #aiToast {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }
}

/* ─── iOS auto-zoom prevention ───────────────────────────────────────────── */
/* iOS Safari zooms the entire viewport when a focused input/textarea has     */
/* font-size < 16px. Scoped to touch devices so desktop sizes are unchanged.  */
@supports (-webkit-touch-callout: none) {
  textarea, input {
    font-size: max(16px, 1em) !important;
  }
}
