/* ============================================================
   MINDED ENGINE — Design System
   Dark editorial AI tool. Glassmorphism + purple bloom.
   Tokens map 1:1 to the app's Tailwind @theme variables.
   ============================================================ */

:root {
  /* Brand (locked) */
  --color-brand: #7c3aed;
  --color-brand-dark: #5b21b6;
  --color-brand-light: #a78bfa;

  /* Surfaces (locked) */
  --color-surface: #111111;
  --color-surface-raised: #161622;
  --color-surface-border: #2a2a3a;

  /* Derived editorial neutrals */
  --ink: #ECEAF6;
  --ink-muted: #9a96b0;
  --ink-faint: #65617a;

  /* Glass layers (intensity-driven; overridden by Tweaks) */
  --glass-alpha: 0.55;
  --glass-blur: 22px;
  --bloom: 0.15;

  /* Brand glow shadows */
  --shadow-purple: 0 18px 50px -22px rgba(124, 58, 237, calc(var(--bloom) + 0.18));
  --shadow-card: 0 24px 60px -30px rgba(0, 0, 0, 0.7);

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-surface);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

::selection { background: rgba(124, 58, 237, 0.4); color: #fff; }

/* Ambient page background — deep, layered, alive */
.app-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 12% -10%, rgba(124, 58, 237, calc(var(--bloom) + 0.10)) 0%, transparent 45%),
    radial-gradient(90% 80% at 100% 0%, rgba(91, 33, 182, calc(var(--bloom) + 0.05)) 0%, transparent 50%),
    radial-gradient(120% 120% at 50% 120%, rgba(167, 139, 250, 0.05) 0%, transparent 55%),
    var(--color-surface);
}
.app-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 3px 3px; opacity: 0.5;
}

/* ---- Scrollbars ---- */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.22); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.4); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Reusable glass surface ---- */
.glass {
  background:
    linear-gradient(180deg, rgba(36, 30, 56, var(--glass-alpha)) 0%, rgba(22, 22, 34, calc(var(--glass-alpha) + 0.18)) 100%);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border: 1px solid rgba(124, 58, 237, 0.14);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* small caps label */
.eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-faint); white-space: nowrap;
}

/* Animated brand gradient text */
.brand-gradient-text {
  background: linear-gradient(100deg, #a78bfa 0%, #c4b5fd 25%, #7c3aed 50%, #c4b5fd 75%, #a78bfa 100%);
  background-size: 250% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: brandflow 7s linear infinite;
  padding-right: 0.08em; display: inline-block;
}
@keyframes brandflow { to { background-position: 250% center; } }

/* pulsing active dot */
.pulse-dot {
  width: 7px; height: 7px; border-radius: 99px; background: var(--color-brand-light);
  box-shadow: 0 0 0 0 rgba(167,139,250,0.55);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(167,139,250,0.5); }
  70% { box-shadow: 0 0 0 7px rgba(167,139,250,0); }
  100% { box-shadow: 0 0 0 0 rgba(167,139,250,0); }
}

/* shimmer sweep for the primary button */
@keyframes shimmer {
  0% { transform: translateX(-120%) skewX(-18deg); }
  100% { transform: translateX(220%) skewX(-18deg); }
}

/* output caret + scanlines */
@keyframes caret { 50% { opacity: 0; } }
.scanlines::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.018) 0px, rgba(255,255,255,0.018) 1px, transparent 1px, transparent 3px);
  opacity: 0.6; mix-blend-mode: screen;
}

/* entrance */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: riseIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .brand-gradient-text, .pulse-dot, .rise { animation: none !important; }
}

/* focus-visible polish */
:focus-visible { outline: 2px solid rgba(167,139,250,0.7); outline-offset: 2px; }

/* generic button reset */
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== component styles ===== */

/* ============================================================
   MINDED ENGINE v2 — BEAST MODE motion layer
   Loads AFTER app/styles.css. Adds atmosphere, transitions,
   particle/burst/scan/flip keyframes. Reduced-motion safe.
   ============================================================ */

/* ---- responsive shell (was inline in v1) ---- */
.desktop-sidebar { display: block; }
@media (max-width: 860px) {
  .desktop-sidebar { display: none; }
  .mobile-bar { display: flex !important; }
  .tool-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 861px) { .mobile-bar { display: none !important; } }
@media (max-width: 560px) { .tool-grid { gap: 16px !important; } }

/* ---- core keyframes ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinRev { to { transform: rotate(-360deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes shimmerbg { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- aurora drift (behind everything) ---- */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora::before, .aurora::after {
  content: ""; position: absolute; width: 58vmax; height: 58vmax; border-radius: 50%;
  filter: blur(90px); opacity: calc(var(--bloom) + 0.10); mix-blend-mode: screen;
}
.aurora::before {
  background: radial-gradient(circle, #7c3aed, transparent 65%);
  top: -22vmax; left: -14vmax; animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
  background: radial-gradient(circle, #312e81, transparent 65%);
  bottom: -26vmax; right: -16vmax; animation: drift2 34s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(16vmax, 11vmax) scale(1.18); } }
@keyframes drift2 { to { transform: translate(-13vmax, -9vmax) scale(0.88); } }

/* ---- page transitions ---- */
@keyframes pageIn {
  0% { opacity: 0; transform: translateY(18px) scale(0.992); filter: blur(10px); }
  100% { opacity: 1; transform: none; filter: blur(0); }
}
.page-in { animation: pageIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }

@keyframes irisIn { from { clip-path: circle(0% at 50% 46%); } to { clip-path: circle(141% at 50% 46%); } }
.iris-in { animation: irisIn 0.9s cubic-bezier(0.6, 0, 0.2, 1) both; }

/* staggered children entrance */
.stagger > * { animation: riseIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.40s; }

/* ---- login boot ---- */
@keyframes letterIn {
  0% { opacity: 0; transform: translateY(18px) rotateX(70deg); filter: blur(7px); }
  100% { opacity: 1; transform: none; filter: blur(0); }
}
.letter { display: inline-block; animation: letterIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }

.logo-ring {
  position: absolute; inset: -10px; border-radius: 26px; padding: 2px; pointer-events: none;
  background: conic-gradient(transparent 0deg, rgba(167,139,250,0.9) 80deg, rgba(125,211,252,0.6) 150deg, transparent 260deg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 4.2s linear infinite;
}

@keyframes warpOut { 0% { transform: scale(0); opacity: 0.95; } 100% { transform: scale(320); opacity: 1; } }
.warp-overlay { position: fixed; inset: 0; z-index: 90; pointer-events: none; display: grid; place-items: center; overflow: hidden; }
.warp-overlay::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle, #c4b5fd, #7c3aed 45%, #111111 72%);
  animation: warpOut 0.8s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

/* ---- nav v2 ---- */
.nav2 { transition: color 0.18s, background 0.18s, transform 0.22s cubic-bezier(0.2, 1.2, 0.4, 1); }
.nav2:hover { transform: translateX(3px); }
.nav-ic { transition: transform 0.28s cubic-bezier(0.2, 1.4, 0.4, 1); }
.nav2:hover .nav-ic { transform: scale(1.14) rotate(-3deg); }

/* ---- fields ---- */
.field {
  width: 100%; background: rgba(17,17,17,0.45); color: var(--ink);
  border: 1px solid var(--color-surface-border); border-radius: 12px;
  padding: 13px 14px; font-size: 14px; line-height: 1.5; outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.field:focus {
  border-color: rgba(167,139,250,0.55);
  box-shadow: 0 0 0 4px rgba(124,58,237,0.16), 0 0 28px -6px rgba(124,58,237,0.55);
  background: rgba(22,22,34,0.7);
}
.field::placeholder { color: var(--ink-faint); }

@keyframes chipPop { 0% { transform: scale(1); } 40% { transform: scale(1.13); } 100% { transform: scale(1); } }
.chip-pop { animation: chipPop 0.32s cubic-bezier(0.2, 1.2, 0.4, 1); }

/* ---- charged generate button ---- */
.gen-wrap { position: relative; border-radius: 14px; margin-top: 4px; }
.gen-clip { position: absolute; inset: 0; border-radius: 14px; overflow: hidden; }
.gen-clip::before {
  content: ""; position: absolute; inset: -60%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(167,139,250,0.55) 90deg, rgba(125,211,252,0.45) 170deg, transparent 250deg, transparent 360deg);
  animation: spin 7s linear infinite;
  filter: blur(6px);
}
.gen-clip::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(167,139,250,0.35);
  animation: genBreath 3.4s ease-in-out infinite;
}
@keyframes genBreath { 0%,100% { box-shadow: inset 0 0 0 1px rgba(167,139,250,0.25), 0 0 18px -4px rgba(124,58,237,0.4); } 50% { box-shadow: inset 0 0 0 1px rgba(125,211,252,0.5), 0 0 30px -2px rgba(125,211,252,0.55); } }
.gen-btn {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 2px; width: calc(100% - 4px); padding: 15px 20px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; letter-spacing: 0.01em; color: #fff;
  background: linear-gradient(120deg, #8b5cf6 0%, #7c3aed 45%, #5b21b6 100%);
  box-shadow: 0 10px 30px -14px rgba(124,58,237,0.7), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: box-shadow 0.25s, transform 0.15s;
}
.gen-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 18px 46px -12px rgba(124,58,237,0.9), inset 0 1px 0 rgba(255,255,255,0.26); }
.gen-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.gen-btn:disabled { cursor: wait; opacity: 0.88; }

/* burst particles */
.burst-p {
  position: absolute; border-radius: 99px; pointer-events: none; z-index: 6;
  box-shadow: 0 0 8px rgba(167,139,250,0.8);
  animation: burstFly 0.75s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
@keyframes burstFly {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.2); opacity: 0; }
}

/* ---- output: loading sequence ---- */
.loadbar { height: 3px; border-radius: 99px; background: rgba(124,58,237,0.15); overflow: hidden; }
.loadbar i { display: block; height: 100%; border-radius: 99px; transform-origin: left;
  background: linear-gradient(90deg, #7c3aed, #a78bfa, #7dd3fc);
  animation: loadFill 2.5s cubic-bezier(0.3, 0.6, 0.4, 1) forwards; }
@keyframes loadFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.eq { display: flex; gap: 3px; align-items: flex-end; height: 24px; }
.eq i { width: 3px; border-radius: 2px; flex: 0 0 auto; transform-origin: bottom;
  background: linear-gradient(180deg, #a78bfa, #7c3aed); animation: eqB 1s ease-in-out infinite; }
@keyframes eqB { 0%, 100% { transform: scaleY(0.22); } 50% { transform: scaleY(1); } }

.phase-line { animation: riseIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ---- empty state orbits ---- */
.orbit { position: absolute; inset: -20px; pointer-events: none; animation: spin 9s linear infinite; }
.orbit.rev { inset: -34px; animation: spinRev 15s linear infinite; }
.orbit i { position: absolute; width: 5px; height: 5px; border-radius: 99px; background: #a78bfa; box-shadow: 0 0 9px #a78bfa; }
.orbit.rev i { background: #7dd3fc; box-shadow: 0 0 9px #7dd3fc; width: 4px; height: 4px; }

/* ---- storyboard ---- */
@keyframes flipIn {
  0% { opacity: 0; transform: perspective(800px) rotateX(-14deg) translateY(26px); filter: blur(6px); }
  100% { opacity: 1; transform: none; filter: blur(0); }
}
.flip-in { animation: flipIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) both; }

.frame-scan { position: relative; }
.frame-scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 36%; top: -40%; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(167,139,250,0.18), transparent);
  animation: scanY 3.6s ease-in-out infinite; animation-delay: inherit;
}
@keyframes scanY { 0% { top: -40%; } 55%, 100% { top: 120%; } }

.panel2 { position: relative; overflow: hidden; }
.panel2::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -80%; width: 50%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.07), transparent);
  transform: skewX(-16deg); transition: left 0.6s ease;
}
.panel2:hover::after { left: 135%; }

/* ---- command palette ---- */
.cmdk-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(5,5,10,0.55); backdrop-filter: blur(8px); animation: fadeIn 0.2s both; }
.cmdk {
  position: fixed; left: 50%; top: 15vh; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); z-index: 81;
  animation: cmdkIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
@keyframes cmdkIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%); }
}
.kbd {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted);
  border: 1px solid rgba(124,58,237,0.28); border-bottom-width: 2px; border-radius: 6px;
  padding: 2px 6px; background: rgba(17,17,17,0.5); white-space: nowrap;
}

/* ---- toasts ---- */
.toast { animation: toastIn 0.42s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.92); } }

/* ---- misc ---- */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--badge-c, #7c3aed) 60%, transparent), inset 0 1px 0 rgba(255,255,255,0.06); }
  50% { box-shadow: 0 18px 42px -12px color-mix(in srgb, var(--badge-c, #7c3aed) 95%, transparent), inset 0 1px 0 rgba(255,255,255,0.1); }
}
.tool-badge { animation: glowPulse 4s ease-in-out infinite; }

/* ---- media render (Grok) ---- */
@keyframes renderPan { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.render-live { background-size: 220% 220%; animation: renderPan 8s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .aurora::before, .aurora::after, .gen-clip::before, .logo-ring,
  .orbit, .orbit.rev, .frame-scan::after, .tool-badge, .eq i, .letter,
  .page-in, .iris-in, .stagger > *, .flip-in { animation: none !important; }
  .render-live { animation: none !important; }
  .letter, .page-in, .stagger > *, .flip-in { opacity: 1 !important; filter: none !important; transform: none !important; }
}

/* ============================================================
   STUDIO — Minded Cut + Minded Flows
   ============================================================ */
@keyframes waveLive { 0%,100% { transform: scaleY(0.6); } 50% { transform: scaleY(1.12); } }
.wave-live { transform-origin: center; animation: waveLive 0.8s ease-in-out infinite; }

@keyframes fillShimmer { 0% { opacity: 0.35; } 50% { opacity: 0.75; } 100% { opacity: 0.35; } }
.expand-fill { animation: fillShimmer 2.2s ease-in-out infinite; }

/* flows canvas */
.flow-canvas {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(124,58,237,0.05), transparent 70%),
    linear-gradient(rgba(124,58,237,0.06) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(124,58,237,0.06) 1px, transparent 1px) 0 0 / 26px 26px,
    rgba(8,8,14,0.5);
  cursor: grab;
}
.flow-canvas.panning { cursor: grabbing; }
.flow-node { position: absolute; width: 200px; border-radius: 14px; user-select: none;
  background: linear-gradient(180deg, rgba(30,26,46,0.94), rgba(18,18,28,0.96));
  border: 1px solid rgba(124,58,237,0.3); box-shadow: 0 18px 44px -22px rgba(0,0,0,0.8);
  transition: box-shadow .2s, border-color .2s; }
.flow-node.sel { border-color: rgba(167,139,250,0.75); box-shadow: 0 0 0 1px rgba(167,139,250,0.5), 0 22px 50px -22px rgba(124,58,237,0.6); }
.flow-node .grip { cursor: grab; }
.flow-node .grip:active { cursor: grabbing; }
.flow-port { position: absolute; width: 15px; height: 15px; border-radius: 99px; top: 33px;
  background: rgba(12,12,20,0.95); border: 2px solid var(--color-brand-light);
  cursor: crosshair; z-index: 3; transition: transform .15s, background .15s, box-shadow .15s; }
.flow-port:hover { transform: scale(1.35); background: var(--color-brand-light); box-shadow: 0 0 12px var(--color-brand-light); }
.flow-port.in { left: -8px; } .flow-port.out { right: -8px; }
@keyframes nodeRun { 0%,100% { box-shadow: 0 0 0 1px rgba(167,139,250,0.4), 0 0 18px rgba(124,58,237,0.4); } 50% { box-shadow: 0 0 0 1px rgba(167,139,250,0.9), 0 0 34px rgba(124,58,237,0.85); } }
.flow-node.running { animation: nodeRun 1s ease-in-out infinite; border-color: rgba(167,139,250,0.8); }

/* editor timeline */
.tl-clip { position: relative; height: 100%; border-radius: 9px; overflow: hidden; cursor: pointer;
  border: 1px solid rgba(124,58,237,0.3); flex: 0 0 auto; transition: box-shadow .15s, border-color .15s; }
.tl-clip.sel { border-color: rgba(167,139,250,0.9); box-shadow: 0 0 0 1px rgba(167,139,250,0.7), 0 10px 26px -14px rgba(124,58,237,0.7); }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 4;
  background: rgba(167,139,250,0.85); display: flex; align-items: center; justify-content: center; }
.tl-handle.l { left: 0; border-radius: 8px 0 0 8px; } .tl-handle.r { right: 0; border-radius: 0 8px 8px 0; }
.tl-handle::after { content: ""; width: 2px; height: 40%; background: rgba(8,8,14,0.7); border-radius: 2px; }
.studio-tab { position: relative; transition: color .18s, background .18s; }
.studio-tab.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 99px;
  background: linear-gradient(180deg, #a78bfa, #7c3aed); box-shadow: 0 0 12px rgba(124,58,237,0.8); }

@media (prefers-reduced-motion: reduce) {
  .wave-live, .expand-fill, .flow-node.running { animation: none !important; }
}

@keyframes marchAnts { to { background-position: 28px 0, -28px 100%, 0 -28px, 100% 28px; } }
.mask-marching {
  background-image:
    linear-gradient(90deg, #7dd3fc 50%, transparent 50%),
    linear-gradient(90deg, #7dd3fc 50%, transparent 50%),
    linear-gradient(0deg, #7dd3fc 50%, transparent 50%),
    linear-gradient(0deg, #7dd3fc 50%, transparent 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 14px 2px, 14px 2px, 2px 14px, 2px 14px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: marchAnts 0.7s linear infinite;
}
@keyframes capBounce { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.04); } }
.cap-bounce { animation: capBounce 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .mask-marching, .cap-bounce { animation: none !important; } }

/* ============================================================
   SAVE FLASH — cyan lightning + "Saved"
   ============================================================ */
.saveflash { position: fixed; inset: 0; z-index: 96; pointer-events: none; display: grid; place-items: center; }
.saveflash .sf-glow { position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(125,211,252,0.45), rgba(125,211,252,0) 65%);
  animation: sfGlow 1.1s cubic-bezier(0.2,0.8,0.3,1) forwards; }
.saveflash .sf-bolt { position: relative; display: grid; place-items: center; width: 78px; height: 78px; border-radius: 22px;
  background: rgba(10,12,20,0.7); border: 1px solid rgba(125,211,252,0.5); backdrop-filter: blur(8px);
  box-shadow: 0 0 30px -4px rgba(125,211,252,0.7), inset 0 1px 0 rgba(255,255,255,0.15);
  filter: drop-shadow(0 0 10px rgba(125,211,252,0.8)); animation: sfBolt 1.2s cubic-bezier(0.2,0.9,0.3,1) forwards; }
.saveflash .sf-bolt svg { animation: sfFlicker 0.5s steps(2) 2; }
.saveflash .sf-label { position: absolute; bottom: calc(50% - 86px); font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: #7dd3fc; text-shadow: 0 0 10px rgba(125,211,252,0.7);
  padding: 5px 14px; border-radius: 99px; background: rgba(10,12,20,0.7); border: 1px solid rgba(125,211,252,0.4);
  animation: sfLabel 1.2s cubic-bezier(0.2,1.4,0.4,1) forwards; }
@keyframes sfGlow { 0% { transform: scale(0.2); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes sfBolt { 0% { transform: scale(0.4) rotate(-12deg); opacity: 0; } 35% { transform: scale(1.12) rotate(3deg); opacity: 1; } 70% { transform: scale(1) rotate(0); opacity: 1; } 100% { transform: scale(0.9) translateY(-10px); opacity: 0; } }
@keyframes sfFlicker { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes sfLabel { 0% { transform: translateY(10px); opacity: 0; } 40% { transform: translateY(0); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-6px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .saveflash .sf-glow, .saveflash .sf-bolt, .saveflash .sf-label, .saveflash svg { animation-duration: 0.01s !important; } }

/* ============================================================
   RESPONSIVE STUDIO (iPad / mobile)
   ============================================================ */
.studio-split { display: flex; min-height: 0; }
.studio-aside { overflow-y: auto; }
.ed-side { display: flex; }
.ed-rail { display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .studio-main { overflow-y: auto !important; }
  .fullbleed { height: auto !important; min-height: 100%; }
  .studio-split { flex-direction: column; }
  .studio-aside { width: 100% !important; flex: 1 1 auto !important; border-left: none !important;
    border-top: 1px solid rgba(124,58,237,0.18) !important; max-height: none !important; }
  .flow-canvas-wrap { height: 62vh; flex: 0 0 auto; }
  .ed-side { width: 100% !important; flex: 1 1 auto !important; flex-direction: column; border-left: none !important;
    border-top: 1px solid rgba(124,58,237,0.18); }
  .ed-rail { flex-direction: row !important; width: 100% !important; flex: 0 0 auto !important; overflow-x: auto;
    border-right: none !important; border-bottom: 1px solid rgba(124,58,237,0.12); }
  .ed-rail button { flex: 0 0 auto; min-width: 66px; }
  .ed-player { min-height: 40vh; }
  .brand-split { flex-direction: column; }
  .brand-phasenav { width: 100% !important; flex: 0 0 auto !important; flex-direction: row !important; overflow-x: auto;
    border-right: none !important; border-bottom: 1px solid rgba(124,58,237,0.14); }
  .brand-phasenav .brand-phase { flex: 0 0 auto; }
  .brand-pers-grid, .brand-strat-grid, .brand-pat-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 560px) {
  .studio-topbar { padding: 12px 16px !important; }
  .studio-topbar h1 { font-size: 19px !important; }
}