/* Story-first shot workspace: compact on desktop, comfortable on mobile. */
.story-first-panel{margin-top:16px}
.story-first-panel .story-first-intro{color:var(--text-muted,#a5a7b4);max-width:70ch}
.story-first-create{display:grid;gap:12px}
.story-first-saved-row{display:flex;gap:10px;align-items:end;flex-wrap:wrap;margin:14px 0}
.story-first-saved-row label{flex:1 1 260px}
.story-first-saved-row select{width:100%;max-width:580px}
.story-first-saved-hint{margin:4px 0 8px}
.story-first-workspace{margin-top:12px}
.story-first-edit-header{display:grid;grid-template-columns:1fr 2fr;gap:10px;margin:12px 0}
.story-first-field{display:flex;flex-direction:column;gap:5px;margin:9px 0;min-width:0}
.story-first-field>span{font-size:.88rem;font-weight:600}
.story-first-field textarea,.story-first-field input,.story-first-field select{width:100%;box-sizing:border-box;max-width:100%;border:1px solid var(--border-color,#77808b);border-radius:8px;background:var(--surface,#1e2329);color:var(--text-color,#eee);padding:9px 10px;font:inherit;line-height:1.4}
.story-first-field textarea{resize:vertical}
.story-first-progress{font-weight:650;margin:14px 0}
.story-first-shot-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,330px),1fr));gap:12px}
.story-first-shot{padding:12px;border:1px solid var(--border-color,#616674);border-radius:12px;min-width:0;background:var(--card-bg,transparent)}
.story-first-shot-head{display:flex;justify-content:space-between;gap:10px;align-items:center}
.story-first-shot-head span{font-variant-numeric:tabular-nums;font-size:.84rem;opacity:.8}
.story-first-shot .story-first-shot-detail{border-top:1px solid var(--border-color,#777);margin-top:10px;padding-top:8px}
.story-first-shot-detail>button{margin:7px 0 3px;white-space:normal;text-align:center}
.story-first-preview{display:inline-block;margin:8px 0;color:inherit;text-decoration:underline}
.story-first-generated-preview{display:block;max-width:230px;width:100%;aspect-ratio:9/16;object-fit:cover;margin:9px 0;border-radius:8px}
.story-first-actions{display:flex;gap:10px;flex-wrap:wrap;margin:14px 0}
#storyFirstPanel .story-first-save-bar{position:sticky;bottom:calc(var(--studio-footer-height, 68px) + 8px);z-index:6;background:#fff;padding:8px 0 4px}
#storyFirstSaveStatus{flex:1 0 100%;margin:0}
@media(max-width:640px){.story-first-edit-header{grid-template-columns:1fr}.story-first-shot-list{grid-template-columns:minmax(0,1fr)}.story-first-shot{padding:10px}.story-first-saved-row>button,.story-first-actions>button{width:100%}}

.story-first-scene-status{display:inline-block;margin:8px 0;padding:4px 8px;border-radius:6px;border:1px solid var(--border-color,#777);font-weight:650;font-size:.85rem}
.story-first-asset{display:flex;gap:10px;align-items:flex-start;border:1px solid var(--border-color,#777);padding:8px;margin:8px 0;border-radius:9px;min-width:0}
.story-first-asset-preview{width:94px;max-width:32%;height:116px;object-fit:cover;border-radius:6px;flex:0 0 auto}
.story-first-asset>div{flex:1;min-width:0;overflow-wrap:anywhere}
.story-first-asset-detail button,.story-first-asset button{display:block;margin-top:7px;white-space:normal}
.story-first-upload-label{display:inline-flex;align-items:center;cursor:pointer;position:relative;margin-top:8px}
.story-first-upload-progress{font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.story-first-browse-results{max-height:440px;overflow:auto;overscroll-behavior:contain;margin-top:10px}
.story-first-override{display:flex;gap:9px;align-items:flex-start;margin:9px 0}
.story-first-actions>button[hidden]{display:none}
@media(max-width:640px){.story-first-asset{flex-direction:column}.story-first-asset-preview{max-width:100%;width:100%;height:auto;max-height:260px;object-fit:contain}.story-first-shot-detail>button,.story-first-shot-detail>.story-first-upload-label,.story-first-asset button{width:100%;box-sizing:border-box}}

/* Scene-level upload, review, and library candidate UX. Keep interactive previews usable on iPhone. */
.story-first-status{font-size:.85rem;font-weight:650;margin:8px 0;color:var(--text-muted,#9aaac0)}
.story-first-shot-detail{display:flex;flex-direction:column;align-items:stretch;gap:8px}
.story-first-shot-detail>button{min-height:42px;white-space:normal;word-break:normal}
.story-first-asset-heading{font-size:.95rem;font-weight:700;margin:8px 0 4px}
.story-first-library-results,.story-first-browse,.story-first-browse-results{display:grid;gap:10px;min-width:0}
.story-first-candidate{display:grid;grid-template-columns:minmax(96px,120px) minmax(0,1fr);gap:12px;
  border:1px solid var(--border-color,#777);border-radius:10px;padding:9px;min-width:0}
.story-first-candidate-img{width:100%;max-width:180px;aspect-ratio:9/12;object-fit:cover;border-radius:7px;
  background:var(--surface,#1e2329)}
.story-first-candidate-desc{display:flex;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;overflow-wrap:anywhere}
.story-first-candidate-desc>small{font-size:.82rem;opacity:.85}
.story-first-candidate-desc button{min-height:38px}
.story-first-selected{padding:10px;border:1px solid var(--border-color,#777);border-radius:9px;margin:9px 0}
.story-first-selected .story-first-candidate-img{width:min(100%,210px)}
.story-first-upload-progress{font-size:.86rem;font-weight:600;margin:5px 0}
.story-first-actions>button{min-height:44px}
@media(max-width:640px){
  .story-first-candidate{grid-template-columns:minmax(90px,33%) minmax(0,1fr);gap:9px}
  .story-first-candidate-desc{font-size:.9rem}
  .story-first-candidate-desc>button{width:100%}
  .story-first-shot-detail>button{width:100%}
}


/* -----------------------------------------------------------------------
   Script a Short · scene cards v2
   All selectors are rooted in #storyFirstPanel so other Idea generators,
   Production, Asset Manager and platform workflows retain their styling.
   ----------------------------------------------------------------------- */
#storyFirstPanel {
  --scene-ink: #112a4a;
  --scene-muted: #51647d;
  --scene-line: #dce6f2;
  --scene-blue: #0755af;
  --scene-blue-light: #e9f2ff;
  --scene-green-light: #e7f8ed;
  scroll-margin-top: 112px;
  padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
}
#storyFirstPanel .story-first-shot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 20px;
  width: 100%;
  min-width: 0;
  margin-top: 16px;
}
#storyFirstPanel .story-first-shot {
  box-sizing: border-box;
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  padding: 16px;
  color: var(--scene-ink);
  background: #fff;
  border: 1px solid #d4e0f0;
  border-radius: 22px;
  box-shadow: 0 7px 20px rgba(22, 52, 88, .10), 0 2px 6px rgba(22, 52, 88, .045);
  isolation: isolate;
}
#storyFirstPanel details.story-first-shot:not([open]) > :not(summary) {
  display: none !important;
}
#storyFirstPanel .story-first-shot-hero {
  display: grid;
  grid-template-columns: minmax(118px, 35%) minmax(0, 1fr) 34px;
  cursor: pointer;
  list-style: none;
  align-items: center;
  gap: 18px;
  padding: 14px;
  min-width: 0;
  min-height: 130px;
  border-radius: 16px;
  background: linear-gradient(120deg, #f2f7ff, #eaf3ff 62%, #dcecff);
}
#storyFirstPanel .story-first-shot-hero::-webkit-details-marker {display: none}
#storyFirstPanel .story-first-shot-hero::marker {content: ""}
#storyFirstPanel .story-first-shot-hero:hover {background: linear-gradient(120deg, #eaf4ff, #e2efff 62%, #d5e8ff)}
#storyFirstPanel .story-first-shot-caret {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #114c88;
  background: #fff;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  transition: transform .15s ease;
}
#storyFirstPanel details.story-first-shot[open] .story-first-shot-caret {transform: rotate(180deg)}
#storyFirstPanel .story-first-shot-thumbnail {
  position: relative;
  min-width: 0;
  height: 114px;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(130deg, #173763, #427bb2 58%, #9ec6e5);
}
#storyFirstPanel .story-first-shot-thumbnail--empty {
  background:
    linear-gradient(150deg, rgba(4,26,59,.1), rgba(4,26,59,.15)),
    linear-gradient(135deg, #214a80, #5984af 60%, #d3e5f5);
}
#storyFirstPanel .story-first-shot-thumbnail--empty::before {
  content: "▧";
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0 0 15px;
  color: rgba(255,255,255,.72);
  font-size: 38px;
  line-height: 1;
}
#storyFirstPanel .story-first-shot-thumbnail-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#storyFirstPanel .story-first-thumbnail-note {
  position: absolute;
  inset: auto 0 0;
  padding: 16px 7px 6px;
  color: #fff;
  background: linear-gradient(transparent, rgba(1,20,45,.82));
  font-size: .65rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  letter-spacing: .01em;
}
#storyFirstPanel .story-first-shot-hero-copy {min-width: 0}
#storyFirstPanel .story-first-shot-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 12px;
}
#storyFirstPanel .story-first-shot-title {
  margin: 0;
  color: #092448;
  font-size: clamp(1.25rem, 1.55vw, 1.7rem);
  font-weight: 800;
  line-height: 1.15;
}
#storyFirstPanel .story-first-time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 2px 12px;
  border-radius: 999px;
  white-space: nowrap;
  color: #0d467c;
  background: #c9e3ff;
  font-size: .92rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
#storyFirstPanel .story-first-time-pill::before {
  content: "◷";
  margin-right: 7px;
  font-size: 1.15rem;
  line-height: 1;
}
#storyFirstPanel .story-first-status-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 7px;
  min-height: 30px;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: normal;
  color: #294a70;
  background: #e6edf6;
  font-size: .83rem;
  font-weight: 750;
  line-height: 1.25;
}
#storyFirstPanel .story-first-status-chip::before {
  content: "•";
  font-size: 1.2em;
}
#storyFirstPanel .story-first-status-chip.is-candidates {
  color: #17613a;
  background: #dff5e8;
}
#storyFirstPanel .story-first-status-chip.is-ready {
  color: #135a35;
  background: #cbf2d8;
}
#storyFirstPanel .story-first-status-chip.is-ready::before {content: "✓"}
#storyFirstPanel .story-first-status-chip.is-review,
#storyFirstPanel .story-first-status-chip.is-uploading {
  color: #755114;
  background: #fff0cd;
}
/* The screenshot's label/textarea collisions came from inherited form rules.
   Make direct scene fields three explicit grid tracks and refuse intrinsic
   min-width growth, including on tablet portrait. */
#storyFirstPanel .story-first-shot > .story-first-scene-field {
  box-sizing: border-box;
  display: grid !important;
  grid-template-columns: 25px minmax(120px, .86fr) minmax(0, 1.35fr);
  align-items: center;
  column-gap: 13px;
  row-gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 14px 4px;
  border-bottom: 1px solid var(--scene-line);
  background: transparent;
}
#storyFirstPanel .story-first-shot > .story-first-scene-field:first-of-type {
  margin-top: 6px;
}
#storyFirstPanel .story-first-scene-field > .story-first-field-icon {
  display: block;
  width: 23px;
  height: 23px;
  color: #164f8b;
}
#storyFirstPanel .story-first-shot .story-first-scene-field > span {
  display: block;
  margin: 0;
  min-width: 0;
  color: var(--scene-ink);
  font-size: .94rem;
  line-height: 1.32;
  font-weight: 750;
  overflow-wrap: anywhere;
}
#storyFirstPanel .story-first-scene-field .story-first-field-hint {
  display: block;
  margin-top: 4px;
  color: var(--scene-muted);
  font-size: .75rem;
  line-height: 1.3;
  font-weight: 450;
}
#storyFirstPanel .story-first-shot .story-first-field :is(input, select, textarea),
#storyFirstPanel .story-first-shot > .story-first-scene-field > :is(input, select, textarea) {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0;
  padding: 10px 12px;
  color: #142d4d;
  background: #fbfdff;
  border: 1px solid #b9cce3;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(14,43,75,.05);
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: normal;
}
#storyFirstPanel .story-first-shot > .story-first-scene-field > input,
#storyFirstPanel .story-first-shot > .story-first-scene-field > select {
  height: 45px;
}
#storyFirstPanel .story-first-shot > .story-first-scene-field > textarea {
  min-height: 88px;
  resize: vertical;
  overflow-y: auto;
}
#storyFirstPanel .story-first-shot :is(input, select, textarea):focus-visible,
#storyFirstPanel .story-first-shot button:focus-visible,
#storyFirstPanel .story-first-shot-hero:focus-visible {
  outline: 3px solid #5ca9f7;
  outline-offset: 2px;
  border-color: #216eb9;
}
#storyFirstPanel .story-first-selected {
  margin: 12px 0 0;
  padding: 12px;
  background: #f0fbf4;
  border-color: #b6e6c6;
  border-radius: 12px;
}
#storyFirstPanel .story-first-shot-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin-top: 14px;
  padding: 0;
  border: 0;
}
#storyFirstPanel .story-first-shot-detail > :not(button) {
  grid-column: 1 / -1;
  min-width: 0;
}
#storyFirstPanel .story-first-shot-detail > button,
#storyFirstPanel .story-first-candidate-desc button {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 9px 12px;
  white-space: normal;
  overflow-wrap: anywhere;
  border-radius: 10px;
  font-size: .84rem;
  font-weight: 700;
}
#storyFirstPanel .story-first-shot-detail > button.primary-button {
  background: #0756ac;
  color: #fff;
}
#storyFirstPanel .story-first-library-results {
  box-sizing: border-box;
  display: grid;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 14px;
  margin: 2px 0;
  border: 1px solid #d5eee2;
  border-radius: 14px;
  background: linear-gradient(115deg,#f0faf4,#f6fcf8);
}
#storyFirstPanel .story-first-library-results .story-first-asset-heading {
  margin: 0 0 2px;
  color: #1a4a34;
  font-size: .92rem;
}
#storyFirstPanel .story-first-shot .subtle {
  color: #50647e;
  overflow-wrap: anywhere;
}
#storyFirstPanel .story-first-candidate {
  align-items: center;
  grid-template-columns: minmax(90px, 115px) minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid #d7e3ee;
  border-radius: 12px;
  background: #fff;
}
#storyFirstPanel .story-first-candidate-img {
  max-width: 100%;
  height: 115px;
  object-fit: cover;
  border-radius: 9px;
}
#storyFirstPanel .story-first-candidate-desc {
  color: #183455;
  font-size: .85rem;
}
#storyFirstPanel .story-first-candidate-desc strong {
  font-size: .93rem;
  overflow-wrap: anywhere;
}
#storyFirstPanel .story-first-browse {padding-top: 10px}
#storyFirstPanel .story-first-browse .story-first-field {width: 100%}
#storyFirstPanel .story-first-generated-preview {
  display: block;
  width: min(100%, 260px);
  max-width: 100%;
  height: auto;
  max-height: 390px;
  object-fit: contain;
  border-radius: 12px;
  background: #e8f1fa;
}
@media (max-width: 1200px) {
  #storyFirstPanel .story-first-shot-list {grid-template-columns: minmax(0,1fr)}
}
@media (max-width: 760px) {
  #storyFirstPanel .story-first-shot-list {gap: 14px}
  #storyFirstPanel .story-first-shot {padding: 11px;border-radius: 16px}
  #storyFirstPanel .story-first-shot-hero {
    grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) 28px;
    gap: 10px;
    padding: 11px;
    min-height: 104px;
  }
  #storyFirstPanel .story-first-shot-caret {width: 28px;height: 28px;font-size: 1.4rem}
  #storyFirstPanel .story-first-shot-thumbnail {height: 102px}
  #storyFirstPanel .story-first-shot-title {font-size: 1.27rem}
  #storyFirstPanel .story-first-shot-title-line {gap: 6px;margin-bottom: 9px}
  #storyFirstPanel .story-first-time-pill {min-height: 26px;font-size: .8rem}
  #storyFirstPanel .story-first-status-chip {font-size: .76rem}
  #storyFirstPanel .story-first-shot > .story-first-scene-field {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 11px 5px;
  }
  #storyFirstPanel .story-first-shot > .story-first-scene-field > .story-first-field-icon {grid-column: 1;grid-row: 1}
  #storyFirstPanel .story-first-shot > .story-first-scene-field > span {grid-column: 2;grid-row: 1}
  #storyFirstPanel .story-first-shot > .story-first-scene-field > :is(input,textarea,select) {grid-column: 1 / -1;grid-row: 2}
  #storyFirstPanel .story-first-shot-detail {grid-template-columns: minmax(0, 1fr)}
  #storyFirstPanel .story-first-shot-detail > button {grid-column: 1}
}
@media (prefers-reduced-motion: reduce) {
  #storyFirstPanel * {scroll-behavior: auto}
  #storyFirstPanel .story-first-shot-caret {transition: none}
}

/* An image request can fail when the authenticated Worker preview and the
   Drive thumbnail are unavailable. Never leave a broken-image glyph. */
#storyFirstPanel .story-first-candidate .story-first-preview-unavailable {
  display: grid;
  place-items: center;
  min-height: 135px;
  aspect-ratio: 9 / 12;
  padding: 12px;
  border-radius: 8px;
  background: #e8eef5;
  color: #435a76;
  font-size: .84rem;
  font-weight: 700;
  text-align: center;
}
#storyFirstPanel .story-first-preview-warning {
  color: #744f18;
  line-height: 1.35;
}

/* Optional ElevenLabs video reference controls stay readable on phone/tablet. */
#storyFirstPanel .story-first-reference-row {
  display:flex;align-items:center;flex-wrap:wrap;gap:8px;
  min-width:0;margin:9px 0;padding:9px 0;
  border-bottom:1px solid var(--border-color,#d1d5db);
}
#storyFirstPanel .story-first-reference-row > span {
  flex:1 1 170px;min-width:0;overflow-wrap:anywhere;
}
#storyFirstPanel .story-first-reference-row > .story-first-field {
  flex:0 1 170px;min-width:120px;
}
#storyFirstPanel .story-first-reference-row button {
  white-space:normal;max-width:100%;
}
#storyFirstPanel video.story-first-generated-preview {
  width:min(100%,380px);max-height:55vh;object-fit:contain;background:#111;
}
@media(max-width:640px) {
  #storyFirstPanel .story-first-reference-row {align-items:stretch;}
  #storyFirstPanel .story-first-reference-row > span,
  #storyFirstPanel .story-first-reference-row button {flex:1 1 100%;}
}


/* ElevenLabs: visible scene-local progress near the status button. The
   provider supplies discrete states, not percent complete, so the moving
   track is intentionally indeterminate and never invents a numeric ETA. */
#storyFirstPanel .story-first-video-progress {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px 14px;
  margin: 6px 0 2px;
  border: 1px solid #b9cce3;
  border-radius: 12px;
  background: #f0f6ff;
  color: #173c67;
}
#storyFirstPanel .story-first-video-progress[hidden] { display: none; }
#storyFirstPanel .story-first-video-progress-caption {
  font-size: .92rem;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#storyFirstPanel .story-first-video-progress-note {
  font-size: .82rem;
  line-height: 1.4;
  color: #395a79;
}
#storyFirstPanel .story-first-video-progress-track {
  position: relative;
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #cfdeef;
}
#storyFirstPanel .story-first-video-progress-track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #2c70bc;
  transform: translateX(-102%);
}
#storyFirstPanel .story-first-video-progress.is-active .story-first-video-progress-track::before {
  width: 42%;
  animation: storyFirstVideoInFlight 1.65s ease-in-out infinite;
}
#storyFirstPanel .story-first-video-progress.is-complete {
  background: #edf7f0;
  border-color: #bcd9c2;
  color: #215c36;
}
#storyFirstPanel .story-first-video-progress.is-error {
  background: #fff4f2;
  border-color: #e4b2a8;
  color: #8a2b1f;
}
#storyFirstPanel .story-first-video-progress.is-complete .story-first-video-progress-track,
#storyFirstPanel .story-first-video-progress.is-error .story-first-video-progress-track { display: none; }
.story-first-video-cost-overlay {
  position: fixed;
  inset: 0;
  z-index: 100003;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 23, 39, 0.66);
  box-sizing: border-box;
}
.story-first-video-cost-overlay .story-first-video-cost {
  display: grid;
  gap: 10px;
  width: min(460px, 100%);
  box-sizing: border-box;
  margin: 0;
  padding: 16px;
  border: 2px solid #8a6a12;
  border-radius: 12px;
  background: #fff8e6;
  color: #3d3112;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}
.story-first-video-cost-overlay .story-first-video-cost-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}
.story-first-video-cost-overlay .story-first-video-cost p { margin: 0; line-height: 1.4; }
.story-first-video-cost-overlay .story-first-video-cost-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@keyframes storyFirstVideoInFlight {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  #storyFirstPanel .story-first-video-progress.is-active .story-first-video-progress-track::before {
    animation: none;
    transform: none;
    width: 100%;
  }
}
