/* Asset refinement: presentation only; existing selection and upload handlers stay intact. */
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card {
  cursor: pointer; display: flex; flex-direction: column; min-width: 0;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-media {
  flex: none; aspect-ratio: 16 / 10; overflow: hidden;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-media :is(img,video) {
  width: 100%; height: 100%; object-fit: contain; object-position: center;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-body {
  display: flex; flex-direction: column; flex: 1; min-width: 0;
  padding: 12px !important; gap: 8px !important;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-info-trigger { min-width: 0; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-title strong {
  flex: 1; min-width: 0; font-size: 13px !important; line-height: 21px !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-usage {
  flex: none; color: var(--studio-muted) !important; font-size: 11px !important;
  font-weight: 400; line-height: 20px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-meta {
  min-width: 0; gap: 7px; margin-top: 3px; font-size: 11px !important; line-height: 18px !important;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-meta > span {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-meta > span:last-child { flex-shrink: 0; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) :is(.asset-library-tags,.asset-library-targets) {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 0; margin-top: 5px;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) :is(.asset-library-tags,.asset-library-targets):empty,
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-targets.is-empty { display: none !important; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) :is(.asset-library-tags,.asset-library-targets) span {
  padding: 2px 5px !important; font-size: 9px !important; line-height: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-relation-slot {
  min-height: 42px !important; margin: 0 !important; padding: 7px 8px !important;
  grid-template-columns: 24px minmax(0,1fr) auto; gap: 7px;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-relation-icon { width: 24px; height: 24px; border-radius: 7px; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-relation-copy b { font-size: 10px !important; line-height: 16px; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-relation-copy small { font-size: 9px !important; line-height: 14px; }
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-relation-slot > button:not(.asset-bound-people-button) {
  width: auto; min-width: 40px; height: 27px; min-height: 27px; padding: 0 7px; border-radius: 6px;
  color: var(--studio-accent); border-color: var(--studio-line); background: var(--studio-surface); font-size: 10px; font-weight: 500;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-status {
  min-height: 18px; margin: auto 0 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 10px !important;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-status > span:last-child {
  min-width: 0; max-width: 48%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-actions {
  margin: 0 !important; padding-top: 8px !important; gap: 6px !important;
}
html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) :is(.asset-library-card-actions > button,.asset-library-more > summary) {
  height: 30px !important; min-height: 30px !important; font-size: 11px !important; border-radius: 7px !important;
}

/* A single cloud symbol and short status is used in the library and chooser. */
html body.reference-ui-shell[data-studio-ui] .asset-cloud-state {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%;
  color: var(--studio-muted); font-size: 10px; font-weight: 400; line-height: 18px; white-space: nowrap;
}
html body.reference-ui-shell[data-studio-ui] .asset-cloud-state svg {
  display: block; width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
html body.reference-ui-shell[data-studio-ui] .asset-cloud-state[data-sync-state=synced] { color: var(--studio-success,#71b99c); }
html body.reference-ui-shell[data-studio-ui] .asset-cloud-state:is([data-sync-state=syncing],[data-sync-state=pending],[data-sync-state=partial]) { color: var(--studio-accent); }
html body.reference-ui-shell[data-studio-ui] .asset-cloud-state[data-sync-state=failed] { color: var(--studio-danger,#dd9292); }

/* Thumbnails retain the existing shelf height, with width derived from source ratio. */
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) {
  --asset-preview-width: clamp(64px,calc(var(--shelf-height,80px) * var(--asset-ratio,1)),240px);
  position: relative !important; display: block !important;
  flex: 0 0 var(--asset-preview-width) !important; width: var(--asset-preview-width) !important;
  min-width: var(--asset-preview-width) !important; max-width: var(--asset-preview-width) !important;
  height: var(--shelf-height,80px) !important; min-height: var(--shelf-height,80px) !important; max-height: var(--shelf-height,80px) !important;
  padding: 0 !important; border: 1px solid var(--studio-line) !important; border-radius: 10px !important;
  background: var(--studio-bg) !important; overflow: hidden !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile[data-media-kind=audio] { --asset-preview-width: var(--shelf-height,80px); }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-media {
  position: absolute !important; inset: 0 !important; display: grid !important; place-items: center !important;
  width: 100% !important; height: 100% !important; min-height: 0 !important; aspect-ratio: auto !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 9px !important;
  background: var(--studio-bg) !important; overflow: hidden !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-media :is(img,video) {
  display: block !important; width: 100% !important; height: 100% !important; max-width: 100% !important;
  max-height: 100% !important; object-fit: contain !important; object-position: center !important; background: var(--studio-bg) !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-copy {
  position: absolute !important; inset: 5px 28px auto 5px !important; display: block !important;
  width: auto !important; min-width: 0 !important; max-width: none !important; height: auto !important; max-height: none !important;
  padding: 0 !important; margin: 0 !important; z-index: 5 !important; background: transparent !important; pointer-events: none;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-copy-badges {
  position: static !important; inset: auto !important; display: flex !important; flex-wrap: nowrap !important; align-items: center;
  width: auto !important; max-width: 100% !important; min-height: 0 !important; padding: 0 !important;
  margin: 0 !important; gap: 3px !important; background: transparent !important; backdrop-filter: none !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-kind {
  display: inline-flex !important; align-items: center; justify-content: center; flex: none;
  height: 17px !important; min-width: 26px; padding: 0 4px !important; margin: 0 !important;
  border: 1px solid #ffffff24 !important; border-radius: 5px !important; background: #18213bd9 !important;
  color: #f0f3ff !important; font-size: 9px !important; line-height: 15px !important; white-space: nowrap;
  box-shadow: 0 1px 3px #0002 !important; box-sizing: border-box;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile[data-media-kind=audio] .asset-kind { background: #4a3b69e8 !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile[data-media-kind=video] .asset-kind { background: #254e47e8 !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-tile-footer {
  position: absolute !important; inset: 0 !important; width: auto !important; height: auto !important;
  padding: 0 !important; margin: 0 !important; pointer-events: none !important; background: transparent !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .remove {
  position: absolute !important; inset: 4px 4px auto auto !important; width: 20px !important; height: 20px !important;
  min-height: 20px !important; padding: 0 !important; display: grid !important; place-items: center !important;
  color: #fff !important; border: 1px solid #ffffff35 !important; border-radius: 6px !important;
  background: #202127db !important; box-shadow: 0 1px 4px #0002 !important; font-size: 14px !important; line-height: 1 !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .remove:hover { background: #b84b59 !important; }
/* Pointer users see removal when inspecting a tile; keyboard focus reveals it
   too. Touch devices keep the action available without requiring hover. */
@media(hover:hover) and (pointer:fine) {
  html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .remove {
    opacity:0!important; pointer-events:none!important;
  }
  html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add):is(:hover,:focus-within) .remove {
    opacity:1!important; pointer-events:auto!important;
  }
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-ark {
  position: absolute !important; inset: auto 4px 4px auto !important; display: grid !important; place-items: center !important;
  width: 22px !important; min-width: 22px !important; height: 22px !important; min-height: 22px !important;
  margin: 0 !important; padding: 0 !important; border: 1px solid #ffffff35 !important; border-radius: 6px !important;
  background: #202127e8 !important; color: #d2ddff !important; opacity: 1 !important;
  font-size: 0 !important; box-shadow: 0 1px 4px #0002 !important; overflow: hidden !important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-ark::before { content: none !important; display: none !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-ark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-label { display: none !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-ark[data-sync-state=synced] { color: #99d4b8 !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-sync-ark[data-sync-state=failed] { color: #ffabb4 !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) .asset-bound-relation { right: 30px !important; bottom: 5px !important; }
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-tile:not(.asset-add) > .asset-duration {
  position: absolute !important; z-index: 7 !important; inset: auto auto 5px 5px !important;
  max-width: calc(100% - 10px) !important; margin: 0 !important; padding: 3px 4px !important;
  font-size: 9px !important; line-height: 12px !important; white-space: nowrap; pointer-events: none;
}

/* Chooser selection is a centered control, independent of generic drawer padding. */
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card :is(.asset-picker-check,.asset-picker-favorite) {
  display: grid !important; place-items: center !important; width: 26px !important; height: 26px !important;
  min-width: 26px !important; min-height: 26px !important; max-width: 26px !important; max-height: 26px !important;
  margin: 0 !important; padding: 0 !important; line-height: 1 !important; border-radius: 7px !important; box-sizing: border-box;
}
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-check {
  top: 17px !important; left: 17px !important; border: 1px solid var(--studio-strong-line) !important;
  color: var(--studio-on-accent,#fff) !important; background: var(--studio-surface) !important; box-shadow: 0 1px 5px #0003 !important;
}
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-check[aria-pressed=true] { background: var(--studio-primary) !important; border-color: var(--studio-primary) !important; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-check svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-favorite { top: 13px !important; right: 10px !important; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-copy { gap: 4px !important; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-copy .asset-cloud-state { min-height: 16px; font-size: 10px; line-height: 16px; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-copy .asset-cloud-state svg { width: 13px; height: 13px; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card .asset-picker-voice-link { margin: 0 !important; font-size: 10px !important; line-height: 15px !important; }
html body.reference-ui-shell[data-studio-ui] #detailDrawer.asset-picker-drawer .asset-picker-card.disabled .asset-picker-check { opacity: .45; }

/* A separate delete action never steals the voice selection click. */
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-row {
  display: grid; grid-template-columns: minmax(0,1fr) 30px; align-items: center; gap: 5px; min-width: 0;
}
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-row .audio-page-voice { min-width: 0; padding: 11px 10px; gap: 8px; }
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-delete {
  display: grid; place-items: center; width: 30px; min-width: 30px; height: 32px; min-height: 32px;
  margin: 0; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--studio-muted); cursor: pointer; transition: background-color .15s,color .15s;
}
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-delete svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-delete:hover:not(:disabled) { color: var(--studio-danger); background: color-mix(in srgb,var(--studio-danger) 10%,transparent); }
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-delete:focus-visible { outline: 2px solid var(--studio-accent); outline-offset: 1px; }
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-row[data-deleting=true] { opacity: .6; }
#workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-row[data-deleting=true] button { cursor: progress; }

@media (max-width:700px) {
  html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-body { padding: 11px !important; }
  html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-card-title { gap: 6px; }
  html body.reference-ui-shell[data-studio-ui] :is(#view-assets,.project-assets-panel) .asset-library-usage { font-size: 11px !important; }
}
@media (prefers-reduced-motion:reduce) {
  #workspace #view-audio #referenceAudioComposerSlot #creationComposer .audio-page-voice-delete { transition: none; }
}

/* Keep adding within reach while the material shelf scrolls underneath. */
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid:has(> .asset-upload-pinned) {
  scroll-padding-inline-start:calc(var(--shelf-height,80px) + 12px);
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-upload-pinned {
  position:sticky!important;left:0!important;z-index:15!important;
  flex:0 0 var(--shelf-height,80px)!important;
  width:var(--shelf-height,80px)!important;min-width:var(--shelf-height,80px)!important;max-width:var(--shelf-height,80px)!important;
  background:var(--studio-surface)!important;border-radius:10px!important;
  box-shadow:7px 0 0 0 var(--studio-bg),12px 0 12px -9px #0003!important;
}
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid > .asset-upload-pinned > .studio-upload-trigger:disabled {
  opacity:1!important;color:var(--studio-muted)!important;cursor:not-allowed!important;background:var(--studio-surface)!important;
}
/* Generic reference labels repeat the mode. Only meaningful frame order stays visible. */
html body.reference-ui-shell[data-studio-ui] #workspace #creationComposer #generationForm #assetGrid .asset-frame-label {
  position:absolute;left:5px;bottom:5px;display:inline-flex;align-items:center;
  height:18px;padding:0 5px;border-radius:5px;background:#202127e8;color:#fff;
  font-size:10px;line-height:18px;white-space:nowrap;pointer-events:none;
}
/* Audio uses the same centered media preview and exposes a full seekable player. */
#mediaLightbox .lightbox-audio-panel[hidden] {display:none!important;}
#mediaLightbox[data-media-kind=audio] .lightbox-title {color:#e7eaf2!important;}
#mediaLightbox .lightbox-audio-panel {
  width:min(580px,calc(100vw - 40px));padding:30px;box-sizing:border-box;
  display:flex;flex-direction:column;align-items:center;gap:22px;
  border:1px solid var(--studio-strong-line);border-radius:22px;
  background:var(--studio-surface);color:var(--studio-text);box-shadow:0 24px 90px #0004;
}
#mediaLightbox .lightbox-audio-art {
  display:grid;place-items:center;width:104px;height:104px;border-radius:28px;
  color:var(--studio-accent);background:color-mix(in srgb,var(--studio-accent) 9%,var(--studio-surface));
}
#mediaLightbox .lightbox-audio-art svg {width:64px;height:64px;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round;}
#mediaLightbox #lightboxAudioName {max-width:100%;font-size:17px;line-height:1.5;font-weight:600;text-align:center;overflow-wrap:anywhere;}
#mediaLightbox #lightboxAudio {display:block;width:100%;height:48px;min-width:0;margin:0;box-shadow:none;}
html[data-zq-theme=dark] #mediaLightbox #lightboxAudio {color-scheme:dark;}
@media(max-width:600px) {
  #mediaLightbox[data-media-kind=audio] {padding:70px 20px 30px;}
  #mediaLightbox .lightbox-audio-panel {padding:24px 16px;gap:20px;border-radius:18px;}
}
