/* Other creation surfaces can use the same measures without inheriting control styles. */
:root {
  --zw-option-size: 14px;
  --zw-label-size: 13px;
  --zw-caption-size: 12px;
  --zw-title-size: 16px;
  --zw-icon-size: 18px;
  --zw-row-height: 36px;
  --zw-button-radius: 8px;
  --zw-popover-radius: 12px;
  --zw-panel: #262629;
  --zw-selected-surface: #ffffff12;
  --zw-dialog-gutter: 20px;

  @media (pointer: coarse) { --zw-row-height: 44px; }
  @media (max-width: 600px) { --zw-dialog-gutter: 16px; }
}

/* This scope includes workbench dialogs and menus mounted directly under body. */
body:has(.studio-shell.jc-studio:is(.studio-image, .studio-video)) {
  --zw-option-size: 13.5px;
  --zw-label-size: 12.5px;
  --zw-title-size: 15.5px;
  --zw-icon-size: 17px;
  --zw-row-height: 34px;
  --zw-button-radius: 7.5px;
  --zw-dialog-gutter: 19px;
  --zw-record-action-size: 31px;

  @media (max-width: 600px) { --zw-dialog-gutter: 15px; }
  @media (hover: none), (pointer: coarse) {
    --zw-row-height: 44px;
    --zw-record-action-size: 44px;
  }

  & .cg-group > .jc-record-header > p { font-size: 14.5px; }
  @media (max-width: 760px) {
    & .cg-group > .jc-record-header > p { font-size: var(--zw-option-size); }
  }

  & .cg-group :is(.zr-footer, .jc-record-actions) > :is(button, a),
  & .cg-group .zr-footer > .zr-menu > summary {
    box-sizing: border-box;
    min-height: var(--zw-record-action-size);
    padding: 4px 7px;
    font-size: var(--zw-option-size);
    line-height: 19px;
  }
  & .cg-group .zr-footer > .zr-menu > summary {
    width: var(--zw-record-action-size);
    min-width: var(--zw-record-action-size);
    height: var(--zw-record-action-size);
    padding-inline: 0;
  }
  & .cg-group :is(.zr-footer, .jc-record-actions) > button[aria-label="复制提示词"] { padding-inline: 7px; }
  & .cg-group :is(.zr-footer, .jc-record-actions) :is(button, a, summary) > svg {
    flex: 0 0 var(--zw-icon-size);
    width: var(--zw-icon-size);
    height: var(--zw-icon-size);
  }

  /* Navigation labels, account shortcuts, history commands and reference selections. */
  & :is(.creator-back, .creator-navigation > button, .creator-nav-footer > button,
      .ch-sidebar .ch-nav-button, .ch-sidebar .ch-recent-open, .studio-account-popover > button,
      .ch-row-options .ch-row-option, .ch-dialog .ch-action, .ch-dialog .ch-day-all,
      .ch-dialog .ch-project-gallery, .ch-dialog .ch-month select, .ch-dialog .ch-project-name,
      .cd-filters .cd-options .cd-chip, .ca-scopes button, .ca-tabs button, .ca-pills button,
      .ca-pop > button, .ca-options label, .studio-popup .jch-tab, .studio-popup .jch-more,
      .studio-popup .jch-retry, .studio-popup .studio-popup-upload, .native-panel footer button,
      .native-panel nav button, .native-region .native-secondary, .rd-details footer button,
      .zr-dialog footer button, .zr-dialog .zr-model-choices .zr-button,
      .gf-dialog .gf-button, .gf-dialog .gf-choice) {
    box-sizing: border-box;
    min-height: var(--zw-row-height);
    border-radius: var(--zw-button-radius);
    font-size: var(--zw-option-size);
    font-weight: 500;
    line-height: 19px;
  }
  & :is(.creator-navigation > button, .ch-sidebar .ch-nav-button) > span { font-size: inherit; }
  & :is(.creator-navigation, .creator-nav-footer) > button { padding-block: 5px; }
  & .ch-dialog :is(.ch-day-caption, .ch-project-info strong, .ch-tile strong),
  & .studio-header .studio-account :is(.studio-credits, .studio-login, .studio-user),
  & .ch-dialog[data-view="remove"] :is(.ch-confirm-name, .ch-action),
  & .studio-popup .jch-item .jch-name {
    font-size: var(--zw-option-size);
    font-weight: 500;
    line-height: 19px;
  }

  /* The small heading and metadata tiers stay distinct from adjacent actions. */
  & :is(.jc-workspace-label, .ch-sidebar .ch-list-heading, .ch-dialog .ch-new label,
      .cd-filters .cd-group-head strong, .ca-pop legend, .native-field label,
      .native-body dt, .rd-role-field label, .pd-dialog .pd-field, .zr-dialog .zr-info dt,
      .gf-form legend, .zr-dialog .zr-body h3, .ch-day-heading h3) {
    font-size: var(--zw-label-size);
    font-weight: 600;
    line-height: 18px;
  }
  & :is(.ch-dialog .ch-day-context, .ch-dialog .ch-meta, .ch-dialog .ch-muted,
      .ch-dialog .ch-project-info small, .ch-sidebar .ch-project-side-title small,
      .ch-dialog .ch-tile > small, .ca-drawer .ca-name, .ca-drawer .ca-status,
      .jch-media, .jch-status, .rd-details > header p, .native-field small, .native-intro,
      .native-panel header small, .pd-status, .gf-muted, .gf-meta, .zr-dialog .zr-refs small) {
    font-size: var(--zw-caption-size);
    font-weight: 400;
    line-height: 18px;
  }
  & .ch-dialog[data-view="remove"] .ch-confirm-description { font-size: var(--zw-option-size); line-height: 20px; }

  /* Limit surface treatment to UI chrome; thumbnails and media previews retain their shape. */
  & :is(.cd-tools .cd-filters, .ca-drawer .ca-pop, .ch-row-options, .studio-account-popover,
      .zw-native-picker-list[data-creator], .ui-select-popover, .creation-kind-popover,
      .ch-dialog, .studio-popup, .native-panel, .rd-details, .zr-dialog, .gf-dialog, .ca-preview) {
    border-radius: var(--zw-popover-radius);
  }
  & :is(.ca-drawer .ca-pop, .ch-row-options, .studio-account-popover, .zw-native-picker-list[data-creator]) {
    background-color: var(--zw-panel);
  }
  & :is(.ch-dialog .ch-dialog-head h2, .studio-popup header h2, .cd-filter-heading strong,
      .ca-drawer .ca-header strong, .ca-preview header strong,
      .native-panel header h2, .rd-details header h2, .zr-dialog header h2, .gf-dialog .gf-head h2) {
    font-size: var(--zw-title-size);
    font-weight: 600;
    line-height: 22px;
    letter-spacing: 0;
  }
  & :is(.ch-dialog:not([data-view="remove"]) > header, .native-panel > header, .rd-details > header,
      .zr-dialog > header, .gf-dialog > header, .native-panel > footer, .rd-details > footer, .zr-dialog > footer) {
    padding: 12px var(--zw-dialog-gutter);
    column-gap: 8px;
  }
  & :is(.native-panel .native-body, .rd-details .rd-role-field, .zr-dialog .zr-body) { padding-inline: var(--zw-dialog-gutter); }
  & .studio-popup { padding: 12px var(--zw-dialog-gutter) var(--zw-dialog-gutter); }
  & .ch-dialog[data-view="remove"] { --ch-confirm-pad: var(--zw-dialog-gutter); }
  & .ch-dialog[data-view="remove"] .ch-actions { padding: 12px var(--zw-dialog-gutter); }
  & .rd-details > footer > button { white-space: nowrap; }
  & :is(.studio-popup header > button, .ch-dialog .ch-close, .native-panel .native-x,
      .rd-details .rd-dialog-close, .gf-dialog .gf-close, .zr-dialog header > .zr-icon,
      .ca-header .ca-icon, .ca-preview header .ca-icon, .ca-flags .ca-icon, .cd-filter-heading .cd-icon) {
    box-sizing: border-box;
    width: var(--zw-row-height);
    min-height: var(--zw-row-height);
    height: var(--zw-row-height);
    padding: 0;
    border-radius: var(--zw-button-radius);
    flex: none;
  }
  & :is(.creator-nav-shell .creator-back, .creator-navigation > button, .creator-nav-footer > button,
      .creator-brand-row > button, .ch-sidebar .ch-nav-button, .ch-sidebar .ch-recent-more,
      .studio-header .studio-account button, .jc-mobile-toggle, .ch-row-option, .ch-dialog .ch-close,
      .ch-dialog .ch-action, .cd-filter-heading .cd-icon, .cd-rail .cd-icon, .ca-icon, .rd-details > footer > button,
      .studio-popup header > button, .studio-popup-upload, .rd-dialog-close, .native-x, .zr-dialog header > .zr-icon) > svg {
    width: var(--zw-icon-size);
    height: var(--zw-icon-size);
    flex: none;
  }
  & :is(.ch-sidebar .ch-recent-more, .creator-brand-row > button, .jc-mobile-toggle) {
    width: var(--zw-row-height);
    height: var(--zw-row-height);
    flex: none;
    border-radius: var(--zw-button-radius);
  }
  & .ch-row-options .ch-row-option { width: 100%; }

  /* Fields may open native popups or the keyboard-navigable list mirrored by the old picker. */
  & :is(.native-panel .native-field, .rd-role-field, .ch-dialog .ch-month, .zw-image-editor .ie-engine) select,
  & :is(.ch-dialog .ch-new, .ch-fav-search, .ch-inline-name, .native-panel .native-field) input:not([type=checkbox]):not([type=radio]):not([type=range]) {
    box-sizing: border-box;
    min-height: var(--zw-row-height);
    border-radius: var(--zw-button-radius);
    font-size: var(--zw-option-size);
    font-weight: 500;
    line-height: 19px;
  }
  & :is(.zw-native-picker-list[data-creator] [role="option"], .ui-select-popover .ui-select-option,
      .creation-kind-popover button) {
    box-sizing: border-box;
    min-height: var(--zw-row-height);
    border-radius: var(--zw-button-radius);
    font-size: var(--zw-option-size);
    font-weight: 500;
    line-height: 19px;
  }

  /* The active surface is quiet; the focus outline and destructive actions keep their own colors. */
  & :is(.creator-navigation > .is-active, .ch-nav-button.ch-current, .ch-recent-row.ch-selected,
      .cd-tools .cd-options .cd-chip[aria-pressed="true"], .ca-pop .ca-pills button[aria-pressed="true"],
      .studio-popup .jch-tab[aria-pressed="true"], .native-panel nav button[aria-pressed="true"],
      .ch-fav-kinds .ch-action[aria-pressed="true"], .zw-native-picker-list[data-creator] [aria-selected="true"]) {
    color: #f3f3f5;
    background-color: var(--zw-selected-surface);
  }

  & .ca-drawer .ca-search { height: var(--zw-row-height); border-radius: var(--zw-button-radius); }
  & :is(.ca-drawer .ca-search input, .cd-rail .cd-query) { font-size: var(--zw-option-size); }
  & .cd-tools .cd-rail { height: calc(var(--zw-row-height) + 2px); border-radius: var(--zw-button-radius); padding-block: 0; }
  & .cd-rail > .cd-icon { flex: 0 0 var(--zw-row-height); width: var(--zw-row-height); height: var(--zw-row-height); border-radius: var(--zw-button-radius); }
  & .cd-options .cr-range .cr-field,
  & .ca-pop .cr-range .cr-field { height: var(--zw-row-height); border-radius: var(--zw-button-radius); }
  & :is(.cd-options, .ca-pop) .cr-range input { font-size: var(--zw-option-size); font-weight: 500; }
  & :is(.cd-options, .ca-pop) .cr-range .cr-calendar { border-radius: var(--zw-popover-radius); }
  & :is(.cd-options, .ca-pop) .cr-range button {
    min-height: var(--zw-row-height);
    border-radius: var(--zw-button-radius);
    font-size: var(--zw-option-size);
    font-weight: 500;
  }
  & :is(.cd-options, .ca-pop) .cr-range .cr-field { padding-left: 5px; }
  & :is(.cd-options, .ca-pop) .cr-range .cr-trigger { min-height: 0; width: var(--zw-row-height); height: 100%; margin: 0; }
  & :is(.cd-options, .ca-pop) .cr-range .cr-arrow { width: var(--zw-row-height); height: var(--zw-row-height); }
  & :is(.cd-options, .ca-pop) .cr-range button svg { width: var(--zw-icon-size); height: var(--zw-icon-size); }
  & :is(.cd-options, .ca-pop) .cr-range .cr-weekday { font-size: var(--zw-caption-size); }
  & :is(.cd-options, .ca-pop) .cr-range .cr-title { font-weight: 600; }
  & :is(.cd-options, .ca-pop) .cr-grid .cr-cell[aria-pressed="true"] {
    color: #f3f3f5;
    background-color: var(--zw-selected-surface);
    border-color: #ffffff56;
  }
  & :is(.cd-options, .ca-pop) .cr-grid .cr-cell[aria-pressed="true"]:focus-visible { outline-color: #c0c5ce; }
  & .ca-pop legend { margin-bottom: 6px; }

  /* All seven header actions remain visible even on narrow touch screens. */
  @media (max-width: 360px) {
    & .studio-header { gap: 1px; padding-inline: 2px; }
    & .studio-header .studio-account { gap: 1px; }
    & .studio-header .cd-rail { gap: 0; padding-inline: 1px; }
  }
  @media (max-width: 440px) {
    & .rd-details > footer:has(> button:nth-child(4)) { padding-inline: 6px; gap: 2px; }
    & .rd-details > footer:has(> button:nth-child(4)) > button { gap: 2px; padding-inline: 2px; }
    & .rd-details > footer:has(> button:nth-child(4)) > .rd-done { min-width: 44px; }
  }

  @media (pointer: coarse) {
    & :is(.ca-drawer .ca-search input, .cd-rail .cd-query, .ch-fav-search input, .ch-new input, .ch-inline-name input) {
      font-size: 16px;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    & dialog:is(.ch-dialog, .studio-popup, .native-panel, .rd-details, .zr-dialog, .gf-dialog, .ca-preview)[open] {
      animation: zw-workbench-dialog-in 160ms cubic-bezier(.2,.7,.2,1);
    }
    & dialog:is(.ch-dialog, .studio-popup, .native-panel, .rd-details, .zr-dialog, .gf-dialog, .ca-preview)[open]::backdrop {
      animation: zw-workbench-backdrop-in 120ms ease-out;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    & dialog:is(.ch-dialog, .studio-popup, .native-panel, .rd-details, .zr-dialog, .gf-dialog, .ca-preview)[open],
    & dialog:is(.ch-dialog, .studio-popup, .native-panel, .rd-details, .zr-dialog, .gf-dialog, .ca-preview)[open]::backdrop {
      animation: none;
      transition: none;
    }
  }
}

@keyframes zw-workbench-dialog-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes zw-workbench-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* These menus are portaled outside the composer so their sizes are in viewport pixels. */
body:has(.studio-shell.jc-studio) {
  --zw-parameter-surface: var(--zw-panel, #262629);
  --zw-parameter-tray: #ffffff06;
  --zw-parameter-muted: #b5b6bf;
  --zw-parameter-border: #ffffff20;
  --zw-parameter-hover: #ffffff0d;
  --zw-parameter-focus: #b9c1db;
}

.jc-overlay-root :is(#jm-model-panel, #jm-ratio-panel, #jc-count-panel),
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover, .ui-select-popover, .zw-native-picker-list) {
  box-sizing: border-box;
  border: 1px solid var(--zw-parameter-border);
  border-radius: var(--zw-popover-radius, 12px);
  background: var(--zw-parameter-surface);
  color: #ebecf0;
  box-shadow: 0 12px 32px #0005, inset 0 1px #ffffff04;
}

.jc-overlay-root :is(#jm-ratio-panel, #jc-count-panel) { padding: 14px; }
.jc-overlay-root #jm-model-panel { padding: 14px; }
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover, .ui-select-popover, .zw-native-picker-list) { padding: 7px; }

.jc-overlay-root #jm-ratio-panel :is(.jc-popover-title, .vout legend),
.jc-overlay-root #jc-count-panel .jc-popover-title,
.jc-overlay-root #jm-model-panel .jc-model-section-label,
body:has(.studio-shell.jc-studio) .creation-kind-popover > p {
  margin: 0 0 7px;
  padding: 0;
  color: #d2d3da;
  font-size: var(--zw-label-size, 12.5px);
  font-weight: 600;
  line-height: 20px;
}
body:has(.studio-shell.jc-studio) .creation-kind-popover > p,
.jc-overlay-root #jm-model-panel .jc-model-section-label { padding-inline: 8px; }
.jc-overlay-root #jm-ratio-panel :is(.jc-popover-title, .vout legend) {
  color: var(--zw-parameter-muted);
  font-size: var(--zw-caption-size, 12px);
  font-weight: 400;
  line-height: 18px;
}
.jc-overlay-root #jm-ratio-panel .jc-section-title:not(:first-child) { margin-top: 14px; }
.jc-overlay-root #jm-ratio-panel .vout { gap: 14px; }
.jc-overlay-root #jm-ratio-panel .vout fieldset:has(> .vout-readout:last-child) legend { margin: 0; }

.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios, .jc-resolution-options, .vout-options),
.jc-overlay-root #jc-count-panel .jc-count-options {
  gap: 4px;
  padding: 4px;
  background: var(--zw-parameter-tray);
  border-radius: 10px;
}
.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
}
.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios, .jc-resolution-options, .vout-options) {
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
}
.jc-overlay-root #jm-ratio-panel :is(.jc-resolution-options, .vout-options):has(> button:only-child) {
  display: inline-grid;
  width: auto;
  min-width: 76px;
  max-width: 100%;
  grid-template-columns: minmax(0, 1fr);
}
.jc-overlay-root #jm-ratio-panel :is(.jc-resolution-options, .vout-options) > button:only-child { padding-inline: 12px; }

.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios, .jc-resolution-options, .vout-options) > button,
.jc-overlay-root #jc-count-panel .jc-count-options > button,
.jc-overlay-root #jm-model-panel :is(.jc-model-family, .jc-model-option),
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button, .ui-select-popover .ui-select-option, .zw-native-picker-list [role="option"]) {
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--zw-row-height, 34px);
  border: 0;
  border-radius: var(--zw-button-radius, 8px);
  background: transparent;
  box-shadow: none;
  color: #d3d4dc;
  font-size: var(--zw-option-size, 13.5px);
  font-weight: 500;
  line-height: 20px;
  transition: background-color .15s ease, color .15s ease;
}

.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios) > button {
  display: grid;
  grid-template-rows: 19px auto;
  align-content: center;
  place-items: center;
  gap: 3px;
  height: 52px;
  padding: 3px 2px;
  border-radius: 10px;
  font-size: var(--zw-caption-size, 12px);
  font-weight: 400;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}
/* On the narrower video panel seven frames form two balanced rows. */
.jc-overlay-root #jm-ratio-panel .vout-ratios:has(> button:nth-child(7)) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-shape, .vout-ratios i) {
  align-self: center;
  box-sizing: border-box;
  border: 1.4px solid currentColor;
  border-radius: 2px;
}
.jc-overlay-root #jm-ratio-panel .jc-ratio-shape { scale: .95; }
/* Both intrinsic frames render with a 19px long edge. */
.jc-overlay-root #jm-ratio-panel .vout-ratios i { scale: 1.1875; }
.jc-overlay-root #jm-ratio-panel .jc-ratio-grid > button > svg { width: 19px; height: 19px; }
.jc-overlay-root #jm-ratio-panel :is(.vout-options, .jc-resolution-options) > button { border-radius: 10px; }
.jc-overlay-root #jm-ratio-panel :is(.vout-options, .jc-resolution-options) > button,
.jc-overlay-root #jc-count-panel .jc-count-options > button { padding: 4px 6px; }
.jc-overlay-root #jm-ratio-panel .jc-resolution-options { flex-wrap: wrap; }
.jc-overlay-root #jm-ratio-panel .jc-resolution-options > button { flex: 1 1 auto; }

.jc-overlay-root :is(#jm-ratio-panel, #jc-count-panel, #jm-model-panel) button:enabled:hover,
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button:enabled:hover, .ui-select-option.is-active:not(.is-disabled), .zw-native-picker-list [data-active]:not([aria-disabled="true"])) {
  color: #fff;
  background: var(--zw-parameter-hover);
}
.jc-overlay-root :is(#jm-ratio-panel, #jc-count-panel, #jm-model-panel) button[aria-pressed="true"],
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button[aria-checked="true"], .ui-select-popover [aria-selected="true"], .zw-native-picker-list [aria-selected="true"], .studio-popup .jch-tab[aria-pressed="true"]) {
  color: #fff;
  background: var(--zw-selected-surface, #ffffff12);
  box-shadow: inset 0 0 0 1px #ffffff28;
}
.jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios, .jc-resolution-options, .vout-options) > button[aria-pressed="true"] {
  background: var(--zw-selected-surface, #ffffff12);
  box-shadow: none;
}

.jc-overlay-root :is(#jm-ratio-panel, #jc-count-panel, #jm-model-panel) :is(button, input):focus-visible,
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button, .studio-popup .jch-item, .studio-popup .jch-tab):focus-visible,
body:has(.studio-shell.jc-studio) .zw-native-picker-list [data-active] {
  outline: 2px solid var(--zw-parameter-focus);
  outline-offset: -2px;
}
body:has(.studio-shell.jc-studio) .ui-select-popover .ui-select-option.is-active:not(.is-selected,.is-disabled) {
  box-shadow: inset 0 0 0 1px #ffffff52;
}

.jc-overlay-root #jm-ratio-panel :is(.jc-dimensions, .jc-dimensions input, .vout-readout) {
  color: #e6e7ec;
  font-size: var(--zw-option-size, 13.5px);
  font-weight: 500;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.jc-overlay-root #jm-ratio-panel .jc-dimensions { gap: 7px; }
.jc-overlay-root #jm-ratio-panel .jc-dimensions :is(label, input) { margin: 0; }
.jc-overlay-root #jm-ratio-panel .jc-dimensions label {
  min-width: 0;
  min-height: var(--zw-row-height, 34px);
  border-radius: var(--zw-button-radius, 8px);
  background: var(--zw-parameter-tray);
}
.jc-overlay-root #jm-ratio-panel .jc-size-lock {
  flex: 0 0 var(--zw-row-height, 34px);
  height: var(--zw-row-height, 34px);
}
.jc-overlay-root #jm-ratio-panel .jc-size-lock > svg { width: var(--zw-icon-size, 18px); height: var(--zw-icon-size, 18px); }
.jc-overlay-root #jm-ratio-panel .vout input[type="range"] { min-height: var(--zw-row-height, 34px); accent-color: #dadce6; }
.jc-overlay-root #jm-ratio-panel :is(.vout-note, .vout-endpoints, .jc-dimensions > span),
.jc-overlay-root #jc-count-panel .jc-output-spec,
.jc-overlay-root #jm-model-panel :is(.jc-model-copy > small, .jc-clip-duration),
body:has(.studio-shell.jc-studio) :is(.ui-select-option-copy > small, .studio-popup .jch-status, .studio-popup .jch-name) {
  color: var(--zw-parameter-muted);
  font-size: var(--zw-caption-size, 12px);
  font-weight: 400;
  line-height: 18px;
}
.jc-overlay-root #jc-count-panel .jc-output-spec { margin: 8px 0 0; }
.jc-overlay-root #jm-model-panel .jc-model-browser { grid-template-columns: minmax(0, .375fr) minmax(0, .625fr); gap: 12px; }
.jc-overlay-root #jm-model-panel .jc-model-families { padding-right: 10px; }
.jc-overlay-root #jm-model-panel :is(.jc-model-family, .jc-model-option) { padding: 5px 7px; gap: 7px; }
.jc-overlay-root #jm-model-panel :is(.jc-model-family > strong, .jc-model-copy > strong),
body:has(.studio-shell.jc-studio) .ui-select-popover .ui-select-option-copy > span {
  font-size: var(--zw-option-size, 13.5px);
  font-weight: 500;
  line-height: 20px;
}
.jc-overlay-root #jm-model-panel .jc-model-option { padding: 7px 9px; margin-bottom: 4px; }
.jc-overlay-root #jm-model-panel .jc-model-copy { gap: 3px; }
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-model-copy > small) { min-height: 52px; }
.jc-overlay-root #jm-model-panel :is(.jc-model-family > strong, .jc-model-copy > strong, .jc-model-copy > small) {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
body:has(.studio-shell.jc-studio) .ui-select-popover .ui-select-option:has(.ui-select-option-copy > small) {
  padding-block: 7px;
  min-height: 52px;
}
body:has(.studio-shell.jc-studio) .ui-select-popover .ui-select-option-copy:has(> small) {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}
body:has(.studio-shell.jc-studio) .ui-select-popover .ui-select-option-copy > :is(span, small) {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 3px 6px;
}
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) .jc-model-copy { display: contents; }
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) .jc-model-copy > strong { grid-area: 1 / 1 / 2 / 3; }
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) .jc-model-check { grid-area: 1 / 3 / 2 / 4; }
.jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) .jc-model-copy > small { grid-area: 2 / 1 / 3 / 2; }
.jc-overlay-root #jm-model-panel .jc-model-option .jc-clip-duration { grid-area: 2 / 2 / 3 / 4; justify-self: end; white-space: nowrap; }
.jc-overlay-root #jm-model-panel .jc-clip-duration { border-radius: 6px; padding: 0 6px; background: #ffffff0a; }
.jc-overlay-root #jm-model-panel .jc-model-family > .ui-icon:last-child { transform: none; opacity: .72; }
.jc-overlay-root #jm-model-panel :is(.jc-model-check, .jc-model-check > svg, .jc-model-family > .ui-icon:last-child),
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button > .ui-icon, .ui-select-popover .ui-select-check) {
  width: var(--zw-icon-size, 18px);
  height: var(--zw-icon-size, 18px);
  flex-basis: var(--zw-icon-size, 18px);
}
body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button, .ui-select-popover .ui-select-option, .zw-native-picker-list [role="option"]) {
  padding: 5px 7px;
  gap: 7px;
}

body:has(.studio-shell.jc-studio) :is(.native-panel, .rd-details, .studio-popup[aria-labelledby="asset-picker-title"]) {
  background: var(--zw-parameter-surface);
  border-color: var(--zw-parameter-border);
}
body:has(.studio-shell.jc-studio) :is(.rd-details, .native-panel, .studio-popup[aria-labelledby="asset-picker-title"]) h2 {
  font-size: var(--zw-title-size, 16px);
  font-weight: 600;
  line-height: 24px;
}
body:has(.studio-shell.jc-studio) :is(.native-field, .rd-role-field) label {
  font-size: var(--zw-label-size, 12.5px);
  font-weight: 600;
  line-height: 20px;
}
body:has(.studio-shell.jc-studio) :is(.native-panel .native-intro, .native-field small, .native-panel header small, .rd-detail-head p) {
  color: var(--zw-parameter-muted);
  font-size: var(--zw-caption-size, 12px);
  font-weight: 400;
}
body:has(.studio-shell.jc-studio) :is(.native-panel .native-field, .rd-details .rd-role-field) :is(input, textarea, select),
body:has(.studio-shell.jc-studio) :is(.rd-details footer, .native-panel footer, .studio-popup .jch-tabs) button {
  min-height: var(--zw-row-height, 34px);
  font-size: var(--zw-option-size, 13.5px);
  font-weight: 500;
  border-radius: var(--zw-button-radius, 8px);
}
body:has(.studio-shell.jc-studio) .studio-popup .jch-tabs { gap: 4px; }
body:has(.studio-shell.jc-studio) .studio-popup .jch-grid { margin-top: 12px; gap: 8px; }

/* Keep the established touch targets while allowing denser pointer menus. */
@media (pointer: coarse) {
  .jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios) > button { height: 56px; }
}

@media (max-width: 540px) {
  .jc-overlay-root :is(#jm-model-panel, #jm-ratio-panel, #jc-count-panel) { padding: 12px; }
  .jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios) { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
  .jc-overlay-root #jm-ratio-panel :is(.jc-ratio-grid, .vout-ratios) > button { height: 50px; }
  .jc-overlay-root #jm-model-panel { padding: 8px; }
  .jc-overlay-root #jm-model-panel .jc-model-browser { grid-template-columns: clamp(149px, 37%, 166px) minmax(0, 1fr); gap: 7px; }
  .jc-overlay-root #jm-model-panel:has(.jc-clip-duration) .jc-model-browser { grid-template-columns: clamp(106px, 31%, 144px) minmax(0, 1fr); }
  .jc-overlay-root #jm-ratio-panel .jc-ratio-grid:has(> button:nth-child(9)) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .jc-overlay-root #jm-model-panel .jc-model-families { padding-inline-end: 5px; }
  .jc-overlay-root #jm-model-panel .jc-model-family { padding-inline: 5px; }
  .jc-overlay-root #jm-model-panel .jc-model-family > .ui-icon:last-child { display: none; }
  .jc-overlay-root #jm-model-panel .jc-model-option { padding-inline: 6px; }
  .jc-overlay-root #jm-model-panel .jc-model-option:not(:has(.jc-clip-duration)) .jc-model-check:empty { display: none; }
}

@media (max-width: 365px) {
  .jc-overlay-root #jm-model-panel {
    inset-inline-start: 4px !important;
    width: calc(100vw - 8px) !important;
    padding: 7px;
  }
  .jc-overlay-root #jm-model-panel .jc-model-browser { grid-template-columns: 147px minmax(0, 1fr); gap: 5px; }
  .jc-overlay-root #jm-model-panel:has(.jc-clip-duration) .jc-model-browser { grid-template-columns: 106px minmax(0, 1fr); }
  .jc-overlay-root #jm-model-panel .jc-model-family { padding-inline: 3px; }
  .jc-overlay-root #jm-model-panel .jc-model-option { padding-inline: 5px; }
  .jc-overlay-root #jm-model-panel .jc-model-option .jc-model-check { display: none; }
  .jc-overlay-root #jm-model-panel .jc-model-option:has(.jc-clip-duration) .jc-model-copy > strong { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .jc-overlay-root :is(#jm-model-panel, #jm-ratio-panel, #jc-count-panel) button,
  body:has(.studio-shell.jc-studio) :is(.creation-kind-popover > button, .ui-select-popover .ui-select-option, .zw-native-picker-list [role="option"]) {
    transition: none;
  }
}

/* Change only the editable prompt's type, leaving the composition area and tools in place. */
.studio-shell.jm-studio.jc-studio:is(.studio-image, .studio-video) .jc-writing textarea.jc-prompt {
  font-size: calc(var(--wc-input) * .97);
}
.studio-shell.jm-studio.jc-studio:is(.studio-image, .studio-video) .jc-writing textarea.jc-prompt:not(:placeholder-shown) {
  font-size: calc(var(--wc-input) * .97 * .95);
}

.studio-shell.jc-studio:is(.studio-image, .studio-video) .jc-composer-dock > .jc-composer {
  box-sizing: border-box;
  width: 97%;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: space-between;
  row-gap: 4.42px;
}
@supports (height: calc-size(auto, size * 1.03)) {
  .studio-shell.jc-studio:is(.studio-image, .studio-video) .jc-composer-dock > .jc-composer {
    height: calc-size(auto, size * 1.03);
    row-gap: 0;
  }
}

/* Scale the panels within the rail so its width and the footer keep their layout. */
.studio-shell.jc-studio:is(.studio-image, .studio-video) > .creator-nav-shell > :is(.creator-brand-row, .creator-history-section),
.studio-shell.jc-studio:is(.studio-image, .studio-video) > .creator-nav-shell > .creator-navigation > button {
  zoom: 1.0609;
}

/* Only the record heading and visible commands grow. Keep media and overflow menus
   in the workbench's existing layout coordinates. */
.studio-shell:is(.studio-image, .studio-video) .cg-group > .jc-record-header,
.studio-shell:is(.studio-image, .studio-video) .jc-record > :is(.zr-footer, .jc-record-actions) > :is(button, a, .zr-native-reedit),
.studio-shell:is(.studio-image, .studio-video) .jc-record > .zr-footer > .zr-menu > summary {
  zoom: 1.03;
}

/* Icon-only composer actions share the result toolbar's compact tooltip styling. */
.jc-direct-tools .jc-icon-tool[aria-label]::after {
  content: attr(aria-label);
  position: absolute;
  z-index: 50;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  padding: 4px 9px;
  border: 1px solid rgb(255 255 255 / 7%);
  border-radius: 8px;
  background: #38383c;
  box-shadow: 0 4px 14px #0004;
  color: #f5f5f7;
  font-size: var(--zw-caption-size, 12px);
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
}
.jc-direct-tools .jc-icon-tool:focus-visible::after {
  visibility: visible;
  animation: zr-tip-in .14s ease-out;
}
@media (hover: hover) {
  .jc-direct-tools .jc-icon-tool:hover::after {
    visibility: visible;
    animation: zr-tip-in .14s ease-out;
  }
}
@media (max-width: 760px) {
  .jc-direct-tools .jc-icon-tool[aria-label]::after {
    left: 0;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .jc-direct-tools .jc-icon-tool[aria-label]::after { animation: none; }
}

/* Video actions share the top edge. On narrow cards, editing wraps beneath
   the right-hand actions and the player's bottom strip stays available. */
.studio-shell.jc-studio .zr-surface:has(> .jc-result-video) {
  grid-template-columns: minmax(0, 1fr);
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay {
  display: flex;
  flex-flow: row-reverse wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 6px;
  padding: 8px;
  box-sizing: border-box;
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay > :is(.zr-top, .zr-tools) {
  position: static;
  flex: 0 0 auto;
  max-width: 100%;
  --zr-rise: -2px;
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay > .zr-top {
  margin-inline-start: auto;
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay > .zr-tools {
  margin-inline-end: auto;
  contain: layout;
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay .zr-tool-overflow {
  position: static;
}
.studio-shell.jc-studio .jc-result-video + .zr-overlay .zr-overflow-list {
  inset: calc(100% + 7px) auto auto 0;
  transform-origin: top left;
}

@supports (top: anchor(--video-edit-tool bottom)) {
  .jc-result-video + .zr-overlay .zr-visible-tools > .zr-icon:is(:hover, :focus-visible) {
    anchor-name: --video-edit-tool;
  }
  body:has(.jc-result-video + .zr-overlay .zr-visible-tools > .zr-icon:is(:hover, :focus-visible)) > .zr-tooltip {
    position-anchor: --video-edit-tool;
    top: calc(anchor(bottom) + 8px) !important;
    position-try-fallbacks: flip-block;
  }
}

/* Enlarge the editing glyphs inside their existing hit areas. */
.studio-shell.jc-studio .cg-group .zr-overlay > .zr-tools :is(.zr-visible-tools > .zr-icon, .zr-tool-overflow > summary) > svg {
  scale: 1.03;
}

/* Both title actions share the existing hover, keyboard and touch placement. */
.jc-record-header .zw-prompt-reuse > .zw-prompt-actions {
  display: inline-flex;
  align-items: stretch;
  padding: 0;
  box-shadow: none;
  cursor: default;
}
.jc-record-header .zw-prompt-actions > button {
  min-height: inherit;
  padding: 3px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: normal;
  white-space: nowrap;
  cursor: pointer;
}
.jc-record-header .zw-prompt-actions > button:is(:hover, :focus-visible) {
  background: #414145;
}
.jc-record-header .zw-prompt-actions > button:focus-visible {
  outline: 1px solid #b6b6ba;
  outline-offset: -2px;
}
.jc-record-header .zw-prompt-reuse:focus-within > .zw-prompt-actions {
  opacity: 1;
  pointer-events: auto;
}
.jc-record-header .zw-prompt-above > .zw-prompt-actions { bottom: 100%; }
.jc-record-header .zw-prompt-below > .zw-prompt-actions { top: 100%; }

/* Standalone cards and the fullscreen viewer still own their copy controls. */
.cg-group:has(> .jc-record-header .zw-copy-prompt) .jc-record > :is(.jc-record-actions,.zr-footer) > button[aria-label="复制提示词"] {
  display: none;
}

/* Use the same reading scale for commands wherever a creator opens them. */
.studio-shell.jc-studio:is(.studio-image, .studio-video) .jc-composer .jc-toolbar {
  --wc-control: var(--zw-row-height);
}
@media (hover: none), (pointer: coarse) {
  .studio-shell.jc-studio:is(.studio-image, .studio-video) .jc-composer .jc-toolbar .native-open {
    min-width: var(--zw-row-height);
  }
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar :is(.creation-kind-trigger, .jm-control > summary, .ui-select-trigger, .native-open),
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar .jc-cost {
  font-size: var(--zw-option-size);
  font-weight: 500;
  line-height: 19px;
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar :is(.creation-kind-trigger, .jm-control > summary, .ui-select-trigger, .native-open) :is(span, strong) {
  font-size: inherit;
  font-weight: inherit;
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar :is(.creation-kind-trigger, .jm-control > summary, .ui-select-trigger, .native-open, .jc-icon-tool) {
  border-radius: var(--zw-button-radius);
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar :is(.creation-kind-trigger, .jm-control > summary, .ui-select-trigger, .native-open, .jc-icon-tool) > svg:not([data-icon="chevron"]) {
  width: var(--zw-icon-size);
  height: var(--zw-icon-size);
  flex: 0 0 var(--zw-icon-size);
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar [data-icon="chevron"] {
  width: 11.5px;
  height: 11.5px;
  min-width: 11.5px;
  flex: 0 0 11.5px;
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-toolbar :is(.creation-kind-trigger, .ui-select-trigger, .jm-control > summary)[aria-expanded="true"] {
  background-color: var(--zw-selected-surface);
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-tool-tip strong { font-size: var(--zw-label-size); }
.studio-shell.jm-studio.jc-studio .jc-composer .jc-tool-tip span { font-size: var(--zw-caption-size); }

/* These form controls also appear in canvas, script, music and standalone editors. */
:is(.zw-shell, .script-studio, .music-studio, .cw-field) .ui-select > .ui-select-trigger,
:root[data-zw-pickers] :is(.zve, .vo) select:not(.ui-select-native):not([multiple]),
.mc-root :is(.mc-family, .mc-version, .mc-model-pill, .mc-model-trigger, .mc-mode-trigger, .mc-ref-picker),
:is(.zve, .vo) :is(button, a[download]),
:is(.zw-panel-tabs, .ms-mode-switch, .discovery-tabs) > button {
  font-size: var(--zw-option-size);
  line-height: 20px;
  border-radius: var(--zw-button-radius);
  font-weight: 500;
}
.mc-root :is(.mc-version-name, .mc-picked-name, .mc-picked-name > strong) {
  font-size: var(--zw-option-size);
  font-weight: 500;
}
.mc-root :is(.mc-version-note-line, .mc-version-count-price),
.ui-select-popover .ui-select-option-copy > small {
  font-size: var(--zw-caption-size);
  line-height: 17px;
}
.mc-root .mc-control-label, :is(.vo, .zve) form label {
  font-size: var(--zw-label-size);
  font-weight: 600;
}
.mc-root :is(.mc-version-check, .mc-ref-picker) svg,
:is(.zw-shell, .script-studio, .music-studio, .cw-field) .ui-select-trigger > .ui-select-leading {
  width: var(--zw-icon-size);
  height: var(--zw-icon-size);
}
body:has(:where(.app-shell:not(.admin-console), .zw-shell, .cw-field, .mc-root, .mp-app, .vo, .zve)) :is(.ui-select-popover, .zw-native-picker-list, .mc-model-picker, .mc-mode-picker) {
  background-color: var(--zw-panel);
  border-radius: var(--zw-popover-radius);
  border: 1px solid #ffffff20;
}
body:has(:where(.app-shell:not(.admin-console), .zw-shell, .cw-field, .mc-root, .mp-app, .vo, .zve)) :is(.ui-select-popover .ui-select-option, .zw-native-picker-list [role="option"]) {
  box-sizing: border-box;
  min-height: var(--zw-row-height);
  border-radius: var(--zw-button-radius);
  padding: 7px 10px;
  font-size: var(--zw-option-size);
  font-weight: 500;
  line-height: 20px;
}
body:has(:where(.app-shell:not(.admin-console), .zw-shell, .cw-field, .mc-root, .mp-app, .vo, .zve)) .ui-select-popover .ui-select-option-copy { font-size: var(--zw-option-size); }
body:has(:where(.app-shell:not(.admin-console), .zw-shell, .cw-field, .mc-root, .mp-app, .vo, .zve)) :is(.ui-select-option.is-selected, .zw-native-picker-list [role="option"][aria-selected="true"]),
.mc-root .mc-model-picker :is([aria-selected="true"], [aria-pressed="true"]) {
  background-color: var(--zw-selected-surface);
}

/* ReferenceInputs unmounts its deck in text-only modes. Let the writing column
   occupy that space without moving any controls when a reference is available. */
.studio-shell.jm-studio.jc-studio .jc-composer .jc-prompt-row:has(> .jc-ref-rail):not(:has(> .jc-ref-rail .jc-reference-inputs)) {
  grid-template-columns: minmax(0, 1fr);
}
.studio-shell.jm-studio.jc-studio .jc-composer .jc-ref-rail:not(:has(.jc-reference-inputs)) {
  display: none;
}

/* Feedback uses native radios and the same dialog heading and actions as the other tools. */
dialog.gf-dialog[data-generation-report] {
  width: min(464px, calc(100% - 24px));
  max-height: min(85dvh, 680px);
}
dialog.gf-dialog[data-generation-report] .gf-content { padding: 16px 20px 18px; }
dialog.gf-dialog[data-generation-report] .gf-form {
  display: grid;
  margin: 0;
  gap: 18px;
  container-type: inline-size;
}
dialog.gf-dialog[data-generation-report] .gf-types {
  display: block;
  min-inline-size: 0;
  padding: 0;
  margin: 0;
  border: 0;
}
dialog.gf-dialog[data-generation-report] :is(.gf-types legend, .gf-note > span) {
  display: block;
  margin: 0;
  padding: 0;
  font-size: var(--zw-label-size);
  font-weight: 600;
  line-height: 18px;
}
dialog.gf-dialog[data-generation-report] .gf-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 0;
}
dialog.gf-dialog[data-generation-report] .gf-choices label.gf-choice {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: var(--zw-row-height);
  margin: 0;
  padding: 7px 10px;
  gap: 8px;
  border: 1px solid #ffffff20;
  border-radius: var(--zw-button-radius);
  background: #ffffff04;
  font-family: inherit;
  cursor: pointer;
}
dialog.gf-dialog[data-generation-report] .gf-choices .gf-choice input[type="radio"] {
  position: static;
  appearance: auto;
  box-sizing: border-box;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: #e3e3eb;
}
dialog.gf-dialog[data-generation-report] .gf-choice span {
  min-width: 0;
  font-size: var(--zw-option-size);
  font-weight: 500;
  line-height: 20px;
}
dialog.gf-dialog[data-generation-report] .gf-choices .gf-choice:has(:checked) {
  background-color: var(--zw-selected-surface);
  border-color: #ffffff51;
}
dialog.gf-dialog[data-generation-report] .gf-choice:has(:focus-visible) {
  outline: 2px solid #b6bbcd;
  outline-offset: 1px;
}
dialog.gf-dialog[data-generation-report] .gf-choices .gf-choice:has(:focus-visible) input[type="radio"]:focus-visible {
  outline: none;
}
dialog.gf-dialog[data-generation-report] .gf-note {
  display: grid;
  margin: 0;
  gap: 8px;
}
dialog.gf-dialog[data-generation-report] .gf-note textarea {
  width: 100%;
  min-height: 76px;
  height: 86px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid #ffffff22;
  border-radius: var(--zw-button-radius);
  font-size: var(--zw-option-size);
  line-height: 21px;
}
dialog.gf-dialog[data-generation-report] .gf-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}
dialog.gf-dialog[data-generation-report] .gf-actions .gf-button {
  min-height: var(--zw-row-height);
  min-width: 64px;
  padding: 6px 14px;
  font-size: var(--zw-option-size);
  font-weight: 500;
  line-height: 20px;
}
@container (max-width: 299px) {
  dialog.gf-dialog[data-generation-report] .gf-choices { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  dialog.gf-dialog[data-generation-report] .gf-content { padding-inline: 16px; }
}
@media (max-height: 620px) {
  dialog.gf-dialog[data-generation-report] { max-height: min(680px, calc(100dvh - 24px)); }
}
@media (hover: hover) {
  dialog.gf-dialog[data-generation-report] .gf-choices label.gf-choice:hover:not(:has(:checked)) {
    background-color: #ffffff0b;
    border-color: #ffffff3d;
  }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.gf-dialog[data-generation-report] :is(.gf-choice, .gf-button, .gf-close) {
    transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
  }
  dialog.gf-dialog[data-generation-report] .gf-actions .gf-button:active { transform: translateY(1px); }
}

/* Keep the workbench form compact while preserving its writing area and touch targets. */
body:has(.studio-shell.jc-studio:is(.studio-image, .studio-video)) dialog.gf-dialog[data-generation-report] {
  width: min(440px, calc(100% - 24px));

  & .gf-content { padding: 15px var(--zw-dialog-gutter) 17px; }
  & .gf-form { gap: 17px; }
  & :is(.gf-types legend, .gf-note > span) { line-height: 17px; }
  & .gf-choices { gap: 7.5px; margin-top: 7.5px; }
  & .gf-choices label.gf-choice { padding: 6px 9.5px; gap: 7.5px; }
  & .gf-choices .gf-choice input[type="radio"] {
    flex-basis: 15px;
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
  }
  & .gf-choice span, & .gf-actions .gf-button { line-height: 19px; }
  & .gf-note, & .gf-actions { gap: 7.5px; }
  & .gf-note textarea { font-size: 14px; }
  & .gf-actions .gf-button { min-width: 60px; padding-inline: 13px; }
}

/* The layout also reads this size to decide which tools fit before the overflow button. */
.studio-shell.jc-studio .cg-group .zr-overlay :is(.zr-top, .zr-tools) {
  --zr-action-size: 31px;
}
.studio-shell.jc-studio .cg-group .zr-overlay :is(.zr-top, .zr-visible-tools, .zr-menu) > :is(.zr-icon, summary) > svg {
  width: 19px;
  height: 19px;
}
.studio-shell.jc-studio .cg-group .zr-overlay .zr-menu-list :is(.zr-button, .zr-icon) {
  min-height: var(--zr-action-size);
  padding: 5px 8px;
  gap: 8px;
  font-size: var(--zw-option-size, 13px);
  line-height: 18px;
}
.studio-shell.jc-studio .cg-group .zr-overlay .zr-tool-overflow > summary span {
  font-size: var(--zw-option-size, 13px);
  line-height: 18px;
}
@media (hover: none), (pointer: coarse) {
  .studio-shell.jc-studio .cg-group .zr-overlay :is(.zr-top, .zr-tools) {
    --zr-action-size: 44px;
  }
}
@media (hover: none) {
  .studio-shell.jc-studio .cg-group .zr-overlay .zr-tools .zr-tool-overflow > summary {
    padding-inline: 8px;
    gap: 5px;
  }
}

/* The player owns the bottom strip for its native controls. Both existing
   tool groups stay inside the frame, including on exceptionally wide clips. */
.studio-shell.jc-studio .zr-surface:has(> .jc-result-video video[controls]) {
  --video-player-clearance: 76px;
  --video-tool-height: 37px;
  min-width: min(100%, 160px);
}
.studio-shell.jc-studio .zr-surface > .jc-result-video:has(video[controls]) {
  position: relative;
  min-height: calc(var(--video-player-clearance) + 2 * var(--video-tool-height) + 16px);
  max-height: 400px;
}

/* Only the picture opens the larger player. The original control strip and
   the higher result tools keep their own pointer and keyboard handling. */
.jc-result-video > .zv-preview-trigger {
  position: absolute;
  inset: 0 0 var(--video-player-clearance, 84px);
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: zoom-in;
  touch-action: manipulation;
}
.zv-preview-trigger:focus-visible { outline: 2px solid #c5cbed; outline-offset: -3px; }
.studio-shell.jc-studio .jc-result-video:has(video[controls]) + .zr-overlay > .zr-tools {
  bottom: var(--video-player-clearance);
}
@media (hover: none), (pointer: coarse) {
  .studio-shell.jc-studio .zr-surface:has(> .jc-result-video video[controls]) {
    --video-player-clearance: 84px;
    --video-tool-height: 48px;
  }
}

.jc-record-header .zw-prompt-reuse {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

.jc-record-header .zw-use-prompt {
  position: absolute;
  z-index: 3;
  inset-inline-start: var(--zw-use-x,100%);
  top: var(--zw-use-y,50%);
  transform: translateY(-50%);
  box-sizing: border-box;
  min-height: 26px;
  padding: 3px 9px;
  border: 0;
  border-radius: 0 5px 5px 0;
  background: #303033;
  box-shadow: none;
  color: #f3f3f5;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.jc-record-header :is(.zw-prompt-above,.zw-prompt-below) > .zw-use-prompt {
  inset-inline-start: 0;
  top: auto;
  bottom: calc(100% + 3px);
  border-radius: 5px;
  transform: none;
}
.jc-record-header .zw-prompt-below > .zw-use-prompt {
  bottom: auto;
  top: calc(100% + 3px);
}
.jc-record-header .zw-prompt-reuse:focus-within > span {
  border-radius: 4px 0 0 4px;
  background: #303033;
  box-shadow: -3px 0 #303033;
}
.jc-record-header .zw-use-prompt:focus {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) {
  .jc-record-header .zw-prompt-reuse[data-prompt-hover] > span {
    border-radius: 4px 0 0 4px;
    background: #303033;
    box-shadow: -3px 0 #303033;
  }
  .jc-record-header .zw-prompt-reuse[data-prompt-hover] > .zw-use-prompt {
    opacity: 1;
    pointer-events: auto;
  }
  /* Preserve the pointer path from either end of a long prompt to its action. */
  .jc-record-header :is(.zw-prompt-above,.zw-prompt-below)[data-prompt-hover]::before {
    content: "";
    position: absolute;
    z-index: 2;
    left: 0;
    bottom: 100%;
    width: max(100%, 80px);
    height: 35px;
    clip-path: polygon(0 0, 74px 0, 100% 100%, 0 100%);
  }
  .jc-record-header .zw-prompt-below[data-prompt-hover]::before {
    top: 100%;
    bottom: auto;
    transform: scaleY(-1);
  }
}

@media (pointer: coarse) {
  .jc-record-header .zw-use-prompt { min-height: 44px; }
}

/* The preview occupies the same main column as the feed. Navigation and the account header stay in place. */
.jc-main:has(> .zv-viewer) > :is(.jc-workspace, .jc-composer-dock, .ch-return-strip) { display: none; }
.jc-main:has(> .zv-viewer) > .studio-header .jc-workspace-label { display: none; }
.jc-main > .studio-header .zv-back {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-inline-size: var(--zw-row-height, 34px);
  min-block-size: var(--zw-row-height, 34px);
  margin: 0;
  padding: 5px;
  border: 0;
  border-radius: var(--zw-button-radius, 8px);
  background: transparent;
  color: #e1e2e7;
  cursor: pointer;
}
.jc-main > .studio-header .zv-back svg { width: 20px; height: 20px; }

.jc-main > .zv-viewer {
  --zv-bg: #151619;
  --zv-surface: #25262a;
  --zv-text: #e9e9ee;
  --zv-muted: #b2b3bc;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 25vw, 440px);
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--zv-bg);
  color: var(--zv-text);
  text-align: start;
}

.zv-viewer .zv-stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 1.05vw, 20px) clamp(44px, 3vw, 64px);
}
.zv-viewer .zv-media {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  container-type: size;
}
.zv-viewer .zv-media > :is(img,video) {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
}
@supports (width: 1cqw) {
  .zv-viewer .zv-media > :is(img,video) {
    width: min(100cqw, calc(100cqh * var(--zv-aspect, 1)));
    aspect-ratio: var(--zv-aspect, 1);
  }
}
.zv-viewer .zv-media > video { background: #101114; }
.zv-viewer .zv-media > video:fullscreen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.zv-viewer .zv-paging {
  position: absolute;
  z-index: 1;
  inset-inline-end: clamp(5px, .85vw, 16px);
  top: 50%;
  display: grid;
  gap: 8px;
  translate: 0 -50%;
}
.zv-viewer .zv-paging button {
  display: grid;
  place-items: center;
  width: var(--zw-row-height, 34px);
  height: var(--zw-row-height, 34px);
  padding: 0;
  border: 0;
  border-radius: var(--zw-button-radius, 8px);
  background: var(--zv-bg);
  color: var(--zv-text);
  cursor: pointer;
}
.zv-viewer .zv-paging button svg { width: 20px; height: 20px; rotate: 90deg; }
.zv-viewer .zv-paging[hidden], .zv-viewer .zv-capabilities[hidden] { display: none; }

.zv-viewer .zv-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #464750 transparent;
  padding: 8px clamp(20px, 2.45vw, 46px) max(12px, env(safe-area-inset-bottom));
  border-inline-start: 1px solid #ffffff0c;
  background: #18191c;
}
.zv-viewer .zv-panel > * { flex: none; min-width: 0; }
.zv-viewer .zv-panel h2 {
  margin: 0;
  color: var(--zv-muted);
  font-size: var(--zw-label-size, 12.5px);
  font-weight: 500;
  line-height: 20px;
}

.zv-viewer .zv-panel-top {
  padding-bottom: 10px;
  border-bottom: 1px solid #ffffff12;
}
.zv-viewer .zv-panel-top .zr-top {
  display: flex;
  align-items: center;
  gap: 4px;
}
.zv-viewer .zv-panel-top .zr-top > :first-child { margin-inline-end: auto; }
.zv-viewer .zv-panel :is(.zr-icon, .zr-button, .zr-menu > summary, .zv-prompt .zv-copy) {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: var(--zw-row-height, 34px);
  margin: 0;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--zw-button-radius, 8px);
  background: transparent;
  color: var(--zv-text);
  font-family: inherit;
  font-size: var(--zw-option-size, 13.5px);
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.zv-viewer .zv-panel :is(.zr-icon, .zr-button, .zr-menu > summary, .zv-prompt .zv-copy) svg {
  flex: 0 0 var(--zw-icon-size, 18px);
  width: var(--zw-icon-size, 18px);
  height: var(--zw-icon-size, 18px);
}
.zv-viewer .zv-panel-top .zr-top > :is(a,button) { width: auto; height: auto; }
.zv-viewer .zv-panel-top .zr-top > .zr-icon,
.zv-viewer .zv-panel-top .zr-menu > summary {
  width: var(--zw-row-height, 34px);
  height: var(--zw-row-height, 34px);
  padding-inline: 0;
}
.zv-viewer .zv-panel-top .zr-top > :first-child:is(a,button) { width: auto; padding-inline: 8px; margin-inline-end: auto; }
.zv-viewer .zv-panel-top .zr-menu-list { inset: calc(100% + 6px) 0 auto auto; }

.zv-viewer .zv-prompt { margin-top: 16px; }
.zv-viewer .zv-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.zv-viewer .zv-prompt > p {
  min-width: 0;
  max-height: 30vh;
  margin: 0;
  overflow: auto;
  color: var(--zv-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  scrollbar-width: thin;
}
.zv-viewer .zv-prompt .zv-copy { color: var(--zv-muted); }
.zv-viewer .zv-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 8px;
  color: var(--zv-muted);
  font-size: var(--zw-caption-size, 12px);
  line-height: 18px;
  overflow-wrap: anywhere;
}
.zv-viewer .zv-meta > * { max-inline-size: 100%; }
.zv-viewer .zv-meta :is(.zv-tags,.zv-meta-line) { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
.zv-viewer .zv-meta :is(.zv-chip,time,.zv-detail-action) { white-space: nowrap; }
.zv-viewer .zv-meta .zv-chip { max-inline-size: 100%; overflow: hidden; text-overflow: ellipsis; color: #c0c1ca; }
.zv-viewer .zv-meta .zv-chip + .zv-chip { padding-inline-start: 8px; border-inline-start: 1px solid #ffffff20; }
.zv-viewer .zv-meta .zr-button { padding: 2px 4px; color: inherit; font-size: inherit; }

.zv-viewer .zv-capabilities { margin-top: auto; padding-top: 24px; }
.zv-viewer .zv-capabilities h2 { margin-bottom: 6px; }
.zv-viewer .zv-capabilities .zr-tools,
.zv-viewer .zv-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  padding: 5px;
  border-radius: 12px;
  background: var(--zv-surface);
}
.zv-viewer .zv-capabilities .zr-tools :is(.zr-video-actions, .zr-visible-tools),
.zv-viewer .zv-footer .zr-native-reedit { display: contents; }
.zv-viewer .zv-capabilities .zr-tools .zr-icon,
.zv-viewer .zv-footer .zr-button {
  justify-content: flex-start;
  flex: 1 0 calc(50% - 2px);
  width: auto;
  min-width: auto;
  max-width: 100%;
  height: auto;
  min-height: max(38px, var(--zw-row-height, 34px));
  padding: 6px 8px;
  text-align: start;
}
.zv-viewer .zv-tool-label { overflow: hidden; text-overflow: ellipsis; }
.zv-viewer .zv-capabilities .zr-tools:empty,
.zv-viewer .zv-footer:not(:has(:is(button,a,summary))) { display: none; }
.zv-viewer .zv-panel > .zv-footer { margin-top: 8px; }

.jc-main > .studio-header .zv-back:hover,
.zv-viewer :is(button,a,summary):hover:not(:disabled) { color: #fff; background-color: #ffffff0c; }
.zv-viewer button:disabled { opacity: .35; cursor: default; }
.jc-main > .studio-header .zv-back:focus-visible,
.zv-viewer :is(button,a,summary):focus-visible { outline: 2px solid #b9c1db; outline-offset: -2px; }

@media (max-width: 990px) {
  .jc-main > .zv-viewer {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .zv-viewer .zv-stage {
    flex: 0 0 auto;
    height: clamp(208px, 53dvh, 490px);
    padding: 12px clamp(12px, 3vw, 28px);
  }
  .zv-viewer .zv-paging {
    inset-inline-end: max(6px, env(safe-area-inset-right));
    gap: 4px;
  }
  .zv-viewer .zv-paging button { background: #191a1ee6; }
  .zv-viewer .zv-panel {
    flex: 1 0 auto;
    overflow: visible;
    padding: 8px clamp(14px, 3.2vw, 26px) max(16px, env(safe-area-inset-bottom));
    border-inline-start: 0;
    border-top: 1px solid #ffffff0c;
  }
  .zv-viewer .zv-prompt { margin-top: 10px; }
  .zv-viewer .zv-capabilities { padding-top: 16px; }
}
/* At phone widths the artwork's back affordance leaves the header's full row for its existing actions. */
@media (max-width: 440px) {
  .studio-shell.jc-studio .jc-main.zv-viewing > .studio-header {
    position: relative;
    z-index: 3;
    overflow: visible;
  }
  .studio-shell.jc-studio .jc-main.zv-viewing > .studio-header .zv-back {
    position: absolute;
    z-index: 1;
    inset-inline-start: max(8px, env(safe-area-inset-left));
    top: calc(100% + 8px);
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
    background: #191a1ee6;
    font-size: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .zv-viewer .zv-media > :is(img,video) { animation: zv-media-in .16s ease-out; }
  @keyframes zv-media-in { from { opacity: .72; } to { opacity: 1; } }
}
