.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ==========================================================================
   V3 two-column workspace.

   The runner mounts <form class="space-y-3"> with one inner
   <div class="space-y-3"> ("basicWrap") whose direct children are field
   wrappers. Unlike V2's single-row sticky bar, V3 keeps the schema form as a
   VERTICAL STACK of cards in the left workspace column — the schema stays the
   single source of truth, we only restyle each rendered field into a card.
   ========================================================================== */
.v3-form-mount { min-width: 0; }
.v3-form-mount > form { display: block; min-width: 0; }
.v3-form-mount > form > .space-y-3 {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  margin: 0; /* defeat Tailwind's space-y-3 — selector wins on specificity */
}
.v3-form-mount > form > .space-y-3 > * { margin: 0 !important; }

/* schema-form ships a <details> "More options" wrapper for any advanced
   fields it bucketed. Our split moves those fields into [data-v3-advanced-row];
   keep the empty <details> hidden so it doesn't leave a stray toggle. */
.v3-form-mount > form > details { display: none; }

/* Each field wrapper reads as a soft card so the workspace looks like the
   v3 mock's stacked "Choose a Video Style" / prompt blocks. */
.v3-form-mount > form > .space-y-3 > div { display: flex; flex-direction: column; }

/* Field labels stay visible in V3 (there's vertical room, unlike V2's bar). */
.v3-form-mount > form > .space-y-3 [data-help-trigger] { color: hsl(var(--muted-foreground)); }

/* Interactive-prompt / visual-picker trigger card — the big tappable block in
   the mock ("Choose a Video Style ›"). Give it presence: full width, padded,
   rounded, subtle border. */
.v3-form-mount [aria-haspopup="dialog"],
.v3-form-mount [data-component="visual-picker"] [role="button"] {
  white-space: normal;
}
.v3-form-mount [data-component="visual-picker"] {
  border-radius: 16px;
}

/* Textareas / prompt inputs */
.v3-form-mount textarea {
  min-height: 96px;
  resize: vertical;
  border-radius: 14px;
}

/* Plain selects / number / text inputs */
.v3-form-mount select,
.v3-form-mount input[type="number"],
.v3-form-mount input[type="text"]:not([type="file"]) {
  height: 44px;
  border-radius: 12px;
}

/* Media dropzone fills the card width in the workspace. */
.v3-form-mount .dropzone-empty,
.v3-form-mount [data-media-field] {
  min-height: 120px;
  border-radius: 16px;
}

/* Skeleton placeholder swapped out once <form> mounts */
.v3-form-mount.v3-form-ready > div.animate-pulse { display: none; }

/* ── Advanced pill row — small filled chips beside Generate (matches the
      "1:1" aspect chip in the mock). The split script appends every
      [data-uap-group="advanced"] field here. ── */
.v3-advanced-row {
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  gap: 6px;
}
.v3-advanced-row::-webkit-scrollbar { height: 4px; }
.v3-advanced-row::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 9999px; }
.v3-advanced-row > * { margin: 0; min-width: 0; flex: 0 0 auto; }

/* Hide stacked labels, helpers, empty error rows — chip is value-only. */
.v3-advanced-row .mb-1\.5,
.v3-advanced-row .mb-2,
.v3-advanced-row label[for]:not(:empty),
.v3-advanced-row [data-help-trigger],
.v3-advanced-row [role="alert"]:empty { display: none !important; }

/* Every interactive control inside the row collapses to a filled pill. */
.v3-advanced-row button,
.v3-advanced-row select,
.v3-advanced-row input[type="text"]:not([type="file"]),
.v3-advanced-row input[type="number"] {
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 14px !important;
  font-size: 12px !important;
  line-height: 36px !important;
  border-radius: 9999px !important;
  background: var(--panel-input) !important;
  border: 1px solid transparent !important;
  color: hsl(var(--foreground)) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
.v3-advanced-row button:hover,
.v3-advanced-row select:hover { background: var(--panel-hover) !important; }
.v3-advanced-row button svg { display: none !important; }
.v3-advanced-row button .shrink-0.ml-2 { display: none !important; }

.v3-advanced-row .dropzone-empty,
.v3-advanced-row [data-media-field] {
  min-height: 36px !important;
  max-width: 140px !important;
  padding: 2px 10px !important;
  border-radius: 9999px !important;
}
.v3-advanced-row .dropzone-empty * { font-size: 12px !important; }
.v3-advanced-row [role="radio"],
.v3-advanced-row [role="radiogroup"] > button {
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  border-radius: 9999px !important;
}
.v3-advanced-row [role="radiogroup"].grid {
  display: inline-flex !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
}

/* ── Generate button: gradient pill matching the v3 mock. ── */
.v3-generate-btn {
  background: linear-gradient(90deg, #9335EC 0%, #7C3AED 100%);
  box-shadow: 0 8px 24px -10px rgba(147, 53, 236, 0.6);
}
.v3-generate-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, #8a2fe0 0%, #6d28d9 100%);
}
/* The runner stamps a credits chip (⚡N) into the button's innerHTML; align it
   to the right edge like the mock. */
.v3-generate-btn { position: relative; }
.v3-generate-btn .ml-2 {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

/* ── Right media stage ── */
.v3-stage-media > img,
.v3-stage-media > video,
.v3-stage-media :is(img, video) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Latest-run mirror cloned from the history list's `.history-list-media`. Its
   own layout classes (fixed lg:h-[470px], aspect-video) would fight the stage's
   aspect box, so normalise the clone to fully fill the stage for both the
   in-flight loading visual and the result media. */
.v3-stage-media .v3-stage-mirror {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  aspect-ratio: auto;
}
.v3-stage { position: relative; max-height: 100%; overflow: auto;}
.v3-stage-media { position: relative; }
.v3-stage-media .v3-stage-mirror :is(img, video) { object-fit: contain; }

/* Tab switching toggles `.hidden` on each panel. The Studio panel ships
   `class="v3-studio hidden lg:grid"`, and Tailwind's responsive `lg:grid`
   utility outranks the base `.hidden` at desktop — so without this the Studio
   panel never actually hides when the user switches to Creation History (the
   generate workspace stays stacked above the in-flight card). Force the hidden
   state to win at every breakpoint. */
.v3-studio.hidden { display: none !important; }

/* Remix area is `display:flex` by default and only belongs to the Studio tab.
   setActiveTab toggles `.hidden` on it; force that to win over the `flex`
   utility so it disappears on Creation History / Details / Guide. */
#remix-area.hidden { display: none !important; }

/* ── Mobile: single column. The Studio panel drops its grid; the workspace
      card and stage stack. Bottom sticky Generate handles the action. ── */
@media (max-width: 1023.98px) {
  .v3-studio:not(.hidden) { display: block; }
  .v3-workspace { border: none; background: transparent; padding: 0; }
  /* Hide the inline desktop Generate on mobile — the sticky mobile bar drives
     the action there. */
  /* .v3-generate-row { display: none; } */
}

/* Guide tab — long-form SEO content */
.prose-guide { color: #898A8B; font-size: 16px; line-height: 24px; }
.prose-guide :is(h1, h2, h3, strong, dt) { color: hsl(var(--foreground)); font-weight: 600; }
.prose-guide :is(h1, h2) { font-size: 16px; line-height: 21px; margin: 24px 0 10px; }
.prose-guide h3 { font-size: 14px; line-height: 20px; margin: 12px 0 4px; }
.prose-guide h3 + p { margin-bottom: 10px; }
.prose-guide dt { font-size: 14px; }
.prose-guide :is(p, ul, dd) { margin-bottom: 14px; }
.prose-guide ul { padding-left: 22px; list-style: disc; }
.prose-guide > :first-child { margin-top: 0; }

/* Size Slider (native range input — Tailwind can't style pseudo-elements) */
.size-slider { -webkit-appearance: none; appearance: none; width: 100px; height: 4px; background: #404040; border-radius: 9999px; cursor: pointer; outline: none; }
.size-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #9335EC; cursor: pointer; border: none; box-shadow: 0 2px 8px rgba(147, 53, 236, 0.5); margin-top: 0; }
.size-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #9335EC; cursor: pointer; border: none; box-shadow: 0 2px 8px rgba(147, 53, 236, 0.5); }
.size-slider::-moz-range-track { background: #404040; height: 4px; border-radius: 9999px; }

.view-toggle-container { display: flex; align-items: center; width: 94px; padding: 5px; background: #262626; border-radius: 24px; gap: 2px; }
.view-toggle-btn { flex: 1; height: 30px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: #737373; background: transparent; border: none; cursor: pointer; transition: all 0.15s ease; }
.view-toggle-btn:hover { color: #a3a3a3; }
.view-toggle-btn.active { background: #404040; color: #ffffff; }

:root:not(.dark) .size-slider { background: #D9D9D9; }
:root:not(.dark) .size-slider::-moz-range-track { background: #D9D9D9; }
:root:not(.dark) .view-toggle-container { background: #DFE4EC; }
:root:not(.dark) .view-toggle-btn { color: #898A8B; }
:root:not(.dark) .view-toggle-btn:hover { color: #0D0D0D; }
:root:not(.dark) .view-toggle-btn.active { background: #ffffff; color: #0D0D0D; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* History list/grid scaffolding (consumed by /js/runner/embed-runner.js when it renders the history list) */
@media (min-width: 1024px) {
  .history-list-card { max-width: 100%; }
  .history-list-media { flex: var(--list-media-flex, 1) 1 var(--list-media-basis, 0); min-width: 0; overflow: hidden; }
  .history-list-info { flex: var(--list-info-flex, 0) 0 var(--list-info-basis, 280px); max-width: var(--list-info-basis, 280px); overflow: hidden; }
}
.history-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; justify-content: start; align-content: start; align-items: start; width: 100%; }
.history-grid.cols-4 { --cols: 4; }
.history-grid.cols-3 { --cols: 3; }
.history-grid.cols-2 { --cols: 2; }

.history-card { position: relative; width: 100%; border-radius: 16px; overflow: hidden; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); }
.history-grid .history-card { align-self: start; height: 0; padding-bottom: 73.75%; }
.history-card-media { position: absolute; inset: 0; background: hsl(var(--secondary)); }
.history-card-media-el { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.history-media-video { object-fit: cover; }
.history-media-image { object-fit: contain; background: rgba(0,0,0,0.04); }
.history-media-placeholder { background: hsl(var(--secondary)); }
.history-card > img, .history-card > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.history-card-overlay { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.8) 100%); opacity: 0; transition: opacity 0.2s; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; }
.history-card:hover .history-card-overlay, .history-card.show-overlay .history-card-overlay { opacity: 1; }
.history-card-actions { display: flex; gap: 8px; }
.history-card-action { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; color: white; border: none; cursor: pointer; transition: background 0.2s; }
.history-card-action:hover { background: rgba(255,255,255,0.25); }
.history-card-text { color: white; font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.history-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.history-card-badge { padding: 6px 10px; border-radius: 10px; font-size: 12px; line-height: 1; background: rgba(255,255,255,0.15); color: white; backdrop-filter: blur(8px); }

.history-list .history-card { aspect-ratio: auto; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; padding: 12px; border-radius: 16px; align-items: start; }
.history-list .history-card-media { position: relative; inset: auto; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: hsl(var(--secondary)); }
.history-list .history-card-media-el { position: absolute; inset: 0; }
.history-list .history-card-overlay { position: static; opacity: 1; background: none; padding: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.history-list .history-card-text { color: hsl(var(--foreground)); -webkit-line-clamp: 8; }
.history-list .history-card-actions { justify-content: flex-end; gap: 8px; }
.history-list .history-card-badge { background: hsl(var(--secondary)); color: hsl(var(--foreground)); backdrop-filter: none; }
.history-list .history-card.history-card-text-only { grid-template-columns: 1fr; }
.history-list .history-card.history-card-text-only .history-card-media { display: none; }
.history-list .history-card.history-card-text-only .history-card-text { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; -webkit-line-clamp: 6; }
