/**
 * studio.css
 * Custom styles for the AI Image Studio (supplements Sneat core)
 */

/* ─── Navbar / header avatars ─────────────────────────────────────────────
   Sneat .avatar is a fixed square; img is width/height 100% without object-fit,
   so non-square uploads look squished. Cover + circle keeps faces circular. */
.avatar img,
.navbar-avatar-img,
#navbar-avatar-img,
#sidebar-avatar-img,
#profile-avatar-img {
  object-fit: cover !important;
  object-position: center !important;
  border-radius: 50% !important;
  /* Kill w-px-40 / h-auto leftovers that fight --bs-avatar-size */
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  flex-shrink: 0;
}
/* Header toggle: keep the online ring from clipping oddly */
.layout-navbar .avatar,
.navbar-nav .avatar {
  width: var(--bs-avatar-size, 2.375rem);
  height: var(--bs-avatar-size, 2.375rem);
  flex-shrink: 0;
  overflow: hidden;
}

/* ─── Full-color provider logos (trust / officiality) ───────────────────── */
.provider-logo {
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 0.25rem;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.06);
}
.provider-logo-tile {
  width: 1.35rem;
  height: 1.35rem;
}
.provider-logo-chip {
  width: 1.35rem;
  height: 1.35rem;
}
.provider-logo-header {
  width: 1.15rem;
  height: 1.15rem;
}
.provider-logo-cf-badge {
  width: 1rem;
  height: 1rem;
  opacity: 0.95;
}
.provider-logo-wrap {
  min-height: 1.35rem;
}
/* Navbar / footer trust strip */
.trust-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  color: var(--bs-secondary-color);
  text-decoration: none;
  white-space: nowrap;
}
.trust-badge:hover {
  color: var(--bs-body-color);
  border-color: rgba(243, 128, 32, 0.45);
  background: rgba(243, 128, 32, 0.08);
}
.trust-badge img {
  width: 1rem;
  height: 1rem;
  object-fit: contain;
}

/* ─── Pill theme variables (overridden by studio-theme.js) ──────────────── */
:root {
  --pill-color:       #c77dff;
  --pill-bg:          rgba(199,125,255,0.28);
  --pill-bg-muted:    rgba(199,125,255,0.02);
  --pill-border-muted:rgba(199,125,255,0.13);
  --pill-text-muted:  rgba(199,125,255,0.45);
  --pill-glow-1:      rgba(199,125,255,0.70);
  --pill-glow-2:      rgba(199,125,255,0.32);
}

/* ─── Layout stability ───────────────────────────────────────────────────────
   1. scrollbar-gutter: stable — reserves 15px for the scrollbar permanently so
      it never steals space from content when it appears/disappears.
   2. Kill transition:all on .layout-wrapper — the Sneat template animates every
      CSS property on resize which causes visible jank. Scope to sidebar width only. */
html {
  scrollbar-gutter: stable;
}
.layout-wrapper {
  transition: none !important;
}

/* ─── Two-column studio layout ──────────────────────── */
/* Uses CSS Grid instead of Bootstrap col-md so it works  */
/* correctly inside the Sneat sidebar content area.       */
.studio-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}
/* Grid children must be allowed to shrink below content size — otherwise
   fixed-width flex-shrink-0 children (preset tiles) inflate the 2fr track
   and steal width from the canvas instead of scrolling. */
.studio-two-col > * {
  min-width: 0;
}
@media (min-width: 768px) {
  .studio-two-col {
    /* controls column: flexible 300–420px, output fills the rest */
    grid-template-columns: minmax(300px, 420px) 1fr;
  }
  /* Keep the output canvas pinned while the controls column scrolls */
  .studio-two-col > div:last-child {
    position: sticky;
    top: 6.5rem;
    z-index: 5;
  }
}

/* ─── Sub-tab horizontal scroll on mobile ──────────── */
.studio-subtab-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 1rem;
  padding: 8px 4px; /* prevents box-shadow clipping */
}
.studio-subtab-scroll::-webkit-scrollbar {
  display: none;
}
.studio-subtab-scroll .nav-pills {
  flex-wrap: nowrap;
}

/* ─── Studio mode tab strip (permanent at all widths) ── */
.studio-mobile-tabs {
  gap: 0.25rem;
}
@media (min-width: 768px) {
  /* Desktop: keep the pill bar compact instead of full-bleed */
  .studio-mobile-tabs {
    max-width: 440px;
  }
}
/* Selector bumped to (0,4,0) so this padding also beats core.css's
   `@media (max-width: 767.98px) .nav.nav-pills[role="tablist"] .nav-link
   { padding: 0.35rem 0.75rem }` — otherwise rest padding differs from the
   hover pin below and the strip grows ~1px on hover, shifting the studio. */
.nav.studio-mobile-tabs[role="tablist"] .nav-link {
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--bs-border-radius);
}
.studio-mobile-tabs .nav-link.active {
  /* Prefer pill theme / primary over hardcoded purple */
  background: linear-gradient(
    135deg,
    var(--pill-color, #7c3aed) 0%,
    color-mix(in srgb, var(--pill-color, #a78bfa) 55%, #fff) 100%
  );
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 12px var(--pill-glow-2, rgba(199, 125, 255, 0.32));
}

/* Kill blinking text carets on pills/tabs/radios. Focused .btn-check radios and
   nav-links can paint a caret on the strip / aspect row (seen next to Music and
   on ratio pills). Real text fields keep a normal caret below. */
.studio-mobile-tabs .nav-link,
.studio-two-col .btn,
.studio-two-col .btn-check,
.studio-two-col label.btn,
#t2i-toolbar .btn,
#t2v-toolbar .btn,
#img-aspect-group .btn,
#img-aspect-group .btn-check,
.preset-style-card,
.style-action-menu .btn {
  caret-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.studio-two-col textarea,
.studio-two-col input[type="text"],
.studio-two-col input[type="number"],
.studio-two-col input[type="search"],
.studio-two-col input:not([type]).form-control,
.studio-two-col .form-control:not(.btn),
.studio-two-col .form-select {
  caret-color: auto;
  user-select: text;
  -webkit-user-select: text;
}
/* Ensure bootstrap btn-check radios never leave a visible caret box */
.studio-two-col .btn-check {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

/* ─── Canvas Card ───────────────────────────────────── */
.studio-canvas-card .card-body {
  min-height: 480px;
  background-color: var(--bs-body-bg);
  background-image:
    radial-gradient(circle, rgba(105, 108, 255, 0.04) 1px, transparent 1px);
  background-size: 20px 20px;
  transition: background-color 0.3s ease;
}

/* ─── Skeleton Loading Animation ────────────────────── */
.studio-skeleton-pulse {
  background: linear-gradient(
    -45deg,
    rgba(105, 108, 255, 0.06),
    rgba(105, 108, 255, 0.12),
    rgba(105, 108, 255, 0.06),
    rgba(105, 108, 255, 0.12)
  );
  background-size: 400% 400%;
  animation: skeletonShimmer 2.4s ease-in-out infinite;
  border-radius: var(--bs-border-radius);
}

@keyframes skeletonShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Particle layer: full body, above skeleton, never covered by theater */
.generation-particle-canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 5 !important;
  pointer-events: none !important;
  /* JS sets opacity:1 on start; default hidden when idle */
}

/* Ensure output body has size while loading so the absolute particle canvas isn't 0×0 */
[id$="canvas-body"],
#canvas-body {
  min-height: 280px;
  overflow: hidden;
}
[id$="canvas-loading"]:not(.d-none) {
  position: relative;
  z-index: 1;
}

/* ─── Generation Theater (footer status strip) ────────
   Lives in card-footer, not body. Body keeps skeleton +
   particle canvas (z-index: 5) unobstructed. */
.canvas-theater-status {
  /* Normal document flow inside .card-footer — never overlay body */
  width: 100%;
  pointer-events: none;
  color: var(--bs-body-color);
  padding: 0.45rem 0.35rem 0.2rem;
  border-radius: 0.5rem;
  background: linear-gradient(
    180deg,
    rgba(var(--bs-primary-rgb), 0.08) 0%,
    rgba(var(--bs-primary-rgb), 0.02) 55%,
    transparent 100%
  );
}

.canvas-theater-status .progress {
  width: 100%;
  height: 5px;
  background-color: rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.canvas-theater-status .progress-bar {
  transition: width 0.45s ease;
  border-radius: 999px;
}

.canvas-theater-status [id$="theater-stage"] {
  color: var(--pill-color, var(--bs-primary));
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─── Prompt cards (premium label + consistent textarea) ─ */
.studio-prompt-card {
  border: 1px solid rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--pill-color, #696cff) 6%, transparent) 0%,
      rgba(255, 255, 255, 0.02) 48%,
      transparent 100%
    ),
    rgba(255, 255, 255, 0.02);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.studio-prompt-card > .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.studio-prompt-card > .card-header .card-title {
  letter-spacing: 0.01em;
  font-weight: 650;
}
.studio-prompt-card > .card-header .card-title .bx {
  color: var(--pill-color, var(--bs-primary));
  opacity: 0.92;
}
.prompt-char-count {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--bs-secondary-color, rgba(255, 255, 255, 0.45));
  min-width: 2.25rem;
  text-align: right;
  user-select: none;
}
.prompt-char-count.is-warm {
  color: #ffab00;
}
.prompt-char-count.is-hot {
  color: #ea5455;
}
.studio-prompt-ta,
#ai-prompt,
#vid-prompt,
#music-prompt {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
  font-size: 0.925rem;
}
#music-prompt {
  min-height: 110px;
}
.studio-prompt-ta:focus,
#ai-prompt:focus,
#vid-prompt:focus,
#music-prompt:focus {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--pill-color, #696cff) 35%, transparent),
    0 0 18px rgba(105, 108, 255, 0.28) !important;
}

/* ─── Result action icon group ──────────────────────── */
.canvas-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem !important;
}
.canvas-actions .btn {
  border-radius: 0.5rem;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.canvas-actions .btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.canvas-actions .btn-icon .bx {
  font-size: 1.05rem;
  line-height: 1;
}
.canvas-actions .btn-send-to-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding-inline: 0.65rem;
  height: 2rem;
  font-size: 0.78rem;
  font-weight: 600;
}
@media (max-width: 575.98px) {
  .canvas-actions .canvas-action-label {
    display: none;
  }
  .canvas-actions .btn-send-to-edit {
    width: 2rem;
    padding: 0;
    justify-content: center;
  }
  .canvas-actions .btn-send-to-edit .me-1 {
    margin-right: 0 !important;
  }
}

/* ─── Result Image ──────────────────────────────────── */
.studio-result-image {
  max-height: 600px;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.studio-result-image:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

/* Short fade+scale when a generation result is shown (JS toggles class) */
@keyframes resultIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.studio-result-reveal {
  animation: resultIn 0.28s ease;
}

/* ─── Generate Button: Rainbow Glass ────────────────── */
@keyframes btnRainbowGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes btnRainbowGlow {
  0%   { box-shadow: 0 0 10px rgba(105, 108, 255, 0.4), 0 0 2px rgba(105, 108, 255, 0.2); }
  33%  { box-shadow: 0 0 15px rgba(113, 221, 55, 0.4), 0 0 5px rgba(113, 221, 55, 0.2); }
  66%  { box-shadow: 0 0 15px rgba(3, 195, 236, 0.4), 0 0 5px rgba(3, 195, 236, 0.2); }
  100% { box-shadow: 0 0 10px rgba(105, 108, 255, 0.4), 0 0 2px rgba(105, 108, 255, 0.2); }
}

#btn-generate,
#btn-img2img,
#btn-txt2vid,
#btn-img2vid,
#btn-vid2vid,
#btn-txt2music {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-image: linear-gradient(135deg, #696cff, #71dd37, #03c3ec, #696cff) !important;
  background-size: 300% 300% !important;
  /* Never use transition:all here — it re-animates layout-affecting props and feels like the page twitches */
  transition: transform 0.4s ease, box-shadow 0.4s ease, opacity 0.4s ease, border-color 0.4s ease, filter 0.4s ease;
  z-index: 1;
}

#btn-generate:not(:disabled),
#btn-img2img:not(:disabled),
#btn-txt2vid:not(:disabled),
#btn-img2vid:not(:disabled),
#btn-vid2vid:not(:disabled),
#btn-txt2music:not(:disabled) {
  animation: btnRainbowGradient 10s ease infinite !important;
}

#btn-generate:not(:disabled):hover,
#btn-img2img:not(:disabled):hover,
#btn-txt2vid:not(:disabled):hover,
#btn-img2vid:not(:disabled):hover,
#btn-vid2vid:not(:disabled):hover,
#btn-txt2music:not(:disabled):hover {
  transform: translateY(-1px);
  animation: btnRainbowGradient 3s ease infinite, btnRainbowGlow 3s linear infinite !important;
  box-shadow: 0 8px 25px rgba(105, 108, 255, 0.5);
}

#btn-generate:disabled,
#btn-img2img:disabled,
#btn-txt2vid:disabled,
#btn-img2vid:disabled,
#btn-vid2vid:disabled,
#btn-txt2music:disabled {
  background: #434456 !important;
  border-color: rgba(255, 255, 255, 0.05);
  cursor: not-allowed;
  opacity: 0.7;
}

#btn-generate i,
#btn-img2img i,
#btn-txt2vid i,
#btn-img2vid i,
#btn-vid2vid i,
/* Provider mark on primary generate CTA — keep natural brand colors (no invert) */
#btn-txt2music-text .provider-logo {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.25rem;
}

/* Music multi-model tiles (stepping stone to full modal/accordion) */
.music-model-tile {
  border-radius: 0.65rem;
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.music-model-tile.active {
  box-shadow: 0 0 0 1px rgba(105, 108, 255, 0.45);
  background: rgba(105, 108, 255, 0.08);
}
.music-model-tile .provider-logo {
  width: 1.35rem;
  height: 1.35rem;
}

#btn-txt2music i {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ─── Model chip names — gradient accent ─────────────── */
#model-chip-name,
#vid-model-chip-name,
#i2i-model-chip-name {
  background: linear-gradient(90deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Model Badge Transitions ───────────────────────── */
#model-tier-badge .badge {
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}


/* ─── Phase 2: Frosted Glass Form controls ───────────
   NOTE: studio.css is also linked from pricing/profile/dashboard/reset.
   These unscoped form rules intentionally theme those pages too.
   Prefer new studio-only rules under .studio-two-col / #t2i-* / #t2v-*. */
.form-control, .form-select, .input-group-text {
  background-color: rgba(50, 50, 73, 0.6) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--bs-body-color) !important;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease !important;
}

/* No transform here — a translateY lift on focus reads as the whole
   form twitching when you click into the prompt box. Glow only. */
.form-control:focus, .form-select:focus {
  background-color: rgba(60, 60, 85, 0.8) !important;
  border-color: rgba(105, 108, 255, 0.5) !important;
  box-shadow: 0 0 15px rgba(105, 108, 255, 0.2) !important;
}
/* core.css shrinks padding ~2px on focus to offset a border-width: 2px
   that our `border: 1px !important` above blocks — so the control got
   shorter on focus and everything below it jumped. Repin base padding. */
.form-control:focus {
  padding-block: calc(0.543rem - var(--bs-border-width));
  padding-inline: calc(0.9375rem - var(--bs-border-width));
}
.form-select:focus, .form-select:focus-within {
  background-position: right 0.9375rem center;
  padding-block: calc(0.543rem - var(--bs-border-width));
  padding-inline-end: calc(2.625rem - var(--bs-border-width));
  padding-inline-start: calc(0.9375rem - var(--bs-border-width));
}

/* Custom Range Sliders */
.form-range::-webkit-slider-runnable-track {
  background: rgba(255, 255, 255, 0.05);
  height: 6px;
  border-radius: 10px;
}

.form-range::-webkit-slider-thumb {
  background: #696cff;
  box-shadow: 0 0 10px rgba(105, 108, 255, 0.6);
  border: 2px solid #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-top: -6px; /* Center thumb on track */
}

.form-range:active::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 20px rgba(105, 108, 255, 0.8);
}

/* Covers ALL radio-style pills across every studio tab/toolbar —
   scoped to .studio-two-col so action buttons outside it are unaffected */
.studio-two-col .btn-group .btn-check + .btn-outline-primary {
  background: var(--pill-bg-muted);
  border-color: var(--pill-border-muted);
  color: var(--pill-text-muted);
  backdrop-filter: blur(4px);
}

/* ─── Prompt collapse ──────────────────────────────── */
/* Exactly ONE line, every browser (mobile included): anything past the
   first line is hidden behind an ellipsis so the modal height — and the
   prev/next arrows — never move when navigating between items. */
.prompt-clamped {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Expanded state stays bounded: full prompt scrolls inside a fixed box
   instead of growing the modal. */
#lightbox-prompt:not(.prompt-clamped) {
  max-height: 4.5em;
  overflow-y: auto;
}

/* ─── Phase 3: History Drawer Polish ───────────────── */
#historyOffcanvas {
  background-color: rgba(8, 12, 26, 0.97) !important;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#historyOffcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 12, 26, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#historyOffcanvas .offcanvas-header .btn-close {
  position: relative;
  z-index: 31;
  opacity: 0.85;
  flex-shrink: 0;
}
/* Card overlays stay below the offcanvas close header */
#historyOffcanvas .history-card-overlay {
  z-index: 5;
}

#historyOffcanvas .history-card {
  background-color: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  transition: all 0.2s ease;
  margin-bottom: 0 !important;
  border-radius: 10px !important;
  overflow: hidden;
  cursor: pointer;
  /* Tall tiles: ~9:16 at the drawer's ~180px column width, so portrait
     generations show nearly uncropped */
  height: 320px;
  position: relative;
}

/* Inner wrapper must fill the card */
#historyOffcanvas .history-card > .position-relative {
  width: 100%;
  height: 100% !important;
}

/* Images and videos fill the card with cover crop */
#historyOffcanvas .history-card img,
#historyOffcanvas .history-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#historyOffcanvas .history-card:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(105, 108, 255, 0.3) !important;
  box-shadow: 0 4px 15px rgba(105, 108, 255, 0.15);
  transform: translateY(-4px);
}

/* History: 2-column grid layout */
#history-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  padding: 8px !important;
}
#history-empty-state {
  grid-column: 1 / -1;
  padding: 2.75rem 1.25rem;
  border-radius: 0.75rem;
  background: radial-gradient(
    ellipse at 50% 35%,
    rgba(var(--bs-primary-rgb), 0.08) 0%,
    transparent 70%
  );
}
#history-empty-state > i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 0.85rem !important;
  border-radius: 50%;
  font-size: 1.65rem !important;
  color: var(--bs-secondary-color);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0.9 !important;
  box-shadow:
    0 0 0 6px rgba(var(--bs-primary-rgb), 0.04),
    inset 0 0 16px rgba(var(--bs-primary-rgb), 0.06);
}
#history-empty-state > p {
  margin-bottom: 0;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}

/* Bulk selection bar (id in EJS; .history-bulk-bar optional class alias) */
#history-bulk-actions,
.history-bulk-bar {
  background: rgba(8, 12, 26, 0.78) !important;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
#history-bulk-actions .form-check-label,
.history-bulk-bar .form-check-label {
  color: var(--bs-heading-color, var(--bs-body-color));
}
#history-bulk-actions .btn,
.history-bulk-bar .btn {
  min-width: 2rem;
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Card action overlay — bottom of tile only (never the offcanvas X) */
.history-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: auto;
  height: auto;
  max-height: 42%;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 6px;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 5;
}
.history-card:hover .history-card-overlay {
  opacity: 1;
  pointer-events: auto;
}
/* Touch devices: always show download/delete/send-edit (no hover) */
@media (hover: none) {
  .history-card-overlay {
    opacity: 1;
    pointer-events: auto;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.25) 65%, transparent 100%);
  }
}

/* History count badge on #history-btn */
#history-count-badge,
.history-count-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  border-radius: 999px;
  background: var(--bs-primary, #696cff);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(var(--bs-body-bg-rgb, 32, 33, 46), 0.9);
  pointer-events: none;
}

/* Neon green download button */
.history-dl-btn {
  border: 1px solid rgba(40, 199, 111, 0.4);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(40, 199, 111, 0.15);
  color: #28c76f;
  box-shadow: 0 0 6px rgba(40, 199, 111, 0.5);
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}
.history-dl-btn:hover {
  background: rgba(40, 199, 111, 0.35);
  box-shadow: 0 0 12px rgba(40, 199, 111, 0.8);
  transform: scale(1.12);
  color: #28c76f;
}

/* Neon red delete button */
.history-del-btn {
  border: 1px solid rgba(234, 84, 85, 0.4);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(234, 84, 85, 0.15);
  color: #ea5455;
  box-shadow: 0 0 6px rgba(234, 84, 85, 0.5);
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}
.history-del-btn:hover {
  background: rgba(234, 84, 85, 0.35);
  box-shadow: 0 0 12px rgba(234, 84, 85, 0.8);
  transform: scale(1.12);
  color: #ea5455;
}

/* History button neon glow when panel is open */
#history-btn.history-btn-active {
  background: rgba(105, 108, 255, 0.15) !important;
  border-color: rgba(105, 108, 255, 0.6) !important;
  box-shadow: 0 0 10px rgba(105, 108, 255, 0.5), 0 0 20px rgba(105, 108, 255, 0.2) !important;
  color: #696cff !important;
}
#history-btn.history-btn-generating {
  border-color: rgba(105, 108, 255, 0.75) !important;
  color: #696cff !important;
  animation: history-glow-pulse 1.5s infinite;
}
#history-btn.history-btn-success {
  background: rgba(40, 199, 111, 0.15) !important;
  border-color: #28c76f !important;
  color: #28c76f !important;
  box-shadow: 0 0 12px rgba(40, 199, 111, 0.6) !important;
  transition: all 0.3s ease;
}
@keyframes history-glow-pulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(105, 108, 255, 0.3);
    background: rgba(105, 108, 255, 0.05);
  }
  50% {
    box-shadow: 0 0 12px rgba(105, 108, 255, 0.65), 0 0 20px rgba(105, 108, 255, 0.25);
    background: rgba(105, 108, 255, 0.18);
  }
}

/* ─── Model Tile Custom Styling ────────────────────── */
.custom-option-icon {
  background: rgba(49, 49, 105, 0.4) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: .75px solid rgba(255, 255, 255, 0.08) !important;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
  border-radius: .5rem !important; /* Soft, pill-like rounding */
  aspect-ratio: 1 / 1; /* Force perfect square */
  display: flex !important;
  align-items: top;
  justify-content: center;
}

.custom-option-icon:hover {
  transform: translateY(-5px);
  background: rgba(105, 108, 255, 0.1) !important;
  border-color: rgba(105, 108, 255, 0.4) !important;
}

.custom-option-icon.checked {
  background: rgba(105, 108, 255, 0.1) !important;
  border: none !important;
  position: relative;
  z-index: 1;
}

/* Selected Tile Rainbow Border Animation */
.custom-option-icon.checked::before {
  content: "";
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
  background-size: 400%;
  z-index: -1;
  filter: blur(5px);
  animation: rainbow-glow 20s linear infinite;
  border-radius: 1.5rem; /* Match the softer rounding */
  opacity: 0.6;
}

.custom-option-icon.checked .custom-option-title {
  color: #fff !important;
  text-shadow: 0 0 10px rgba(105, 108, 255, 0.8);
}

.custom-option-icon i {
  font-size: 1.5rem !important;
  color: rgba(255, 255, 255, 0.6);
}

.custom-option-icon.checked i {
  color: #696cff !important;
}

/* ─── Responsive Adjustments ────────────────────────── */
@media (max-width: 991.98px) {
  .studio-canvas-card .card-body {
    min-height: 320px;
  }
}

@media (max-width: 575.98px) {
  .studio-canvas-card .card-body {
    min-height: 240px;
  }

  #t2i-toolbar .btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }
}

/* ─── Lightbox Modal Top Bar & Info Panel ────────────── */
body:has(#imageLightboxModal.show) .modal-backdrop {
  background-color: rgba(2, 4, 12, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lb-modal-shell {
  filter: drop-shadow(0 18px 48px rgba(0, 0, 0, 0.55));
  position: relative;
  z-index: 1;
  overflow: hidden;
}
.lb-topbar {
  position: relative;
  z-index: 40; /* above media edge zones (z 15–20) — actions always clickable */
  background: linear-gradient(
    180deg,
    rgba(12, 16, 32, 0.98) 0%,
    rgba(8, 12, 26, 0.96) 100%
  );
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  gap: 0.5rem;
  flex-wrap: nowrap;
}
.lb-topbar-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.lb-topbar-actions {
  position: relative;
  z-index: 41;
  flex: 0 0 auto;
  margin-left: auto;
}
.lb-action-divider {
  width: 1px;
  height: 1.25rem;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 0.15rem;
  flex-shrink: 0;
}
.lb-close-btn {
  flex-shrink: 0 !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  /* Isolated from neon DL/delete so it never “disappears” under them */
  position: relative;
  z-index: 42;
}
.lb-title-text {
  font-size: 0.88rem;
}
.lb-meta-text {
  font-size: 0.8rem;
}
.lb-sep {
  font-size: 0.75rem;
}
.lb-media-stage {
  position: relative;
  z-index: 1; /* keep under topbar so nav zones never cover close/actions */
  background: rgba(3, 5, 14, 0.92);
  height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Edge click zones must stay inside media stage — never bleed into topbar */
#lightbox-zone-prev,
#lightbox-zone-next {
  max-height: 100%;
  top: 0 !important;
  bottom: 0 !important;
}
.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #696cff, #9b59b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.78rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.lb-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  font-size: 1.15rem;
}
.lb-action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
}
.lb-dl-btn {
  background: rgba(40, 199, 111, 0.18);
  color: #28c76f;
  border-color: rgba(40, 199, 111, 0.4);
  box-shadow: 0 0 8px rgba(40, 199, 111, 0.25);
}
.lb-dl-btn:hover {
  background: rgba(40, 199, 111, 0.38);
  box-shadow: 0 0 16px rgba(40, 199, 111, 0.65);
  color: #28c76f;
  border-color: rgba(40, 199, 111, 0.7);
  transform: scale(1.08);
}
.lb-del-btn {
  background: rgba(234, 84, 85, 0.12);
  color: rgba(234, 84, 85, 0.75);
  border-color: rgba(234, 84, 85, 0.25);
}
.lb-del-btn:hover {
  background: rgba(234, 84, 85, 0.3);
  box-shadow: 0 0 12px rgba(234, 84, 85, 0.6);
  color: #ea5455;
  border-color: rgba(234, 84, 85, 0.6);
  transform: scale(1.08);
}
.lb-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.lb-infopanel {
  background: rgba(8, 12, 26, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0 0 12px 12px;
}

/* ─── White tooltips ────────────────────────────────── */
.tooltip .tooltip-inner {
  background-color: #fff;
  color: #1a1b2e;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
}
.tooltip .tooltip-arrow::before,
.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: #fff;
}
.bs-tooltip-bottom .tooltip-arrow::before {
  border-bottom-color: #fff;
}
.bs-tooltip-start .tooltip-arrow::before {
  border-left-color: #fff;
}
.bs-tooltip-end .tooltip-arrow::before {
  border-right-color: #fff;
}

/* ─── Glow system ───────────────────────────────────── */
@keyframes aihub-pulse {
  0%, 100% {
    box-shadow:
      0 0 10px rgba(var(--bs-primary-rgb), 0.35),
      0 0 30px rgba(var(--bs-primary-rgb), 0.12);
  }
  50% {
    box-shadow:
      0 0 16px rgba(var(--bs-primary-rgb), 0.55),
      0 0 48px rgba(var(--bs-primary-rgb), 0.22);
  }
}

/* Soft hover glow — scoped to generate CTAs + intentional classes
   (not every .btn, so toolbar/outline pills stay calm). */
#btn-generate:hover:not(:disabled),
#btn-img2img:hover:not(:disabled),
#btn-txt2vid:hover:not(:disabled),
#btn-img2vid:hover:not(:disabled),
#btn-vid2vid:hover:not(:disabled),
#btn-txt2music:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn.btn-glow:hover:not(:disabled) {
  box-shadow: 0 0 10px rgba(var(--bs-primary-rgb), 0.3);
}
.btn-outline-secondary:hover:not(:disabled) {
  box-shadow: 0 0 8px rgba(var(--bs-secondary-rgb), 0.35);
}
.btn-outline-warning:hover:not(:disabled) {
  box-shadow: 0 0 8px rgba(var(--bs-warning-rgb), 0.4);
}
.btn-outline-danger:hover:not(:disabled) {
  box-shadow: 0 0 8px rgba(var(--bs-danger-rgb), 0.4);
}

/* Selected segmented options (aspect / size / quality / format radios) */
.btn-check:checked + .btn {
  box-shadow: 0 0 9px rgba(var(--bs-primary-rgb), 0.5);
}
.btn-check:checked + .btn-outline-warning {
  box-shadow: 0 0 9px rgba(var(--bs-warning-rgb), 0.5);
}

/* Model tiles + preset tiles
   Selected model/vid tiles: static primary ring + soft glow (not rainbow).
   Style presets / Quick Start keep rainbow via .preset-style-card.selected
   and .preset-tile.selected-tile further below. */
.model-tile,
.vid-model-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-height: 5.25rem;
  padding: 0.65rem 0.75rem !important;
  /* room for top-right token badge ("N tokens") */
  padding-right: 4.5rem !important;
  cursor: pointer;
  border-radius: 0.5rem !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  background: rgba(255, 255, 255, 0.025);
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease,
    transform 0.15s ease;
}
.preset-tile {
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
}
.model-tile:hover,
.vid-model-tile:hover {
  border-color: rgba(var(--bs-primary-rgb), 0.45) !important;
  background: rgba(var(--bs-primary-rgb), 0.06);
  box-shadow: 0 0 14px rgba(var(--bs-primary-rgb), 0.28);
  transform: translateY(-1px);
}
.preset-tile:hover {
  box-shadow: 0 0 12px rgba(var(--bs-primary-rgb), 0.35);
  transform: translateY(-1px);
}
/* Model selected: static primary ring + soft glow — !important beats
   residual inline border/background JS may still set on click. */
.model-tile.selected-tile,
.vid-model-tile.selected-tile {
  border-color: var(--bs-primary) !important;
  background: rgba(var(--bs-primary-rgb), 0.12) !important;
  box-shadow:
    0 0 0 1.5px var(--bs-primary),
    0 0 16px rgba(var(--bs-primary-rgb), 0.38) !important;
  animation: none !important;
  transform: none;
}
.model-tile.selected-tile:hover,
.vid-model-tile.selected-tile:hover {
  border-color: var(--bs-primary) !important;
  background: rgba(var(--bs-primary-rgb), 0.14) !important;
  box-shadow:
    0 0 0 1.5px var(--bs-primary),
    0 0 18px rgba(var(--bs-primary-rgb), 0.45) !important;
  transform: none;
}
/* Category / tier badges on tiles */
.model-tile > .badge:not(.model-token-cost),
.vid-model-tile > .badge:not(.model-token-cost) {
  margin-top: 0.3rem;
  font-size: 0.6rem !important;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.model-tile .fw-semibold,
.vid-model-tile .fw-semibold {
  line-height: 1.25;
  padding-right: 0.15rem;
}
.model-tile .text-muted,
.vid-model-tile .text-muted {
  line-height: 1.3;
  font-size: 0.68rem !important;
}
.model-tile .provider-logo-wrap,
.vid-model-tile .provider-logo-wrap {
  margin-bottom: 0.2rem !important;
}

/* Model select chips: full name next to logo; short tier badge only (never truncate name) */
.studio-model-chip {
  gap: 0.5rem;
  min-height: 2.75rem;
  white-space: normal;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(255, 255, 255, 0.1) !important;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}
.studio-model-chip:hover {
  border-color: color-mix(in srgb, var(--pill-color, #696cff) 60%, transparent) !important;
  background: rgba(var(--bs-primary-rgb), 0.07);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--pill-color, #696cff) 18%, transparent);
}
.studio-model-chip:focus-visible {
  outline: none;
  border-color: var(--pill-color, var(--bs-primary)) !important;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--pill-color, #696cff) 35%, transparent),
    0 0 16px color-mix(in srgb, var(--pill-color, #696cff) 22%, transparent);
}
.studio-model-chip-main {
  flex: 1 1 auto;
  min-width: 0;
  /* allow full model title to show / wrap — no text-truncate */
}
.studio-model-chip-name {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.3;
  overflow: visible;
  text-overflow: unset;
  max-width: 100%;
}
.studio-model-chip-meta {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 0.15rem;
}
.studio-model-chip-meta .badge {
  max-width: 7.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Token-cost badges on individual model tiles — pinned top-right for alignment */
.model-token-cost {
  font-size: 0.62rem !important;
  font-weight: 700;
  opacity: 1;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}
.model-tile .model-token-cost,
.vid-model-tile .model-token-cost {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
  padding: 0.2rem 0.45rem;
  max-width: 4.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0.35rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.model-tile.selected-tile .model-token-cost,
.vid-model-tile.selected-tile .model-token-cost {
  box-shadow:
    0 0 0 1px rgba(var(--bs-primary-rgb), 0.35),
    0 1px 6px rgba(var(--bs-primary-rgb), 0.25);
}

/* ─── Model picker modals (T2I / I2I / Video) ───────────────────────────── */
#modelPickerModal .modal-header,
#i2iModelPickerModal .modal-header,
#vidModelPickerModal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
#modelPickerModal .modal-title,
#i2iModelPickerModal .modal-title,
#vidModelPickerModal .modal-title {
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
#modelPickerModal .modal-title i,
#i2iModelPickerModal .modal-title i,
#vidModelPickerModal .modal-title i {
  color: var(--bs-primary);
  opacity: 0.95;
}
#modelPickerModal .modal-body,
#i2iModelPickerModal .modal-body,
#vidModelPickerModal .modal-body {
  padding-top: 0.85rem;
}

/* Sticky search in T2I model picker (modal-body is the scroll container) */
#model-search {
  position: sticky;
  top: 0;
  z-index: 6;
  margin-bottom: 0.75rem !important;
  padding: 0.45rem 0.75rem;
  background: var(--bs-modal-bg, var(--bs-body-bg));
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 12px -8px rgba(0, 0, 0, 0.45);
}
#model-search:focus {
  border-color: rgba(var(--bs-primary-rgb), 0.55);
  box-shadow:
    0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.2),
    0 8px 12px -8px rgba(0, 0, 0, 0.45);
}

/* Accordion headers in T2I model grid */
#model-grid.accordion {
  --bs-accordion-border-color: rgba(255, 255, 255, 0.07);
  --bs-accordion-bg: transparent;
  --bs-accordion-btn-bg: transparent;
  --bs-accordion-active-bg: rgba(var(--bs-primary-rgb), 0.08);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.18);
}
#model-grid .accordion-item {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.07);
  margin-bottom: 0.15rem;
  border-radius: 0.45rem !important;
  overflow: hidden;
}
#model-grid .accordion-button {
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  padding: 0.55rem 0.85rem !important;
  gap: 0.15rem;
  color: var(--bs-body-color);
  box-shadow: none !important;
  min-height: 2.4rem;
}
#model-grid .accordion-button:not(.collapsed) {
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.08) !important;
}
#model-grid .accordion-button::after {
  width: 0.9rem;
  height: 0.9rem;
  background-size: 0.9rem;
  opacity: 0.7;
}
#model-grid .accordion-button .provider-logo-header,
#model-grid .accordion-button > i {
  flex-shrink: 0;
}
#model-grid .accordion-body {
  padding: 0.45rem 0.55rem 0.65rem !important;
  background: rgba(0, 0, 0, 0.12);
}

/* Horizontal scroll strip for video (and I2I) brand/tier pills + fade edges */
.model-tier-nav-scroll {
  position: relative;
  margin-bottom: 0.85rem;
}
.model-tier-nav-scroll::before,
.model-tier-nav-scroll::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0.15rem;
  width: 1.4rem;
  z-index: 2;
  pointer-events: none;
}
.model-tier-nav-scroll::before {
  left: 0;
  background: linear-gradient(
    to right,
    var(--bs-modal-bg, var(--bs-body-bg)) 0%,
    transparent 100%
  );
}
.model-tier-nav-scroll::after {
  right: 0;
  background: linear-gradient(
    to left,
    var(--bs-modal-bg, var(--bs-body-bg)) 0%,
    transparent 100%
  );
}
#vid-model-tier-nav,
#i2i-model-tier-nav {
  display: flex;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0 !important;
  padding: 0.15rem 0.65rem 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
#vid-model-tier-nav::-webkit-scrollbar,
#i2i-model-tier-nav::-webkit-scrollbar {
  height: 4px;
}
#vid-model-tier-nav::-webkit-scrollbar-thumb,
#i2i-model-tier-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}
#vid-model-tier-nav .nav-item,
#i2i-model-tier-nav .nav-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
}
#vid-model-tier-nav .nav-link,
#i2i-model-tier-nav .nav-link {
  white-space: nowrap;
  font-size: 0.75rem !important;
  font-weight: 600;
  padding: 0.3rem 0.65rem !important;
  border-radius: 999px;
  line-height: 1.2;
  border: 1px solid transparent;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease;
}
#vid-model-tier-nav .nav-link:not(.active),
#i2i-model-tier-nav .nav-link:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--bs-secondary-color);
}
#vid-model-tier-nav .nav-link:not(.active):hover,
#i2i-model-tier-nav .nav-link:not(.active):hover {
  background: rgba(var(--bs-primary-rgb), 0.1);
  border-color: rgba(var(--bs-primary-rgb), 0.3);
  color: var(--bs-body-color);
  padding-block-end: 0.3rem !important; /* override core.css pill hover growth */
}
#vid-model-tier-nav .nav-link.active,
#i2i-model-tier-nav .nav-link.active {
  box-shadow: 0 0 10px rgba(var(--bs-primary-rgb), 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .model-tile,
  .vid-model-tile {
    transform: none !important;
  }
}

/* Accessibility: no animation for users who opt out of motion */
@media (prefers-reduced-motion: reduce) {
  #btn-generate,
  #btn-img2img,
  #btn-txt2vid,
  #btn-img2vid,
  #btn-vid2vid,
  #btn-txt2music {
    animation: none;
    box-shadow: 0 0 12px rgba(var(--bs-primary-rgb), 0.4);
  }
  .model-tile,
  .vid-model-tile,
  .preset-tile,
  .btn {
    transition: none;
  }

  /* Theater / result: no reveal motion; keep stage UI static */
  .studio-result-reveal {
    animation: none;
  }
  .canvas-theater-status .progress-bar {
    transition: none;
  }
  .studio-skeleton-pulse {
    animation: none;
  }
  .pulse-dot {
    animation: none;
  }
  /* Do NOT force particle canvas opacity:0 — the orb animation is intentional product UI */
}

/* ─── Preset strip carousel ─────────────────────────── */
#preset-strip {
  scrollbar-width: none;
  scroll-behavior: smooth;
}
#preset-strip::-webkit-scrollbar {
  display: none;
}
.preset-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  font-size: 1.1rem;
  background: rgba(8, 12, 26, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.preset-arrow:hover {
  background: rgba(var(--bs-primary-rgb), 0.85);
  box-shadow: 0 0 10px rgba(var(--bs-primary-rgb), 0.5);
}
#preset-prev { left: 0.35rem; }
#preset-next { right: 0.35rem; }
@media (hover: none) {
  /* Touch devices swipe natively — arrows are noise */
  .preset-arrow { display: none !important; }
}

/* Ratio row: only supported pills are rendered in JS. Reserve ~2 pill rows so
   switching models (e.g. 10 ratios → 3) does not collapse height / jump the
   toolbar or create a scrollbar. */
#img-aspect-group {
  min-height: 4.5rem; /* ~2 rows of sm pills + gap */
  align-content: flex-start;
}

/* ─── T2I / T2V compact settings toolbars ───────────── */
#t2i-toolbar,
#t2v-toolbar {
  flex-wrap: wrap;
  row-gap: 0.5rem;
  column-gap: 0.5rem;
  align-content: flex-start;
  min-width: 0;
  /* One pill-row floor so optional groups toggling display:none cannot collapse the strip to zero */
  min-height: 2.25rem;
}
/* Bootstrap btn-groups are nowrap by default — let them wrap so the
   ratio pills never overflow the card into the canvas column */
#t2i-toolbar .btn-group,
#t2v-toolbar .btn-group {
  flex-wrap: wrap;
}
#t2i-toolbar .btn,
#t2v-toolbar .btn {
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  white-space: nowrap;
}
#t2i-toolbar .form-select,
#t2v-toolbar .form-select {
  font-size: 0.72rem;
}
/* Ratio + res groups can wrap as units; Advanced drops to next line on mid widths */
#t2v-toolbar > #vid-aspect-wrapper,
#t2v-toolbar > #vid-resolution-wrapper {
  min-width: 0;
}
#t2v-toolbar > #btn-vid-advanced {
  margin-left: auto;
}
/* Size and Quality each get their own full-width row in the toolbar so
   their pills line up under the Ratio row (Format shares its row with
   the right-aligned Advanced button). */
#t2i-toolbar #size-group,
#t2i-toolbar #quality-group {
  width: 100%;
}
/* Tiny group captions — fixed width so every row's pills start at the
   same x (RATIO / SIZE / QUALITY / FORMAT all line up) */
.toolbar-lbl {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  flex-shrink: 0;
  align-self: center;
  min-width: 3.2rem;
  display: inline-block;
}
/* Aspect-ratio orientation shape — revealed on the SELECTED pill only */
.ar-shape {
  display: none;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: -2px;
}
.btn-check:checked + .btn .ar-shape {
  display: inline-block;
}

/* Bleed containment + elevated control cards inside the studio grid.
   Optional .studio-card-primary (document for EJS later) = slightly stronger emphasis. */
.studio-two-col .card {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  background-color: rgba(var(--bs-paper-bg-rgb, 30, 30, 48), 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
/* Stronger control card — add class in EJS when a panel should read as primary */
.studio-two-col .card.studio-card-primary {
  border-color: color-mix(in srgb, var(--pill-color, #696cff) 35%, rgba(255, 255, 255, 0.08));
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--pill-color, #696cff) 10%, transparent) 0%,
      rgba(var(--bs-paper-bg-rgb, 30, 30, 48), 0.88) 55%
    );
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.2),
    0 0 0 1px color-mix(in srgb, var(--pill-color, #696cff) 12%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

/* Video mode toggle: keep labels on one line instead of going two-line
   "fat" at intermediate widths */
#vid-mode-toggle .btn {
  white-space: nowrap;
  font-size: clamp(0.68rem, 1.5vw, 0.9375rem);
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

/* ─── Mobile: fixed Generate bar + content clearance ──
   #t2i-generate-bar is live in EJS; .studio-generate-bar is the shared
   class for video/music (and any future) modes — add the class on wrappers.
   Fixed (not sticky) so the CTA stays on-screen while scrolling controls.
   Particles / theater footer are unaffected (canvas-local, not viewport chrome). */
@media (max-width: 767.98px) {
  #t2i-generate-bar,
  .studio-generate-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    margin: 0;
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 12, 26, 0.82);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }
  #t2i-generate-bar .btn,
  .studio-generate-bar .btn {
    margin-bottom: 0 !important;
  }
  /* Keep last form fields above the fixed bar */
  .studio-two-col {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Custom outline button hover behavior for check groups and active buttons */
.btn-group .btn-check:not(:checked) + .btn-outline-primary:hover,
.btn-group .btn-outline-primary:not(.active):hover {
  background-color: var(--pill-bg) !important;
  color: var(--pill-color) !important;
  border-color: var(--pill-color) !important;
}

.btn-group .btn-check:not(:checked) + .btn-outline-secondary:hover,
.btn-group .btn-outline-secondary:not(.active):hover {
  background-color: rgba(133, 141, 152, 0.12) !important;
  color: #858d98 !important;
  border-color: #858d98 !important;
}

.btn-group .btn-check:not(:checked) + .btn-outline-warning:hover,
.btn-group .btn-outline-warning:not(.active):hover {
  background-color: rgba(255, 171, 0, 0.12) !important;
  color: #ffab00 !important;
  border-color: #ffab00 !important;
}

/* Custom separated and rounded button group toggles for the Studio */
.studio-two-col .btn-group,
#t2i-toolbar .btn-group {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  box-shadow: none !important;
  background: transparent !important;
  border: none !important;
}

.studio-two-col .btn-group .btn,
#t2i-toolbar .btn-group .btn {
  flex: 0 0 auto; /* Stop stretching/shrinking on resize */
  border-radius: 8px !important; /* Separated and fully rounded */
  margin: 0 !important;
  padding: 0.4375rem 1.25rem !important; /* Uniform padding */
}
/* core.css zeroes the inner corners of first/last grouped buttons with
   !important LONGHANDS at (0,5,0) specificity, which beat the shorthand
   above. Restore all four corners at equal specificity, loaded later. */
.studio-two-col .btn-group:not(.btn-group-vertical) > .btn:not(.dropdown-toggle),
#t2i-toolbar .btn-group:not(.btn-group-vertical) > .btn:not(.dropdown-toggle) {
  border-start-start-radius: 8px !important;
  border-start-end-radius: 8px !important;
  border-end-start-radius: 8px !important;
  border-end-end-radius: 8px !important;
}

/* Full-width segmented bars (music Format / Sample Rate / Bitrate, and the
   mode toggles) should share their width evenly instead of clustering left
   with dead space. Higher specificity than the flex:0 0 auto rule above. */
.studio-two-col .btn-group.w-100 .btn {
  flex: 1 1 0 !important;
}

/* Kill the global core.css `.btn:hover { transform: translateY(-1px) }` on
   segmented/grouped controls — a 1px lift inside a tight row reads as the
   whole studio twitching on hover. Big Generate buttons and model tiles keep
   their intentional lift. */
#vid-mode-toggle .btn:hover,
.image-mode-toggle .btn:hover,
#t2i-toolbar .btn:hover,
#t2v-toolbar .btn:hover,
#img-aspect-group .btn:hover,
#size-btn-group .btn:hover,
#vid-aspect-group .btn:hover,
#vid-resolution-group .btn:hover,
.studio-two-col .btn-group .btn:hover {
  transform: none;
}

/* core.css applies `.nav-pills .nav-item .nav-link:not(.active):hover
   { padding-block-end: 0.5435rem }` (a nav-tabs-style hover treatment).
   On our pill strips that grows the hovered pill ~2-3px taller and shifts
   the ENTIRE studio below it down on hover (measured: +2.3px on the
   Image/Video/Music strip). Pin each strip's own padding on hover. */
.studio-mobile-tabs .nav-item .nav-link:not(.active):hover {
  padding-block-end: 0.4rem; /* matches .studio-mobile-tabs .nav-link */
}
#vid-model-tier-nav .nav-item .nav-link:not(.active):hover,
#i2i-model-tier-nav .nav-item .nav-link:not(.active):hover {
  padding-block-end: 0.3rem; /* matches #vid/#i2i tier nav pill padding */
}

/* Allow main video mode toggle to distribute widths equally and fit within the controls column */
/* Allow main video and image mode toggles to distribute widths equally and fit within the controls column */
#vid-mode-toggle,
.image-mode-toggle {
  display: flex !important;
  flex-wrap: nowrap !important; /* Keep mode selector inline on desktop */
  width: 100% !important;
}
#vid-mode-toggle .btn,
.image-mode-toggle .btn {
  flex: 1 1 0% !important; /* Share width equally and shrink as needed */
  min-width: 0 !important;
  padding-left: 0.5rem !important; /* Balanced padding to fit content */
  padding-right: 0.5rem !important;
  font-size: 0.78rem !important; /* Slightly smaller text size to avoid wrapping */
  text-align: center !important;
  white-space: nowrap !important; /* Prevent text wrapping within the button */
}

/* Stack video mode toggle earlier (phones + large phones); image mode stays ≤480 */
@media (max-width: 575.98px) {
  #vid-mode-toggle {
    flex-direction: column !important;
    flex-wrap: wrap !important;
  }
  #vid-mode-toggle .btn {
    width: 100% !important;
    flex: none !important;
    font-size: 0.85rem !important;
    padding: 0.4375rem 1.25rem !important;
  }
}
@media (max-width: 480px) {
  .image-mode-toggle {
    flex-direction: column !important;
    flex-wrap: wrap !important;
  }
  .image-mode-toggle .btn {
    width: 100% !important;
    flex: none !important;
    font-size: 0.85rem !important;
    padding: 0.4375rem 1.25rem !important;
  }
}

/* Neon glow indicators for active selections (both radio labels and active buttons) */
.studio-two-col .btn-group .btn-check:checked + .btn-outline-primary,
.studio-two-col .btn-group .btn-outline-primary.active,
#t2i-toolbar .btn-group .btn-check:checked + .btn-outline-primary,
#t2i-toolbar .btn-group .btn-outline-primary.active {
  box-shadow: 0 0 10px var(--pill-glow-1), 0 0 18px var(--pill-glow-2) !important;
  border-color: var(--pill-color) !important;
  color: var(--pill-color) !important;
  background: var(--pill-bg) !important;
}

.studio-two-col .btn-group .btn-check:checked + .btn-outline-warning,
.studio-two-col .btn-group .btn-outline-warning.active,
#t2i-toolbar .btn-group .btn-check:checked + .btn-outline-warning,
#t2i-toolbar .btn-group .btn-outline-warning.active {
  box-shadow: 0 0 10px rgba(255, 171, 0, 0.6), 0 0 18px rgba(255, 171, 0, 0.3) !important;
  border-color: #ffab00 !important;
}

.studio-two-col .btn-group .btn-check:checked + .btn-outline-secondary,
.studio-two-col .btn-group .btn-outline-secondary.active,
#t2i-toolbar .btn-group .btn-check:checked + .btn-outline-secondary,
#t2i-toolbar .btn-group .btn-outline-secondary.active {
  box-shadow: 0 0 10px rgba(133, 141, 152, 0.5), 0 0 18px rgba(133, 141, 152, 0.2) !important;
  border-color: #858d98 !important;
}

/* ── Holographic Style Preset Cards ──────────────────────────────────────
   The .preset-style-card wrapper + .preset-overlay gives every style chip
   (and Quick Start tiles that opt in) the holographic foil Pokemon-card look:
   glass blur + rainbow conic gradient cycling on hover. */

/* Styles: always 2 visible; carousel hides the rest (←/→ jumps by 2) */
.style-carousel-viewport {
  min-width: 0;
  width: 100%;
}
#style-preset-strip,
.style-carousel-track {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important; /* exactly 2 thumbs */
  gap: 0.45rem;
  min-width: 0;
}
.style-carousel-btn {
  width: 1.85rem;
  height: 1.85rem;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.style-carousel-btn:disabled,
.style-carousel-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}
/* Cards that are not on the current page are .d-none from JS */

.preset-style-card {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  transition: filter 0.15s ease;
  background-size: cover;
  background-position: center;
}
.preset-style-card:hover {
  filter: brightness(1.15);
}
.preset-style-card .preset-overlay {
  display: none;
}
.preset-style-card .preset-style-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.2rem 0.35rem;
  font-size: 0.62rem;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
  z-index: 2;
  pointer-events: none;
}

/* Per-style mood gradients */
.preset-style-cyberpunk     { background: linear-gradient(135deg, #1a0033, #0d00cc, #00eaff); }
.preset-style-cinematic     { background: linear-gradient(135deg, #1a1200, #c8960c, #2c2c2c); }
.preset-style-photorealistic { background: linear-gradient(135deg, #1a2a1a, #3a7a3a, #c8d8c8); }
.preset-style-anime         { background: linear-gradient(135deg, #2d0033, #ff69b4, #b0e0ff); }
.preset-style-darkfantasy   { background: linear-gradient(135deg, #0a0010, #4b0082, #8b0000); }
.preset-style-watercolor    { background: linear-gradient(135deg, #e0f0f8, #b3d9f0, #f9c6d0); }
.preset-style-neonnoir      { background: linear-gradient(135deg, #0d0d0d, #ff0066, #6600ff); }
.preset-style-oilpainting   { background: linear-gradient(135deg, #2a1500, #8b4513, #d4a043); }

/* Prevent horizontal overflow in any flex-ancestor context */
#style-preset-card,
#style-strip-wrap {
  min-width: 0;
}

/* Give the style strip vertical breathing room so the selected glow
   box-shadow isn't clipped */
#style-preset-strip {
  padding: 4px;
  margin: -4px;
}

/* ── Selected-state rainbow radiate glow ────────────────────────────────── */
/* Applies to style cards (.preset-style-card.selected) and
   Quick Start tiles (.preset-tile.selected-tile) */
@keyframes rainbow-border-glow {
  0%   { box-shadow: 0 0 0 2.5px #ff0080, 0 0 14px 2px rgba(255,0,128,0.65); }
  16%  { box-shadow: 0 0 0 2.5px #ff6600, 0 0 14px 2px rgba(255,102,0,0.65); }
  33%  { box-shadow: 0 0 0 2.5px #ffe100, 0 0 14px 2px rgba(255,225,0,0.65); }
  50%  { box-shadow: 0 0 0 2.5px #00ff88, 0 0 14px 2px rgba(0,255,136,0.65); }
  66%  { box-shadow: 0 0 0 2.5px #00ccff, 0 0 14px 2px rgba(0,204,255,0.65); }
  83%  { box-shadow: 0 0 0 2.5px #9900ff, 0 0 14px 2px rgba(153,0,255,0.65); }
  100% { box-shadow: 0 0 0 2.5px #ff0080, 0 0 14px 2px rgba(255,0,128,0.65); }
}

.preset-style-card.selected {
  animation: rainbow-border-glow 2s linear infinite;
  z-index: 1;
}
.preset-tile.selected-tile {
  animation: rainbow-border-glow 2s linear infinite !important;
  border-color: transparent !important;
  background: rgba(255,255,255,0.04) !important;
}

/* ── Style card action menu (replaces BS popover — reliable button clicks) ─ */
.style-action-menu {
  position: fixed;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 10.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(20, 24, 40, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.style-action-menu .btn {
  justify-content: flex-start;
}

/* Pulse loading wave dots next to EJS header status badge */
.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-wave 1.2s infinite ease-in-out;
}
.pulse-dot:nth-child(2) { animation-delay: 0.2s; }
.pulse-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse-wave {
  0%, 100% { transform: scale(0.6); opacity: 0.4; }
  50% { transform: scale(1.4); opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
}

/* ─── Empty states (canvas idle) ──────────────────────
   .studio-empty for explicit opt-in; [id$="canvas-empty"] covers
   #canvas-empty, #i2i-canvas-empty, #vid-canvas-empty, #music-canvas-empty. */
.studio-empty,
[id$="canvas-empty"] {
  position: relative;
  width: 100%;
  padding: 2.75rem 1.25rem;
  border-radius: 0.75rem;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(var(--bs-primary-rgb), 0.09) 0%,
    rgba(var(--bs-primary-rgb), 0.02) 42%,
    transparent 70%
  );
}
/* Icon circle: direct <i> (legacy) or .studio-empty-icon wrapper */
.studio-empty > i,
[id$="canvas-empty"] > i,
.studio-empty-icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 50%;
  font-size: 2.15rem !important;
  line-height: 1;
  color: var(--bs-secondary-color) !important;
  opacity: 0.9 !important;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 8px rgba(var(--bs-primary-rgb), 0.04),
    inset 0 0 22px rgba(var(--bs-primary-rgb), 0.08),
    0 8px 24px rgba(0, 0, 0, 0.18);
}
.studio-empty-icon > i {
  font-size: inherit;
  line-height: 1;
  color: inherit;
  opacity: 1;
}
.studio-empty > p,
.studio-empty-title,
[id$="canvas-empty"] > p {
  margin-top: 1.2rem !important;
  margin-bottom: 0.35rem !important;
  letter-spacing: 0.01em;
}
.studio-empty > small,
.studio-empty-hint,
[id$="canvas-empty"] > small {
  display: block;
  line-height: 1.4;
  opacity: 0.8;
}

/* ─── Dropzones ───────────────────────────────────────
   .studio-dropzone for future class; id suffix covers live EJS zones. */
.studio-dropzone,
[id$="-dropzone"],
#i2v-dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.16) !important;
  background: rgba(var(--bs-primary-rgb), 0.03);
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    box-shadow 0.2s ease;
}
.studio-dropzone:hover,
[id$="-dropzone"]:hover,
#i2v-dropzone:hover {
  border-color: color-mix(in srgb, var(--pill-color, #696cff) 55%, transparent) !important;
  background: rgba(var(--bs-primary-rgb), 0.07);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill-color, #696cff) 12%, transparent);
}
.studio-dropzone.is-dragover,
[id$="-dropzone"].is-dragover,
#i2v-dropzone.is-dragover {
  border-color: var(--pill-color, var(--bs-primary)) !important;
  background: rgba(var(--bs-primary-rgb), 0.12);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--pill-color, #696cff) 22%, transparent),
    inset 0 0 28px rgba(var(--bs-primary-rgb), 0.1);
}

/* ─── Music result panel ────────────────────────────── */
.studio-music-result,
#music-canvas-result {
  position: relative;
  padding: 1.75rem 1.15rem 1.35rem;
  border-radius: 0.85rem;
  background:
    radial-gradient(
      ellipse at 50% 0%,
      color-mix(in srgb, var(--pill-color, #696cff) 22%, transparent) 0%,
      transparent 58%
    ),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.04) 0%,
      rgba(255, 255, 255, 0.01) 100%
    );
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.studio-music-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(40, 199, 111, 0.12);
  border: 1px solid rgba(40, 199, 111, 0.28);
  color: #28c76f;
  font-size: 1.55rem;
  box-shadow: 0 0 18px rgba(40, 199, 111, 0.18);
}
.studio-audio-player-wrap {
  width: 100%;
  max-width: 28rem;
  margin-inline: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 6px 18px rgba(0, 0, 0, 0.22);
}
.studio-music-result audio,
#music-canvas-result audio {
  border-radius: 0.55rem;
  background: transparent;
  box-shadow: none;
  height: 2.5rem;
}

/* ─── Profile page (light polish via studio.css link) ─ */
.profile-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0.875rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.profile-card:hover {
  border-color: rgba(var(--bs-primary-rgb), 0.28);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

/* ─── Mobile-safe header brand + token + avatar ───────── */
.navbar-brand-logo {
  width: 108px;
  height: 32px;
  max-width: 28vw;
}
@media (min-width: 576px) {
  .navbar-brand-logo {
    width: 148px;
    height: 36px;
    max-width: none;
  }
}
@media (min-width: 992px) {
  .navbar-brand-logo {
    width: 180px;
    height: 40px;
  }
}
/* Keep right cluster (tokens + avatar) from being shoved off-screen */
.navbar-user-cluster {
  max-width: 100%;
  gap: 0.15rem;
}
#layout-navbar {
  overflow: visible;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════
   Mobile Studio batch (phones / xs)
   Loaded last so !important toolbar paddings above lose.
   Does not touch particle canvas or .canvas-theater-status.
   ═══════════════════════════════════════════════════════ */

/* History denser + near-full-width drawer */
@media (max-width: 575.98px) {
  #historyOffcanvas {
    width: 100% !important;
    max-width: 100vw;
  }
  #history-container {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 6px !important;
  }
  #historyOffcanvas .history-card {
    height: 200px; /* was 320px — denser tiles on small screens */
  }
  /* Slightly quieter hover lift on cramped drawers */
  #historyOffcanvas .history-card:hover {
    transform: translateY(-2px);
  }

  /* Toolbar padding war: beat `padding: 0.4375rem 1.25rem !important` */
  #t2i-toolbar .btn,
  #t2v-toolbar .btn,
  #t2i-toolbar .btn-group .btn,
  #t2v-toolbar .btn-group .btn,
  .studio-two-col #t2i-toolbar .btn-group .btn,
  .studio-two-col #t2v-toolbar .btn-group .btn {
    padding: 0.32rem 0.48rem !important;
    font-size: 0.72rem !important;
  }
  #t2i-toolbar .btn-group,
  #t2v-toolbar .btn-group {
    gap: 5px !important;
  }
  .toolbar-lbl {
    min-width: 2.4rem;
    font-size: 0.55rem;
  }

  /* Hide resolution pixel subtext (1280×720) on xs — label stays "720p" */
  #vid-resolution-group .btn small,
  #vid-resolution-group label small {
    display: none !important;
  }

  /* Lightbox: fluid stage using dvh (pairs with modal-fullscreen-sm-down) */
  #imageLightboxModal .lb-modal-shell {
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    filter: none;
    overflow: hidden;
  }
  #imageLightboxModal .lb-topbar {
    border-radius: 0;
    flex-shrink: 0;
  }
  #imageLightboxModal .lb-infopanel {
    flex-shrink: 0;
  }
  #imageLightboxModal .lb-media-stage {
    flex: 1 1 auto;
    height: auto;
    min-height: calc(100dvh - 9.5rem);
    max-height: none;
  }
}
#layout-navbar #navbar-collapse {
  min-width: 0;
  /* overflow:hidden was clipping the profile dropdown menu */
  overflow: visible;
}
#layout-navbar {
  z-index: 1080;
  overflow: visible;
}
/* Account dropdown must sit above sticky Generate / canvas */
#nav-user-dropdown {
  position: relative;
  z-index: 1085;
}
#nav-user-dropdown .dropdown-menu {
  z-index: 1095;
  min-width: 14rem;
  padding: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(18, 22, 38, 0.98);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
#nav-user-dropdown .nav-link {
  cursor: pointer;
}
/* Clear hover / focus highlight on account menu rows */
#nav-user-dropdown .dropdown-item {
  border-radius: 0.45rem;
  padding: 0.55rem 0.75rem;
  color: var(--bs-body-color, #d7d8de);
  transition: background-color 0.12s ease, color 0.12s ease;
}
#nav-user-dropdown .dropdown-item:hover,
#nav-user-dropdown .dropdown-item:focus,
#nav-user-dropdown .dropdown-item:focus-visible {
  background: rgba(var(--bs-primary-rgb), 0.18) !important;
  color: #fff !important;
  outline: none;
}
#nav-user-dropdown .dropdown-item:active {
  background: rgba(var(--bs-primary-rgb), 0.28) !important;
  color: #fff !important;
}
#nav-user-dropdown .dropdown-item .bx,
#nav-user-dropdown .dropdown-item .icon-base {
  opacity: 0.75;
  transition: opacity 0.12s ease, color 0.12s ease;
}
#nav-user-dropdown .dropdown-item:hover .bx,
#nav-user-dropdown .dropdown-item:hover .icon-base,
#nav-user-dropdown .dropdown-item:focus .bx,
#nav-user-dropdown .dropdown-item:focus .icon-base {
  opacity: 1;
  color: var(--bs-primary);
}
/* Header block (avatar + name) — subtler hover */
#nav-user-dropdown .dropdown-item:first-child:hover,
#nav-user-dropdown .dropdown-item:first-child:focus {
  background: rgba(255, 255, 255, 0.06) !important;
}
#nav-user-dropdown .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.08);
  margin: 0.35rem 0.25rem;
}
#layout-navbar .layout-menu-toggle {
  flex-shrink: 0;
  margin-right: 0.35rem !important;
}
@media (max-width: 575.98px) {
  #layout-navbar.navbar-detached {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  #layout-navbar .avatar {
    --bs-avatar-size: 2rem;
    width: 2rem;
    height: 2rem;
  }
  .token-balance-chip {
    max-width: 5.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #nav-token-count {
    max-width: 3.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
  }
}

/* ─── Nav token chip (always visible; compact on phones) ─ */
.token-balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  line-height: 1.2;
  max-width: 100%;
}
/* Brief attention pulse when generation fails for insufficient tokens (402) */
.token-balance-chip.token-balance-attention {
  animation: tokenBalanceAttention 0.45s ease 2;
  outline: 2px solid rgba(var(--bs-danger-rgb), 0.85);
  outline-offset: 2px;
}
@keyframes tokenBalanceAttention {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.token-balance-chip .bx-coin-stack {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}
@media (min-width: 576px) {
  .token-balance-chip {
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    gap: 0.35rem;
    max-width: none;
  }
}

/* ─── Frosted toasts (opt-in .studio-toast + dark BS toasts) ─ */
/* Sit under the fixed/detached navbar so sticky Generate doesn't cover them */
.studio-toast-container {
  margin-top: 4.25rem;
}
.studio-toast,
.toast.bs-toast:not([class*="bg-"]) {
  background: rgba(20, 24, 40, 0.88) !important;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  color: var(--bs-body-color);
}
.studio-toast .toast-header,
.toast.bs-toast:not([class*="bg-"]) .toast-header {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.06);
  color: var(--bs-heading-color, var(--bs-body-color));
}
/* Colored studio toasts keep semantic tint under frost */
.studio-toast.bg-danger {
  background: rgba(185, 40, 55, 0.9) !important;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.14);
}
.studio-toast.bg-success {
  background: rgba(25, 120, 80, 0.9) !important;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.14);
}
.studio-toast .toast-body {
  display: flex;
  align-items: center;
}

/* ─── Auth modal polish ─────────────────────────────────────────── */
.auth-modal-dialog {
  max-width: 420px;
}
.auth-modal-sub {
  font-size: 0.85rem;
}
.auth-modal-divider {
  font-size: 0.75rem;
}
.auth-modal-legal {
  font-size: 0.78rem;
}

/* Frosted pill track (Sign In / Create Account) */
.frosted-pill-track {
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.frosted-pill-track .nav-link {
  color: var(--bs-secondary-color, rgba(255, 255, 255, 0.65));
  border: 0;
  padding: 0.5rem 0.75rem;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.frosted-pill-track .nav-link:hover:not(.active) {
  color: var(--bs-body-color);
  background: rgba(255, 255, 255, 0.06);
}
.frosted-pill-track .nav-link.active {
  background: linear-gradient(
    135deg,
    var(--pill-color, #7c3aed) 0%,
    color-mix(in srgb, var(--pill-color, #a78bfa) 55%, #fff) 100%
  );
  color: #fff;
  box-shadow: 0 0 12px var(--pill-glow-2, rgba(199, 125, 255, 0.32));
}
#authModal .modal-content {
  background: rgba(22, 26, 42, 0.96);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Pricing page (shared polish) ---------------------
   Core layout lives in pricing.ejs <style>; these rules
   reinforce popular-card presence + trust strip spacing. */
.pricing-wrapper .plan-card.popular {
  z-index: 1;
}
@media (min-width: 1200px) {
  .pricing-wrapper .plan-card.popular {
    transform: scale(1.03);
  }
  .pricing-wrapper .plan-card.popular:hover {
    transform: scale(1.03) translateY(-4px);
  }
}
.pricing-wrapper .pricing-trust {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}
