/* Shared design system: tokens, GlassPanel, Button, FormControl and functional widgets. */

:root,[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #202126;
  --text: #f5f4f7;
  --muted: #bcbcc7;
  --surface: rgba(30,31,36,.76);
  --surface-soft: rgba(49,50,57,.48);
  --field-bg: rgba(27,28,33,.46);
  --solid-surface: #292a31;
  --task-bg: rgba(25,26,31,.53);
  --hover-bg: rgba(255,255,255,.10);
  --border: rgba(232,228,245,.18);
  --control-border: rgba(231,227,242,.25);
  --accent: #8b5cf6;
  --accent-hover: #9a70f7;
  --accent-soft: rgba(139,92,246,.20);
  --accent-text: #ddd0ff;
  --success-bg: rgba(94,168,128,.17);
  --success-text: #b2dfc1;
  --error-bg: rgba(204,91,106,.16);
  --error-text: #f2a9b2;
  --pending-bg: rgba(210,167,86,.16);
  --pending-text: #ebd09b;
  --ui-shadow: 0 12px 36px rgba(0,0,0,.17),inset 0 1px 0 rgba(255,255,255,.035);
  --radius: 16px;
  --glass-blur: 18px;
  --font-sans: Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --page-bg: #e9e9ef;
  --text: #262833;
  --muted: #606372;
  --surface: rgba(249,248,251,.77);
  --surface-soft: rgba(255,255,255,.39);
  --field-bg: rgba(255,255,255,.46);
  --solid-surface: #f5f4f8;
  --task-bg: rgba(255,255,255,.38);
  --hover-bg: rgba(51,48,65,.07);
  --border: rgba(69,63,91,.17);
  --control-border: rgba(70,63,94,.23);
  --accent: #8150e3;
  --accent-hover: #7240d4;
  --accent-soft: rgba(139,92,246,.13);
  --accent-text: #6036ab;
  --success-bg: rgba(78,156,112,.12);
  --success-text: #256640;
  --error-bg: rgba(196,77,97,.11);
  --error-text: #a5354a;
  --pending-bg: rgba(169,128,55,.12);
  --pending-text: #846022;
  --ui-shadow: 0 10px 32px rgba(32,28,45,.09),inset 0 1px 0 rgba(255,255,255,.55);
}

html {
  min-height: 100%;
  scrollbar-gutter: stable
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh
}

h1,h2,h3,h4,p {
  margin-top: 0
}

h2 {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 0
}

h3 {
  font-size: 17px;
  line-height: 1.45
}

a {
  color: inherit
}

svg {
  display: block
}

button,input,textarea,select {
  font: inherit;
  color: inherit
}

button,a,input,select,textarea {
  touch-action: manipulation
}

button,.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--control-border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s,border-color .15s,box-shadow .15s;
  line-height: 1.4
}

button:hover:not(:disabled),.button:hover {
  background: var(--hover-bg);
  border-color: color-mix(in srgb,var(--control-border),var(--text) 20%)
}

button:disabled {
  opacity: .46;
  cursor: not-allowed
}

button svg,[data-icon] svg {
  width: 20px;
  height: 20px;
  flex: none
}

.primary,.send-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 650
}

.primary:hover:not(:disabled),.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover)
}

.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 9px
}

.danger {
  color: var(--error-text)
}

.success {
  color: var(--success-text)
}

:where(body:not(.admin-page)) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),select,textarea) {
  min-width: 0;
  border: 1px solid var(--control-border);
  border-radius: 9px;
  background: var(--field-bg);
  color: var(--text);
  padding: 9px 11px;
  outline: none
}

select {
  max-width: 100%;
  height: 40px;
  padding-right: 26px;
  text-overflow: ellipsis
}

:where(body:not(.admin-page)) select option {
  background: var(--solid-surface);
  color: var(--text)
}

:where(body:not(.admin-page)) :is(input,textarea)::placeholder {
  color: var(--muted);
  opacity: .78
}

textarea {
  resize: vertical;
  line-height: 1.7
}

input[type="checkbox"],input[type="radio"],input[type="range"] {
  accent-color: var(--accent)
}

:where(body:not(.admin-page)) :is(input,textarea,select,[contenteditable="true"]):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 17%,transparent)
}

:is(button,a,[tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px
}

.panel,.glass-panel,.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  min-width: 0
}

.panel {
  position: relative;
  padding: 24px
}

.hidden,[hidden] {
  display: none!important
}

.sr-only,.plaza-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0
}

.muted {
  color: var(--muted);
  font-size: 12px
}

.eyebrow {
  font-size: 11px;
  letter-spacing: .15em;
  font-weight: 700;
  color: var(--accent-text)
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb,var(--muted) 40%,transparent) transparent
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px
}

::-webkit-scrollbar-thumb {
  border-radius: 12px;
  background: color-mix(in srgb,var(--muted) 40%,transparent)
}

/* Video workbench. One glass workspace and a separately scrolling queue. */

.grid {
  display: grid;
  grid-template-columns: minmax(0,1.75fr) minmax(360px,1fr);
  gap: 18px;
  min-width: 0;
  height: calc(100dvh - 104px);
  min-height: 640px
}

.creation-workspace {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 24px
}

.creation-workspace>.panel {
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  overflow: visible;
  flex: none
}

.prompt-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px
}

.prompt-section-title {
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 2px
}

.workspace-heading h2 {
  font-size: 23px
}

.workspace-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px
}

.prompt-upload-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  margin-left: auto
}

.prompt-upload-actions .small {
  min-height: 34px;
  font-size: 12px;
  padding: 6px 9px
}

.prompt-upload-actions [data-icon] svg {
  width: 16px;
  height: 16px
}

.face-protection-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap
}

.face-protection-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0
}

.face-protection-switch {
  position: relative;
  width: 27px;
  height: 16px;
  border-radius: 20px;
  background: color-mix(in srgb,var(--muted) 40%,transparent)
}

.face-protection-switch::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s
}

.face-protection-toggle input:checked+.face-protection-switch {
  background: var(--accent)
}

.face-protection-toggle input:checked+.face-protection-switch::after {
  transform: translateX(11px)
}

.face-protection-toggle:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px
}

.image-shelf {
  height: 160px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--control-border);
  border-radius: 12px;
  background: var(--field-bg);
  transition: border-color .15s
}

/* Keep uploaded thumbnails usable; only the empty drop target is compact. */

#dropZone:has(.image-list.empty) {
  height: 104px;
  min-height: 104px
}

.image-shelf.over,.editor.over {
  border-color: var(--accent);
  background: var(--accent-soft)
}

.image-shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  gap: 8px;
  color: var(--muted)
}

.image-shelf-title {
  min-width: 0
}

.image-shelf-head em {
  font-style: normal;
  white-space: nowrap
}

.image-list {
  display: flex;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch
}

.image-list.empty {
  justify-content: center;
  align-items: center;
  cursor: pointer
}

.image-drop-empty {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none
}

.image-drop-empty::before {
  content: "";
  width: 30px;
  height: 30px;
  grid-row: 1/3;
  margin: 0 8px 0 0;
  background: var(--muted);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Ccircle cx='8' cy='8' r='1.5'/%3E%3Cpath d='m3 17 5-5 4 4 4-6 5 7'/%3E%3C/svg%3E") center/contain no-repeat
}

.image-drop-empty strong {
  font-size: 13px;
  font-weight: 500
}

.image-drop-empty small {
  font-size: 11px;
  color: var(--muted)
}

.image-card {
  position: relative;
  flex: 0 0 108px;
  width: 108px;
  height: 108px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  cursor: grab
}

.image-card img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 7px;
  margin: auto
}

.image-card .name {
  text-align: center;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.image-card .row {
  display: flex;
  gap: 3px;
  margin-top: auto
}

.image-card .row button {
  min-height: 22px;
  font-size: 10px;
  padding: 2px 4px;
  flex: 1;
  border-radius: 5px
}

.image-card.dragging,.ref-tag.dragging {
  opacity: .45
}

.del {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 6px;
  z-index: 3;
  background: var(--solid-surface);
  color: var(--error-text)
}

.upload-state {
  position: absolute;
  left: 3px;
  top: 3px;
  padding: 2px 4px;
  z-index: 2;
  border-radius: 5px;
  max-width: calc(100% - 26px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  background: var(--solid-surface);
  color: var(--pending-text)
}

.upload-ok .upload-state {
  color: var(--success-text)
}

.upload-failed .upload-state,.image-error {
  color: var(--error-text)
}

.image-error {
  font-size: 9px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis
}

.reference-media-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px
}

.audio-reference-row {
  min-width: 0;
  min-height: 63px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--field-bg);
  display: flex;
  flex-direction: column;
  gap: 5px
}

.audio-reference-row strong {
  font-size: 12px;
  font-weight: 500
}

.audio-reference-row em {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
  margin-left: 5px
}

.audio-reference-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0
}

.media-empty {
  font-size: 11px;
  color: var(--muted)
}

.audio-reference-item {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  max-width: 350px;
  padding: 4px 6px;
  border-radius: 7px;
  background: var(--surface-soft);
  font-size: 10px
}

.media-reference-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.audio-reference-item button {
  min-height: 23px;
  height: 23px;
  padding: 2px 5px;
  font-size: 10px;
  border-radius: 5px
}

.audio-del,.video-del {
  color: var(--error-text)
}

.media-upload-status {
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
  color: var(--muted)
}

.media-upload-status.uploading {
  color: var(--pending-text)
}

.media-upload-status.ok {
  color: var(--success-text)
}

.media-upload-status.failed {
  color: var(--error-text)
}

.editor-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: -5px
}

.editor-label label {
  font-size: 13px;
  font-weight: 600
}

.editor-label span {
  font-size: 11px;
  color: var(--muted)
}

.editor {
  height: 240px;
  min-height: 220px;
  max-height: 650px;
  resize: vertical;
  overflow: auto;
  flex: none;
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 11px;
  padding: 13px 14px;
  background: var(--field-bg);
  outline: none;
  line-height: 1.8;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere
}

.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  opacity: .8;
  pointer-events: none
}

.prompt-character-counter {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: -6px;
  font-variant-numeric: tabular-nums
}

.prompt-character-counter.over-limit {
  color: var(--error-text)
}

.ref-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  vertical-align: middle;
  border: 1px solid var(--control-border);
  background: var(--surface-soft);
  border-radius: 7px;
  padding: 2px 5px;
  margin: 0 2px;
  cursor: grab;
  user-select: none;
  white-space: normal
}

.ref-tag img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 5px;
  pointer-events: none
}

.ref-tag span {
  font-size: 12px
}

.ref-tag b {
  color: var(--error-text);
  cursor: pointer
}

.video-ref-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted)
}

.mention-popup {
  position: absolute;
  z-index: 100;
  width: 250px;
  max-width: calc(100vw - 44px);
  max-height: 220px;
  overflow: auto;
  padding: 5px;
  background: var(--solid-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--ui-shadow)
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer
}

.mention-item:hover,.mention-item.active {
  background: var(--hover-bg)
}

.mention-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 7px
}

.fixed-prompt-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0
}

.fixed-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px
}

.fixed-prompt-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0
}

.fixed-prompt-preset-select {
  font-size: 11px;
  min-width: 0;
  max-width: 290px;
  height: 30px;
  padding: 4px 8px
}

.fixed-prompt-input {
  width: 100%;
  min-height: 64px;
  height: 70px;
  max-height: 250px;
  font-size: 12px
}

.fixed-prompt-head .small {
  font-size: 11px;
  padding: 4px 7px;
  min-height: 28px
}

.option-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px
}

.option-panel h2 {
  font-size: 15px
}

.option-row {
  display: grid;
  grid-template-columns: 1fr .8fr .8fr 1.35fr;
  gap: 12px
}

.option-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted)
}

.option-row select {
  width: 100%;
  font-size: 13px
}

.send-btn {
  width: 100%;
  height: 46px;
  font-size: 15px;
  border-radius: 10px
}

.status-line {
  font-size: 11px;
  min-height: 18px;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere
}

.task-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  min-height: 0
}

.task-section-title {
  gap: 8px;
  flex-wrap: wrap
}

.task-section-title h2 {
  order: -1;
  margin-right: auto;
  font-size: 23px
}

.task-title-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap
}

.task-title-actions .small,#selectAllTasksBtn {
  font-size: 11px;
  padding: 5px 8px;
  min-height: 29px
}

.task-retention-note {
  color: var(--muted);
  font-size: 11px;
  margin: -5px 0 2px
}

.task-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 1px 3px 1px 1px
}

.task-list.empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  min-height: 160px
}

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  flex: none;
  min-width: 0;
  padding: 16px 12px 16px 34px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--task-bg);
  overflow: hidden
}

.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: color-mix(in srgb,var(--muted) 50%,transparent)
}

.task-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px
}

.task-left {
  display: flex;
  gap: 9px;
  min-width: 0
}

.task-main {
  min-width: 0;
  flex: 1
}

.task-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 7px;
  font-size: 11px;
  line-height: 1.5
}

.task-head strong {
  font-size: 12px
}

.task-time,.task-elapsed {
  font-size: 10px;
  color: var(--muted)
}

.task-prompt {
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere
}

.task-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.task-info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: anywhere
}

.task-info span {
  max-width: 100%
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px
}

.task-actions button {
  font-size: 10px;
  padding: 4px 7px;
  min-height: 27px;
  border-radius: 6px
}

.task-error {
  font-size: 11px;
  color: var(--error-text);
  line-height: 1.65;
  overflow-wrap: anywhere;
  max-height: 96px;
  overflow: auto;
  margin-bottom: 10px
}

.task-error-details {
  margin-bottom:10px;
  font-size:11px;
  line-height:1.65;
  overflow-wrap:anywhere;
}

.task-error-details summary {
  color:var(--error-text);
  cursor:pointer;
}

.task-error-details ul {
  margin:8px 0;
  padding-left:18px;
  white-space:pre-wrap;
}

.task-error-details dl {
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  gap:4px 10px;
  margin:8px 0;
}

.task-error-details dt, .task-error-details p {
  color:var(--muted);
}

.task-error-details dd {
  margin:0;
  user-select:text;
}

.fan {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  min-height: 60px
}

.fan:empty {
  display: none
}

.fan > img,.fan > .task-image-placeholder {
  position: absolute;
  top: 8px;
  width: 34px;
  height: 40px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--solid-surface)
}

.fan > :nth-child(1) {
  left: 0
}

.fan > :nth-child(2) {
  left: 5px;
  top: 14px
}

.fan > :nth-child(3) {
  left: 10px;
  top: 20px
}

.fan > .task-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 1px;
  background: var(--solid-surface);
  border-color: var(--control-border);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden
}

.task-image-placeholder svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round
}

.task-select {
  position: absolute;
  left: 11px;
  top: 18px;
  width: 15px;
  height: 16px;
  cursor: pointer
}

.task-select input {
  position: absolute;
  opacity: 0;
  width: 15px;
  height: 15px;
  margin: 0
}

.task-select span {
  display: block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--field-bg)
}

.task-select input:checked+span {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--solid-surface)
}

.task-select input:focus-visible+span {
  outline: 2px solid var(--accent);
  outline-offset: 3px
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 10px;
  white-space: nowrap;
  background: var(--success-bg);
  color: var(--success-text)
}

.badge.fail {
  background: var(--error-bg);
  color: var(--error-text)
}

.badge:is(.processing,.pending,.waiting) {
  background: var(--pending-bg);
  color: var(--pending-text)
}

.task-video-area {
  display: flex;
  gap: 10px;
  min-width: 0;
  align-items: stretch
}

.task-video-divider {
  width: 1px;
  background: var(--border)
}

.task-video-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 85px
}

.task-preview-video {
  position: relative;
  width: 80px;
  height: 86px;
  min-height: 0;
  padding: 0;
  background: #17191e;
  overflow: hidden;
  border-radius: 8px
}

.task-cover {
  width: 100%;
  height: 100%;
  object-fit: cover
}

.task-cover-play {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%,-50%);
  color: white;
  text-shadow: 0 1px 6px #000
}

.task-cover-label {
  position: absolute;
  bottom: 3px;
  font-size: 10px;
  left: 0;
  right: 0;
  color: white;
  text-shadow: 0 1px 6px #000
}

.task-video-box button:not(.task-preview-video) {
  min-height: 29px;
  font-size: 10px;
  padding: 5px 7px;
  width: 100%
}

.task-card:is(.status-processing,.status-pending,.status-queued,.status-submitting) .task-video-area {
  display: none
}

.media-load-failed {
  background: #252730!important;
  border: 1px dashed var(--control-border)!important;
  object-fit: contain!important
}

/* Shared dialogs, preserving upload, asset selection, prompt editing and download controls. */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5,6,10,.66);
  backdrop-filter: blur(5px)
}

.modal-card {
  position: relative;
  width: min(640px,96vw);
  max-height: 92dvh;
  overflow: auto;
  padding: 24px;
  background: var(--solid-surface)
}

.close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  z-index: 5;
  font-size: 21px;
  border-radius: 8px
}

.preview-card,.asset-preview-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(1000px,94vw);
  height: 88dvh
}

.preview-card img,.asset-preview-card img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px
}

.video-card {
  width: min(1000px,94vw);
  height: 90dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: hidden
}

.video-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #101114;
  border-radius: 10px;
  overflow: hidden
}

.video-frame video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto
}

.video-preview-status {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 55px;
  z-index: 3;
  padding: 5px 10px;
  background: rgba(20,21,26,.8);
  color: #ddd;
  font-size: 12px;
  border-radius: 8px;
  pointer-events: none
}

.video-preview-status:empty {
  display: none
}

.video-preview-status.error {
  color: #ffc1c8
}

.video-download-btn {
  flex: none;
  min-width: 130px
}

.asset-card {
  width: min(1200px,90vw);
  height: 82dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden
}

.asset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-right: 34px
}

.asset-head h2 {
  font-size: 20px;
  margin: 0 0 5px
}

.asset-head p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  max-width: 640px
}

.asset-head-actions {
  display: flex;
  gap: 8px;
  flex: none
}

.asset-grid {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(140px,1fr));
  gap: 12px;
  align-content: start;
  overflow: auto;
  padding: 14px;
  border: 1px dashed var(--control-border);
  border-radius: 12px;
  background: var(--field-bg);
  user-select: none
}

.asset-grid.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  cursor: pointer
}

.asset-card.over .asset-grid {
  border-color: var(--accent)
}

.asset-item {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden
}

.asset-item.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft)
}

.asset-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px
}

.asset-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0
}

.asset-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.asset-rename {
  min-height: 22px;
  width: 22px;
  padding: 2px;
  flex: none;
  border: 0
}

.asset-name-input {
  width: 100%;
  height: 28px;
  font-size: 11px;
  text-align: center
}

.asset-selection-box {
  position: absolute;
  z-index: 6;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  pointer-events: none;
  border-radius: 5px
}

.asset-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted)
}

.asset-delete-all,.asset-delete-selected {
  color: var(--error-text);
  flex: none
}

.edit-prompt-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(900px,94vw);
  height: min(800px,90dvh);
  overflow: auto
}

.edit-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 34px
}

.edit-prompt-editor {
  flex: 1;
  min-height: 170px
}

.edit-prompt-send {
  align-self: flex-end;
  background: var(--accent);
  color: white
}

.edit-image-shelf {
  flex: none
}

.edit-prompt-character-counter {
  flex: none
}

.download-card {
  width: min(560px,94vw)
}

.download-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px
}

.download-mode-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text)
}

.download-mode-panel {
  display: none;
  gap: 14px
}

.download-modal[data-mode="download"] .download-directory-panel,.download-modal[data-mode="package"] .download-package-panel {
  display: flex;
  flex-direction: column
}

.download-main-input {
  width: 100%;
  height: 42px
}

.download-modal-actions,.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px
}

.confirm-delete-card {
  width: min(480px,94vw)
}

.confirm-delete-card p {
  font-size: 14px;
  line-height: 1.8
}

.download-notice {
  position: fixed;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  background: var(--solid-surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  box-shadow: var(--ui-shadow);
  pointer-events: none;
  font-size: 13px
}

.download-notice-ok {
  color: var(--success-text)
}

.download-notice-fail {
  color: var(--error-text)
}

.announcement-card {
  width: min(560px,94vw)
}

.announcement-card-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-right: 30px;
  margin-bottom: 20px
}

.announcement-card-head small {
  color: var(--muted);
  font-size: 11px
}

.announcement-card-icon {
  font-size: 24px;
  color: var(--muted)
}

.announcement-modal-text {
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.9;
  max-height: 50dvh;
  overflow: auto
}

.announcement-modal-image {
  display: block;
  max-width: 100%;
  max-height: 46dvh;
  object-fit: contain;
  margin: 15px auto;
  border-radius: 9px
}

.announcement-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px
}

.prompt-editor-expanded {
  overflow: hidden
}

.creation-workspace:has(.prompt-expanded) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible
}

.prompt-panel.prompt-expanded {
  position: fixed;
  inset: 4dvh max(24px,calc((100vw - 1260px)/2));
  z-index: 160;
  overflow: auto;
  padding: 26px;
  background: var(--solid-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(5,6,10,.7)
}

.prompt-expanded #editor {
  height: 36dvh;
  max-height: none;
  min-height: 170px
}

.prompt-expanded .option-panel {
  display: none
}

@media(max-width:1450px) {

  .creation-workspace,.task-panel {
    padding: 20px
  }

  .grid {
    grid-template-columns: minmax(0,1.55fr) minmax(340px,1fr)
  }

  .prompt-upload-actions {
    justify-content: flex-start;
    margin-left: 0
  }

  .task-card {
    padding-right: 9px
  }

  .task-video-box {
    width: 72px
  }

  .task-preview-video {
    width: 68px;
    height: 76px
  }

  .option-row {
    gap: 8px
  }
}

@media(max-width:1100px) {

  .grid {
    grid-template-columns: minmax(0,1.35fr) minmax(300px,1fr)
  }

  .option-row {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .task-card {
    grid-template-columns: 1fr
  }

  .task-video-area {
    justify-content: flex-end
  }

  .task-video-divider {
    display: none
  }

  .task-video-box {
    flex-direction: row;
    width: auto
  }

  .task-preview-video {
    flex: none;
    width: 60px;
    height: 65px
  }

  .task-video-box button:not(.task-preview-video) {
    width: auto
  }

  .reference-media-grid {
    grid-template-columns: 1fr
  }

  .fixed-prompt-head-actions {
    width: 100%
  }

  .fixed-prompt-preset-select {
    flex: 1
  }
}

@media(max-width:950px) {

  .grid {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 14px
  }

  .creation-workspace {
    overflow: visible
  }

  .task-panel {
    min-height: 300px
  }

  .task-list {
    flex: none;
    max-height: 65dvh;
    min-height: 180px
  }

  .task-list.empty {
    min-height: 200px
  }

  .reference-media-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .task-card {
    grid-template-columns: minmax(0,1fr) auto
  }

  .task-video-box {
    width: 85px;
    flex-direction: column
  }

  .prompt-upload-actions {
    margin-left: auto
  }
}

@media(max-width:600px) {

  .creation-workspace,.panel {
    padding: 16px
  }

  .workspace-heading h2,.task-section-title h2 {
    font-size: 21px
  }

  .prompt-upload-actions {
    margin-left: 0;
    justify-content: flex-start;
    gap: 6px
  }

  .prompt-upload-actions .small {
    font-size: 11px;
    padding: 5px 8px
  }

  .prompt-upload-actions .face-protection-toggle {
    font-size: 10px
  }

  .reference-media-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px
  }

  .audio-reference-row {
    padding: 9px
  }

  .fixed-prompt-head-actions {
    width: 100%;
    flex-wrap: wrap
  }

  .fixed-prompt-preset-select {
    max-width: 100%;
    flex: 1
  }

  .fixed-prompt-head {
    font-size: 11px
  }

  .option-row {
    gap: 10px
  }

  .task-card {
    grid-template-columns: 1fr
  }

  .task-video-area {
    justify-content: flex-end
  }

  .task-video-box {
    flex-direction: row;
    width: auto
  }

  .modal {
    padding: 12px
  }

  .modal-card {
    padding: 18px;
    max-height: 94dvh
  }

  .asset-card {
    width: 96vw;
    height: 90dvh
  }

  .asset-head {
    flex-direction: column;
    align-items: flex-start
  }

  .asset-head-actions {
    flex-wrap: wrap
  }

  .asset-grid {
    grid-template-columns: repeat(auto-fill,minmax(110px,1fr));
    gap: 8px;
    padding: 8px
  }

  .asset-head p {
    font-size: 11px
  }

  .asset-footer {
    align-items: flex-start;
    flex-wrap: wrap
  }

  .prompt-panel.prompt-expanded {
    inset: 10px;
    padding: 15px
  }

  .prompt-expanded .prompt-upload-actions {
    flex-wrap: wrap
  }

  .prompt-expanded #editor {
    height: 35dvh
  }

  .edit-prompt-head {
    flex-wrap: wrap
  }

  .video-card {
    height: 90dvh
  }

  .task-section-title {
    align-items: flex-start
  }

  .task-title-actions {
    margin-left: auto
  }
}

@media(prefers-reduced-motion:reduce) {

  *,*::before,*::after {
    animation: none!important;
    transition: none!important;
    scroll-behavior: auto!important
  }
}

@media(forced-colors:active) {

  .glass-panel,.panel,.modal-card {
    background: Canvas;
    border-color: CanvasText;
    backdrop-filter: none
  }

  .primary,.send-btn {
    border: 2px solid ButtonText
  }
}
