/* The result workspace is a media library. Keep each task in the same-sized cell. */
.results-head-actions { display: flex; gap: 14px; align-items: center; }
.results-head-actions > span { color: var(--studio-quiet); font-size: 11px; }
.results-head-actions button {
  display: inline-flex;
  min-height: 34px;
  padding: 0 12px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--studio-line-strong);
  border-radius: 8px;
  background: var(--studio-panel);
  color: var(--studio-text);
  font-size: 11px;
  font-weight: 600;
}
.results-head-actions button:hover { border-color: var(--studio-accent); color: var(--studio-accent); }
.results-head-actions button[hidden],
body.reference-workspace .results-head-actions { display: none !important; }

body.reference-workspace #stage {
  --gallery-ink: var(--studio-text);
  --gallery-muted: var(--studio-muted);
  --gallery-line: var(--studio-line);
  min-height: 0;
  padding: 24px clamp(16px, 2vw, 36px) 30px;
  background: var(--studio-bg);
  color: var(--gallery-ink);
}
body.reference-workspace #stage .results-head,
body.reference-workspace #stage .results {
  width: 100%;
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}
body.reference-workspace #stage .results-head {
  min-height: 45px;
  margin-bottom: 16px;
  padding: 0;
  align-items: center;
}
body.reference-workspace #stage .results-head .eyebrow { color: var(--studio-quiet); font-size: 9px; }
body.reference-workspace #stage .results-head h2 { color: var(--gallery-ink); font-size: 20px; }
body.reference-workspace #stage .results-head > span { color: var(--gallery-muted); }
body.reference-workspace #stage .results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  align-content: start;
}
body.reference-workspace #stage .project-day {
  grid-column: 1 / -1;
  display: flex;
  min-height: 24px;
  margin: 7px 0 0;
  gap: 12px;
  color: var(--gallery-ink);
}
body.reference-workspace #stage .project-day:first-child { margin-top: 0; }
body.reference-workspace #stage .project-day span { font-size: 13px; font-weight: 650; letter-spacing: 0; }
body.reference-workspace #stage .project-day i { background: var(--gallery-line); }
body.reference-workspace #stage .project-day em { color: var(--gallery-muted); font-size: 10px; }
body.reference-workspace #stage .generation-project,
body.reference-workspace #stage .project-output-grid { display: contents; }
body.reference-workspace #stage .project-head { display: none; }

body.reference-workspace #stage .project-output-grid > .card,
body.reference-workspace #stage .project-output-grid > .card.r-square,
body.reference-workspace #stage .project-output-grid > .card.r-tall,
body.reference-workspace #stage .project-output-grid > .card.r-wide,
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card,
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card.r-square,
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card.r-tall,
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card.r-wide {
  display: block;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0;
  padding: 0;
  grid-column: auto;
  aspect-ratio: 4 / 5 !important;
  overflow: hidden;
  border: 1px solid var(--gallery-line);
  border-radius: 12px;
  background: var(--studio-panel-2);
  box-shadow: none;
  transform: none;
}
body.reference-workspace #stage .project-output-grid > .card:hover,
body.reference-workspace #stage .project-output-grid > .card:focus-visible {
  border-color: var(--studio-line-strong);
  outline: none;
  box-shadow: 0 0 0 2px var(--studio-focus-soft);
  transform: none;
}
body.reference-workspace #stage .card.is-empty-result { cursor: default; }
body.reference-workspace #stage .project-output-grid > .card:has(> .card-failed),
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card:has(> .card-failed) {
  height: 158px !important;
  max-height: 158px !important;
  aspect-ratio: auto !important;
}
body.reference-workspace #stage .card-media-shell,
body.reference-workspace #stage .card-video-shell,
body.reference-workspace #stage .card-media { width: 100%; height: 100%; }
body.reference-workspace #stage .card-media { object-fit: cover; }
body.reference-workspace #stage .card-overlay {
  z-index: 3;
  display: flex !important;
  min-height: 42%;
  padding: 58px 11px 11px;
  background: linear-gradient(180deg, transparent 0%, rgba(9,10,13,.72) 48%, rgba(9,10,13,.96) 100%);
  color: #f6f6f6;
  opacity: 1;
  transform: none;
}
body.reference-workspace #stage .card-prompt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.4;
}
body.reference-workspace #stage .card-config { overflow: hidden; color: #d0d2d7; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
body.reference-workspace #stage .card-meta { min-width: 0; margin-top: 8px; gap: 6px; }
body.reference-workspace #stage .card-model { overflow: hidden; color: #b8bbc3; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
body.reference-workspace #stage .card-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  gap: 4px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
body.reference-workspace #stage .card:hover .card-actions,
body.reference-workspace #stage .card:focus-within .card-actions,
body.reference-workspace #stage .card.result-unavailable .card-actions { opacity: 1; transform: none; }
body.reference-workspace #stage .card-action,
body.reference-workspace #stage .card-dl {
  min-height: 29px;
  padding: 0 8px;
  border: 1px solid rgba(255,255,255,.23);
  border-radius: 7px;
  background: rgba(26,27,32,.88);
  color: #fff;
  font-size: 10px;
  backdrop-filter: blur(8px);
}
body.reference-workspace #stage .card-action:hover,
body.reference-workspace #stage .card-dl:hover { border-color: #fff; background: #f5f5f6; color: #15161a; }
body.reference-workspace #stage .card-dl:disabled,
body.reference-workspace #stage .card-reference:disabled { opacity: .4; cursor: not-allowed; }
body.reference-workspace #stage .card-image-state,
body.reference-workspace #stage .card-video-state { top: 10px; bottom: auto; left: 10px; z-index: 3; }
body.reference-workspace #stage .card-result-count { z-index: 3; }

body.reference-workspace #stage .card-media-shell.media-loading .card-media-image { opacity: 0; }
body.reference-workspace #stage .card-media-shell.media-loading { background: var(--studio-panel-2); }
body.reference-workspace #stage .card-media-progress,
body.reference-workspace #stage .card-media-unavailable { display: none; }
body.reference-workspace #stage .card-media-shell.media-loading .card-media-progress,
body.reference-workspace #stage .card-media-shell.media-failed .card-media-unavailable,
body.reference-workspace #stage .card-video-shell.media-failed .card-media-unavailable {
  position: absolute;
  top: 43%;
  left: 50%;
  z-index: 2;
  display: block;
  width: calc(100% - 28px);
  color: var(--studio-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  transform: translate(-50%, -50%);
}
body.reference-workspace #stage .card-media-unavailable small { color: var(--studio-quiet); font-size: 10px; }
body.reference-workspace #stage .card-media-shell.media-failed .card-media-fallback,
body.reference-workspace #stage .card-video-shell.media-failed .card-video-poster { opacity: 0; }
body.reference-workspace #stage .card.result-unavailable,
body.reference-workspace #stage .card.result-unavailable .card-media-shell,
body.reference-workspace #stage .card.result-unavailable .card-video-shell { background: var(--studio-panel-2); }
body.reference-workspace #stage .card.result-unavailable::after { display: none; }
body.reference-workspace #stage .card.result-unavailable .card-overlay { display: flex !important; }

body.reference-workspace #stage .project-output-grid .card-generating,
body.reference-workspace #stage .project-output-grid .card-failed,
body.reference-workspace #stage .project-output-grid .card-unknown {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 18px;
  gap: 11px;
  align-items: flex-start;
  justify-content: flex-end;
  flex-direction: column;
  background: var(--studio-panel);
  text-align: left;
}
body.reference-workspace #stage .project-output-grid .card-failed { padding: 12px; gap: 5px; justify-content: center; }
body.reference-workspace #stage .project-output-grid > .card:has(.card-generating),
body.reference-workspace #stage .project-output-grid:has(> .card:only-child) > .card:has(.card-generating) {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 4 / 5 !important;
}
body.reference-workspace #stage .project-output-grid .card-generating {
  position: relative;
  padding: 16px;
  gap: 12px;
  justify-content: flex-start;
  cursor: default;
}
.gen-stage { display: flex; gap: 8px; align-items: center; }
.gen-status-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--studio-accent); animation: gen-breathe 2.4s ease-in-out infinite; }
body.reference-workspace #stage .gen-stage .gen-status { color: var(--studio-muted); font-size: 11px; font-weight: 550; }
.gen-preview {
  display: flex;
  width: 100%;
  min-height: 36px;
  flex: 1;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px dashed var(--studio-line-strong);
  border-radius: 7px;
  background: var(--studio-panel-2);
  color: var(--studio-quiet);
}
.gen-preview svg { width: 54px; height: 40px; opacity: .55; }
.gen-preview span { font-size: 10px; letter-spacing: .04em; }
body.reference-workspace #stage .gen-text { flex: 0 0 auto; }
@keyframes gen-breathe { 50% { opacity: .35; } }
body.reference-workspace #stage .gen-text { width: 100%; gap: 7px; }
body.reference-workspace #stage .gen-status,
body.reference-workspace #stage .unknown-title { color: var(--studio-text); font-size: 13px; }
body.reference-workspace #stage .gen-prompt,
body.reference-workspace #stage .fail-prompt,
body.reference-workspace #stage .unknown-prompt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--studio-text);
  font-size: 12px;
  line-height: 1.45;
}
body.reference-workspace #stage .gen-model,
body.reference-workspace #stage .gen-hint,
body.reference-workspace #stage .unknown-msg { color: var(--studio-muted); font-size: 10px; line-height: 1.45; }
body.reference-workspace #stage .gen-hint { margin: -5px 0 0; color: var(--studio-quiet); text-align: left; }
body.reference-workspace #stage .fail-icon,
body.reference-workspace #stage .unknown-icon { flex: 0 0 auto; width: 25px; height: 25px; }
body.reference-workspace #stage .fail-msg { overflow: visible; color: var(--danger); font-size: 11px; white-space: normal; }
body.reference-workspace #stage .project-output-grid .card-failed .fail-msg {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 1.35;
}
body.reference-workspace #stage .project-output-grid .card-failed .fail-retry {
  width: max-content;
  margin: 4px 0 0;
  padding: 7px 10px;
  border: 1px solid var(--studio-line-strong);
  border-radius: 7px;
  background: var(--studio-panel-2);
  color: var(--studio-text);
  font-size: 10px;
}
body.reference-workspace #stage .project-output-grid .card-failed .fail-retry:hover { border-color: var(--studio-accent); background: var(--studio-accent-soft); color: var(--studio-accent); transform: none; }

/* A narrow floating prompt stays available without covering the media wall. */
body.reference-workspace #dock {
  position: sticky;
  bottom: 0;
  z-index: 32;
  width: 100%;
  padding: 8px 16px max(15px, env(safe-area-inset-bottom));
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}
body.reference-workspace #dock #composer {
  width: min(100%, 760px);
  margin: 0 auto;
  border: 1px solid var(--studio-line-strong);
  border-radius: 16px;
  background: var(--studio-panel);
  box-shadow: var(--studio-shadow-soft);
  color: var(--studio-text);
  pointer-events: auto;
}
body.reference-workspace #dock #composer:focus-within { border-color: var(--studio-focus); box-shadow: 0 0 0 3px var(--studio-focus-soft), var(--studio-shadow-soft); }
body.reference-workspace #dock #composer .prompt-input { color: var(--studio-text); }
body.reference-workspace #dock #composer .prompt-input::placeholder { color: var(--studio-quiet); }
body.reference-workspace #dock #composer .composer-upload,
body.reference-workspace #dock #composer .dock-options-toggle { border-color: var(--studio-line-strong); background: var(--studio-panel-2); color: var(--studio-text); }
body.reference-workspace #dock #composer .dock-options-toggle:hover { background: var(--studio-accent-soft); color: var(--studio-accent); }
body.reference-workspace #dock #composer .chips { background: var(--studio-panel); border-color: var(--studio-line-strong); }
body.reference-workspace #dock #composer .chips > .chip { background: var(--studio-panel-2); border-color: var(--studio-line-strong); }
body.reference-workspace #dock #composer .chips .chip-label { color: var(--studio-text); }
body.reference-workspace #dock #composer .submission-status { color: var(--studio-muted); }

body.reference-workspace .pop-panel,
body.reference-workspace .model-panel,
body.reference-workspace .advanced-panel,
body.reference-workspace .reference-link-panel {
  border-color: var(--studio-line-strong);
  background: var(--studio-panel);
  color: var(--studio-text);
  box-shadow: var(--studio-shadow-soft);
}
body.reference-workspace .pop-item { color: var(--studio-muted); }
body.reference-workspace .pop-item:hover,
body.reference-workspace .pop-item.selected,
body.reference-workspace .model-item:hover,
body.reference-workspace .model-item.selected { background: var(--studio-accent-soft); color: var(--studio-accent); }
body.reference-workspace .model-item-name,
body.reference-workspace .advanced-head,
body.reference-workspace .advanced-toggle-row strong,
body.reference-workspace .reference-link-head strong { color: var(--studio-text); }
body.reference-workspace .advanced-field,
body.reference-workspace .advanced-panel small,
body.reference-workspace .model-group { color: var(--studio-muted); }
body.reference-workspace .advanced-field input,
body.reference-workspace .advanced-field textarea,
body.reference-workspace .reference-link-panel input { border-color: var(--studio-line-strong); background: var(--studio-panel-2); color: var(--studio-text); }

@media (max-width: 760px) {
  .results-head-actions > span { display: none; }
  body.reference-workspace #stage { padding: 68px 12px 28px; }
  body.reference-workspace #stage .results-head { align-items: flex-start; }
  body.reference-workspace #stage .results-head > span { display: none; }
  body.reference-workspace #stage .results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  body.reference-workspace #stage .card-actions { opacity: 1; transform: none; }
  body.reference-workspace #stage .card-model { display: none; }
  body.reference-workspace #stage .card-overlay { padding: 40px 8px 8px; }
  body.reference-workspace #stage .card-action,
  body.reference-workspace #stage .card-dl { min-height: 26px; padding: 0 5px; font-size: 9px; }
  body.reference-workspace #stage .card-actions { right: 6px; bottom: 6px; }
  body.reference-workspace #stage .card-config { display: none; }
  body.reference-workspace #stage .project-output-grid .card-generating,
  body.reference-workspace #stage .project-output-grid .card-failed,
  body.reference-workspace #stage .project-output-grid .card-unknown { padding: 11px; }
  body.reference-workspace #stage .gen-hint { display: none; }
  body.reference-workspace #dock { bottom: 0; padding: 6px 10px max(7px, env(safe-area-inset-bottom)); }
  body.reference-workspace #dock #composer { width: 100%; }
}
@media (max-width: 380px) {
  body.reference-workspace #stage .results { grid-template-columns: 1fr 1fr; }
  body.reference-workspace #stage .card-reference { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.reference-workspace #stage .card-actions { transition: none; }
  .gen-status-dot { animation: none; }
}
