/* Shared controls for project pages and the creative workspace. */
:is(.project-workspace, .studio-body.projects-desk) {
  --control-ink: var(--creator-text);
  --control-muted: var(--creator-muted);
  --control-accent: var(--creator-accent);
  --control-border: var(--creator-line);
  --control-surface: var(--creator-control);
  --control-focus: var(--creator-accent);
}
:is(.project-workspace, .studio-body.projects-desk) .primary-button {
  min-height: 36px;
  border: 1px solid #a2ee7c;
  border-radius: 10px;
  background: var(--creator-action-fill);
  color: var(--creator-accent-ink);
  font-weight: 750;
  box-shadow: inset 0 1px #fff4, 0 2px 5px #0003;
  transition: transform .16s ease, box-shadow .18s ease, border-color .18s ease, opacity .18s ease;
}
:is(.project-workspace, .studio-body.projects-desk) .primary-button:hover:not(:disabled) {
  border-color: var(--creator-accent-hover);
  background: var(--creator-action-fill-hover);
  color: var(--creator-accent-ink);
  box-shadow: inset 0 1px #fff5, 0 3px 10px #88e66222;
}
:is(.project-workspace, .studio-body.projects-desk) .primary-button:disabled {
  border-color: var(--creator-line);
  background: var(--creator-control);
  color: #8f948f;
  box-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}
:is(.project-workspace, .studio-body.projects-desk) :is(.secondary-button, .square-button, .toolbar-icon, .model-picker-trigger) {
  border: 1px solid var(--control-border);
  border-radius: 9px;
  background-color: var(--control-surface);
  color: var(--control-ink);
}
:is(.project-workspace, .studio-body.projects-desk) :is(.secondary-button, .square-button, .toolbar-icon, .model-picker-trigger):hover:not(:disabled) {
  border-color: var(--creator-edge);
  background-color: var(--creator-hover);
  color: #fff;
}
:is(.project-workspace, .studio-body.projects-desk) :is(.primary-button, .secondary-button, .text-button, .square-button, .toolbar-icon, .model-picker-trigger, .btn-close):focus-visible {
  outline: 2px solid var(--control-focus);
  outline-offset: 2px;
}

:is(.project-workspace, .studio-body.projects-desk) .modal:not(.studio-compact-modal) > .modal-dialog {
  display: flex;
  align-items: center;
  width: min(var(--bs-modal-width), calc(100% - 2 * var(--studio-modal-inset)));
  height: calc(100% - 2 * var(--studio-modal-inset));
  margin: var(--studio-modal-inset) auto;
}
:is(.project-workspace, .studio-body.projects-desk) .modal:not(.studio-compact-modal) > .modal-dialog > .modal-content {
  height: auto;
  max-height: min(100%, var(--studio-modal-height));
}

/* Keep the voice chooser frame fixed while filter result counts change. */
:is(.project-workspace, .studio-body.projects-desk) #voice-modal { --studio-modal-height: 680px; }
:is(.project-workspace, .studio-body.projects-desk) #voice-modal > .voice-modal-dialog {
  height: min(var(--studio-modal-height), calc(100% - 48px));
  margin-block: max(24px, calc((100dvh - var(--studio-modal-height)) / 2));
  margin-inline: auto;
}
:is(.project-workspace, .studio-body.projects-desk) #voice-modal > .voice-modal-dialog > .modal-content {
  height: 100%;
  max-height: 100%;
}
:is(.project-workspace, .studio-body.projects-desk) #voice-modal .modal-body {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.project-workspace :is(#ep-preview-modal, #record-modal) > .modal-dialog > .modal-content {
  height: min(100%, var(--studio-modal-height));
}
.project-workspace #video-modal { --studio-modal-height: 720px; }
.project-workspace #video-modal > .modal-dialog { --bs-modal-width: 650px; }
:is(.project-workspace, .studio-body.projects-desk) .modal > .modal-dialog > .modal-content {
  border: 1px solid var(--creator-line);
  border-radius: 18px;
  background: var(--creator-dialog);
  color: var(--control-ink);
  box-shadow: 0 20px 75px #000a, inset 0 1px #ffffff0a;
}
:is(.project-workspace, .studio-body.projects-desk) .modal-content :is(.modal-header, .modal-footer) {
  gap: 9px;
  padding: 13px clamp(14px, 4vw, 22px);
  border-color: var(--creator-line);
  background: var(--creator-dialog);
}
:is(.project-workspace, .studio-body.projects-desk) .modal-content .modal-title {
  margin: 0;
  color: var(--control-ink);
  font-size: 17px;
  font-weight: 740;
  line-height: 1.35;
}
:is(.project-workspace, .studio-body.projects-desk) .modal-header .text-secondary { font-size: 12px; margin-top: 4px; }
:is(.project-workspace, .studio-body.projects-desk) .modal-header .btn-close {
  flex: 0 0 auto;
  padding: 7px;
  margin: 0 0 0 auto;
  border-radius: 8px;
  background-size: 12px;
}
:is(.project-workspace, .studio-body.projects-desk) .modal-header .btn-close:hover { background-color: var(--creator-hover); }
:is(.project-workspace, .studio-body.projects-desk) .modal-content .modal-body {
  padding: 17px clamp(14px, 4vw, 22px);
  scrollbar-gutter: auto;
}
:is(.project-workspace, .studio-body.projects-desk) .modal-footer > * { margin: 0; }
:is(.project-workspace, .studio-body.projects-desk) .modal-footer .modal-note { margin-inline-end: auto; color: var(--creator-muted); font-size: 12px; }
:is(.project-workspace, .studio-body.projects-desk) .modal-footer :is(.primary-button, .secondary-button) { min-height: 38px; padding-inline: 15px; font-size: 13px; }
:is(.project-workspace, .studio-body.projects-desk) .modal :is(.field > label, .form-label) { margin-bottom: 6px; color: #dbdddb; font-size: 12px; font-weight: 650; }
:is(.project-workspace, .studio-body.projects-desk) .modal :is(.field-help, .studio-compact-hint) { font-size: 12px; line-height: 1.5; }
:is(.project-workspace, .studio-body.projects-desk) .modal .form-control {
  border-color: var(--control-border);
  border-radius: 9px;
  background-color: #151616;
  color: var(--control-ink);
  font-size: 13px;
}
:is(.project-workspace, .studio-body.projects-desk) .form-select:not([multiple]):not([size]) {
  --bs-form-select-bg-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23c7cbc8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.4' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  appearance: none;
  min-height: 36px;
  padding: 6px 32px 6px 11px;
  border-color: var(--control-border);
  border-radius: 9px;
  background-color: var(--control-surface);
  background-position: right 9px center;
  background-size: 14px 14px;
  color: var(--control-ink);
  font-size: 13px;
  transition: background-color .16s ease, border-color .16s ease;
}
:is(.project-workspace, .studio-body.projects-desk) .form-select:hover:not(:disabled) { border-color: var(--creator-edge); background-color: var(--creator-hover); }
:is(.project-workspace, .studio-body.projects-desk) :is(.form-select, .modal .form-control):focus {
  border-color: var(--control-focus);
  box-shadow: 0 0 0 2px #a5f57824;
}
:is(.project-workspace, .studio-body.projects-desk) .form-select:disabled { opacity: .64; cursor: not-allowed; }
:is(.project-workspace, .studio-body.projects-desk) [data-model-picker][hidden], .model-picker-menu[hidden] { display: none; }

.model-picker-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 10px;
  text-align: left;
  transition: background-color .16s ease, border-color .16s ease;
}
:is(.project-workspace, .studio-body.projects-desk) .model-picker-trigger[aria-expanded="true"] { border-color: var(--creator-selected-edge); background: var(--creator-hover); }
:is(.project-workspace, .studio-body.projects-desk) .model-picker-trigger:disabled { color: var(--creator-muted); opacity: .65; cursor: not-allowed; }
.model-picker-icon {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--creator-edge);
  border-radius: 8px;
  background: var(--creator-hover);
  color: var(--creator-text);
}
.model-picker-option[aria-selected="true"] .model-picker-icon { border-color: var(--creator-selected-edge); color: var(--creator-accent); }
.model-picker-icon svg { width: 16px; height: 16px; }
.model-picker-copy { display: grid; flex: 1 1 auto; gap: 2px; min-width: 0; line-height: 1.25; }
.model-picker-copy strong { overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.model-picker-copy small { overflow-wrap: anywhere; color: var(--control-muted); font-size: 11px; }
.model-picker-arrow, .model-picker-check { width: 17px; height: 17px; flex: 0 0 auto; color: var(--creator-muted); }
.model-picker-arrow { transition: transform .18s ease; }
.model-picker-trigger[aria-expanded="true"] .model-picker-arrow { transform: rotate(180deg); }
.model-picker-menu {
  position: absolute;
  z-index: 3;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--creator-edge);
  border-radius: 13px;
  background: var(--creator-dialog);
  color: var(--control-ink);
  box-shadow: 0 12px 36px #000b;
  scrollbar-width: thin;
  scrollbar-color: #5e625f transparent;
}
.model-picker-option { display: flex; align-items: center; gap: 10px; min-height: 51px; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.model-picker-option[aria-selected="true"] { color: var(--control-accent); background: var(--creator-selected); }
.model-picker-option:is(.is-active, :hover):not([aria-selected="true"]) { background: var(--creator-hover); }
.model-picker-option .model-picker-check { visibility: hidden; color: var(--control-accent); }
.model-picker-option[aria-selected="true"] .model-picker-check { visibility: visible; }
.video-parameter-bar { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) 80px 95px; align-items: end; gap: 9px; }
.project-workspace .video-parameter-bar :is(#video-duration, #video-ratio) { min-height: 45px; background-color: var(--control-surface); }
.project-workspace .video-parameter-bar #video-duration { text-align: center; }

@media (max-width: 440px) {
  .video-parameter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .video-model-field { grid-column: 1 / -1; }
  .project-workspace .video-parameter-bar :is(#video-duration, #video-ratio) { min-height: 38px; }
  :is(.project-workspace, .studio-body.projects-desk) .modal-footer .modal-note:not(:empty) { flex: 0 0 100%; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.project-workspace, .studio-body.projects-desk) .primary-button,
  .model-picker-arrow, .model-picker-trigger { transition: none; }
}
