/* ============================================================
   Media AI Box — Polish layer (Cinema Atelier)
   ----------------------------------------------------------------
   - Refined scrollbars, dropdowns, job bar, spinners
   ============================================================ */

/* ============ Scrollbars (global refresh) ============ */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(14, 28, 48, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s var(--ease-out);
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(10, 107, 118, 0.35);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background-color: rgba(10, 107, 118, 0.5);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(14, 28, 48, 0.22) transparent;
}

/* ============ Selects / dropdowns (unified) ============ */
.select {
  appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5l4.5 4.5 4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 10px 7px;
  padding-inline-start: 32px;
  padding-inline-end: 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out),
    background-color 0.15s;
}
.select:hover {
  border-color: var(--border-strong);
  background-color: var(--surface-hover);
}
.select:focus {
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: var(--shadow-focus);
}
.select::-ms-expand {
  display: none;
}
.select option {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  padding: 8px 10px;
}
.select-sm {
  background-position: left 9px center;
  padding-inline-start: 26px;
  padding-inline-end: 10px;
}

/* Dropdown menu (custom) */
.dropdown-menu {
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow:
    0 14px 40px -10px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  padding: 5px;
}
.dropdown-item {
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-weight: 500;
  transition: background 0.12s var(--ease-out);
}
.dropdown-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============ Custom select (button trigger + body-mounted menu) ============ */
.cselect-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.005em;
  transition:
    border-color 0.15s var(--ease-out),
    background 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out);
}
.cselect-trigger:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.cselect-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.cselect-trigger.open {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.cselect-trigger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.cselect-trigger-label {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cselect-trigger-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.18s var(--ease-out);
}
.cselect-trigger.open .cselect-trigger-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* The menu lives on <body> via position: fixed (set inline) */
.cselect-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow:
    0 18px 48px -12px rgba(0, 0, 0, 0.22),
    0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 9999;
  animation: cselectIn 0.15s var(--ease-out);
  font-family: inherit;
}
@keyframes cselectIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.cselect-option {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: start;
  white-space: nowrap;
  transition: background 0.1s;
  justify-content: space-between;
}
.cselect-option:hover {
  background: var(--surface-hover);
}
.cselect-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* Each header + its options live in their own column - a plain vertical
   stack by default (voices, effects, ... anything without headers ends up
   as a single column, unchanged from before). */
.cselect-column {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cselect-column:not(:first-child) {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--divider);
}
/* Non-selectable category header inside a grouped dropdown (e.g. video models). */
.cselect-group-header {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #888);
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}
.cselect-option-label {
  flex-shrink: 0;
}
.cselect-option-sample {
  flex: 1;
  min-width: 0;
  text-align: start;
  color: var(--text-2);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cselect-option.active .cselect-option-sample {
  color: var(--accent);
}
.cselect-option-hint {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Video model list: JS packs category groups into exactly 3 balanced columns
   (see custom-select.js) so short groups don't leave tall empty holes. */
.cselect-menu--video-models {
  display: block;
  width: min(900px, 94vw);
  max-height: 76vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 6px;
  columns: unset;
  column-gap: unset;
  column-rule: none;
}
.cselect-menu--video-models .cselect-list-host {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cselect-menu--video-models .cselect-list-host--cols {
  display: grid;
  align-items: start;
  gap: 0;
}
.cselect-menu--video-models .cselect-column {
  min-width: 0;
  margin: 0 !important;
  padding: 0 8px !important;
  border: none !important;
  border-top: none !important;
  gap: 0;
}
.cselect-menu--video-models .cselect-column:not(:first-child) {
  border-inline-start: 1px solid var(--divider) !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
}
.cselect-menu--video-models .cselect-group-header {
  white-space: normal;
  line-height: 1.3;
  padding: 6px 8px 3px;
}
/* Next category inside the same packed column — tight divider, not a big gap. */
.cselect-menu--video-models
  .cselect-column
  .cselect-group-header:not(:first-child) {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}
.cselect-menu--video-models .cselect-option {
  gap: 6px;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 8px;
}
.cselect-menu--video-models .cselect-option-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hint (quality — price) stays compact; never spills over the next row/column. */
.cselect-menu--video-models .cselect-option-hint {
  flex: 0 1 auto;
  max-width: 48%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: end;
}
.cselect-menu--video-models .cselect-option-hint-inner {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: none), (max-width: 768px) {
  .cselect-menu--video-models {
    width: auto;
    max-width: 92vw;
    max-height: 320px;
    padding: 5px;
  }
  .cselect-menu--video-models .cselect-list-host {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .cselect-menu--video-models .cselect-column {
    padding: 0 !important;
  }
  .cselect-menu--video-models .cselect-column:not(:first-child) {
    margin-top: 4px !important;
    padding-top: 4px !important;
    border-inline-start: none !important;
    border-top: 1px solid var(--divider) !important;
  }
  .cselect-menu--video-models
    .cselect-column
    .cselect-group-header:not(:first-child) {
    margin-top: 4px;
  }
  .cselect-menu--video-models .cselect-option {
    padding: 8px 12px;
  }
  .cselect-menu--video-models .cselect-option-hint {
    max-width: 42%;
  }
}

/* Voices: split panel — categories on the right, voices on the left (RTL). */
.cselect-menu--voices {
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 24px));
  max-height: min(64vh, 440px);
  overflow: hidden;
  padding: 0;
  columns: unset;
  column-gap: unset;
  column-rule: none;
}
.cselect-menu--voices .cselect-search-wrap,
.cselect-menu--voices .cselect-voice-toolbar {
  flex-shrink: 0;
  padding: 8px 10px 0;
}
.cselect-menu--voices .cselect-voice-toolbar:not([hidden]) {
  padding-bottom: 4px;
}
.cselect-menu--voices .cselect-list-host,
.cselect-menu--voices .cselect-voice-split {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 220px;
  overflow: hidden;
}
.cselect-voice-cats {
  flex: 0 0 168px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--surface-2, #f4f5f6);
  border-inline-end: 1px solid var(--divider);
}
.cselect-voice-cat {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-sm, 8px);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: start;
  line-height: 1.3;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}
.cselect-voice-cat:hover {
  background: color-mix(in srgb, var(--accent, #0a6b76) 8%, transparent);
  color: var(--text);
}
.cselect-voice-cat.is-active {
  background: color-mix(in srgb, var(--accent, #0a6b76) 14%, var(--surface));
  color: var(--accent, #0a6b76);
}
.cselect-voice-items {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
}
.cselect-menu--voices .cselect-option-row {
  width: 100%;
  min-width: 0;
}
.cselect-menu--voices .cselect-option {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  padding: 8px 10px;
  min-width: 0;
}
.cselect-menu--voices .cselect-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.25;
}
.cselect-menu--voices .cselect-option-hint {
  flex-shrink: 0;
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  opacity: 0.85;
}
.cselect-menu--voices .cselect-option-preview {
  width: 34px;
  min-width: 34px;
  align-self: stretch;
  margin: 0;
  height: auto;
  border-radius: var(--r-sm);
}
@media (hover: none), (max-width: 768px) {
  .cselect-menu--voices {
    width: min(96vw, 420px);
    max-height: min(70vh, 480px);
  }
  .cselect-voice-cats {
    flex-basis: 132px;
  }
}
.cselect-option-hint-inner {
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
}
.cselect-audio-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--text-2);
}
.cselect-audio-icon--conditional {
  color: var(--text-muted);
  opacity: 0.55;
}
.cselect-option.active .cselect-audio-icon--conditional {
  color: var(--text-muted);
  opacity: 0.65;
}
/* .cselect-option-hint::before {
  content: "·";
  margin-inline-end: 6px;
  color: var(--text-muted);
} */
.cselect-option.active .cselect-option-hint {
  color: var(--accent);
  opacity: 0.85;
}

.cselect-option-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.cselect-option-row .cselect-option {
  flex: 1;
  min-width: 0;
}

.cselect-option-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  margin: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-pressed);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    color 0.12s,
    border-color 0.12s,
    background 0.12s;
}

.cselect-option-preview:hover:not(:disabled) {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-pressed));
}

.cselect-option-preview:disabled {
  opacity: 0.55;
  cursor: wait;
}

.cselect-option-preview--text {
  width: auto;
  min-width: 38px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.cselect-option-row:has(.cselect-option.active) .cselect-option-preview {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.cselect-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0 8px;
  margin-bottom: 4px;
  background: var(--surface);
}
.cselect-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-pressed, #f4f5f6);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
}
.cselect-search:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--surface);
}
.cselect-list-host {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}
.cselect-voice-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 6px;
}
.cselect-voice-toolbar[hidden] {
  display: none;
}
.cselect-voice-more {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--accent, #0a6b76);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.cselect-voice-more:hover {
  text-decoration: underline;
}
.cselect-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted, #888);
  font-size: 13px;
}

/* ============ Inline spinner inside buttons ============ */
.btn-inline-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-inline-end: 6px;
}
.btn-secondary .btn-inline-spinner,
.btn-ghost .btn-inline-spinner {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--text);
}

/* ============ Style tab: tiles-grid with inline add tile ============ */
.card-compact {
  padding: var(--s-4);
}
.card-header-compact {
  margin-bottom: var(--s-3);
}

.card-compact .elem-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--s-2);
}
.card-compact .elem-tile {
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.card-compact .elem-tile-img {
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-pressed);
  position: relative;
}
.card-compact .elem-tile-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
}
.card-compact .elem-tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  gap: 4px;
  min-height: 26px;
}
.card-compact .elem-tile-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-compact .elem-remove-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.card-compact .elem-remove-btn:hover {
  background: var(--surface-pressed);
  color: var(--red);
}

/* ── Inline "add" tile ───────────────────────────── */
.elem-tile-add {
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.elem-tile-add:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.elem-tile-add-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-3);
}
.elem-tile-add-plus {
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.elem-tile-add:hover .elem-tile-add-plus {
  color: var(--accent);
}
.elem-tile-name-hint {
  color: var(--text-3) !important;
  font-style: normal;
}
.elem-tile-footer-hint {
  justify-content: center;
}
.elem-tile-footer-edit {
  gap: 4px;
}
.elem-tile-save-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent, #7c5cfc);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.elem-tile-save-btn:hover {
  opacity: 0.85;
}

/* ── Add character modal ── */
.add-char-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-block: 20px;
}
.add-char-preview {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--border);
}
.add-char-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  align-self: flex-start;
  width: 100%;
}
.add-char-name-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.add-char-name-input:focus {
  border-color: var(--accent);
}

/* Crop step before a reference photo is saved (reference-crop.js). */
.refcrop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 14, 22, 0.58);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeIn 0.18s var(--ease-out);
}

.refcrop-panel {
  width: min(760px, 100%);
  max-height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 0 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow:
    0 24px 70px rgba(6, 16, 24, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  animation: modalIn 0.28s var(--ease-out);
  overflow: hidden;
}

.refcrop-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 0 18px;
}

.refcrop-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.refcrop-head-copy {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.refcrop-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.refcrop-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
}

.refcrop-stage {
  position: relative;
  margin: 0 18px;
  height: min(50vh, 440px);
  min-height: 240px;
  border-radius: 16px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(
      120% 90% at 50% 0%,
      color-mix(in srgb, var(--accent) 28%, #121a22),
      #0c1218 62%
    );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.refcrop-photo {
  position: absolute;
}

.refcrop-photo img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.refcrop-shade {
  position: absolute;
  background: rgba(6, 10, 16, 0.62);
  pointer-events: none;
}

.refcrop-box {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
  cursor: grab;
  touch-action: none;
}

.refcrop-box.is-dragging {
  cursor: grabbing;
}

.refcrop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      to right,
      transparent 33.33%,
      rgba(255, 255, 255, 0.42) 33.33%,
      rgba(255, 255, 255, 0.42) calc(33.33% + 1px),
      transparent calc(33.33% + 1px),
      transparent 66.66%,
      rgba(255, 255, 255, 0.42) 66.66%,
      rgba(255, 255, 255, 0.42) calc(66.66% + 1px),
      transparent calc(66.66% + 1px)
    ),
    linear-gradient(
      to bottom,
      transparent 33.33%,
      rgba(255, 255, 255, 0.42) 33.33%,
      rgba(255, 255, 255, 0.42) calc(33.33% + 1px),
      transparent calc(33.33% + 1px),
      transparent 66.66%,
      rgba(255, 255, 255, 0.42) 66.66%,
      rgba(255, 255, 255, 0.42) calc(66.66% + 1px),
      transparent calc(66.66% + 1px)
    );
}

.refcrop-size {
  position: absolute;
  inset-inline-start: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.72);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.refcrop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.refcrop-handle--nw { top: -7px; left: -7px; cursor: nwse-resize; }
.refcrop-handle--ne { top: -7px; right: -7px; cursor: nesw-resize; }
.refcrop-handle--se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.refcrop-handle--sw { bottom: -7px; left: -7px; cursor: nesw-resize; }

.refcrop-handle--n,
.refcrop-handle--s {
  width: 28px;
  height: 7px;
  border-radius: 99px;
  left: 50%;
  margin-left: -14px;
  cursor: ns-resize;
}
.refcrop-handle--n { top: -4px; }
.refcrop-handle--s { bottom: -4px; }

.refcrop-handle--e,
.refcrop-handle--w {
  width: 7px;
  height: 28px;
  border-radius: 99px;
  top: 50%;
  margin-top: -14px;
  cursor: ew-resize;
}
.refcrop-handle--e { right: -4px; }
.refcrop-handle--w { left: -4px; }

.refcrop-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  flex-wrap: wrap;
}

.refcrop-tools-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.refcrop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.refcrop-chip,
.refcrop-reset {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.refcrop-chip {
  padding: 5px 11px;
  border-radius: 999px;
}

.refcrop-chip:hover,
.refcrop-reset:hover {
  border-color: var(--accent);
  color: var(--text);
}

.refcrop-chip.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
}

.refcrop-reset {
  margin-inline-start: auto;
  padding: 5px 12px;
  border-radius: 10px;
}

.refcrop-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 18px 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

@media (max-width: 640px) {
  .refcrop-backdrop {
    padding: 10px;
    align-items: flex-end;
  }
  .refcrop-panel {
    border-radius: 18px 18px 14px 14px;
  }
  .refcrop-stage {
    height: min(46vh, 360px);
    min-height: 200px;
  }
  .refcrop-sub {
    display: none;
  }
}

.elem-tile-img-clear {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.elem-tile-add .elem-tile-img:hover .elem-tile-img-clear {
  opacity: 1;
}
.elem-tile-name-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  padding: 0;
  font-family: inherit;
}
.elem-tile-name-input::placeholder {
  color: var(--text-muted);
}

/* ============ AI generation toast (Cinema Atelier) ============ */
.toast.toast-ai {
  --ai-ring-w: 1px;
  --ai-radius: var(--r-md, 12px);
  --_toast-color: transparent;
  position: relative;
  isolation: isolate;
  overflow: visible;
  padding: 10px 12px 10px 14px;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  align-items: center;
  border: none;
  border-radius: var(--ai-radius);
  font-family: var(--font-ui, inherit);
  background-color: var(--surface);
  background-image: linear-gradient(
    135deg,
    color-mix(in srgb, var(--surface) 90%, var(--accent, #0a6b76)) 0%,
    var(--surface) 48%,
    color-mix(in srgb, var(--surface) 94%, var(--ember, #e86d2f)) 100%
  );
  box-shadow:
    var(--shadow-md),
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 0 24px color-mix(in srgb, var(--accent, #0a6b76) 6%, transparent);
  animation: toastIn 0.28s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

/* Spinning border ring — teal → cyan → ember */
.toast.toast-ai::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: var(--ai-ring-w);
  --ai-shimmer: 0deg;
  background: conic-gradient(
    from var(--ai-shimmer),
    #12a3b0 0deg 240deg,
    #7ec8d0 265deg,
    #eef6f7 278deg,
    #0a6b76 292deg,
    #e86d2f 308deg,
    #12a3b0 325deg 360deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  animation: aiToastBorderFlow 2.8s linear infinite;
}

@property --ai-shimmer {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* Soft teal aura */
.toast.toast-ai::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: calc(var(--ai-radius) + 6px);
  z-index: -1;
  background: radial-gradient(
    ellipse 90% 80% at 50% 50%,
    color-mix(in srgb, var(--accent, #0a6b76) 16%, transparent),
    transparent 72%
  );
  pointer-events: none;
  animation: aiToastAura 3.2s ease-in-out infinite;
}

.toast.toast-ai > * {
  position: relative;
  z-index: 1;
}

/* Resolved AI toast: keep the same footprint as in-progress toastAI */
.toast.toast-ai.toast-ai-resolved::before,
.toast.toast-ai.toast-ai-resolved::after {
  animation: none;
}
.toast.toast-ai.toast-ai-resolved::before {
  background: color-mix(
    in srgb,
    var(--_toast-color, var(--accent, #0a6b76)) 55%,
    transparent
  );
  opacity: 0.85;
}
.toast.toast-ai.toast-ai-resolved::after {
  opacity: 0.35;
}
.toast-ai-brand--done {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: color-mix(
    in srgb,
    var(--_toast-color, var(--accent, #0a6b76)) 16%,
    var(--surface)
  );
}
.toast-ai-brand--done .toast-icon {
  font-size: 16px;
}
.toast.toast-ai.toast-success {
  --_toast-color: color-mix(in srgb, var(--green, #1f9d63) 55%, transparent);
}
.toast.toast-ai.toast-error {
  --_toast-color: color-mix(in srgb, var(--red, #d64545) 55%, transparent);
}
.toast.toast-ai.toast-warning {
  --_toast-color: color-mix(in srgb, var(--ember, #e86d2f) 55%, transparent);
}
.toast.toast-ai.toast-info {
  --_toast-color: color-mix(in srgb, var(--accent, #0a6b76) 45%, transparent);
}

@keyframes aiToastBorderFlow {
  to {
    --ai-shimmer: 360deg;
  }
}

@keyframes aiToastAura {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.9;
  }
}

.toast-ai-text {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.4;
}

.toast-ai-timer {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  opacity: 0.7;
  margin-inline-start: auto;
  padding-inline-start: 8px;
  flex-shrink: 0;
  align-self: center;
}

/* Sparkles create the logo → logo holds → logo fades → loop (no outer frame) */
.toast-ai-brand {
  --ai-create: 3.6s;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
}

.toast-ai-spark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 0;
  pointer-events: none;
  animation: toastAiCreateSpark var(--ai-create) ease-in-out infinite;
}

.toast-ai-lottie {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  max-width: none;
}

.toast-ai-fallback-icon {
  color: var(--accent, #0a6b76);
}

.toast-ai-logo {
  width: 32px;
  height: 32px;
  display: block;
  overflow: visible;
  position: relative;
  z-index: 1;
  animation: toastAiCreateLogo var(--ai-create) ease-in-out infinite;
}

.toast-ai-logo-track {
  fill: none;
  stroke: color-mix(in srgb, var(--text, #0a1628) 10%, transparent);
  opacity: 0;
  animation: toastAiCreateBase var(--ai-create) ease-in-out infinite;
}

.toast-ai-logo-base {
  fill: none;
  stroke: var(--text, #0a1628);
  opacity: 0;
  animation: toastAiCreateBase var(--ai-create) ease-in-out infinite;
}

.toast-ai-logo-sweep {
  fill: none;
}

/* Draw-in when sparkles “write” the box; undraw when logo dissolves */
.toast-ai-logo-sweep-path {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: toastAiCreateDraw var(--ai-create)
    cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.toast-ai-logo-sweep-fold {
  animation-delay: 0.06s;
}

.toast-ai-logo-sweep-spine {
  animation-delay: 0.12s;
}

.toast-ai-logo-letters {
  opacity: 0;
  animation: toastAiCreateLetters var(--ai-create) ease-in-out infinite;
}

/* 0–18% sparkles peak alone
   18–42% sparkles fade while logo draws
   42–62% logo holds, sparkles quiet
   62–82% logo dissolves, sparkles return
   82–100% sparkles ready for next create */
@keyframes toastAiCreateSpark {
  0%,
  8% {
    opacity: 0.2;
    transform: scale(0.92);
  }
  18% {
    opacity: 0.95;
    transform: scale(1.02);
  }
  32% {
    opacity: 0.55;
    transform: scale(1);
  }
  48%,
  58% {
    opacity: 0.18;
    transform: scale(0.96);
  }
  72% {
    opacity: 0.55;
    transform: scale(1);
  }
  88%,
  100% {
    opacity: 0.25;
    transform: scale(0.94);
  }
}

@keyframes toastAiCreateLogo {
  0%,
  12% {
    opacity: 0;
  }
  16%,
  62% {
    opacity: 1;
  }
  80%,
  100% {
    opacity: 0;
  }
}

@keyframes toastAiCreateDraw {
  0%,
  14% {
    stroke-dashoffset: 1;
  }
  36% {
    stroke-dashoffset: 0;
  }
  60% {
    stroke-dashoffset: 0;
  }
  78%,
  100% {
    stroke-dashoffset: 1;
  }
}

@keyframes toastAiCreateBase {
  0%,
  32% {
    opacity: 0;
  }
  38%,
  60% {
    opacity: 1;
  }
  76%,
  100% {
    opacity: 0;
  }
}

@keyframes toastAiCreateLetters {
  0%,
  28% {
    opacity: 0;
  }
  38%,
  60% {
    opacity: 1;
  }
  76%,
  100% {
    opacity: 0;
  }
}

/* Continuous sweep for export / long jobs (no create–dissolve) */
.toast-ai-brand--loop {
  width: 32px;
  height: 32px;
}

.toast-ai-brand--loop .toast-ai-logo {
  width: 32px;
  height: 32px;
  animation: none;
  opacity: 1;
}

.toast-ai-brand--loop .toast-ai-logo-track,
.toast-ai-brand--loop .toast-ai-logo-base,
.toast-ai-brand--loop .toast-ai-logo-letters {
  animation: none;
  opacity: 1;
}

.toast-ai-brand--loop .toast-ai-logo-sweep-path {
  stroke-dasharray: 0.2 0.8;
  stroke-dashoffset: 0;
  animation: toastAiLogoSweepLoop 2.4s cubic-bezier(0.45, 0.05, 0.55, 0.95)
    infinite;
}

.toast-ai-brand--loop .toast-ai-logo-sweep-fold {
  animation-delay: -0.8s;
}

.toast-ai-brand--loop .toast-ai-logo-sweep-spine {
  animation-delay: -1.6s;
  stroke-dasharray: 0.28 0.72;
}

@keyframes toastAiLogoSweepLoop {
  to {
    stroke-dashoffset: -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.toast-ai::before {
    animation: none;
    --ai-shimmer: 280deg;
  }
  .toast.toast-ai::after {
    animation: none;
    opacity: 0.7;
  }
  .toast-ai-spark,
  .toast-ai-logo,
  .toast-ai-logo-sweep-path,
  .toast-ai-logo-letters,
  .toast-ai-logo-base,
  .toast-ai-logo-track {
    animation: none;
  }
  .toast-ai-spark {
    opacity: 0.3;
  }
  .toast-ai-logo {
    opacity: 1;
  }
  .toast-ai-logo-sweep-path {
    stroke-dashoffset: 0;
  }
  .toast-ai-logo-letters,
  .toast-ai-logo-base,
  .toast-ai-logo-track {
    opacity: 1;
  }
  .toast-ai-brand--loop .toast-ai-logo-sweep-path {
    stroke-dasharray: 0.35 0.65;
    stroke-dashoffset: -0.15;
  }
}

/* ============ AI work overlay (image studios) ============ */
/* Erase / fill, auto-fix and colour check all wait on the same overlay: the
   frame is dimmed but still readable, a viewfinder marks it, a light sweep
   scans it, and one glass pill carries the brand mark + the running step. */
@property --aiw-spin {
  syntax: "<angle>";
  inherits: false;
  initial-value: 120deg;
}

.aiw {
  --aiw-glow: #12a3b0;
  --aiw-glow-2: #e86d2f;
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  border-radius: inherit;
  overflow: hidden;
  isolation: isolate;
  animation: aiwFade 0.32s ease both;
}

.aiw[data-tone="color"] {
  --aiw-glow: #5ac8d4;
  --aiw-glow-2: #f0a060;
}

.aiw[hidden] {
  display: none;
}

/* Vignette, not a flat wash - the middle of the picture stays legible. */
.aiw-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    118% 88% at 50% 46%,
    rgba(7, 16, 30, 0.2) 0%,
    rgba(7, 16, 30, 0.5) 52%,
    rgba(7, 16, 30, 0.76) 100%
  );
  backdrop-filter: blur(2.5px) saturate(0.86);
  -webkit-backdrop-filter: blur(2.5px) saturate(0.86);
}

/* The worked-on picture, measured by trackAiWorkTarget(). Everything that
   scans or frames lives in here - never over the empty stage around it. */
.aiw-zone {
  position: absolute;
  top: var(--aiw-top, 0px);
  left: var(--aiw-left, 0px);
  width: var(--aiw-w, 100%);
  height: var(--aiw-h, 100%);
  border-radius: var(--aiw-radius, 0px);
  overflow: hidden;
  pointer-events: none;
  /* Lifts the picture out of the dimmed stage around it. */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 22px 52px -26px rgba(0, 0, 0, 0.8);
}

/* Soft band with a bright leading edge, travelling top → bottom. Both fade
   out towards the sides so it reads as light passing over the picture rather
   than a laser drawn edge to edge. */
.aiw-scan {
  position: absolute;
  inset-inline: 0;
  top: -46%;
  height: 46%;
  mix-blend-mode: screen;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    color-mix(in srgb, var(--aiw-glow) 7%, transparent) 55%,
    color-mix(in srgb, var(--aiw-glow) 22%, transparent) 88%,
    color-mix(in srgb, var(--aiw-glow) 36%, transparent) 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    #000 14%,
    #000 86%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    #000 14%,
    #000 86%,
    transparent 100%
  );
  animation: aiwScan 4.2s cubic-bezier(0.5, 0.02, 0.4, 1) infinite;
}

.aiw-scan::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 1px;
  background: var(--aiw-glow);
  box-shadow: 0 0 10px 0 color-mix(in srgb, var(--aiw-glow) 45%, transparent);
  opacity: 0.75;
}

/* The colour check measures hue, so its leading edge carries the spectrum. */
.aiw[data-tone="color"] .aiw-scan::after {
  background: linear-gradient(
    to right,
    #12a3b0,
    #6fd3a8,
    #f3c969,
    #e86d2f,
    #12a3b0
  );
  box-shadow: 0 0 12px 1px rgba(120, 200, 210, 0.45);
}

/* Viewfinder - four hairline corners that breathe with the sweep. */
.aiw-frame {
  position: absolute;
  inset: clamp(8px, 2.6%, 18px);
  pointer-events: none;
  animation: aiwFrame 4.2s ease-in-out infinite;
}

.aiw-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 14px -2px color-mix(in srgb, var(--aiw-glow) 70%, transparent);
  animation: aiwCorner 4.2s ease-in-out infinite;
}

/* Physical sides on purpose - the corners are pinned to physical corners, so
   logical borders would flip the open edge inside an RTL dialog. */
.aiw-corner--tl {
  top: 0;
  left: 0;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 7px;
}

.aiw-corner--tr {
  top: 0;
  right: 0;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 7px;
  animation-delay: 0.12s;
}

.aiw-corner--br {
  right: 0;
  bottom: 0;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 7px;
  animation-delay: 0.24s;
}

.aiw-corner--bl {
  bottom: 0;
  left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 7px;
  animation-delay: 0.36s;
}

/* Status pill - glass, with the brand gradient orbiting its hairline. */
.aiw-pill {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-block: 8px;
  padding-inline: 11px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(10, 20, 36, 0.5);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  box-shadow:
    0 14px 34px -12px rgba(0, 0, 0, 0.75),
    0 0 44px -16px color-mix(in srgb, var(--aiw-glow) 75%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: aiwPillIn 0.44s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.aiw-pill::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--aiw-spin),
    transparent 0deg,
    transparent 46deg,
    var(--aiw-glow) 96deg,
    var(--aiw-glow-2) 134deg,
    transparent 188deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: aiwSpin 4.6s linear infinite;
}

.aiw-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #fff;
}

.aiw-mark .toast-ai-brand,
.aiw-mark .toast-ai-logo {
  width: 24px;
  height: 24px;
}

/* On the dark pill the mark's ink has to invert - its default is page text. */
.aiw-mark .toast-ai-logo-base {
  stroke: rgba(255, 255, 255, 0.9);
}

.aiw-mark .toast-ai-logo-track {
  stroke: rgba(255, 255, 255, 0.16);
}

.aiw-label {
  color: #fff;
  font-size: 13.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

@keyframes aiwFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes aiwPillIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes aiwScan {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  86% {
    opacity: 1;
  }
  100% {
    transform: translateY(322%);
    opacity: 0;
  }
}

@keyframes aiwFrame {
  0%,
  100% {
    transform: scale(0.994);
  }
  50% {
    transform: scale(1.004);
  }
}

@keyframes aiwCorner {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.92;
  }
}

@keyframes aiwSpin {
  to {
    --aiw-spin: 480deg;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aiw,
  .aiw-pill,
  .aiw-pill::before,
  .aiw-frame,
  .aiw-corner {
    animation: none;
  }
  .aiw-corner {
    opacity: 0.7;
  }
  .aiw-scan {
    top: 44%;
    animation: none;
    opacity: 0.55;
  }
}

/* ============ Job status chips (live inside #toastContainer) ============ */
/* Each chip is a sticky toast - uses the existing .toast layout from
   main.css, with status-aware accents below. */
.toast.job-chip {
  /* Match the toast container width while still allowing icon+text layout */
  gap: var(--s-2);
  align-items: center;
}
.toast.job-chip-running {
  border-color: rgba(0, 113, 227, 0.25);
}
.toast.job-chip-done {
  border-color: rgba(52, 199, 89, 0.35);
  background: rgba(52, 199, 89, 0.06);
}
.toast.job-chip-error {
  border-color: rgba(255, 59, 48, 0.35);
  background: rgba(255, 59, 48, 0.06);
}
.job-chip-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.toast.job-chip-done .job-chip-icon {
  background: var(--green);
  color: white;
}
.toast.job-chip-error .job-chip-icon {
  background: var(--red);
  color: white;
}
.job-chip-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 113, 227, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.job-chip-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.job-chip-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
.job-chip-meta {
  font-size: 11px;
  color: var(--text-3);
}
.toast.job-chip-done .job-chip-meta {
  color: #1a7a2f;
}
.toast.job-chip-error .job-chip-meta {
  color: #b4291f;
}

/* ============ AI image creator modal ============ */
.ai-modal {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

.modal.modal-lg:has(.ai-modal) {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 880px);
  overflow: hidden;
  padding: 0;
}

.modal.modal-lg:has(.ai-modal--fix),
.modal.modal-lg:has(.ai-modal--create) {
  width: min(800px, 96vw);
  max-width: min(800px, 96vw);
  height: min(86vh, 820px);
  max-height: min(86vh, 820px);
}

.ai-modal--fix,
.ai-modal--create {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.ai-modal-header {
  flex-shrink: 0;
  margin: 0;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--divider);
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
}

.ai-modal-heading {
  min-width: 0;
  flex: 1;
}

.ai-modal-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

.ai-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ai-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: 14px 18px 18px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.ai-modal-body--fix,
.ai-modal-body--create {
  gap: 14px;
}
.ai-modal-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.ai-modal-textarea {
  min-height: 100px;
  resize: vertical;
}
.ai-modal-textarea.fix {
  min-height: 88px;
}

/* Mode toggle - segmented control at top of the modal (create vs fix) */
.ai-modal-mode-toggle {
  display: inline-flex;
  align-self: flex-start;
  background: var(--surface-pressed);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.ai-modal--fix .ai-modal-mode-toggle,
.ai-modal--create .ai-modal-mode-toggle {
  align-self: stretch;
  display: flex;
  width: 100%;
}
.ai-modal--fix .ai-modal-mode-toggle .mode-pill,
.ai-modal--create .ai-modal-mode-toggle .mode-pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ai-modal-mode-toggle .mode-pill {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-radius: calc(var(--r-md) - 3px);
  padding: 7px 16px;
  cursor: pointer;
  transition:
    background 0.15s var(--ease-out),
    color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out);
  letter-spacing: -0.005em;
}
/* Three tabs (create / fix / result) share the same row - tighten the padding
   and let the labels shrink so the longest one still fits on one line. */
.ai-modal-mode-toggle--three .mode-pill {
  padding: 7px 8px;
  min-width: 0;
  white-space: nowrap;
}
.ai-modal-mode-toggle--three .mode-pill svg {
  flex: none;
}
.ai-modal-mode-toggle .mode-pill:hover:not(.active):not(:disabled) {
  color: var(--text);
}
.ai-modal-mode-toggle .mode-pill.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.ai-modal-mode-toggle .mode-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Textarea loading overlay */
.ai-textarea-wrap {
  position: relative;
}
.ai-textarea-wrap.loading .ai-modal-textarea,
.ai-textarea-wrap.loading .textarea {
  opacity: 0.4;
  pointer-events: none;
  filter: saturate(0.85);
}
.ai-textarea-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}
.ai-textarea-spinner-ring {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ai-spin 0.7s linear infinite;
  display: block;
}
@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}
.ai-textarea-spinner-label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}

/* Bottom action row - model/quality (physical right, compact) · button+price (physical left)
   space-between: in RTL, first child (controls) → right, second (button) → left.
   Do NOT rely on margin-inline-start:auto on .generate-btn-with-price — that wrapper
   is direction:ltr, so inline-start maps to physical left and pulls the button right. */
.ai-modal-action-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 6px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding-top: var(--s-3);
  border-top: 1px solid var(--divider);
  container-type: inline-size;
  container-name: ai-modal-action;
}
.ai-modal-action-row-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  /* Stay compact on the physical right — do not stretch across the row */
  flex: 0 1 auto;
  overflow: hidden;
  justify-content: flex-start;
}
.ai-modal-action-row .duration-group {
  flex: 0 0 auto;
  min-width: 0;
  gap: 3px;
  overflow: hidden;
}
.ai-modal-action-row .cselect-trigger {
  width: auto;
  min-width: 0;
  max-width: 11rem;
  padding: 6px 8px;
  font-size: 12px;
  gap: 3px;
}
.ai-modal-action-row .cselect-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-modal-action-row .generate-btn-with-price {
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-inline-start: 0;
  margin-left: 0;
  margin-right: 0;
  gap: 6px;
  min-width: 0;
}

@container ai-modal-action (max-width: 36rem) {
  .ai-modal-action-row .duration-label {
    display: none;
  }

  .ai-modal-action-row-controls {
    gap: 3px;
  }

  .ai-modal-action-row .cselect-trigger {
    padding: 5px 6px;
    font-size: 11px;
  }

  .ai-modal-action-row .generate-btn-with-price {
    gap: 4px;
  }

  .ai-modal-action-row .video-generate-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}
/* Price chip only - same button placement as before */
.generate-btn-with-price {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-inline-start: auto;
  direction: ltr;
}
.generate-btn-with-price .video-generate-btn {
  margin-inline-start: 0;
  direction: rtl; /* keep icon+label order; wrapper is ltr only for [btn][price] */
}
.generate-btn-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  direction: ltr;
  flex-shrink: 0;
}

/* References row (persistent characters from style tab) */
.ai-modal-refs {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  height: auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.ai-modal-settings {
  height: auto;
  min-height: 0;
  overflow: visible;
}
/* Uploaded photos and system stills are a gallery, not a form fieldset.
   The settings row keeps the boxed chrome. */
.ai-modal-refs:not(.ai-modal-settings) {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: visible;
}
.ai-modal-refs:not(.ai-modal-settings) .ai-modal-section-label,
.ai-modal-lookdev .ai-modal-section-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 0;
}
/* Reference groups share one gallery layout; settings stay in the footer. */
.ai-modal-send-board.ai-modal-refs-section {
  gap: 0;
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.ai-modal-send-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
.ai-modal-send-media > .ai-modal-refs,
.ai-modal-send-media > .ai-modal-lookdev {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: start;
  min-width: 0;
  padding: 8px 12px;
  gap: 10px;
}
.ai-modal-send-media > :not(:first-child) {
  border-top: 1px solid var(--divider);
}
.ai-modal-reference-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding-block-start: 3px;
}
.ai-modal-reference-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: var(--accent);
}
.ai-modal-send-media .ai-modal-reference-heading .ai-modal-section-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.ai-modal-reference-count {
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ai-modal-reference-hint {
  display: none;
}
.ai-modal-send-board > .ai-modal-settings {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  box-shadow: none;
  margin: 0;
  padding: 5px 10px;
  min-height: 0;
}
.ai-modal-send-board .ai-modal-settings .ai-modal-section-label {
  display: none;
}
.ai-modal-send-board .ai-modal-settings-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  width: 100%;
  min-width: 0;
  overflow: visible;
  row-gap: 6px;
}
.ai-modal-send-board .ai-modal-setting-chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 2px 10px;
  border: 0;
  border-radius: 0;
  border-inline-start: 1px solid var(--divider);
  background: transparent;
  box-shadow: none;
}
.ai-modal-send-board .ai-modal-setting-chip:first-child {
  padding-inline-start: 2px;
  border-inline-start: 0;
}
.ai-modal-send-board .ai-modal-setting-chip-wide {
  max-width: none;
  flex: 0 0 auto;
}
.ai-modal-send-board .ai-modal-setting-chip-grow {
  flex: 1 1 80px;
  max-width: none;
  margin: 0;
  padding: 2px 10px;
  border-top: 0;
  border-inline-start: 1px solid var(--divider);
}
.ai-modal-send-board .ai-modal-setting-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  box-sizing: border-box;
}
.ai-modal-send-board .ai-modal-setting-check input[type="checkbox"]:checked {
  border: 0;
  background: var(--accent) center / 8px 8px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.2 8.3l3 3.1 6.2-6.6'/%3E%3C/svg%3E");
}
.ai-modal-send-board .ai-modal-setting-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}
.ai-modal-send-board .ai-modal-setting-value {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
}
.ai-modal-send-board .ai-modal-setting-control {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
}
.ai-modal-send-board .ai-modal-setting-chip-grow .ai-modal-setting-control {
  flex: 1 1 auto;
}
.ai-modal-send-board .ai-modal-setting-control .cselect-trigger {
  width: auto;
  max-width: 9rem;
  min-height: 0;
  justify-content: flex-start;
  gap: 3px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 400;
}
.ai-modal-send-board .ai-modal-setting-control .cselect-trigger:hover:not(:disabled),
.ai-modal-send-board .ai-modal-setting-control .cselect-trigger.open {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
}
.ai-modal-send-board .ai-modal-setting-chip.excluded {
  opacity: 1;
  border-style: solid;
}
.ai-modal-send-board .ai-modal-setting-chip.excluded .ai-modal-setting-control {
  opacity: 1;
}
.ai-modal-send-board .ai-modal-setting-chip.excluded .ai-modal-setting-value,
.ai-modal-send-board .ai-modal-setting-chip.excluded .cselect-trigger-label {
  color: var(--text-2);
  text-decoration: none;
}
.ai-modal-refs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.ai-modal-refs-empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
}
.ai-modal-refs-empty-hint {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-3);
}
.ai-modal-send-board > .ai-modal-refs-empty-hint {
  margin: 0;
  padding: 8px 12px;
  border-radius: 0;
  border-top: 1px solid var(--divider);
}
.ai-modal-refs-row,
.ai-modal-lookdev-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.ai-modal-ref {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 84px;
}
.ai-modal-ref img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: block;
}
.ai-modal-ref-name {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* Start-frame checkbox row (above refs box, end-frame only) */
.ai-modal-refs-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.ai-modal-cast {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-modal-lookdev {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.ai-modal-ref-item,
.ai-modal-lookdev-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 80px;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.ai-modal-ref-item,
.ai-modal-lookdev-item {
  max-width: 128px;
}
.ai-modal-ref-item:not(.excluded):not(.ai-modal-ref-add),
.ai-modal-lookdev-item:not(.excluded) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface));
}
.ai-modal-ref-item:hover,
.ai-modal-lookdev-item:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.ai-modal-ref-item:has(input:focus-visible),
.ai-modal-lookdev-item:has(input:focus-visible),
.ai-modal-ref-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ai-modal-ref-item input[type="checkbox"],
.ai-modal-lookdev-item input[type="checkbox"] {
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 18px;
  height: 18px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}
.ai-modal-ref-item:not(.ai-modal-ref-add):not(.ai-modal-ref-item--adhoc)::after,
.ai-modal-lookdev-item::after {
  content: "";
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  z-index: 2;
  pointer-events: none;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgb(0 0 0 / 10%);
}
.ai-modal-ref-item:not(.excluded):not(.ai-modal-ref-add):not(.ai-modal-ref-item--adhoc)::after,
.ai-modal-lookdev-item:not(.excluded)::after {
  border-color: var(--accent);
  background: var(--accent) center / 11px 11px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.2 8.3l3 3.1 6.2-6.6'/%3E%3C/svg%3E");
}
.ai-modal-ref-item.excluded img,
.ai-modal-lookdev-item.excluded img,
.ai-modal-lookdev-item.excluded .ai-modal-lookdev-empty {
  opacity: 0.65;
}
.ai-modal-lookdev-item.excluded .ai-modal-lookdev-text {
  opacity: 0.85;
}
.ai-modal-ref-item img,
.ai-modal-lookdev-item img,
.ai-modal-lookdev-empty,
.ai-modal-lookdev-text {
  width: 100%;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 0;
  border: 0;
  background: var(--surface-2);
  box-sizing: border-box;
  box-shadow: none;
}
.ai-modal-ref-item img,
.ai-modal-lookdev-item img {
  object-fit: contain;
  display: block;
}
.ai-modal-refs--places .ai-modal-ref-item img,
.ai-modal-ref-item--adhoc img {
  object-fit: cover;
}
.ai-modal-lookdev-text {
  display: flex;
  align-items: flex-start;
  overflow: hidden;
  padding-block: 8px;
  padding-inline: 10px 32px;
  color: var(--text-2);
  text-align: start;
}
.ai-modal-lookdev-text-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-modal-lookdev-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.ai-modal-reference-caption {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  padding: 4px 8px;
}
.ai-modal-ref-item .ai-modal-ref-name,
.ai-modal-lookdev-item .ai-modal-lookdev-name {
  position: static;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: start;
  text-decoration: none;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-modal-reference-detail {
  display: none;
}
@media (max-width: 640px) {
  .ai-modal-send-media > .ai-modal-refs,
  .ai-modal-send-media > .ai-modal-lookdev {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px 10px;
    gap: 6px;
  }
  .ai-modal-reference-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-block-start: 0;
  }
  .ai-modal-refs-row,
  .ai-modal-lookdev-row {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
}
.ai-modal-cast-list.planning-story-cast {
  max-height: 200px;
}
.ai-modal-cast .planning-story-cast-card.excluded {
  opacity: 0.45;
}
.ai-modal-cast .planning-story-cast-head > input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.ai-modal-fix-prompts,
.ai-create-prompts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-create-prompts > .end-source {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

/* Spacing comes from .prompt-composer - a gap declared here would land later
   in the cascade and silently flatten it back to zero. */
.ai-fix-section {
  display: flex;
  flex-direction: column;
}

/* Both sections ARE prompt composers now (.prompt-composer in
   workspace-tools.css owns the frame, the fill and the hairlines), so all they
   carry here is what makes one primary and the other a quiet aside. Repeating
   the chrome is how the two drifted apart in the first place. */
.ai-fix-section--primary .ai-modal-textarea,
.ai-fix-section--primary .ai-modal-textarea.fix {
  min-height: 96px;
}

.ai-fix-section--muted .field-label {
  color: var(--text-3);
  font-weight: 600;
  font-size: 12px;
}

.ai-fix-section--muted .ai-modal-textarea {
  min-height: 64px;
  color: var(--text-2);
}
.ai-modal-start-check-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

/* One-time web-search reference (frame-slot modal) - no checkbox, has an
   explicit remove button instead since it isn't a project-level toggle. */
.ai-modal-ref-item--adhoc {
  cursor: default;
}
.ai-modal-ref-remove {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 4;
}
.ai-modal-ref-remove:hover {
  background: var(--danger-soft, #fef2f2);
  color: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
}

/* "Add from the internet" tile within the references row */
.ai-modal-ref-add {
  background: transparent;
  /* Dashed stays - it means "empty, add here", the same as the site's upload
     targets - but at the one border weight everything else uses. */
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  width: 100%;
  max-width: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-3);
  cursor: pointer;
  box-shadow: none;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}
.ai-modal-ref-add:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.ai-modal-ref-add .ai-modal-ref-name {
  position: static;
  max-width: none;
  width: auto;
  padding: 0;
  background: none;
  color: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  border-radius: 0;
  white-space: normal;
}

/* ── Web image search modal ("הוסף תמונה מאינטרנט", image-search.js) ─────
   Same four-part chrome as the logo / overlay / subtitle windows: a head with
   an accent icon tile, a pinned toolbar, a tinted scrolling body and a quiet
   footer strip. */
.modal.modal-lg:has(.img-search-modal) {
  width: min(940px, calc(100vw - 32px));
  max-width: min(940px, calc(100vw - 32px));
  height: min(88vh, 760px);
  height: min(88dvh, 760px);
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.img-search-modal {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
}

.img-search-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.img-search-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.img-search-head-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.img-search-head-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.img-search-head-main {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.img-search-head-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.3;
}

.img-search-modal .modal-close {
  flex: none;
  width: 32px;
  height: 32px;
}

/* Toolbar: the search row and the result count stay pinned above the grid. */
.img-search-toolbar {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--s-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.img-search-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 0;
  background: var(--surface-2);
}

.img-search-foot {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.img-search-foot-icon {
  flex: none;
  opacity: 0.65;
}

/* One restrained search row: neutral field and a solid primary action. */
.img-search-bar {
  display: flex;
  flex: none;
  gap: var(--s-2);
}

.img-search-field {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  min-height: 44px;
  padding-inline: var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}

.img-search-field:hover:not(:focus-within) {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong));
}

.img-search-field:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.img-search-field-icon {
  flex: none;
  color: var(--text-muted);
}

.img-search-field:focus-within .img-search-field-icon {
  color: var(--accent);
}

.img-search-input {
  flex: 1;
  min-width: 0;
  padding-block: 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.img-search-input::placeholder {
  color: var(--text-muted);
}

.img-search-clear {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.img-search-clear:hover,
.img-search-clear:focus-visible {
  background: var(--surface-hover);
  color: var(--text);
}

.img-search-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.img-search-clear[hidden] {
  display: none;
}

.img-search-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  min-height: 44px;
  padding: 9px var(--s-4);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--text-on-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    opacity 0.15s;
}

.img-search-btn-icon {
  opacity: 0.85;
}

.img-search-btn:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.img-search-btn:active:not(:disabled) {
  border-color: var(--accent-pressed);
  background: var(--accent-pressed);
}

.img-search-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.img-search-btn:disabled {
  opacity: 0.58;
  cursor: default;
}

/* The results area owns scrolling; the modal chrome remains stable. */
.img-search-results {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--s-2);
  min-height: 0;
  padding: var(--s-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.img-search-meta {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.4;
}

.img-search-meta:empty {
  display: none;
}

.img-search-meta-count {
  color: var(--text-2);
  font-weight: 600;
}

.img-search-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 9px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A uniform grid makes the gallery easy to scan. */
.img-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-content: start;
  gap: var(--s-3);
}

.img-search-tile {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.2s var(--ease-out),
    border-color 0.15s,
    box-shadow 0.2s,
    opacity 0.15s;
}

.img-search-tile:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  box-shadow: var(--shadow-md);
}

.img-search-tile:active {
  transform: translateY(0);
}

.img-search-tile:focus-visible {
  z-index: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.img-search-tile img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition:
    opacity 0.22s ease,
    transform 0.35s var(--ease-out);
}

.img-search-tile.is-loaded img {
  opacity: 1;
}

.img-search-tile:hover img {
  transform: scale(1.05);
}

.img-search-tile-ph {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Same "פס זוהר" as the files grid / media-loading skeleton. */
  background-color: var(--surface-pressed);
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.85) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: media-loading-shimmer 1s linear infinite;
}

:root[data-theme="dark"] .img-search-tile-ph {
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 80%
  );
}

.img-search-tile.is-loaded .img-search-tile-ph {
  display: none;
}

.img-search-tile.is-broken .img-search-tile-ph {
  animation: none;
  background-color: var(--surface-hover);
  background-image: none;
}

.img-search-tile-license {
  position: absolute;
  top: 7px;
  inset-inline-start: 7px;
  max-width: calc(100% - 14px);
  padding: 3px 8px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(8, 18, 32, 0.56);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.img-search-tile.is-loaded .img-search-tile-license {
  opacity: 1;
}

.img-search-tile-license:empty {
  display: none;
}

/* Title / creator ride in on hover so the grid itself stays clean. */
.img-search-tile-info {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 24px 9px 8px;
  background: linear-gradient(transparent, rgba(6, 14, 26, 0.82));
  color: #fff;
  text-align: start;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.18s ease,
    transform 0.24s var(--ease-out);
  pointer-events: none;
}

.img-search-tile:hover .img-search-tile-info,
.img-search-tile:focus-visible .img-search-tile-info {
  opacity: 1;
  transform: none;
}

/* Hover affordance: this tile is a pick, not just a picture. */
.img-search-tile-pick {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 2px 8px rgba(6, 14, 26, 0.3);
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity 0.18s ease,
    transform 0.24s var(--ease-spring);
  pointer-events: none;
}

.img-search-tile:hover .img-search-tile-pick,
.img-search-tile:focus-visible .img-search-tile-pick {
  opacity: 1;
  transform: none;
}

.img-search-tile.is-broken {
  cursor: not-allowed;
  opacity: 0.55;
}

.img-search-tile.is-broken:hover {
  transform: none;
  box-shadow: var(--shadow-xs);
}

.img-search-tile.is-broken .img-search-tile-info,
.img-search-tile.is-broken .img-search-tile-pick,
.img-search-tile.is-broken .img-search-tile-license {
  display: none;
}

.img-search-tile-broken {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: color-mix(in srgb, var(--surface-hover) 88%, transparent);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

/* Preview confirm overlay - a small window inside the window, built from the
   same head / media / meta / actions parts as the dialog around it. */
.img-search-preview {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.16s var(--ease-out);
}

.img-search-preview-card {
  display: flex;
  flex-direction: column;
  width: min(100%, 460px);
  max-height: min(80%, 580px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s var(--ease-out);
}

.img-search-preview-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--divider);
}

.img-search-preview-head-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.img-search-preview-head .modal-close {
  width: 28px;
  height: 28px;
}

.img-search-preview-media {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: min(42vh, 320px);
  overflow: hidden;
  background: #0a1628;
}

.img-search-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: min(42vh, 320px);
  object-fit: contain;
}

.img-search-preview-meta {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px 0;
}

.img-search-preview-title {
  max-width: 100%;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-search-preview-creator {
  max-width: 100%;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-search-preview-license {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-top: 2px;
  padding: 2px 9px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-search-preview-actions {
  display: flex;
  flex: none;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px;
}

.img-search-preview-add {
  min-width: 96px;
  gap: 6px;
}

.img-search-tile-title,
.img-search-tile-creator {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-search-tile-title {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.img-search-tile-creator {
  font-size: 10px;
  line-height: 1.3;
  opacity: 0.82;
}

.img-search-grid--busy .img-search-tile {
  pointer-events: none;
}

.img-search-grid--busy .img-search-tile:not(.is-downloading) {
  opacity: 0.62;
}

.img-search-tile-dl {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.64);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.img-search-spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: imgSearchSpin 0.8s linear infinite;
}

.img-search-tile-dl .img-search-spinner {
  border-color: rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
}

/* Compact empty, no-results and error states. */
.img-search-hero {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 200px;
  padding: var(--s-8) var(--s-4);
  text-align: center;
  animation: slideUp 0.25s var(--ease-out);
}

.img-search-hero-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: var(--s-2);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}

.img-search-hero--error .img-search-hero-icon {
  border-color: color-mix(in srgb, var(--red) 24%, transparent);
  background: color-mix(in srgb, var(--red) 9%, transparent);
  color: var(--red);
}

.img-search-hero-title {
  max-width: 460px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.img-search-hero-sub {
  max-width: 440px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.img-search-retry,
.img-search-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.img-search-retry {
  margin-top: var(--s-1);
}

.img-search-retry:hover,
.img-search-more-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.img-search-retry:focus-visible,
.img-search-more-btn:focus-visible,
.img-search-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.img-search-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 440px;
  margin-top: var(--s-2);
}

.img-search-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.img-search-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.img-search-loading {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 180px;
  color: var(--text-3);
  font-size: 12.5px;
}

/* Pagination and source attribution stay visually secondary. */
.img-search-more {
  display: flex;
  flex: none;
  justify-content: center;
  min-height: 8px;
  padding: var(--s-2) 0 var(--s-1);
}

.img-search-more-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-3);
  font-size: 12px;
}

.img-search-more-loading .img-search-spinner {
  width: 16px;
  height: 16px;
}

.img-search-end {
  color: var(--text-muted);
  font-size: 11.5px;
}

.img-search-foot a {
  color: var(--text-3);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.img-search-foot a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

@keyframes imgSearchSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 768px) {
  .modal.modal-lg:has(.img-search-modal) {
    width: 100%;
    max-width: 100%;
    height: min(90vh, 760px);
    height: min(90dvh, 760px);
    max-height: min(90vh, 760px);
    max-height: min(90dvh, 760px);
    padding: 0;
  }

  .img-search-head {
    padding: 10px 12px;
  }

  .img-search-head-icon {
    width: 30px;
    height: 30px;
  }

  .img-search-head-main {
    font-size: 15px;
  }

  .img-search-head-sub {
    display: none;
  }

  .img-search-toolbar {
    padding: 10px 12px;
  }

  .img-search-modal .modal-close {
    width: 36px;
    height: 36px;
  }

  .img-search-results {
    padding: var(--s-3);
  }

  .img-search-input {
    font-size: 16px;
  }

  .img-search-clear {
    width: 32px;
    height: 32px;
  }

  .img-search-btn {
    min-width: 48px;
    padding-inline: var(--s-3);
  }

  /* Room is tight - the magnifier alone carries the action. */
  .img-search-btn > span {
    display: none;
  }

  .img-search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-2);
  }

  /* No hover on touch: keep the caption and the pick badge visible. */
  .img-search-tile-info,
  .img-search-tile-pick {
    opacity: 1;
    transform: none;
  }

  .img-search-hero {
    min-height: 180px;
    padding: var(--s-6) var(--s-2);
  }

  .img-search-hero-icon {
    width: 52px;
    height: 52px;
  }

  .img-search-chips {
    margin-top: var(--s-1);
  }

  .img-search-preview {
    padding: var(--s-3);
  }

  .img-search-preview-card {
    width: min(100%, 380px);
    max-height: min(84%, 560px);
  }

  .img-search-chip {
    min-height: 34px;
    padding-inline: 12px;
  }

  .img-search-foot {
    padding: 8px 12px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .img-search-field {
    padding-inline: 10px;
  }

  .img-search-btn {
    min-width: 44px;
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .img-search-spinner,
  .img-search-tile-ph {
    animation: none;
  }

  .img-search-hero,
  .img-search-preview,
  .img-search-preview-card {
    animation: none;
  }

  .img-search-field,
  .img-search-clear,
  .img-search-btn,
  .img-search-tile,
  .img-search-tile img,
  .img-search-tile-info,
  .img-search-tile-pick,
  .img-search-tile-license,
  .img-search-retry,
  .img-search-more-btn,
  .img-search-chip {
    transition: none;
  }

  .img-search-tile:hover {
    transform: none;
  }

  .img-search-tile:hover img {
    transform: none;
  }
}
/* ── Shots overview board ("סקירת קטעים", shots-overview.js) ───────────── */
.modal.modal-lg:has(.shots-overview-modal) {
  width: min(1180px, 98vw);
  max-width: min(1180px, 98vw);
  height: min(94vh, 980px);
  max-height: min(94vh, 980px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}
.shots-overview-modal {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

/* Header */
.shots-overview-header {
  flex-shrink: 0;
  margin: 0;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  gap: 16px;
  align-items: center;
}
.shots-overview-heading {
  min-width: 0;
  flex-shrink: 0;
}
.shots-overview-subtitle {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
}
.shots-overview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
  margin-inline-end: 8px;
}
.ov-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.ov-metric.is-warn {
  background: color-mix(in srgb, var(--orange) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--orange) 35%, var(--border));
}
.ov-metric-label {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
}
.ov-metric-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ov-metric.is-warn .ov-metric-value {
  color: var(--orange);
}
.ov-metric-audio {
  max-width: 180px;
}
.ov-metric-audio-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sticky chrome: timeline + filters */
.shots-overview-chrome {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--surface-2), var(--bg));
  border-bottom: 1px solid var(--divider);
}
.shots-overview-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
  background: var(--bg);
  gap: 0;
}

/* List / grid container */
.shots-overview-list {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.shots-overview-list.is-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.shots-overview-list.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-content: start;
  background: transparent;
  border: none;
  box-shadow: none;
  /* Grid scrolls inside the same flex child */
  grid-auto-rows: max-content;
}
.shots-overview-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 200px;
  text-align: center;
  color: var(--text-3);
  padding: 24px;
}
.shots-overview-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}
.shots-overview-empty-text {
  font-size: 12px;
  max-width: 280px;
  line-height: 1.4;
}

/* Column header (list) */
.ov-list-head {
  display: grid;
  grid-template-columns:
    28px 36px 72px minmax(140px, 1.4fr)
    108px 100px 96px 132px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  z-index: 2;
}
.ov-col-time,
.ov-col-dur {
  direction: ltr;
  text-align: center;
}

/* Scene banner over the run of shots filmed in one place.
   Derived from the plan's parts, not stored on the shot - see
   resolveShotScenes in plan-apply-align.js. Shown only when at least one run
   actually has a scene, so a plan-less board stays exactly as it was. */
.ov-scene-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 12px 6px;
  border-bottom: 1px solid var(--divider);
}
.ov-scene-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-scene-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
}
.ov-scene-head.is-unscened .ov-scene-name {
  font-weight: 600;
  color: var(--text-3);
}
/* Grid mode lays cards in auto-fill columns; the banner takes a whole row. */
.shots-overview-list.is-grid .ov-scene-head {
  grid-column: 1 / -1;
  padding: 8px 2px 6px;
}
.shots-overview-list.is-grid .ov-scene-head:first-child {
  padding-top: 0;
}
.shots-overview-list.is-list .ov-scene-head {
  background: var(--surface-2);
}

/* Shared card / row */
.shots-overview-card {
  position: relative;
  cursor: pointer;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  transition:
    background 0.12s var(--ease-out),
    border-color 0.12s var(--ease-out),
    box-shadow 0.12s var(--ease-out);
}
.shots-overview-card.dragging {
  opacity: 0.35;
}

/* LIST ROW */
.shots-overview-list.is-list .shots-overview-card.is-row {
  display: grid;
  grid-template-columns:
    28px 36px 72px minmax(140px, 1.4fr)
    108px 100px 96px 132px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  min-height: 64px;
}
.shots-overview-list.is-list .shots-overview-card.is-row:last-child {
  border-bottom: none;
}
.shots-overview-list.is-list .shots-overview-card.is-row:hover {
  background: var(--surface-hover);
}
.shots-overview-list.is-list .shots-overview-card.is-highlight {
  background: var(--accent-soft);
  border-inline-start: 3px solid var(--accent);
}
.shots-overview-list.is-list .shots-overview-card.is-selected {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-inline-start: 3px solid var(--accent);
}
.shots-overview-list.is-list .shots-overview-card.is-excluded {
  opacity: 0.55;
}
.shots-overview-list.is-list
  .shots-overview-card.is-excluded
  .shots-overview-thumb {
  filter: grayscale(0.7);
}

/* List drop indicators = horizontal lines */
.shots-overview-list.is-list .shots-overview-card.ov-drop-before::before,
.shots-overview-list.is-list .shots-overview-card.ov-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 3;
  width: auto;
  top: auto;
  bottom: auto;
}
.shots-overview-list.is-list .shots-overview-card.ov-drop-before::before {
  top: -1px;
  inset-inline-start: auto;
}
.shots-overview-list.is-list .shots-overview-card.ov-drop-after::after {
  bottom: -1px;
  inset-inline-end: auto;
}

.ov-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.55;
}
.shots-overview-card:hover .ov-drag-handle {
  opacity: 1;
  color: var(--text-2);
}
.shots-overview-list.is-list .shots-overview-num {
  position: static;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--r-sm);
  background: var(--surface-pressed);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: none;
}
.shots-overview-list.is-list .shots-overview-thumb {
  width: 72px;
  height: 40px;
  aspect-ratio: auto;
  border-radius: 6px;
  background: var(--surface-pressed);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  flex-shrink: 0;
}
.shots-overview-list.is-list .ov-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.shots-overview-list.is-list .ov-card-sub {
  display: none;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-3);
}
.shots-overview-list.is-list .ov-card-sub-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Lets time / dur / status stay in the desktop grid columns */
.shots-overview-list.is-list .ov-card-meta {
  display: contents;
}
.shots-overview-list.is-list .shots-overview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.shots-overview-list.is-list .ov-lyric {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 14px;
}
.ov-lyric-empty {
  visibility: hidden;
}
.shots-overview-list.is-list .ov-context,
.shots-overview-list.is-list .ov-dur-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.shots-overview-list.is-list .ov-time-chip {
  direction: ltr;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-pressed);
  color: var(--text-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.shots-overview-list.is-list .shots-overview-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-2);
  min-width: 0;
}
.shots-overview-list.is-list .ov-status-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shots-overview-list.is-list .ov-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding: 0;
  border: none;
  background: transparent;
}
.shots-overview-list.is-list .ov-act-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.shots-overview-list.is-list .ov-act-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.shots-overview-list.is-list .ov-act-btn.is-off,
.shots-overview-list.is-list .ov-act-btn.is-on,
.shots-overview-list.is-list .ov-act-btn.is-playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.shots-overview-list.is-list .ov-sel-badge {
  display: none;
  position: absolute;
  top: 50%;
  inset-inline-start: 10px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.shots-overview-list.is-list .shots-overview-card.is-selected .ov-sel-badge {
  display: flex;
}
.shots-overview-list.is-list .shots-overview-card.is-selected .ov-drag-handle {
  visibility: hidden;
}

/* GRID CARD (secondary view) */
.shots-overview-list.is-grid .shots-overview-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.shots-overview-list.is-grid .shots-overview-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.shots-overview-list.is-grid .shots-overview-card.is-highlight {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent-soft-2),
    var(--shadow-sm);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
}
.shots-overview-list.is-grid .shots-overview-card.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    var(--shadow-sm);
}
.shots-overview-list.is-grid .shots-overview-card.is-excluded .ov-card-media,
.shots-overview-list.is-grid .shots-overview-card.is-excluded .ov-card-body {
  opacity: 0.55;
  filter: grayscale(0.65);
}
.shots-overview-list.is-grid .shots-overview-card.ov-drop-before::before,
.shots-overview-list.is-grid .shots-overview-card.ov-drop-after::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 3;
}
.shots-overview-list.is-grid .shots-overview-card.ov-drop-before::before {
  inset-inline-start: -6px;
}
.shots-overview-list.is-grid .shots-overview-card.ov-drop-after::after {
  inset-inline-end: -6px;
}
.ov-card-media {
  position: relative;
}
.shots-overview-list.is-grid .shots-overview-num {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.shots-overview-list.is-grid .shots-overview-thumb {
  aspect-ratio: 16 / 9;
  background: var(--surface-pressed);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.ov-card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px 6px;
  min-width: 0;
}
.ov-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.shots-overview-list.is-grid .shots-overview-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shots-overview-list.is-grid .shots-overview-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  max-width: 46%;
  font-size: 10.5px;
  color: var(--text-3);
}
.shots-overview-list.is-grid .ov-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 8px 8px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}
.shots-overview-list.is-grid .ov-act-btn {
  flex: 1;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.shots-overview-list.is-grid .ov-act-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.shots-overview-list.is-grid .ov-act-btn.is-off,
.shots-overview-list.is-grid .ov-act-btn.is-on,
.shots-overview-list.is-grid .ov-act-btn.is-playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.shots-overview-list.is-grid .ov-sel-badge {
  display: none;
  position: absolute;
  top: 8px;
  inset-inline-start: 36px;
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.shots-overview-list.is-grid .shots-overview-card.is-selected .ov-sel-badge {
  display: flex;
}

.ov-context-muted {
  color: var(--text-muted);
  font-size: 11px;
}
.ov-dur {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.ov-dur-btn {
  width: 22px;
  height: 22px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ov-dur-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.ov-dur-val {
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 2.8em;
  text-align: center;
  font-weight: 600;
}
.ov-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
  font-size: 11px;
  overflow: hidden;
}
.ov-time-chip {
  flex-shrink: 0;
  direction: ltr;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-pressed);
  color: var(--text-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.ov-lyric {
  color: var(--text-3);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Toolbar */
.shots-overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.shots-overview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.ov-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s,
    color 0.12s;
}
.ov-filter-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ov-filter-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.ov-filter-chip.is-active .status-pip {
  background: #fff;
}
.ov-view-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  gap: 2px;
  flex-shrink: 0;
}
.ov-view-btn {
  width: 30px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ov-view-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.ov-view-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Song strip / mini player */
.shots-overview-strip-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.ov-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ov-strip-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ov-strip-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ov-strip-label {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.ov-strip-audio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}
.ov-strip-audio .ui-icon {
  flex-shrink: 0;
  color: var(--text-3);
}
.ov-strip-audio-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-strip-audio.is-empty {
  font-weight: 500;
  color: var(--text-3);
}
.ov-strip-status {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-strip-status[hidden] {
  display: none;
}
.ov-strip-total {
  flex-shrink: 0;
  direction: ltr;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-pressed);
}
.ov-strip-row {
  display: flex;
  direction: ltr;
  align-items: center;
  gap: 12px;
}
.ov-strip-bar-wrap {
  flex: 1;
  min-width: 0;
}
.ov-playall-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.12s,
    color 0.12s,
    background 0.12s;
}
.ov-playall-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.ov-playall-btn.is-playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ov-playall-btn.is-playing:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.shots-overview-strip {
  position: relative;
  display: flex;
  direction: ltr;
  height: 40px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-pressed);
  box-shadow: inset 0 0 0 1px var(--border);
}
.ov-strip-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 2;
}
.ov-strip-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.ov-strip-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: var(--orange, #ff9500);
  opacity: 0.75;
}
.ov-strip-seg {
  position: relative;
  flex-grow: 0;
  flex-shrink: 0;
  min-width: 3px;
  border: none;
  border-inline-end: 1px solid rgba(0, 0, 0, 0.22);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.12s;
}
.ov-seg-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}
.ov-seg-handle:hover {
  background: rgba(255, 255, 255, 0.45);
}
.ov-strip-seg:hover,
.ov-strip-seg.is-highlight {
  opacity: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}
.ov-strip-seg.status-empty {
  background: var(--text-muted);
}
.ov-strip-seg.status-prompt {
  background: var(--accent);
}
.ov-strip-seg.status-image {
  background: var(--purple);
}
.ov-strip-seg.status-pick {
  background: var(--orange);
}
.ov-strip-seg.status-done {
  background: var(--green);
}
.ov-strip-seg.status-editing {
  background: var(--indigo);
}
.ov-strip-seg.status-skip {
  background: var(--text-3);
}
.ov-strip-times {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  direction: ltr;
  font-size: 10px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-inline-start: 0;
}
.ov-strip-times-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ov-bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--accent-soft-2);
  background: var(--accent-soft);
}
.ov-bulk-bar[hidden] {
  display: none !important;
}
.ov-bulk-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-inline-end: 2px;
}
.ov-bulk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
}
.ov-bulk-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ov-title-input {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 6px;
  outline: none;
  box-shadow: var(--shadow-focus);
}

@media (max-width: 900px) {
  .ov-col-status {
    display: none;
  }
  .shots-overview-list.is-list .shots-overview-status {
    display: none;
  }
  .ov-list-head,
  .shots-overview-list.is-list .shots-overview-card.is-row {
    grid-template-columns: 24px 32px 64px minmax(100px, 1fr) 90px 88px 112px;
  }
}

/* Mobile: bottom sheet. List stays compact rows; card view stays a grid. */
@media (max-width: 720px) {
  .modal.modal-lg:has(.shots-overview-modal) {
    width: 100%;
    max-width: 100%;
    height: min(92dvh, 92vh);
    max-height: min(92dvh, 92vh);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal.modal-lg:has(.shots-overview-modal)::before {
    flex-shrink: 0;
    margin: 10px auto 6px;
  }
  .shots-overview-modal {
    flex: 1;
    min-height: 0;
  }

  .shots-overview-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title close"
      "summary summary";
    gap: 4px 8px;
    padding: 10px 12px 8px;
    align-items: center;
  }
  .shots-overview-heading {
    grid-area: title;
    min-width: 0;
  }
  .shots-overview-subtitle {
    display: none;
  }
  .shots-overview-header .modal-close {
    grid-area: close;
    margin: 0;
  }
  .shots-overview-header .modal-title {
    font-size: 16px;
  }
  .shots-overview-summary {
    grid-area: summary;
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    margin: 0;
    justify-content: flex-start;
  }
  .ov-metric {
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
  }
  .ov-metric.is-warn {
    background: transparent;
    border: none;
  }
  .ov-metric-label {
    font-size: 11px;
  }
  .ov-metric-label::after {
    content: ":";
  }
  .ov-metric-value {
    font-size: 11px;
    font-weight: 600;
  }
  .ov-metric-audio {
    display: none;
  }

  .shots-overview-chrome {
    gap: 6px;
    padding: 4px 10px 8px;
  }
  .shots-overview-strip-wrap {
    padding: 8px;
    gap: 4px;
  }
  .ov-strip-label {
    font-size: 11px;
  }
  .ov-strip-audio {
    font-size: 10px;
  }
  .ov-strip-times,
  .ov-strip-times-hint {
    display: none;
  }
  .ov-strip-row {
    gap: 8px;
  }
  .ov-playall-btn {
    width: 34px;
    height: 34px;
  }
  .shots-overview-strip {
    height: 26px;
  }
  .ov-seg-handle {
    width: 12px;
  }

  .shots-overview-toolbar {
    gap: 4px;
  }
  .ov-view-toggle {
    flex-shrink: 0;
  }
  .shots-overview-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .shots-overview-chips::-webkit-scrollbar {
    display: none;
  }
  .ov-filter-chip {
    flex: 0 0 auto;
    padding: 5px 10px;
  }

  .shots-overview-body {
    padding: 0 0 10px;
  }

  .ov-list-head {
    display: none;
  }

  /* Compact horizontal rows — list view only. Card view keeps the grid. */
  .shots-overview-list.is-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .shots-overview-list.is-list .shots-overview-card.is-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    min-height: 56px;
    border: none;
    border-bottom: 1px solid var(--divider);
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    background: var(--surface);
  }
  .shots-overview-list.is-list .shots-overview-card.is-row:last-child {
    border-bottom: none;
  }
  .shots-overview-list.is-list .shots-overview-card.is-highlight,
  .shots-overview-list.is-list .shots-overview-card.is-selected {
    border-inline-start: 3px solid var(--accent);
    background: var(--accent-soft);
    box-shadow: none;
  }

  .shots-overview-list.is-list .ov-drag-handle {
    display: none;
  }

  .shots-overview-list.is-list .shots-overview-num {
    position: static;
    flex-shrink: 0;
    width: 24px;
    min-width: 24px;
    height: 24px;
    padding: 0;
    border-radius: var(--r-sm);
    background: var(--surface-pressed);
    color: var(--text-2);
    font-size: 11px;
    backdrop-filter: none;
  }

  .shots-overview-list.is-list .shots-overview-thumb {
    position: relative;
    flex-shrink: 0;
    width: 56px;
    height: 36px;
    aspect-ratio: auto;
    border-radius: 6px;
    overflow: hidden;
  }

  .shots-overview-list.is-list .ov-card-main {
    flex: 1;
    min-width: 0;
    padding: 0;
    gap: 2px;
  }
  .shots-overview-list.is-list .shots-overview-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    -webkit-line-clamp: unset;
  }
  .shots-overview-list.is-list .ov-lyric {
    display: none;
  }
  .shots-overview-list.is-list .ov-card-sub {
    display: flex;
  }
  .shots-overview-list.is-list .ov-card-meta {
    display: none;
  }

  .shots-overview-list.is-list .ov-card-actions {
    flex-shrink: 0;
    justify-content: flex-end;
    gap: 2px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    width: auto;
  }
  .shots-overview-list.is-list .ov-act-btn {
    flex: 0 0 auto;
    width: 34px;
    min-width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-2);
  }
  .shots-overview-list.is-list .ov-act-add {
    display: none;
  }
  .shots-overview-list.is-list .ov-act-btn.is-off,
  .shots-overview-list.is-list .ov-act-btn.is-playing {
    background: var(--accent);
    color: #fff;
    border-radius: var(--r-sm);
  }

  .shots-overview-list.is-list .ov-sel-badge {
    top: 50%;
    inset-inline-start: 10px;
    transform: translateY(-50%);
  }

  .shots-overview-list.is-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 10px 8px;
  }
  .shots-overview-list.is-grid .ov-card-body {
    gap: 4px;
    padding: 6px 8px 4px;
  }
  .shots-overview-list.is-grid .shots-overview-title {
    font-size: 12px;
  }
  .shots-overview-list.is-grid .shots-overview-status {
    max-width: 42%;
    font-size: 10px;
  }
  .shots-overview-list.is-grid .ov-card-actions {
    gap: 2px;
    padding: 4px 4px 6px;
  }
  .shots-overview-list.is-grid .ov-act-btn {
    height: 32px;
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .shots-overview-header .modal-title {
    font-size: 15px;
  }
  .shots-overview-list.is-list .ov-act-btn {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }
}

/* Style-tab settings - single horizontal row */
.ai-modal-settings-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.ai-modal-setting-chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  max-width: 220px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition:
    opacity 0.15s,
    border-color 0.15s;
}
.ai-modal-setting-chip-wide {
  max-width: 200px;
}
.ai-modal-setting-chip-grow {
  flex: 1 1 auto;
  max-width: 280px;
  min-width: 120px;
}
.ai-modal-setting-check {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.ai-modal-setting-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}
.ai-modal-setting-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.ai-modal-setting-control {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
.ai-modal-setting-control .cselect-trigger {
  width: 100%;
  min-width: 72px;
  max-width: 120px;
  font-size: 12px;
  padding: 4px 8px;
}
.ai-modal-setting-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.ai-modal-setting-chip.excluded {
  opacity: 0.55;
  border-style: dashed;
}
.ai-modal-setting-chip.excluded .ai-modal-setting-value {
  color: var(--text-3);
  text-decoration: line-through;
}
.ai-modal-setting-chip.excluded .ai-modal-setting-control {
  opacity: 0.45;
  pointer-events: none;
}

/* "What will be sent" preview */
.ai-modal-send-preview {
  background: var(--accent-soft);
  border: 1px solid rgba(0, 113, 227, 0.22);
  border-radius: var(--r-md);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-modal-send-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.ai-modal-send-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-modal-send-model {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid rgba(0, 113, 227, 0.22);
  border-radius: var(--r-pill);
  padding: 2px 10px;
}
.ai-modal-send-refs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.ai-modal-send-ref-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--surface);
  background: var(--surface);
  display: block;
  box-shadow: var(--shadow-xs);
}
.ai-modal-send-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ai-modal-send-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 2px 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-modal-send-tag-style {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(0, 113, 227, 0.2);
}
.ai-modal-send-style-tags {
  margin-top: -2px;
}
.ai-modal-send-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-modal-send-prompt {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  max-height: 96px;
  overflow-y: auto;
  direction: ltr;
  text-align: start;
  font-family: "SF Mono", Consolas, monospace;
}
.ai-modal-send-prompt.is-he {
  direction: rtl;
  font-family: inherit;
}
.ai-modal-send-prompt em {
  font-family: inherit;
  font-style: italic;
  color: var(--text-muted);
}

/* Result panel inside modal */
.ai-modal-result {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.ai-modal-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.ai-modal-result-badge {
  font-size: 10px;
  font-weight: 700;
  color: white;
  background: var(--green);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-modal-result-badge--muted {
  background: var(--text-3);
}
.ai-modal-result-meta {
  font-size: 11px;
  color: var(--text-3);
}
.ai-modal-result-caption {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.ai-modal-result-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--divider);
  background: var(--surface-2);
}
.ai-modal-result-status.is-on-slot {
  border-color: color-mix(in srgb, var(--green) 45%, var(--divider));
  background: color-mix(in srgb, var(--green) 10%, var(--surface-2));
}
.ai-modal-result-status.is-off-slot {
  border-color: color-mix(in srgb, var(--amber, #c48a2a) 50%, var(--divider));
  background: color-mix(in srgb, var(--amber, #c48a2a) 12%, var(--surface-2));
}
.ai-modal-result-status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 180px;
}
.ai-modal-result-status-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ai-modal-result-status-detail {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.35;
}
.ai-modal-result-slot-now {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.ai-modal-result-slot-now-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-modal-result-slot-now-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #000;
  cursor: zoom-in;
  display: block;
}
.ai-modal-result-slot-now-empty {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 10px;
  text-align: center;
  padding: 4px;
  line-height: 1.2;
}
.ai-modal-result--detached .ai-modal-result-img {
  outline: 2px solid color-mix(in srgb, var(--amber, #c48a2a) 55%, transparent);
  outline-offset: -2px;
}
.ai-modal-result-img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #000;
  border-radius: var(--r-md);
  display: block;
}
.ai-modal-result-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ai-modal-result-actions .btn {
  flex: 1 1 auto;
  min-width: 120px;
}
.ai-modal-undo-btn,
.ai-modal-reassign-btn {
  flex: 1 1 160px;
}
/* "You are editing this image" preview at the top of fix mode */
.ai-modal-editing-preview,
.ai-fix-source {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}

.ai-fix-source-media {
  flex-shrink: 0;
  width: 112px;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: var(--shadow-xs);
}

.ai-fix-source-img,
.ai-modal-editing-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.ai-modal-editing-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.ai-fix-source-meta,
.ai-modal-editing-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.ai-fix-source-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: var(--r-pill);
}

.ai-fix-source-title,
.ai-modal-editing-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.ai-modal-editing-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.ai-fix-source-hint,
.ai-modal-editing-hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}

.ai-fix-suggestions,
.ai-create-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-fix-suggestions-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.suggestion-cards.ai-fix-suggestion-cards,
.ai-fix-suggestion-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-modal--fix .ai-fix-suggestion-cards .suggestion-card,
.ai-modal--create .ai-fix-suggestion-cards .suggestion-card,
.video-prompt-suggestions .ai-fix-suggestion-cards .suggestion-card {
  padding: 10px 12px;
  margin: 0;
  min-width: 0;
}

.video-prompt-suggestions .suggestion-card-label {
  font-size: 12px;
  line-height: 1.3;
}

.video-prompt-suggestions .suggestion-card-desc {
  font-size: 11px;
  line-height: 1.35;
}

.ai-fix-prompt-field {
  margin-top: 4px;
}

.ai-modal--fix .ai-modal-action-row,
.ai-modal--create .ai-modal-action-row {
  flex-shrink: 0;
  position: static;
  margin: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  overflow: visible;
  z-index: 2;
}

/* ============================================================
   RESPONSIVE / MOBILE - Media AI Box
   Breakpoints:
     960px → tablet  (nav collapses to drawer)
     768px → mobile  (full layout rework)
     480px → phone   (compact tweaks)
   ============================================================ */

/* ─── Missing base utility ─── */
/* input-big used in new-project modal */
.input-big {
  font-size: 17px;
  font-weight: 500;
  padding: 12px var(--s-4);
  border-radius: var(--r-md);
  letter-spacing: -0.015em;
}

/* mobile topbar: hidden on desktop */
.mobile-topbar {
  display: none;
}

/* project-header-bottom: tabs + editor button together */
.project-header-bottom {
  display: flex;
  align-items: stretch;
  gap: var(--s-2);
}

/* ─── Tablet & below (≤960px): nav drawer ─── */
@media (max-width: 960px) {
  /* App shell: single column. 100vw is a few pixels wider than the
     phone screen and lets the page drag sideways. */
  #app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Side nav: fixed right-side drawer (RTL app) */
  .side-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0; /* physical right - same as inset-inline-start in RTL */
    left: auto; /* prevent any LTR offset */
    width: min(280px, 85vw);
    z-index: 502;
    transform: translateX(100%);
    transition: transform 0.18s var(--ease-out);
    box-shadow: none;
    overflow-y: auto;
    padding-top: var(--s-6);
    border-inline-start: none;
    border-left: 1px solid var(--border);
    will-change: transform;
  }

  .side-nav.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Dim backdrop when nav is open */
  body:has(.side-nav.open)::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 500;
    pointer-events: auto;
  }

  /* Main area: full width, content scrollable */
  .main-area {
    min-width: 0;
    width: 100%;
  }

  .content-area {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    touch-action: pan-y;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /* leave room at top for fixed topbar (52px) */
    padding: calc(52px + var(--s-4)) var(--s-5) var(--s-8);
  }

  .content-area::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  /* Full-width fixed topbar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 501;
  }

  .mobile-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    flex: 1;
    min-width: 0;
  }

  .mobile-topbar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
    margin-inline-end: var(--s-4);
    display: block;
  }

  .mobile-toggle {
    display: flex !important;
    position: static;
    inset-inline-end: unset;
    top: unset;
    z-index: unset;
    width: 36px;
    height: 36px;
    min-width: 36px;
    touch-action: manipulation;
    /* background: var(--surface-pressed); */
    /* border: 1px solid var(--border); */
    /* border-radius: var(--r-sm); */
    font-size: 22px;
    flex-shrink: 0;
    margin-right: var(--s-1);
  }

  /* Workspace: no fixed heights, prevent overflow */
  .shots-layout {
    --shots-col-h: auto;
    min-height: unset;
  }

  .shots-layout > * {
    min-width: 0;
    overflow-x: hidden;
  }

  .shots-layout > .shot-rail,
  .shots-layout > .shot-stage,
  .shots-layout > .videos-panel,
  .shot-rail,
  .shot-stage,
  .videos-panel {
    position: static;
    height: auto;
    max-height: none;
  }

  .shots-layout > .shot-rail,
  .shot-rail {
    max-height: 240px;
  }

  /* Project header: wrappable */
  .project-header {
    padding: var(--s-3) var(--s-4);
    flex-wrap: wrap;
    gap: var(--s-2);
  }

  /* Usage: one-row stats + scrollable history table */
  .usage-stats-grid {
    grid-template-columns: 1.5fr repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .usage-stat-box {
    padding: var(--s-2);
    min-width: 0;
  }

  .usage-history-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Editor: proper layout with fixed 52px topbar ── */
  .content-area:has(.editor-shell) {
    padding: calc(52px + var(--s-2)) var(--s-2) var(--s-2);
    overflow: hidden;
  }

  .editor-shell {
    height: calc(100dvh - 52px - var(--s-4));
    min-height: unset;
    grid-template-rows: 1fr minmax(200px, 40%);
  }
}

/* ─── Mobile (≤768px): full layout rework ─── */
@media (max-width: 768px) {
  .content-area {
    padding: calc(52px + var(--s-3)) var(--s-3) var(--s-8);
  }

  /* ── Home ── */
  .home,
  .home-section,
  .projects-grid {
    min-width: 0;
    max-width: 100%;
  }

  .home-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) 0 var(--s-3);
    gap: var(--s-3);
    min-width: 0;
    max-width: 100%;
  }

  .home-section-toggle {
    overflow: hidden;
  }

  .home-section-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-section-meta {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-greeting {
    min-width: 0;
  }

  .home-new-group {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--s-3);
  }

  /* Always show delete + assign-to-group (no hover on touch) */
  .project-delete-btn,
  .project-group-btn {
    opacity: 1;
  }

  /* ── Shot rail → header above, shots scroll horizontally ── */
  .shots-layout > .shot-rail,
  .shot-rail {
    flex-direction: column;
    max-height: none;
    padding: var(--s-2) var(--s-3) 0;
    overflow: visible;
  }

  .rail-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    margin-top: var(--s-2);
    flex: 1;
    gap: var(--s-2);
    padding-bottom: var(--s-2);
    scrollbar-width: none;
  }

  .rail-list::-webkit-scrollbar {
    display: none;
  }

  .rail-item {
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    min-width: 68px;
    max-width: 80px;
    padding: var(--s-2) var(--s-1);
    gap: 4px;
    -webkit-touch-callout: none;
    user-select: none;
  }

  .rail-thumb {
    width: 60px;
    height: 44px;
    border-radius: var(--r-sm);
  }

  .rail-item-actions {
    display: none;
  }

  .rail-info {
    display: none;
  }

  .rail-item:has(.shot-performance-badge) .rail-info,
  .archive-item:has(.shot-performance-badge) .rail-info {
    display: block;
    position: absolute;
    inset: 0;
    min-width: 0;
    flex: none;
    pointer-events: none;
  }

  .rail-item .rail-title,
  .rail-item .rail-status-label,
  .rail-item .status-pip,
  .archive-item .rail-title {
    display: none;
  }

  .rail-item:has(.shot-performance-badge) .rail-status {
    display: block;
    margin: 0;
  }

  .archive-item {
    position: relative;
  }

  .rail-item .shot-performance-badge,
  .archive-item .shot-performance-badge {
    position: absolute;
    margin: 0;
    inset-inline-start: auto;
    inset-inline-end: 4px;
    bottom: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    pointer-events: auto;
    z-index: 1;
  }

  .rail-item .shot-performance-badge .ui-icon,
  .rail-item .shot-performance-badge .ui-icon svg,
  .archive-item .shot-performance-badge .ui-icon,
  .archive-item .shot-performance-badge .ui-icon svg {
    width: 11px;
    height: 11px;
  }

  .rail-insert {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 22px;
    padding: 0 2px;
    margin: 0;
    opacity: 0.9;
    gap: 3px;
  }

  .rail-insert-line {
    width: 1px;
    height: 16px;
    flex: 0 0 auto;
  }

  .rail-insert-plus {
    width: 20px;
    height: 20px;
  }

  .rail-add-btn {
    flex-shrink: 0;
    align-self: center;
    margin-top: 0;
    margin-inline-start: var(--s-2);
  }

  /* ── Shot stage ── */
  .shots-layout > .shot-stage,
  .shot-stage {
    height: auto;
    max-height: none;
    overflow: visible;
    padding-inline-end: 0;
  }

  .shot-stage > .stage-card {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .shot-stage > .stage-card .video-card-body {
    flex: none;
    overflow: visible;
  }

  /* Keep generate row visible while scrolling the page on mobile. */
  .shot-stage > .stage-card .video-card-footer {
    position: sticky;
    bottom: 0;
    z-index: 8;
    background: var(--surface);
    box-shadow: 0 -6px 16px color-mix(in srgb, #000 8%, transparent);
    border-bottom-left-radius: var(--r-lg);
    border-bottom-right-radius: var(--r-lg);
    /* Pull the framed generate row down to the sticky edge */
    padding-top: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
  }

  /* A bottom-stuck box is inset by the SCROLLER's own padding-bottom, so the
     generate row docked ~24-32px above the screen edge and read as a bar
     floating over a white strip. Move that breathing room off the scroller and
     onto the layout: the row sits flush on the edge while the page still ends
     with air under the last card. */
  .content-area:has(.shots-layout) {
    padding-bottom: 0;
  }

  .content-area:has(.shots-layout) .shots-layout {
    padding-bottom: var(--s-4);
  }

  /* ── Videos panel ── */
  .shots-layout > .videos-panel,
  .videos-panel {
    max-height: 50vh;
    overflow-y: auto;
  }

  /* ── Project header: stack title, then tabs+button row ── */
  .project-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .project-header-bottom {
    align-self: stretch;
    justify-content: space-between;
  }

  .project-header-tabs .wtab {
    flex: 0 1 auto;
    text-align: center;
  }

  /* ── Stage bar: allow wrapping ── */
  .stage-bar {
    flex-wrap: wrap;
    gap: var(--s-2);
  }

  /* ── Prompt card head: wrap actions below ── */
  .prompt-card-head {
    flex-wrap: wrap;
  }

  /* Frames stay side by side. The swap button floats on the seam and
     does not take a column, so the image slots keep their width. */
  .frame-chooser {
    position: relative;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-2);
  }

  .frame-arrow {
    transform: rotate(-90deg);
    height: 18px;
    font-size: 14px;
  }

  .frame-swap-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    width: 32px;
    height: 32px;
    margin: 0;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: 0 1px 6px color-mix(in srgb, #000 18%, transparent);
    transform: translate(-50%, -50%);
  }

  .frame-slot {
    max-height: unset;
    overflow: hidden;
    min-height: auto;
  }

  /* On touch/mobile: icon chips always visible (handled in workspace-layout.css) */

  /* Mobile: compact AI menu trigger */
  .frame-slot-action-bar {
    top: 6px;
    left: 6px;
    right: auto;
  }

  .frame-slot-ai-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
  }

  .frame-slot-ai-btn .ui-icon,
  .frame-slot-ai-btn .ui-icon svg {
    width: 12px;
    height: 12px;
  }

  /* Empty slot - the chooser is one column here, so the labels still fit */
  .frame-slot-empty-btns {
    gap: var(--s-2);
    padding: var(--s-2);
  }

  .frame-slot-empty-head {
    gap: 5px;
  }

  .frame-slot-hint-text {
    font-size: 11px;
  }

  .frame-slot-icon {
    width: 28px;
    height: 28px;
  }

  .frame-slot-icon svg {
    width: 15px;
    height: 15px;
  }

  .frame-slot-btn-row {
    gap: 5px;
    max-width: 260px;
  }

  .frame-slot-empty {
    min-height: unset;
    padding: var(--s-2) var(--s-1);
    gap: 4px;
  }

  .frame-slot-empty-icon {
    width: 28px;
    height: 28px;
    font-size: 15px;
    margin: 0;
  }

  .frame-slot-empty-label {
    font-size: 9px;
  }

  .frame-slot-empty-actions {
    gap: 4px;
    max-width: 100%;
  }

  .frame-slot-empty-actions .btn {
    font-size: 11px;
    padding: 4px 6px;
    white-space: nowrap;
  }

  /* Video settings: row 1 = controls (fill width), row 2 = price + button (fill width).
     Chrome stays; content width matches the pre-chrome layout.
     Flush the frame toward the bottom of the sticky footer on mobile. */
  .video-settings-row {
    flex-wrap: wrap;
    gap: 4px 0;
    width: calc(100% + 18px);
    margin-inline: -9px;
    margin-bottom: 0;
    padding: 6px 8px;
    border-radius: var(--r-md);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
    background: color-mix(in srgb, var(--surface) 86%, var(--accent));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 10%, transparent);
    box-sizing: border-box;
  }

  /* Row 1: controls take the full width and divide it equally */
  .video-settings-row-controls {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .video-settings-row .duration-group {
    flex: 1 1 0;
    min-width: 0;
    gap: 2px;
  }

  .video-settings-row .duration-group--model {
    flex: 0 0 auto;
    min-width: 0;
  }

  .video-settings-row .duration-group--model .cselect-trigger {
    width: auto;
  }

  .video-settings-row .duration-label {
    display: none;
  }

  .video-settings-row .duration-group .cselect-trigger {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 5px 6px;
    font-size: 11px;
    gap: 3px;
  }

  .video-settings-row .duration-group--model .cselect-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Row 2: price + button take the full width, button stretches */
  .video-settings-row .generate-btn-with-price {
    flex: 1 1 100%;
    margin-inline-start: 0;
    margin-top: 4px;
    justify-content: flex-end;
  }

  /* Match Planning "apply and create images" CTA: 36px, 8px radius */
  .video-generate-btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--r-sm);
  }

  .video-settings-row .generate-btn-with-price .video-generate-btn {
    flex: 1;
    justify-content: center;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--r-sm);
  }

  /* ── Modals → bottom sheet ── */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--s-5) var(--s-5)
      max(var(--s-5), env(safe-area-inset-bottom, var(--s-5)));
  }

  .modal.modal-lg {
    max-width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--s-4) var(--s-4)
      max(var(--s-4), env(safe-area-inset-bottom, var(--s-4)));
  }

  /* Planning apply+generate: desktop uses a fixed 840x78vh card whose rules
     beat the generic sheet above. Match every other mobile bottom sheet. */
  .modal:has(.planning-gen-dialog),
  .modal.modal-lg:has(.planning-gen-dialog) {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 88vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: var(--s-4) var(--s-4)
      max(var(--s-4), env(safe-area-inset-bottom, var(--s-4)));
    overflow: hidden;
  }

  .planning-gen-pick-list {
    min-height: 0;
  }

  /* Run-all: fixed header + scrolling list + pinned footer, like the other sheets. */
  .modal.modal-lg:has(.run-all-modal),
  .modal:has(.run-all-modal) {
    width: 100%;
    max-width: 100%;
    height: min(92dvh, 92vh);
    max-height: min(92dvh, 92vh);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal.modal-lg:has(.run-all-modal)::before,
  .modal:has(.run-all-modal)::before {
    flex-shrink: 0;
    margin: 10px auto 2px;
  }

  .run-all-modal {
    flex: 1;
    min-height: 0;
  }

  .run-all-header {
    padding: 8px 14px 10px;
    gap: 8px;
  }

  .run-all-title-icon {
    width: 30px;
    height: 30px;
  }

  .run-all-header .modal-title {
    font-size: 16px;
  }

  .run-all-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .run-all-chrome {
    gap: 8px;
    padding: 10px 12px;
  }

  .run-all-chrome .planning-gen-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .run-all-chrome .planning-gen-pick-actions {
    max-width: none;
    width: 100%;
    min-width: 0;
  }

  .run-all-chrome .planning-gen-filter-btn {
    font-size: 11px;
    padding: 6px 4px;
    min-height: 36px;
  }

  .run-all-chrome .planning-gen-model {
    margin-inline-start: 0;
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 8px;
  }

  .run-all-chrome .planning-gen-res {
    display: contents;
  }

  .run-all-chrome .planning-gen-model .cselect-trigger {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .run-all-chrome .planning-gen-model .cselect-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .run-all-hint {
    font-size: 12px;
  }

  .run-all-chrome .planning-gen-advanced .video-advanced-body {
    max-height: min(28vh, 220px);
  }

  .run-all-chrome .planning-gen-pick-bar {
    flex-wrap: nowrap;
    align-items: center;
  }

  .run-all-chrome .planning-gen-pick-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .run-all-chrome .planning-gen-select-actions .btn {
    min-height: 36px;
  }

  .run-all-body {
    padding: 8px 12px 10px;
  }

  .run-all-footer {
    padding: 10px 12px;
  }

  .run-all-confirm {
    flex: 1 1 auto;
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* VFX studio: fixed header + scrollable body (not whole-sheet scroll) */
  .modal:has(.vfx-modal),
  .modal.modal-lg:has(.vfx-modal) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: min(92dvh, 92vh);
    min-height: 0;
    padding: 0;
  }

  /* Export: sticky footer buttons, body scrolls inside the sheet */
  .modal:has(.export-modal) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    max-height: min(92dvh, 92vh);
    min-height: 0;
    padding: 0;
  }

  /* Audio picker: scroll the list only, not the whole bottom sheet */
  .modal:has(.audio-picker-modal),
  .modal:has(.add-local-modal),
  .modal.modal-lg:has(.add-local-modal--video) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 88vh;
    min-height: 0;
    padding: 0;
  }

  /* AI sound: full-bleed sheet, pinned chrome, inner columns scroll */
  .modal:has(.auto-soundtrack-modal),
  .modal.modal-lg:has(.auto-soundtrack-modal) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 92vh);
    min-height: 0;
    padding: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .modal:has(.auto-soundtrack-modal)::before,
  .modal.modal-lg:has(.auto-soundtrack-modal)::before {
    flex: 0 0 auto;
    margin-top: 10px;
    margin-bottom: 0;
  }

  .modal:has(.global-library-modal) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 88vh;
    min-height: 0;
  }

  /* Drag handle at top of bottom-sheet modal */
  .modal::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-strong);
    border-radius: var(--r-pill);
    margin: 0 auto var(--s-4);
  }

  /* Modal footer: buttons stay in one row, wrap only if very narrow */
  .modal-footer {
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-top: var(--s-4);
    padding-top: var(--s-3);
  }

  .modal-footer .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .modal-footer:has(.modal-footer-extra-actions),
  .modal:has(.planning-gap-fill-list) .modal-footer {
    flex-wrap: nowrap;
  }

  .modal-footer:has(.modal-footer-extra-actions) > .btn,
  .modal-footer-extra-actions .btn,
  .modal:has(.planning-gap-fill-list) .modal-footer > .btn {
    flex: 1 1 0;
    min-width: 0;
  }

  /* ── Form sheets (פרויקט חדש / קבוצה חדשה) ──
     Full-width sheet: fixed header, one scrolling body, footer pinned above
     the home indicator - the whole sheet scrolling would push "צור פרויקט"
     off the bottom of a phone. */
  .modal:has(.form-sheet),
  .modal.modal-lg:has(.form-sheet) {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 92vh);
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  /* The sheet's drag handle sits flush at the top once padding is 0. */
  .modal:has(.form-sheet)::before {
    margin: 8px auto 0;
  }

  .form-sheet-header {
    padding: 12px 16px;
  }

  .form-sheet-header .modal-title {
    font-size: 17px;
  }

  .form-sheet-body {
    gap: 10px;
    padding: 12px 14px 16px;
  }

  .form-sheet-sec {
    padding: 12px;
  }

  /* Beats the generic mobile .modal-footer margin/padding above. */
  .form-sheet-footer {
    margin-top: 0;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom, 10px));
  }

  /* Two style columns: one wastes a whole screen of scroll, and the swatch
     rows still read at this width. */
  .np-sec--style .style-choice-grid--styles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  /* Each preference takes a full row - side by side, its own 2-up grid gets
     only a quarter of the sheet and "חרדי ליטאי" breaks over three lines. */
  .np-sec--style .style-prefs-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .np-sec--style .style-choice-swatch {
    width: 38px;
    height: 30px;
  }

  /* ── Editor: full mobile overhaul ── */
  /* Page container: pull bottom padding tight; respect device safe area */
  .content-area:has(.editor-shell) {
    padding: calc(52px + var(--s-2)) var(--s-2)
      env(safe-area-inset-bottom, var(--s-2));
  }

  /* Shell: grow to fill viewport, give preview more room than timeline */
  .editor-shell {
    height: calc(
      100dvh - 52px - var(--s-2) - env(safe-area-inset-bottom, var(--s-2))
    );
    grid-template-rows: 1fr minmax(185px, 38%);
  }

  /* Back button: 40 × 40 touch target */
  .editor-back-btn {
    width: 40px;
    height: 40px;
  }

  /* Transport: taller bar with finger-sized buttons */
  .preview-transport {
    height: 50px;
    padding: 0 10px;
    gap: 8px;
  }

  .tr-play {
    width: 50px;
    height: 38px;
  }

  .tr-btn,
  .tr-fullscreen {
    width: 38px;
    height: 38px;
  }

  /* Scrub: thicker track + always-visible handle (no hover on touch) */
  .tr-scrub {
    height: 6px;
  }

  .tr-scrub-handle {
    width: 16px;
    height: 16px;
    opacity: 1;
  }

  .tr-timecode {
    min-width: 80px;
    font-size: 11px;
  }

  /* Timeline tools bar: scrollable icon strip */
  .timeline-tools-bar {
    --tb-h: 36px;
    --tb-btn-min-w: 36px;
    gap: 4px;
    padding: 4px 8px;
    min-height: 44px;
  }

  /* Hide text labels - icons are sufficient on small screens */
  .tb-btn-label {
    display: none;
  }

  /* Compact tool buttons: icon-only. Inner buttons fill the pill
     (height: 100%) so they don't overflow the 2px segment padding. */
  .tb-btn {
    min-width: var(--tb-btn-min-w, 36px);
    height: var(--tb-h, 36px);
    min-height: 0;
    padding: 0;
    gap: 0;
  }

  .tb-mobile-only {
    display: inline-flex;
  }

  .tb-segment {
    height: var(--tb-h, 36px);
  }

  .tb-segment .tb-btn {
    min-width: var(--tb-btn-min-w, 36px);
    height: 100%;
    min-height: 0;
  }

  .tb-fit-all-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 0;
  }

  /* BPM number input triggers the number keyboard and crowds the bar - hide it.
     The beat-sync button (in the same tb-group) stays visible. */
  .tb-bpm-group {
    display: none;
  }

  /* Shorter zoom slider so it doesn't dominate the bar */
  .tb-zoom {
    height: var(--tb-h, 36px);
  }
  .tb-zoom input[type="range"] {
    width: 54px;
  }

  /* History buttons: square touch target matching bar height */
  .tb-history {
    height: var(--tb-h, 36px);
  }
  .tb-history-btn {
    width: 32px;
    height: 100%;
  }

  /* Export: icon-only square button on mobile (match the other tool buttons) */
  .tb-export {
    height: var(--tb-h, 36px);
    width: var(--tb-h, 36px);
    padding: 0;
    gap: 0;
    justify-content: center;
    flex: 0 0 var(--tb-h, 36px);
  }

  /* Hide the "ייצוא" caption - the download icon is enough on small screens */
  .tb-export span {
    display: none;
  }

  /* Smooth kinetic scroll for the tracks area */
  .timeline-scroll {
    -webkit-overflow-scrolling: touch;
  }

  /* Playhead drag handle: wider for finger precision */
  .tl-playhead-handle {
    width: 18px;
    height: 18px;
  }

  /* Track rows: slightly tighter to show more tracks on a small viewport */
  .track-row.video .track-label,
  .track-row.video .track-content {
    min-height: 50px;
    height: 50px;
  }

  .track-row.audio .track-label,
  .track-row.audio .track-content,
  .track-row.overlays .track-label,
  .track-row.overlays .track-content {
    min-height: 38px;
    height: 38px;
  }

  .color-popover,
  .tx-popover {
    width: calc(100vw - var(--s-6));
    max-width: 340px;
  }

  .export-radio-group {
    grid-template-columns: 1fr 1fr;
  }

  /* ── Image creator controls: single column ── */
  .img-creator-controls {
    grid-template-columns: 1fr;
  }

  /* AI modal action row: single row, controls stay compact on the right */
  .ai-modal-action-row {
    flex-wrap: nowrap;
    gap: 4px;
    padding-top: var(--s-2);
    overflow: hidden;
  }

  .ai-modal-action-row-controls {
    flex-wrap: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    gap: 3px;
    overflow: hidden;
  }

  .ai-modal-action-row .duration-group {
    flex: 0 0 auto;
    min-width: 0;
    gap: 2px;
  }

  .ai-modal-action-row .duration-label {
    display: none;
  }

  .ai-modal-action-row .cselect-trigger {
    width: auto;
    min-width: 0;
    max-width: 8.5rem;
    padding: 5px 6px;
    font-size: 11px;
    gap: 3px;
  }

  .ai-modal-action-row .video-generate-btn {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--r-sm);
  }
  .ai-modal-action-row .generate-btn-with-price {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-inline-start: 0;
    margin-left: 0;
    margin-right: 0;
    justify-content: flex-end;
  }
  .ai-modal-action-row .generate-btn-with-price .video-generate-btn {
    flex: 0 0 auto;
    min-width: 0;
  }

  /* ── AI modal refs: auto height ── */
  .ai-modal-refs {
    height: auto;
  }

  .ai-fix-source {
    gap: 10px;
    padding: 10px 12px;
  }

  .ai-fix-source-media {
    width: 84px;
  }

  .ai-fix-suggestion-cards {
    grid-template-columns: 1fr 1fr;
  }

  .video-prompt-suggestions .ai-fix-suggestion-cards {
    grid-template-columns: 1fr;
  }

  .ai-fix-section--primary,
  .ai-fix-section--muted {
    padding: 10px;
  }

  .ai-modal--fix .ai-modal-action-row,
  .ai-modal--create .ai-modal-action-row {
    padding: 10px 14px 12px;
  }

  .ai-modal-body--fix,
  .ai-modal-body--create {
    padding: 12px 14px 14px;
  }

  /* ── Lightbox: full-width media ── */
  .lightbox-media {
    max-height: calc(60vh);
  }

  .lightbox-actions {
    justify-content: stretch;
  }

  .lightbox-actions .btn {
    flex: 1;
  }

  /* Lightbox stays centered (not bottom-sheet) on mobile */
  .modal-backdrop:has(.lightbox) {
    align-items: center;
    padding: var(--s-4);
  }

  .modal.modal-lg:has(.lightbox) {
    border-radius: var(--r-xl);
    width: fit-content;
    max-width: calc(100vw - var(--s-6));
    max-height: 90vh;
  }

  .modal.modal-lg:has(.lightbox)::before {
    display: none;
  }

  /* ── Settings: style row stacks ── */
  .style-row {
    flex-direction: column;
    gap: var(--s-3);
  }

  /* ── Settings: element add form stacks ── */
  .elem-add-form {
    flex-wrap: wrap;
  }

  .elem-add-fields {
    flex: 1 1 100%;
  }

  /* ── Settings: API key row - input + actions stay on one line ── */
  .settings-section .api-key-input-row {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }

  .settings-section .api-key-input-row .input {
    flex: 1 1 0;
    min-width: 0;
  }

  .settings-section .api-key-input-actions {
    flex-shrink: 0;
    width: auto;
  }

  /* ── Settings: key row stacks ── */
  .settings-key-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }

  /* ── Settings: data actions stay in one row ── */
  .data-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--s-2);
  }

  /* ── Files grid ── */
  .files-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  /* ── Elem tiles ── */
  .card-compact .elem-tiles-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .style-panel--refs .elem-tiles-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 8px;
  }

  .style-panel--refs .elem-tile-img {
    width: min(64px, 100%);
    max-width: 64px;
  }

  .style-choice {
    min-height: 48px;
  }

  /* ── Choice pills: 2 columns on mobile ── */
  .choice-pills {
    grid-template-columns: 1fr 1fr;
  }

  /* ── Custom select menu: constrain width ── */
  .cselect-menu {
    max-width: 92vw;
  }

  /* ── Toast: narrower than the screen, hugging the inline-end side ── */
  .toast-container {
    bottom: max(var(--s-4), env(safe-area-inset-bottom, var(--s-4)));
    inset-inline: 0;
    /* Not stretched: the chips are capped below, so keep them on the same
       side as the desktop stack instead of spanning the whole width. */
    align-items: flex-end;
    padding-inline: var(--s-4);
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    /* The stack spans the width, so only the vertical drag offset means
       anything here. */
    transform: translateY(var(--toast-drag-y, 0px));
  }

  .toast,
  .toast.toast-ai,
  .toast.job-chip,
  .render-progress--in-dock {
    min-width: 0;
    width: 100%;
    /* Leave the screen edge visible; cap it on wide phones / small tablets. */
    max-width: min(360px, 86%);
    box-sizing: border-box;
  }

  .toast,
  .toast.toast-ai,
  .toast.job-chip {
    padding: 10px 14px;
  }

  .toast.toast-ai::after {
    inset: -4px;
  }

  /* ── Touch targets: 44px minimum ── */
  .btn:not(.btn-sm):not(.btn-icon):not(.btn-xs) {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .nav-item,
  .sidebar-project {
    min-height: 44px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    border: none !important;
  }

  .rail-item {
    min-height: 44px;
  }

  .form-sheet-pill,
  .style-pill,
  .choice-pill,
  .aspect-pill,
  .style-choice,
  .usage-tab,
  .wtab {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .style-choice:not(.style-choice--with-swatch):not(.style-choice--aspect) {
    flex-direction: column;
    align-items: flex-start;
  }

  .style-prefs-grid .style-choice-grid--season > .style-choice {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }

  .style-choice--with-swatch {
    flex-direction: row;
    align-items: center;
  }

  .style-choice--aspect {
    align-items: center;
  }

  .project-header-tabs .wtab {
    min-height: 0;
  }

  /* ── Inputs: 16px prevents iOS auto-zoom ── */
  .input,
  .textarea,
  .select,
  .input-big {
    font-size: 16px;
  }

  /* ── Planning tab: compact mobile chrome (override touch-target inflation) ── */
  .planning-tab {
    gap: 8px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .planning-mobile-nav {
    padding: 2px;
    gap: 2px;
    border-radius: 8px;
  }

  .planning-mobile-nav-btn {
    min-height: 32px !important;
    font-size: 12px;
    gap: 5px;
    border-radius: 6px;
    padding: 4px 8px;
  }

  .planning-mobile-nav-num {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }

  .planning-panel {
    padding: 10px 12px !important;
    gap: 8px;
    border-radius: 10px;
  }

  .planning-panel-titles .card-title {
    font-size: 12px;
  }

  .planning-panel--source {
    min-height: 0 !important;
  }

  .planning-raw {
    min-height: 96px !important;
    max-height: none;
    padding: 10px 12px;
    border-radius: 8px;
  }

  .planning-raw-actions {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
  }

  .planning-tab .planning-ai-btn,
  .planning-tab .planning-gap-btn,
  .planning-tab .planning-extract-btn,
  .planning-tab .planning-more-btn,
  .planning-tab .planning-apply-btn,
  .planning-tab .planning-gen-btn,
  .planning-tab .planning-story-revise-btn,
  .planning-tab .planning-story-run-btn,
  .btn.video-generate-btn {
    min-height: 36px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    font-size: 12px;
    border-radius: 8px;
  }

  .planning-ai-btn {
    flex: 1.4 1 0;
    width: auto;
  }

  .planning-gap-btn {
    flex: 1.1 1 0;
    width: auto;
  }

  .planning-more-btn {
    flex: 0 0 auto;
    width: 36px;
    min-width: 36px;
    padding: 0 !important;
  }

  .planning-extract-btn {
    flex: 0 0 auto;
    width: auto !important;
    justify-content: center;
  }

  .planning-story {
    min-height: 72px !important;
    max-height: 140px;
  }

  .planning-story-cast {
    max-height: 280px;
  }

  .planning-story-beats {
    max-height: 120px;
  }

  .planning-brief {
    min-height: 44px !important;
  }

  .planning-brief-summary {
    min-height: 0 !important;
    font-size: 11px;
  }

  .planning-chars-banner-inner {
    padding: 5px 8px;
    gap: 5px 6px;
    font-size: 11px;
  }

  .planning-char-chip {
    font-size: 10px;
    padding: 1px 6px;
    max-width: 96px;
  }

  .planning-structure-empty {
    min-height: 100px !important;
    padding: 20px 12px !important;
  }

  .planning-part {
    padding: 7px;
    gap: 5px;
  }

  .planning-part-title {
    font-size: 13px !important;
    min-height: 0 !important;
  }

  .planning-seg-row {
    padding: 6px 7px;
    gap: 4px;
  }

  .planning-seg-top {
    grid-template-columns: 16px minmax(0, 1fr) auto 30px;
    gap: 5px;
  }

  .planning-seg-title {
    min-height: 0 !important;
    font-size: 13px !important;
    padding: 6px 8px !important;
  }

  .planning-seg-notes {
    min-height: 0 !important;
    font-size: 12px !important;
    padding: 4px 6px !important;
  }

  .planning-seg-prompt-peek {
    min-height: 0 !important;
    padding: 6px 8px !important;
  }

  .planning-seg-prompt {
    min-height: 56px !important;
    font-size: 12px !important;
    padding: 8px !important;
  }

  .planning-seg-top > .planning-icon-btn {
    width: 30px !important;
    height: 30px !important;
  }

  .planning-seg-row > .keyframe-plan-label {
    margin-inline-start: 21px;
    font-size: 10px;
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
  }

  .planning-add-seg {
    min-height: 28px !important;
    font-size: 11px;
    padding: 2px 8px !important;
  }

  .planning-footer {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 10px 10px 0 0;
    gap: 4px;
    box-shadow: 0 -2px 12px rgba(10, 22, 40, 0.05);
  }

  .planning-apply-actions {
    display: grid;
    grid-template-columns: 36px 1fr 1.35fr;
    gap: 6px;
    width: 100%;
  }
}

/* ─── Small phones (≤480px) ─── */
@media (max-width: 480px) {
  .np-sec--style .style-choice-grid--styles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-area {
    padding: calc(52px + var(--s-2)) var(--s-3) var(--s-6);
  }

  .home-greeting h1 {
    font-size: 20px;
  }

  .projects-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
  }

  .modal {
    padding: var(--s-4) var(--s-3)
      max(var(--s-4), env(safe-area-inset-bottom, var(--s-4)));
  }

  .modal:has(.planning-gen-dialog),
  .modal.modal-lg:has(.planning-gen-dialog) {
    padding: var(--s-4) var(--s-3)
      max(var(--s-4), env(safe-area-inset-bottom, var(--s-4)));
  }

  .editor-shell {
    grid-template-rows: 1fr minmax(160px, 35%);
  }

  /* Transport: hide timecode on smallest phones to give scrub more room */
  .tr-timecode {
    display: none;
  }

  /* Transport buttons: slightly smaller but still 36px tap zone */
  .tr-btn,
  .tr-fullscreen {
    width: 34px;
    height: 34px;
  }

  /* Narrow side-by-side slots: smaller AI chip */
  .frame-slot-action-bar {
    top: 4px;
    left: 4px;
    right: auto;
  }

  .frame-slot-ai-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }

  .frame-slot-ai-btn .ui-icon,
  .frame-slot-ai-btn .ui-icon svg {
    width: 11px;
    height: 11px;
  }

  /* Narrow side-by-side slots: icon-only actions, still one balanced pair */
  .frame-slot-empty-btns {
    gap: 6px;
    padding: 5px;
  }

  .frame-slot-empty-head {
    gap: 4px;
  }

  .frame-slot-icon {
    width: 22px;
    height: 22px;
    border-radius: var(--r-sm);
  }

  .frame-slot-icon svg {
    width: 13px;
    height: 13px;
  }

  .frame-slot-hint-text {
    font-size: 9px;
  }

  .frame-slot-btn-row {
    grid-template-columns: repeat(2, 26px);
    justify-content: center;
    gap: 5px;
    width: auto;
  }

  .frame-slot-empty-btn {
    height: 26px;
    padding: 0;
  }

  .frame-slot-empty-btn-label {
    display: none;
  }

  /* Stack choice pills to single column */
  .choice-pills {
    grid-template-columns: 1fr;
  }

  /* Style pills: single row, scroll if needed */
  .style-pills-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  /* Compact sidebar when open */
  .side-nav {
    width: min(260px, 90vw);
  }

  /* Usage stats: slightly smaller on small phones */
  .usage-stat-value {
    font-size: 13px;
  }

  .usage-stat-label,
  .usage-stat-sub {
    font-size: 9px;
  }

  /* Files grid: 2 items per row */
  .files-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── Touch devices: scrub interaction & larger tap targets ─── */
@media (pointer: coarse) {
  .tr-scrub {
    touch-action: none;
    height: 6px;
  }

  .tr-scrub-handle {
    opacity: 1;
    width: 16px;
    height: 16px;
  }

  .editor-back-btn {
    width: 40px;
    height: 40px;
  }

  /* Reveal controls that are otherwise shown only on hover - on touch there is
     no hover to trigger them, so they'd be unreachable. (Timeline trim handles
     already appear on tap-to-select; rail-insert is hidden on mobile by design.) */
  .panel-video-zoom-btn,
  .panel-video-remove-btn,
  .vplayer-knob,
  .aplayer-knob,
  .project-delete-btn,
  .project-group-btn,
  .project-menu-trigger,
  .elem-tile-img-clear {
    opacity: 1;
  }
}

/* ─── Open Editor CTA button ─── */
.btn-open-editor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 7px 16px;
  border-radius: var(--r-sm);
  gap: 6px;
  transition: background 0.15s var(--ease-out);
  box-sizing: border-box;
}
.btn-open-editor:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-open-editor:active:not(:disabled) {
  background: var(--accent-pressed);
}
.btn-open-editor svg {
  flex-shrink: 0;
}

/* Mobile nav overflow menu - unused; kept selectors inert if leftover DOM */
.wtab-more-wrap {
  display: none;
}

@media (max-width: 768px) {
  .project-header {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  .project-header-title {
    width: 100%;
    min-width: 0;
  }

  /* One tight row: tabs fill the strip, open-editor keeps its label */
  .project-header-bottom {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  .project-header-tabs {
    display: flex;
    flex: 1 1 0;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: stretch;
    gap: 0;
    width: auto;
    min-width: 0;
    padding: 3px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .project-header-tabs .wtab {
    flex: 1 1 0;
    width: auto;
    min-width: 0 !important;
    min-height: 0;
    height: auto;
    padding: 8px 4px;
    gap: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .project-header-tabs .wtab .wtab-icon,
  .project-header-tabs .wtab .ui-icon.wtab-icon {
    /* icon() sets inline display:inline-flex — need !important to win */
    display: none !important;
  }

  .btn-open-editor {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    min-height: 0;
    height: auto;
    padding: 0 8px;
    gap: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    align-self: stretch;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
  }

  .btn-open-editor-label {
    display: inline;
    line-height: 1;
  }

  .btn-open-editor svg {
    display: none;
  }
}

@media (max-width: 480px) {
  .project-header {
    padding-inline: var(--s-2);
  }

  .project-header-bottom {
    gap: 5px;
  }

  .project-header-tabs {
    padding: 2px;
  }

  .project-header-tabs .wtab {
    padding: 7px 2px;
  }

  .btn-open-editor {
    padding: 0 7px;
    font-size: 10.5px;
    gap: 0;
  }
}

/* ════════════════════════════════════════════════════════════════════════
   MOBILE EDITOR - app-grade touch ergonomics. Tool panels slide up as
   bottom sheets (CapCut/InShot style); all controls are finger-sized.
   Loaded last so it wins the cascade and overrides the smaller defaults.
   ════════════════════════════════════════════════════════════════════════ */
@keyframes sheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@media (hover: none), (max-width: 768px) {
  /* ── Every editor tool popover → a bottom sheet ──────────────────────── */
  .popover {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 22px 16px max(16px, env(safe-area-inset-bottom, 16px)) !important;
    gap: 16px !important;
    box-shadow: 0 -10px 44px rgba(0, 0, 0, 0.3) !important;
    animation: sheetUp 0.24s cubic-bezier(0.32, 0.72, 0, 1) !important;
    z-index: 1000 !important;
  }
  /* Grab handle so it reads as a draggable sheet */
  .popover::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong, #c7c7cc);
  }

  .popover.tb-checks-popover {
    top: var(--tb-checks-top, auto) !important;
    left: var(--tb-checks-left, auto) !important;
    right: auto !important;
    bottom: auto !important;
    width: min(188px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(70vh, 420px) !important;
    overflow-y: auto !important;
    border-radius: 12px !important;
    padding: 5px !important;
    gap: 2px !important;
    box-shadow: var(--shadow-lg, 0 12px 40px rgba(14, 28, 48, 0.18)) !important;
    animation: popIn 0.15s var(--ease-out) !important;
    z-index: 1000 !important;
  }
  .popover.tb-checks-popover::before {
    content: none !important;
    display: none !important;
  }
  /* Beat tools ride the shared sheet padding; only the gap stays tighter. */
  .popover.beatsync-popover {
    gap: 12px !important;
  }
  /* Match the pinned footer to the sheet's own padding. */
  .beatsync-popover .beatsync-footer {
    bottom: calc(-1 * max(16px, env(safe-area-inset-bottom, 16px)));
    margin: 0 -16px calc(-1 * max(16px, env(safe-area-inset-bottom, 16px)));
    padding: 10px 16px max(16px, env(safe-area-inset-bottom, 16px));
  }

  /* Finger-sized controls inside the sheets */
  .popover .slider,
  .popover input[type="range"] {
    height: 26px;
  }
  .popover .slider::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
  .popover .slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }
  .popover-actions {
    gap: 10px;
  }
  .popover-actions .btn,
  .popover .btn {
    min-height: 46px;
    font-size: 14px;
  }
  .speed-grid button,
  .tx-chip,
  .fit-grid button,
  .fx-grid button {
    min-height: 44px;
  }
  .slider-row {
    gap: 12px;
  }

  /* ── Option pickers (custom-select) → bottom sheets with big rows ──────── */
  .cselect-menu:not(.cselect-menu--planning) {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: 72vh !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 20px 10px max(14px, env(safe-area-inset-bottom, 14px)) !important;
    box-shadow: 0 -10px 44px rgba(0, 0, 0, 0.3) !important;
    animation: sheetUp 0.24s cubic-bezier(0.32, 0.72, 0, 1) !important;
    gap: 2px !important;
  }
  .cselect-menu:not(.cselect-menu--planning)::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong, #c7c7cc);
  }
  .cselect-option {
    min-height: 48px;
    font-size: 15px;
    padding: 11px 14px;
  }
  .cselect-option-hint {
    font-size: 12px;
  }

  /* Toolbar: 40px pills, 36px inner buttons (40 − 2×2px pad), 48px bar.
     min-height on buttons used to be 40px inside a 40px padded pill, so
     icons stuck out of the frames and the bar gained leftover empty space. */
  .timeline-tools-bar {
    --tb-h: 40px;
    --tb-btn-min-w: 36px;
    height: 48px;
    min-height: 48px;
    gap: 6px;
    padding: 4px 8px;
    align-items: center;
    box-sizing: border-box;
    overflow-y: hidden;
  }
  .timeline-tools-bar .tb-group {
    height: var(--tb-h, 40px);
    align-items: center;
  }
  .tb-segment,
  .tb-history,
  .tb-zoom {
    height: var(--tb-h, 40px);
    box-sizing: border-box;
  }
  .tb-segment,
  .tb-history {
    padding: 1px;
  }
  .tb-btn {
    width: var(--tb-btn-min-w, 36px);
    min-width: var(--tb-btn-min-w, 36px);
    height: var(--tb-h, 40px);
    min-height: 0;
    padding: 0;
    gap: 0;
  }
  .tb-segment .tb-btn {
    width: var(--tb-btn-min-w, 36px);
    min-width: var(--tb-btn-min-w, 36px);
    height: 100%;
    min-height: 0;
    padding: 0;
  }
  .tb-fit-all-btn,
  .tb-zoom .tb-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 0;
  }
  .tb-history-btn {
    width: 32px;
    height: 100%;
  }
  .tb-export,
  .timeline-tools-bar .tb-export {
    width: var(--tb-h, 40px);
    height: var(--tb-h, 40px);
    min-height: 0;
    padding: 0;
    flex: 0 0 var(--tb-h, 40px);
  }
  .timeline-tools-bar .tb-group:has(.tb-export) {
    flex: 0 0 auto;
    position: sticky;
    inset-inline-end: 0;
    z-index: 3;
    margin-inline-start: 4px;
    padding-inline-start: 8px;
    background: color-mix(in srgb, var(--surface, #fff) 82%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 8px 0 12px 2px color-mix(in srgb, var(--surface, #fff) 70%, transparent);
  }
  html:not([dir="rtl"]) .timeline-tools-bar .tb-group:has(.tb-export) {
    box-shadow: -8px 0 12px 2px color-mix(in srgb, var(--surface, #fff) 70%, transparent);
  }
  [data-theme="dark"] .timeline-tools-bar .tb-group:has(.tb-export) {
    background: color-mix(in srgb, #1c1f28 75%, transparent);
    box-shadow: 8px 0 12px 2px rgba(28, 31, 40, 0.7);
  }
  html:not([dir="rtl"])[data-theme="dark"]
    .timeline-tools-bar
    .tb-group:has(.tb-export) {
    box-shadow: -8px 0 12px 2px rgba(28, 31, 40, 0.7);
  }
  .preview-transport {
    height: 56px;
  }
  .tr-btn,
  .tr-fullscreen {
    width: 42px;
    height: 42px;
  }
  .tr-play {
    width: 58px;
    height: 42px;
  }
  .tr-scrub {
    height: 8px;
  }
  .tr-scrub-handle {
    width: 20px;
    height: 20px;
  }

  /* Slightly tighter shell gap to give the timeline a bit more room */
  .editor-shell {
    gap: 6px;
  }

  /* Native-app feel: kill the grey tap-flash and the long-press text/callout
     on controls and draggable surfaces. */
  button,
  a,
  .cselect-trigger,
  .cselect-option,
  .tb-btn,
  .tr-btn,
  .nav-item,
  .tl-clip,
  .tl-trim,
  .tl-audio-block,
  .wm-box,
  .preview-logo {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }
}

/* ============ Media loading / re-fetch state ============ */
/* Added by attachMediaFallback() on a thumb container while its <img>/<video>
   is being (re)fetched from the server. The class only appears after a short
   delay (instant cache hits never flash it). It renders the SAME glow-sweep
   skeleton as the files grid ("פס זוהר") - no "טוען…" text and no spinner - so
   every loading state across the app looks identical. .media-reloading is still
   set for a genuine re-fetch but is now visually the same sweep. */
.media-loading {
  position: relative;
}
/* UNIFIED loading look: identical to the skeleton/overlay shimmer (the files
   grid "פס זוהר"). No "טוען…" text, no spinner circle - just the sweeping glow
   band - so EVERY loading state across the app (initial skeleton AND
   attachMediaFallback's re-fetch) looks the same. The failed+loading combined
   selectors are included so a re-fetch always shows the sweep, never the error
   ribbon ("loading wins"). */
.media-loading::before,
.media-loading.media-load-failed::before,
.media-loading.media-reloading.media-load-failed::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  background-color: #e3e6ec;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: media-loading-shimmer 1s linear infinite;
}
/* No spinner - the glow sweep IS the whole indicator. */
.media-loading::after {
  content: none;
}
/* Terminal load failure (all retries exhausted). Replaces the old silent blank
   tile with a clear ribbon; hovering the tile re-arms a fresh retry round
   (see markFailed in attachMediaFallback). */
.media-load-failed {
  position: relative;
}
.media-load-failed::before {
  content: "לא נטען · עבור עם העכבר לניסיון חוזר";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 5;
  padding: 4px 6px;
  font-size: 10.5px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
@keyframes media-loading-shimmer {
  0% {
    background-position: 220% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

/* Skeleton shimmer for tiles whose media hasn't painted yet - the initial
   split-second (or longer, on a cold cache) between mounting the grid and the
   thumb arriving. Pure CSS via :has(): active while the tile's <img> has no
   src yet / its <video> has neither src nor poster, and vanishes the moment
   the media paints on top. No JS state, no cleanup.
   Also covers shot start/end frames, home project covers, sidebar + rail. */
.file-item-thumb:has(> img:not(.media-ready)):not(:has(> video)):not(
    .media-load-failed
  ),
.file-item-thumb:has(> video:not(.media-ready):not([poster])):not(
    .media-load-failed
  ),
.media-thumb--video:has(> video:not(.media-ready):not([poster])),
.frame-slot-image:has(> img:not(.media-ready)):not(.media-load-failed),
.project-thumb-bg:has(> img:not(.media-ready)):not(.media-load-failed),
.sidebar-project-thumb:has(> img:not(.media-ready)):not(.media-load-failed),
.sidebar-project-thumb:has(> video:not(.media-ready):not([poster])):not(
    .media-load-failed
  ),
.rail-thumb:has(> img:not(.media-ready)):not(.media-load-failed),
.workshop-shot-thumb:has(> img:not(.media-ready)):not(.media-load-failed),
.shots-overview-thumb:has(> img:not(.media-ready)):not(.media-load-failed),
.ov-thumb-media:has(> img:not(.media-ready)):not(.media-load-failed),
/* Style-tab character avatars. Round + overflow:hidden, so the sweep band is
   clipped to the circle. The missing-image state replaces the <img> with the
   re-add affordance, which ends the shimmer on its own. */
.elem-tile-img:has(> img:not(.media-ready)):not(.media-load-failed) {
  /* A clearly visible skeleton: mid-gray base with a bright sweeping band.
     The earlier white-on-near-white version was invisible in practice. */
  background-color: #e3e6ec;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: media-loading-shimmer 1s linear infinite;
}
/* While shimmering, hide the alt-text/name that browsers render inside a
   src-less / not-yet-painted <img> - the skeleton should be clean. */
.file-item-thumb > img:not([src]),
.file-item-thumb > img:not(.media-ready),
.frame-slot-image > img:not(.media-ready),
.project-thumb-bg > img:not(.media-ready),
.sidebar-project-thumb > img:not(.media-ready),
.rail-thumb > img:not(.media-ready),
.workshop-shot-thumb > img:not(.media-ready),
.shots-overview-thumb > img:not(.media-ready),
.ov-thumb-media > img:not(.media-ready),
.elem-tile-img > img:not(.media-ready) {
  visibility: hidden;
}

/* Video THUMBS (shots window "קטעים", rail, workshop list): the <video> element
   fills the tile and covers a parent-background shimmer, so paint it as an
   OVERLAY on top instead. Shows while the poster frame is still being fetched;
   removed the moment the poster is set (armLazyVideoPoster). */
.media-thumb--video,
.panel-video-thumb,
.ws-version-thumb,
.assign-picker-thumb {
  position: relative;
}
.media-thumb--video:has(> video:not(.media-ready):not([poster]))::after,
.panel-video-thumb:has(> video:not(.media-ready):not([poster]))::after,
.ws-version-thumb:has(> video:not(.media-ready):not([poster]))::after,
.assign-picker-thumb:has(> video:not(.media-ready):not([poster]))::after,
.ws-scrub-video-wrap:has(> video:not(.media-ready))::after,
.ws-frame-img-wrap:has(> img:not(.media-ready))::after,
.ws-gen-thumb:has(> img:not(.media-ready))::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  background-color: #e3e6ec;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 25%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(255, 255, 255, 0) 75%
  );
  background-size: 220% 100%;
  background-repeat: no-repeat;
  animation: media-loading-shimmer 1s linear infinite;
}

/* Hide unpainted media inside premium-edit frames while the light bar runs. */
.ws-frame-img-wrap > img:not(.media-ready),
.ws-gen-thumb > img:not(.media-ready),
.ws-scrub-video-wrap > video:not(.media-ready) {
  visibility: hidden;
}

/* Lightbox skeleton: the modal opens PRE-SIZED to the media's real aspect
   (openLightbox sets aspect-ratio/width from item metadata) and shimmers
   until the video/image actually paints - no tiny black box that jumps to
   size when playback starts. */
.lightbox .vplayer-wrap:has(video:not(.media-ready)),
.lightbox .lightbox-media-wrap:has(> img:not(.media-ready)) {
  min-height: 240px;
  background-color: #e3e6ec;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: media-loading-shimmer 1s linear infinite;
}
/* Modest placeholder until openLightbox (or image load) sets real dims.
   Sized to the viewport (not a tiny thumb), 16:9 until real aspect arrives. */
.lightbox .lightbox-media-wrap {
  width: min(calc(90vw - 48px), 920px, calc((85vh - 120px) * 16 / 9));
  aspect-ratio: 16 / 9;
  min-height: 0;
  max-width: 100%;
}
/* Same for video: before metadata/poster aspect is known, open at a real
   viewing size so the blurred poster isn't a postage stamp. */
.lightbox .vplayer-wrap.vplayer-fit {
  width: min(calc(90vw - 48px), 920px, calc((85vh - 120px) * 16 / 9));
  aspect-ratio: 16 / 9;
  min-height: 0;
}
/* Keep the player chrome (buttons/seek) unobtrusive over the skeleton. */
.lightbox .vplayer-wrap:has(video:not(.media-ready)) .vplayer-overlay {
  opacity: 0;
}
/* Blur-up: the grid thumb paints instantly (blurred, full box); the sharp
   original CROSS-FADES in over it, so the blur-to-sharp is always perceptible
   - even when the original is cached and would otherwise pop in instantly. */
.lightbox .lightbox-media-wrap {
  position: relative;
  overflow: hidden;
}
.lightbox .lightbox-media-wrap > img.lightbox-media {
  position: relative;
  z-index: 2; /* above the blurred preview */
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transition: opacity 0.32s ease;
}
.lightbox .lightbox-media-wrap > img.lightbox-media.media-ready {
  opacity: 1;
}
.lightbox .lightbox-thumb-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(14px) saturate(1.05);
  transform: scale(1.06);
  border-radius: inherit;
  z-index: 1; /* under the sharp image, which fades in on top */
  pointer-events: none;
  transition: opacity 0.32s ease;
}
.lightbox .lightbox-thumb-preview.is-fading {
  opacity: 0;
}
/* Video player: blurred poster fills the frame (over the black video) until
   the clip paints, then JS removes it. Match cover so a tiny poster isn't
   letterboxed inside the video-sized window. */
.lightbox .vplayer-wrap > .lightbox-thumb-preview {
  object-fit: cover;
  background: #000;
  z-index: 2;
}
/* Inside the lightbox the retry overlay's own spinner/label would double up
   with our clean veil - suppress it; the veil is the single source of truth. */
.lightbox .lightbox-media-wrap.media-loading::before,
.lightbox .lightbox-media-wrap.media-loading::after,
.lightbox .vplayer-wrap.media-loading::before,
.lightbox .vplayer-wrap.media-loading::after {
  content: none !important;
  background: none !important;
  animation: none !important;
}

/* ── Clean media loading veil (lightbox) ──────────────────────────────────
   A real element over the blurred placeholder: a visible diagonal light
   sweep + a centered "טוען…" pill. Removed the instant the media paints. */
.media-loading-veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.media-loading-veil.is-hiding {
  opacity: 0;
}
.media-loading-veil-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px 7px 12px;
  border-radius: 999px;
  background: rgba(18, 20, 26, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.media-loading-veil-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Android PWA install banner ─── */
.pwa-install-banner {
  position: fixed;
  z-index: 10050;
  inset-inline: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-xl, 18px);
  background: var(--surface, #fbfcfe);
  color: var(--text, #0a1628);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border, rgba(14, 28, 48, 0.1));
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
  max-width: 420px;
  margin-inline: auto;
  left: 12px;
  right: 12px;
  direction: rtl;
}
.pwa-install-banner.pwa-install-visible {
  opacity: 1;
  transform: translateY(0);
}
.pwa-install-banner.pwa-install-hiding {
  opacity: 0;
  transform: translateY(12px);
}
.pwa-install-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2, #eef2f7);
  display: block;
}
.pwa-install-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pwa-install-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-family: var(--font-ui, Outfit, Rubik, system-ui, sans-serif);
}
.pwa-install-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-3, #5a6b7d);
  font-family: var(--font-ui, Outfit, Rubik, system-ui, sans-serif);
}
.pwa-install-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  flex: 0 0 auto;
}
.pwa-install-cta,
.pwa-install-dismiss {
  border: none;
  cursor: pointer;
  font-family: var(--font-ui, Outfit, Rubik, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--r-sm, 8px);
  padding: 8px 14px;
  white-space: nowrap;
  text-align: center;
}
.pwa-install-cta {
  background: var(--accent, #0a6b76);
  color: #fff;
}
.pwa-install-cta:active {
  opacity: 0.88;
}
.pwa-install-dismiss {
  background: transparent;
  color: var(--text-3, #5a6b7d);
  padding: 6px 14px;
  font-weight: 500;
}

/* ============ Activity Center (pill + panel) ============ */
/* One fixed 44px pill in the toast corner replaces the stack of persistent
   AI/job chips; the panel opens upward on click. Floating toast() messages
   (errors etc.) get lifted above the pill via .ac-lift. */
.activity-center {
  position: fixed;
  /* --ac-bar-clear is measured by activity-center.js: the height of any bar
     pinned to the bottom edge right now (the planning footer goes full-width
     fixed on a phone). The pill rides above it instead of on its buttons, and
     drops back to 0 the moment the bar is gone. */
  bottom: calc(
    max(24px, env(safe-area-inset-bottom, 0px)) + var(--ac-bar-clear, 0px)
  );
  inset-inline-end: 24px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition: bottom 0.2s var(--ease-out, ease);
}
@media (prefers-reduced-motion: reduce) {
  .activity-center {
    transition: none;
  }
}
/* The panel matches toast z-index (1300) so it stays above the workspace,
   but that is above .modal-backdrop (1100). A button inside the panel
   that opens a dialog would then be covered by the panel. While any
   modal is up, drop under it. */
body:has(#modalBackdrop:not([hidden])) .activity-center {
  z-index: 1050;
}
.activity-center.ac-hidden {
  display: none;
}
/* A bottom SHEET owns the screen on a touch device - it is full width and up
   to 80vh tall, so there is nowhere for the pill to move to, and at z-index
   1300 over the sheet's 1000 it lands on the sheet's own content. Fold it away
   while one is open; it comes back on close, exactly like the modal rule
   above. Popovers are removed from the DOM when dismissed, so :has() is a
   reliable "one is open". */
@media (hover: none), (max-width: 768px) {
  body:has(.popover, .tx-popover) .activity-center {
    display: none;
  }
}
.toast-container.ac-lift {
  bottom: calc(
    max(24px, env(safe-area-inset-bottom, 0px)) + 62px + var(--ac-bar-clear, 0px)
  );
}

.ac-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-family: var(--font-ui, inherit);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease,
    border-color 0.2s ease;
}
.ac-pill:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.ac-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ac-pill.ac-compact {
  width: 44px;
  padding: 0;
  justify-content: center;
}
.ac-pill.ac-error {
  border-color: color-mix(in srgb, var(--red, #d64545) 55%, transparent);
  animation: acErrPulse 1.6s ease 1;
}
@keyframes acErrPulse {
  40% {
    box-shadow: 0 0 0 8px
      color-mix(in srgb, var(--red, #d64545) 20%, transparent);
  }
}
.ac-pill-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  vertical-align: 0;
  color: var(--accent, #0a6b76);
}
.ac-pill.ac-error .ac-pill-icon {
  color: var(--red, #d64545);
}
.ac-pill-icon svg {
  width: 100%;
  height: 100%;
}

.ac-spin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent, #0a6b76) 22%, transparent);
  border-top-color: var(--accent, #0a6b76);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.ac-badge {
  position: absolute;
  top: -5px;
  inset-inline-start: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--green, #1f9d63);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  box-shadow: 0 2px 6px
    color-mix(in srgb, var(--green, #1f9d63) 50%, transparent);
}
.ac-badge.ac-badge-err {
  background: var(--red, #d64545);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--red, #d64545) 50%, transparent);
}

.ac-panel {
  display: none;
  width: min(360px, calc(100vw - 32px));
  max-height: min(460px, 62vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  flex-direction: column;
}
.ac-panel.open {
  display: flex;
  animation: acPanelIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes acPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ac-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 5px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3, #5a6b7d);
}
.ac-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ac-clear {
  font-family: var(--font-ui, inherit);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3, #5a6b7d);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}
.ac-clear:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.ac-x {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3, #5a6b7d);
  cursor: pointer;
}
.ac-x:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.ac-x svg {
  width: 12px;
  height: 12px;
}

.ac-body {
  overflow-y: auto;
  padding: 2px 0 6px;
}
.ac-sect {
  padding: 7px 14px 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-3, #5a6b7d);
}
.ac-empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--text-3, #5a6b7d);
  font-size: 12.5px;
}

.ac-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
}
.ac-row.toast-clickable {
  cursor: pointer;
}
.ac-row.toast-clickable:hover {
  background: color-mix(in srgb, var(--accent, #0a6b76) 6%, transparent);
}
.ac-row-main {
  flex: 1;
  min-width: 0;
}
.ac-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.ac-title-row .ac-row-title {
  flex: 1;
  min-width: 0;
}
.ac-pct {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent, #0a6b76);
}
.ac-pbar {
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent, #0a6b76) 14%, transparent);
  margin-top: 6px;
  overflow: hidden;
}
.ac-pbar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent, #0a6b76), #12a3b0);
}
.ac-remain {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.ac-action {
  flex-shrink: 0;
  font-family: var(--font-ui, inherit);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #0a6b76);
  background: color-mix(in srgb, var(--accent, #0a6b76) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #0a6b76) 28%, transparent);
  border-radius: 8px;
  padding: 4px 10px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.ac-action:hover {
  background: color-mix(in srgb, var(--accent, #0a6b76) 16%, transparent);
}
.ac-row.ac-error .ac-action,
.ac-row.ac-warning .ac-action {
  color: var(--red, #d64545);
  background: color-mix(in srgb, var(--red, #d64545) 8%, transparent);
  border-color: color-mix(in srgb, var(--red, #d64545) 28%, transparent);
}
.ac-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  /* Long AI progress messages: cap at two lines instead of one-line clipping */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ac-row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-3, #5a6b7d);
  min-width: 0;
}
.ac-row-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-elapsed,
.ac-ago {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.ac-stop {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3, #5a6b7d);
  cursor: pointer;
  flex-shrink: 0;
}
.ac-stop:hover {
  border-color: var(--red, #d64545);
  color: var(--red, #d64545);
}
.ac-stop svg {
  width: 12px;
  height: 12px;
}
.ac-dismiss {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3, #5a6b7d);
  cursor: pointer;
  flex-shrink: 0;
}
.ac-dismiss:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.ac-dismiss svg {
  width: 12px;
  height: 12px;
}

.ac-thumb {
  width: 46px;
  height: 30px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: color-mix(in srgb, var(--text, #0a1628) 7%, transparent);
}
.ac-thumb img,
.ac-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ac-spin.ac-spin-sm {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.ac-dot {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  color: #fff;
  overflow: hidden;
  line-height: 0;
}
.ac-dot .ui-icon {
  width: 11px;
  height: 11px;
  font-size: 11px;
  vertical-align: 0;
  display: grid;
  place-items: center;
}
.ac-dot svg {
  width: 100%;
  height: 100%;
  display: block;
}
.ac-dot-success {
  background: var(--green, #1f9d63);
}
.ac-dot-error {
  background: var(--red, #d64545);
}
.ac-dot-warning {
  background: var(--ember, #e86d2f);
}
.ac-dot-info {
  background: color-mix(in srgb, var(--accent, #0a6b76) 75%, transparent);
}
.ac-dot-i {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-ui, inherit);
  line-height: 1;
  color: #fff;
}
.ac-dot-bang {
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-ui, inherit);
  line-height: 1;
  color: #fff;
}
.ac-row.ac-row-note .ac-dot-i,
.ac-row.ac-row-note .ac-dot-bang {
  font-size: 10px;
}
/* Routine confirmations: align the badge with the title line, not the
   title+time block, and size the inner glyph to the circle (not 1em). */
.ac-row.ac-row-note {
  padding-block: 6px;
  align-items: flex-start;
}
.ac-row.ac-row-note .ac-row-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--text-2, #33475c);
  -webkit-line-clamp: 1;
}
.ac-row.ac-row-note .ac-dot {
  width: 16px;
  height: 16px;
}
.ac-row.ac-row-note .ac-dot .ui-icon {
  width: 11px;
  height: 11px;
  font-size: 11px;
}

.ac-row.ac-error,
.ac-row.ac-warning {
  background: color-mix(in srgb, var(--red, #d64545) 6%, transparent);
  border-block: 1px solid
    color-mix(in srgb, var(--red, #d64545) 16%, transparent);
}
.ac-row.ac-warning {
  background: color-mix(in srgb, var(--ember, #e86d2f) 7%, transparent);
  border-block: 1px solid
    color-mix(in srgb, var(--ember, #e86d2f) 18%, transparent);
}

@media (max-width: 720px) {
  .activity-center {
    inset-inline-end: 16px;
  }
  .toast-container.ac-lift {
    bottom: calc(
      max(var(--s-4), env(safe-area-inset-bottom, var(--s-4))) + 60px +
        var(--ac-bar-clear, 0px)
    );
  }
}

/* --- AI generations keep the branded toastAI look inside the center --- */
/* Pill: animated brand logo + the same spinning teal→ember shimmer ring. */
.ac-pill.ac-ai {
  border-color: transparent;
  isolation: isolate;
  background-image: linear-gradient(
    135deg,
    color-mix(in srgb, var(--surface) 90%, var(--accent, #0a6b76)) 0%,
    var(--surface) 48%,
    color-mix(in srgb, var(--surface) 94%, var(--ember, #e86d2f)) 100%
  );
}
.ac-pill.ac-ai > * {
  position: relative;
  z-index: 1;
}
/* The ring must sit exactly where the (transparent) 1px border is - inset -1px
   reaches the border box edge, padding 1px keeps the ring hairline-thin. */
.ac-pill.ac-ai::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  --ai-shimmer: 0deg;
  background: conic-gradient(
    from var(--ai-shimmer),
    #12a3b0 0deg 240deg,
    #7ec8d0 265deg,
    #eef6f7 278deg,
    #0a6b76 292deg,
    #e86d2f 308deg,
    #12a3b0 325deg 360deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  animation: aiToastBorderFlow 2.8s linear infinite;
}
.ac-pill .toast-ai-brand {
  width: 30px;
  height: 30px;
  margin-inline-start: -4px;
}
.ac-pill .toast-ai-logo,
.ac-pill .toast-ai-brand--loop .toast-ai-logo {
  width: 26px;
  height: 26px;
}

/* Panel rows: AI jobs keep the animated logo, small and without a tint -
   several parallel generations must not turn the list into a light show. */
.ac-row-ai .toast-ai-brand {
  width: 26px;
  height: 26px;
}
.ac-row-ai .toast-ai-logo,
.ac-row-ai .toast-ai-brand--loop .toast-ai-logo {
  width: 24px;
  height: 24px;
}

/* Long-press on a shot in the rail: a tiny delete / archive tip. */
.rail-shot-tip {
  position: fixed;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px color-mix(in srgb, #000 16%, transparent);
  animation: railShotTipIn 0.12s ease-out;
}

.rail-shot-tip-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  margin: 0;
  padding: 0 7px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: 600 10px/1 inherit;
  white-space: nowrap;
  cursor: pointer;
}

.rail-shot-tip-btn--danger {
  color: var(--danger, #c62828);
}

.rail-shot-tip-btn .ui-icon,
.rail-shot-tip-btn .ui-icon svg {
  width: 11px;
  height: 11px;
}

.rail-item.is-rail-tip-anchor {
  background: var(--accent-soft);
}

@keyframes railShotTipIn {
  from {
    opacity: 0;
    transform: translateY(3px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail-shot-tip {
    animation: none;
  }
  .ac-spin {
    animation-duration: 1.6s;
  }
  .ac-pill.ac-error {
    animation: none;
  }
  .ac-panel.open {
    animation: none;
  }
  .ac-pill.ac-ai::before {
    animation: none;
    --ai-shimmer: 280deg;
  }
}
