.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; }

/* ==========================================================================
   V4 prompt bar: lay the runner-rendered <form> out as a single row.
   The runner mounts a <form> with one inner div stamped
   [data-form-body="basic"] ("basicWrap") whose direct children are field
   wrappers. We key every selector off that stable data-* hook — never off
   schema-form's Tailwind classes, which are presentation and may change.
   Everything else (advanced details, error messages) is hidden because it
   doesn't fit a single-row UI.
   ========================================================================== */
.v4-form-mount { min-width: 0; overflow: hidden; }
/* Top row: basic fields. schema-form mounts <form><div data-form-body="basic">…</div></form>
   in this container; we flatten the inner stack into a horizontal flex row. */
.v4-form-mount > form { display: block; min-width: 0; }
.v4-form-mount > form > [data-form-body="basic"] {
  min-width: 0;
  /* margin: 0 defeats Tailwind's space-y-3 — the selector wins on specificity */
  margin: 0;
  display: grid;
  grid-template-columns: fit-content(25%) 1fr;
  grid-template-areas:
    "media prompt"
    "pills pills";
  align-items: start;
  column-gap: 8px;
  row-gap: 8px;
  overflow: visible;
}
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media { grid-area: media; }
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-prompt { grid-area: prompt; }
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills { grid-area: pills; }
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media {
    display: flex; flex-direction: row; flex-wrap: wrap;
    align-items: flex-start; align-content: flex-start; gap: 8px;
    min-width: 0;
  }
}
.v4-zone-prompt { display: flex; min-width: 0; }
.v4-zone-prompt > * { flex: 1 1 auto; min-width: 0; }
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media > * {
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto;
  }
  body.template-v4 .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media .media-field-header,
  body.template-v4 .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media > * > .mb-3:has(label) {
    display: none !important;
  }
  .v4-zone-pills { display: flex; align-items: center; flex-wrap: wrap; min-width: 0; }
  .v4-zone-pills > * { flex: 0 0 auto; }
  .v4-zone-media > * { width: 118px; }
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty {
    width: 118px !important;
    min-width: 118px !important;
    height: 76px !important;
    min-height: 76px !important;
    max-height: 76px !important;
    max-width: none !important;
    padding: 8px 6px !important;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
  }
}
.v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .v4-tile-caption {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: none;
  max-width: 100%;
  font-size: 11px; line-height: 14px; font-weight: 500;
  text-align: center; color: hsl(var(--muted-foreground));
  overflow: hidden; text-overflow: ellipsis; white-space: normal;
}
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty .agent-form-upload-title,
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty .agent-form-hint,
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty .min-w-0 { display: none !important; }
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty > div {
    display: flex !important; gap: 0 !important; height: auto !important;
  }
  .v4-form-mount > form > [data-form-body="basic"] .v4-zone-media .dropzone-empty svg {
    width: 22px !important; height: 22px !important;
  }
}
.v4-split-shell {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}
.v4-split-row { gap: 8px; align-items: stretch; }
.v4-field-bar [data-v4-field-row].v4-split-row { align-items: stretch; }
/* Bar-only frame/controls compaction — desktop bar design */
@media (min-width: 1024px) {
  .v4-frame-panel { flex: 0 0 auto; align-self: stretch; }
  .v4-controls-card {
    flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center;
  }
  .v4-frame-panel [data-component="image-pair"],
  .v4-frame-panel > .grid-cols-2 { width: 242px !important; }
  .v4-frame-panel.is-stacked [data-component="image-pair"],
  .v4-frame-panel.is-stacked > .grid-cols-2 { width: 148px !important; }
  .v4-frame-panel .media-field-header,
  .v4-frame-panel .mb-3 { display: none !important; }
  .v4-frame-panel .grid-cols-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    align-items: stretch;
  }
  .v4-frame-panel [data-component="image-pair"],
  .v4-frame-panel .grid-cols-2,
  .v4-frame-panel .grid-cols-2 > *,
  .v4-frame-panel .grid-cols-2 > * > * { height: 100%; }
  .v4-frame-panel.is-stacked .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  .v4-frame-panel.is-stacked .dropzone-empty {
    width: 148px !important;
    min-width: 148px !important;
    min-height: 76px !important;
  }
  .v4-frame-panel .dropzone-empty {
    width: 118px !important;
    min-width: 118px !important;
    height: 100% !important;
    min-height: 96px !important;
    max-height: none !important;
    max-width: none !important;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; padding: 8px !important;
  }
  .v4-frame-panel .agent-form-upload-title,
  .v4-frame-panel .agent-form-hint,
  .v4-frame-panel .min-w-0 { display: none !important; }
  .v4-frame-panel .dropzone-empty > div { display: flex !important; gap: 0 !important; height: auto !important; }
  .v4-frame-panel .dropzone-empty svg { width: 20px !important; height: 20px !important; }
}
.v4-frame-panel .v4-tile-caption {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%; text-align: center;
  font-size: 11px; line-height: 14px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: normal; overflow: hidden; text-overflow: ellipsis;
}
.v4-form-mount > form > [data-form-body="basic"].v4-no-dock {
  grid-template-columns: 1fr;
  grid-template-areas: "prompt" "pills";
}
.v4-form-mount > form > [data-form-body="basic"].v4-no-prompt {
  grid-template-areas: "media pills";
  align-items: stretch;
}
.v4-form-mount > form > [data-form-body="basic"].v4-no-prompt > .v4-zone-prompt { display: none; }
.v4-form-mount > form > [data-form-body="basic"].v4-no-dock.v4-no-prompt {
  grid-template-columns: 1fr;
  grid-template-areas: "pills";
}
.v4-form-mount > form > [data-form-body="basic"].v4-no-prompt > .v4-zone-media:has(> *:only-child),
.v4-form-mount > form > [data-form-body="basic"].v4-no-prompt > .v4-zone-media:has(> *:only-child) div {
  height: 100%;
}
/* Full prefix: the dock pins 76px with !important, so this has to out-specify
   it rather than just come later. */
.v4-form-mount > form > [data-form-body="basic"].v4-no-prompt > .v4-zone-media:has(> *:only-child) .dropzone-empty {
  height: 100% !important;
  max-height: none !important;
}
.v4-form-mount > form > [data-form-body="basic"] > * {
  margin: 0!important;
  /* Default a sensible minimum so a field wrapper that would otherwise
     collapse to 0 (e.g. visual-picker trigger card whose inner block uses
     width:100%) stays visible. */
  min-width: 140px;
  flex: 0 0 auto;
}
.v4-form-mount > form > [data-form-body="basic"] > * { order: 3; }
.v4-form-mount > form > [data-form-body="basic"] > *:has(.dropzone-empty),
.v4-form-mount > form > [data-form-body="basic"] > *:has([data-media-field]) { order: 1; }
.v4-form-mount > form > [data-form-body="basic"] > *:has(textarea),
.v4-form-mount > form > [data-form-body="basic"] > *:has([contenteditable="true"][role="textbox"]) { order: 2; }

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

/* ── Advanced row — small pill chips under the basic row.
      Matches templates/v1/1.png: subtle, muted "16:9 · 5s" style. ── */
.v4-advanced-row {
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  gap: 6px;
}
.v4-advanced-row:empty { display: none; }
.v4-advanced-row::-webkit-scrollbar { height: 4px; }
.v4-advanced-row::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 9999px;
}
.v4-advanced-row > * { margin: 0; min-width: 0; flex: 0 0 auto; }

/* Hide stacked labels, helpers, and empty error rows — chip is value-only. */
.v4-advanced-row .mb-1\.5,
.v4-advanced-row .mb-2,
.v4-advanced-row label:not(:has(input, select, textarea, button)),
.v4-advanced-row [data-help-trigger],
.v4-advanced-row [role="alert"]:empty { display: none !important; }
.v4-advanced-row input[type="range"] { width: 110px; }

/* Every interactive control inside the row collapses to a filled 26px pill.
   Matches templates/v1/1.png: solid panel-input background, foreground text,
   no border — reads as a chip, not as an input field. */
.v4-advanced-row button,
.v4-advanced-row select,
.v4-advanced-row input[type="text"]:not([type="file"]),
.v4-advanced-row input[type="number"] {
  height: 26px !important;
  min-height: 26px !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  line-height: 26px !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;
}
.v4-advanced-row button:hover,
.v4-advanced-row select:hover {
  background: var(--panel-hover) !important;
}

/* Hide chevrons / extra svgs inside the custom select button — keep only
   the value text so the chip reads "16:9", "5s", etc. */
.v4-advanced-row button svg { display: none !important; }
.v4-advanced-row button .shrink-0.ml-2 { display: none !important; }

/* Dropzone (file-upload) shrinks to a chip too. */
.v4-advanced-row .dropzone-empty,
.v4-advanced-row [data-media-field] {
  min-height: 22px !important;
  max-width: 120px !important;
  padding: 2px 8px !important;
  border-radius: 9999px !important;
}
.v4-advanced-row .dropzone-empty * { font-size: 11px !important; }

/* Chip-group / radio-group buttons — same compact treatment. */
.v4-advanced-row [role="radio"],
.v4-advanced-row [role="radiogroup"] > button {
  height: 22px !important;
  min-height: 22px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  border-radius: 9999px !important;
}
.v4-advanced-row [role="radio"][aria-checked="true"],
.v4-advanced-row [role="radiogroup"] > button[aria-checked="true"] {
  background: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
}

/* prompt-picker / visual-picker grid wrappers don't belong in a pill row
   visually; collapse the inner grid down so they still fit. */
.v4-advanced-row [role="radiogroup"].grid {
  display: inline-flex !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
}

/* Field labels: hidden on desktop — the bar reads like a playground
   prompt bar */
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .mb-1\.5,
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .mb-2,
  .v4-form-mount > form > [data-form-body="basic"] [data-id] > .mb-3:has(label),
  .v4-form-mount > form > [data-form-body="basic"] [data-id] label:not(:has(input, select, textarea, button)),
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .media-field-header { display: none; }
}
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] [data-id] [data-help-trigger] { display: none; }
}

/* Instant field-name tooltip */
.v4-field-tip {
  position: fixed; z-index: 70;
  padding: 4px 10px; border-radius: 8px;
  font-size: 11px; line-height: 16px; font-weight: 500;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
  pointer-events: none; white-space: nowrap;
}.v4-pop-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--panel-border); background: var(--panel-input);
  color: hsl(var(--foreground)); cursor: pointer;
  font-size: 12px; font-weight: 500; white-space: nowrap; max-width: 190px;
}
.v4-pop-trigger:hover { background: var(--panel-hover); }
.v4-pop-name {
  text-transform: capitalize; opacity: 0.7;
  flex: 0 0 auto; white-space: nowrap;
}
.v4-pop-val {
  font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v4-pop-dot {
  width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0;
  border: 1px solid rgba(128,128,128,0.25);
}
.v4-pop-panel {
  position: fixed; z-index: 120;
  min-width: 240px; max-width: 300px; padding: 12px;
  border-radius: 16px; background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 12px 34px rgb(0 0 0 / 0.28);
}
.v4-pop-panel[hidden] { display: none; }
.v4-pop-panel label { display: block !important; }
.v4-pop-panel [data-component="toggle"] > label { display: flex !important; }
.v4-more-panel {
  min-width: min(320px, calc(100vw - 24px));
  max-width: min(380px, calc(100vw - 24px));
  max-height: min(60vh, 460px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.v4-more-panel > * { margin: 0 !important; }
.v4-more-trigger { font-weight: 600; }
@media (min-width: 1024px) {
  .v4-zone-pills > *:has([data-component="multi-select"]) {
    width: 260px !important; max-width: 260px !important; flex: 0 0 260px !important;
  }
}
.v4-zone-pills [data-component="multi-select"] {
  width: 100% !important; max-width: 100% !important;
}
.v4-zone-pills [data-component="multi-select"] button[data-trigger] {
  width: 100% !important; min-width: 0 !important;
  height: 44px; padding: 0 10px; border-radius: 12px;
  overflow: hidden;
}
.v4-zone-pills [data-component="multi-select"] button[data-trigger][data-v4-name]::before {
  content: attr(data-v4-name);
  flex: 0 0 auto;
  margin-right: 8px;
  font-size: 12px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}
.v4-zone-pills [data-component="multi-select"] button[data-trigger][data-v4-empty] > .flex-1 {
  display: none;
}
.v4-zone-pills [data-component="multi-select"] .flex.flex-wrap {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  max-width: 100%;
}
.v4-zone-pills [data-component="multi-select"] .flex.flex-wrap::-webkit-scrollbar { display: none; }
.v4-zone-pills [data-component="multi-select"] .flex.flex-wrap > * { flex: 0 0 auto; }
.v4-pop-panel [data-component="chip-group"] button[aria-checked="false"] {
  border: 1px solid var(--panel-border);
}

@media (min-width: 1024px) {
  .v4-zone-pills [data-component="toggle"] .agent-form-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 168px;
  }
}
.v4-zone-pills > * select,
.v4-zone-pills > * input[type="text"] {
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Visual-picker / inline pill triggers — already compact, keep as-is */
.v4-form-mount > form > [data-form-body="basic"] > div [aria-haspopup="dialog"] { white-space: nowrap; }

/* Media field (file dropzone): shrink to a small 48x48 button-like target.
   The runner's media component wraps the dropzone in deep nested divs;
   scope the override to elements with [data-media-field] when present
   and to any <input type="file"> sibling otherwise. */
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] > div .dropzone-empty,
  .v4-form-mount > form > [data-form-body="basic"] > div [data-media-field] {
    min-height: 48px !important;
    max-width: 220px;
    padding: 6px 10px !important;
  }
  .v4-form-mount > form > [data-form-body="basic"] > div .dropzone-empty * { font-size: 12px !important; }

  /* Textareas / prompt inputs grow to fill the middle */
  .v4-form-mount > form > [data-form-body="basic"] > *:has(textarea),
  .v4-form-mount > form > [data-form-body="basic"] > *:has([contenteditable="true"][role="textbox"]) {
    flex: 1 1 0% !important;
    min-width: 240px;
  }
}
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] [data-id] textarea {
    min-height: 88px;
    height: 88px;
    resize: none;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 6px;
  }
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .bg-panel-input:has(textarea) {
    background: transparent !important;
    border: none !important;
    padding: 0;
  }
  .v4-form-mount > form > [data-form-body="basic"] > *:not(:has([data-id], .v4-more-trigger)) { display: none; }
}

/* Plain selects / number / chip groups stay compact */
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] > div select,
  .v4-form-mount > form > [data-form-body="basic"] > div input[type="number"],
  .v4-form-mount > form > [data-form-body="basic"] > div input[type="text"]:not([type="file"]) {
    height: 40px;
  }
}

/* Model selector wrapper: if it ended up inside the form, pin it small left */
.v4-form-mount > form .model-selector-in-form { margin: 0; flex: 0 0 auto; }

/* Error rows the runner appends underneath — hide in the bar to keep one line */
.v4-form-mount > form > [data-form-body="basic"] > div [role="alert"]:empty { display: none; }
/* Skeleton placeholder swapped out once <form> mounts */
.v4-form-mount.v4-form-ready > div.animate-pulse { display: none; }

/* ── Field column layout ──
   Each [data-id] is a label-above-control column; wrappers between the
   row and [data-id] contribute no size of their own. Controls keep their
   natural height and the row's align-items: flex-end lines them all up
   on one shared baseline. */
.v4-form-mount > form > [data-form-body="basic"] [data-id] {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}

/* Mobile (Studio tab): bar is docked inline, stack fields vertically again
   and let labels reappear so the form is usable on a small screen. */
@media (max-width: 1023.98px) {
  [data-mobile-form-slot] { border-radius: 0; }
  /* Field labels are visible on mobile — the in-tile caption is a duplicate. */
  .v4-tile-caption { display: none !important; }
  .v4-form-mount > form { display: block; }
  .v4-form-mount > form > [data-form-body="basic"] { align-items: stretch; }
  .v4-form-mount > form > [data-form-body="basic"] > * { flex: 0 0 auto; width: 100%; min-width: 0; }
  .v4-advanced-row { flex-wrap: wrap; overflow-x: visible; }
  .v4-form-mount > form > [data-form-body="basic"] > div textarea { min-height: 80px; resize: none; }
  .v4-field-bar [data-v4-field-row] { align-items: stretch; }
}

@media (min-width: 1024px) {
  .v4-field-bar [data-v4-field-row] { align-items: center; }
  .v4-field-bar div:has(> button[data-agent-run-button]) { justify-content: center; }
  .v4-field-bar button[data-agent-run-button] {
    flex-direction: column;
    flex: 0 0 auto;
    margin-top: 0 !important;
  }
  .v4-field-bar button[data-agent-run-button] > .ml-2 { margin-left: 0; }
}

@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] .dropzone-empty,
  .v4-form-mount > form > [data-form-body="basic"] [data-uap-group="basic"] .h-\[115px\] {
    height: 100px;
    max-height: 100px;
  }
  .v4-form-mount > form > [data-form-body="basic"] .dropzone-empty {
    width: 150px;
    min-width: 150px;
  }
  .v4-form-mount > form > [data-form-body="basic"] .dropzone-empty * { font-size: 11px !important; }
  .v4-form-mount > form > [data-form-body="basic"] .dropzone-empty .space-y-1 > *:not(:first-child) { display: none; }
  .v4-form-mount > form > [data-form-body="basic"] .dropzone-empty > div { gap: 6px; justify-content: center; height: 100%; }
}
.v4-form-mount > form > [data-form-body="basic"] [data-component="visual-picker"] .pr-3{
  padding-right: 0.375rem!important;
}
.v4-form-mount > form > [data-form-body="basic"] [data-component="visual-picker"] .pr-3 > div{
  width: 100%;
  height: 100%;
}
.v4-form-mount [data-agent-run-button]{
  margin-top: 0px!important;
}
.v4-form-mount > form > [data-form-body="basic"] [data-component="visual-picker"] .pr-3 > span{
  position: absolute;
  margin: 0px auto;
  width: 92%;
  background: rgba(0, 0, 0, .5);
  text-align: center;
  opacity: .8;
  bottom: 5px;
  border-radius: 10px;
}
@media (min-width: 1024px) {
  .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3 > div{
    width: 28px;
    height: 28px;
  }
  .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3 > span{
    position: static;
    width: auto;
    margin: 0;
    background: none;
    opacity: 1;
    text-align: left;
    border-radius: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3{
  max-width: 100%;
  padding-right: 10px !important;
}
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3[data-v4-name]::before{
  content: attr(data-v4-name);
  order: -1;
  flex: 0 0 auto;
  font-size: 12px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3[data-v4-name] > div{
  order: -2;
}

.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3 > div {
  overflow: hidden;
}
.v4-form-mount > form > [data-form-body="basic"] > .v4-zone-pills [data-component="visual-picker"] .pr-3 > div > div {
  font-size: 0;
}

/* 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; }

/* ==========================================================================
   V4 spotlight hero — only what Tailwind utilities can't express:
   the repeating dot grid, the per-tile depth ramp (each tile reads its own
   --d), and the restyling of runner-rendered markup we don't author.
   Everything else lives as utilities in templates/V4.html.
   ========================================================================== */

.v4-dots {
  pointer-events: none;
  background:
    radial-gradient(rgba(0,0,0,0.06) 1px, transparent 1.2px) 0 0 / 22px 22px,
    radial-gradient(ellipse 260px 120px at 50% 20px, rgba(139,92,246,0.16), transparent 100%),
    radial-gradient(ellipse 380px 170px at 50% 430px, rgba(139,92,246,0.18), transparent 100%),
    radial-gradient(ellipse 360px 360px at 50% 230px, rgba(139,92,246,0.09), transparent 100%);
}
.dark .v4-dots {
  background:
    radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1.2px) 0 0 / 22px 22px,
    radial-gradient(ellipse 260px 120px at 50% 20px, rgba(105,45,180,0.19), transparent 100%),
    radial-gradient(ellipse 380px 170px at 50% 430px, rgba(105,45,180,0.21), transparent 100%),
    radial-gradient(ellipse 360px 360px at 50% 230px, rgba(95,40,165,0.11), transparent 100%);
}

/* V4 replaces the thumbnail strip with the carousel itself, but the preview
   shell still builds one at runtime and the carousel reads its .hero-thumb
   entries as its data source — so hide it rather than removing it. */
body.template-v4 [data-preview-thumbnail-nav] { display: none !important; }

.v4-fan {
  position: relative;
  min-height: 300px;
  /* Card pitch: how far each ring step sits from the one inside it. */
  --v4-side-w: min(300px, 22vw);
  --v4-pitch: calc(var(--v4-side-w) * 0.72);
}
/* Landscape stage: rings shrink and dim outward. */
.v4-tile--main { width: min(380px, 28vw) !important; height: auto !important; aspect-ratio: 4 / 3; }
.v4-eyebrow {
  margin: 0 0 6px; text-align: center;
  font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: 0.01em;
  color: rgba(0,0,0,0.5);
}
.dark .v4-eyebrow { color: rgba(255,255,255,0.55); }
.v4-eyebrow[hidden] { display: none; }
.v4-eyebrow:not([hidden]) {
  font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; color: rgba(0,0,0,0.85);
}
.dark .v4-eyebrow:not([hidden]) { color: rgba(255,255,255,0.92); }
.v4-eyebrow:not([hidden]) ~ [data-agent-title] {
  max-width: 48rem; font-size: 16px; line-height: 1.45; letter-spacing: 0; color: rgba(0,0,0,0.55);
}
.dark .v4-eyebrow:not([hidden]) ~ [data-agent-title] { color: rgba(255,255,255,0.6); }
@media (max-width: 1023.98px) {
  .v4-eyebrow:not([hidden]) ~ [data-agent-title]:not(.is-expanded) {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; cursor: pointer;
  }
}
@media (min-width: 1024px) {
  .v4-eyebrow:not([hidden]) { font-size: 30px; line-height: 36px; margin-bottom: 10px; }
  .v4-eyebrow:not([hidden]) ~ [data-agent-title] { font-size: 18px; }
}

.chain-host-below { padding-bottom: 0px!important; }

/* Stage ships overflow-auto; the fan needs it clipped for the rounded corners. */
.v4-tile--main { overflow: hidden !important; position: relative; z-index: 6; }

/* Result must occupy the stage; flowing under it gets clipped by overflow:hidden. */
.v4-tile--main > .chain-media-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  box-sizing: border-box;
  /* Stage already fixes the box; drop result-renderer's inline ratio. */
  aspect-ratio: auto !important;
}
/* Hide the showcase media while a result is on the stage. */
.v4-tile--main:has(> .chain-media-host) > :is(img, video, picture) { visibility: hidden; }
.v4-tile :is(img, video) { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --o/--d drive a transform, so they must be typed: an untyped custom property
   is a string and the transform never interpolates (nor reliably recomputes).
   @property makes them real numbers the compositor can animate. */
@property --o {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
@property --d {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}

/* Carousel tiles. The ring is laid out absolutely around the centre so the
   strip stays symmetric no matter which item is active: --o is the signed
   offset from the active slot (-2..2) and --d its magnitude. Only transform,
   width and height animate, so a click reads as the ring rotating. */
.v4-tile--side {
  position: absolute;
  bottom: 0;
  /* Anchor every tile on the SAME centre line: a fixed-width box centred with
     margin-left, so a tile's own width can change without shifting its slot
     (translateX(-50%) would re-centre against the new width and drift). */
  left: 50%;
  top: 50%;
  bottom: auto;
  margin-left: calc(var(--v4-side-w) / -2);
  width: calc(var(--v4-side-w) - (var(--d) - 1) * 56px);
  height: calc(var(--v4-side-w) * 0.75 - (var(--d) - 1) * 42px);
  /* Centre the (possibly narrower) card inside its slot, then step it out. */
  transform: translate(calc(
    (var(--v4-side-w) - (var(--v4-side-w) - (var(--d) - 1) * 56px)) / 2
    + var(--o) * var(--v4-pitch)
  ), -50%);
  z-index: calc(5 - var(--d));
  filter: brightness(calc(1.05 - var(--d) * 0.2));
  border: 0; padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #E9E9EC;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  cursor: pointer;
  transition:
    transform .6s cubic-bezier(.34,1.25,.64,1),
    width .6s cubic-bezier(.34,1.25,.64,1),
    height .6s cubic-bezier(.34,1.25,.64,1),
    opacity .3s ease,
    box-shadow .25s ease,
    filter .25s ease,
    scale .25s ease;
}
/* `scale`, not transform: transform carries the slot position. */
.v4-tile--side:hover { scale: 1.035; }
.v4-tile--side:active { scale: 0.98; }

/* Stage swap animation. */
.v4-tile--main.is-switching { animation: v4-stage-pop .6s cubic-bezier(.22,.61,.36,1); }
.v4-tile--main.is-switching > :is(img, video, picture) { animation: v4-stage-in .55s cubic-bezier(.22,.61,.36,1) both; }
.v4-tile--main.is-switching > [data-v4-stage-tag] { animation: v4-tag-in .45s .12s cubic-bezier(.22,.61,.36,1) both; }
@keyframes v4-stage-pop {
  0% { transform: scale(.985); }
  55% { transform: scale(1.012); }
  100% { transform: none; }
}
@keyframes v4-stage-in {
  from { opacity: 0; transform: scale(1.08); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes v4-tag-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .v4-tile--side { transition-duration: 0s; }
  .v4-tile--main.is-switching, .v4-tile--main.is-switching > * { animation: none; }
}
.dark .v4-tile--side { background: #131317; box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
/* The active item is shown by the stage element, so its own tile fades out
   under the stage instead of doubling the centre card. */
.v4-tile--side.is-active { opacity: 0; pointer-events: none; }
/* Beyond the visible ring the tiles would spill past the hero. layout() parks
   them on the centre slot so they reserve no width; they fan out from behind
   the stage as they rotate into view. */
.v4-tile--side.is-far { opacity: 0; pointer-events: none; }
/* Hover lifts the card WITHOUT touching transform — that property carries the
   tile's slot position, so overriding it would snap the card to centre. */
.v4-tile--side:hover { box-shadow: 0 22px 46px rgba(0,0,0,0.22); filter: brightness(calc(1.2 - var(--d) * 0.2)); }
.dark .v4-tile--side:hover { box-shadow: 0 22px 46px rgba(0,0,0,0.6); }

@media (max-width: 1023.98px) {
  /* Phones keep one ring, peeking out behind the stage. */
  .v4-fan { min-height: 0; overflow-x: clip; touch-action: pan-y; --v4-side-w: min(300px, 60vw); --v4-pitch: min(56px, 12vw); }
  .v4-tile--side:hover { scale: none; }
}

/* ── Mode switch (runner-rendered picker, restyled here) ── */
.v4-mode-switch:not(.hidden) { display: flex; }
.v4-mode-switch > * {
  display: inline-flex !important; align-items: center; gap: 4px;
  margin: 0 !important;
  backdrop-filter: blur(10px);
}
.v4-mode-switch [role="radiogroup"],
.v4-mode-switch [data-component="chip-group"] {
  display: inline-flex !important; gap: 0 !important; flex-wrap: nowrap !important;
  padding: 0 !important; background: transparent !important; border: 0 !important; box-shadow: none !important;
}
.v4-mode-switch label:not(:has(input, select, textarea, button)) { display: none !important; }
.v4-mode-switch [data-component="agent-selector"] > :not([role="radiogroup"]),
.v4-mode-inline [data-component="agent-selector"] > :not([role="radiogroup"]) { display: none !important; }
.v4-mode-switch button {
  background: transparent !important; box-shadow: none !important;
  transition: background 0.15s ease, color 0.15s ease;
}
.v4-mode-switch button:hover { color: #111 !important; }
.dark .v4-mode-switch button:hover { color: #fff !important; }

/* ── Prompt bar: card + Generate are authored in the template with utilities;
      these rules only reshape the runner's own fields inside it. ── */
/* The runner injects a credits line under the Generate button when the
   template ships no [data-agent-run-hint]; V4 already prints the cost inside
   the button, so the duplicate is hidden rather than left to flicker in. */
.v4-field-bar [data-agent-run-credits] { display: none !important; }

.v4-generate { flex-direction: column; gap: 4px; }
/* The runner sets display inline. */
.v4-field-bar [data-run-estimate] { display: none !important; }
.dark .v4-field-bar .v4-form-mount,
.dark .v4-field-bar .v4-advanced-row { color: #F4F4F5; }

/* ── Composer: media dock + prompt row + pills ── */
.v4-frame-panel { border-radius: 26px; display: flex; flex-wrap: wrap; align-items: stretch; }
.v4-controls-card { border-radius: 26px; }
.v4-frame-panel > .v4-dock-tile { display: block; flex: 0 0 auto; margin: 0 !important; align-self: flex-start; }
.v4-frame-panel .v4-dock-tile .mb-2:has(label),
.v4-frame-panel .v4-dock-tile .mb-3:has(label),
.v4-frame-panel .v4-dock-tile .media-field-header,
.v4-frame-panel .v4-dock-tile [data-media-url],
.v4-frame-panel .v4-dock-tile details,
.v4-frame-panel .v4-dock-tile p:not([role="alert"]) { display: none !important; }
.v4-frame-panel .v4-dock-tile p[role="alert"] { font-size: 10px; line-height: 12px; margin: 4px 0 0; }

.v4-frame-panel .v4-dock-tile .dropzone-empty {
  padding: 10px 6px !important;
  display: flex !important; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed rgba(0,0,0,0.18) !important; background: transparent !important;
}
.dark .v4-frame-panel .v4-dock-tile .dropzone-empty { border-color: rgba(255,255,255,0.14) !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty:hover { background: rgba(0,0,0,0.04) !important; }
.dark .v4-frame-panel .v4-dock-tile .dropzone-empty:hover { background: rgba(255,255,255,0.05) !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty.hidden { display: none !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty > div {
  display: flex !important; flex-direction: column; align-items: center; gap: 0 !important; height: auto !important;
}
.v4-frame-panel .v4-dock-tile .dropzone-empty > div::before {
  content: '+'; font-size: 26px; line-height: 28px; font-weight: 300; color: hsl(var(--foreground));
}
.v4-frame-panel .v4-dock-tile .dropzone-empty > div > .w-8,
.v4-frame-panel .v4-dock-tile .dropzone-empty .agent-form-upload-title,
.v4-frame-panel .v4-dock-tile .dropzone-empty .agent-form-hint,
.v4-frame-panel .v4-dock-tile .dropzone-empty .min-w-0 { display: none !important; }
.v4-frame-panel .v4-dock-tile .space-y-3 > :is(.justify-between, .gap-2) { display: none !important; }
.v4-frame-panel .v4-dock-tile .space-y-3 > * { margin-top: 0 !important; margin-bottom: 0 !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone {
  height: 80px !important; padding: 6px 4px !important; border-radius: 12px !important;
  border: 1px dashed rgba(0,0,0,0.18) !important; background: transparent !important;
}
.dark .v4-frame-panel .v4-dock-tile .file-drop-zone { border-color: rgba(255,255,255,0.14) !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone:hover { background: rgba(0,0,0,0.04) !important; }
.dark .v4-frame-panel .v4-dock-tile .file-drop-zone:hover { background: rgba(255,255,255,0.05) !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone > div { gap: 0 !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone > div > * { display: none !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone > div::before {
  content: '+'; font-size: 26px; line-height: 28px; font-weight: 300; color: hsl(var(--foreground));
}
.v4-frame-panel .v4-dock-tile .file-drop-zone > [data-multi-count] { top: 4px; right: 5px; font-size: 9px; line-height: 12px; }
.v4-frame-panel .v4-dock-tile .file-drop-zone ~ .grid:not(.hidden) {
  display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 4px !important; margin-top: 6px !important;
}
.v4-frame-panel .v4-dock-tile .file-drop-zone ~ .grid :is(img, video, .h-20) { height: 28px !important; border-radius: 6px !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone ~ .grid .bottom-1 { display: none !important; }
.v4-frame-panel .v4-dock-tile .file-drop-zone ~ .grid button { top: -4px !important; right: -4px !important; width: 16px !important; height: 16px !important; }
.v4-frame-panel .v4-dock-tile .v4-tile-caption {
  font-weight: 500; color: hsl(var(--foreground)); display: block; max-width: 100%; white-space: normal; overflow: hidden; text-overflow: ellipsis;
}

.v4-frame-panel .v4-dock-tile .dropzone-empty + div {
  padding: 0 !important; overflow: hidden; display: flex; border: 1px solid rgba(0,0,0,0.1) !important; background: rgba(0,0,0,0.06) !important;
}
.dark .v4-frame-panel .v4-dock-tile .dropzone-empty + div { border-color: rgba(255,255,255,0.1) !important; background: rgba(255,255,255,0.05) !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty + div.hidden { display: none !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty + div > div { display: block !important; width: 100% !important; height: 100% !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty + div > div > :is(img, video):not(.hidden) {
  display: block; width: 100% !important; height: 100% !important;
  object-fit: cover !important; border-radius: 0 !important; background: transparent !important;
}
.v4-frame-panel .v4-dock-tile .dropzone-empty + div > div > .bottom-2 { display: none !important; }
.v4-frame-panel .v4-dock-tile .dropzone-empty + div > div > button {
  top: 6px !important; right: 6px !important; width: 22px !important; height: 22px !important;
}
.v4-frame-panel .v4-dock-tile .dropzone-empty + div > div > button svg { width: 12px; height: 12px; }

.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] {
  display: flex !important; flex-direction: column; align-items: center; justify-content: center; padding: 10px 6px !important; border: 1px dashed rgba(0,0,0,0.18) !important;
  background: transparent !important; overflow: hidden; text-align: center;
}
.dark .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] { border-color: rgba(255,255,255,0.14) !important; }
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger]:hover { background: rgba(0,0,0,0.04) !important; }
.dark .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger]:hover { background: rgba(255,255,255,0.05) !important; }
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div {
  border-radius: 0 !important; background: transparent !important;
}
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div svg { color: hsl(var(--foreground)); }
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > span {
  font-weight: 500; color: hsl(var(--foreground)); white-space: normal;
}
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] {
  padding: 0 !important; border-style: solid !important; border-color: rgba(0,0,0,0.1) !important;
}
.dark .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] { border-color: rgba(255,255,255,0.1) !important; }
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] > div {
  width: 100% !important; height: 100% !important;
}
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] > div :is(img, video) {
  width: 100% !important; height: 100% !important; object-fit: cover !important;
}
.v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] > span { display: none; }
.v4-frame-panel .v4-dock-tile [data-asset-trigger-box] { display: flex; width: 100%; }
.v4-frame-panel .v4-dock-tile [data-asset-clear] { top: 4px; right: 3px; width: 19px; height: 19px; }
.v4-frame-panel .v4-dock-tile [data-asset-clear] svg { width: 10px; height: 10px; }

.v4-zone-prompt > .v4-attach {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.v4-zone-prompt > .v4-attach:hover { background: var(--panel-hover); }
.v4-zone-prompt > .v4-attach[hidden] { display: none; }
@media (min-width: 1024px) {
  body.template-v4 .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-prompt textarea {
    height: auto !important; max-height: 132px; field-sizing: content;
  }
}

.v4-pill-icon { display: inline-flex; flex: 0 0 auto; margin-right: 8px; color: hsl(var(--foreground)); }
@media (min-width: 1024px) {
  .v4-zone-pills > * { max-width: 280px; }
  .v4-zone-pills [data-component="select"] .relative > button {
    width: auto !important; height: 40px !important; padding: 0 12px !important;
    border-radius: 12px !important; gap: 0 !important;
  }
  .v4-zone-pills [data-component="select"] .relative > button { max-width: 100%; }
  .v4-zone-pills [data-component="select"] .relative > button > .flex-1 { flex: 0 1 auto !important; min-width: 0; }
  .v4-zone-pills [data-component="select"] .relative > button > .flex-1 > div { font-size: 13px !important; font-weight: 600 !important; }
  .v4-zone-pills [data-component="select"] .relative > button > .shrink-0 { display: none !important; }
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger] { gap: 0 !important; }
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger] > div { display: none !important; }
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger] > span:not(.v4-pill-icon) {
    position: static !important; width: auto !important; margin: 0 !important; background: none !important;
    opacity: 1 !important; border-radius: 0 !important; font-size: 13px !important; font-weight: 600 !important;
    color: hsl(var(--foreground)) !important;
  }
}

/* ── Composer look (desktop): colours and states ── */
@media (min-width: 1024px) {
  .v4-split-row { gap: 12px; }

  /* Dock tiles */
  .v4-frame-panel .v4-dock-tile .dropzone-empty > div::before,
  .v4-frame-panel .v4-dock-tile .file-drop-zone > div::before { font-size: 22px; line-height: 24px; }

  /* Prompt row */
  .v4-zone-prompt > .v4-attach { border: 0; color: #3a3a40; }
  .v4-zone-prompt > .v4-attach:hover { background: #E6E6EA; }
  .dark .v4-zone-prompt > .v4-attach:hover { background: #26262a; }
  .v4-zone-prompt > .v4-attach svg { stroke-width: 1.6; }
  .v4-zone-prompt textarea::placeholder { color: #7C7C82 !important; opacity: 1; }

  /* Pills: outlined */
  .v4-zone-pills [data-component="select"] > .relative > button,
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger],
  .v4-zone-pills .v4-pop-trigger,
  .v4-zone-pills .v4-more-trigger {
    background: transparent !important; color: hsl(var(--foreground)) !important; font-size: 13px !important; font-weight: 600 !important; box-shadow: none !important;
  }
  .v4-zone-pills [data-component="select"] > .relative > button:hover,
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger]:hover,
  .v4-zone-pills .v4-pop-trigger:hover { background: rgba(0,0,0,0.04) !important; }
  .dark .v4-zone-pills [data-component="select"] > .relative > button:hover,
  .dark .v4-zone-pills [data-component="visual-picker"] button[data-trigger]:hover,
  .dark .v4-zone-pills .v4-pop-trigger:hover { background: rgba(255,255,255,0.05) !important; }
  .v4-zone-pills [data-component="select"] > .relative > button > .flex-1 > div { font-size: 13px !important; }
  .v4-pill-icon { opacity: 1; position: static !important; }

  /* Generate */
  .v4-field-bar button[data-agent-run-button] { padding: 0; background-image: none; box-shadow: none; font-weight: 600; }
  .v4-field-bar button[data-agent-run-button]:hover { filter: none; }
  .v4-field-bar button[data-agent-run-button] > span:last-child:not(:only-child) { margin: 0 !important; font-weight: 600 !important; gap: 4px; }
}

/* ── Explore Templates gallery ── */
body.template-v4 .v4-spotlight { padding-bottom: 20px; }
.v4-explore { margin-top: 0 !important; border-radius: 22px; padding: 24px; background: #fff; border: 1px solid rgba(0,0,0,0.06); }
.dark .v4-explore { background: #101012; border-color: rgba(255,255,255,0.06); }
.v4-explore[hidden] { display: none; }
.v4-explore-title { margin: 0; font-size: 20px; line-height: 26px; font-weight: 600; color: hsl(var(--foreground)); }
.v4-explore-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v4-explore-source { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9999px; background: rgba(0,0,0,0.05); }
.dark .v4-explore-source { background: rgba(255,255,255,0.06); }
.v4-explore-source > button { height: 32px; padding: 0 16px; border: 0; border-radius: 9999px; background: transparent; font-size: 14px; font-weight: 500; color: #77777c; cursor: pointer; }
.v4-explore-source > button:hover { color: #111; }
.v4-explore-source > button.is-active { background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.dark .v4-explore-source > button { color: #a0a0a5; }
.dark .v4-explore-source > button:hover { color: #fff; }
.dark .v4-explore-source > button.is-active { background: #26262a; color: #fff; box-shadow: none; }
.v4-explore-msg { grid-column: 1 / -1; margin: 0; padding: 40px 0; text-align: center; font-size: 14px; color: #8a8a8f; }
.v4-explore-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.v4-explore-chips[hidden] { display: none; }
.v4-explore-chip {
  height: 36px; padding: 0 14px; border-radius: 10px; border: 0; cursor: pointer;
  font-size: 14px; font-weight: 500; color: hsl(var(--foreground));
  background: rgba(0,0,0,0.06); transition: background 0.15s ease, color 0.15s ease;
}
.v4-explore-chip:hover { background: rgba(0,0,0,0.1); }
.v4-explore-chip.is-active { background: #111; color: #fff; }
.dark .v4-explore-chip { background: #1E1E21; color: #f2f2f4; }
.dark .v4-explore-chip:hover { background: #26262a; }
.dark .v4-explore-chip.is-active { background: #fff; color: #111; }
.v4-explore-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; margin-top: 24px;
}
@media (min-width: 640px) { .v4-explore-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .v4-explore-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .v4-explore-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.v4-explore-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit;
}
.v4-explore-thumb {
  position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden;
  background: rgba(0,0,0,0.06); margin-bottom: 8px;
  transition: box-shadow 0.2s ease, transform 0.2s cubic-bezier(.22,.61,.36,1);
}
.dark .v4-explore-thumb { background: rgba(255,255,255,0.06); }
.v4-explore-thumb > :is(img, video) {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.35s cubic-bezier(.22,.61,.36,1);
}
.v4-explore-card:hover .v4-explore-thumb {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.18), inset 0 0 0 1px rgba(0,0,0,0.08);
}
.dark .v4-explore-card:hover .v4-explore-thumb { box-shadow: 0 12px 28px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.14); }
.v4-explore-card:hover .v4-explore-thumb > :is(img, video) { transform: scale(1.04); }
.v4-explore-card:active .v4-explore-thumb { transform: translateY(-1px) scale(0.99); }
.v4-explore-thumb::after {
  content: ''; position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 9999px;
  background: hsl(var(--primary)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35); opacity: 0; transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.34,1.4,.64,1); pointer-events: none;
}
.v4-explore-card[aria-pressed="true"] .v4-explore-thumb { box-shadow: inset 0 0 0 2.5px hsl(var(--primary)); }
.v4-explore-card[aria-pressed="true"] .v4-explore-thumb::after { opacity: 1; transform: none; }
.v4-explore-card:focus-visible .v4-explore-thumb { box-shadow: inset 0 0 0 2.5px hsl(var(--primary)), 0 0 0 3px hsl(var(--primary) / 0.25); }
.v4-explore-card:focus-visible { outline: none; }
.v4-explore-eyebrow {
  font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dark .v4-explore-eyebrow { color: #d6d6db; }
.v4-explore-name { font-size: 16px; line-height: 20px; font-weight: 600; color: hsl(var(--foreground)); }

/* ── Creations entry ── */
.v4-history-btn {
  position: absolute; top: 16px; right: 16px; z-index: 20;
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px; border-radius: 9999px;
  border: 1px solid rgba(0,0,0,0.1); background: rgba(255,255,255,0.7);
  color: rgba(0,0,0,0.75); font-size: 13px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.v4-history-btn:hover { background: #fff; color: #111; }
.v4-history-btn:active { transform: scale(0.97); }
.dark .v4-history-btn { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.8); }
.dark .v4-history-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.v4-history-btn svg { width: 16px; height: 16px; }
@media (max-width: 639.98px) { .v4-history-btn span { display: none; } .v4-history-btn { padding: 0 10px; } }

.v4-history-back {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px;
  border-radius: 10px; border: 0; cursor: pointer; font-size: 14px; font-weight: 500;
  background: rgba(0,0,0,0.06); color: #111; transition: background 0.15s ease;
}
.v4-history-back:hover { background: rgba(0,0,0,0.1); }
.dark .v4-history-back { background: rgba(255,255,255,0.08); color: #fff; }
.dark .v4-history-back:hover { background: rgba(255,255,255,0.14); }
.v4-history-back svg { width: 12px; height: 12px; }

/* ── My Generations gallery ── */
.v4-history-bar { display: block; margin: 8px 0 18px; }
.v4-history-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.v4-history-title { margin: 0; font-size: 20px; line-height: 26px; font-weight: 600; color: hsl(var(--foreground)); }
.v4-history-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.v4-history-chips[hidden] { display: none; }
body.template-v4 [data-history-grid-view] {
  display: flex !important; flex-wrap: wrap; gap: 16px; align-items: flex-start;
  padding-bottom: 200px;
}
body.template-v4 [data-history-grid-view].hidden { display: none !important; }
body.template-v4 [data-history-grid-view] > .history-grid-item {
  position: relative; flex: 0 1 auto; width: auto; max-width: 100%;
  border-radius: 16px; overflow: hidden; background: rgba(0,0,0,0.06);
}
.dark body.template-v4 [data-history-grid-view] > .history-grid-item { background: rgba(255,255,255,0.05); }
body.template-v4 [data-history-grid-view] > .history-grid-item[hidden] { display: none; }
body.template-v4 [data-history-grid-view] > .history-grid-item > :is(img, video),
body.template-v4 [data-history-grid-view] > .history-grid-item > div:first-of-type > img {
  height: 100% !important; width: auto !important; max-width: none; display: block; object-fit: cover;
}
body.template-v4 [data-history-grid-view] > .history-grid-item > div:first-of-type:not(.history-grid-progress) { height: 100%; width: auto; }
body.template-v4 [data-history-grid-view] > .history-grid-item > .history-grid-overlay { position: absolute; inset: 0; }
body.template-v4 [data-history-grid-view] .history-grid-prompt { display: none; }
.v4-gen-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 18px 18px;
  display: flex; flex-direction: column; gap: 2px; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
  color: #fff; opacity: 0; transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.history-grid-item:hover .v4-gen-caption { opacity: 1; transform: none; }
.v4-gen-eyebrow { font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.85; }
.v4-gen-name { font-size: 16px; line-height: 20px; font-weight: 600; }
body.template-v4 [data-history-list-view] .animate-spin { border-color: hsl(var(--primary)); border-top-color: transparent; }

/* Docked composer */
.v4-float-dock {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(1180px, calc(100vw - 32px)); z-index: 60;
  filter: drop-shadow(0 24px 48px rgba(0,0,0,0.45));
  animation: v4-dock-in 0.4s cubic-bezier(.22,.61,.36,1) both;
}
.v4-float-dock:empty { display: none; }
body:has(#creationDetailModal:not(.hidden)) .v4-float-dock { display: none; }
@keyframes v4-dock-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.v4-float-dock .v4-field-bar { margin: 0; }
.v4-float-dock .v4-frame-panel, .v4-float-dock .v4-controls-card { border-radius: 22px; }
.v4-mode-inline { display: inline-flex; align-items: center; }
.v4-float-dock > .v4-mode-inline { display: flex; justify-content: center; margin: 0 0 10px; }
.v4-mode-inline > * { margin: 0 !important; padding: 0 !important; background: transparent !important; border: 0 !important; }
.v4-mode-inline [role="radiogroup"] {
  display: inline-flex !important; gap: 2px !important; padding: 3px !important;
  border-radius: 12px !important; border: 1px solid rgba(0,0,0,0.12) !important; background: #fff !important;
}
.dark .v4-mode-inline [role="radiogroup"] { border-color: rgba(255,255,255,0.12) !important; background: #121014 !important; }
.v4-mode-inline label:not(:has(input, select, textarea, button)) { display: none !important; }
.v4-mode-inline button {
  height: 28px !important; padding: 0 10px !important; border-radius: 9px !important; border: 0 !important;
  font-size: 13px !important; font-weight: 500 !important; background: transparent !important;
  color: rgba(0,0,0,0.5) !important; box-shadow: none !important;
}
.dark .v4-mode-inline button { color: rgba(255,255,255,0.55) !important; }
.v4-mode-inline button[aria-checked="true"] { background: rgba(0,0,0,0.08) !important; color: #111 !important; font-weight: 600 !important; }
.dark .v4-mode-inline button[aria-checked="true"] { background: rgba(255,255,255,0.14) !important; color: #fff !important; }
@media (max-width: 1023.98px) {
  body.template-v4 [data-history-grid-view] { padding-bottom: calc(var(--v4-dock-h, 360px) + 24px); }
}

/* ── Progress tile (base look lives in creation-history.js) ── */
body.v4-generations-open [data-agent-run-panel="history"] > [data-agent-run-output] { display: none !important; }
body.template-v4 [data-history-grid-view] > .history-grid-item-progress:not([hidden]) {
  width: 300px; display: flex !important; flex-direction: column;
  background: rgba(0,0,0,0.05); border: 1px dashed rgba(0,0,0,0.14);
}
.dark body.template-v4 [data-history-grid-view] > .history-grid-item-progress { background: #121214; border-color: rgba(255,255,255,0.12); }
body.template-v4 [data-history-grid-view] > .history-grid-item-progress > .history-grid-progress { margin: auto; }
body.template-v4 [data-history-grid-view] > .history-grid-item { height: min(440px, 56vh); }
body.template-v4 [data-history-grid-view] > .history-grid-item-progress { height: min(440px, 56vh); }
body.template-v4 [data-history-grid-view] > .history-grid-item:has(> video) { aspect-ratio: 16 / 9; max-width: min(100%, 720px); }
body.template-v4 [data-history-grid-view] > .history-grid-item:has(> video) > video { width: 100% !important; height: 100% !important; object-fit: cover; }

/* ── Phone layout (≤1023px): composer as one card in the hero ── */
@media (max-width: 1023.98px) {
  .v4-tile--main { width: min(360px, 72vw) !important; }
  body.template-v4 main > article.max-w-\[1600px\] { padding-left: 10px; padding-right: 10px; }
  body.template-v4 .v4-spotlight { padding-left: 12px; padding-right: 12px; padding-bottom: 16px; }
  body.template-v4 .v4-explore { padding: 18px 12px; }
  body.template-v4 .v4-explore-grid { gap: 18px 10px; }
  body.template-v4 .v4-history-bar { padding-left: 8px; padding-right: 8px; }

  .v4-field-bar { margin-top: 18px !important; box-shadow: none; }
  .v4-field-bar > div, [data-mobile-form-slot] { padding: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
  .v4-field-bar [data-v4-field-card] {
    padding: 12px !important; border-radius: 20px !important;
    border: 1px solid rgba(0,0,0,0.08) !important; background: #fff !important; box-shadow: none !important;
  }
  .dark .v4-field-bar [data-v4-field-card] { background: #101012 !important; border-color: rgba(255,255,255,0.08) !important; }
  .v4-field-bar [data-v4-field-row].v4-split-row { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }

  .v4-frame-panel { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 10px; padding: 0; border: 0; background: transparent; }
  .v4-frame-panel:empty { display: none; }
  .v4-frame-panel > .v4-dock-tile { flex: 1 1 0; width: auto; min-width: 0; }
  .v4-frame-panel .v4-dock-tile .dropzone-empty,
  .v4-frame-panel .v4-dock-tile .dropzone-empty + div,
  .v4-frame-panel .v4-dock-tile .file-drop-zone,
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] {
    width: 100% !important; min-width: 0 !important; max-width: none !important;
    height: 104px !important; min-height: 104px !important; max-height: 104px !important;
    border-radius: 16px !important; gap: 10px;
  }
  .v4-frame-panel .v4-dock-tile .dropzone-empty + div > div > :is(img, video):not(.hidden),
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger][data-filled] > div :is(img, video) { object-fit: contain !important; }
  .v4-frame-panel .v4-dock-tile .v4-tile-caption { display: block !important; font-size: 12px; line-height: 14px; font-weight: 600; }
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > span { font-size: 12px; line-height: 14px; font-weight: 600; }
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div { width: 28px !important; height: 28px !important; }
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div svg { width: 26px !important; height: 26px !important; }
  .v4-controls-card { display: flex; flex-direction: column; gap: 12px; padding: 0; border: 0; background: transparent; }
  /* An empty media zone would double the gap above the pills. */
  .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-media:empty { display: none; }

  .v4-form-mount > form > [data-form-body="basic"] [data-id] .mb-1\.5,
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .mb-2,
  .v4-form-mount > form > [data-form-body="basic"] [data-id] > .mb-3:has(label),
  .v4-form-mount > form > [data-form-body="basic"] [data-id] label:not(:has(input, select, textarea, button)),
  .v4-form-mount > form > [data-form-body="basic"] [data-id] [data-help-trigger],
  .v4-form-mount > form > [data-form-body="basic"] [data-id] .media-field-header { display: none !important; }
  .v4-form-mount > form > [data-form-body="basic"] { display: flex; flex-direction: column; gap: 12px; }

  /* Prompt row */
  .v4-zone-prompt {
    display: flex; flex-direction: row; align-items: flex-start; gap: 10px;
    padding: 6px 10px; border-radius: 14px; background: rgba(0,0,0,0.05);
  }
  .dark .v4-zone-prompt { background: rgba(255,255,255,0.06); }
  .v4-zone-prompt > .v4-attach { width: 36px; height: 36px; margin-top: 4px; border-radius: 10px; border: 0; background: rgba(0,0,0,0.06); color: #3a3a40; flex: 0 0 auto; }
  .dark .v4-zone-prompt > .v4-attach { background: rgba(255,255,255,0.1); color: #d0d0d5; }
  .v4-zone-prompt > .v4-attach svg { width: 18px; height: 18px; stroke-width: 1.6; }
  .v4-zone-prompt > [data-id] { flex: 1 1 auto; width: auto; min-width: 0; }
  .v4-zone-prompt [data-id] .rounded-xl.border { border: 0 !important; padding: 0 !important; background: transparent !important; box-shadow: none !important; }
  body.template-v4 .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-prompt textarea {
    min-height: 44px !important; height: auto !important; max-height: 140px; field-sizing: content;
    font-size: 14px !important; line-height: 21px; padding: 11px 0 !important;
    background: transparent !important; border: 0 !important; box-shadow: none !important; resize: none;
  }
  .v4-zone-prompt textarea::placeholder { color: #7C7C82 !important; opacity: 1; font-size: 14px; line-height: 21px; }

  .v4-zone-pills {
    display: flex; flex-direction: row; flex-wrap: nowrap; gap: 8px; align-items: center;
    height: 36px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 !important; padding: 0 !important;
  }
  .v4-zone-pills::-webkit-scrollbar { display: none; }
  .v4-zone-pills:empty { display: none; }
  .v4-zone-pills .v4-pop-val { margin-left: 6px; }
  .v4-zone-pills .v4-pop-dot { margin-right: 6px; }
  .v4-zone-pills > * { flex: 0 0 auto; width: auto !important; max-width: 240px; height: 36px; margin: 0 !important; display: flex; align-items: center; }
  .v4-zone-pills > * > * { margin: 0 !important; min-width: 0; max-width: 100%; }
  .v4-zone-pills [data-component="select"] > .relative > button,
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger],
  .v4-zone-pills .v4-pop-trigger,
  .v4-zone-pills .v4-more-trigger {
    width: auto !important; height: 36px !important; min-height: 36px !important; padding: 0 12px !important;
    border-radius: 11px !important; background: rgba(0,0,0,0.05) !important; gap: 0 !important;
    border: 1px solid rgba(0,0,0,0.08) !important; color: hsl(var(--foreground)) !important;
    font-size: 12px !important; font-weight: 600 !important; box-shadow: none !important; white-space: nowrap;
  }
  .dark .v4-zone-pills [data-component="select"] > .relative > button,
  .dark .v4-zone-pills [data-component="visual-picker"] button[data-trigger],
  .dark .v4-zone-pills .v4-pop-trigger,
  .dark .v4-zone-pills .v4-more-trigger { background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.1) !important; }
  .v4-zone-pills [data-component="select"] .relative > button { max-width: 100%; }
  .v4-zone-pills [data-component="select"] .relative > button > .flex-1 { flex: 0 1 auto !important; min-width: 0; }
  .v4-zone-pills [data-component="select"] .relative > button > .flex-1 > div { font-size: 12px !important; font-weight: 600 !important; }
  .v4-zone-pills [data-component="select"] .relative > button > .shrink-0 { display: none !important; }
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger] > div { display: none !important; }
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger] > span:not(.v4-pill-icon) {
    position: static !important; width: auto !important; margin: 0 !important; background: none !important;
    opacity: 1 !important; border-radius: 0 !important; font-size: 12px !important; font-weight: 600 !important;
    color: hsl(var(--foreground)) !important;
  }
  .v4-pill-icon { width: 13px !important; height: 13px !important; margin: 0 7px 0 0 !important; opacity: 1; position: static !important; }
  .v4-pill-icon svg { width: 13px; height: 13px; }

  /* Generate */
  .v4-field-bar [data-v4-field-row] { flex-direction: column; }
  .v4-field-bar div:has(> button[data-agent-run-button]) { flex-direction: row; }
  .v4-field-bar button[data-agent-run-button] {
    width: 100%; height: 50px; max-height: 50px; padding: 0; margin-top: 0 !important;
    border-radius: 15px; background: #8B5CF6; background-image: none; box-shadow: none;
    font-size: 15px; font-weight: 600; flex-direction: row; gap: 10px;
  }
  .v4-field-bar button[data-agent-run-button]:hover { background: #9469F7; filter: none; }
  .v4-field-bar button[data-agent-run-button] > span:last-child:not(:only-child) {
    margin: 0 !important; padding: 3px 9px !important; border-radius: 6px !important;
    background: rgba(255,255,255,0.22) !important; font-size: 12px !important; font-weight: 600 !important; line-height: 17px;
  }
  .v4-explore-title { font-size: 18px; line-height: 24px; }
  .v4-explore-chip { height: 32px; padding: 0 12px; font-size: 13px; }
  .v4-explore-eyebrow { font-size: 10px; }
  .v4-explore-name { font-size: 14px; line-height: 18px; }

  .v4-float-dock { bottom: 10px; width: calc(100vw - 20px); }
}

/* ── Desktop sizes from the 2x design export ── */
@media (min-width: 1024px) {
  .v4-frame-panel, .v4-controls-card {
    border-radius: 19px; background: #fff; border: 1px solid rgba(0,0,0,0.08);
  }
  .dark .v4-frame-panel, .dark .v4-controls-card { background: #121014; border-color: #232024; }
  .v4-controls-card { padding: 16px; gap: 13px; }
  .v4-frame-panel { padding: 16px; gap: 12px; }

  .v4-frame-panel > .v4-dock-tile { width: 64px; }
  .v4-frame-panel .v4-dock-tile .dropzone-empty,
  .v4-frame-panel .v4-dock-tile .dropzone-empty + div,
  .v4-frame-panel .v4-dock-tile .file-drop-zone,
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] {
    width: 64px !important; min-width: 64px !important; max-width: 64px !important;
    height: 80px !important; min-height: 80px !important; max-height: 80px !important;
    border-radius: 12px !important; gap: 8px;
  }
  .v4-frame-panel .v4-dock-tile .rounded-2xl.overflow-hidden { border-radius: 12px; }
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div { width: 22px !important; height: 22px !important; }
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > div svg { width: 20px !important; height: 20px !important; }
  .v4-frame-panel .v4-dock-tile .v4-tile-caption,
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger] > span { font-size: 11px; line-height: 13px; }
  .v4-frame-panel .v4-dock-tile .dropzone-empty,
  .v4-frame-panel .v4-dock-tile .file-drop-zone,
  .v4-frame-panel .v4-dock-tile [data-component="asset-picker"] button[data-trigger]:not([data-filled]) {
    padding-top: 6px !important; padding-bottom: 6px !important; justify-content: center !important;
  }
  .v4-frame-panel .v4-dock-tile .v4-tile-caption {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; flex: none; line-height: 12px;
  }

  .v4-form-mount > form > [data-form-body="basic"] { row-gap: 13px; }
  .v4-zone-prompt { gap: 14px; align-items: center; }
  .v4-zone-prompt > .v4-attach { width: 34px; height: 34px; border-radius: 6px; background: #F0F0F2; }
  .dark .v4-zone-prompt > .v4-attach { background: #232024; color: #d0d0d5; }
  .v4-zone-prompt > .v4-attach svg { width: 18px; height: 18px; }
  .v4-zone-prompt [data-id] .rounded-xl.border { border: 0 !important; padding: 0 !important; background: transparent !important; box-shadow: none !important; }
  body.template-v4 .v4-form-mount > form > [data-form-body="basic"] > .v4-zone-prompt textarea {
    min-height: 34px !important; font-size: 14px !important; line-height: 20px !important; padding: 7px 0 !important;
    background: transparent !important; border: 0 !important; box-shadow: none !important;
  }
  body.template-v4 .v4-form-mount .v4-zone-prompt textarea::placeholder,
  .dark body.template-v4 .v4-form-mount .v4-zone-prompt textarea::placeholder { color: #898A8B !important; opacity: 1; font-size: 14px; }
  .v4-frame-panel .v4-dock-tile .file-drop-zone > [data-multi-count] { color: #898A8B; }

  .v4-zone-pills { gap: 8px; }
  .v4-zone-pills [data-component="select"] > .relative > button,
  .v4-zone-pills [data-component="visual-picker"] button[data-trigger],
  .v4-zone-pills .v4-pop-trigger,
  .v4-zone-pills .v4-more-trigger {
    height: 32px !important; min-height: 32px !important; padding: 0 14px !important;
    border-radius: 8px !important; border: 1px solid rgba(0,0,0,0.12) !important;
  }
  .dark .v4-zone-pills [data-component="select"] > .relative > button,
  .dark .v4-zone-pills [data-component="visual-picker"] button[data-trigger],
  .dark .v4-zone-pills .v4-pop-trigger,
  .dark .v4-zone-pills .v4-more-trigger { border-color: #272727 !important; }
  .v4-pill-icon { width: 13px !important; height: 13px !important; margin: 0 10px 0 0 !important; }
  .v4-pill-icon svg { width: 13px; height: 13px; }

  .v4-field-bar button[data-agent-run-button] {
    width: 108px; min-width: 108px; height: 80px; max-height: 80px;
    border-radius: 17px; background: #8B36EB; font-size: 14px; line-height: 18px; gap: 9px;
  }
  .v4-field-bar button[data-agent-run-button]:hover { background: #9747F2; }
  .v4-field-bar button[data-agent-run-button] > span:last-child:not(:only-child) {
    height: 24px; padding: 0 12px !important; border-radius: 8px !important;
    background: #8B5CF6 !important; font-size: 13px !important; line-height: 24px;
  }
  .v4-field-bar button[data-agent-run-button] > span:last-child svg { width: 11px !important; height: 11px !important; }
}

/* Mode switch per design export. */
.v4-mode-switch > * {
  position: relative; box-sizing: border-box; height: 36px;
  padding: 4px !important; border-radius: 9999px; border: 1px solid transparent;
  background: linear-gradient(180deg, #ECE9F1, #F5F3F8);
  box-shadow: -2px 3px 8px rgba(0,0,0,0.06);
  /* Glass rim: lit top-left and bottom-right. */
  --v4-rim: conic-gradient(
    rgba(0,0,0,0.10) 0deg, rgba(0,0,0,0.20) 70deg, rgba(0,0,0,0.24) 78deg,
    rgba(0,0,0,0.05) 102deg, rgba(0,0,0,0.08) 112deg, rgba(0,0,0,0.10) 180deg,
    rgba(0,0,0,0.18) 248deg, rgba(0,0,0,0.24) 258deg, rgba(0,0,0,0.10) 270deg,
    rgba(0,0,0,0.04) 282deg, rgba(0,0,0,0.08) 292deg, rgba(0,0,0,0.10) 360deg);
}
.v4-mode-switch > *::after,
.v4-mode-switch button[aria-checked="true"]::before,
.v4-mode-switch button[aria-selected="true"]::before {
  content: ''; position: absolute; inset: -1px; padding: 1px; border-radius: inherit; pointer-events: none;
  background: var(--v4-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.v4-mode-switch button {
  position: relative; height: 26px; padding: 0 23px !important; border-radius: 16px !important;
  border: 1px solid transparent !important;
  font-size: 12px !important; font-weight: 400 !important; line-height: 24px;
  color: rgba(0,0,0,0.6) !important;
}
.v4-mode-switch button[aria-checked="true"],
.v4-mode-switch button[aria-selected="true"] {
  background: linear-gradient(180deg, #FFFFFF, #FAF9FC) !important;
  color: #111 !important;
  box-shadow: -1px 2px 5px rgba(0,0,0,0.12) !important;
}
.v4-mode-switch button[aria-checked="true"]::before,
.v4-mode-switch button[aria-selected="true"]::before { opacity: 0.9; }

.dark .v4-mode-switch > * {
  background: linear-gradient(180deg, rgba(0,0,0,0.22), rgba(0,0,0,0.08) 14%, transparent 35%, transparent 65%, rgba(255,255,255,0.032)), #190F22;
  box-shadow: -4px 6px 14px rgba(0,0,0,0.35);
  --v4-rim: conic-gradient(
    rgba(255,255,255,0.40) 0deg, rgba(255,255,255,0.06) 70deg, rgba(255,255,255,0.02) 78deg,
    rgba(255,255,255,0.75) 102deg, rgba(255,255,255,0.45) 112deg, rgba(255,255,255,0.35) 180deg,
    rgba(255,255,255,0.16) 248deg, rgba(255,255,255,0.03) 258deg, rgba(255,255,255,0.45) 270deg,
    rgba(255,255,255,0.77) 282deg, rgba(255,255,255,0.50) 292deg, rgba(255,255,255,0.40) 360deg);
}
.dark .v4-mode-switch button { color: #fff !important; }
.dark .v4-mode-switch button[aria-checked="true"],
.dark .v4-mode-switch button[aria-selected="true"] {
  background: #282130 !important;
  box-shadow: -2px 3px 6px rgba(0,0,0,0.35) !important;
}

/* Last on purpose: overrides the desktop row height. */
@media (max-width: 1023.98px) {
  body.template-v4 [data-history-grid-view] > .history-grid-item,
  body.template-v4 [data-history-grid-view] > .history-grid-item-progress { height: 260px; }
}

/* ── Recreate Template modal ── */
.v4-rt-overlay { position: fixed; inset: 0; z-index: 9998; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,0.72); backdrop-filter: blur(6px); }
.v4-rt-overlay.is-open { display: flex; animation: v4-rt-fade .2s ease both; }
.v4-rt-overlay.is-open .v4-rt-dialog { animation: v4-rt-in .28s cubic-bezier(.22,.61,.36,1) both; }
@keyframes v4-rt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes v4-rt-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.v4-rt-dialog {
  position: relative; width: min(880px, 100%); max-height: 92vh; overflow-y: auto; scrollbar-width: none;
  padding: 36px; border-radius: 24px; background: #fff; border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 30px 80px rgba(0,0,0,0.25); color: #111;
}
.dark .v4-rt-dialog { background: #141116; border-color: rgba(255,255,255,0.08); box-shadow: 0 30px 80px rgba(0,0,0,0.5); color: #fff; }
.v4-rt-dialog::-webkit-scrollbar { display: none; }
.v4-rt-close {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 9999px; border: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; background: rgba(0,0,0,0.06); color: #555;
}
.v4-rt-close:hover { background: rgba(0,0,0,0.1); color: #111; }
.dark .v4-rt-close { background: rgba(255,255,255,0.08); color: #c8c8cc; }
.dark .v4-rt-close:hover { background: rgba(255,255,255,0.14); color: #fff; }
.v4-rt-close svg { width: 14px; height: 14px; }
.v4-rt-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 37px; align-items: start; }
.v4-rt-media { position: relative; aspect-ratio: 644 / 695; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,0.05); }
.dark .v4-rt-media { background: rgba(255,255,255,0.05); }
.v4-rt-media > :is(img, video) { width: 100%; height: 100%; object-fit: cover; display: block; }
.v4-rt-side { display: flex; flex-direction: column; min-width: 0; }
.v4-rt-title { margin: 0 0 26px; font-size: 26px; line-height: 32px; font-weight: 500; }
.v4-rt-label { margin: 0 0 12px; font-size: 13px; line-height: 18px; color: #6B6770; }
.dark .v4-rt-label { color: #8C8792; }
.v4-rt-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 128px; margin-bottom: 38px; border-radius: 16px; border: 1px dashed rgba(0,0,0,0.18);
  background: transparent; color: #111; cursor: pointer;
}
.v4-rt-drop:hover { border-color: rgba(0,0,0,0.35); }
.dark .v4-rt-drop { border-color: rgba(255,255,255,0.14); color: #fff; }
.dark .v4-rt-drop:hover { border-color: rgba(255,255,255,0.28); }
.v4-rt-drop > * { pointer-events: none; }
.v4-rt-drop:focus-visible { outline: 2px solid #8B5CF6; outline-offset: 2px; }
.v4-rt-drop.is-dragover { border-color: #8B5CF6; background-color: rgba(139,92,246,0.1); }
.v4-rt-drop.is-invalid .v4-rt-drop-hint { color: #DC2626; }
.dark .v4-rt-drop.is-invalid .v4-rt-drop-hint { color: #F87171; }
.v4-rt-drop.has-file > :not(.v4-rt-drop-preview) { display: none; }
.v4-rt-drop-preview { display: none; position: relative; height: 100%; padding: 12px 0; }
.v4-rt-drop.has-file .v4-rt-drop-preview { display: block; }
.v4-rt-drop-preview img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; border-radius: 10px; }
.v4-rt-drop-clear {
  position: absolute; top: 4px; right: -8px; width: 22px; height: 22px; border-radius: 9999px; border: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; pointer-events: auto;
  background: rgba(38,38,38,0.85); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.v4-rt-drop-clear:hover { background: rgba(38,38,38,1); }
.v4-rt-drop-clear svg { width: 11px; height: 11px; }
.v4-rt-drop-icon { width: 30px; height: 30px; margin-bottom: 10px; border-radius: 9999px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.06); }
.dark .v4-rt-drop-icon { background: rgba(255,255,255,0.08); }
.v4-rt-drop-icon svg { width: 15px; height: 15px; }
.v4-rt-drop-title { font-size: 13px; font-weight: 600; }
.v4-rt-drop-hint { font-size: 12px; color: #6B6770; }
.dark .v4-rt-drop-hint { color: #8C8792; }
.v4-rt-edit {
  height: 132px; margin-bottom: 28px; padding: 14px 16px; resize: none; border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.1); background: #F6F5F8; color: #111; font-size: 15px; line-height: 22px; outline: none;
}
.v4-rt-edit::placeholder { color: #8A8690; }
.dark .v4-rt-edit { border-color: rgba(255,255,255,0.08); background: #0F0D12; color: #fff; }
.dark .v4-rt-edit::placeholder { color: #8C8792; }
.v4-rt-edit:focus { border-color: rgba(139,92,246,0.6); }
.v4-rt-submit {
  display: flex; align-items: center; justify-content: center; gap: 14px; height: 44px; border: 0; border-radius: 9999px;
  background: linear-gradient(90deg, #8B36EB, #7C3AED); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 12px 30px rgba(139,54,235,0.35);
}
.v4-rt-submit[disabled] { opacity: 0.6; cursor: progress; }
.v4-rt-optional { margin-left: 4px; font-size: 12px; opacity: 0.7; }
.v4-rt-error { margin: -16px 0 16px; font-size: 13px; line-height: 18px; color: #DC2626; }
.v4-rt-error:empty { display: none; }
.dark .v4-rt-error { color: #F87171; }
[data-rt-product][hidden] { display: none; }
.v4-rt-cost { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: 6px; background: rgba(255,255,255,0.2); font-size: 13px; }
.v4-rt-cost[hidden] { display: none; }
.v4-rt-cost svg { width: 11px; height: 11px; }
.v4-rt-more-title { margin: 34px 0 16px; font-size: 16px; line-height: 22px; font-weight: 500; }
.v4-rt-more { display: flex; flex-wrap: wrap; gap: 4px; }
.v4-rt-more-item { flex: 1 1 140px; height: 150px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer; background: rgba(0,0,0,0.05); }
.dark .v4-rt-more-item { background: rgba(255,255,255,0.05); }
.v4-rt-more-item > :is(img, video) { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.v4-rt-more-item:hover > :is(img, video) { transform: scale(1.04); }
@media (max-width: 767.98px) {
  .v4-rt-dialog { padding: 20px; }
  .v4-rt-top { grid-template-columns: 1fr; gap: 20px; }
  .v4-rt-more-item { height: 140px; }
}
@media (prefers-reduced-motion: reduce) { .v4-rt-overlay.is-open, .v4-rt-overlay.is-open .v4-rt-dialog { animation: none; } }
body.template-v4 [data-history-grid-view] > .history-grid-item-checkpoint { flex: 1 0 100%; height: auto !important; background: transparent; }

/* ── Pills that are not dropdowns keep the row's height ── */
.v4-zone-pills { --v4-pill-h: 36px; }
@media (min-width: 1024px) { .v4-zone-pills { --v4-pill-h: 32px; } }
.v4-zone-pills [data-component="input"] input[type="text"] {
  height: var(--v4-pill-h) !important; min-height: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important;
  border-radius: 12px !important; font-size: 13px !important;
}
.v4-zone-pills [data-component="input"] > .inline-flex,
.v4-zone-pills [data-component="input"] > .inline-flex > .flex { height: var(--v4-pill-h) !important; min-height: 0 !important; }
.v4-zone-pills [data-component="input"] > .inline-flex > .flex > button { height: 100% !important; width: 32px !important; }
.v4-zone-pills [data-component="toggle"] > label { height: var(--v4-pill-h); padding-top: 0 !important; padding-bottom: 0 !important; }
.v4-zone-pills [data-component="pill-toggle"] > .inline-flex { height: var(--v4-pill-h); padding: 3px !important; }
.v4-zone-pills [data-component="pill-toggle"] > .inline-flex > button {
  height: 100%; padding: 0 12px !important; font-size: 12px !important; display: inline-flex; align-items: center;
}

body.template-v4 #hero-media-main [data-progress-root] > div { padding: 14px 20px; gap: 8px; }
body.template-v4 #hero-media-main [data-progress-root] .w-20 { width: 56px; height: 56px; }
body.template-v4 #hero-media-main [data-progress-root] [data-progress-circle-pct] { font-size: 14px; }
body.template-v4 #hero-media-main [data-progress-root] [data-leave-hint] { font-size: 11px !important; line-height: 15px; }

.v4-own-tag {
  position: absolute; left: 12px; bottom: 12px; pointer-events: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 12px; line-height: 16px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.v4-own-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.v4-tile.is-own { outline: 2px solid hsl(var(--primary)); outline-offset: -2px; }
.v4-tile--main.is-own { cursor: pointer; }
.v4-stage-regen {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.6); color: #fff; backdrop-filter: blur(8px);
  font-size: 12px; line-height: 16px; font-weight: 600; transition: background 0.15s ease;
}
.v4-stage-regen:hover { background: rgba(0,0,0,0.8); }

.v4-fan.is-running .v4-tile--side { filter: blur(4px) brightness(0.4); pointer-events: none; }

.v4-zone-prompt > .v4-attach { order: 0; }
.v4-zone-prompt > .v4-attach-field { order: 1; flex: 0 0 auto !important; width: 44px !important; height: 44px; margin-right: 8px; align-self: flex-start; }
.v4-zone-prompt > :not(.v4-attach):not(.v4-attach-field) { order: 2; }
.v4-zone-prompt > .v4-attach-field:has(.dropzone-empty:not(.hidden)) { display: none; }
.v4-attach-field .media-field-header, .v4-attach-field input[type="url"], .v4-attach-field p, .v4-attach-field .dropzone-empty { display: none !important; }
.v4-attach-field [data-id], .v4-attach-field [data-id] > .overflow-hidden, .v4-attach-field [data-id] > .overflow-hidden > div:not(.media-busy-row), .v4-attach-field [data-id] > .overflow-hidden > div:not(.media-busy-row) > div {
  width: 44px !important; height: 44px !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; border: 0 !important; border-radius: 10px !important; position: relative;
}
.v4-attach-field img:not(.hidden), .v4-attach-field video:not(.hidden) { width: 44px !important; height: 44px !important; object-fit: cover; border-radius: 10px; }
.v4-attach-field [data-id] > .overflow-hidden { overflow: visible !important; }
.v4-attach-field button.backdrop-blur { position: absolute !important; top: -6px !important; right: -6px !important; width: 18px !important; height: 18px !important; padding: 0 !important; display: flex; align-items: center; justify-content: center; border-radius: 50% !important; }
.v4-attach-field button.backdrop-blur svg { width: 10px; height: 10px; }
.v4-attach-field div.backdrop-blur { display: none !important; }
.v4-zone-prompt:has(> .v4-attach-field .dropzone-empty.hidden) > .v4-attach { display: none; }

[data-v4-field-card] [data-id] p.text-red-500 { display: none !important; }
[data-v4-field-card] [data-id]:has(p.text-red-500:not(.hidden)) :is(button[data-trigger], .dropzone-empty, textarea, select, input:not([type="file"]):not([type="hidden"])) {
  outline: 1.5px solid #ef4444 !important; outline-offset: -1.5px;
}
.v4-form-errors { margin: 8px 14px 4px; font-size: 12px; line-height: 16px; color: #f87171; text-align: center; }
.v4-form-errors[hidden] { display: none; }

.v4-controls-card.is-dragover { outline: 1.5px dashed hsl(var(--primary)); outline-offset: -1.5px; background: hsl(var(--primary) / 0.08) !important; }

/* Justified rows; the ::after filler keeps the last row unstretched. */
body.template-v4 [data-history-grid-view] > .history-grid-item { flex-grow: 1; }
body.template-v4 [data-history-grid-view] > .history-grid-item > :is(img, video),
body.template-v4 [data-history-grid-view] > .history-grid-item > div:first-of-type:not(.history-grid-progress),
body.template-v4 [data-history-grid-view] > .history-grid-item > div:first-of-type > img { min-width: 100%; }
body.template-v4 [data-history-grid-view] > .history-grid-item:has(> video) { max-width: min(100%, 1100px); flex: 25 1 40%; }
body.template-v4 [data-history-grid-view]::after { content: ''; flex: 100000 1 0; }

.v4-fan.is-glide .v4-tile--side { margin-left: 0; transition: box-shadow .25s ease, scale .25s ease, filter .25s ease; will-change: transform, opacity; }
.v4-fan.is-glide:not(.is-running) .v4-tile--side, .v4-fan.is-glide:not(.is-running) .v4-tile--side:hover { filter: none; }

@media (max-width: 1023.98px) {
  .v4-fan { margin-top: 40px; }
  .v4-tile--main { width: 60% !important; height: auto !important; aspect-ratio: 13.5 / 15; }
}

@media (hover: none) {
  body.template-v4 [data-history-grid-view] .history-grid-overlay > .opacity-0 { opacity: 1 !important; }
}

.v4-dock-handle { display: none; }
@media (max-width: 1023.98px) {
  body.v4-generations-open .v4-float-dock { padding-top: 14px; }
  body.v4-generations-open .v4-dock-handle {
    display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 2;
    width: 56px; height: 14px; padding: 0; border: 0; background: transparent; cursor: pointer;
  }
  body.v4-generations-open .v4-dock-handle::before {
    content: ''; display: block; width: 36px; height: 4px; margin: 5px auto; border-radius: 999px; background: rgba(255,255,255,0.35);
  }
  body.v4-generations-open .v4-float-dock.is-collapsed { padding-top: 0; }
  body.v4-generations-open .v4-float-dock.is-collapsed .v4-dock-handle,
  body.v4-generations-open .v4-float-dock.is-collapsed > .v4-mode-inline,
  body.v4-generations-open .v4-float-dock.is-collapsed .v4-frame-panel,
  body.v4-generations-open .v4-float-dock.is-collapsed .v4-zone-pills,
  body.v4-generations-open .v4-float-dock.is-collapsed [data-v4-advanced-row],
  body.v4-generations-open .v4-float-dock.is-collapsed .v4-form-errors,
  body.v4-generations-open .v4-float-dock.is-collapsed [data-agent-run-button],
  body.v4-generations-open .v4-float-dock.is-collapsed [data-run-estimate] { display: none !important; }
  body.v4-generations-open .v4-float-dock.is-collapsed textarea { height: 1.5em !important; min-height: 0 !important; max-height: 1.5em !important; overflow: hidden !important; pointer-events: none; }
  body.v4-generations-open .v4-float-dock.is-collapsed { cursor: pointer; }
}
.v4-dock-scrim {
  position: fixed; inset: 0; z-index: 59; background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.v4-dock-scrim.is-visible { opacity: 1; pointer-events: auto; }
body:has(#creationDetailModal:not(.hidden)) .v4-dock-scrim { display: none; }
