/* ApexFlow theme, 16 October 2026: "Darkroom glass".
   One professional surface system for every screen, after the getlayers.ai
   studio language (glass panels with sheen and rim light, silver pills,
   champagne accents, generous calm spacing), in ApexFlow colours: near-black
   film base, amber safelight, champagne highlights. Loaded last among app
   styles; it overrides older layers and must stay visual only. */

:root {
  --bg: #060606;
  --canvas: #0a0a0b;
  --panel: #0e0e10;
  --raised: #151517;
  --surface: var(--panel);
  --surface-hover: #1a1a1d;
  --line: #ffffff17;
  --line-soft: #ffffff0f;
  --line-strong: #ffffff29;
  --text: #f5f4f0;
  --muted: #a7a7ab;
  --subtle: #85858c;
  --accent: #efb865;
  --accent-hover: #f6cd8e;
  --accent-ink: #1e1408;
  --accent-soft: #efb8651a;
  --accent-line: #efb86559;
  --champagne: #feeae1;
  --cool: #c0cef2;
  --danger: #ff9b95;
  --success: #8fe0b5;

  --glass-fill: #ffffff08;
  --glass-sheen: linear-gradient(180deg, #ffffff0a 0%, #ffffff00 42%);
  --glass-aurora:
    radial-gradient(120% 90% at 0% 0%, #feeae10c, transparent 55%),
    radial-gradient(120% 90% at 100% 100%, #c0cef20a, transparent 60%);
  --glass-rim: inset 0 1px 0 0 #ffffff12;
  --glass-shadow: 0 24px 60px -32px #000000e6;

  --radius-stage: 24px;
  --radius-panel: 18px;
  --radius-card: 14px;
  --radius-control: 12px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --radius-dialog: 24px;

  --content-max: 1760px;
  --page-pad: clamp(16px, 2.4vw, 40px);
  --field-h: 44px;
  --field-focus-border: #ffffff3d;
  --field-focus-ring: 0 0 0 3px #efb8651c;
}

html,
body {
  background: var(--bg);
}
body {
  color: var(--text);
  letter-spacing: -0.003em;
}

/* Scrollbars: thin, rounded, never arrow buttons. */
* {
  scrollbar-width: thin;
  scrollbar-color: #ffffff2b transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #ffffff24;
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #ffffff3d;
}

/* ── Surfaces ───────────────────────────────────────────────────────── */
:is(
    .modal,
    .admin-panel,
    .admin-metric,
    .admin-summary,
    .admin-note,
    .studio-create-card,
    .studio-status-card,
    .studio-story,
    .studio-export,
    .studio-pipeline,
    .studio-inspector,
    .studio-stage-card,
    .studio-board-card,
    #studio-timeline-panel,
    .studio-create-footer,
    .pool-card,
    .project-card,
    .job-card,
    .history-entry,
    .composer,
    .admin-table-wrap,
    .settings-popover
  ) {
  background:
    var(--glass-sheen),
    var(--glass-aurora),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--glass-rim);
}
.job-card.job-failed {
  background:
    radial-gradient(90% 70% at 0% 0%, #ff9b9512, transparent 60%),
    var(--glass-sheen),
    var(--panel);
}
:is(.admin-panel, .admin-summary, .studio-create-card, .studio-status-card, .studio-story, .studio-export, .studio-inspector, #studio-timeline-panel) {
  border-radius: var(--radius-panel);
}
:is(.admin-metric, .studio-stage-card, .studio-board-card, .pool-card, .project-card, .history-entry, .admin-note) {
  border-radius: var(--radius-card);
}

/* ── Typography ─────────────────────────────────────────────────────── */
:is(.admin-page-heading h1, .gallery-heading h1, #gallery-heading h1, .studio-create-heading h1, .studio-title h1, .home-section h2) {
  font-weight: 600;
  letter-spacing: -0.04em;
  background: linear-gradient(122deg, var(--text) 30%, #b9b7b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow,
.admin-eyebrow,
.admin-page-context {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.primary-button,
.generate-button:not(:disabled) {
  border-radius: var(--radius-pill);
  border: 1px solid #ffe2b366;
  background: linear-gradient(135deg, #fbe2b8 0%, #f3c47e 46%, #e9a955 100%);
  color: var(--accent-ink);
  font-weight: 700;
  padding-inline: 20px;
  box-shadow:
    inset 0 1px 0 #ffffffa6,
    inset 0 -10px 18px -12px #a5651c80,
    0 10px 30px -14px #efb865a6;
}
.primary-button:hover:not(:disabled),
.generate-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #fde9c7 0%, #f6cd8e 46%, #eeb262 100%);
  box-shadow:
    inset 0 1px 0 #ffffffb3,
    inset 0 -10px 18px -12px #a5651c80,
    0 14px 36px -12px #efb865c4;
}
.primary-button:disabled {
  background: #ffffff0d;
  color: var(--subtle);
  border-color: var(--line);
  box-shadow: none;
  opacity: 1;
}
/* Silver glass pill (secondary). */
.subtle-button {
  position: relative;
  border-radius: var(--radius-pill);
  border: 0;
  background: #ffffff0e;
  color: var(--text);
  padding-inline: 16px;
  font-weight: 600;
  box-shadow:
    inset 0 1px 1px #ffffff26,
    inset 0 -12px 22px -16px #ffffff2e,
    inset 0 0 0 1px #ffffff14;
}
.subtle-button:hover:not(:disabled) {
  background: #ffffff17;
  box-shadow:
    inset 0 1px 1px #ffffff33,
    inset 0 -16px 26px -16px #ffffff3d,
    inset 0 0 0 1px #ffffff24;
}
.subtle-button:disabled {
  opacity: 0.5;
}
.subtle-button.danger,
.danger.subtle-button,
.menu-row.danger,
[data-admin="license-toggle"].danger {
  color: var(--danger);
  background: #ff9b950d;
  box-shadow:
    inset 0 1px 1px #ffffff14,
    inset 0 0 0 1px #ff9b9533;
}
.icon-button {
  border-radius: 12px;
}
.icon-button:hover:not(:disabled) {
  background: #ffffff12;
}
.modal-actions,
.admin-actions,
.studio-page #film-actions,
.gallery-heading-actions {
  gap: 10px !important;
}

/* ── Fields ─────────────────────────────────────────────────────────── */
:is(
    .text-input,
    .modal input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
    .modal select,
    .modal textarea,
    .studio-page textarea,
    .studio-page input:not([type="checkbox"]):not([type="range"]):not([type="file"]),
    .studio-page select,
    .admin-form input,
    .admin-form select,
    .admin-form textarea,
    .admin-main select,
    .admin-main input[type="search"],
    .admin-main input[type="text"],
    .admin-main input[type="number"]
  ) {
  background: #0b0b0c;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  min-height: var(--field-h);
  color: var(--text);
  box-shadow: inset 0 1px 0 #00000080;
}
:is(.text-input, .modal :is(input, select, textarea), .studio-page :is(input, select, textarea), .admin-form :is(input, select, textarea), .admin-main :is(input, select)):hover:not(:focus):not(:disabled) {
  border-color: #ffffff24;
}
/* Browser autofill must not paint fields light blue. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent);
  -webkit-box-shadow: 0 0 0 1000px #0b0b0c inset !important;
  transition: background-color 9999s ease-out 0s;
}
/* File inputs: one styled control instead of the native grey button. */
input[type="file"] {
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed #ffffff26;
  border-radius: var(--radius-control);
  padding: 10px;
  width: 100%;
  background: #ffffff05;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font: 600 12px Manrope, "Segoe UI", sans-serif;
  color: var(--text);
  background: #ffffff14;
  box-shadow: inset 0 1px 0 #ffffff26;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: #ffffff1f;
}
/* Checkboxes: a quiet square that lights amber when checked. */
input[type="checkbox"]:not([role="switch"]) {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  border-radius: 6px;
  border: 1px solid #ffffff38;
  background: #0b0b0c;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease;
}
input[type="checkbox"]:not([role="switch"])::after {
  content: "";
  width: 9px;
  height: 5px;
  border: 2px solid var(--accent-ink);
  border-top: 0;
  border-right: 0;
  translate: 0 -1px;
  rotate: -45deg;
  scale: 0;
  transition: scale var(--dur-fast) var(--ease-out);
}
input[type="checkbox"]:not([role="switch"]):checked {
  background: linear-gradient(135deg, #fbe2b8, #efb865);
  border-color: #ffe2b380;
}
input[type="checkbox"]:not([role="switch"]):checked::after {
  scale: 1;
}
/* Switches (role=switch checkboxes). */
input[type="checkbox"][role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  flex: 0 0 34px;
  margin: 0;
  border-radius: 99px;
  background: #ffffff1f;
  box-shadow: inset 0 0 0 1px #ffffff1a;
  position: relative;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease;
}
input[type="checkbox"][role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f5f4f0;
  box-shadow: 0 1px 3px #0009;
  transition: translate var(--dur-med) var(--ease-out);
}
input[type="checkbox"][role="switch"]:checked {
  background: linear-gradient(135deg, #f6cd8e, #e9a955);
}
input[type="checkbox"][role="switch"]:checked::after {
  translate: 14px 0;
}

/* ── Dialogs ────────────────────────────────────────────────────────── */
.modal-overlay {
  background: #030304b8;
  backdrop-filter: blur(10px) saturate(120%);
}
.modal {
  border-radius: var(--radius-dialog);
  border-color: #ffffff1f;
  background:
    var(--glass-sheen),
    radial-gradient(120% 70% at 0% 0%, #feeae10f, transparent 55%),
    radial-gradient(120% 80% at 100% 100%, #c0cef20c, transparent 60%),
    #0d0d0f;
  box-shadow:
    inset 0 1px 0 #ffffff14,
    0 40px 120px -40px #000,
    0 0 0 1px #00000080;
}
.modal h2 {
  letter-spacing: -0.035em;
}

/* ── Segmented controls with a glass thumb ──────────────────────────── */
:is(.studio-choices, .studio-view-tabs, .history-filters, .segmented, .pool-filter) {
  background: #ffffff06;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 1px 2px #0000008c;
}
:is(.studio-choices, .studio-view-tabs, .history-filters, .segmented) button {
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  min-height: 36px;
}
:is(.studio-choices, .studio-view-tabs, .history-filters, .segmented) button:hover:not([aria-pressed="true"]):not(.active):not(:disabled) {
  color: var(--text);
  background: #ffffff08;
}
:is(.studio-choices, .studio-view-tabs, .history-filters, .segmented) button:is([aria-pressed="true"], .active, [aria-current]) {
  color: var(--text);
  background:
    radial-gradient(120% 120% at 0% 0%, #feeae114, transparent 60%),
    #ffffff12;
  border-color: #ffffff1f;
  box-shadow:
    0 1px 4px #00000073,
    inset 0 1px 0 #ffffff1a;
}

/* ── Chips and badges ───────────────────────────────────────────────── */
:is(.admin-badge, .count-badge, .activity-badge, .eyebrow-chip) {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass-sheen), var(--glass-aurora), #ffffff07;
  box-shadow: var(--glass-rim);
}

/* ── Content width: one column for every page, on any screen ───────── */
.gallery-main.studio-page > *,
.admin-main {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
}
.studio-page .studio-work {
  max-width: none;
}

/* ── Destructive confirmations: never the amber primary ─────────────── */
:is(#trash-confirm, #film-purge-confirm, [data-confirm-purge], [data-confirm-delete], .danger-button) {
  background: linear-gradient(135deg, #ffb3ad 0%, #f2766d 100%) !important;
  border-color: #ffc9c466 !important;
  color: #2a0906 !important;
  box-shadow:
    inset 0 1px 0 #ffffff99,
    0 10px 28px -14px #f2766db3 !important;
}
.dialog-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

/* ── Reference picker: whole tile selects, ring shows the choice ─────── */
.studio-image-picker {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-height: min(52vh, 560px);
  overflow: auto;
  padding: 2px;
  margin: 18px 0;
}
.studio-pick-ref {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.studio-image-picker label {
  position: relative;
  display: grid !important;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-card);
  padding: 6px;
  background: #ffffff06;
  border: 1px solid var(--line-soft);
  transition:
    border-color var(--dur-fast) ease,
    background-color var(--dur-fast) ease,
    box-shadow var(--dur-med) var(--ease-out);
}
.studio-image-picker label:hover {
  border-color: var(--line-strong);
  background: #ffffff0a;
}
.studio-image-picker label:has(input:checked) {
  border-color: #efb865b3;
  background: #efb86512;
  box-shadow:
    0 0 0 3px #efb86526,
    0 14px 34px -18px #efb86599;
}
.studio-image-picker img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.studio-image-picker label input[type="checkbox"] {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  box-shadow: 0 2px 8px #000a;
}
.studio-image-picker span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px 2px;
}
.studio-image-picker select {
  min-height: 36px !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
}
.studio-image-picker select:disabled {
  opacity: 0.45;
}
.modal:has(.studio-image-picker) #studio-ref-upload {
  margin-bottom: 16px;
}
.modal:has(.studio-image-picker) #studio-ref-done {
  float: right;
  min-width: 180px;
}

/* ── Form rhythm: group title, label, control, hint ─────────────────── */
.form-group > legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.studio-page label,
.admin-form label,
.studio-create-form .field-label {
  gap: 8px;
}
.studio-page .muted.small,
.admin-form small {
  color: var(--subtle);
  line-height: 1.55;
}
.studio-create-card {
  padding: 26px 28px 28px !important;
}
.studio-create-card-heading {
  margin-bottom: 20px !important;
}

/* ── Studio films strip: real cards in a row, aligned to the column ─── */
.studio-page .studio-film-strip {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
  gap: 14px;
  padding: 0 !important;
}
.studio-page .studio-film-strip .studio-film {
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background: var(--glass-sheen), var(--glass-aurora), var(--panel);
  box-shadow: var(--glass-rim);
  padding: 8px 8px 12px;
}
.studio-page .studio-film-cover {
  aspect-ratio: 16 / 9;
  height: auto !important;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(80% 80% at 50% 0%, #efb8651a, transparent 70%), #0a0a0b;
}
/* ── Equal blocks in a row; actions sit on one baseline ─────────────── */
.admin-two-columns,
.admin-account-grid,
.admin-metrics {
  align-items: stretch !important;
}
.admin-two-columns > .admin-panel,
.admin-account-grid > .admin-panel {
  display: flex;
  flex-direction: column;
}
.admin-two-columns > .admin-panel > :is(a, button).subtle-button:last-child,
.admin-account-grid > .admin-panel > .subtle-button:last-child {
  margin-top: auto;
  align-self: flex-start;
}
.admin-metric {
  padding: 22px 24px !important;
}
.admin-metric strong {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

/* ── Tables: compact rows, sticky head, quiet zebra on hover ────────── */
.admin-table {
  border-collapse: separate;
  border-spacing: 0;
}
.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111113;
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle);
  padding: 12px 18px !important;
  border-bottom: 1px solid var(--line);
}
.admin-table tbody td {
  padding: 14px 18px !important;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ── Studio: films strip and film work share one left edge ──────────── */
.studio-page .studio-work,
.studio-page .studio-create,
.studio-page .studio-brief {
  padding-inline: 0 !important;
}
/* ── Gallery: justified rows ───────────────────────────────────────────
   Each tile grows in proportion to its own aspect ratio, so every tile in
   a row keeps the same height and the row ends exactly at the right edge.
   The trailing filler stops the last row from stretching. Geometry still
   comes from --ratio (known before pixels arrive). */
.gallery {
  gap: 12px !important;
}
.gallery :is(.media-card, .job-card) {
  flex: var(--ratio, 1.77778) 1 calc(var(--tile-height) * var(--ratio, 1.77778)) !important;
  width: auto !important;
  height: auto !important;
  aspect-ratio: var(--ratio, 1.77778) !important;
  max-width: calc(var(--tile-height) * var(--ratio, 1.77778) * 1.6) !important;
  min-width: 0;
}
.gallery::after {
  content: "";
  flex: 1000000 1 0px;
}
.gallery .gallery-empty,
.gallery .gallery-more {
  flex: 1 1 100%;
  max-width: none !important;
  aspect-ratio: auto !important;
}
.gallery :is(.media-card, .job-card) {
  border-radius: var(--radius-card) !important;
}
/* Content never hides under the floating prompt bar. */
.gallery-main:has(+ .composer-wrap),
.workspace:has(.composer-wrap:not([hidden])) .gallery-main:not(.studio-page) {
  padding-bottom: 230px !important;
}
.composer-wrap {
  z-index: 6;
}
.composer {
  border-radius: 22px !important;
  backdrop-filter: blur(18px) saturate(140%);
  background:
    var(--glass-sheen),
    var(--glass-aurora),
    #0e0e10e6 !important;
  border-color: #ffffff1f !important;
  box-shadow:
    inset 0 1px 0 #ffffff14,
    0 30px 80px -30px #000 !important;
}
/* ── Timelapse sources: the picture fills its frame ─────────────────── */
.process-source-grid {
  gap: 16px !important;
}
.process-source-grid article {
  padding: 12px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line-soft);
  background: #ffffff05;
}
.process-source-grid article > strong {
  font-size: 13px;
  font-weight: 700;
}
.process-source-preview {
  min-height: 0 !important;
  aspect-ratio: 4 / 3;
  padding: 0 !important;
  border-radius: 12px !important;
  border: 1px dashed #ffffff21 !important;
  background:
    radial-gradient(80% 80% at 50% 0%, #efb86512, transparent 70%),
    #0a0a0b !important;
  overflow: hidden;
}
.process-source-preview:has(img) {
  border-style: solid !important;
  border-color: var(--line) !important;
}
.process-source-preview img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}
.process-source-preview span {
  color: var(--subtle);
}

/* ── Storyboard tiles: an empty frame is a calm placeholder ──────────── */
.studio-board-art {
  border-radius: 12px !important;
  overflow: hidden;
  background:
    radial-gradient(90% 90% at 30% 0%, #efb86514, transparent 65%),
    radial-gradient(90% 90% at 100% 100%, #c0cef20d, transparent 60%),
    #0a0a0b !important;
  border: 1px solid var(--line-soft) !important;
}
.studio-stage-card .studio-stage-number {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff08;
}
.studio-stage-card.current {
  border-color: #efb86566 !important;
  background:
    radial-gradient(120% 100% at 0% 0%, #efb8651c, transparent 60%),
    var(--glass-sheen),
    var(--panel) !important;
  box-shadow:
    0 0 0 1px #efb86526,
    0 20px 50px -28px #efb86580 !important;
}
/* ═══ Punch list pass 1: global rhythm ════════════════════════════════ */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;
  --control-h: 40px;
}
/* One control height for primary, secondary and danger buttons. */
:is(.primary-button, .subtle-button, .generate-button) {
  min-height: var(--control-h) !important;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.2;
}
/* Footers: Cancel then the main action, right-aligned, 10 px apart. */
.dialog-actions > .primary-button,
.modal-actions > .primary-button {
  width: auto !important;
  min-width: 140px;
}
/* Field groups: the legend takes part in layout (float), one rhythm. */
.form-group {
  display: grid !important;
  gap: var(--space-4) !important;
  padding-top: var(--space-5) !important;
  border-top: 1px solid var(--line-soft) !important;
  margin-top: var(--space-6) !important;
}
.form-group:first-of-type,
.studio-create-card-heading + .form-group,
.modal-heading + form > .form-group:first-child,
form > .form-group:first-child {
  padding-top: 0 !important;
  border-top: 0 !important;
  margin-top: 0 !important;
}
.form-group > legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 var(--space-1) !important;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.form-group.form-group.form-group > p.muted.small {
  margin-top: calc(-1 * var(--space-2)) !important;
}
:is(.studio-page, .admin-form, .modal) :is(p.muted.small, small) {
  max-width: 68ch;
}
/* Segmented controls hug their options instead of stretching. */
.studio-choice-field .studio-choices {
  display: inline-grid !important;
  grid-auto-flow: column;
  grid-auto-columns: minmax(96px, auto);
  width: fit-content !important;
  max-width: 100%;
}
/* Native date/time and select chrome follow the dark scheme. */
input[type="datetime-local"],
input[type="date"] {
  color-scheme: dark;
  font: inherit !important;
  font-size: 13px !important;
}
/* Disclosure markers become the shared chevron. */
summary {
  list-style: none;
  cursor: pointer;
}
summary::-webkit-details-marker {
  display: none;
}
summary::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  rotate: -45deg;
  translate: 0 -1px;
  opacity: 0.7;
  transition: rotate var(--dur-fast) var(--ease-out);
}
details[open] > summary::before {
  rotate: 45deg;
}
/* Toast never sits on a dialog's title row. */
body.modal-open .modal-overlay {
  padding-top: 84px;
}
@media (max-width: 760px) {
  #toast {
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    translate: 0 -12px !important;
  }
  #toast.visible {
    translate: 0 0 !important;
  }
}

/* ═══ Job tiles: content anchored, front line kept out of the text ═══ */
.gallery .job-card .job-center {
  position: absolute !important;
  inset: auto 0 0 0;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 12px !important;
  padding: 16px !important;
  text-align: left;
  max-height: none;
  background: linear-gradient(transparent, #060606d9 55%);
}
.gallery .job-card .job-center > :is(.spinner, .icon) {
  grid-column: 1;
  width: 16px !important;
  height: 16px !important;
}
.gallery .job-card .job-center > strong {
  grid-column: 1;
  font-size: 15px;
  font-weight: 650;
}
.gallery .job-card .job-center > :is(.spinner, .icon) {
  grid-row: 1;
}
.gallery .job-card .job-center > strong {
  grid-row: 2;
}
.gallery .job-card .job-center > .job-percent {
  position: static;
  grid-row: 2;
  grid-column: 2;
  justify-self: end;
  align-self: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}
.gallery .job-card .job-center > p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}
.gallery .job-card .job-center > button {
  min-height: 32px !important;
  padding-inline: 12px;
  font-size: 12px;
}
.gallery .job-card .card-trash {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}
.job-card:is([data-state="preparing"], [data-state="submitting"], [data-state="running"], [data-state="downloading"])::after {
  -webkit-mask-image: linear-gradient(#000 0%, #000 40%, transparent 72%);
  mask-image: linear-gradient(#000 0%, #000 40%, transparent 72%);
}
/* Tiles fade under the floating prompt bar instead of a hard edge. */
.composer-wrap::after {
  content: "";
  position: absolute;
  /* The prompt bar is centred in the content column: reach exactly its edges,
     never over the sidebar (which sits below the bar's layer). */
  left: calc(50% - (100vw - var(--sidebar, 0px)) / 2 + 8px);
  right: calc(50% - (100vw - var(--sidebar, 0px)) / 2);
  bottom: -18px;
  height: 160px;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(transparent, var(--bg) 78%);
}
.composer-footnote {
  font-size: 12px !important;
  color: var(--subtle) !important;
}

/* ═══ Shell ══════════════════════════════════════════════════════════ */
.workspace-header {
  background: #060606cc !important;
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line-soft) !important;
}
.sidebar {
  background:
    radial-gradient(120% 40% at 0% 0%, #feeae108, transparent 70%),
    #09090a !important;
  border-right: 1px solid var(--line-soft) !important;
}
.nav-group-label {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--subtle) !important;
}
.nav-item {
  min-height: 40px;
  height: 40px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
}
.nav-item:hover:not(.active) {
  background: #ffffff08 !important;
}

/* ═══ Empty states: one component ════════════════════════════════════ */
:is(.studio-library-empty, .history-empty, .generation-no-events, .admin-empty, .gallery-empty) {
  display: grid !important;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 32px 24px !important;
  text-align: center;
  color: var(--muted);
}
/* ═══ Studio: one column, balanced form, title row ═══════════════════ */
.gallery-main.studio-page > #studio-body {
  max-width: var(--content-max) !important;
  margin-inline: auto !important;
}
.studio-create-form#studio-form {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  gap: var(--space-6) !important;
}
.studio-create-form > .studio-create-card {
  height: 100%;
}
.studio-create-form > :is(.studio-create-footer, .form-error, .studio-error) {
  grid-column: 1 / -1;
}
/* Create footer: a glass panel with inner breathing room, like the cards
   above it (the older hairline footer had no side padding). */
.studio-page .studio-create-footer {
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-panel);
}
/* «Главное»: the creation heading carries the film tabs on their own row,
   where a film shows them under its title. */
.studio-page .studio-main-heading {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
}
.studio-page .studio-main-heading .studio-view-tabs button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Film references: the same cards as the timelapse sources — a soft
   glass frame, a 4:3 picture that fills it, pill actions. */
.studio-page .studio-create-materials #brief-ref-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: var(--space-4);
}
.studio-page .studio-create-materials .studio-brief-ref {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line-soft);
  background: #ffffff05;
}
.studio-page .studio-create-materials .studio-brief-ref img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0a0a0b;
}
.studio-page .studio-create-materials .studio-brief-ref :is(label, button) {
  margin: 0;
}
/* Title + actions on the first row, view tabs on their own row below. */
.studio-work > .studio-title {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-4) var(--space-6) !important;
}
.studio-work > .studio-title .studio-film-controls {
  display: contents !important;
}
.studio-work > .studio-title #film-actions {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.studio-work > .studio-title .studio-view-tabs {
  grid-row: 2;
  grid-column: 1 / -1;
  justify-self: start;
}
.studio-work > .studio-title h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 2vw, 32px);
  letter-spacing: -0.02em;
}
.studio-work > .studio-title .film-meta {
  margin: 0;
}
/* Disabled primary reads as unavailable, not as muddy amber. */
:is(.primary-button, .generate-button):disabled,
:is(.primary-button, .generate-button)[aria-disabled="true"] {
  background: #ffffff0d !important;
  color: var(--subtle) !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  filter: none !important;
}
@media (max-width: 760px) {
  .studio-create-form#studio-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .studio-page .studio-create-footer {
    padding: var(--space-4) var(--space-5);
  }
  /* Four film tabs on a phone: the icon sits above its label. */
  .studio-page .studio-view-tabs {
    width: 100%;
  }
  .studio-page .studio-view-tabs > button {
    flex-direction: column;
    gap: 3px;
    padding: 7px 2px;
    font-size: 11px;
    min-width: 0;
  }
  .studio-work > .studio-title {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-work > .studio-title #film-actions {
    grid-row: 2;
    grid-column: 1;
    justify-content: stretch;
    flex-wrap: wrap;
  }
  .studio-work > .studio-title #film-actions > * {
    flex: 1 1 140px;
  }
  .studio-work > .studio-title .studio-view-tabs {
    grid-row: 3;
    width: 100%;
  }
  .studio-work > .studio-title .studio-view-tabs > button {
    flex: 1;
  }
}
/* Fields inside a group get their spacing from the group gap only. */
.form-group > :is(label, div, p, section) {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
.studio-choice-field {
  display: grid !important;
  gap: 8px;
  justify-items: start;
}
.studio-choice-field > :is(span, strong, label, .studio-choice-label) {
  margin: 0 !important;
}
/* ═══ Stage effects (fx.js) ══════════════════════════════════════════
   Canvases sit under content and never take the pointer. Without WebGL or
   with reduced motion the stage stays empty and the static art remains. */
.fx-stage {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}
.fx-stage > .fx-canvas {
  opacity: 0;
  animation: fx-in 1.4s var(--ease-out) 0.2s forwards;
}
@keyframes fx-in {
  to { opacity: 1; }
}
.hero-showcase {
  position: relative;
  isolation: isolate;
}
.hero-showcase > :not(.fx-stage) {
  position: relative;
  z-index: 1;
}
.hero-fx {
  inset: -34% -26%;
  -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent);
  mask-image: radial-gradient(closest-side, #000 62%, transparent);
}
.landing-showcase {
  position: relative;
  isolation: isolate;
}
.landing-showcase > :not(.fx-stage) {
  position: relative;
  z-index: 1;
}
.landing-fx {
  inset: -30% -22%;
  -webkit-mask-image: radial-gradient(closest-side, #000 58%, transparent);
  mask-image: radial-gradient(closest-side, #000 58%, transparent);
}
@media (max-width: 760px) {
  .hero-fx,
  .landing-fx {
    inset: -10% -6%;
  }
}
/* ═══ Admin: compact queue rows, short numeric fields ════════════════ */
.admin-table :is(td, th) {
  padding: 12px 18px !important;
  vertical-align: middle;
}
.admin-table td > a {
  display: block;
}
.admin-table td > a + small,
.admin-table td > a + small + code {
  display: inline !important;
  margin: 0 !important;
  font-size: 12px;
}
.admin-table td > a + small + code {
  margin-left: 8px !important;
  color: var(--subtle);
  font-size: 11px;
}
.admin-table td > a + small + code::before {
  content: "· ";
  font-family: var(--font, inherit);
}
.admin-table .admin-job-error:not(:empty) {
  display: block;
  margin-top: 6px;
  max-width: 46ch;
}
.admin-table .admin-actions {
  justify-content: flex-end;
}
#admin-settings-form.admin-form {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5) var(--space-6) !important;
  align-items: start;
}
#admin-settings-form > label {
  display: grid;
  gap: 8px;
  margin: 0 !important;
}
#admin-settings-form > label > input {
  width: 100%;
  max-width: 240px;
}
#admin-settings-form > [type="submit"] {
  grid-column: 1 / -1;
  justify-self: end;
  width: auto !important;
  min-width: 200px;
}
@media (max-width: 760px) {
  #admin-settings-form > label > input {
    max-width: none;
  }
  #admin-settings-form > [type="submit"] {
    justify-self: stretch;
  }
}
/* ═══ Pool: careful-use rules ════════════════════════════════════════ */
.pool-care {
  margin: 4px 0 16px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #ffffff05;
}
.pool-care > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 650;
}
.pool-care-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 20px;
  align-items: start;
  padding: 4px 16px 16px;
}
.pool-care-form > label {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.pool-care-form > label > input {
  width: 100%;
  max-width: 200px;
}
.pool-care-form > label > small {
  color: var(--subtle);
  font-size: 11px;
}
.pool-care-form > [type="submit"] {
  grid-column: 1 / -1;
  justify-self: end;
}
.pool-pause-reason {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}
.pool-pause-reason > svg {
  flex: none;
  margin-top: 2px;
}
@media (max-width: 760px) {
  .pool-care-form > label > input {
    max-width: none;
  }
  .pool-care-form > [type="submit"] {
    justify-self: stretch;
  }
}
/* ═══ Media card corners: one chip system ════════════════════════════
   Timer and «1080p доступно» are the same chip: control height, glass
   fill, one radius, stacked with a 6 px gap at the left inset. The right
   rail (favourite / download / delete, add to prompt) uses the same size. */
.gallery .media-card .artifact-expiry,
.gallery .media-card .quality-badge {
  position: absolute;
  left: var(--media-control-inset);
  z-index: 3;
  height: var(--media-control-size);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid #ffffff1f;
  border-radius: 10px;
  background: #0a0a0bb3;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 16px -10px #000;
}
.gallery .media-card .artifact-expiry {
  bottom: var(--media-control-inset);
  color: var(--text);
}
.gallery .media-card .quality-badge {
  bottom: calc(var(--media-control-inset) + var(--media-control-size) + 6px);
  color: var(--accent);
  border-color: var(--accent-line);
}
.gallery .media-card:not(:has(.artifact-expiry)) .quality-badge {
  bottom: var(--media-control-inset);
}
.gallery .media-card .quality-badge,
.gallery .media-card .artifact-expiry {
  max-width: calc(100% - 2 * var(--media-control-inset) - var(--media-control-size) - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery .media-top .icon-button,
.gallery .media-bottom .icon-button {
  border: 1px solid #ffffff1f;
  border-radius: 10px;
  background: #0a0a0bb3;
}
/* The prompt line shown on hover moves above the chips instead of under them. */
.gallery .media-card:has(.quality-badge) .media-bottom > span {
  bottom: calc(2 * var(--media-control-size) + 2 * var(--media-control-inset) + 6px);
}
@container media-card (max-width: 150px) {
  .gallery .media-card .artifact-expiry,
  .gallery .media-card .quality-badge {
    --media-control-size: 28px;
    --media-control-inset: 6px;
    padding: 0 6px;
    font-size: 10px;
    border-radius: 8px;
  }
}
/* ═══ Job cards: professional layout in both grid sizes ═════════════════
   A job tile is never narrower than a 16:9 frame of the row height, so a
   9:16 request no longer squeezes its controls. Inside: status row (icon,
   stage, real provider %), the stage/time line, then actions — side by
   side when they fit, otherwise full width. Nothing wraps word by word. */
.gallery .job-card {
  --job-ratio: max(var(--ratio, 1.77778), 1.77778);
  container: job-card / size;
  flex: var(--job-ratio) 1 calc(var(--tile-height) * var(--job-ratio)) !important;
  aspect-ratio: var(--job-ratio) !important;
  max-width: calc(var(--tile-height) * var(--job-ratio) * 1.6) !important;
  min-width: min(100%, 300px) !important;
}
.gallery .job-card .job-center {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  flex-wrap: wrap;
  align-content: flex-end;
  align-items: center;
  justify-content: flex-start;
  gap: 8px !important;
  padding: 16px !important;
  max-height: none !important;
  overflow: hidden !important;
  text-align: left;
  background: linear-gradient(180deg, transparent 20%, #060606c7 78%) !important;
}
.gallery .job-card .job-center > * {
  grid-area: auto !important;
  margin: 0 !important;
}
.gallery .job-card .job-center > :is(.spinner, .icon) {
  flex: none;
  width: 16px !important;
  height: 16px !important;
}
.gallery .job-card .job-center > strong {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}
.gallery .job-card .job-center > .job-percent {
  flex: none;
  position: static !important;
  translate: none !important;
  padding: 2px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.gallery .job-card .job-center > p {
  flex: 1 1 100%;
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.gallery .job-card .job-center > button {
  flex: 1 0 auto;
  max-width: 100%;
  min-width: 0;
  min-height: 34px !important;
  height: 34px;
  padding: 0 12px !important;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px !important;
}
/* Failed tiles keep their trash button clear of the text. */
.gallery .job-card.job-failed .job-center {
  padding-top: 52px !important;
}
.gallery .job-card .card-trash {
  top: 10px !important;
  right: 10px !important;
}
/* The progress line sits on the tile edge, under the actions. */
.gallery .job-card .job-bar {
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
}
/* Compact grid (row 180 px): tighter rhythm so everything fits the tile. */
.gallery:not(.large) .job-card .job-center {
  gap: 6px !important;
  padding: 12px !important;
}
.gallery:not(.large) .job-card .job-center > button {
  min-height: 30px !important;
  height: 30px;
  font-size: 12px !important;
}
.gallery:not(.large) .job-card .job-center > strong {
  font-size: 14px;
}
.gallery:not(.large) .job-card.job-failed .job-center {
  padding-top: 12px !important;
}
.gallery:not(.large) .job-card.job-failed .job-center > strong {
  margin-right: 40px !important;
}
@container job-card (max-width: 299px) {
  .gallery .job-card .job-center > button {
    flex-basis: 100%;
  }
}
/* Phones: a job tile takes the full row and its natural height. */
@media (max-width: 760px) {
  .gallery .job-card {
    container-type: inline-size !important;
    flex: 1 1 100% !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    height: auto !important;
    min-height: max(var(--tile-height), 172px);
  }
  .gallery .job-card .job-center {
    position: relative !important;
    inset: auto !important;
    min-height: inherit;
  }
}
/* The future frame: an outline in the requested format above the status,
   filled from below by the provider's real progress. Only where the tile
   has room for it; failed tiles show the empty frame. */
@container job-card (min-height: 270px) {
  .gallery .job-card .job-center::before {
    content: "";
    position: absolute;
    top: 18px;
    left: 50%;
    translate: -50% 0;
    height: min(calc(100cqh - 214px), 62cqh);
    aspect-ratio: var(--ratio, 1.77778);
    max-width: calc(100cqw - 120px);
    border: 1px solid #ffffff1c;
    border-radius: 10px;
    background:
      linear-gradient(0deg, #efb86529 calc(var(--progress, 0) * 1%), transparent calc(var(--progress, 0) * 1%)),
      #ffffff05;
    box-shadow: inset 0 1px 0 #ffffff0d;
    transition: background var(--dur-layout) var(--ease-out);
  }
  .gallery .job-card.job-failed .job-center::before {
    background: #ffffff04;
    border-style: dashed;
  }
}
/* Narrow tiles (fallback below 300 px): the stage title is never clipped,
   the description wraps, actions stack full width at one height. */
@container job-card (max-width: 299px) {
  .gallery .job-card .job-center {
    gap: 6px !important;
    padding: 12px !important;
  }
  .gallery .job-card .job-center > strong {
    flex: 1 1 auto;
    white-space: normal;
    overflow: visible;
    font-size: 14px;
  }
  .gallery .job-card .job-center > p {
    -webkit-line-clamp: 3;
    font-size: 12px;
    overflow-wrap: normal;
  }
  .gallery .job-card .job-center > button {
    flex: 1 1 100%;
    min-height: 30px !important;
    height: 30px;
    font-size: 12px !important;
  }
  .gallery .job-card .job-center::before {
    display: none;
  }
}
.gallery .job-card.job-failed .job-center > strong {
  margin-right: 40px !important;
}
@container job-card (max-width: 219px) {
  .gallery .job-card .job-center > button {
    padding: 0 8px !important;
    font-size: 11.5px !important;
  }
}
/* ═══ Delete project dialog ══════════════════════════════════════════ */
.modal.delete-project-modal {
  width: min(520px, calc(100vw - 32px)) !important;
}
.delete-project-modal .danger-mark {
  background: #ff9b951a;
  color: var(--danger);
  box-shadow: inset 0 0 0 1px #ff9b9533;
}
.delete-project-modal .delete-project-name {
  margin: 2px 0 0;
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.delete-project-body {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.delete-project-body > p {
  margin: 0;
}
.delete-project-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px 16px;
  list-style: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  background: #ffffff05;
}
.delete-project-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.delete-project-list .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
}
.delete-project-error:not([hidden]) {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #ff9b9540;
  border-radius: 12px;
  background: #ff9b9512;
  color: var(--danger);
  font-size: 13px;
}
.delete-project-modal .dialog-actions .danger-button {
  min-width: 176px;
}
/* Busy action: the icon becomes a spinner, the label says what happens. */
button[aria-busy="true"] {
  cursor: progress !important;
}
button[aria-busy="true"] > .icon {
  display: none;
}
button[aria-busy="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.delete-project-modal button:disabled:not([aria-busy="true"]) {
  opacity: 0.5;
}
@media (max-width: 760px) {
  .delete-project-modal .dialog-actions > * {
    flex: 1 1 140px;
  }
}
/* ═══ Pool credits (admin) ═══════════════════════════════════════════ */
.pool-pill .pool-credits {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pool-pill .pool-credits-sep {
  color: var(--subtle);
}
.pool-pill .pool-credits-word {
  color: var(--muted);
}
.pool-pill .pool-credits.low .pool-credits-value {
  color: var(--danger);
}
@media (max-width: 1100px) {
  .pool-pill .pool-credits-word {
    display: none;
  }
}
@media (max-width: 600px) {
  .pool-pill .pool-label,
  .pool-pill .pool-credits-sep {
    display: none;
  }
  .pool-pill .pool-credits::before {
    content: "·";
    color: var(--subtle);
  }
}
.pool-stat small {
  display: block;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.pool-stat.danger-stat {
  border-color: #ff9b9559 !important;
  background: #ff9b9512 !important;
}
.pool-stat.danger-stat strong {
  color: var(--danger) !important;
}
.pool-stat.danger-stat.selected {
  box-shadow: inset 0 0 0 1px #ff9b9599 !important;
}
.pool-card.low-credits {
  border-color: #ff9b9559 !important;
  background:
    linear-gradient(90deg, #ff9b9512, transparent 55%),
    var(--glass-fill) !important;
}
.pool-card.low-credits .pool-balance strong,
.pool-card.low-credits .pool-balance > span {
  color: var(--danger) !important;
}
@media (max-width: 600px) {
  .pool-pill,
  .pool-pill > span {
    white-space: nowrap;
  }
  .pool-pill:has(.pool-warning) .pool-credits {
    display: none;
  }
}
/* ═══ Licence tokens ═════════════════════════════════════════════════ */
.licence-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  margin-left: 6px;
  padding: 0 11px 0 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-sheen), var(--glass-fill);
  box-shadow: var(--glass-rim);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.licence-chip:hover {
  border-color: var(--line-strong);
}
.licence-chip-role {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 650;
}
.licence-chip-tokens {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.licence-chip.low .licence-chip-tokens {
  color: var(--accent);
}
.licence-chip.empty {
  border-color: #ff9b9559;
}
.licence-chip.empty .licence-chip-tokens {
  color: var(--danger);
}
.cost-note.token-cost {
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
}
.cost-note.token-cost strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.token-estimate {
  margin: 4px 0 8px !important;
  max-width: 72ch;
  color: var(--muted);
}
@media (max-width: 760px) {
  .licence-chip {
    height: 28px;
    padding: 0 9px;
    margin-left: 2px;
  }
  .licence-chip-role {
    display: none;
  }
}
/* Header row: the search sits in the flow between the project and the actions,
   so wider pills (credits, licence) push it narrower instead of overlapping. */
@media (min-width: 761px) {
  .workspace-header .project-heading {
    flex: 0 1 auto;
    min-width: 0;
  }
  .workspace-header .project-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workspace-header .search-tools {
    position: static !important;
    transform: none !important;
    flex: 0 1 440px;
    width: auto !important;
    min-width: 180px;
    margin-inline: auto;
  }
  .workspace-header .search-box {
    flex: 1;
    min-width: 0;
    width: auto;
  }
  .workspace-header .header-end {
    flex: none;
    margin-left: 0 !important;
  }
}
@media (min-width: 761px) {
  .workspace-header .project-heading > :not(.project-title) {
    flex: none;
  }
  .workspace-header .project-title {
    min-width: 96px;
  }
  .workspace-header .search-tools {
    min-width: 150px;
  }
}
@media (min-width: 761px) and (max-width: 1180px) {
  .workspace-header .licence-chip-role {
    display: none;
  }
  .workspace-header .licence-chip {
    padding-left: 10px;
  }
}
/* ═══ Preview side panel: lists instead of stretched pills ════════════ */
@media (min-width: 761px) {
  .preview-modal .preview-layout {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 360px) !important;
  }
}
.preview-modal .preview-details {
  gap: 0 !important;
  padding: 22px 22px 26px !important;
  background: var(--glass-sheen), #0c0c0e !important;
}
.preview-details .preview-group {
  gap: 10px;
  padding: 18px 0;
}
.preview-details .preview-group:first-child {
  padding-top: 0;
}
.preview-details .preview-group + .preview-group {
  border-top: 1px solid var(--line-soft);
}
.preview-details .preview-group-title {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}
.preview-details .preview-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}
/* Tool, request and version buttons read as one bordered list. */
.preview-details :is(.preview-tools .preview-group-body, .preview-row) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #ffffff04;
}
.preview-details :is(.preview-tools .preview-group-body, .preview-row) > :is(button, a),
.preview-details .version-links > button {
  display: flex !important;
  align-items: center;
  justify-content: flex-start !important;
  gap: 10px;
  width: 100%;
  min-height: 42px !important;
  height: auto !important;
  margin: 0 !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text) !important;
  font-size: 13px !important;
  font-weight: 550 !important;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  transition: background-color var(--dur-fast) ease;
}
.preview-details :is(.preview-tools .preview-group-body, .preview-row) > :is(button, a) + :is(button, a) {
  border-top: 1px solid var(--line-soft) !important;
}
.preview-details :is(.preview-tools .preview-group-body, .preview-row) > :is(button, a):hover,
.preview-details .version-links > button:hover {
  background: #ffffff0a !important;
}
.preview-details :is(.preview-tools .preview-group-body, .preview-row) .icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.preview-details :is(.preview-tools, .preview-request) :is(button, a):focus-visible,
.preview-details .version-links > button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px #d6dce2b3 !important;
}
/* The original request: a calm reading box, one scroll, no arrow buttons. */
.preview-details .saved-prompt {
  margin: 0 !important;
  max-height: 176px;
  overflow: auto;
  padding: 12px 14px !important;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0a0a0b;
  color: var(--muted);
  font-size: 13px !important;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-details .saved-prompt::-webkit-scrollbar-button {
  display: none;
  height: 0;
}
/* Facts and the version history. */
.preview-details .preview-job-meta {
  margin: 0 !important;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #ffffff04;
  color: var(--muted);
  font-size: 12.5px !important;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.preview-details .version-links {
  display: grid !important;
  gap: 0 !important;
  margin-top: 6px;
}
.preview-details .version-links > .field-label {
  margin: 0 0 8px !important;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 650;
}
.preview-details .version-links > button {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  border-left: 1px solid var(--line) !important;
  border-right: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line-soft) !important;
  background: #ffffff04 !important;
}
.preview-details .version-links > .field-label + button {
  border-top: 1px solid var(--line) !important;
  border-top-left-radius: var(--radius-card) !important;
  border-top-right-radius: var(--radius-card) !important;
}
.preview-details .version-links > button:last-child {
  border-bottom: 1px solid var(--line) !important;
  border-bottom-left-radius: var(--radius-card) !important;
  border-bottom-right-radius: var(--radius-card) !important;
}
/* New version form. */
.preview-details #image-edit-form {
  display: grid;
  gap: 8px;
}
.preview-details #image-edit-form .edit-prompt {
  min-height: 108px;
  resize: vertical;
  line-height: 1.5;
}
.preview-details #image-edit-form > :is(button, .primary-button) {
  margin-top: 6px;
  width: 100%;
}
.preview-details .preview-primary :is(button, a) {
  width: 100%;
}
.preview-details .preview-danger {
  padding-bottom: 0;
}
.preview-details .preview-danger :is(button, a) {
  width: 100%;
}
.license-metric .license-token-note {
  display: block;
  margin-top: 8px;
  color: var(--subtle);
  font-size: 11.5px;
}
/* ═══ Rejected frames (automatic frame check) ═════════════════════════ */
.gallery .media-card.is-rejected .media-open :is(img, video) {
  filter: saturate(0.45) brightness(0.62);
}
.gallery .media-card.is-rejected {
  box-shadow: inset 0 0 0 1px #ff9b9566 !important;
}
.gallery .media-card .rejected-badge {
  position: absolute;
  top: var(--media-control-inset, 8px);
  left: var(--media-control-inset, 8px);
  z-index: 3;
  display: grid;
  gap: 2px;
  max-width: calc(100% - 2 * var(--media-control-inset, 8px) - var(--media-control-size, 32px) - 6px);
  padding: 6px 10px;
  border: 1px solid #ff9b9559;
  border-radius: 10px;
  background: #1a0b0acc;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  line-height: 1.25;
}
.gallery .media-card .rejected-badge b {
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 700;
}
.gallery .media-card .rejected-badge span {
  overflow: hidden;
  color: #f3d9d6;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@container media-card (max-width: 150px) {
  .gallery .media-card .rejected-badge {
    padding: 4px 7px;
  }
  .gallery .media-card .rejected-badge span {
    display: none;
  }
}
.preview-details .rejected-note {
  display: grid;
  gap: 2px;
  margin: 10px 0 0 !important;
  padding: 10px 12px;
  border: 1px solid #ff9b9559;
  border-radius: 12px;
  background: #ff9b9512;
  font-size: 12.5px;
  line-height: 1.4;
}
.preview-details .rejected-note b {
  color: var(--danger);
  font-size: 12px;
}
.preview-details .rejected-note span {
  color: var(--text);
}
.preview-details .rejected-note small {
  color: var(--muted);
}
/* Stage text and history: rejected frames in red, best-of choice in amber. */
#studio-pipeline small.stage-rejected,
.progress-events li.stage-rejected,
.process-frame-card small.stage-rejected {
  color: var(--danger) !important;
}
#studio-pipeline small.stage-best,
.progress-events li.stage-best,
.process-frame-card small.stage-best {
  color: var(--accent) !important;
}
#studio-pipeline small.stage-rejected::before,
.progress-events li.stage-rejected::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: 1px;
}
/* On phones the stage line is hidden, except a rejected frame or a best-of
   choice, which the owner must see. */
@media (max-width: 760px) {
  .studio-pipeline small:is(.stage-rejected, .stage-best) {
    display: block !important;
    flex: 1 1 100%;
    margin: 6px 0 0 !important;
    font-size: 12px;
    line-height: 1.4;
  }
}
/* A spare variant the check did not pick: neutral, no alarm. */
.gallery .media-card.is-alternate .media-open :is(img, video) {
  filter: saturate(0.8) brightness(0.85);
}
.gallery .media-card .rejected-badge.alternate {
  display: inline-flex;
  align-items: center;
  height: var(--media-control-size, 32px);
  padding: 0 10px;
  border-color: #ffffff24;
  background: #0a0a0bb3;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.preview-details .rejected-note.alternate {
  border-color: var(--line);
  background: #ffffff06;
}
.preview-details .rejected-note.alternate b {
  color: var(--muted);
}
/* ═══ Film cost in tokens ════════════════════════════════════════════ */
.token-mark {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3dc, var(--accent) 55%, #b9822f);
  box-shadow: inset 0 0 0 1.5px #00000033, 0 0 0 1px #efb86540;
}
.workspace-header .project-heading .licence-chip {
  margin-left: 10px;
}
.token-estimate.short {
  color: var(--danger) !important;
}
.studio-pipeline .pipeline-tokens {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 14px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff05;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.studio-film {
  position: relative;
}
.studio-film .studio-film-tokens {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.studio-film small {
  padding-right: 64px;
}
.dialog-mark.danger-mark {
  background: #ff9b951a;
  color: var(--danger);
  box-shadow: inset 0 0 0 1px #ff9b9533;
}
.modal.budget-modal {
  width: min(480px, calc(100vw - 32px)) !important;
}
.budget-modal .budget-message {
  margin: 16px 0 0;
  line-height: 1.55;
}
@media (max-width: 760px) {
  .studio-pipeline .pipeline-tokens {
    margin: 8px 0 0;
  }
}
.licence-chip-short {
  display: none;
}
@media (max-width: 760px) {
  .workspace-header .licence-chip-full {
    display: none;
  }
  .workspace-header .licence-chip-short {
    display: inline;
  }
  .workspace-header .project-heading .licence-chip {
    flex: none;
    margin-left: 4px;
  }
  .workspace-header .project-heading .project-title {
    min-width: 72px;
  }
}
/* Rule fields line up: the caption row always holds two lines. */
.pool-care-form > label {
  grid-template-rows: minmax(2.7em, auto) auto auto;
  align-content: start;
  line-height: 1.35;
}
/* «Хук в начале»: a switch with its explanation under the label. */
.studio-hook.export-hook {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #ffffff04;
  max-width: 60ch;
}
.studio-hook.export-hook > span {
  display: grid;
  gap: 4px;
  font-weight: 600;
}
.studio-hook.export-hook small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}
/* ═══ Connection banner and poster recovery ═════════════════════════════ */
#connection-status[data-tone="calm"]:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
  border-color: var(--line-strong) !important;
  background: #0e0e10f2 !important;
  color: var(--text) !important;
  box-shadow: 0 18px 40px -24px #000 !important;
  backdrop-filter: blur(12px);
}
#connection-status[data-tone="calm"]:not([hidden])::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: connection-breathe 1.6s ease-in-out infinite;
}
@keyframes connection-breathe {
  50% { opacity: 0.35; }
}
html[data-motion="reduced"] #connection-status::before {
  animation: none;
}
.preview-loading {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(100deg, transparent 30%, #ffffff0a 50%, transparent 70%) 0 0 / 220% 100%,
    var(--canvas);
  animation: preview-wait 1.8s ease-in-out infinite;
}
@keyframes preview-wait {
  from { background-position: 120% 0, 0 0; }
  to { background-position: -120% 0, 0 0; }
}
html[data-motion="reduced"] .preview-loading {
  animation: none;
}
#process-duration-help .duration-note {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-weight: 600;
}
#process-duration-help .duration-note[hidden] {
  display: none;
}
/* ═══ «Ваши фильмы»: one row, scrolls sideways ══════════════════════════
   About six cards on a desktop, fewer on narrower screens, one and a peek on
   phones. Snap per card; the page never grows downwards. */
.studio-page .studio-film-carousel {
  --films-per-view: 6;
  --films-gap: 14px;
  display: block !important;
  position: relative;
  padding-bottom: 14px;
}
.studio-page .studio-film-carousel .studio-film-strip {
  position: relative;
  display: grid !important;
  grid-auto-flow: column;
  grid-template-columns: none !important;
  grid-auto-columns: calc((100% - (var(--films-per-view) - 1) * var(--films-gap)) / var(--films-per-view));
  gap: var(--films-gap) !important;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scroll-padding-inline: 0;
  scrollbar-width: none;
  padding: 2px 0 4px !important;
}
.studio-page .studio-film-carousel .studio-film-strip > .studio-film {
  scroll-snap-align: start;
  min-width: 0;
}
.studio-page .studio-film-carousel .studio-film-strip:has(> p),
.studio-page .studio-film-carousel .studio-film-strip:empty {
  display: block !important;
}
/* Before the first answer: a calm row of placeholders in final geometry. */
.studio-page .studio-film-carousel .studio-film-strip:empty {
  min-height: 150px;
  border-radius: var(--radius-card);
  background:
    linear-gradient(100deg, transparent 30%, #ffffff08 50%, transparent 70%) 0 0 / 220% 100%,
    repeating-linear-gradient(90deg, #ffffff05 0 calc((100% - 70px) / 6), transparent 0 calc((100% - 70px) / 6 + 14px));
  animation: preview-wait 1.8s ease-in-out infinite;
}
html[data-motion="reduced"] .studio-page .studio-film-strip:empty {
  animation: none;
}
@media (max-width: 1279px) {
  .studio-page .studio-film-carousel { --films-per-view: 5; }
}
@media (max-width: 1099px) {
  .studio-page .studio-film-carousel { --films-per-view: 4; }
}
@media (max-width: 899px) {
  .studio-page .studio-film-carousel { --films-per-view: 3; }
}
@media (max-width: 760px) {
  .studio-page .studio-film-carousel .studio-film-strip {
    grid-auto-columns: 72%;
    --films-gap: 10px;
  }
}
/* Round glass arrows at the row's edges; hidden where nothing is left. */
.studio-page .studio-film-carousel .studio-film-arrow {
  position: absolute;
  top: calc(50% - 30px);
  z-index: 3;
  display: grid !important;
  place-items: center;
  width: 40px !important;
  height: 40px !important;
  padding: 0;
  border: 1px solid var(--line-strong) !important;
  border-radius: 50% !important;
  background: var(--glass-sheen), #0e0e10e6 !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-rim), 0 10px 24px -12px #000;
  color: var(--text) !important;
  cursor: pointer;
  transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease, scale var(--dur-press) var(--ease-out);
}
.studio-page .studio-film-carousel .studio-film-arrow.previous {
  left: -20px;
}
.studio-page .studio-film-carousel .studio-film-arrow.next {
  right: -20px;
}
.studio-page .studio-film-carousel .studio-film-arrow .icon {
  width: 18px;
  height: 18px;
}
.studio-page .studio-film-carousel .studio-film-arrow:hover:not(:disabled) {
  color: var(--accent) !important;
  border-color: var(--accent-line) !important;
}
.studio-page .studio-film-carousel .studio-film-arrow:active:not(:disabled) {
  scale: 0.94;
}
.studio-page .studio-film-carousel .studio-film-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}
.studio-page .studio-film-carousel .studio-film-arrow:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #0a0a0b, 0 0 0 4px #d6dce2b3;
}
@media (max-width: 760px) {
  .studio-page .studio-film-carousel .studio-film-arrow {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .studio-page .studio-film-carousel .studio-film-strip {
    scroll-behavior: auto;
  }
}
html[data-motion="reduced"] .studio-page .studio-film-carousel .studio-film-strip {
  scroll-behavior: auto;
}
/* Narrow film cards: the meta line ends before the token count. */
.studio-page .studio-film-strip .studio-film:has(.studio-film-tokens) small {
  display: block;
  padding-right: 54px !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-page .studio-film-strip .studio-film .studio-film-tokens {
  right: 10px;
  bottom: 11px;
}
/* Omni 1.2 duration slider (08.11.2026) */
.duration-range { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.duration-range span { font-size: 13px; opacity: .8; white-space: nowrap; }
.duration-range input { flex: 1; accent-color: var(--accent); min-width: 0; }
.duration-range output { font-weight: 600; min-width: 52px; text-align: right; color: var(--accent); }
