:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-elevated: #0f1319;
  --bg-soft: #151b23;
  --bg-contrast: #1d2530;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f7fb;
  --muted: #9ca8b8;
  --accent: #2f7dff;
  --accent-strong: #86c7ff;
  --warn: #f6bf4f;
  --danger: #ef6666;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-soft: #f0f2f5;
  --bg-contrast: #e4e8ee;
  --line: rgba(15, 23, 42, 0.16);
  --line-strong: rgba(15, 23, 42, 0.26);
  --text: #151923;
  --muted: #4f5e70;
  --accent: #1f6fff;
  --accent-strong: #0b4fd1;
  --warn: #d39118;
  --danger: #d94d4d;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(47, 125, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(134, 199, 255, 0.15), transparent 32%),
    linear-gradient(180deg, #080b10 0%, #05070a 100%);
  color: var(--text);
  font-size: 14px;
}

:root[data-theme="light"] body {
  background: #eef0f3;
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 12px;
  min-height: 100vh;
  height: 100vh;
  padding: 12px;
  overflow: hidden;
}

.sidebar,
.workspace {
  min-height: 0;
  height: calc(100vh - 24px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-width: 0;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(15, 19, 25, 0.96), rgba(8, 10, 14, 0.94));
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
}

:root[data-theme="light"] .workspace {
  background: #f8f9fb;
}

:root[data-theme="light"] .thread-activity {
  background: #ffffff;
  box-shadow: none;
}

:root[data-theme="light"] .thread-user {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.03);
}

:root[data-theme="light"] .thread-user.is-current {
  border-color: rgba(31, 111, 255, 0.32);
  background: rgba(31, 111, 255, 0.08);
}

:root[data-theme="light"] .thread-user-count {
  background: rgba(15, 23, 42, 0.06);
}

:root[data-theme="light"] .panel {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.14);
}

:root[data-theme="light"] .composer-block,
:root[data-theme="light"] .model-dropdown-button,
:root[data-theme="light"] .model-dropdown-menu,
:root[data-theme="light"] .generation-dialog-panel,
:root[data-theme="light"] .media-viewer-footer,
:root[data-theme="light"] .media-viewer-counter,
:root[data-theme="light"] .media-viewer-badge,
:root[data-theme="light"] .media-viewer-actions .ghost-button,
:root[data-theme="light"] .media-viewer-actions .icon-button,
:root[data-theme="light"] .task-status-shell,
:root[data-theme="light"] .export-panel,
:root[data-theme="light"] .gallery-card,
:root[data-theme="light"] .reference-set-panel,
:root[data-theme="light"] .prompt-body-shell {
  background: #ffffff;
}

:root[data-theme="light"] .field-input,
:root[data-theme="light"] .field-select,
:root[data-theme="light"] .field-textarea,
:root[data-theme="light"] .reference-dropzone,
:root[data-theme="light"] .pager-button,
:root[data-theme="light"] .pager-index,
:root[data-theme="light"] .tab-pill,
:root[data-theme="light"] .ghost-button,
:root[data-theme="light"] .secondary-button,
:root[data-theme="light"] .icon-button,
:root[data-theme="light"] .model-dropdown-option {
  background: #ffffff;
  color: var(--text);
}

:root[data-theme="light"] .task-status-row,
:root[data-theme="light"] .task-status-icon,
:root[data-theme="light"] .task-status-label,
:root[data-theme="light"] .task-status-count,
:root[data-theme="light"] .export-folder-row,
:root[data-theme="light"] .export-folder-icon,
:root[data-theme="light"] .meta-text,
:root[data-theme="light"] .field-group label,
:root[data-theme="light"] .field-group-title {
  color: var(--muted);
}

:root[data-theme="light"] .task-status-row.is-disabled {
  opacity: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 1px 5px;
}

.brand h1,
.workspace-header h2,
.empty-copy h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.46rem;
  line-height: 1.05;
}

.workspace-header h2 {
  font-size: 1.34rem;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.58rem;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  padding: 3px;
  background: #ffffff;
  border: 1px solid rgba(134, 199, 255, 0.32);
  box-shadow: 0 8px 22px rgba(3, 7, 18, 0.22);
  overflow: hidden;
}

:root[data-theme="light"] .brand-mark {
  background: #ffffff;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 7px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(19, 24, 31, 0.95), rgba(12, 16, 22, 0.95));
  padding: 10px;
  min-width: 0;
  overflow: hidden;
}

.panel-header,
.workspace-header,
.workspace-meta,
.thread-activity,
.field-row,
.workspace-toolbar,
.header-actions,
.gallery-card footer,
.reference-toolbar,
.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.thread-activity {
  flex: 1 1 560px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.thread-activity:empty {
  display: none;
}

.workspace-meta {
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(17, 23, 32, 0.86), rgba(10, 14, 20, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.workspace-meta .queue-pill {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.thread-activity-users {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.thread-user {
  display: grid;
  grid-template-columns: auto minmax(64px, auto) auto auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  white-space: nowrap;
}

.thread-user.is-current {
  border-color: rgba(134, 199, 255, 0.42);
  background: rgba(47, 125, 255, 0.12);
}

.thread-user-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(156, 168, 184, 0.12);
}

.thread-user.online .thread-user-dot {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(134, 199, 255, 0.14);
}

.thread-user.working .thread-user-dot {
  background: #44d17a;
  box-shadow: 0 0 0 3px rgba(68, 209, 122, 0.14);
}

.thread-user.waiting .thread-user-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(246, 191, 79, 0.16);
}

.thread-user.offline {
  color: var(--muted);
  opacity: 0.72;
}

.thread-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-user-status {
  color: var(--muted);
  font-size: 0.74rem;
}

.thread-user-count {
  min-width: 38px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
  text-align: center;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.86rem;
}

.export-panel {
  display: grid;
  gap: 10px;
}

.export-panel-header,
.export-panel-title,
.export-folder-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.export-panel-header {
  justify-content: space-between;
  gap: 8px;
}

.export-panel-title {
  gap: 8px;
}

.export-panel-title h2 {
  margin: 0;
  font-size: 0.86rem;
}

.export-panel-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.export-folder-row {
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.86rem;
}

.export-folder-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-folder-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #b7c3d4;
}

.export-folder-button {
  display: inline-flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  min-height: 34px;
}

.panel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.task-status-shell {
  padding: 6px 10px;
}

.task-status-panel {
  display: grid;
}

.task-status-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 0;
  color: #dbe3ee;
}

.task-status-row + .task-status-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.task-status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 14px;
}

.task-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: #cfd7e3;
  flex: 0 0 auto;
}

.task-status-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.task-status-label {
  min-width: 0;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-status-center {
  min-width: 0;
  display: flex;
  align-items: center;
}

.task-status-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}

.task-status-meta {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
}

.task-status-meta:empty {
  display: none;
}

.task-status-count {
  min-width: 44px;
  text-align: right;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.task-status-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.task-stop-button {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.98rem;
  line-height: 1;
}

.task-stop-button:hover {
  border-color: rgba(239, 102, 102, 0.55);
  background: rgba(239, 102, 102, 0.12);
  color: #ffd7d7;
}

.task-spinner {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-top-color: currentColor;
  animation: spin 0.9s linear infinite;
}

.task-status-row[data-task-kind="video"] .task-status-icon {
  color: #2fb8ff;
}

.task-status-row.is-processing .task-status-icon,
.task-status-row.is-processing .task-status-label,
.task-status-row.is-processing .task-status-count {
  color: var(--accent-strong);
}

.task-status-row.is-stopping .task-status-icon,
.task-status-row.is-stopping .task-status-label,
.task-status-row.is-stopping .task-status-count {
  color: var(--warn);
}

.task-status-row.is-queued .task-status-icon,
.task-status-row.is-queued .task-status-label {
  color: #e4edf8;
}

.task-status-row.is-error .task-status-icon,
.task-status-row.is-error .task-status-label,
.task-status-row.is-error .task-status-count {
  color: #ff8f8f;
}

.task-status-row.is-disabled {
  opacity: 0.58;
}

.composer-shell {
  display: grid;
  gap: 0;
  padding: 8px;
  min-width: 0;
  overflow: hidden;
}

.composer-tabs,
#app-notice {
  display: none;
}

.composer-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.composer-block + .composer-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

:root[data-theme="light"] .composer-block + .composer-block {
  border-top-color: rgba(15, 23, 42, 0.1);
}

.composer-shell .panel-header {
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-row h2 {
  margin: 0 0 2px;
  font-size: 0.86rem;
}

.reference-toolbar strong,
.prompt-toolbar strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.8rem;
}

.prompt-toolbar .meta-text,
.reference-toolbar .meta-text {
  font-size: 0.74rem;
}

.reference-toolbar .secondary-button {
  flex: 0 0 auto;
}

.reference-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.reference-title-group {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.reference-add-files-button {
  display: none;
}

.reference-title-input {
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  outline: none;
}

.reference-title-input:focus {
  color: var(--accent-strong);
}

.composer-shell .reference-set-card,
.composer-shell .prompt-editor {
  margin-top: 6px;
}

.composer-shell .summary-card {
  margin-top: 2px;
}

.settings-panel {
  gap: 4px;
}

.settings-panel .field-group {
  gap: 4px;
  margin-bottom: 0;
}

.settings-panel .field-row {
  gap: 0;
}

.settings-panel #dynamic-settings {
  display: grid;
  gap: 5px;
}

.settings-panel #dynamic-settings:empty {
  display: none;
}

.settings-panel .primary-button {
  margin-top: 4px;
}

.slider-row {
  display: block;
}

.slider-field {
  gap: 4px;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.slider-value {
  width: 48px;
  min-width: 48px;
  height: 24px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: center;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.slider-value:focus {
  border-color: rgba(47, 125, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 125, 255, 0.1);
}

.slider-value::-webkit-outer-spin-button,
.slider-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.slider-value[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.usage-cards {
  display: grid;
  gap: 10px;
}

.usage-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}

.usage-card strong,
.summary-card p:first-child {
  display: block;
  margin-bottom: 4px;
}

.usage-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 1.1rem;
}

.usage-reset {
  font-size: 0.8rem;
  color: var(--muted);
}

.workspace-toolbar {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.workspace-toolbar .header-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.logout-button {
  min-height: 36px;
  padding-inline: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 12, 16, 0.92);
  color: var(--text);
  box-shadow: var(--shadow);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle:hover {
  border-color: rgba(47, 125, 255, 0.42);
  background: rgba(47, 125, 255, 0.1);
}

:root[data-theme="light"] .theme-toggle,
:root[data-theme="light"] .limit-ribbon {
  background: #ffffff;
}

.limit-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
  min-height: 36px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(9, 12, 16, 0.92);
  box-shadow: var(--shadow);
}

.limit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
  font-size: 0.84rem;
}

.limit-chip svg {
  width: 12px;
  height: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.limit-chip-value {
  font-weight: 700;
}

.limit-chip.muted {
  color: var(--muted);
}

.limit-chip.muted .limit-chip-value {
  font-weight: 600;
}

.limit-chip.expiry {
  color: var(--muted);
}

.meta-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.78rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.mode-tab,
.tab-pill,
.pager-button,
.pager-index,
.ghost-button,
.secondary-button,
.primary-button,
.icon-button,
.field-select,
.field-input,
.field-textarea,
.status-chip {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition: 180ms ease;
}

.mode-tab,
.ghost-button,
.secondary-button,
.icon-button,
.tab-pill,
.pager-button,
.pager-index {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.mode-tab,
.tab-pill,
.pager-button,
.pager-index {
  min-height: 30px;
  padding: 6px 9px;
}

.mode-tab.active,
.tab-pill.active,
.tab-pill:hover,
.pager-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.icon-button:hover {
  border-color: rgba(47, 125, 255, 0.4);
  background: rgba(47, 125, 255, 0.08);
}

.mode-tab:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.field-group {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.field-group label {
  font-size: 0.76rem;
  color: var(--muted);
}

.field-group-title {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.aspect-segments {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(38px, 1fr);
  align-items: center;
  gap: 0;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
}

.aspect-segment {
  min-width: 0;
  min-height: 30px;
  padding: 0 7px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.aspect-segment:first-child {
  border-left: 0;
}

.aspect-segment:hover {
  color: var(--text);
  background: rgba(47, 125, 255, 0.1);
}

.aspect-segment.is-selected {
  border-left-color: transparent;
  border-radius: 7px;
  background: #f4f7fb;
  color: #111827;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .aspect-segment.is-selected {
  background: #111827;
  color: #ffffff;
}

.model-dropdown {
  position: relative;
}

.field-row .field-group {
  flex: 1;
  margin-bottom: 0;
}

.field-select,
.field-input,
.field-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  font-size: 0.88rem;
}

.field-range {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
}

.field-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(47, 125, 255, 0.42), rgba(134, 199, 255, 0.42));
}

.field-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, rgba(47, 125, 255, 1), rgba(134, 199, 255, 1));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.field-range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(47, 125, 255, 0.42), rgba(134, 199, 255, 0.42));
}

.field-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(47, 125, 255, 1), rgba(134, 199, 255, 1));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.field-textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.35;
}

.field-select:focus,
.field-input:focus,
.field-textarea:focus {
  border-color: rgba(47, 125, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(47, 125, 255, 0.12);
}

.model-dropdown-button,
.model-dropdown-option {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text);
}

.model-dropdown-button {
  min-height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.model-dropdown-button:hover,
.model-dropdown-button.is-open {
  border-color: rgba(47, 125, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(47, 125, 255, 0.1);
}

.model-dropdown-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.model-dropdown-value,
.model-dropdown-option-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.model-dropdown-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 0.88rem;
}

.model-dropdown-check {
  min-width: 12px;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
}

.model-dropdown-chevron {
  color: var(--muted);
  font-size: 0.66rem;
}

.model-dropdown-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.model-dropdown-menu.is-open {
  display: grid;
  gap: 5px;
}

.model-dropdown-option {
  min-height: 34px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.model-dropdown-option:hover,
.model-dropdown-option.is-selected {
  border-color: rgba(47, 125, 255, 0.38);
  background: rgba(47, 125, 255, 0.08);
}

:root[data-theme="light"] .model-dropdown-option:hover,
:root[data-theme="light"] .model-dropdown-option.is-selected {
  border-color: rgba(31, 111, 255, 0.34);
  background: #eef5ff;
}

.model-dropdown-option .status-dot,
.model-dropdown-button .status-dot {
  flex: 0 0 auto;
}

.credit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(211, 145, 24, 0.34);
  background: rgba(211, 145, 24, 0.18);
  color: #c36f00;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

:root[data-theme="light"] .credit-badge {
  border-color: rgba(211, 145, 24, 0.28);
  background: #ffe0a6;
  color: #9a5a00;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, rgba(47, 125, 255, 0.95), rgba(134, 199, 255, 0.82));
  color: #041108;
  font-weight: 700;
}

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

.secondary-button {
  background: rgba(104, 154, 255, 0.08);
}

.secondary-button:disabled,
.ghost-button:disabled,
.reference-add-card:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.ghost-button {
  background: transparent;
}

.icon-button {
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1;
}

.icon-button svg {
  width: 13px;
  height: 13px;
  display: block;
}

.composer-shell .icon-button {
  width: 26px;
  min-height: 26px;
  padding: 0;
  font-size: 0.76rem;
  border-radius: 10px;
}

.hint-box,
.summary-card,
.queue-pill {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.hint-box {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
}

#model-capabilities,
#model-status-list,
#dynamic-settings {
  margin-top: 10px;
}

.status-list,
.tab-row,
.reference-list,
.reference-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.composer-shell .pager {
  gap: 5px;
  margin-top: 4px;
}

.pager-between {
  justify-content: space-between;
}

.pager-main,
.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-shell .pager-main,
.composer-shell .pager-actions {
  gap: 5px;
}

.pager-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
}

.composer-shell .pager-button {
  width: 24px;
  min-height: 24px;
  font-size: 0.68rem;
  border-radius: 9px;
}

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

.pager-index {
  min-width: 42px;
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.88rem;
}

.composer-shell .pager-index {
  min-width: 32px;
  min-height: 24px;
  padding: 0 7px;
  font-size: 0.74rem;
  border-radius: 9px;
}

.pager-total {
  color: var(--muted);
  font-size: 0.8rem;
}

.composer-shell .pager-total {
  font-size: 0.68rem;
}

.pager-icon-button svg {
  width: 14px;
  height: 14px;
}

.composer-shell .pager-icon-button svg {
  width: 9px;
  height: 9px;
}

.pager-button.danger {
  border-color: rgba(239, 102, 102, 0.45);
  background: rgba(239, 102, 102, 0.16);
  color: #ffb2b2;
}

.pager-button.danger:hover {
  border-color: rgba(239, 102, 102, 0.65);
  background: rgba(239, 102, 102, 0.24);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  font-size: 0.72rem;
}

.status-dot,
.model-status-summary::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.status-chip.online .status-dot,
.model-status-summary.online::before,
.status-dot.online {
  background: var(--accent);
}

.status-chip.slow .status-dot,
.model-status-summary.slow::before,
.status-dot.slow {
  background: var(--warn);
}

.status-chip.offline .status-dot,
.model-status-summary.offline::before,
.status-dot.offline {
  background: var(--danger);
}

.model-status-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.reference-set-card,
.prompt-editor,
.reference-dropzone,
.gallery-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.reference-set-card,
.prompt-editor {
  padding: 8px;
  margin-top: 6px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.reference-dropzone {
  appearance: none;
  width: 100%;
  display: grid;
  gap: 5px;
  place-items: center;
  padding: 12px 10px;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.reference-dropzone:hover,
.reference-dropzone:focus-visible,
.reference-dropzone.dragover {
  border-color: rgba(47, 125, 255, 0.58);
  background: rgba(47, 125, 255, 0.08);
}

.reference-dropzone.is-disabled {
  cursor: not-allowed;
}

.reference-dropzone-large {
  min-height: 92px;
}

.reference-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  align-items: flex-start;
  overflow: hidden;
}

.reference-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  cursor: grab;
  user-select: none;
}

.reference-card button {
  border: 0;
  background: transparent;
  color: inherit;
}

.reference-preview-trigger {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  cursor: inherit;
}

.reference-card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  background: rgba(255, 255, 255, 0.035);
  pointer-events: none;
}

.reference-hover-preview {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(3, 7, 18, 0.62);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 140ms ease, visibility 140ms ease;
}

.reference-hover-preview.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.reference-hover-preview-image {
  display: block;
  max-width: min(72vw, 980px);
  max-height: 82vh;
  object-fit: contain;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: #070b12;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.reference-hover-preview-close {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 50%;
  background: rgba(7, 11, 18, 0.86);
  color: #f8fafc;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.reference-hover-preview-close:hover {
  border-color: rgba(248, 250, 252, 0.6);
  background: rgba(15, 23, 42, 0.96);
}

.reference-card-footer {
  padding: 5px 6px;
  align-items: center;
  justify-content: space-between;
}

.reference-card-name {
  flex: 1;
  min-width: 0;
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drag-handle {
  cursor: inherit;
  color: var(--muted);
}

.reference-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.reference-card.drop-target {
  border-color: rgba(47, 125, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(47, 125, 255, 0.14);
}

.reference-list.is-reordering .reference-card:not(.dragging) {
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.reference-add-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 0;
  aspect-ratio: 1 / 1;
  padding: 10px 6px;
  align-content: center;
  justify-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.prompt-toolbar {
  display: none;
}

.reference-add-plus {
  font-size: 1.55rem;
  line-height: 1;
  color: var(--text);
}

.composer-shell .reference-add-plus {
  font-size: 1rem;
}

.reference-add-label {
  color: var(--muted);
  font-size: 0.74rem;
}

.composer-shell .reference-add-label {
  font-size: 0.68rem;
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
}

.queue-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
}

.generated-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  grid-auto-rows: max-content;
  gap: 8px;
  margin-top: 0;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
}

.generated-grid.empty-state {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 0;
  height: 100%;
  align-content: center;
  justify-items: center;
  justify-content: center;
}

.generated-grid.loading-state {
  position: relative;
}

.generated-grid.has-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.empty-copy {
  max-width: 460px;
  width: min(460px, calc(100% - 40px));
  margin: 0 auto;
  text-align: center;
  justify-self: center;
  align-self: center;
  display: grid;
  justify-items: center;
}

.loading-copy {
  gap: 10px;
}

.generation-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.generation-group-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.generation-group-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.generation-group-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.01em;
  min-width: 0;
}

.generation-action-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  flex: 0 0 auto;
  border-radius: 999px;
  opacity: 0.9;
}

.generation-action-button svg {
  width: 18px;
  height: 18px;
}

.generation-delete-button {
  color: #ff8d8d;
}

.generation-delete-button:hover {
  border-color: rgba(239, 102, 102, 0.5);
  background: rgba(239, 102, 102, 0.12);
}

.generation-group-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.generation-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 8px;
  min-width: 0;
}

.loading-orb {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 35% 35%, rgba(47, 125, 255, 0.78), rgba(47, 125, 255, 0.08) 52%, transparent 56%),
    radial-gradient(circle at 65% 65%, rgba(104, 154, 255, 0.74), rgba(104, 154, 255, 0.08) 48%, transparent 54%),
    rgba(255, 255, 255, 0.03);
  box-shadow:
    0 0 0 10px rgba(255, 255, 255, 0.02),
    0 16px 40px rgba(0, 0, 0, 0.3);
  animation: pulse-glow 1.8s ease-in-out infinite;
}

.gallery-card {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(19, 24, 31, 0.98), rgba(14, 18, 24, 0.98));
}

.gallery-media {
  position: relative;
  display: block;
  min-width: 0;
  overflow: hidden;
  cursor: zoom-in;
}

.gallery-card.processing .gallery-placeholder {
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, 0.02) 8%,
    rgba(255, 255, 255, 0.08) 18%,
    rgba(255, 255, 255, 0.02) 33%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.gallery-card img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
  display: block;
  background: rgba(255, 255, 255, 0.035);
}

.gallery-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  flex: 0 0 auto;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.gallery-card-body {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 4px;
  padding: 44px 8px 8px;
  color: #fff;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.72);
  background: linear-gradient(180deg, transparent 0%, rgba(3, 7, 18, 0.58) 44%, rgba(3, 7, 18, 0.88) 100%);
}

:root[data-theme="light"] .gallery-card-body {
  background: linear-gradient(180deg, transparent 0%, rgba(3, 7, 18, 0.48) 42%, rgba(3, 7, 18, 0.82) 100%);
}

.gallery-card h3,
.gallery-card p {
  margin: 0;
}

.gallery-card h3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: 0.8rem;
  line-height: 1.18;
}

.gallery-card .meta-text {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.68rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card footer {
  flex: 0 0 auto;
  padding: 0 10px 10px;
  background: rgba(17, 22, 29, 0.94);
}

:root[data-theme="light"] .gallery-card footer {
  background: #ffffff;
}

.gallery-card .gallery-meta {
  gap: 4px;
  margin-top: 2px;
}

.gallery-card .pill {
  padding: 3px 6px;
  border: 0;
  color: #fff;
  background: rgba(3, 7, 18, 0.66);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.22);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.1;
}

.gallery-actions-overlay {
  position: absolute;
  z-index: 3;
  right: 6px;
  top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.gallery-card:hover .gallery-actions-overlay,
.gallery-card:focus-within .gallery-actions-overlay {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.gallery-icon-action {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  background: rgba(3, 7, 18, 0.72);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.gallery-icon-action:hover {
  border-color: rgba(134, 199, 255, 0.82);
  background: rgba(31, 111, 255, 0.82);
}

.gallery-icon-action:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.gallery-icon-action svg {
  width: 15px;
  height: 15px;
}

.generation-dialog {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
}

.generation-dialog.is-open {
  display: block;
}

.generation-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 10, 0.72);
  backdrop-filter: blur(8px);
}

.generation-dialog-panel {
  position: relative;
  width: min(460px, calc(100% - 28px));
  margin: min(14vh, 120px) auto 0;
  padding: 18px 18px 16px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(18, 23, 30, 0.98), rgba(10, 14, 20, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.generation-dialog-panel h3 {
  margin: 0;
  font-size: 1.28rem;
}

.generation-dialog-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.generation-dialog-preview {
  margin: -2px 0 0;
}

.generation-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.generation-dialog-confirm {
  width: auto;
  min-width: 118px;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
}

.media-viewer.is-open {
  display: block;
}

.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.82);
  backdrop-filter: blur(8px);
}

.media-viewer-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  padding: 16px 18px 18px;
}

.media-viewer-topbar,
.media-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.media-viewer-meta,
.media-viewer-actions,
.media-viewer-submeta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-viewer-counter,
.media-viewer-badge {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 18, 0.74);
  font-size: 0.74rem;
}

.media-viewer-badge {
  letter-spacing: 0.06em;
}

.media-viewer-actions .ghost-button,
.media-viewer-actions .icon-button {
  min-height: 34px;
  background: rgba(10, 13, 18, 0.74);
}

.media-viewer-stage {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 70px;
}

.media-viewer-image-wrap {
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.media-viewer-image {
  max-width: min(90vw, 980px);
  max-height: calc(100vh - 260px);
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  object-fit: contain;
}

.media-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(134, 199, 255, 0.48);
  background: rgba(9, 14, 24, 0.92);
  color: #fff;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

#media-viewer-prev {
  left: 18px;
}

#media-viewer-next {
  right: 18px;
}

.media-viewer-nav:hover {
  border-color: rgba(134, 199, 255, 0.86);
  background: rgba(31, 111, 255, 0.82);
}

:root[data-theme="light"] .media-viewer-nav {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(15, 23, 42, 0.84);
  color: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
}

.media-viewer-nav[hidden] {
  visibility: hidden;
}

.media-viewer-footer {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 13, 18, 0.88), rgba(8, 11, 16, 0.82));
  align-items: start;
}

.media-viewer-caption {
  margin: 0;
  flex: 1;
  min-width: 0;
  max-width: none;
  max-height: 8.8rem;
  overflow: auto;
  padding-right: 10px;
  line-height: 1.55;
  color: var(--text);
}

:root[data-theme="light"] .media-viewer-counter,
:root[data-theme="light"] .media-viewer-badge,
:root[data-theme="light"] .media-viewer-actions .ghost-button,
:root[data-theme="light"] .media-viewer-actions .icon-button,
:root[data-theme="light"] .media-viewer-footer {
  background: #ffffff;
  color: var(--text);
}

:root[data-theme="light"] .media-viewer-footer {
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
}

.media-viewer-submeta {
  flex-wrap: wrap;
  flex: 0 0 auto;
  max-width: 340px;
  justify-content: end;
}

.gallery-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pill {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--line);
}

.toast-root {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
  z-index: 50;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(9, 12, 16, 0.96);
  box-shadow: var(--shadow);
}

.toast.error {
  border-color: rgba(239, 102, 102, 0.35);
}

.toast.success {
  border-color: rgba(47, 125, 255, 0.35);
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  display: inline-flex;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.switch span::before {
  content: "";
  position: absolute;
  box-sizing: border-box;
  top: 50%;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%);
  transition: 180ms ease;
}

:root[data-theme="light"] .switch span {
  background: #e4e9f0;
  border-color: rgba(15, 23, 42, 0.18);
}

:root[data-theme="light"] .switch span::before {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.switch input:checked + span {
  background: rgba(47, 125, 255, 0.24);
}

:root[data-theme="light"] .switch input:checked + span {
  background: rgba(31, 111, 255, 0.26);
  border-color: rgba(31, 111, 255, 0.34);
}

.switch input:checked + span::before {
  transform: translate(18px, -50%);
  background: var(--accent-strong);
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.84;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .workspace {
    min-height: auto;
    height: auto;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .sidebar {
    position: static;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
    gap: 12px;
  }

  .workspace,
  .panel {
    padding: 14px;
  }

  .reference-card {
    width: 100%;
  }

  .workspace-header,
  .workspace-meta,
  .thread-activity,
  .workspace-toolbar,
  .panel-header,
  .generation-group-header,
  .field-row,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .thread-activity-users {
    justify-content: stretch;
  }

  .thread-user {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    width: 100%;
  }

  .workspace-toolbar {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .theme-toggle,
  .limit-ribbon,
  .logout-button,
  .workspace-toolbar .header-actions {
    justify-self: stretch;
    width: 100%;
  }

  .theme-toggle {
    justify-self: end;
    width: 36px;
  }

  .limit-ribbon {
    justify-content: center;
    overflow-x: auto;
  }

  .generation-group-title {
    font-size: 1.18rem;
  }

  .generation-dialog-panel {
    width: min(100% - 20px, 460px);
    margin-top: 72px;
    padding: 16px 14px 14px;
  }

  .generation-dialog-actions {
    flex-direction: column-reverse;
  }

  .generation-dialog-confirm,
  .generation-dialog-actions .ghost-button {
    width: 100%;
  }

  .media-viewer-shell {
    padding: 10px;
  }

  .media-viewer-stage {
    padding: 0 44px;
  }

  .media-viewer-nav {
    width: 40px;
    height: 40px;
  }

  .media-viewer-image {
    max-width: 100%;
    max-height: calc(100vh - 280px);
  }

  .media-viewer-topbar,
  .media-viewer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .media-viewer-submeta {
    justify-content: flex-start;
  }
}
