/* Create studios in the Agent OS: image and video clips (#/create/image,
   #/create/video) and produced films / design projects (#/create/film,
   #/create/refine). Uses os.css tokens only. Every control is at least 44 px
   tall so it works under a thumb at 390 px. */

/* ---- shared form parts ------------------------------------------------------------------ */
.cr .btn, .cr .btn-sm { min-height: 44px; }
.cr .btn-sm { padding: 0 16px; }
.cr input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .cr select, .cr textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font-size: 16px; line-height: 1.45;
}
.cr textarea { resize: vertical; }
.cr input[type="file"] { width: 100%; min-height: 44px; padding: 8px 0; font-size: 14px; color: var(--soft); }
.cr input[type="file"]::file-selector-button { min-height: 36px; margin-right: 10px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.cr input:focus-visible, .cr select:focus-visible, .cr textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.cr select:disabled, .cr input:disabled { opacity: .55; }
.cr-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cr-field > label { font-weight: 600; font-size: 14px; }
.cr-form { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; min-width: 0; }
.cr-form > .btn { align-self: flex-start; }
.cr-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; font-size: 14px; color: var(--soft); cursor: pointer; }
.cr-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--violet); }
.cr-details > summary, .cf-fal-summary { list-style: none; }
.cr-details > summary::-webkit-details-marker, .cf-fal-summary::-webkit-details-marker { display: none; }
.cr-details > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; color: var(--soft); font-weight: 600; font-size: 14px; }
.cr-details > summary::before, .cf-fal-summary::before { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--cyan); border-bottom: 2px solid var(--cyan); transform: rotate(-45deg); transition: transform .15s; }
.cr-details[open] > summary::before, .cf-fal[open] > .cf-fal-summary::before { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .cr-details > summary::before, .cf-fal-summary::before { transition: none; } }
.cr-details > summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }
.cr-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-width: 0; }
.cr-step { display: flex; align-items: center; gap: 10px; margin: 0; font: 600 16px var(--font); }
.cr-step label { cursor: pointer; }
.cr-go-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cr-why { margin: 0; flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.cr-switch { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 16px; }
.cr-switch .chip { min-height: 44px; padding: 0 16px; font-size: 14px; }
.cr-switch .chip[aria-current="page"] { background: rgba(155, 107, 255, .16); border-color: rgba(155, 107, 255, .5); color: var(--text); }
.cr .chip:focus-visible, .cr .btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---- image and video studio ----------------------------------------------------------- */
.cm-health { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.cm-stage { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2); font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.cm-stage.is-ok { color: var(--green); border-color: rgba(61, 255, 168, .4); }
.cm-stage.is-bad { color: var(--muted); }
.cm-stage-why { flex-basis: 100%; color: var(--amber); }
.cm-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 8px; }
.cm-setting { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-setting label { font-size: 13px; color: var(--soft); }
.cm-setting-wide { grid-column: 1 / -1; }
.cm-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cm-gallery > .empty, .cm-gallery > .ds-alert { grid-column: 1 / -1; }
.cm-job { display: flex; flex-direction: column; min-width: 0; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.cm-preview { aspect-ratio: 1 / 1; display: grid; place-items: center; background: repeating-conic-gradient(#1b2140 0 25%, #151a33 0 50%) 0 0 / 16px 16px; }
.cm-preview-video { aspect-ratio: 16 / 9; background: #05060c; }
.cm-preview:has(.cm-placeholder) { aspect-ratio: 16 / 7; }
.cm-preview img, .cm-preview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cm-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; background: var(--bg-2); color: var(--muted); font-size: 14px; text-align: center; }
.cm-placeholder .bar { width: 60%; }
.cm-placeholder.is-failed { color: #ffb3c1; }
.cm-job-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; min-width: 0; }
.cm-job-body p { margin: 0; overflow-wrap: anywhere; }
.cm-job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cm-job-prompt { font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cm-hash { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-pill-bad { color: var(--red); border-color: rgba(255, 92, 122, .5); }
.cm-job .row-actions { margin-top: 4px; }

/* ---- productions: index ---------------------------------------------------------------- */
.cf-strip { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.cf-strip-step { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.cf-strip-step .step-num { flex: none; }
.cf-strip-step span { min-width: 0; overflow-wrap: anywhere; }
.cf-index { margin-top: 16px; }
.cf-projects { min-width: 0; }
.cf-project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cf-project { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; border-radius: 12px; color: var(--text); min-width: 0; }
.cf-project:hover { background: rgba(155, 107, 255, .08); color: var(--text); }
.cf-project:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.cf-project-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: rgba(62, 230, 255, .1); color: var(--cyan); }
.cf-fal { margin-top: 18px; }
.cf-fal-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: center; min-height: 44px; cursor: pointer; }
.cf-fal-summary::before { grid-row: span 2; }
.cf-fal-summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }
.cf-h3 { margin: 10px 0 0; font: 600 15px var(--display); }
.cf-fal-search { display: flex; gap: 8px; }
.cf-fal-search input { flex: 1; }
.cf-fal-models { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.cf-fal-model, .cf-fal-job { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.cf-fal-model p { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cf-fal-model .btn { align-self: flex-start; margin-top: auto; }
.cf-endpoint { overflow-wrap: anywhere; }
.cf-fal-jobs { display: flex; flex-direction: column; gap: 8px; }
.cf-fal-job { flex-direction: row; align-items: center; flex-wrap: wrap; }
.cf-fal-job > .grow { flex: 1 1 220px; }
.cf-json { max-height: 60dvh; overflow: auto; }

/* ---- productions: one project --------------------------------------------------------- */
.cf-back { min-height: 44px; margin-bottom: 12px; padding: 0 14px; }
.cf .page-head h1 { overflow-wrap: anywhere; }
.cf-meta { margin: 4px 0 0; }
.cf-status { margin: -8px 0 12px; color: var(--soft); min-height: 1em; overflow-wrap: anywhere; }
.cf-status.error { color: var(--red); }
.cf-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; padding: 14px 16px; border-radius: var(--r); background: rgba(255, 194, 77, .07); border: 1px solid rgba(255, 194, 77, .5); box-shadow: var(--glow-amber); }
.cf-banner-text { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cf-banner-text b { color: var(--amber); }
.cf-tabs { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 -2px 16px; padding: 2px; border-bottom: 1px solid var(--line); }
.cf-tabs::-webkit-scrollbar { display: none; }
.cf-tab { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.cf-tab:hover { color: var(--text); }
.cf-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--cyan); }
.cf-tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; border-radius: 8px; }
.cf-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cf-panel:focus-visible { outline: none; }
.cf-run-state { margin: 0; font-weight: 600; }
.cf-log { max-height: 12em; }
.cf-thread { display: flex; flex-direction: column; gap: 10px; max-height: 58dvh; overflow-y: auto; padding: 4px 2px; min-width: 0; }
.cf-thread:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cf-older { align-self: center; }
.cf-turn { display: flex; flex-direction: column; gap: 4px; max-width: 86%; padding: 10px 14px; border-radius: 14px; min-width: 0; }
.cf-turn p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.cf-turn-me { align-self: flex-end; background: rgba(155, 107, 255, .16); border: 1px solid rgba(155, 107, 255, .35); }
.cf-turn-them { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.cf-empty { margin: 0; padding: 16px; text-align: center; }
.cf-composer { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line-2); }
.cf-composer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cf-composer-row .cr-why { flex: 1 1 160px; }
.cf-stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cf-stage { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.cf-stage.is-done .ds-step-mark { background: rgba(61, 255, 168, .14); border-color: rgba(61, 255, 168, .5); color: var(--green); }
.cf-stage.is-active { border-color: rgba(62, 230, 255, .45); }
.cf-stage.is-active .ds-step-mark { border-color: var(--cyan); color: var(--cyan); }
.cf-stage.is-waiting { border-color: rgba(255, 194, 77, .55); background: rgba(255, 194, 77, .06); }
.cf-refs, .cf-files, .cf-linked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cf-ref { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cf-ref img, .cf-ref video { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.cf-ref audio { width: 180px; flex: none; }
.cf-file { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.cf-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.cf-file-row > .grow { flex: 1 1 180px; }
.cf-file-media img, .cf-file-media video { display: block; width: 100%; max-height: 60dvh; object-fit: contain; border-radius: 8px; background: #05060c; }
.cf-file-media audio, .cf-sample audio { display: block; width: 100%; }
.cf-linked li { display: flex; flex-direction: column; gap: 2px; }
.cf-linked a { display: inline-flex; align-items: center; min-height: 44px; }
.cf-review { display: flex; flex-direction: column; gap: 14px; }
.cf-samples { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cf-sample { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.cf-sample p { margin: 0; }
.cf-sample video { display: block; width: 100%; max-height: 68dvh; border-radius: 8px; background: #05060c; object-fit: contain; }
.cf-script { display: flex; flex-direction: column; gap: 10px; }
.cf-line { padding: 6px 14px; border-left: 3px solid var(--gold); }
.cf-line p { margin: 4px 0 0; color: var(--soft); }

/* ---- guided image studio ---------------------------------------------------------------- */
.is { display: flex; flex-direction: column; gap: 14px; min-width: 0; margin-bottom: 18px; }
.is-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.is-label { font-weight: 600; font-size: 14px; }
.is-assets, .is-export-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.is-ops { display: flex; flex-direction: column; gap: 2px; }
.is-op span { min-width: 0; overflow-wrap: anywhere; }
.is-limits { margin: 0; }
.is-plan-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid rgba(62, 230, 255, .35); }
.is-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.is-dl dt { color: var(--muted); }
.is-dl dd { margin: 0; overflow-wrap: anywhere; }
.is-runs { display: flex; flex-direction: column; gap: 10px; }
.is-run { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.is-run p { margin: 0; overflow-wrap: anywhere; }
.is-run > .btn { align-self: flex-start; }
.is-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.is-version { display: flex; flex-direction: column; min-width: 0; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.is-version.is-selected { border-color: rgba(61, 255, 168, .6); box-shadow: 0 0 0 1px rgba(61, 255, 168, .35); }
.is-version.is-rejected { opacity: .62; }

/* ---- film production -------------------------------------------------------------------- */
.fp { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.fp .btn, .is .btn { white-space: normal; text-align: center; max-width: 100%; }
.fp-status { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line-2); }
.fp-status b { font: 600 17px var(--display); overflow-wrap: anywhere; }
.fp-status.is-finished { border-color: rgba(61, 255, 168, .55); }
.fp-stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fp-stage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.fp-stage > .grow { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.fp-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fp-shots { display: flex; flex-direction: column; gap: 12px; }
.fp-shot { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.fp-shot-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fp-shot-head > .grow { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.fp-takes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fp-take { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); min-width: 0; }
.fp-take.is-accepted { border-color: rgba(61, 255, 168, .55); }
.fp-take.is-rejected { opacity: .62; }
.fp-take video, .fp-film video { display: block; width: 100%; max-height: 60dvh; border-radius: 8px; background: #05060c; object-fit: contain; }
.fp-take p, .fp-shot p { margin: 0; overflow-wrap: anywhere; }
.fp-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fp-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; min-width: 0; }
.fp-check > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.fp-film { display: flex; flex-direction: column; gap: 10px; }

/* ---- tablet and phone ------------------------------------------------------------------ */
@media (max-width: 1180px) {
  .cf-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .cm-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm-gallery, .cf-samples, .cf-fal-models { grid-template-columns: minmax(0, 1fr); }
  .cr-go-row .cr-go { width: 100%; }
  .cf-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cf-strip-step { padding: 10px; }
  .cf-turn { max-width: 94%; }
  .cf .page-head > .grow { flex: 1 1 100%; }
  .cf-thread { max-height: none; }
  .cf-banner .row-actions { width: 100%; }
  .cf-banner .row-actions .btn { flex: 1 1 auto; }
  .cf-composer-row .btn-primary { flex: 1 1 100%; }
  .cf-fal-search { flex-wrap: wrap; }
  .cf-fal-search .btn { flex: 1 1 100%; }
  .cr-form > .btn { align-self: stretch; }
  .is-grid { grid-template-columns: minmax(0, 1fr); }
  .is-dl { grid-template-columns: minmax(0, 1fr); }
  .is-dl dt { margin-top: 6px; }
  .fp-two { grid-template-columns: minmax(0, 1fr); }
}
