/* Composer layouts built on the shared controls (controls.css). The Image composer is finished here; Video and
   Cinema Studio get only what keeps them working on the new controls until their own rebuild. Colours come from
   tokens.css only. */

/* Every composer: the main settings sit in the chip row itself, in the order the row sets. */
#primary-settings {
  display: contents;
}
.composer .controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Reference thumbnails, as Higgsfield draws them: small rounded squares with no labels. The × shows on hover or
   focus (always on touch), and a role chip appears only where the role changes the result. */
.reference :is([data-remove-ref], [data-remove-element]) {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--scrim);
  color: var(--text);
  transition: opacity 150ms var(--ease);
}
@media (hover: hover) and (min-width: 761px) {
  .reference :is([data-remove-ref], [data-remove-element]) {
    opacity: 0;
  }
  .reference:hover :is([data-remove-ref], [data-remove-element]),
  .reference:focus-within :is([data-remove-ref], [data-remove-element]) {
    opacity: 1;
  }
}
/* An attached Element: one thumbnail (its first picture) with its @handle along the bottom, white over a dark
   fade, and how many pictures it has in the corner the × does not use. */
.reference-element .reference-element-name {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  padding: 12px 5px 3px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(transparent, var(--scrim));
  color: var(--text);
  font-size: 10px;
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
/* Where a Kling 4.0 frame stands (Start, 2, 3, …, End), along the bottom like an Element's handle. */
.reference .reference-frame {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 12px 5px 3px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(transparent, var(--scrim));
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  line-height: 12px;
  text-align: center;
  pointer-events: none;
}
.reference-element .reference-count {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--scrim);
  color: var(--text);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}
/* A reference's picture in the @ suggestions. */
.mention-thumb {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
  background: var(--chip);
}
#mention-suggestions [data-reference] {
  display: flex;
  align-items: center;
}
/* The last row of a bare @ list opens the whole Elements library. It is not an Element, so it is not Element-coloured. */
:is(.image-workspace, .video-workspace) #mention-suggestions button[data-browse-elements] {
  color: var(--muted);
}
/* The Image composer's @ list opens in the strip above the composer where a notice floats, so the notice steps aside
   while the list is open instead of lying under it. */
.image-workspace #composer:has(#mention-suggestions:not([hidden])) #composer-notice {
  visibility: hidden;
}
.reference .chip {
  position: absolute;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  justify-content: center;
  height: 18px;
  min-height: 18px;
  padding: 0 4px;
  border-radius: 0 0 8px 8px;
  background: var(--scrim);
  font-size: 10px;
}
.reference .chip .chip-lead {
  display: none;
}
.reference .chip .chip-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Image: the composer floats over the My generations gallery. Reference thumbnails run along the top; the prompt
   and the chip row fill the left; the tall Generate block stands beside them; a notice runs full width beneath. */
.image-workspace .composer-wrap {
  bottom: 20px;
  width: min(920px, calc(100% - 32px));
}
.image-workspace #composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto auto;
  gap: 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 50px -12px var(--shadow);
  transition: border-color 150ms var(--ease);
}
.image-workspace #composer:focus-within {
  border-color: var(--line-strong);
}
.image-workspace #composer > * {
  grid-column: 1;
}
.image-workspace #composer > [hidden] {
  display: none;
}
.image-workspace #references {
  grid-column: 1 / -1;
  grid-row: 1;
  gap: 8px;
  margin: 0 0 10px;
}
.image-workspace .composer .reference {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.image-workspace #prompt-editor {
  grid-row: 2;
}
.image-workspace #prompt {
  min-height: 56px;
  max-height: 160px;
  padding: 6px 6px 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
}
.image-workspace #prompt:focus-visible {
  outline: none;
}
.image-workspace #prompt::placeholder {
  color: var(--faint);
}
.image-workspace #prompt-count {
  grid-row: 3;
  margin-top: 4px;
}
.image-workspace #selection-chips {
  grid-row: 4;
  margin-top: 8px;
}
.image-workspace #selection-chips:empty {
  display: none;
}
.image-workspace .element-chip {
  gap: 2px;
  height: 26px;
  padding: 0 2px 0 8px;
  border-radius: 7px;
  background: var(--element-bg);
  color: var(--element);
  font-size: 12.5px;
}
.image-workspace .composer-bottom {
  display: contents;
}
.image-workspace .controls {
  grid-row: 5;
  margin-top: 10px;
}
.image-workspace #generate {
  grid-column: 2;
  grid-row: 2 / 6;
  align-self: stretch;
}
/* A notice (not enough credits, an estimate error) floats as a strip just above the composer, over the gallery: the
   composer never changes height, so the prompt never moves under the Creator's cursor. */
.image-workspace #composer,
.studio-workspace #composer {
  position: relative;
}
:is(.image-workspace, .studio-workspace) #composer-notice {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 4;
  min-height: 44px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: linear-gradient(var(--warn-bg), var(--warn-bg)), var(--menu);
  box-shadow: 0 14px 36px -10px var(--shadow);
  animation: notice-in 160ms var(--ease);
}
:is(.image-workspace, .studio-workspace) #composer-notice[data-tone='error'] {
  background: linear-gradient(var(--danger-bg), var(--danger-bg)), var(--menu);
}
:is(.image-workspace, .studio-workspace) #composer-notice[data-tone='info'] {
  background: var(--menu);
}
/* In Cinema Studio the strip lies over the heading, which steps out of sight rather than show half its letters. */
#image-view:has(#composer-notice:not([hidden])) #studio-intro h1 {
  visibility: hidden;
}
@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@media (prefers-reduced-motion: reduce) {
  #composer-notice {
    animation: none;
  }
}
.image-workspace .composer-top {
  grid-column: 1 / -1;
  grid-row: 7;
  margin-top: 8px;
}
/* The status line stays for screen readers; the price, the Generate state and the notice show it on screen. */
.image-workspace .composer-footer {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* @Element suggestions open above the composer, as a menu. */
.image-workspace #mention-suggestions {
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 12px;
  min-width: 240px;
  max-width: min(380px, calc(100% - 24px));
  max-height: min(240px, 30dvh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--menu);
  box-shadow: 0 20px 50px -10px var(--shadow);
}
.image-workspace #mention-suggestions button {
  min-height: 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--element);
}
.image-workspace #mention-suggestions button:hover,
.image-workspace #mention-suggestions button:focus,
.image-workspace #mention-suggestions button.highlighted {
  background: var(--chip);
  outline: none;
}
.image-workspace #mention-suggestions small {
  color: var(--faint);
}
@media (max-width: 760px) {
  .image-workspace .composer-wrap {
    position: fixed;
    left: 50%;
    bottom: 12px;
    width: calc(100% - 24px);
    margin: 0;
    transform: translateX(-50%);
  }
  .image-workspace #gallery {
    padding-bottom: 320px;
  }
  .image-workspace #composer {
    grid-template-columns: minmax(0, 1fr);
  }
  .image-workspace #prompt {
    font-size: 15px;
  }
  .image-workspace .controls {
    width: auto;
  }
  .image-workspace #generate {
    grid-column: 1;
    grid-row: 6;
    width: 100%;
    min-height: 56px;
    margin-top: 10px;
  }
  .image-workspace .composer-top {
    grid-row: 8;
  }
}

/* Reference role chips size to their label, not to the older 23 px reference buttons. */
.reference .chip {
  width: auto;
}

/* Video and Cinema Studio order their chips as Higgsfield does: + and @, camera moves, model, quality, aspect,
   length, sound, then the rest. */
:where(.video-workspace, .studio-workspace) .controls :where(.chip, .pair, .stepper) {
  order: 7;
}
:is(.video-workspace, .studio-workspace) .controls .pair {
  order: 0;
}
:is(.video-workspace, .studio-workspace) .controls #studio-toolbar-camera {
  order: 1;
}
:is(.video-workspace, .studio-workspace) .controls #model-open {
  order: 2;
}
:is(.video-workspace, .studio-workspace) .controls :is([data-primary='quality'], [data-primary='resolution']) {
  order: 3;
}
:is(.video-workspace, .studio-workspace) .controls #aspect-ratio {
  order: 4;
}
:is(.video-workspace, .studio-workspace)
  .controls
  :is(.chip-input:has([data-primary='duration']), [data-primary='duration']) {
  order: 5;
}
:is(.video-workspace, .studio-workspace) .controls :is([data-primary='generate_audio'], [data-primary='sound']) {
  order: 6;
}
:is(.video-workspace, .studio-workspace) .controls #settings-open {
  order: 8;
}
:is(.video-workspace, .studio-workspace) .controls #batch-stepper {
  order: 9;
}

/* Video: a left panel holding the composer card (the Create Video and Edit Video tabs, a compact drop zone, the
   prompt, the chip row and a full-width Generate), with My generations beside it. The panel runs the full height:
   the prompt takes the spare height and Generate sits at the bottom. A short window scrolls inside the panel. */
.video-workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0 16px;
  height: calc(100dvh - var(--header-h));
  padding: 16px 20px;
  overflow: hidden;
}
.video-workspace .composer-wrap {
  position: relative;
  left: auto;
  bottom: auto;
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: auto;
  max-height: 100%;
  padding: 12px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 50px -12px var(--shadow);
  transform: none;
  scrollbar-width: thin;
}
.video-workspace #composer {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.video-workspace #composer > * {
  order: 9;
}
.video-workspace #video-tabs,
.video-workspace #model-modes {
  order: 0;
}
.video-workspace #start-frame {
  order: 1;
}
.video-workspace #references {
  order: 2;
}
.video-workspace #prompt-row {
  order: 3;
}
/* Higgsfield Genjutsu's controls, and the drop zones and prompt it hides. */
#model-modes[hidden],
#start-frame[hidden],
#video-box[hidden],
#images-box[hidden],
#images-zone[hidden],
#prompt-row[hidden],
#prompt-editor[hidden],
.frame-note[hidden] {
  display: none;
}
/* The prompt takes the spare height, and gives it up first: to the notice, which sits between it and the chips, so
   the chips and Generate never move under the cursor. */
.video-workspace #prompt-editor {
  order: 3;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 72px;
}
.video-workspace #prompt-count {
  order: 3;
  margin-top: -8px;
}
.video-workspace #mention-suggestions {
  order: 4;
}
.video-workspace #composer-notice {
  order: 5;
}
.video-workspace #selection-chips {
  order: 5;
}
.video-workspace .composer-bottom {
  order: 6;
}
.video-workspace .composer-top {
  order: 8;
}

/* Create Video and Edit Video: a segmented control on the darkest ground. */
.workflow-tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg);
}
.workflow-tabs button {
  flex: 1;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 500 13.5px/1 var(--ui);
  white-space: nowrap;
  transition:
    background 120ms var(--ease),
    color 120ms var(--ease);
}
@media (hover: hover) {
  .workflow-tabs button:hover:not(:disabled) {
    background: transparent;
    color: var(--text);
  }
  .frame-add:hover:not(:disabled) {
    border-color: var(--faint);
    background: var(--surface-2);
    color: var(--text);
  }
}
.workflow-tabs button:is([aria-selected='true'], [aria-checked='true']),
.workflow-tabs button:is([aria-selected='true'], [aria-checked='true']):hover {
  background: var(--chip-hover);
  color: var(--text);
}
.workflow-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The drop zone: an icon box and two lines, dashed until something is added. */
.frame-add {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  transition:
    border-color 150ms var(--ease),
    background 150ms var(--ease),
    color 150ms var(--ease);
}
.frame-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.frame-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--chip);
  color: inherit;
}
.frame-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.frame-text strong {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}
.frame-text small {
  color: var(--faint);
  font-size: 12px;
}

/* Genjutsu's images zone shows three small icons: characters, clothes, products. */
.frame-icons {
  display: flex;
  gap: 2px;
  width: auto;
  padding: 0 8px;
}

/* The Prompt row of Genjutsu's Motion transfer: the word, and a switch that shows the prompt box. */
.prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font: 500 14px/1 var(--ui);
}
.switch {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--off);
  transition: background 150ms var(--ease);
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 150ms var(--ease);
}
.switch[aria-checked='true'],
[aria-pressed='true'] > .switch {
  background: var(--accent);
}
:is(.switch[aria-checked='true'], [aria-pressed='true'] > .switch) .switch-knob {
  background: var(--accent-ink);
  transform: translateX(16px);
}
.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* References, the prompt box and the Element chips. */
.video-workspace #references {
  gap: 8px;
  margin: 0;
  padding: 0;
}
.video-workspace .composer .reference {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.video-workspace .reference :is(img, video) {
  border-radius: 10px;
}
/* The prompt's own height (v1.js sets it from the text) is where it starts; it then grows into the spare height. */
.video-workspace #prompt {
  flex: 1 1 0;
  min-height: 72px;
  max-height: none;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
}
.video-workspace #prompt:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.video-workspace #prompt::placeholder {
  color: var(--faint);
}
.video-workspace #selection-chips:empty {
  display: none;
}
:is(.video-workspace, .studio-workspace) .element-chip {
  gap: 2px;
  height: 26px;
  padding: 0 2px 0 8px;
  border-radius: 7px;
  background: var(--element-bg);
  color: var(--element);
  font-size: 12.5px;
}
/* @Element suggestions open as a menu under the prompt. */
.video-workspace #mention-suggestions {
  position: static;
  min-width: 0;
  max-width: none;
  max-height: min(240px, 30dvh);
  overflow-y: auto;
  flex-shrink: 0;
  margin: -4px 0 0;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--menu);
  box-shadow: 0 20px 50px -10px var(--shadow);
}
.video-workspace #mention-suggestions button {
  min-height: 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--element);
}
.video-workspace #mention-suggestions button:is(:hover, :focus, .highlighted) {
  background: var(--chip);
  outline: none;
}
.video-workspace #mention-suggestions small {
  color: var(--faint);
}
.video-workspace .composer-bottom {
  display: block;
  margin: 0;
}
.video-workspace .controls {
  gap: 6px;
}
/* The status line stays for screen readers; the price, the Generate state and the notice show it on screen. */
:is(.video-workspace, .studio-workspace) .composer-footer {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.video-workspace #video-generate-dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding: 0;
  border: 0;
  background: none;
}
.video-workspace #video-generate-dock[hidden] {
  display: none;
}
/* Video's Generate is the shared tall block (GENERATE with ✦ and the price beneath), running the panel's full
   width. */
.video-workspace #generate {
  width: 100%;
}

/* My generations beside the panel. The heading row starts at the panel's top edge, and its title and tools sit level
   with the Create Video / Edit Video tabs (12 px panel padding, 38 px tabs). */
.video-workspace .gallery-heading {
  grid-column: 2;
  grid-row: 1;
  min-height: 62px;
  margin: 0;
  padding: 12px 0;
  border: 0;
  background: none;
}
.video-workspace .gallery-heading h1 {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.video-workspace .gallery-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}
.video-workspace #image-total {
  color: var(--faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.video-workspace #history-filters {
  grid-column: 2;
  grid-row: 2;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.video-workspace .video-history {
  grid-column: 2;
  grid-row: 3;
  min-height: 0;
  overflow: auto;
  padding: 0 0 24px;
  border: 0;
  background: none;
  scrollbar-width: thin;
}
/* With nothing made yet, the empty state fills the gallery area and sits in its middle, in list and grid view. The
   shared `.empty` rules (built for the Image grid) stay as they are. */
.video-workspace .gallery.video-history:has(> .empty) {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding-bottom: 0;
}
.video-workspace .video-history > .empty {
  grid-column: 1;
  align-self: stretch;
  width: 100%;
  margin: 0;
}

/* Each video is a card: the player on the left; the model, prompt, settings, time and actions on the right. A card
   keeps the height its content needs: the gallery's `align-items: start` would shrink its width to its content, and
   a flex item with `min-height: 0` shrinks to fit the scroll area, so its content spills over the next card. */
.video-history.list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.video-history.list .history-item {
  display: grid;
  flex: none;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  padding: 10px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.video-history.list .history-preview {
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--bg);
}
.video-history.list .history-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.video-history .history-model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font: 500 12.5px/1.3 var(--ui);
}
.video-history .history-prompt {
  max-height: 150px;
  margin: 0;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}
.video-history :is(.history-chips, .history-references, .history-settings):empty {
  display: none;
}
.video-history .history-chips {
  margin: 0;
}
.video-history .history-settings {
  gap: 6px;
  margin: 0;
}
.video-history .history-settings span {
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.video-history .history-copy time {
  margin: 0;
  padding: 0;
  color: var(--faint);
  font-size: 12px;
}
.video-history .history-actions {
  gap: 6px;
  margin: 2px 0 0;
}
.video-history .history-actions button {
  height: 30px;
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: var(--chip);
  color: var(--text);
  font: 500 13px/1 var(--ui);
}
.video-history .like-button {
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--scrim);
  font-size: 16px;
}
@media (hover: hover) {
  .video-history .history-actions button:hover:not(:disabled) {
    background: var(--chip-hover);
  }
}
.camera-chip .ic,
.element-chip .ic {
  display: inline-block;
  vertical-align: -2px;
}

@media (max-width: 1100px) {
  .video-workspace {
    grid-template-columns: 320px minmax(0, 1fr);
    padding: 12px;
    gap: 0 12px;
  }
  .video-history.list .history-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .video-history.list .history-copy {
    padding: 0 4px 4px;
  }
}
/* On a phone the panel comes first and the page scrolls. */
@media (max-width: 760px) {
  .video-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: auto;
    padding: 12px;
    overflow: visible;
  }
  .video-workspace .composer-wrap {
    order: -1;
    width: 100%;
    max-height: none;
    overflow: visible;
  }
  /* The panel is not full height here, so the prompt grows with its text (v1.js) and the notice sits under
     Generate. */
  .video-workspace :is(#prompt-editor, #prompt) {
    flex: 1 1 auto;
  }
  .video-workspace #prompt {
    min-height: 96px;
  }
  .video-workspace .gallery-heading {
    min-height: 0;
    padding: 4px 0 0;
  }
  .video-workspace .video-history {
    overflow: visible;
  }
}

/* Cinema Studio (studio-A): the guidance tiles over an inner prompt box, with the Generate block filling the box's
   right side and the Image / Video switch beside the card. */
.studio-workspace .composer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 60px -20px var(--shadow);
}
#studio-heading {
  left: -86px;
}
.studio-mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.studio-mode button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 64px;
  min-height: 64px;
  padding: 8px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font: 500 12.5px/1 var(--ui);
  transition:
    background 150ms var(--ease),
    color 150ms var(--ease);
}
.studio-mode .ic {
  width: 18px;
  height: 18px;
}
.studio-mode button.active {
  background: var(--chip-hover);
  color: var(--text);
}
.studio-mode button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Guidance tiles: an icon box, a small label and the current choice. */
#studio-creative-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}
.studio-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 60px;
  padding: 10px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  transition: background 150ms var(--ease);
}
.studio-selector:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.studio-selector > span:last-child {
  display: grid;
  min-width: 0;
}
.studio-selector-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--text);
}
.studio-selector-icon .ic {
  width: 20px;
  height: 20px;
}
#studio-tile-camera .studio-selector-icon {
  background: var(--camera-bg);
  color: var(--camera);
}
#studio-tile-palette .studio-selector-icon {
  background: var(--element-bg);
  color: var(--element);
}
#studio-tile-lighting .studio-selector-icon {
  background: var(--warn-bg);
  color: var(--warn);
}
.studio-selector small {
  color: var(--faint);
  font: 500 11.5px/1.3 var(--ui);
  white-space: nowrap;
}
.studio-selector strong {
  overflow: hidden;
  color: var(--text);
  font: 600 15px/1.3 var(--ui);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The inner prompt box: prompt, suggestions and chip row on the left, Generate on the right, the guidance preview
   across the bottom. `.composer-bottom` steps aside so its chip row and Generate are placed on their own. */
#studio-prompt-surface {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 12px;
  min-width: 0;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--surface-2);
  transition: border-color 150ms var(--ease);
}
#studio-prompt-surface:focus-within {
  border-color: var(--line-strong);
}
#studio-prompt-surface > #prompt-editor {
  grid-area: 1 / 1;
}
/* The # menu opens over the chip row, just under the prompt, so nothing below it moves. */
#studio-prompt-surface > #studio-hash-suggestions {
  position: absolute;
  grid-area: 2 / 1 / 3 / 2;
  top: 6px;
  right: 0;
  left: 0;
  z-index: 10;
}
/* Row 2 holds only the # menu, which floats; the count takes it when shown. */
#studio-prompt-surface > #prompt-count {
  grid-area: 2 / 1;
  margin-top: 4px;
}
#studio-prompt-surface > #mention-suggestions {
  grid-area: 3 / 1;
  margin-top: 8px;
}
#studio-prompt-surface > #selection-chips {
  grid-area: 4 / 1;
  margin-top: 8px;
}
.studio-workspace .composer-bottom {
  display: contents;
}
.studio-workspace .controls {
  grid-area: 5 / 1;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 10px;
}
.studio-workspace #generate {
  grid-area: 1 / 2 / 6 / 3;
  align-self: stretch;
}
#studio-prompt-surface > #studio-guidance {
  grid-area: 6 / 1 / 7 / 3;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.studio-workspace #prompt {
  min-height: 64px;
  padding: 4px 2px;
}
#studio-guidance summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  color: var(--muted);
  font: 500 12px/1.3 var(--ui);
  cursor: pointer;
  list-style: none;
}
#studio-guidance summary::-webkit-details-marker {
  display: none;
}
#studio-guidance summary .ic {
  flex: none;
  transition: transform 150ms var(--ease);
}
#studio-guidance[open] summary .ic {
  transform: rotate(90deg);
}
#studio-guidance summary strong {
  flex: none;
  font-weight: 500;
}
/* The guidance itself, on one row; the open line shows all of it below. */
#studio-guidance summary span {
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}
#studio-guidance[open] summary span {
  visibility: hidden;
}
#studio-guidance pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font: 12.5px/1.6 var(--ui);
  white-space: pre-wrap;
}
/* # suggestions: camera moves as a menu under the prompt. */
#studio-hash-suggestions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  max-height: 200px;
  padding: 6px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--menu);
  box-shadow: 0 20px 50px -10px var(--shadow);
}
#studio-hash-suggestions button {
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--camera);
  font: 500 13px/1.3 var(--ui);
  text-align: left;
}
#studio-hash-suggestions button[aria-selected='true'] {
  background: var(--camera-bg);
}
#studio-hash-suggestions small {
  display: block;
  color: var(--faint);
  font-size: 11.5px;
}
#studio-hash-suggestions .ic {
  display: inline-block;
  margin-right: 6px;
  vertical-align: -2px;
}
/* Drawn icons in the empty gallery and the camera panel, at the size their glyphs had. */
.studio-empty > span .ic {
  display: inline-block;
  width: 30px;
  height: 30px;
}
.studio-camera-default > span .ic {
  display: inline-block;
  width: 44px;
  height: 44px;
}
.studio-camera-style-grid button > span .ic {
  display: inline-block;
  width: 28px;
  height: 28px;
}

/* The sidebar: compact rows with drawn icons; Drafts and New shot under a divider. */
#studio-sidebar {
  gap: 12px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
#studio-sidebar nav,
#studio-sidebar .studio-sidebar-drafts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#studio-sidebar .studio-sidebar-drafts {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
#studio-sidebar :is(nav, .studio-sidebar-drafts) button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 500 14px/1 var(--ui);
  text-align: left;
  transition:
    background 150ms var(--ease),
    color 150ms var(--ease);
}
#studio-sidebar :is(nav, .studio-sidebar-drafts) button strong {
  font-weight: 500;
  white-space: nowrap;
}
#studio-sidebar nav button.active {
  background: var(--chip);
  color: var(--text);
}
@media (hover: hover) {
  .studio-mode button:hover:not(.active, :disabled) {
    background: var(--chip);
    color: var(--text);
  }
  .studio-selector:hover:not(:disabled) {
    background: var(--chip);
  }
  #studio-sidebar :is(nav, .studio-sidebar-drafts) button:hover:not(.active) {
    background: var(--surface-2);
    color: var(--text);
  }
}

/* Between phone and desktop the tiles drop their icons to keep the labels whole. */
@media (max-width: 1100px) and (min-width: 761px) {
  .studio-selector-icon {
    display: none;
  }
}
/* On a phone the switch sits above the card as a segmented control, the tiles pair up, and Generate runs the
   full width under the chip row. */
@media (max-width: 760px) {
  .studio-workspace .composer {
    gap: 8px;
    padding: 9px;
    border-radius: 20px;
  }
  .studio-mode {
    flex-direction: row;
    width: 100%;
    padding: 3px;
    border-radius: 12px;
  }
  .studio-mode button {
    flex: 1;
    flex-direction: row;
    gap: 8px;
    width: auto;
    min-height: 44px;
    border-radius: 9px;
    font-size: 14px;
  }
  #studio-creative-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .studio-selector {
    gap: 10px;
    min-height: 52px;
    padding: 8px;
    border-radius: 12px;
  }
  .studio-selector-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
  .studio-selector-icon .ic {
    width: 18px;
    height: 18px;
  }
  .studio-selector strong {
    font-size: 14px;
  }
  #studio-prompt-surface {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 8px 8px;
    border-radius: 16px;
  }
  .studio-workspace #prompt {
    min-height: 84px;
  }
  .studio-workspace #generate {
    grid-area: 6 / 1;
    width: 100%;
    min-height: 60px;
    margin-top: 10px;
  }
  #studio-prompt-surface > #studio-guidance {
    grid-area: 7 / 1;
  }
  #studio-guidance summary {
    min-height: 32px;
  }
  #studio-guidance summary span {
    display: none;
  }
  #studio-hash-suggestions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #studio-sidebar :is(nav, .studio-sidebar-drafts) button {
    min-height: 44px;
  }
}

/* Genjutsu follows its source page: mode, video, pictures, prompt, Model and Quality. */
.video-workspace #composer.genjutsu-composer {
  flex: 0 0 auto;
}
.video-workspace .genjutsu-composer #model-modes {
  order: 1;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.video-workspace .genjutsu-composer #model-modes button {
  min-height: 38px;
  height: auto;
  font-weight: 600;
}
.video-workspace .genjutsu-composer #start-frame {
  order: 2;
}
/* The video box holds the attached video, filling the box; the images box holds the pictures, then the zone as the
   add tile while there is room. */
.video-workspace .genjutsu-composer #video-box {
  order: 2;
  min-height: clamp(168px, 22dvh, 210px);
  border-radius: 16px;
  background: var(--surface-2);
}
.video-workspace .genjutsu-composer #video-box .reference {
  position: relative;
  width: 100%;
  height: clamp(168px, 22dvh, 210px);
  border-radius: 16px;
}
.video-workspace .genjutsu-composer #video-box .reference video {
  border-radius: 16px;
  object-fit: contain;
}
.video-workspace .genjutsu-composer #images-box:not([hidden]) {
  order: 3;
  display: flex;
  flex-direction: column;
}
.genjutsu-composer #images-thumbs {
  display: contents;
}
.video-workspace .genjutsu-composer #images-box.has-images {
  flex-flow: row wrap;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
}
.video-workspace .genjutsu-composer #images-box.has-images #images-zone {
  width: 56px;
  min-height: 56px;
  height: 56px;
  padding: 0;
  border-radius: 10px;
}
.video-workspace .genjutsu-composer #images-box.has-images #images-zone::after {
  inset: 3px;
  border-radius: 8px;
}
.video-workspace .genjutsu-composer #images-box.has-images #images-zone::before {
  content: '+';
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
.video-workspace .genjutsu-composer #images-box.has-images #images-zone > * {
  display: none;
}
.video-workspace .genjutsu-composer #references {
  order: 4;
}
.video-workspace .genjutsu-composer #prompt-row {
  order: 5;
}
.video-workspace .genjutsu-composer #prompt-editor {
  order: 6;
  flex: none;
}
.video-workspace .genjutsu-composer #prompt-count {
  order: 6;
}
.video-workspace .genjutsu-composer #mention-suggestions {
  order: 7;
}
.video-workspace .genjutsu-composer #selection-chips {
  order: 7;
}
.video-workspace .genjutsu-composer .composer-bottom {
  order: 8;
}
.video-workspace .genjutsu-composer #composer-notice {
  order: 9;
}
.video-workspace .genjutsu-composer .composer-top {
  order: 10;
}
.video-workspace .genjutsu-composer .frame-add {
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: clamp(168px, 22dvh, 210px);
  padding: 24px 18px;
  border: 0;
  border-radius: 16px;
  background: var(--surface-2);
  text-align: center;
}
.video-workspace .genjutsu-composer .frame-add::after {
  position: absolute;
  inset: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  content: '';
  pointer-events: none;
}
.video-workspace .genjutsu-composer .frame-icon:not(.frame-icons),
.video-workspace .genjutsu-composer .frame-orb {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, var(--chip-hover), var(--surface));
  box-shadow: inset 0 1px 5px var(--line);
  color: var(--text);
}
.video-workspace .genjutsu-composer .frame-icons {
  gap: 0;
  height: auto;
  background: none;
}
.video-workspace .genjutsu-composer .frame-orb + .frame-orb {
  margin-left: -8px;
}
.video-workspace .genjutsu-composer .frame-text {
  gap: 0;
}
.video-workspace .genjutsu-composer .frame-text strong,
.video-workspace .genjutsu-composer #start-frame .frame-text > small:not(.frame-note) {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}
.video-workspace .genjutsu-composer #images-zone strong {
  max-width: 230px;
}
.video-workspace .genjutsu-composer .frame-note,
.video-workspace .genjutsu-composer #images-zone small {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}
.video-workspace .genjutsu-composer #prompt-row {
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 16px;
}
.video-workspace .genjutsu-composer .controls {
  gap: 10px;
}
.video-workspace .genjutsu-composer .controls .pair {
  order: 4;
}
.video-workspace .genjutsu-composer :is(#model-open, #primary-resolution),
.video-workspace
  .tool-composer
  :is(#primary-extension_mode, #primary-duration, #primary-bitrate_mode, #primary-generate_audio) {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px;
  width: 100%;
  height: auto;
  min-height: 66px;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: left;
}
.video-workspace .genjutsu-composer :is(#model-open, #primary-resolution) .chip-lead,
.video-workspace
  .tool-composer
  :is(#primary-extension_mode, #primary-duration, #primary-bitrate_mode, #primary-generate_audio)
  .chip-lead {
  display: none;
}
.video-workspace .genjutsu-composer .genjutsu-field-label {
  grid-area: 1 / 1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.video-workspace .genjutsu-composer :is(#model-open, #primary-resolution) .chip-value,
.video-workspace
  .tool-composer
  :is(#primary-extension_mode, #primary-duration, #primary-bitrate_mode, #primary-generate_audio)
  .chip-value {
  grid-area: 2 / 1;
  font-size: 16px;
  font-weight: 600;
  white-space: normal;
}
.video-workspace .genjutsu-composer :is(#model-open, #primary-resolution) > .ic,
.video-workspace
  .tool-composer
  :is(#primary-extension_mode, #primary-duration, #primary-bitrate_mode, #primary-generate_audio)
  > .ic {
  grid-area: 1 / 2 / 3 / 3;
  align-self: center;
  transform: rotate(-90deg);
}

/* Edit Video's tools (creative.js renderEditTools), as Higgsfield lists them: a card naming the list, then a row per
   tool. While the list shows, the rest of the panel waits for a tool. Once one is open, its card says which, with
   Change to go back. */
.video-workspace :is(#edit-tools, #edit-tool-card, #edit-tool-tabs) {
  order: 0;
}
#composer.tool-list-open > :not(#video-tabs, #edit-tools) {
  display: none;
}
.edit-tools {
  display: flex;
  flex-direction: column;
}
.edit-tools[hidden],
.tool-card[hidden] {
  display: none;
}
.tool-hero {
  position: relative;
  display: grid;
  align-content: end;
  gap: 5px;
  min-height: 112px;
  margin-bottom: 8px;
  padding: 14px;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(circle at 82% 18%, var(--accent-selection), transparent 58%),
    linear-gradient(140deg, var(--chip-hover), var(--surface-2) 70%);
}
.tool-card {
  margin-bottom: 0;
}
.tool-hero strong {
  color: var(--accent);
  font: 800 21px/1 var(--mark);
  font-stretch: 88%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tool-hero small {
  color: var(--text);
  font-size: 12.5px;
}
.tool-text {
  display: grid;
  flex: 1;
  gap: 4px;
  min-width: 0;
}
.tool-change {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--scrim);
  color: var(--text);
  font: 500 12.5px/1 var(--ui);
}
.tool-change:hover {
  background: var(--chip-hover);
}
.tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.tool-row:last-child {
  border-bottom: 0;
}
.tool-row:hover {
  background: var(--surface-2);
}
.tool-row:focus-visible,
.tool-change:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tool-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
}
.tool-row strong {
  font-size: 14.5px;
  font-weight: 600;
}
.tool-row small {
  color: var(--faint);
  font-size: 12.5px;
}
.tool-row > .ic {
  color: var(--faint);
}

/* Extend Video, in Higgsfield's order: the tool card, the video, the pictures, Direction, the prompt, then Duration
   and Quality side by side, Bitrate, Audio and Generate. Seedance 2.5 is fixed, and the result follows the video's
   shape, so there is no model, aspect ratio or other setting to choose. The .tool-composer rules are Edit Video's too. */
.video-workspace .extend-composer #primary-extension_mode {
  order: 4;
}
.video-workspace .extend-composer :is(#model-open, #aspect-ratio, #settings-open, #unlimited-toggle) {
  display: none;
}
.video-workspace .tool-composer .controls {
  flex-direction: column;
  align-items: stretch;
}
.video-workspace .tool-composer .controls .pair {
  order: 0;
  align-self: flex-start;
}
.video-workspace .tool-composer #primary-settings {
  order: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.video-workspace .extend-composer #primary-duration {
  order: 1;
}
.video-workspace .extend-composer #primary-resolution {
  order: 2;
}
.video-workspace .extend-composer #primary-bitrate_mode {
  order: 3;
  grid-column: 1 / -1;
}
/* The reminder that a lower Quality makes the whole video that quality (E9), right under Duration and Quality. */
.video-workspace .extend-composer #extend-quality-reminder {
  order: 2;
  grid-column: 1 / -1;
}
/* Audio is a row with a switch, as on Higgsfield; the chip's value stays for screen readers. */
.video-workspace .tool-composer #primary-generate_audio {
  order: 4;
  grid-column: 1 / -1;
  align-items: center;
  min-height: 52px;
}
.video-workspace .tool-composer #primary-generate_audio .genjutsu-field-label {
  color: var(--text);
  font-size: 15px;
}
.video-workspace .tool-composer #primary-generate_audio .chip-value {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.video-workspace .tool-composer #primary-generate_audio .switch {
  grid-area: 1 / 2;
}

/* Edit Video on Seedance 2.5, in Higgsfield's order: the tool card, the video, the pictures, the prompt, then Model,
   Quality and Bitrate side by side, Audio, Unlimited and Generate. The edit is as long as the video and follows its
   shape, so there is no Duration or aspect ratio to choose. */
.video-workspace .edit-composer :is(#aspect-ratio, #settings-open) {
  display: none;
}
/* Model comes before the settings it holds, as it does in the page's source. */
.video-workspace .edit-composer #model-open {
  order: 1;
}
.video-workspace .edit-composer #primary-resolution {
  order: 1;
}
.video-workspace .edit-composer #primary-bitrate_mode {
  order: 2;
}
/* The reminder that a lower Quality makes the edited video that quality (E9), right under Quality and Bitrate. */
.video-workspace .edit-composer #edit-quality-reminder {
  order: 3;
  grid-column: 1 / -1;
}
.video-workspace .edit-composer #unlimited-toggle {
  order: 2;
}
/* Soul 2.0's Style and Character picker: a grid of thumbnails like the Elements library, the chosen one outlined in
   the accent. A character that can't be picked yet is dimmed, with its reason under it. */
/* Laid out only while open: a closed dialog stays display: none. */
.soul-modal {
  width: min(760px, calc(100vw - 40px));
  max-height: 80vh;
}
.soul-modal[open] {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.soul-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  /* Rows as tall as their cards: in the height-capped dialog, stretched rows squeezed each card to ~49 px. */
  grid-auto-rows: max-content;
  gap: 12px;
  overflow-y: auto;
  padding: 2px;
}
.soul-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
}
button.soul-card {
  cursor: pointer;
}
.soul-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  background: var(--chip);
  border: 2px solid transparent;
  overflow: hidden;
  color: var(--muted);
}
.soul-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
button.soul-card:hover .soul-thumb {
  border-color: var(--line-strong);
}
button.soul-card:focus-visible .soul-thumb,
.soul-card[aria-pressed='true'] .soul-thumb {
  border-color: var(--accent);
}
.soul-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.soul-card.unavailable .soul-thumb,
.soul-card.unavailable .soul-name {
  opacity: 0.45;
}
.soul-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.soul-error {
  color: var(--warn);
  font-size: 13px;
}
.soul-retry {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
