/* ═══════════════════════════════════════════════════════════════════════
   NAERIS CARD STUDIO · create.css
   Electric animated border on preview · Liquid glass panels
   Performance: GPU-composited layers, isolation contexts, no cascade blur
═══════════════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; /* Firefox on Android */
  overflow: hidden;
  height: 100dvh;
  overscroll-behavior: none;      /* stop pull-to-refresh hijacking the shader */
  touch-action: pan-x pan-y;     /* allow normal scroll, block pinch-zoom on root */
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }
input, textarea, select { font: inherit; color: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
::selection { background: rgba(124,58,237,.4); color: #fff; }

/* ── Design tokens ── */
:root {
  --bg:        #070714;
  --bg-2:      #0B0B1F;

  /* Electric accent — violet/cyan to match neural background */
  --electric:       #A78BFA;
  --electric-glow:  rgba(124,58,237,.5);
  --electric-dim:   rgba(124,58,237,.2);

  /* Glass surfaces — true layered glass */
  --glass-0:   rgba(255,255,255,.018);
  --glass-1:   rgba(255,255,255,.032);
  --glass-2:   rgba(255,255,255,.058);
  --glass-3:   rgba(255,255,255,.095);
  --glass-4:   rgba(255,255,255,.14);

  /* Borders */
  --border:    rgba(255,255,255,.07);
  --border-2:  rgba(255,255,255,.12);
  --border-hi: rgba(255,255,255,.20);

  /* Accent */
  --violet:      #7C3AED;
  --violet-soft: #A78BFA;
  --violet-glow: rgba(124,58,237,.45);
  --cyan:        #00D4FF;
  --cyan-soft:   #67E8FF;
  --cyan-glow:   rgba(0,212,255,.45);

  /* Text */
  --text:       #ffffff;
  --text-soft:  rgba(255,255,255,.72);
  --text-mute:  rgba(255,255,255,.42);
  --text-faint: rgba(255,255,255,.20);

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  --blur: 28px;
  --blur-sm: 14px;

  /* Layout */
  --rail-w:      200px;
  --panel-w:     380px;
  --toolbar-h:   52px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --tx-display: 'Syncopate', sans-serif;
  --tx-script:  'Dancing Script', cursive;
}

/* ═══════════════════════════════════════════════════════════════════════
   ELECTRIC BORDER ANIMATION  (preview shell uses this)
═══════════════════════════════════════════════════════════════════════ */
@keyframes electricSlide {
  from { transform: translateX(0%); }
  to   { transform: translateX(-50%); }
  /* transform is GPU-composited; background-position forces main-thread repaint */
}
@keyframes electricPulse {
  0%,100% { opacity:.7; }
  50%      { opacity:1; }
}

/* ═══════════════════════════════════════════════════════════════════════
   BACKGROUND
═══════════════════════════════════════════════════════════════════════ */
#bg-shader{
  position:fixed;inset:0;z-index:0;
  width:100%;height:100%;
  pointer-events:none;
}
#bg-fallback{
  display:none;position:fixed;inset:0;z-index:0;overflow:hidden;
  background:var(--bg);
}
#bg-fallback .blob{position:absolute;border-radius:50%;filter:blur(80px);mix-blend-mode:screen;will-change:transform}
#bg-fallback .v{width:60vmax;height:60vmax;top:-15vmax;left:-12vmax;background:radial-gradient(circle,var(--violet) 0%,transparent 60%);opacity:.45;animation:bDriftV 24s ease-in-out infinite}
#bg-fallback .c{width:50vmax;height:50vmax;bottom:-12vmax;right:-10vmax;background:radial-gradient(circle,var(--cyan) 0%,transparent 60%);opacity:.30;animation:bDriftC 28s ease-in-out infinite}
@keyframes bDriftV{0%,100%{transform:translate3d(0,0,0)}50%{transform:translate3d(8vmax,5vmax,0)}}
@keyframes bDriftC{0%,100%{transform:translate3d(0,0,0)}50%{transform:translate3d(-6vmax,-4vmax,0)}}

.cyan-accent{
  position:fixed;z-index:1;pointer-events:none;
  bottom:-30vmax;right:-30vmax;
  width:70vmax;height:70vmax;
  background:radial-gradient(circle,rgba(0,212,255,.16) 0%,transparent 55%);
  filter:blur(60px);
  opacity:.7;
}
.violet-accent{
  position:fixed;z-index:1;pointer-events:none;
  top:-25vmax;left:-25vmax;
  width:60vmax;height:60vmax;
  background:radial-gradient(circle,rgba(124,58,237,.18) 0%,transparent 55%);
  filter:blur(60px);
  opacity:.6;
}

.vignette{
  position:fixed;inset:0;z-index:2;pointer-events:none;
  background:radial-gradient(ellipse at center,transparent 30%,rgba(7,7,20,.55) 95%);
}
.grain{
  position:fixed;inset:0;z-index:2;pointer-events:none;
  opacity:.05;mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════════════════════
   STUDIO SHELL
═══════════════════════════════════════════════════════════════════════ */
.studio {
  position: relative;
  /* z-index intentionally absent — adding any z-index here creates a new stacking
     context that traps the neural-noise canvas (position:fixed, z-index:0) OUTSIDE
     the context. When that happens, backdrop-filter on toolbar/rail/panel samples
     the opaque body background instead of the live shader, making the background
     visible only where no panel covers it (typically just the preview area).
     Without z-index, .studio has no stacking context; all child z-indexes are
     resolved in the root context alongside the canvas — backdrop-filter works
     correctly across the full viewport. */
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════
   SVG FILTER DEFS  (hidden — referenced via filter:url())
   These are injected inline in create.html
═══════════════════════════════════════════════════════════════════════ */

/* ── Liquid glass mixin — applied via data attributes to avoid
   stacking backdrop-filter on every card (kills perf).
   Only the outer panel shell gets backdrop-filter.
   Inner cards use the SVG turbulence displacement filter instead.  ── */

/* ═══════════════════════════════════════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════════════════════════════════════ */
.studio-toolbar {
  flex-shrink: 0;
  height: calc(var(--toolbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: max(14px, env(safe-area-inset-left, 14px));
  padding-right: max(14px, env(safe-area-inset-right, 14px));

  /* True glass toolbar — transparent so neural bg shows through */
  background: rgba(7,7,20,.28);
  backdrop-filter: blur(16px) saturate(160%) brightness(.9);
  -webkit-backdrop-filter: blur(16px) saturate(160%) brightness(.9);
  border-bottom: 1px solid var(--border);
  box-shadow:
    inset 0 1px 0 var(--border-hi),
    0 4px 24px rgba(0,0,0,.4);

  display: flex;
  align-items: center;
  gap: 0;
  overflow: visible;
  z-index: 50;
  min-width: 0;
}
.studio-toolbar > * { flex-shrink: 0; }
.toolbar-spacer    { flex: 1 1 0; min-width: 0; }

/* Logo */
.toolbar-logo {
  display: flex; align-items: center; gap: 7px;
  text-decoration: none; margin-right: 10px;
}
.toolbar-logo svg { width: 24px; height: 24px; flex-shrink: 0; }
.toolbar-logo-text {
  font-family: var(--tx-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase;
  color: #fff; white-space: nowrap;
}

.toolbar-divider {
  width: 1px; height: 20px;
  background: var(--border);
  flex-shrink: 0; margin: 0 8px;
}

.toolbar-status {
  font-size: 11px; color: var(--text-mute);
  letter-spacing: .03em; white-space: nowrap; min-width: 0;
}
.toolbar-status.saving { color: var(--cyan-soft); }
.toolbar-status.saved  { color: rgba(100,220,130,.75); }

.tb-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-mute);
  transition: background .15s, color .15s;
  flex-shrink: 0; margin: 0 2px;
}
.tb-btn:hover { background: var(--glass-2); color: var(--text); }
.tb-btn:disabled { opacity: .28; cursor: not-allowed; }
.tb-btn svg { width: 16px; height: 16px; }

.tb-mode-group {
  display: flex;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden; margin: 0 6px;
}
.tb-mode-btn {
  padding: 5px 10px; font-size: 11px;
  letter-spacing: .04em; color: var(--text-mute);
  transition: background .15s, color .15s; white-space: nowrap;
}
.tb-mode-btn.active { background: var(--glass-3); color: var(--text); }

.tb-vp-group {
  display: flex;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden; margin: 0 6px;
}
.tb-vp-btn {
  width: 30px; height: 28px;
  display: grid; place-items: center;
  color: var(--text-mute);
  transition: background .15s, color .15s;
}
.tb-vp-btn.active { background: var(--glass-3); color: var(--text); }
.tb-vp-btn svg { width: 14px; height: 14px; }

.tb-qf-btn {
  padding: 5px 12px;
  background: rgba(0,212,255,.07);
  border: 1px solid rgba(0,212,255,.22);
  border-radius: var(--r-pill);
  font-size: 11px; color: var(--cyan-soft);
  display: flex; align-items: center; gap: 5px;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap; margin: 0 6px;
}
.tb-qf-btn:hover {
  background: rgba(0,212,255,.14);
  box-shadow: 0 0 14px rgba(0,212,255,.22);
}
.tb-qf-btn svg { width: 12px; height: 12px; }

.tb-save-btn {
  padding: 5px 13px;
  background: var(--glass-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  font-size: 12px; color: var(--text-soft);
  transition: background .2s, border-color .2s, color .2s;
  white-space: nowrap; margin: 0 4px;
}
.tb-save-btn:hover { background: var(--glass-3); color: #fff; }

.tb-publish-btn {
  padding: 5px 14px;
  background: linear-gradient(135deg, var(--violet), #5b21b6);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; color: #fff;
  transition: box-shadow .2s, transform .15s;
  white-space: nowrap; margin: 0 4px;
}
.tb-publish-btn:hover {
  box-shadow: 0 0 22px var(--violet-glow);
  transform: translateY(-1px);
}

.tb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: grid; place-items: center;
  font-family: var(--tx-script);
  font-size: 15px; font-weight: 700; color: #fff;
  cursor: pointer; flex-shrink: 0; border: none;
  transition: transform .2s; margin-left: 6px;
}
.tb-avatar:hover { transform: scale(1.06); }

/* Dropdown */
.tb-dropdown-wrap { position: relative; }
.tb-dropdown {
  position: absolute; top: 42px; right: 0;
  min-width: 175px;
  /* Liquid glass dropdown */
  background: rgba(10,10,28,.82);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--border-hi),
    0 16px 52px rgba(0,0,0,.6),
    0 0 0 1px rgba(255,255,255,.04);
  padding: 6px;
  opacity: 0; pointer-events: none;
  transform: translateY(-8px) scale(.95);
  transform-origin: top right;
  transition: opacity .2s, transform .25s cubic-bezier(.34,1.56,.64,1);
  z-index: 200;
}
.tb-dropdown.open { opacity: 1; pointer-events: auto; transform: none; }
.tb-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-soft);
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none; width: 100%; text-align: left;
}
.tb-dropdown-item:hover { background: var(--glass-2); color: #fff; }
.tb-dropdown-item svg { width: 14px; height: 14px; opacity: .6; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   STUDIO BODY
═══════════════════════════════════════════════════════════════════════ */
.studio-body {
  flex: 1; display: flex;
  overflow: hidden; min-height: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   NAVIGATION RAIL  — liquid glass left column
═══════════════════════════════════════════════════════════════════════ */
.nav-rail {
  width: var(--rail-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 12px 8px; gap: 2px;

  /* True glass — low fill so WebGL background bleeds through */
  background: rgba(7,7,20,.22);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border-right: 1px solid var(--border);
  box-shadow:
    inset -1px 0 0 rgba(255,255,255,.04),
    inset 0 1px 0 rgba(255,255,255,.06);
  overflow-y: auto; overflow-x: hidden;
  /* No will-change here — it creates a compositing layer that can block
     backdrop-filter from sampling the bg-shader behind it */
}
.nav-rail { scrollbar-width: none; }           /* Firefox + Android */
.nav-rail::-webkit-scrollbar { display: none; } /* Chrome/Safari/Android */
.nav-rail::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.rail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  border: 1px solid transparent;
  color: var(--text-mute);
  position: relative;
}
.rail-item:hover { background: var(--glass-2); color: var(--text-soft); }
.rail-item.active {
  background: rgba(124,58,237,.15);
  border-color: rgba(124,58,237,.30);
  color: var(--violet-soft);
  box-shadow:
    0 0 14px rgba(124,58,237,.14),
    inset 0 1px 0 rgba(255,255,255,.07);
}
.rail-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .6; }
.rail-item.active .rail-icon { opacity: 1; }
.rail-label { font-size: 12px; letter-spacing: .03em; font-weight: 500; white-space: nowrap; }

.rail-dot {
  width: 6px; height: 6px; border-radius: 50%;
  margin-left: auto;
  background: rgba(100,220,130,.7);
  flex-shrink: 0; display: none;
}
.rail-item.done .rail-dot { display: block; }

.rail-section {
  font-size: 9px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 10px 10px 4px; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════
   PREVIEW PANE  (center)
═══════════════════════════════════════════════════════════════════════ */
.preview-pane {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 20px; overflow: hidden; min-width: 0;
}

.preview-frame-wrap {
  position: relative; display: flex;
  flex-direction: column; align-items: center; gap: 14px;
  flex: 1; width: 100%; max-height: 100%;
}

.preview-device {
  position: relative; flex: 1; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* ── Electric animated border preview shell — uses SVG turbulent-displace filter ── */
.preview-shell {
  position: relative;
  border-radius: 24px;
  background: #000;
}
.preview-shell.mobile  { width: 320px; height: 580px; }
.preview-shell.desktop { width: min(560px,80vw); height: 420px; }

/* Electric border wrapper — outer container with gradient bg (no filter here) */
.preview-electric-wrap {
  position: absolute;
  inset: -2px;
  border-radius: 26px;
  padding: 1px;
  overflow: hidden;      /* clip the sliding pseudo-element */
  pointer-events: none;
  z-index: 2;
}
/* Slide a WIDE gradient using transform (GPU composited) instead of
   background-position (main-thread repaint). The pseudo is 200% wide
   so translateX(-50%) = one full cycle, exactly matching the old effect. */
.preview-electric-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 200%;
  border-radius: inherit;
  background: linear-gradient(
    -30deg,
    rgba(124,58,237,.6),
    transparent 20%,
    rgba(0,212,255,.65) 45%,
    rgba(124,58,237,.55) 65%,
    transparent 80%,
    rgba(0,212,255,.4) 100%
  );
  animation: electricSlide 4s linear infinite;
  will-change: transform;
}

/* The animated border div — filter goes HERE */
.preview-electric-border {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  border: 1px solid rgba(0,212,255,.75);
  filter: url(#turbulent-displace);
  will-change: filter;
  pointer-events: none;
}

/* Glow layer behind the border */
.preview-electric-glow {
  position: absolute;
  inset: -3px;
  border-radius: 27px;
  border: 1px solid rgba(124,58,237,.5);
  filter: blur(3px);
  pointer-events: none;
  z-index: 1;
  opacity: .8;
  animation: electricPulse 2s ease-in-out infinite;
}

/* Outer ambient glow */
.preview-electric-ambient {
  position: absolute;
  inset: -4px;
  border-radius: 28px;
  filter: blur(18px);
  transform: scale(1.04);
  opacity: .18;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    -30deg,
    rgba(124,58,237,.9),
    transparent,
    rgba(0,212,255,.8)
  );
  animation: electricPulse 2.6s ease-in-out infinite alternate;
}

/* Inner card render target — z-index 4 keeps it above all border/overlay layers */
#studio-card {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 22px;
  overflow: hidden;
  isolation: isolate;
  z-index: 4;
}

/* Overlay highlight — decorative edge sheen, must be BELOW studio-card */
.preview-overlay {
  position: absolute; inset: 0;
  border-radius: 22px;
  opacity: .45;
  mix-blend-mode: overlay;
  transform: scale(1.08) translateZ(0);
  filter: blur(14px);
  background: linear-gradient(
    -30deg,
    white,
    transparent 30%,
    transparent 70%,
    white
  );
  pointer-events: none; z-index: 1;
}

.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: var(--text-faint);
  font-size: 13px; text-align: center; padding: 24px;
}
.preview-empty .pe-icon { opacity: .35; display: flex; align-items: center; justify-content: center; }
.preview-empty p { max-width: 200px; line-height: 1.5; }

/* Candidate preview bar */
.preview-candidate-bar {
  display: none; align-items: center; gap: 10px;
  padding: 7px 16px;
  background: rgba(0,212,255,.08);
  border: 1px solid rgba(0,212,255,.24);
  border-radius: var(--r-pill);
  font-size: 12px; color: var(--cyan-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(0,212,255,.10), inset 0 1px 0 rgba(255,255,255,.09);
}
.preview-candidate-bar.visible { display: flex; }
.preview-candidate-bar button {
  font-size: 11px; padding: 4px 12px;
  border-radius: var(--r-pill); transition: background .15s;
}
.preview-candidate-bar .pcb-use {
  background: var(--cyan); color: #070714; font-weight: 600;
}
.preview-candidate-bar .pcb-use:hover { opacity: .88; }
.preview-candidate-bar .pcb-discard {
  color: var(--text-mute); background: var(--glass-2);
  border: 1px solid var(--border);
}
.preview-candidate-bar .pcb-discard:hover { background: var(--glass-3); color: #fff; }

/* Refresh */
.preview-refresh-btn {
  padding: 6px 14px;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 11px; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.preview-refresh-btn:hover { background: var(--glass-2); color: #fff; }
.preview-refresh-btn svg { width: 12px; height: 12px; }

/* ═══════════════════════════════════════════════════════════════════════
   EDITOR PANEL  — liquid glass right column
   ONE backdrop-filter at the panel level. Inner cards use SVG filter.
═══════════════════════════════════════════════════════════════════════ */
.editor-panel {
  width: var(--panel-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  /* True glass — backdrop-filter directly here so WebGL bg bleeds through.
     The ::after trick with isolation:isolate was preventing the filter from
     sampling the fixed bg-shader canvas. */
  background: rgba(9,8,26,.25);
  backdrop-filter: blur(20px) saturate(160%) brightness(.9);
  -webkit-backdrop-filter: blur(20px) saturate(160%) brightness(.9);
  border-left: 1px solid rgba(255,255,255,.09);
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,.08),
    inset 0 1px 0 rgba(124,58,237,.14),
    -8px 0 56px rgba(0,0,0,.38),
    -2px 0 80px rgba(124,58,237,.08);
  overflow: hidden;
  position: relative;
  /* No will-change:transform here — it creates a compositing layer boundary
     that blocks backdrop-filter from seeing the bg-shader on some drivers.
     Promote the canvas and nav-rail instead. */
}

/* Top luminous gradient line */
.editor-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,.7), rgba(0,212,255,.65), transparent);
  opacity: .75; z-index: 2; pointer-events: none;
}
/* ::after reserved for future decoration; no backdrop-filter here */
.editor-panel::after { content: none; }

.panel-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0; position: relative; z-index: 2;
  background: rgba(255,255,255,.022);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.09),
    0 1px 0 rgba(124,58,237,.13);
}
.panel-title {
  font-family: var(--tx-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--violet-soft); margin-bottom: 4px;
}
.panel-sub { font-size: 12px; color: var(--text-mute); }

/* Panel body */
.panel-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 20px 24px;
  position: relative; z-index: 1;
  -webkit-overflow-scrolling: touch; /* momentum scroll on iOS/Android */
  transform: translateZ(0);          /* promote scroll container to GPU layer — smooths fling on Android */
  contain: layout paint;       /* prevents full-page layout on every input keystroke */
  overscroll-behavior-y: contain; /* stop scroll chaining out of panel */
  /* isolation:isolate removed — prevented backdrop-filter from seeing WebGL bg */
}

/* Panel content animation — gives immediate visual feedback on switch */
@keyframes panelStepIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* panelStepIn scoped to explicit panel switches only — not every innerHTML rebuild.
   The JS adds .is-switching to .panel-body for one frame when the active panel changes. */
.panel-body.is-switching > * {
  animation: panelStepIn .28s cubic-bezier(.22,1,.36,1) both;
}
/* Mobile sheet: animate children only on first open, not on re-renders */
.mobile-sheet.is-switching .panel-body > * {
  animation: panelStepIn .22s cubic-bezier(.22,1,.36,1) both;
}
.panel-body { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── Panel groups ── */
.ps-group { margin-bottom: 20px; }
.ps-label {
  font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-mute);
  margin-bottom: 8px; font-weight: 600;
}
.ps-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; line-height: 1.5; }
.ps-hint-inline { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: 10px; }
.ps-group-hint { font-size: 11px; color: var(--text-faint); font-style: italic; margin-top: 2px; line-height: 1.4; }

/* ═══════════════════════════════════════════════════════════════════════
   LIQUID GLASS CARD — the core surface used for all inner cards/tiles
   Uses the SVG displacement filter (no backdrop-filter) so it works
   without stacking compositing layers
═══════════════════════════════════════════════════════════════════════ */
.lg-card {
  position: relative;
  border-radius: var(--r-md);
  overflow: visible; /* let ::before show outside bounds for glow */
}

/* The frosted glass surface via CSS glass technique */
.lg-card-inner {
  position: relative;
  border-radius: inherit;
  overflow: hidden;
  /* displacement filter applied inline via JS for panel body children */
}

/* Inner highlight ring — the "scrollbar glass" bead from reference */
.lg-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    150deg,
    rgba(255,255,255,.40) 0%,
    rgba(255,255,255,.07) 28%,
    rgba(255,255,255,.07) 70%,
    rgba(255,255,255,.50) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

/* ── Glass inputs ── */
.st-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-sm);
  color: var(--text); padding: 9px 12px;
  font-size: 13px; line-height: 1.5;
  transition: border-color .2s, background .2s, box-shadow .2s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.st-input:focus {
  outline: none;
  border-color: rgba(124,58,237,.55);
  background: rgba(255,255,255,.09);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    0 0 0 3px rgba(124,58,237,.14);
}
.st-input::placeholder { color: var(--text-faint); }
.st-textarea { min-height: 100px; resize: vertical; }
.st-select {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.06) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  padding-right: 30px;
}
.st-row { display: flex; gap: 8px; }
.st-row .st-input { flex: 1; }

/* ── Toggle ── */
.st-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.st-toggle-row:last-child { border-bottom: none; }
.st-toggle-row.locked { opacity: .42; pointer-events: none; }
.st-toggle-info { flex: 1; min-width: 0; }
.st-toggle-name { font-size: 13px; color: var(--text-soft); display: flex; align-items: center; gap: 6px; }
.st-toggle-desc { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.lock-pill {
  font-size: 9px; padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(240,198,128,.12);
  border: 1px solid rgba(240,198,128,.25);
  color: rgba(240,198,128,.8);
  letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
}

.st-toggle { position: relative; width: 34px; height: 20px; flex-shrink: 0; }
.st-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.st-toggle-track {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.1);
  border-radius: var(--r-pill); cursor: pointer; transition: background .2s;
}
.st-toggle input:checked + .st-toggle-track { background: var(--violet); }
.st-toggle-track::after {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.st-toggle input:checked + .st-toggle-track::after { transform: translateX(14px); }

/* ── Pill group ── */
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-opt {
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 12px;
  border: 1px solid rgba(255,255,255,.09);
  color: var(--text-mute); cursor: pointer;
  transition: all .15s;
  background: rgba(255,255,255,.04);
  display: flex; align-items: center; gap: 5px;
}
.pill-opt:hover { border-color: var(--border-2); color: var(--text-soft); background: var(--glass-2); }
.pill-opt.sel {
  background: rgba(124,58,237,.16);
  border-color: rgba(124,58,237,.42);
  color: var(--violet-soft);
}
.pill-icon { display: flex; align-items: center; justify-content: center; width: 14px; height: 14px; }
.pill-icon svg { width: 14px; height: 14px; }

/* ── Color inputs ── */
.st-color-row { display: flex; align-items: center; gap: 10px; }
.st-color-swatch { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--border); overflow: hidden; flex-shrink: 0; }
.st-color-swatch input[type=color] { width: 48px; height: 48px; margin: -8px; cursor: pointer; border: none; background: none; }

/* ═══════════════════════════════════════════════════════════════════════
   GLASS SURFACE CARD — used for all panel inner cards
   This is the "scrollbar glass" style from the reference (doc 2):
   semi-transparent bg + inner highlight ring + optional glow
═══════════════════════════════════════════════════════════════════════ */

/* Base glass card — maps to .start-path, .gate-card, .theme-card, etc. */
.glass-surface {
  position: relative;
  background: radial-gradient(
      47% 50% at 50% 88%,
      rgba(255,255,255,.10) 0%,
      rgba(255,255,255,0) 100%
    ),
    rgba(255,255,255,.05);
  border-radius: var(--r-md);
  transition: background .18s, transform .15s, box-shadow .18s;
}
.glass-surface::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    150deg,
    rgba(255,255,255,.42) 0%,
    rgba(255,255,255,.08) 28%,
    rgba(255,255,255,.08) 70%,
    rgba(255,255,255,.52) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.glass-surface:hover {
  background: radial-gradient(
      47% 50% at 50% 88%,
      rgba(255,255,255,.14) 0%,
      rgba(255,255,255,0) 100%
    ),
    rgba(255,255,255,.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
}

/* ═══════════════════════════════════════════════════════════════════════
   START PANEL
═══════════════════════════════════════════════════════════════════════ */
.start-paths {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 20px;
}
.start-path {
  padding: 14px 12px; cursor: pointer; text-align: left;
  /* glass-surface inline */
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.09) 0%, transparent 100%),
              rgba(255,255,255,.04);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background .18s, transform .15s, box-shadow .18s, border-color .18s;
}
.start-path::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.38) 0%, rgba(255,255,255,.07) 28%,
    rgba(255,255,255,.07) 70%, rgba(255,255,255,.48) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.start-path:hover {
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.13) 0%, transparent 100%),
              rgba(255,255,255,.07);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(0,0,0,.26);
}
.start-path.sel {
  background: radial-gradient(47% 50% at 50% 88%, rgba(124,58,237,.18) 0%, transparent 100%),
              rgba(124,58,237,.12);
  border-color: rgba(124,58,237,.42);
  box-shadow: 0 0 22px rgba(124,58,237,.18), 0 4px 16px rgba(0,0,0,.2);
}
.sp-icon { width: 22px; height: 22px; margin-bottom: 8px; color: var(--violet-soft); }
.sp-icon svg { width: 18px; height: 18px; }
.sp-label { font-size: 12px; font-weight: 600; color: var(--text); }
.sp-desc  { font-size: 10px; color: var(--text-mute); margin-top: 2px; line-height: 1.4; }

.start-hint-row {
  margin-top: 16px; padding: 10px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.start-hint { font-size: 11px; color: var(--text-mute); line-height: 1.5; }

/* Occasion grid */
.occ-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; }
.occ-card {
  padding: 10px 10px 8px; cursor: pointer;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.08) 0%, transparent 100%),
              rgba(255,255,255,.04);
  border-radius: var(--r-md);
  font-size: 12px; color: var(--text-mute);
  transition: all .18s;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.occ-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.35) 0%, rgba(255,255,255,.06) 28%,
    rgba(255,255,255,.06) 70%, rgba(255,255,255,.42) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.occ-card:hover {
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.12) 0%, transparent 100%),
              rgba(255,255,255,.07);
  color: var(--text); transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
}
.occ-card.sel {
  background: radial-gradient(47% 50% at 50% 88%, rgba(0,212,255,.12) 0%, transparent 100%),
              rgba(0,212,255,.08);
  color: var(--cyan-soft);
  box-shadow: 0 0 16px rgba(0,212,255,.12);
}
.occ-icon { width: 18px; height: 18px; }
.occ-icon svg { width: 18px; height: 18px; }

/* Templates */
.template-list { display: flex; flex-direction: column; gap: 8px; }
.tpl-card {
  padding: 12px 14px; cursor: pointer; position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.08) 0%, transparent 100%),
              rgba(255,255,255,.04);
  border-radius: var(--r-md);
  transition: all .18s;
}
.tpl-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.36) 0%, rgba(255,255,255,.06) 28%,
    rgba(255,255,255,.06) 70%, rgba(255,255,255,.44) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.tpl-card:hover {
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.12) 0%, transparent 100%),
              rgba(255,255,255,.07);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(0,0,0,.26);
}
.tpl-name { font-size: 13px; font-weight: 600; color: var(--text); }
.tpl-desc { font-size: 11px; color: var(--text-mute); margin-top: 3px; }
.tpl-tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.tpl-tag {
  font-size: 10px; padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(124,58,237,.12); color: var(--violet-soft);
  border: 1px solid rgba(124,58,237,.2);
}

/* ═══════════════════════════════════════════════════════════════════════
   RECOMMENDATION CARDS
═══════════════════════════════════════════════════════════════════════ */
.rec-combo-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.rec-combo-card {
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(0,212,255,.10) 0%, transparent 100%),
              rgba(0,212,255,.05);
  border-radius: var(--r-md); padding: 12px;
  box-shadow: 0 0 24px rgba(0,212,255,.07);
}
.rec-combo-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(0,212,255,.30) 0%, rgba(0,212,255,.08) 30%,
    rgba(255,255,255,.06) 70%, rgba(0,212,255,.36) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.rcc-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rcc-gate-icon { width: 28px; height: 28px; flex-shrink: 0; color: var(--violet-soft); }
.rcc-gate-icon svg { width: 28px; height: 28px; }
.rcc-swatch { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.1); }
.rcc-info { flex: 1; min-width: 0; }
.rcc-name { font-size: 13px; font-weight: 600; color: var(--text); }
.rcc-role { font-size: 11px; color: var(--text-mute); margin-top: 1px; }
.rcc-applied {
  font-size: 10px; font-weight: 700; color: var(--cyan-soft);
  background: rgba(0,212,255,.12); border-radius: var(--r-pill);
  padding: 2px 8px; letter-spacing: .04em; white-space: nowrap;
}
.rcc-desc { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; line-height: 1.45; }
.rcc-why  { font-size: 11px; color: var(--text-mute); font-style: italic; margin-bottom: 8px; line-height: 1.4; }
.rcc-actions { display: flex; gap: 8px; }
.rcc-btn {
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 500;
  border: 1px solid var(--border-2); color: var(--text-soft);
  background: rgba(255,255,255,.05); cursor: pointer;
  transition: background .15s, color .15s;
}
.rcc-btn:hover { background: var(--glass-3); color: var(--text); }
.rcc-btn.primary {
  background: rgba(124,58,237,.18);
  border-color: rgba(124,58,237,.38);
  color: var(--violet-soft);
}
.rcc-btn.primary:hover { background: rgba(124,58,237,.30); }

/* ═══════════════════════════════════════════════════════════════════════
   GATE LIBRARY
═══════════════════════════════════════════════════════════════════════ */
.lib-search-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.lib-search {
  flex: 1; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10); border-radius: var(--r-sm);
  color: var(--text); padding: 7px 10px 7px 32px; font-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none'%3E%3Ccircle cx='6' cy='6' r='4.5' stroke='%23555' stroke-width='1.4'/%3E%3Cpath d='M9.5 9.5l2.5 2.5' stroke='%23555' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center;
  transition: border-color .2s, background .2s;
}
.lib-search:focus { outline: none; border-color: rgba(124,58,237,.5); background: rgba(255,255,255,.08); }

.lib-filters { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.lib-filter {
  padding: 4px 10px; border-radius: var(--r-pill); font-size: 11px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09); color: var(--text-mute);
  cursor: pointer; transition: all .15s;
}
.lib-filter:hover { border-color: var(--border-2); color: var(--text-soft); }
.lib-filter.active {
  background: rgba(124,58,237,.16);
  border-color: rgba(124,58,237,.38); color: var(--violet-soft);
}

.filter-group-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mute); margin: 10px 0 4px;
}

.lib-sort-row { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.lib-sort-label { font-size: 11px; color: var(--text-mute); white-space: nowrap; }
.lib-sort-select {
  background: rgba(255,255,255,.05); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); color: var(--text-soft);
  font-size: 11px; padding: 4px 8px; cursor: pointer;
}
.lib-sort-select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lib-empty { padding: 28px 20px; text-align: center; color: var(--text-faint); font-size: 12px; line-height: 1.5; }

/* Gate cards */
.gate-grid { display: flex; flex-direction: column; gap: 8px; }
.gate-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 120px;  /* estimated card height — prevents scroll jump */
  position: relative; border-radius: var(--r-md); overflow: hidden;
  background: radial-gradient(47% 40% at 50% 0%, rgba(255,255,255,.06) 0%, transparent 70%),
              rgba(255,255,255,.04);
  transition: background .18s, transform .15s, box-shadow .18s;
}
.gate-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.36) 0%, rgba(255,255,255,.06) 28%,
    rgba(255,255,255,.06) 70%, rgba(255,255,255,.44) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 2;
}
.gate-card:hover {
  background: radial-gradient(47% 40% at 50% 0%, rgba(255,255,255,.09) 0%, transparent 70%),
              rgba(255,255,255,.07);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0,0,0,.26);
}
.gate-card.sel {
  background: radial-gradient(47% 40% at 50% 0%, rgba(124,58,237,.18) 0%, transparent 70%),
              rgba(124,58,237,.11);
  box-shadow: 0 0 24px rgba(124,58,237,.18), 0 4px 14px rgba(0,0,0,.2);
}
.gate-card.previewing {
  background: radial-gradient(47% 40% at 50% 0%, rgba(0,212,255,.14) 0%, transparent 70%),
              rgba(0,212,255,.07);
  box-shadow: 0 0 20px rgba(0,212,255,.14);
}
.gate-card.locked { opacity: .52; }

.gate-card-top { padding: 11px 12px 8px; display: flex; align-items: flex-start; gap: 10px; }
.gate-svg-icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--text-mute); }
.gate-svg-icon svg { width: 24px; height: 24px; }
.gate-card.sel .gate-svg-icon { color: var(--violet-soft); }
.gate-card.previewing .gate-svg-icon { color: var(--cyan-soft); }
.pcs-gate-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--violet-soft); }
.pcs-gate-icon svg { width: 22px; height: 22px; }
.gate-info { flex: 1; min-width: 0; }
.gate-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.gate-desc { font-size: 11px; color: var(--text-mute); margin-top: 2px; line-height: 1.4; }
.gate-badge {
  font-size: 9px; padding: 2px 7px; border-radius: var(--r-pill);
  background: rgba(240,198,128,.12); border: 1px solid rgba(240,198,128,.2);
  color: rgba(240,198,128,.8); letter-spacing: .05em; text-transform: uppercase;
  font-weight: 700; white-space: nowrap;
}
.gate-badge.free {
  background: rgba(100,220,130,.1); border-color: rgba(100,220,130,.2);
  color: rgba(100,220,130,.85);
}
.gate-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 12px 8px; }
.gate-meta-pill {
  font-size: 10px; color: var(--text-mute);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 2px 7px; white-space: nowrap;
}
.gate-meta-pill.energy-low    { border-color: rgba(100,220,120,.2); color: rgba(100,220,120,.7); }
.gate-meta-pill.energy-medium { border-color: rgba(255,200,80,.2);  color: rgba(255,200,80,.7); }
.gate-meta-pill.energy-high   { border-color: rgba(255,100,80,.2);  color: rgba(255,100,80,.7); }
.gate-actions { padding: 0 12px 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.gate-act-btn {
  padding: 4px 11px; border-radius: var(--r-pill); font-size: 11px;
  border: 1px solid rgba(255,255,255,.09); color: var(--text-mute);
  background: rgba(255,255,255,.04); cursor: pointer; transition: all .15s;
}
.gate-act-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.gate-act-btn.primary {
  background: rgba(124,58,237,.18); border-color: rgba(124,58,237,.38);
  color: var(--violet-soft);
}
.gate-act-btn.primary:hover { background: rgba(124,58,237,.30); }
.gate-sel-mark {
  position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--violet); display: none; place-items: center; z-index: 3;
}
.gate-card.sel .gate-sel-mark { display: grid; }
.gate-sel-mark svg { width: 10px; height: 10px; }
.gate-selected-label {
  font-size: 11px; color: var(--cyan-soft);
  padding: 5px 12px;
  background: rgba(0,212,255,.08);
  border: 1px solid rgba(0,212,255,.2); border-radius: var(--r-pill);
}
.panel-current-sel {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(124,58,237,.14) 0%, transparent 100%),
              rgba(124,58,237,.09);
  border-radius: var(--r-md); margin-bottom: 14px;
  box-shadow: 0 0 20px rgba(124,58,237,.10);
}
.panel-current-sel::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(124,58,237,.35) 0%, rgba(255,255,255,.06) 30%,
    rgba(255,255,255,.06) 70%, rgba(124,58,237,.42) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.pcs-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }
.pcs-name  { font-size: 13px; font-weight: 600; color: var(--violet-soft); }
.pcs-swatch { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(255,255,255,.1); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   THEME LIBRARY
═══════════════════════════════════════════════════════════════════════ */
.theme-independence-note {
  font-size: 11px; color: var(--text-mute); font-style: italic;
  margin-bottom: 12px; padding: 6px 10px;
  background: rgba(0,212,255,.04);
  border-left: 2px solid rgba(0,212,255,.22);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  cursor: pointer;
  background: radial-gradient(47% 40% at 50% 0%, rgba(255,255,255,.06) 0%, transparent 70%),
              rgba(255,255,255,.04);
  transition: background .18s, transform .15s, box-shadow .18s;
}
.theme-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.38) 0%, rgba(255,255,255,.07) 28%,
    rgba(255,255,255,.07) 70%, rgba(255,255,255,.46) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 2;
}
.theme-card:hover {
  background: radial-gradient(47% 40% at 50% 0%, rgba(255,255,255,.09) 0%, transparent 70%),
              rgba(255,255,255,.07);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
}
.theme-card.sel {
  box-shadow: 0 0 24px rgba(124,58,237,.20), 0 4px 16px rgba(0,0,0,.22);
}
.theme-card.previewing { box-shadow: 0 0 20px rgba(0,212,255,.16); }
.theme-card.locked { opacity: .52; }
.theme-preview { height: 80px; position: relative; overflow: hidden; }
.theme-preview-inner {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.theme-preview-title { font-size: 11px; font-weight: 600; }
.theme-preview-line { width: 60%; height: 2px; border-radius: 1px; opacity: .5; }
.theme-preview-body { width: 80%; height: 3px; background: rgba(0,0,0,.08); border-radius: 2px; margin-top: 4px; }
.theme-swatches { display: flex; gap: 3px; position: absolute; bottom: 6px; left: 8px; }
.theme-swatch-dot { width: 8px; height: 8px; border-radius: 50%; }
.theme-lock-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; border-radius: inherit;
}
.theme-card-info { padding: 8px 10px; }
.theme-card-name { font-size: 12px; font-weight: 600; color: var(--text); }
.theme-card-fonts { font-size: 10px; color: var(--text-mute); margin-top: 2px; }
.theme-card-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.theme-card-actions { padding: 0 8px 8px; display: flex; gap: 5px; }
.theme-card-actions .gate-act-btn { flex: 1; text-align: center; }

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGE COMPOSER
═══════════════════════════════════════════════════════════════════════ */
.letter-style-seg {
  display: flex; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--r-sm); overflow: hidden; margin-bottom: 14px;
}
.ls-seg-btn {
  flex: 1; padding: 7px; text-align: center;
  font-size: 12px; color: var(--text-mute);
  cursor: pointer; transition: background .15s, color .15s;
}
.ls-seg-btn.active { background: rgba(255,255,255,.08); color: var(--text); }

.msg-block {
  margin-bottom: 14px; padding: 12px; position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.08) 0%, transparent 100%),
              rgba(255,255,255,.04);
  border-radius: var(--r-md);
}
.msg-block::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.34) 0%, rgba(255,255,255,.06) 28%,
    rgba(255,255,255,.06) 70%, rgba(255,255,255,.42) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}

.msg-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.msg-block-label { font-size: 11px; font-weight: 600; color: var(--text-mute); letter-spacing: .05em; text-transform: uppercase; }
.msg-block-remove {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,80,80,.1); color: rgba(255,100,100,.7);
  display: grid; place-items: center; font-size: 13px; cursor: pointer;
  transition: background .15s; border: none;
}
.msg-block-remove:hover { background: rgba(255,80,80,.2); color: #ff6060; }

/* Element tray */
.elem-tray { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.elem-opt {
  content-visibility: auto;
  contain-intrinsic-size: 0 60px;
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.07) 0%, transparent 100%),
              rgba(255,255,255,.03);
  border-radius: var(--r-md); transition: all .15s;
}
.elem-opt::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.30) 0%, rgba(255,255,255,.05) 30%,
    rgba(255,255,255,.05) 70%, rgba(255,255,255,.36) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.elem-opt:hover { background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.11) 0%, transparent 100%), rgba(255,255,255,.06); }
.elem-opt.is-on { background: radial-gradient(47% 50% at 50% 88%, rgba(0,212,255,.10) 0%, transparent 100%), rgba(0,212,255,.05); }
.elem-opt-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--text-mute); display: flex; align-items: center; justify-content: center; }
.elem-opt-icon svg { width: 16px; height: 16px; }
.elem-opt.is-on .elem-opt-icon { color: var(--cyan-soft); }
.elem-opt-info { flex: 1; min-width: 0; }
.elem-opt-name { font-size: 12px; color: var(--text); }
.elem-opt-desc { font-size: 10px; color: var(--text-mute); }
.elem-opt-lock {
  font-size: 9px; padding: 2px 7px; border-radius: var(--r-pill);
  background: rgba(240,198,128,.1); color: rgba(240,198,128,.8);
  border: 1px solid rgba(240,198,128,.2);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 700; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   MUSIC / MEDIA PANELS
═══════════════════════════════════════════════════════════════════════ */
.info-card {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(124,58,237,.10) 0%, transparent 100%),
              rgba(124,58,237,.06);
  border-radius: var(--r-md); margin-bottom: 14px;
  box-shadow: 0 0 22px rgba(124,58,237,.08);
}
.info-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(124,58,237,.38) 0%, rgba(255,255,255,.06) 30%,
    rgba(255,255,255,.06) 70%, rgba(124,58,237,.44) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.ic-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--violet-soft); }
.ic-icon svg { width: 22px; height: 22px; }
.ic-body { flex: 1; min-width: 0; }
.ic-title { font-size: 12px; font-weight: 600; color: var(--violet-soft); margin-bottom: 3px; }
.ic-desc  { font-size: 11px; color: var(--text-mute); line-height: 1.45; }
.ic-action {
  align-self: center; font-size: 11px; font-weight: 600; color: var(--violet-soft);
  white-space: nowrap; padding: 4px 10px;
  border: 1px solid rgba(124,58,237,.3); border-radius: var(--r-pill); transition: background .15s;
}
.ic-action:hover { background: rgba(124,58,237,.12); }

.music-selected {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(0,212,255,.10) 0%, transparent 100%),
              rgba(0,212,255,.06);
  border-radius: var(--r-md); margin-bottom: 12px;
  box-shadow: 0 0 20px rgba(0,212,255,.08);
}
.music-selected::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(0,212,255,.32) 0%, rgba(255,255,255,.06) 30%,
    rgba(255,255,255,.06) 70%, rgba(0,212,255,.38) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.ms-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--cyan-soft); }
.ms-icon svg { width: 20px; height: 20px; }
.ms-info { flex: 1; min-width: 0; }
.ms-name { font-size: 12px; font-weight: 600; color: var(--cyan-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-desc { font-size: 11px; color: var(--text-mute); }
.ms-remove {
  font-size: 11px; color: var(--text-mute); background: none;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 3px 10px; cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.ms-remove:hover { color: #ff6b6b; border-color: rgba(255,107,107,.35); }

.upload-slot {
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.07) 0%, transparent 100%),
              rgba(255,255,255,.03);
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: var(--r-md); padding: 20px 16px;
  text-align: center; cursor: pointer; transition: all .2s;
}
.upload-slot::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.28) 0%, rgba(255,255,255,.04) 30%,
    rgba(255,255,255,.04) 70%, rgba(255,255,255,.34) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.upload-slot:hover {
  background: radial-gradient(47% 50% at 50% 88%, rgba(255,255,255,.11) 0%, transparent 100%),
              rgba(255,255,255,.06);
  border-color: rgba(124,58,237,.45);
  box-shadow: 0 0 20px rgba(124,58,237,.12);
}
.upload-slot.has {
  border-style: solid; border-color: rgba(100,220,130,.32);
  background: radial-gradient(47% 50% at 50% 88%, rgba(100,220,130,.08) 0%, transparent 100%),
              rgba(100,220,130,.04);
}
.upload-slot.locked { opacity: .42; pointer-events: none; }
.upload-icon { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--text-mute); }
.upload-icon svg { width: 28px; height: 28px; }
.upload-label { font-size: 12px; color: var(--text-soft); }
.upload-hint  { font-size: 10px; color: var(--text-mute); margin-top: 4px; }
.upload-slot input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-clear {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,.1); display: none;
  place-items: center; font-size: 12px; color: var(--text-mute); z-index: 2;
}
.upload-slot.has .upload-clear { display: grid; }
.upload-clear:hover { background: rgba(255,80,80,.2); color: #ff6060; }

.up-progress { margin-top: 8px; height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; display: none; }
.up-progress-bar { height: 100%; background: linear-gradient(90deg,var(--violet),var(--cyan)); width: 0; transition: width .1s; border-radius: 1px; }
.up-progress.visible { display: block; }
.media-thumb { max-height: 100px; width: auto; border-radius: var(--r-md); border: 1px solid var(--border); display: block; margin-top: 8px; }

.voice-rec-btn {
  margin-top: 8px; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; position: relative;
  background: rgba(124,58,237,.10);
  border: 1px solid rgba(124,58,237,.3); border-radius: var(--r-md);
  font-size: 12px; color: var(--violet-soft); cursor: pointer; transition: all .2s;
}
.voice-rec-btn:hover { background: rgba(124,58,237,.18); border-color: rgba(124,58,237,.5); }
.voice-rec-btn.recording {
  background: rgba(220,50,50,.12); border-color: rgba(220,50,50,.4); color: #ff6b6b;
  animation: recPulse 1.2s ease-in-out infinite;
}
@keyframes recPulse { 0%,100%{box-shadow:0 0 0 0 rgba(220,50,50,.25)} 50%{box-shadow:0 0 0 6px rgba(220,50,50,0)} }
.voice-rec-timer { margin-top: 6px; font-size: 11px; color: #ff6b6b; text-align: center; letter-spacing: .04em; }

/* ═══════════════════════════════════════════════════════════════════════
   PUBLISH PANEL
═══════════════════════════════════════════════════════════════════════ */
.pub-summary-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.pub-summary-item:last-child { border-bottom: none; }
.pub-summary-key { color: var(--text-mute); }
.pub-summary-val { color: var(--text); text-align: right; }
.pub-action-btn {
  width: 100%; padding: 12px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; text-align: center;
  transition: all .2s; cursor: pointer;
}
.pub-action-btn.primary { background: linear-gradient(135deg,var(--violet),#5b21b6); color: #fff; }
.pub-action-btn.primary:hover { box-shadow: 0 0 28px var(--violet-glow); transform: translateY(-1px); }
.pub-action-btn.secondary {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--text-soft); margin-top: 8px;
}
.pub-action-btn.secondary:hover { background: var(--glass-2); color: #fff; }

/* ── Publish panel viewport picker ── */
.pub-vp-seg {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.pub-vp-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--glass-1);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  touch-action: manipulation;
}
.pub-vp-btn svg {
  width: 13px; height: 13px;
  flex-shrink: 0;
  opacity: .75;
}
.pub-vp-btn.sel svg { opacity: 1; }
.pub-vp-btn:hover {
  background: var(--glass-2);
  color: var(--text);
}
.pub-vp-btn.sel {
  background: rgba(124,58,237,.18);
  border-color: rgba(124,58,237,.45);
  color: var(--violet-soft);
}
.pub-upgrade-note {
  padding: 10px 12px;
  background: rgba(124,58,237,.07); border: 1px solid rgba(124,58,237,.18);
  border-radius: var(--r-md); font-size: 12px; color: var(--text-mute); margin-bottom: 10px; line-height: 1.45;
}

/* ═══════════════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════════════ */
#studio-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(10,10,28,.90);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 10px 18px;
  font-size: 13px; color: var(--text-soft);
  z-index: 500; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 var(--border-hi), 0 8px 36px rgba(0,0,0,.55);
}
#studio-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-link { font-size: 12px; color: var(--cyan-soft); text-decoration: underline; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(7,7,20,.72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 300; display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  position: relative;
  background: rgba(12,12,30,.78);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--border-hi),
    0 24px 80px rgba(0,0,0,.7),
    0 0 60px rgba(124,58,237,.08);
  padding: 28px; width: min(440px,90vw);
  animation: modalIn .25s cubic-bezier(.22,1,.36,1);
}
.modal-box::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(255,255,255,.36) 0%, rgba(255,255,255,.06) 28%,
    rgba(255,255,255,.06) 70%, rgba(255,255,255,.44) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-title {
  font-family: var(--tx-display);
  font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  margin-bottom: 6px; color: #fff;
}
.modal-sub { font-size: 13px; color: var(--text-mute); margin-bottom: 20px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--glass-2); display: grid; place-items: center;
  font-size: 16px; color: var(--text-mute); cursor: pointer;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--glass-3); color: #fff; }

.qf-textarea {
  width: 100%; min-height: 110px; resize: vertical;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); padding: 12px;
  font-size: 13px; line-height: 1.6; margin-bottom: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.qf-textarea:focus { outline: none; border-color: rgba(124,58,237,.5); }
.qf-char-count { font-size: 11px; color: var(--text-faint); text-align: right; margin-bottom: 12px; }
.qf-btn {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg,var(--violet),var(--cyan));
  border-radius: var(--r-md); font-size: 14px; font-weight: 600; color: #fff;
  cursor: pointer; transition: opacity .2s;
}
.qf-btn:disabled { opacity: .5; cursor: not-allowed; }

.share-url-row { display: flex; gap: 8px; margin-bottom: 12px; }
.share-url-input {
  flex: 1; background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-soft); padding: 9px 12px;
  font-size: 12px; font-family: monospace;
}
.share-copy-btn {
  padding: 9px 16px; background: var(--violet);
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  color: #fff; cursor: pointer; white-space: nowrap; transition: opacity .2s;
}
.share-copy-btn:hover { opacity: .85; }
.share-expiry { font-size: 11px; color: var(--text-mute); margin-bottom: 16px; }
.share-actions { display: flex; gap: 8px; }
.share-act-btn {
  flex: 1; padding: 10px; background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 12px; color: var(--text-soft); cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s;
}
.share-act-btn:hover { background: var(--glass-2); border-color: var(--border-2); color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════
   SPINNER
═══════════════════════════════════════════════════════════════════════ */
.preview-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(7,7,20,.7); z-index: 10;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,.1);
  border-top-color: var(--violet-soft);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE  ≤ 768px
═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --toolbar-h: 48px; }
  body { overflow: hidden; }

  .studio-toolbar { gap: 0; overflow: visible; }
  .studio-toolbar > * { flex-shrink: 1; min-width: 0; }
  .studio-toolbar > .toolbar-spacer { flex: 0 1 0; }
  .toolbar-logo-text  { display: none; }
  .toolbar-status     { display: none; }
  .tb-mode-group      { display: none; }
  .tb-vp-group        { display: none; }
  .tb-save-btn        { display: none; }
  .tb-publish-btn     { display: none; }
  .tb-qf-btn          { display: none; }
  .toolbar-divider:first-of-type { display: none; }
  .toolbar-divider    { margin: 0 3px; }
  .tb-btn             { margin: 0 1px; width: 30px; height: 30px; }

  .studio-body  { flex-direction: column; overflow: hidden; }
  .nav-rail     { display: none; }
  .editor-panel { display: none; width: 0; }

  .preview-pane { padding: 10px 12px 8px; flex: 1; }
  .preview-shell.mobile  { width: min(300px,90vw); height: min(520px,62dvh); }
  .preview-shell.desktop { width: min(90vw,440px); height: min(280px,48dvh); }

  /* Mobile bottom nav — liquid glass */
  .mobile-bottom-nav {
    flex-shrink: 0;
    height: calc(56px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex; align-items: center; justify-content: space-around;
    background: rgba(7,7,20,.55);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid var(--border);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.09),
      0 -4px 24px rgba(0,0,0,.3);
    z-index: 50; overflow-x: hidden;
  }
  .mn-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 5px 2px; border-radius: var(--r-sm);
    cursor: pointer; flex: 1; transition: background .15s; min-width: 0;
  }
  .mn-item:hover  { background: var(--glass-1); }
  .mn-item.active .mn-icon  { color: var(--violet-soft); }
  .mn-item.active .mn-label { color: var(--violet-soft); }
  .mn-icon  { width: 17px; height: 17px; color: var(--text-mute); flex-shrink: 0; }
  .mn-label { font-size: 8px; color: var(--text-mute); letter-spacing: .02em; white-space: nowrap; }

  /* Mobile bottom sheet — true liquid glass */
  .mobile-sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(7,7,20,.5);
    /* No backdrop-filter — was making whole screen look blurry */
    z-index: 100; display: none;
  }
  .mobile-sheet-backdrop.open { display: block; }

  .mobile-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(7,7,20,.32);
    backdrop-filter: blur(22px) saturate(160%) brightness(.9);
    -webkit-backdrop-filter: blur(22px) saturate(160%) brightness(.9);
    /* Electric top border */
    border-top: 1px solid transparent;
    border-image: linear-gradient(90deg,
      transparent,
      rgba(124,58,237,.7) 30%,
      rgba(0,212,255,.65) 70%,
      transparent) 1;
    border-left: 1px solid rgba(255,255,255,.08);
    border-right: 1px solid rgba(255,255,255,.08);
    border-radius: 22px 22px 0 0;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.18),
      0 -2px 0 rgba(124,58,237,.35),
      0 -16px 60px rgba(0,0,0,.55),
      0 0 100px rgba(124,58,237,.14);
    z-index: 101;
    max-height: 82dvh;
    display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform .38s cubic-bezier(.22,1,.36,1);
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
    /* No will-change or isolation here — off-screen composited layers don't
       paint on certain Android drivers, and isolation:isolate broke z-index
       relative to the backdrop on Android Chrome */
  }
  /* Subtle top highlight ring only */
  .mobile-sheet::before {
    content: '';
    position: absolute; inset: 0; z-index: 0;
    border-radius: 22px 22px 0 0;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.18),
      inset 1px 0 0 rgba(255,255,255,.06),
      inset -1px 0 0 rgba(255,255,255,.06);
    pointer-events: none;
  }
  .mobile-sheet::after {
    content: '';
    position: absolute; z-index: 0; inset: 0;
    border-radius: 22px 22px 0 0;
    pointer-events: none;
    /* Pseudo-element kept for potential future use; blur is now on the
       sheet directly to avoid the isolation:isolate paint issue */
  }
  .mobile-sheet.open { transform: translateY(0); }
  .mobile-sheet.is-animating { will-change: transform; }
  .mobile-sheet-handle {
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--border-2); margin: 10px auto 0; flex-shrink: 0;
  }
  .mobile-sheet .panel-head { flex-shrink: 0; border-bottom: 1px solid var(--border); }
  .mobile-sheet .panel-body {
    flex: 1; overflow-y: auto;
    overscroll-behavior-y: contain;  /* stop scroll chaining to page */
    -webkit-overflow-scrolling: touch; /* legacy iOS momentum — harmless to keep */
  }
  .mobile-sheet .panel-head { position: relative; padding-right: 48px; }
  #mobile-sheet-close {
    position: absolute !important; top: 14px !important; right: 14px !important;
    width: 28px; height: 28px; background: var(--glass-2);
    border: 1px solid var(--border); border-radius: 50%;
    display: grid; place-items: center; color: var(--text-mute);
  }
  #mobile-sheet-close:hover { background: var(--glass-3); color: #fff; }
  .mobile-sheet .st-input {
    background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.13);
  }
  .mobile-sheet .st-input:focus {
    background: rgba(255,255,255,.12); border-color: rgba(124,58,237,.6);
  }
}

/* Desktop: hide mobile elements */
@media (min-width: 769px) {
  .mobile-bottom-nav     { display: none; }
  .mobile-sheet-backdrop { display: none !important; }
  .mobile-sheet          { display: none !important; }
}

/* Responsive breakpoints */
@media (max-width: 1200px) { :root { --panel-w: 320px; --rail-w: 170px; } }
@media (max-width: 900px) {
  :root { --rail-w: 52px; }
  .rail-label   { display: none; }
  .rail-section { display: none; }
  .rail-item    { justify-content: center; padding: 10px; }
  .rail-dot     { position: absolute; top: 6px; right: 6px; }
  :root { --panel-w: 300px; }
}

/* ── Rec banner ── */
.rec-banner {
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%, rgba(0,212,255,.08) 0%, transparent 100%),
              rgba(0,212,255,.04);
  border-radius: var(--r-md); padding: 10px 12px;
  margin-bottom: 14px; display: flex; align-items: flex-start; gap: 10px;
}
.rec-banner::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(0,212,255,.28) 0%, rgba(255,255,255,.05) 30%,
    rgba(255,255,255,.05) 70%, rgba(0,212,255,.34) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 1;
}
.rec-body { flex: 1; min-width: 0; }
.rec-title { font-size: 12px; font-weight: 600; color: var(--cyan-soft); }
.rec-desc  { font-size: 11px; color: var(--text-mute); margin-top: 2px; line-height: 1.4; }
.rec-dismiss {
  font-size: 16px; color: var(--text-faint); cursor: pointer; flex-shrink: 0;
  transition: color .15s; background: none; border: none;
}
.rec-dismiss:hover { color: var(--text-mute); }

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY & MOTION
═══════════════════════════════════════════════════════════════════════ */
/* ── Touch devices: remove hover-only transforms that cause 300ms ghost taps ── */
@media (hover: none) {
  .gate-card:hover { transform: none; box-shadow: none; }
  .pub-action-btn.primary:hover { transform: none; box-shadow: none; }
  .tb-avatar:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
@media (forced-colors: active) {
  .gate-card, .theme-card, .rec-combo-card, .info-card, .music-selected { border: 2px solid ButtonText; }
  .rcc-btn.primary, .gate-act-btn.primary { forced-color-adjust: none; }
}

/* ── Supplemental — app.js classes ── */
.gate-try-btn  {}
.gate-use-btn  {}
.theme-try-btn {}
.theme-use-btn {}
.interaction-toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.lib-filter-type {}
.lib-filter-mood {}
.sp-conditional {}
[class*="energy-low"]    { border-color: rgba(100,220,120,.2) !important; color: rgba(100,220,120,.7) !important; }
[class*="energy-medium"] { border-color: rgba(255,200,80,.2)  !important; color: rgba(255,200,80,.7)  !important; }
[class*="energy-high"]   { border-color: rgba(255,100,80,.2)  !important; color: rgba(255,100,80,.7)  !important; }

/* ══════════════════════════════════════════════════════════════════════
   APP-PATCH STYLES
   CSS for components rendered by app-patch.js:
   inline placeholder toolbar, gate config editor active states,
   media extras, message extras, fade toggle.
══════════════════════════════════════════════════════════════════════ */

/* gate-act-btn active state (used in gate config + interactive runWhich) */
.gate-act-btn.active {
  background: rgba(124,58,237,.22);
  border-color: rgba(124,58,237,.50);
  color: var(--violet-soft);
}

/* ── Inline [photo]/[voice] placeholder toolbar ── */
.nrs-ph-bar {
  margin: 4px 0 14px;
  padding: 10px 12px;
  position: relative;
  background: radial-gradient(47% 50% at 50% 88%,
    rgba(0,212,255,.07) 0%, transparent 100%),
    rgba(0,212,255,.04);
  border-radius: var(--r-md);
  border: 1px solid rgba(0,212,255,.18);
}
.nrs-ph-bar::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(150deg,
    rgba(0,212,255,.22) 0%, rgba(255,255,255,.04) 30%,
    rgba(255,255,255,.04) 70%, rgba(0,212,255,.28) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

.nrs-ph-insert-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.nrs-ph-label {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  margin-right: 2px;
}
.nrs-ph-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 11px; font-family: monospace;
  background: rgba(124,58,237,.12);
  border: 1px solid rgba(124,58,237,.30);
  color: var(--violet-soft); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.nrs-ph-btn:hover {
  background: rgba(124,58,237,.22);
  border-color: rgba(124,58,237,.50);
}
.nrs-ph-hint {
  font-size: 10px; color: var(--text-faint); font-style: italic; flex: 1;
}
.nrs-ph-locked-note {
  font-size: 11px; color: var(--text-mute); font-style: italic; line-height: 1.4;
}
.nrs-ph-locked-note code {
  background: rgba(255,255,255,.06);
  padding: 1px 5px; border-radius: 4px; color: var(--cyan-soft);
  font-style: normal;
}

/* Active placeholder strip */
.nrs-ph-active {
  display: none; flex-wrap: wrap; align-items: center; gap: 5px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.nrs-ph-strip-label {
  font-size: 10px; color: var(--text-faint);
  letter-spacing: .05em; text-transform: uppercase;
}
.nrs-ph-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 6px; border-radius: var(--r-pill);
  background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.26);
  color: var(--violet-soft); font-size: 11px; font-family: monospace;
}
.nrs-ph-remove {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.35); font-size: 13px; line-height: 1;
  padding: 0 0 0 2px; transition: color .15s;
}
.nrs-ph-remove:hover { color: #ff6b6b; }

/* Media extras note */
.nrs-ph-note {
  font-size: 11px; color: var(--text-mute); font-style: italic;
  margin-bottom: 10px; line-height: 1.5;
}
.nrs-ph-note em { color: var(--cyan-soft); font-style: normal; }
.nrs-ph-note code {
  background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px;
  color: var(--violet-soft); font-style: normal;
}

/* Micro label used inside gate cfg / media cfg editors */
#nrs-gate-cfg .ps-label,
#nrs-media-cfg .ps-label,
#nrs-msg-cfg .ps-label { margin-bottom: 6px; }
#nrs-gate-cfg,
#nrs-media-cfg,
.panel-body.is-switching #nrs-msg-cfg { animation: panelStepIn .22s cubic-bezier(.22,1,.36,1) both; }

/* ── gate-act-btn used inside patch (runWhich toggles) ── */
#nrs-gate-cfg .gate-act-btn,
#nrs-msg-cfg .gate-act-btn {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1);
  color: var(--text-mute); border-radius: var(--r-sm);
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; text-align: center;
}
#nrs-gate-cfg .gate-act-btn:hover,
#nrs-msg-cfg .gate-act-btn:hover { background: rgba(255,255,255,.09); color: var(--text); }
#nrs-gate-cfg .gate-act-btn.active,
#nrs-msg-cfg .gate-act-btn.active {
  background: rgba(124,58,237,.20); border-color: rgba(124,58,237,.45);
  color: var(--violet-soft);
}


/* ── Free user publish info block ── */
.pub-free-info {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.pub-free-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--violet-soft);
  margin-bottom: 6px;
}
.pub-free-body {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
}
/* ═══════════════════════════════════════════════════════════════════════
   ADD ELEMENT TRAY  (generated by app.js renderMessage)
   These classes are missing from the original create.css, which causes
   the SVG plus icon to render at full browser-default size (~300px).
   The fix constrains the SVG and gives the button + drawer proper layout.
═══════════════════════════════════════════════════════════════════════ */
.add-element-row {
  margin-top: 16px;
}

.add-elem-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--glass-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-align: left;
}

.add-elem-btn:hover {
  background: var(--glass-2);
  border-color: var(--border-2);
  color: var(--text);
}

.add-elem-btn[aria-expanded="true"] {
  border-color: rgba(124,58,237,.35);
  background: var(--glass-2);
  color: var(--text);
}

/* THIS is the critical fix — SVG had no size, so it exploded to ~300px */
.add-elem-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--violet-soft);
}

.elem-drawer {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 6px;
  background: rgba(255,255,255,.018);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.elem-drawer.open {
  display: flex;
}

/* .elem-opt, .elem-opt-icon, .elem-opt-name, .elem-opt-desc,
   .elem-opt-lock, .locked-opt  are already defined earlier in this file. */
