.workbench {
  --studio-pad: clamp(16px, 2.6vw, 30px);
  --studio-radius: 16px;
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--studio-radius);
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(0 0 0 / .20);
}
.workbench .control { min-width: 0; padding: 0; margin: 0; border: 0; }
.generation-segment {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}
.generation-segment label, .scene-choice, .video-chips label { position: relative; min-width: 0; cursor: pointer; }
.generation-segment input, .scene-choice input, .video-chips input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.generation-segment span {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 5px clamp(12px, 2vw, 24px);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: var(--fs-small);
  font-weight: 800;
}
.generation-segment label:hover span { color: var(--text); }
.generation-segment input:checked + span {
  border-color: rgb(255 144 111 / .36);
  background: var(--peach-tint);
  color: var(--primary-bright);
}
.generation-segment input:focus-visible + span,
.scene-choice input:focus-visible + span,
.video-chips input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.workbench[data-running] :is(.generation-segment label, .scene-choice, .video-chips label) { cursor: wait; }

.studio-fields {
  display: grid;
  grid-template-columns: minmax(230px, .36fr) minmax(0, .64fr);
  gap: clamp(22px, 3.3vw, 42px);
  align-items: start;
  padding: var(--studio-pad);
}
.studio-source, .studio-options, .studio-templates { min-width: 0; }
.studio-source { display: grid; gap: var(--space-2); }
.studio-source .generation-modes { margin-bottom: var(--space-2); }
.studio-field-title, .studio-templates legend {
  display: block;
  min-height: 30px;
  padding: 0;
  font: 700 23px/1.1 var(--heading);
  color: var(--text);
}
.studio-templates legend { margin-bottom: var(--space-2); }

.drop-area {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: 152px;
  padding: var(--space-3);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--panel-dark);
  text-align: center;
}
.drop-area svg { color: var(--primary-bright); }
.drop-area:hover, .drop-area:focus-within, .drop-area.is-dragging {
  border-color: var(--primary);
  background: var(--peach-tint);
}
.drop-area:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-area input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-area input:disabled { cursor: wait; }
.studio-upload-list { display: grid; gap: var(--space-2); }
.studio-upload-list[data-multiple] { grid-auto-rows: 1fr; }
.studio-upload-list[data-multiple] .drop-area { min-height: 120px; }
.upload-formats { white-space: normal; }
.source-file-copy { display: grid; min-width: 0; max-width: 100%; gap: 2px; }
.file-title, .file-hint { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-title { font-size: var(--fs-small); font-weight: 800; }
.file-hint { color: var(--muted); font-size: var(--fs-xs); }
.source-replace { display: none; color: var(--accent); font-weight: 700; font-size: var(--fs-xs); }
.drop-area[data-has-photo] {
  grid-template-columns: auto minmax(0, 1fr);
  justify-items: stretch;
  align-items: center;
  gap: var(--space-3);
  min-height: 112px;
  text-align: left;
}
.drop-area[data-has-photo] [data-upload-icon] { display: none; }
.drop-area[data-has-photo] .source-replace { display: block; }
.source-thumb {
  width: clamp(74px, 9vw, 110px);
  height: 84px;
  border-radius: 6px;
  background: var(--bg);
  object-fit: contain;
}
.studio-source-actions { display: flex; align-items: center; flex-wrap: wrap; column-gap: var(--space-4); margin-block-start: 2px; }
.workbench .text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-underline-offset: 3px;
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
}
.workbench .text-btn:hover { text-decoration: underline; }
.workbench .text-btn:disabled { opacity: .65; cursor: wait; }
.studio-options { display: grid; gap: var(--space-4); }
.scene-picker {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1.65fr)) repeat(2,minmax(105px,.78fr));
  align-items: start;
  gap: var(--space-2);
}
[data-video-templates] .scene-picker {
  grid-template-columns: repeat(3,minmax(0,1fr));
  max-inline-size: calc(552px + 2 * var(--space-2));
}
[data-video-templates] .scene-choice :is(b, small) { overflow-wrap: anywhere; }
.template-card { position: relative; min-width: 0; }
.scene-choice { display: block; }
.scene-choice > span {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 4px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-dark);
}
.scene-choice:hover > span { border-color: var(--line-strong); }
.scene-choice input:checked + span { border-color: var(--primary); background: var(--peach-tint); }
.scene-choice img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 5px;
  object-fit: contain;
}
.scene-choice b, .scene-choice small { margin-inline: 4px; font-size: var(--fs-xs); line-height: 1.3; }
.scene-choice b { font-weight: 800; }
.scene-choice small { color: var(--muted); }

.template-zoom {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgb(251 241 232 / .52);
  border-radius: 7px;
  background: rgb(21 21 26 / .83);
  color: var(--text);
  cursor: zoom-in;
}
.template-zoom:hover { border-color: var(--accent); background: var(--bg); color: var(--accent); }
.template-zoom:disabled { opacity: .64; cursor: wait; }

.studio-photo-options { display: grid; gap: var(--space-3); }
.photo-details textarea {
  width: 100%;
  min-height: 39px;
  padding: 6px var(--space-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-dark);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-small);
}
.photo-details summary { width: fit-content; cursor: pointer; font-size: var(--fs-small); font-weight: 700; }
.photo-details summary span { margin-inline-start: 4px; color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.photo-details textarea { display: block; resize: vertical; margin-top: var(--space-2); }
.workbench[data-running] .photo-details summary { color: var(--muted); }

.workbench .video-fixed:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, .63fr);
  gap: var(--space-3) var(--space-4);
}
.workbench :is([data-video-settings], [data-rooftop-settings]).video-fixed:not([hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.loading-text-label { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; }
.loading-text-label span { margin-inline-start: 3px; font-weight: 400; }
.loading-text-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  margin-top: calc(-1 * var(--space-2));
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-dark);
  color: inherit;
  font: inherit;
}
.loading-text-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.video-chips legend { padding: 0; margin-bottom: 5px; color: var(--muted); font-size: var(--fs-xs); font-weight: 700; }
.video-chips > div { display: flex; flex-wrap: wrap; gap: 6px; }
.video-chips span {
  display: grid;
  place-items: center;
  min-height: 36px;
  min-width: 48px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-dark);
  font-size: var(--fs-xs);
  font-weight: 800;
}
.video-chips label:hover span { border-color: var(--line-strong); }
.video-chips input:checked + span { border-color: var(--primary); background: var(--peach-tint); color: var(--primary-bright); }
.video-fixed .control-line { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--muted); }
.video-fixed .control-line b { font-weight: 500; }

.studio-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px var(--studio-pad);
  border-top: 1px solid var(--line);
  background: var(--panel-dark);
}
.studio-billing { min-width: 0; }
.generation-cost { color: var(--muted); font-size: var(--fs-xs); }
.workbench [data-image-price-retry] { font-size: var(--fs-xs); min-height: 29px; }
.workbench .apply, .workbench .download {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.workbench .apply { margin-inline-start: auto; flex: none; min-width: 202px; }
.workbench .apply:not(:disabled):hover { background: var(--primary-bright); }
.workbench .apply:disabled { opacity: .70; cursor: default; }
.workbench[data-running] .apply:disabled { opacity: 1; cursor: wait; }
.studio-apply-price { padding-inline-start: 8px; border-inline-start: 1px solid rgb(32 21 23 / .32); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.studio-apply-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(32 21 23 / .30);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: studio-spin .8s linear infinite;
}
@keyframes studio-spin { to { transform: rotate(1turn); } }

.studio-activity, .studio-credit-return {
  border-top: 1px solid var(--line);
  background: var(--panel-dark);
  color: var(--muted);
}
.studio-credit-return { padding: var(--space-3) var(--studio-pad); font-size: var(--fs-small); }
.studio-activity-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--studio-pad);
  font-size: var(--fs-small);
}
.studio-activity [data-status][data-error] { color: var(--primary-bright); }
.studio-activity[data-loading] [data-status] { font-weight: 800; color: var(--text); }
.studio-progress-note { font-size: var(--fs-xs); color: var(--muted); }
.studio-progress { height: 3px; overflow: hidden; background: var(--surface-lift); }
.studio-progress span {
  display: block;
  width: 34%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--primary-bright), transparent);
  animation: studio-progress 1.9s ease-in-out infinite;
}
@keyframes studio-progress { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.studio-result {
  border-top: 1px solid var(--line);
  padding: var(--space-4) var(--studio-pad) var(--studio-pad);
  background: var(--panel-dark);
  border-radius: 0 0 var(--studio-radius) var(--studio-radius);
  scroll-margin-top: var(--space-4);
}
.studio-result-head, .studio-example-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.studio-result-head h2 { font-size: var(--fs-h3); }
.studio-result-head p { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.workbench .download { min-height: 38px; background: var(--accent); }
.workbench .download:hover { background: var(--text); }
.studio-result-media {
  display: grid;
  justify-items: center;
  width: 100%;
  background: var(--bg);
  border-radius: 9px;
  padding: var(--space-2);
}
.studio-result-media a { display: block; max-width: 100%; }
.studio-result-media img, .studio-result-media video {
  display: block;
  max-width: 100%;
  max-height: min(52dvh, 440px);
  object-fit: contain;
  border-radius: 5px;
}

.studio-signin {
  width: min(470px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.studio-signin::backdrop { background: var(--overlay); }
.studio-signin .dialog-title { color: var(--text); font: 700 clamp(25px, 5vw, 36px)/1.04 var(--heading); }
.studio-signin p { color: var(--muted); }
.studio-signin:not(.studio-example) .dialog-title { margin-bottom: var(--space-2); }
.studio-signin-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.studio-signin-status:not(:empty) { margin-top: var(--space-3); font-size: var(--fs-small); }
.studio-example { width: min(620px, calc(100% - 32px)); }
.studio-example-head { align-items: start; }
.studio-close { min-width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.studio-example [data-example-poster] {
  max-width: 100%;
  max-height: min(65dvh, 580px);
  margin-inline: auto;
  border-radius: 7px;
  object-fit: contain;
}
.studio-example [data-example-video] {
  display: block;
  width: min(100%,calc(min(65dvh,560px) * .5625));
  max-height: min(65dvh,560px);
  margin-inline: auto;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg);
}
.studio-example [data-example-status]:not(:empty) { margin-top: var(--space-2); font-size: var(--fs-small); }
.phone-pair{position:fixed;width:min(calc(100% - 32px),430px);max-height:calc(100dvh - 30px);overflow:auto}
.phone-pair .dialog-title{padding-right:44px}
.phone-pair .phone-close{position:absolute;right:var(--space-3);top:var(--space-3)}
.phone-close button{font-size:22px;line-height:1;min-width:42px;padding:6px}
.phone-pair [data-phone-invite]{display:grid;justify-items:center;gap:var(--space-2);margin-top:var(--space-3);text-align:center}
.phone-pair [data-phone-qr]{display:block;width:min(232px,100%);height:auto;image-rendering:pixelated;border-radius:6px}
.phone-pair [data-phone-status]{font-size:var(--fs-small);margin-top:var(--space-3)}
.phone-pair [data-phone-status][data-error]{color:var(--primary-bright)}
.phone-targets{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-3);margin:var(--space-3) 0}
.phone-targets label{font-size:var(--fs-small);display:flex;align-items:center;gap:5px;cursor:pointer;min-height:36px}
.phone-targets input{accent-color:var(--primary)}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 870px) {
  .workbench .video-fixed:not([hidden]) { grid-template-columns: 1fr; }
  [data-photo-scenes] .scene-picker { grid-template-columns: repeat(2,minmax(0,1fr)); }
  [data-photo-scenes] [data-orientation="portrait"] { width: min(100%,145px); }
}
@media (max-width: 700px) {
  .studio-fields { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .drop-area { min-height: 101px; }
  .drop-area[data-has-photo] { min-height: 87px; gap: var(--space-2); }
  .studio-upload-list[data-multiple] .drop-area { min-height: 96px; }
  .source-thumb { width: 76px; height: 66px; }
  .studio-footer { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .studio-footer .apply { width: 100%; min-width: 0; min-height: 48px; grid-row: 1; }
  .studio-billing:has(> p:empty):has(> button[hidden]) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .studio-apply-spinner, .studio-progress span { animation: none; }
  .studio-progress span { margin-inline: auto; }
}
.workbench .source-presets {
  min-width: 0;
  margin-top: var(--space-1);
}
.source-presets legend {
  padding: 0;
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 800;
}
.source-preset-list {
  display: flex;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 3px 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.source-preset {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-dark);
  cursor: pointer;
}
.source-preset img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.source-preset[data-sample-preset="coastal-driver"] img { object-position: 66% 14%; }
.source-preset[data-sample-preset="night-rider"] img { object-position: 48% 10%; }
.source-preset:hover { border-color: var(--primary); }
.source-preset:focus-visible { outline-offset: 1px; }
.source-preset:disabled { opacity: .62; cursor: wait; }
.source-preset-feedback { font-size: var(--fs-xs); color: var(--muted); }
.source-preset-feedback:not(.sr-only) { margin-top: var(--space-1); }
.remove-source-photo {
  position: absolute;
  z-index: 2;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-dark);
  color: var(--text);
  line-height: 1;
  font-size: 20px;
  cursor: pointer;
}
.remove-source-photo:not(:disabled):hover { border-color: var(--primary); color: var(--primary-bright); }
.remove-source-photo:disabled { cursor: wait; opacity: .62; }
.drop-area[data-has-photo] { padding-inline-end: 42px; }
