:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-muted: #f7f7f8;
  --ink: #1b1c1f;
  --ink-soft: #686b73;
  --line: #dedfe3;
  --line-strong: #c9cbd1;
  --accent: #c94f65;
  --accent-dark: #a93b50;
  --teal: #16786f;
  --gold: #a87522;
  --danger: #b63c3c;
  --shadow: 0 16px 48px rgba(26, 29, 35, 0.10);
  --radius: 6px;
  --header-height: 72px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }

body { min-width: 320px; }

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"], summary { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.app-header {
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-lockup, .header-actions, .main-tabs, .section-heading > div, .toolbar-actions,
.empty-specs, .privacy-line, .consent-row, .range-label, .progress-meta, .modal-header,
.setup-status-row, .text-link { display: flex; align-items: center; }

.brand-lockup { gap: 11px; min-width: 180px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: white; border-radius: var(--radius);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-name { font-weight: 800; font-size: 18px; line-height: 1; }
.brand-subtitle { color: var(--ink-soft); font-size: 11px; margin-top: 5px; }

.main-tabs { align-self: stretch; gap: 4px; }
.tab-button {
  position: relative; min-width: 116px; padding: 0 18px; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-soft); cursor: pointer;
}
.tab-link { text-decoration: none; }
.tab-button span { white-space: nowrap; }
.tab-button svg { width: 17px; height: 17px; }
.tab-button::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 2px; background: transparent; }
.tab-button.is-active { color: var(--ink); font-weight: 700; }
.tab-button.is-active::after { background: var(--accent); }

.local-edit-view, .embedded-tool-view { height: calc(100vh - var(--header-height)); min-height: 620px; overflow: hidden; background: var(--bg); }
.local-edit-frame, .embedded-tool-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.view-enter-active { animation: workspace-view-enter 150ms ease-out both; }
@keyframes workspace-view-enter {
  from { opacity: .72; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.header-actions { justify-content: flex-end; gap: 9px; }
.user-chip { height: 36px; display: flex; align-items: center; gap: 7px; padding: 0 7px 0 5px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); font-size: 11px; }
.user-avatar { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #eef1f2; color: var(--teal); }
.user-avatar svg { width: 14px; height: 14px; }
.chip-logout { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; color: var(--ink-soft); }
.chip-logout:hover { color: var(--danger); }
.chip-logout svg { width: 14px; height: 14px; }
.api-status {
  border: 1px solid var(--line); background: var(--surface); height: 36px; padding: 0 12px;
  border-radius: var(--radius); display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-soft); font-size: 12px;
}
.status-dot { width: 8px; height: 8px; background: #9da0a7; border-radius: 50%; flex: 0 0 auto; }
.api-status.is-ready .status-dot, .setup-status-row.is-ready .status-dot { background: var(--teal); box-shadow: 0 0 0 3px rgba(22, 120, 111, 0.12); }
.api-status.is-error .status-dot, .setup-status-row.is-error .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(182, 60, 60, 0.12); }
.assistant-button { height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid #b8dcd7; border-radius: var(--radius); background: #eef9f7; color: var(--teal); cursor: pointer; font-size: 11px; font-weight: 700; }
.assistant-button:hover { border-color: var(--teal); background: #e3f5f1; }
.assistant-button svg { width: 15px; height: 15px; }

.icon-button {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); cursor: pointer;
}
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.icon-button svg { width: 18px; height: 18px; }

.studio-view { display: grid; grid-template-columns: minmax(350px, 420px) minmax(0, 1fr); min-height: calc(100vh - var(--header-height)); }
.config-panel { background: var(--surface); border-right: 1px solid var(--line); min-width: 0; }
.config-section { padding: 24px; border-bottom: 1px solid var(--line); }
.compact-section { padding-bottom: 18px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-heading > div { gap: 9px; }
.section-heading h2 { font-size: 15px; margin: 0; letter-spacing: 0; }
.step-index { color: var(--accent); font-family: Consolas, monospace; font-size: 11px; font-weight: 700; }
.section-meta { color: var(--ink-soft); font-size: 11px; }

.people-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.upload-hint, .workflow-note { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; color: var(--ink-soft); font-size: 10px; line-height: 1.45; }
.upload-hint svg, .workflow-note svg { width: 13px; height: 13px; color: var(--teal); flex: 0 0 auto; }
.upload-slot, .style-upload {
  position: relative; overflow: hidden; border: 1px dashed var(--line-strong); background: var(--surface-muted);
  border-radius: var(--radius); cursor: pointer; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.upload-slot { aspect-ratio: 3 / 4; min-width: 0; }
.upload-slot:hover, .style-upload:hover, .upload-slot.is-dragging, .style-upload.is-dragging { border-color: var(--accent); background: #fff7f8; }
.upload-slot.is-filled { border-style: solid; background: #e6e7ea; }
.upload-slot img, .style-upload img { width: 100%; height: 100%; object-fit: cover; }
.slot-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9598a0; }
.slot-placeholder svg { width: 20px; height: 20px; }
.remove-image {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; color: white; background: rgba(20, 21, 24, 0.78); cursor: pointer;
}
.remove-image svg { width: 13px; height: 13px; }
.style-upload { height: 146px; }
.style-placeholder { height: 100%; display: grid; place-items: center; text-align: center; color: var(--ink-soft); }
.style-placeholder > div { display: grid; justify-items: center; gap: 8px; }
.style-placeholder .upload-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); background: white; border-radius: 50%; color: var(--accent); }
.style-placeholder .upload-icon svg { width: 17px; height: 17px; }
.style-placeholder strong { font-size: 13px; color: var(--ink); }
.style-placeholder span { font-size: 11px; }
.style-badge { position: absolute; left: 8px; bottom: 8px; padding: 5px 7px; border-radius: 4px; background: rgba(20, 21, 24, 0.78); color: white; font-size: 10px; }
.style-upload.is-filled { height: auto; min-height: 146px; padding: 8px; background: var(--surface-muted); }
.style-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; width: 100%; }
.style-tile { position: relative; min-width: 0; aspect-ratio: 3 / 4; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #e6e7ea; }
.style-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.style-tile .style-badge { left: 5px; bottom: 5px; padding: 3px 5px; }
.style-tile .remove-image { z-index: 2; width: 22px; height: 22px; }
.style-count { display: block; margin-top: 6px; color: var(--ink-soft); font-size: 10px; text-align: right; }
.addon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.addon-upload { min-height: 116px; padding: 14px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-muted); display: grid; justify-items: start; align-content: center; gap: 6px; text-align: left; cursor: pointer; }
.addon-upload:hover, .addon-upload.is-filled, .addon-upload.is-dragging { border-color: var(--accent); background: #fff7f8; }
.addon-upload.is-filled { border-style: solid; }
.addon-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.26; }
.addon-upload { position: relative; overflow: hidden; }
.addon-upload > *:not(.addon-preview) { position: relative; z-index: 1; }
.addon-remove { position: absolute; top: 7px; right: 7px; z-index: 3; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(20, 21, 24, 0.82); color: white; cursor: pointer; }
.addon-remove:hover, .addon-remove:focus-visible { background: var(--accent); outline: none; }
.addon-remove svg { width: 13px; height: 13px; }
.addon-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: white; color: var(--accent); }
.addon-icon svg { width: 15px; height: 15px; }
.addon-name { font-size: 12px; font-weight: 700; }
.addon-file { max-width: 100%; color: var(--ink-soft); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.field-group { margin-top: 16px; min-width: 0; }
.field-group:first-of-type { margin-top: 0; }
.field-group > label, .range-field label { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.field-label-row label { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.resolution-pixels { color: var(--teal); font: 700 10px Consolas, monospace; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: #eceef1; border-radius: var(--radius); }
.segment { min-height: 34px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: var(--ink-soft); font-size: 12px; }
.segment.is-active { background: white; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(24, 26, 30, 0.11); }
.settings-row { display: flex; align-items: end; gap: 18px; margin-top: 17px; }
.settings-row .field-group { margin-top: 0; }
.grow { flex: 1; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-grid .field-group { margin-top: 16px; }
.stepper { width: 126px; height: 38px; display: grid; grid-template-columns: 38px 1fr 38px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stepper button { border: 0; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.stepper button:hover { background: var(--surface-muted); }
.stepper button:disabled { color: #b9bbc1; cursor: not-allowed; }
.stepper svg { width: 15px; height: 15px; }
.stepper output { display: grid; place-items: center; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-weight: 800; font-size: 13px; }
.aspect-picker { position: relative; }
.aspect-trigger {
  width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: white; display: grid; grid-template-columns: 17px minmax(0, 1fr) 15px; align-items: center; gap: 8px;
  text-align: left; cursor: pointer; font-size: 12px;
}
.aspect-trigger:hover, .aspect-trigger[aria-expanded="true"] { border-color: var(--line-strong); background: var(--surface-muted); }
.aspect-trigger svg { width: 16px; height: 16px; }
.aspect-trigger svg:last-child { width: 14px; height: 14px; justify-self: end; }
.aspect-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aspect-menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); right: 0; width: min(244px, calc(100vw - 32px));
  max-height: 330px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #1d1f23; color: white; box-shadow: 0 18px 38px rgba(18, 20, 24, 0.24);
}
.aspect-menu button {
  width: 100%; min-height: 39px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: #e8e9ec;
  display: grid; grid-template-columns: 18px minmax(0, 1fr) 15px; align-items: center; gap: 9px; text-align: left; cursor: pointer; font-size: 12px;
}
.aspect-menu button:hover, .aspect-menu button.is-active { background: #30333a; color: white; }
.aspect-menu button svg { width: 16px; height: 16px; }
.aspect-menu button svg:last-child { color: #ef8295; }
.aspect-control { display: grid; grid-template-columns: repeat(3, 1fr); height: 38px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.aspect-button { border: 0; border-right: 1px solid var(--line); background: white; display: grid; place-items: center; cursor: pointer; }
.aspect-button:last-child { border-right: 0; }
.aspect-button.is-active { background: var(--ink); }
.aspect-shape { display: block; border: 1.5px solid var(--ink-soft); }
.aspect-button.is-active .aspect-shape { border-color: white; }
.portrait-shape { width: 10px; height: 15px; }
.square-shape { width: 13px; height: 13px; }
.landscape-shape { width: 16px; height: 10px; }

.advanced-settings { margin-top: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-settings summary { min-height: 42px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; }
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary svg { width: 15px; height: 15px; transition: transform 160ms ease; }
.advanced-settings[open] summary svg { transform: rotate(180deg); }
.advanced-body { padding: 2px 0 17px; }
.range-field { margin-top: 14px; }
.range-label { justify-content: space-between; }
.range-label output { font-family: Consolas, monospace; color: var(--accent); font-size: 11px; font-weight: 700; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); outline: none; }
.text-input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); outline: none; }
input[type="search"] { appearance: none; }
select { height: 38px; padding: 0 10px; }
textarea { resize: vertical; min-height: 78px; padding: 10px; line-height: 1.55; }
select:focus, textarea:focus, .text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 79, 101, 0.10); }
.prompt-file-picker { display: inline-flex; align-items: center; gap: 5px; width: fit-content; margin-top: 7px; color: var(--teal); font-size: 10px; cursor: pointer; }
.prompt-file-picker:hover { color: var(--accent-dark); }
.prompt-file-picker svg { width: 14px; height: 14px; }
.workflow-section { background: #fbfbfc; }
.consent-row { gap: 9px; margin-top: 15px; color: var(--ink-soft); font-size: 11px; cursor: pointer; line-height: 1.4; }
.consent-row input { position: absolute; opacity: 0; pointer-events: none; }
.custom-checkbox { width: 18px; height: 18px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 4px; display: grid; place-items: center; color: white; }
.custom-checkbox svg { width: 13px; height: 13px; opacity: 0; }
.consent-row input:checked + .custom-checkbox { border-color: var(--teal); background: var(--teal); }
.consent-row input:checked + .custom-checkbox svg { opacity: 1; }

.generate-bar { position: sticky; bottom: 0; padding: 18px 24px 20px; background: rgba(255,255,255,0.97); border-top: 1px solid var(--line); }
.primary-button, .secondary-button { border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.primary-button { width: 100%; height: 48px; border: 0; background: var(--ink); color: white; position: relative; }
.primary-button:hover:not(:disabled) { background: #2d2f34; }
.primary-button:disabled { background: #c8cad0; cursor: not-allowed; }
.primary-button svg { width: 18px; height: 18px; }
.primary-button kbd { position: absolute; right: 12px; padding: 4px 7px; border: 1px solid rgba(255,255,255,0.26); background: rgba(255,255,255,0.08); border-radius: 4px; font: 10px Consolas, monospace; }
.privacy-line { margin-top: 10px; justify-content: center; gap: 6px; color: var(--ink-soft); font-size: 10px; }
.privacy-line svg { width: 13px; height: 13px; color: var(--teal); }

.chat-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(240px, 1fr) auto auto; background: #f8f9fa; border-right: 1px solid var(--line); }
.chat-panel.is-drop-target { outline: 2px solid var(--teal); outline-offset: -2px; background: #effaf8; }
.chat-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; padding: 18px 16px 14px; background: white; border-bottom: 1px solid var(--line); }
.chat-panel-header h2 { margin: 4px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.chat-panel-header p { margin: 0; overflow: hidden; color: var(--ink-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-live-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(22,120,111,0.10); }
.chat-messages { min-height: 0; overflow-y: auto; padding: 14px 12px 16px; scroll-behavior: smooth; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 12px; }
.chat-message.is-own { align-items: flex-end; }
.chat-message.is-system { align-items: center; }
.chat-message-meta { display: flex; align-items: center; gap: 7px; max-width: 92%; color: var(--ink-soft); font-size: 10px; }
.chat-message-meta strong { color: var(--ink); font-size: 10px; }
.chat-message-meta time { color: #a0a3aa; font: 9px Consolas, monospace; }
.chat-bubble { max-width: 92%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px 8px 8px 3px; background: white; box-shadow: 0 2px 7px rgba(26,29,35,0.04); }
.chat-message.is-own .chat-bubble { border-color: #f0c7cf; border-radius: 8px 8px 3px 8px; background: #fff3f5; }
.chat-message.is-system .chat-bubble { max-width: 100%; padding: 7px 10px; border-color: #cde6e2; border-radius: 5px; background: #eef9f7; color: var(--teal); text-align: center; box-shadow: none; }
.chat-bubble p { margin: 0; color: var(--ink); font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.is-system .chat-bubble p { color: var(--teal); }
.chat-attachments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 7px; }
.chat-image-attachment { position: relative; min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); cursor: grab; }
.chat-image-attachment:active { cursor: grabbing; }
.chat-image-attachment:hover { border-color: var(--accent); }
.chat-image-attachment img { width: 100%; aspect-ratio: 1 / 1.18; object-fit: cover; }
.chat-image-attachment span { position: absolute; left: 4px; right: 4px; bottom: 4px; overflow: hidden; padding: 3px 4px; border-radius: 3px; background: rgba(20,21,24,0.72); color: white; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.chat-prompt-file { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 6px; min-width: 0; padding: 7px; border: 1px solid #d6e7e4; border-radius: 5px; background: #f4fbfa; color: var(--teal); text-align: left; cursor: pointer; }
.chat-prompt-file:hover { border-color: var(--teal); background: #eaf8f5; }
.chat-prompt-file svg { width: 15px; height: 15px; }
.chat-prompt-file span { overflow: hidden; font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.chat-prompt-file small { grid-column: 2; color: var(--ink-soft); font-size: 9px; }
.chat-empty { min-height: 180px; display: grid; align-content: center; justify-items: center; gap: 8px; padding: 22px 12px; color: var(--ink-soft); text-align: center; }
.chat-empty svg { width: 28px; height: 28px; color: var(--accent); }
.chat-empty strong { color: var(--ink); font-size: 12px; }
.chat-empty span { max-width: 230px; font-size: 10px; line-height: 1.55; }
.chat-composer { padding: 10px 12px 11px; border-top: 1px solid var(--line); background: white; }
.chat-composer.is-disabled { opacity: 0.72; }
.chat-composer textarea { min-height: 64px; max-height: 170px; padding: 9px; font-size: 11px; }
.chat-composer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; margin-top: 7px; }
.chat-composer-row select { min-width: 0; height: 34px; padding: 0 7px; font-size: 10px; }
.chat-send-button { width: auto; height: 34px; padding: 0 11px; }
.chat-send-button svg { width: 14px; height: 14px; }
.chat-file-picker { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink-soft); font-size: 10px; cursor: pointer; white-space: nowrap; }
.chat-file-picker:hover { border-color: var(--line-strong); background: var(--surface-muted); color: var(--ink); }
.chat-file-picker svg { width: 14px; height: 14px; }
.chat-file-note { margin-top: 6px; color: var(--ink-soft); font-size: 9px; line-height: 1.4; }
.chat-selected-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chat-selected-file { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 5px 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-muted); color: var(--ink-soft); font-size: 9px; }
.chat-selected-file > span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-selected-file > svg { width: 12px; height: 12px; color: var(--teal); }
.chat-selected-file button { width: 17px; height: 17px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.chat-selected-file button:hover { color: var(--danger); }
.chat-selected-file button svg { width: 12px; height: 12px; }
.chat-completion { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #fbfbfc; }
.chat-completion-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 10px; }
.chat-completion-heading > span:first-child { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-weight: 700; }
.chat-completion-heading svg { width: 14px; height: 14px; color: var(--teal); }
.chat-completion-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.chat-completion-actions .secondary-button { min-width: 0; height: 32px; padding: 0 6px; font-size: 10px; }
.chat-completion-actions .secondary-button svg { width: 13px; height: 13px; }
.chat-completion-actions .secondary-button.is-confirmed { border-color: #a7d6d0; background: #eaf8f5; color: var(--teal); }

.workspace-panel { min-width: 0; padding: 28px 30px 36px; }
.workspace-toolbar { height: 52px; display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.workspace-toolbar h1, .history-header h1 { margin: 3px 0 0; font-size: 22px; letter-spacing: 0; }
.workspace-status-title { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.toolbar-eyebrow, .modal-kicker, .empty-kicker { color: var(--accent); font: 700 9px Consolas, monospace; }
.toolbar-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.secondary-button { height: 36px; padding: 0 13px; border: 1px solid var(--line); background: white; font-size: 12px; text-decoration: none; }
.secondary-button:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.secondary-button svg { width: 16px; height: 16px; }
.source-desk { margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfbfc; }
.source-desk { display: none !important; }
.source-desk-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.source-desk-header h2 { margin: 4px 0 4px; font-size: 16px; }
.source-desk-header p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.source-desk-guide { display: flex; align-items: center; gap: 5px; margin-top: 6px !important; color: var(--teal) !important; font-size: 10px !important; }
.source-desk-guide svg { width: 13px; height: 13px; }
.source-desk-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.source-desk-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.source-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.source-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--ink); font-size: 11px; font-weight: 700; }
.source-card-heading span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.source-card-heading svg { width: 14px; height: 14px; color: var(--teal); }
.source-card-count { color: var(--ink-soft); font: 10px Consolas, monospace; font-weight: 400; }
.source-thumbs { display: flex; gap: 5px; min-height: 68px; overflow-x: auto; padding-bottom: 2px; }
.source-thumb { position: relative; flex: 0 0 54px; width: 54px; height: 68px; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-muted); cursor: grab; }
.source-thumb:active { cursor: grabbing; }
.source-thumb:hover { border-color: var(--accent); }
.source-thumb img { width: 100%; height: 100%; object-fit: cover; }
.source-thumb span { position: absolute; left: 3px; bottom: 3px; padding: 2px 4px; border-radius: 3px; background: rgba(20, 21, 24, 0.66); color: white; font: 9px Consolas, monospace; }
.source-empty { display: grid; place-items: center; width: 100%; min-height: 68px; color: var(--ink-soft); font-size: 10px; }
.source-load-button { width: 100%; height: 30px; margin-top: 8px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--teal); font-size: 10px; font-weight: 700; cursor: pointer; }
.source-load-button:hover:not(:disabled) { border-color: var(--teal); background: #f0faf8; }
.source-load-button:disabled { color: #a7a9af; cursor: not-allowed; }
.source-request-card { display: flex; flex-direction: column; }
.source-request-text, .source-handoff-text { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow: auto; }
.source-request-text { flex: 1; max-height: 74px; }
.source-handoff-text { margin-top: 6px; color: var(--accent-dark); max-height: 38px; }
.delivery-desk { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 10px 11px; border-top: 1px solid var(--line); }
.delivery-desk-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.delivery-desk { display: none !important; }
.delivery-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #e9f5f3; color: var(--teal); }
.delivery-icon svg { width: 15px; height: 15px; }
.delivery-desk-info strong { display: block; font-size: 11px; }
.delivery-desk-info p { margin: 3px 0 0; color: var(--ink-soft); font-size: 10px; line-height: 1.4; }
.delivery-desk-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.delivery-count { color: var(--ink-soft); font: 10px Consolas, monospace; white-space: nowrap; }
.preview-stage { position: relative; min-height: 640px; height: calc(100vh - 170px); max-height: 920px; overflow: hidden; background: #24262a; border-radius: var(--radius); }
.sample-image { width: 100%; height: 100%; object-fit: cover; object-position: center 40%; opacity: 0.73; filter: saturate(0.82) contrast(1.02); }
.sample-scrim { position: absolute; inset: 0; background: rgba(16,17,20,0.33); }
.empty-state { position: absolute; left: 38px; right: 38px; bottom: 34px; color: white; }
.empty-state h2 { margin: 8px 0 18px; font-size: 28px; max-width: 520px; letter-spacing: 0; }
.empty-specs { gap: 18px; flex-wrap: wrap; color: rgba(255,255,255,0.82); font-size: 11px; }
.empty-specs span { display: inline-flex; align-items: center; gap: 6px; }
.empty-specs svg { width: 14px; height: 14px; color: #f1b2bf; }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.result-card { position: relative; overflow: hidden; border-radius: var(--radius); background: #dedfe2; aspect-ratio: 2 / 3; }
.result-card:last-child:nth-child(odd) { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.result-card img { width: 100%; height: 100%; object-fit: cover; }
.result-select { position: absolute; top: 9px; left: 9px; z-index: 2; display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 4px; background: rgba(19,20,23,0.70); color: white; font-size: 10px; cursor: pointer; }
.result-select input { width: 13px; height: 13px; margin: 0; accent-color: var(--teal); }
.result-actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 7px; opacity: 0; transform: translateY(5px); transition: opacity 160ms ease, transform 160ms ease; }
.result-card:hover .result-actions, .result-card:focus-within .result-actions { opacity: 1; transform: translateY(0); }
.result-actions .icon-button { color: white; border-color: rgba(255,255,255,0.24); background: rgba(19,20,23,0.74); backdrop-filter: blur(8px); }
.result-index { position: absolute; top: 10px; left: 10px; padding: 5px 7px; border-radius: 4px; background: rgba(19,20,23,0.64); color: white; font: 10px Consolas, monospace; }
.review-badge { position: absolute; top: 10px; right: 10px; padding: 5px 7px; border-radius: 4px; background: rgba(19,20,23,0.7); color: #f2c873; font: 700 10px Consolas, monospace; }
.review-badge.is-pass { color: #8fe1d5; }
.review-badge.is-warn { color: #f4bd7b; }

.history-view { max-width: 1280px; margin: 0 auto; padding: 34px 30px 60px; }
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.history-tools { display: flex; align-items: center; gap: 8px; }
.history-search { width: min(240px, 32vw); height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); outline: none; font-size: 12px; }
.history-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 79, 101, 0.10); }
.history-tools select, .history-tools input[type="date"] { width: 130px; height: 36px; font-size: 11px; }
.history-tools input[type="date"] { padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); }
.task-thumb { display: grid; place-items: center; background: var(--surface-muted); color: var(--accent); }
.task-thumb svg { width: 30px; height: 30px; }
.task-history-item .history-info p { color: var(--accent-dark); }
.history-list { display: grid; gap: 12px; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 18px; }
.history-empty { min-height: 420px; display: grid; place-items: center; text-align: center; color: var(--ink-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-empty svg { width: 28px; height: 28px; margin: 0 auto 12px; color: var(--accent); }
.history-empty h2 { color: var(--ink); font-size: 17px; margin: 0 0 6px; }
.history-empty p { margin: 0; font-size: 12px; }
.history-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .history-thumbs { height: 92px; display: flex; overflow: hidden; border-radius: 4px; background: #e3e4e7; }
  .history-thumbs img { width: 100%; min-width: 0; object-fit: cover; border-right: 1px solid rgba(255,255,255,0.6); }
  .history-thumb-button { flex: 1 1 0; min-width: 0; height: 100%; padding: 0; border: 0; overflow: hidden; background: transparent; cursor: zoom-in; }
  .history-thumb-button:hover img, .history-thumb-button:focus-visible img { transform: scale(1.04); filter: brightness(0.9); }
  .history-thumb-button img { display: block; height: 100%; transition: transform 160ms ease, filter 160ms ease; }
.history-info h2 { font-size: 14px; margin: 0 0 7px; }
.history-info p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.workflow-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.workflow-chip { padding: 4px 6px; border-radius: 4px; background: #f1f2f4; color: var(--ink-soft); font-size: 10px; }
.workflow-chip.is-due { color: var(--accent-dark); background: #fff2f4; }
.intake-item { align-items: start; }
.intake-item.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201, 79, 101, 0.08); }
.intake-thumbs { min-width: 150px; }
.intake-request { margin-top: 9px !important; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.intake-error { margin-top: 7px !important; color: var(--danger) !important; }
.intake-status-select { height: 34px; min-width: 88px; font-size: 11px; }
.intake-submit-button { width: 100%; height: 36px; margin-top: 8px; color: var(--teal); }
.intake-submit-button:disabled { color: #9da0a7; cursor: not-allowed; }
.history-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.danger-button { color: var(--danger); }

.modal { border: 0; border-radius: 8px; background: white; color: var(--ink); box-shadow: var(--shadow); padding: 0; }
.modal::backdrop { background: rgba(18, 19, 22, 0.72); backdrop-filter: blur(4px); }
.asset-library-dialog { width: min(920px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); overflow: hidden; }
.asset-library-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 15px; border-bottom: 1px solid var(--line); }
.asset-library-header h2 { margin: 5px 0 4px; font-size: 19px; }
.asset-library-header p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.asset-library-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.asset-library-kinds { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.asset-kind-tab { min-height: 29px; padding: 0 9px; border: 0; border-radius: 3px; background: transparent; color: var(--ink-soft); font-size: 11px; cursor: pointer; }
.asset-kind-tab.is-active { background: var(--ink); color: white; }
.asset-library-toolbar .history-search { flex: 1; min-width: 120px; height: 34px; box-sizing: border-box; }
.asset-upload-button { flex: 0 0 auto; height: 34px; box-sizing: border-box; }
.asset-library-note { margin: 0; padding: 10px 22px 0; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }
.asset-library-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; max-height: 570px; overflow-y: auto; padding: 14px 22px 22px; }
.asset-library-empty { grid-column: 1 / -1; min-height: 220px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--ink-soft); font-size: 11px; text-align: center; }
.asset-library-empty svg { width: 30px; height: 30px; color: var(--accent); }
.asset-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: white; }
.asset-card-media { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border: 0; background: #e6e7ea; cursor: pointer; }
.asset-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.asset-card-media:hover img { transform: scale(1.03); }
.asset-card-add { position: absolute; right: 7px; bottom: 7px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: rgba(20, 21, 24, 0.8); color: white; }
.asset-card-add svg { width: 14px; height: 14px; }
.asset-card-info { display: grid; gap: 3px; padding: 8px 8px 3px; }
.asset-card-info strong { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.asset-card-info small { color: var(--ink-soft); font-size: 9px; }
.asset-card-actions { display: flex; align-items: center; gap: 4px; padding: 5px 7px 7px; }
.asset-card-use { min-width: 0; flex: 1; height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--teal); font-size: 10px; cursor: pointer; }
.asset-card-use:hover { border-color: var(--teal); background: #f2fbfa; }
.asset-card-use svg { width: 12px; height: 12px; }
.asset-card-delete { width: 28px; height: 28px; padding: 0; color: var(--danger); }
.asset-card-delete svg { width: 13px; height: 13px; }
.asset-library-item { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: white; }
.asset-library-select { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border: 0; background: #e6e7ea; cursor: pointer; }
.asset-library-select img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.asset-library-select:hover img { transform: scale(1.03); }
.asset-library-add { position: absolute; right: 7px; bottom: 7px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: rgba(20, 21, 24, 0.8); color: white; }
.asset-library-add svg { width: 14px; height: 14px; }
.asset-library-item-footer { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 7px; }
.asset-library-item-footer > span { min-width: 0; flex: 1; overflow: hidden; color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.asset-library-delete { width: 28px; height: 28px; flex: 0 0 auto; padding: 0; color: var(--danger); }
.asset-library-delete svg { width: 13px; height: 13px; }
.asset-library-grid.is-dragging { outline: 2px dashed var(--accent); outline-offset: -7px; background: #fff7f8; }
.addon-remove { position: absolute; top: 7px; right: 7px; z-index: 3; width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(20, 21, 24, 0.82); color: white; cursor: pointer; }
.addon-remove svg { width: 13px; height: 13px; }
.progress-modal { width: min(430px, calc(100vw - 32px)); padding: 34px; text-align: center; }
.progress-visual { width: 74px; height: 74px; position: relative; margin: 0 auto 22px; display: grid; place-items: center; }
.focus-frame { width: 48px; height: 48px; display: grid; place-items: center; color: var(--accent); }
.focus-frame svg { width: 31px; height: 31px; }
.progress-ring { position: absolute; inset: 0; border: 2px solid #eceef1; border-top-color: var(--accent); border-right-color: var(--teal); border-radius: 50%; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-modal h2 { margin: 8px 0 9px; font-size: 20px; }
.progress-modal p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.progress-track { height: 5px; background: #e9eaed; margin-top: 24px; overflow: hidden; border-radius: 2px; }
.progress-track span { display: block; width: 12%; height: 100%; background: var(--accent); transition: width 700ms ease; }
.progress-meta { justify-content: space-between; margin-top: 8px; color: var(--ink-soft); font: 10px Consolas, monospace; }
.generation-status-card { position: fixed; right: 24px; bottom: 24px; z-index: 70; width: min(380px, calc(100vw - 32px)); padding: 14px 15px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,0.98); color: var(--ink); box-shadow: 0 14px 34px rgba(26,29,35,0.18); }
.generation-status-card[hidden] { display: none; }
.generation-status-card .progress-visual { display: none; }
.generation-status-card .modal-kicker { display: block; margin-bottom: 5px; }
.generation-status-card h2 { margin: 0; font-size: 15px; }
.generation-status-card p { margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.generation-status-task { display: block; margin-top: 2px; color: var(--ink); font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generation-status-card .progress-track { height: 5px; margin-top: 11px; }
.generation-status-card .progress-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.generation-status-card.is-failed { border-color: #e7aeb7; }
.generation-status-card.is-failed .progress-track span { background: var(--danger); }
.generation-status-card.is-complete { border-color: #a7d6d0; }
.status-action { margin-left: auto; padding: 0; border: 0; background: transparent; color: var(--teal); font: inherit; cursor: pointer; }
.status-action:hover { color: var(--accent-dark); text-decoration: underline; }
.viewer-modal { width: min(1100px, calc(100vw - 36px)); height: min(88vh, 900px); background: #151619; overflow: hidden; }
.viewer-modal img { width: 100%; height: 100%; object-fit: contain; }
.viewer-close { position: absolute; top: 12px; right: 12px; z-index: 2; color: white; border-color: rgba(255,255,255,0.2); background: rgba(10,10,12,0.7); }
.viewer-download { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); color: white; border-color: rgba(255,255,255,0.24); background: rgba(10,10,12,0.72); }
.assistant-dialog { width: min(560px, calc(100vw - 30px)); max-height: min(760px, calc(100vh - 30px)); padding: 0; overflow: hidden; }
.assistant-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 20px 15px; border-bottom: 1px solid var(--line); }
.assistant-dialog-header h2 { margin: 5px 0 4px; font-size: 19px; }
.assistant-dialog-header p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.assistant-messages { min-height: 280px; max-height: 52vh; overflow-y: auto; padding: 16px 18px; background: #f8f9fa; }
.assistant-message { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 12px; }
.assistant-message.is-own { align-items: flex-end; }
.assistant-bubble { max-width: 88%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px 8px 8px 3px; background: white; font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-message.is-own .assistant-bubble { border-color: #f0c7cf; border-radius: 8px 8px 3px 8px; background: #fff3f5; }
.assistant-message time { color: #a0a3aa; font: 9px Consolas, monospace; }
.assistant-empty { min-height: 240px; display: grid; align-content: center; justify-items: center; gap: 9px; color: var(--ink-soft); text-align: center; font-size: 11px; }
.assistant-empty svg { width: 30px; height: 30px; color: var(--accent); }
.assistant-composer { padding: 12px 16px 16px; border-top: 1px solid var(--line); background: white; }
.assistant-composer textarea { min-height: 76px; max-height: 180px; font-size: 12px; }
.assistant-composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
.assistant-composer-footer > span { color: var(--ink-soft); font-size: 9px; line-height: 1.4; }
.assistant-composer-footer .primary-button { width: auto; height: 35px; padding: 0 12px; }
.assistant-composer-footer .primary-button svg { width: 14px; height: 14px; }
.setup-modal { width: min(440px, calc(100vw - 32px)); padding: 26px; }
.modal-header { justify-content: space-between; }
.modal-header h2 { margin: 5px 0 0; font-size: 20px; }
.setup-status-row { gap: 12px; margin-top: 22px; padding: 14px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius); }
.setup-status-row > div { display: grid; gap: 3px; }
.setup-status-row strong { font-size: 13px; }
.setup-status-row span:last-child { color: var(--ink-soft); font-size: 11px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.setup-item { padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 5px; }
.setup-item span, .setup-command span { color: var(--ink-soft); font-size: 10px; }
.setup-item strong { font: 700 12px Consolas, monospace; }
.setup-command { margin-top: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 7px; }
.setup-command code { font-size: 12px; color: var(--accent-dark); }
.text-link { margin-top: 18px; width: fit-content; gap: 5px; color: var(--teal); font-size: 12px; text-decoration: none; }
.text-link svg { width: 14px; height: 14px; }
.api-config-panel { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.api-config-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.api-config-heading h3 { margin: 4px 0 0; font-size: 14px; }
.api-config-subtitle { margin: 4px 0 0; color: var(--ink-soft); font-size: 10px; }
.api-config-panel label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 11px; }
.api-config-panel input { width: 100%; box-sizing: border-box; }
.api-config-panel small { color: var(--ink-soft); line-height: 1.45; }
.api-config-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.api-config-message { min-height: 18px; margin: 0; color: var(--teal); font-size: 11px; line-height: 1.5; }
.api-config-message.is-error { color: var(--danger); }
.api-config-note { margin: 0; color: var(--ink-soft); font-size: 10px; line-height: 1.55; }
.api-config-backup { display: grid; gap: 10px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.provider-status-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.provider-status-item { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.provider-status-item > div { display: grid; gap: 2px; min-width: 0; }
.provider-status-item strong, .provider-status-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-status-item strong { font-size: 11px; }
.provider-status-item small { color: var(--ink-soft); font-size: 9px; }
.provider-status-item.is-ready .status-dot { background: var(--teal); }
.provider-status-item.is-error .status-dot { background: var(--danger); }
@media (max-width: 560px) { .provider-status-list { grid-template-columns: 1fr; } }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 8px; min-height: 40px; max-width: min(520px, calc(100vw - 32px)); padding: 9px 13px; border-radius: var(--radius); background: #202226; color: white; box-shadow: var(--shadow); font-size: 12px; transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error svg { color: #ff8595; }
.toast svg { width: 16px; height: 16px; color: #76d1c6; flex: 0 0 auto; }

.auth-shell { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: #f3f4f6; }
.auth-panel { width: min(410px, 100%); padding: 30px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 38px; }
.auth-brand .brand-mark { width: 34px; height: 34px; }
.auth-brand strong { display: block; font-size: 17px; }
.auth-brand div > span { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 10px; }
.auth-panel h1 { margin: 7px 0 8px; font-size: 24px; }
.auth-note { margin: 0 0 22px; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.auth-form input { height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); outline: none; }
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 79, 101, 0.1); }
.auth-form .primary-button { margin-top: 5px; }
.auth-error { min-height: 18px; margin-top: 11px; color: var(--danger); font-size: 11px; line-height: 1.5; }
.users-panel { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.users-panel-heading { display: flex; justify-content: space-between; align-items: center; }
.users-panel h3 { margin: 4px 0 0; font-size: 14px; }
.create-user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.create-user-form input, .create-user-form select { min-width: 0; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; }
.create-user-form select { grid-column: 1 / 2; }
.create-user-form button { grid-column: 2 / 3; height: 34px; padding: 0 8px; }
.users-list { display: grid; gap: 6px; margin-top: 10px; max-height: 180px; overflow-y: auto; }
.user-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px; align-items: center; padding: 8px; background: var(--surface-muted); border-radius: 4px; font-size: 11px; }
.user-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row select { height: 28px; border: 1px solid var(--line); border-radius: 4px; font-size: 10px; }
.user-row button { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); background: white; border-radius: 4px; cursor: pointer; color: var(--danger); }
.user-row button svg { width: 13px; height: 13px; }

@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr auto; }
  .main-tabs { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 40; height: 48px; padding: 4px; border: 1px solid var(--line); background: rgba(255,255,255,0.96); border-radius: 8px; box-shadow: var(--shadow); }
  .tab-button { min-width: 108px; border-radius: 5px; }
  .tab-button::after { display: none; }
  .tab-button.is-active { background: var(--ink); color: white; }
  .studio-view { grid-template-columns: 360px minmax(0, 1fr); }
  .workspace-panel { padding: 24px 20px 86px; }
  .preview-stage { min-height: 560px; }
  .source-desk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-view { padding-bottom: 100px; }
}

@media (min-width: 1100px) {
  .studio-view { grid-template-columns: minmax(460px, 500px) minmax(0, 1fr); align-items: start; }
  .config-panel { max-height: calc(100vh - var(--header-height)); overflow-y: auto; scrollbar-gutter: stable; }
  .workspace-panel { position: sticky; top: var(--header-height); min-height: calc(100vh - var(--header-height)); }
  .preview-stage { min-height: 380px; height: max(380px, calc(100vh - 405px)); }
  .lookSection { background: #fff8f9; }
}

@media (min-width: 1400px) {
  .studio-view { grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); grid-template-rows: auto minmax(0, 1fr); align-items: start; }
  .config-panel { grid-column: 1; grid-row: 1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-content: start; max-height: none; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .config-panel > .config-section:first-child { grid-column: 1 / -1; }
  .config-panel > .config-section:nth-child(2), .config-panel > .config-section:nth-child(3), .config-panel > .config-section:nth-child(4), .config-panel > .config-section:nth-child(5), .config-panel > .config-section:nth-child(6) { min-width: 0; }
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .chat-panel { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: var(--header-height); height: calc(100vh - var(--header-height)); border-right: 0; border-left: 1px solid var(--line); }
  .workspace-panel { grid-column: 1; grid-row: 2; position: static; min-height: calc(100vh - var(--header-height)); }
  .people-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .preview-stage { min-height: 560px; height: max(560px, calc(100vh - 420px)); }
}

@media (min-width: 981px) and (max-width: 1399px) {
  .studio-view { grid-template-columns: minmax(360px, 430px) minmax(0, 1fr); }
  .chat-panel { grid-column: 1 / -1; grid-row: 2; min-height: 500px; max-height: 680px; border-top: 1px solid var(--line); border-right: 0; }
  .workspace-panel { grid-column: 1 / -1; grid-row: 3; position: static; }
  .chat-messages { min-height: 300px; }
}

@media (max-width: 760px) {
  :root { --header-height: 62px; }
  .app-header { padding: 0 14px; }
  .brand-subtitle, .status-label { display: none; }
  .assistant-button span { display: none; }
  .assistant-button { width: 36px; padding: 0; justify-content: center; }
  .brand-lockup { min-width: 0; }
  .user-chip { display: none; }
  .api-status { width: 36px; padding: 0; justify-content: center; }
  .asset-library-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .asset-library-header, .asset-library-toolbar { padding-left: 14px; padding-right: 14px; }
  .asset-library-toolbar { flex-wrap: wrap; }
  .asset-library-kinds { order: 1; width: 100%; }
  .asset-kind-tab { flex: 1; }
  .asset-library-toolbar .history-search { order: 2; min-width: 0; }
  .asset-upload-button { order: 3; }
  .asset-library-note { padding-left: 14px; padding-right: 14px; }
  .asset-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: calc(100vh - 225px); padding-left: 14px; padding-right: 14px; }
  .studio-view { display: block; }
  .config-panel { border-right: 0; max-height: none; overflow: visible; }
  .chat-panel { min-height: 520px; border-top: 8px solid var(--bg); border-right: 0; }
  .chat-composer-row { grid-template-columns: minmax(0, 1fr) auto; }
  .chat-send-button { grid-column: 1 / -1; }
  .config-section { padding: 20px 16px; }
  .people-grid { gap: 6px; }
  .style-upload { height: 132px; }
  .style-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .addon-grid { gap: 7px; }
  .workflow-section .profile-grid { gap: 8px; }
  .generate-bar { padding: 14px 16px 76px; }
  .workspace-panel { padding: 24px 16px 94px; border-top: 8px solid var(--bg); }
  .workspace-panel { position: static; }
  .source-desk { padding: 12px; }
  .source-desk-header { display: block; }
  .source-desk-actions { justify-content: flex-start; margin-top: 10px; }
  .source-desk-grid { grid-template-columns: 1fr 1fr; }
  .delivery-desk { align-items: flex-start; flex-direction: column; }
  .delivery-desk-actions { width: 100%; justify-content: space-between; }
  .preview-stage { height: 66vh; min-height: 520px; max-height: 720px; }
  .generation-status-card { right: 12px; bottom: 76px; width: min(360px, calc(100vw - 24px)); }
  .empty-state { left: 22px; right: 22px; bottom: 24px; }
  .empty-state h2 { font-size: 22px; }
  .empty-specs { gap: 12px; }
  .results-grid { gap: 8px; }
  .result-actions { opacity: 1; transform: none; }
  .history-view { padding: 24px 16px 92px; }
  .history-header { display: block; }
  .history-tools { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .history-search { width: 100%; grid-column: 1 / -1; }
  .history-tools select, .history-tools input[type="date"] { width: 100%; }
  .history-item { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .history-thumbs { height: 78px; }
  .intake-thumbs { min-width: 96px; }
  .history-actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 10px; }
}

@media (max-width: 430px) {
  .tab-button { min-width: 90px; padding: 0 8px; gap: 5px; font-size: 11px; }
  .settings-row { gap: 11px; }
  .stepper { width: 116px; }
  .workspace-toolbar h1, .history-header h1 { font-size: 19px; }
  .secondary-button span { display: none; }
  .toolbar-actions .secondary-button { width: 36px; padding: 0; }
  .history-tools .secondary-button { width: 36px; padding: 0; }
  .preview-stage { min-height: 470px; }
  .empty-specs span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Desktop operations layout: H5 order queue on the left, generation workbench in the center, service chat on the right. */
@media (min-width: 981px) {
  .studio-view {
    grid-template-columns: minmax(238px, 268px) minmax(0, 1fr) minmax(316px, 352px) !important;
    grid-template-rows: minmax(360px, 54vh) minmax(300px, 1fr) !important;
    min-height: calc(100vh - var(--header-height));
    align-items: stretch;
  }
  .order-queue-panel {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    height: calc(100vh - var(--header-height));
    border-right: 1px solid var(--line);
    border-left: 0;
  }
  .config-panel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: block !important;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-gutter: stable;
  }
  .workspace-panel {
    grid-column: 2 !important;
    grid-row: 2 !important;
    position: static !important;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px 22px;
    border-bottom: 0;
    scrollbar-gutter: stable;
  }
  .chat-panel {
    grid-column: 3 !important;
    grid-row: 1 / span 2 !important;
    position: static !important;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    border-left: 1px solid var(--line);
    border-right: 0;
  }
}

/* Compact output board: keep progress and deliverables visible without a large preview canvas. */
.preview-stage.generation-board {
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8f9;
}
.preview-stage.generation-board .sample-image,
.preview-stage.generation-board .sample-scrim,
.preview-stage.generation-board .empty-state { display: none !important; }
.generation-board-count { color: var(--ink-soft); font: 10px Consolas, monospace; }
.generation-task-list { display: grid; gap: 7px; max-height: 330px; overflow-y: auto; padding-right: 2px; scrollbar-gutter: stable; }
.generation-empty { min-height: 105px; display: grid; place-items: center; align-content: center; gap: 5px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 5px; background: white; color: var(--ink-soft); text-align: center; }
.generation-empty strong { color: var(--ink); font-size: 13px; }
.generation-empty > span:last-child { font-size: 10px; line-height: 1.4; }
.generation-task-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.generation-task-card.is-generating, .generation-task-card.is-queued { border-color: #c9e3df; }
.generation-task-card.is-completed { border-color: #b9ddd8; }
.generation-task-card.is-failed { border-color: #e8b9c0; background: #fffafb; }
.generation-task-thumbs { display: flex; gap: 4px; min-width: 58px; max-width: 238px; overflow: hidden; }
.generation-task-thumb { position: relative; display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 64px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-muted); color: var(--ink-soft); }
.generation-task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.generation-task-thumb.is-result { padding: 0; cursor: zoom-in; }
.generation-task-thumb.is-result:hover { border-color: var(--accent); }
.generation-task-thumb > span { position: absolute; right: 2px; bottom: 2px; padding: 1px 3px; border-radius: 2px; background: rgba(20,21,24,0.68); color: white; font: 8px Consolas, monospace; }
.generation-task-thumb.is-placeholder svg { width: 18px; height: 18px; }
.generation-task-main { min-width: 0; }
.generation-task-title, .generation-task-meta, .generation-task-foot { display: flex; align-items: center; gap: 7px; min-width: 0; }
.generation-task-title { justify-content: space-between; }
.generation-task-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.generation-task-status { flex: 0 0 auto; padding: 3px 5px; border-radius: 3px; background: #eef1f2; color: var(--ink-soft); font-size: 9px; }
.is-generating .generation-task-status, .is-queued .generation-task-status { background: #e8f7f4; color: var(--teal); }
.is-completed .generation-task-status { background: #e8f7f4; color: var(--teal); }
.is-failed .generation-task-status { background: #fff0f2; color: var(--danger); }
.generation-task-meta { margin-top: 4px; color: var(--ink-soft); font-size: 9px; }
.generation-task-meta span:last-child { margin-left: auto; font-family: Consolas, monospace; }
.generation-task-progress { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 2px; background: #e8eaed; }
.generation-task-progress span { display: block; height: 100%; border-radius: inherit; background: var(--teal); transition: width 360ms ease; }
.is-failed .generation-task-progress span { background: var(--danger); }
.generation-task-foot { margin-top: 5px; color: var(--ink-soft); font-size: 9px; }
.generation-task-foot span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generation-task-foot strong { flex: 0 0 auto; color: var(--ink); font: 700 10px Consolas, monospace; }
.generation-task-open { height: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--teal); font-size: 10px; cursor: pointer; white-space: nowrap; }
.generation-task-open:hover { border-color: var(--teal); background: #f0faf8; }
.results-grid { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; margin-top: 9px; }
.result-card { min-width: 0; aspect-ratio: 3 / 4; border-radius: 5px; }
.result-card:last-child:nth-child(odd) { grid-column: auto; aspect-ratio: 3 / 4; }
.result-card img { object-fit: cover; }
.result-index { top: 5px; left: 5px; padding: 3px 5px; font-size: 9px; }
.result-select { top: 5px; left: 5px; padding: 3px 5px; font-size: 9px; }
.result-actions { right: 5px; bottom: 5px; gap: 4px; opacity: 1; transform: none; }
.result-actions .icon-button { width: 28px; height: 28px; }
.result-actions .icon-button svg { width: 14px; height: 14px; }
.review-badge { top: 5px; right: 5px; padding: 3px 5px; font-size: 8px; }
.generation-status-card { width: min(320px, calc(100vw - 32px)); right: 16px; bottom: 16px; padding: 11px 12px 10px; }

@media (max-width: 980px) {
  .preview-stage.generation-board { margin-top: 0; }
  .generation-task-list { max-height: none; }
}

/* Desktop operations workspace: queue, generation controls/results, and H5 handoff stay visible together. */
.order-queue-panel { min-width: 0; display: flex; flex-direction: column; background: #fbfbfc; border-right: 1px solid var(--line); }
.order-queue-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 14px 12px; background: white; border-bottom: 1px solid var(--line); }
.order-queue-header h2 { margin: 4px 0 0; font-size: 15px; }
.queue-live-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(22,120,111,0.10); }
.queue-active-context { margin: 9px 9px 0; padding: 9px; border: 1px solid #cde6e2; border-radius: 5px; background: #f4fbfa; }
.queue-context-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; color: var(--teal); font-size: 10px; font-weight: 700; }
.queue-context-heading > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.queue-context-heading svg { width: 13px; height: 13px; }
.queue-context-heading > span:last-child { color: var(--ink-soft); font: 9px Consolas, monospace; font-weight: 400; }
.queue-active-context > strong { display: block; overflow: hidden; color: var(--ink); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.queue-active-context > p { margin: 4px 0 0; color: var(--ink-soft); font-size: 9px; line-height: 1.45; }
.queue-context-request { max-height: 44px; overflow: auto; white-space: pre-wrap; }
.queue-context-materials { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 7px; }
.queue-context-thumb { position: relative; min-width: 0; height: 43px; padding: 0; overflow: hidden; border: 1px solid #cde6e2; border-radius: 3px; background: #e6f2f0; cursor: pointer; }
.queue-context-thumb:hover { border-color: var(--teal); }
.queue-context-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-context-thumb span { position: absolute; right: 2px; bottom: 2px; left: 2px; overflow: hidden; padding: 1px 2px; border-radius: 2px; background: rgba(20,21,24,0.68); color: white; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.queue-tools { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 6px; padding: 10px 12px 8px; background: white; }
.queue-search-wrap { min-width: 0; height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-muted); color: var(--ink-soft); }
.queue-search-wrap:focus-within { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(201,79,101,0.08); }
.queue-search-wrap svg { width: 14px; height: 14px; flex: 0 0 auto; }
.queue-search-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.queue-tools .icon-button { width: 34px; height: 34px; }
.queue-status-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 0 12px 9px; background: white; border-bottom: 1px solid var(--line); }
.queue-status-tab { min-width: 0; min-height: 31px; padding: 0 4px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-soft); font-size: 10px; cursor: pointer; white-space: nowrap; }
.queue-status-tab span { margin-left: 2px; color: #9a9da4; font: 10px Consolas, monospace; }
.queue-status-tab:hover { background: var(--surface-muted); color: var(--ink); }
.queue-status-tab.is-active { background: #fff0f3; color: var(--accent-dark); font-weight: 700; }
.queue-status-tab.is-active span { color: var(--accent-dark); }
.workspace-queue-list { min-height: 0; flex: 1; overflow-y: auto; padding: 9px; scrollbar-gutter: stable; }
.workspace-queue-item { position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; min-width: 0; margin-bottom: 7px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
.workspace-queue-item:hover { border-color: var(--line-strong); background: #fff; box-shadow: 0 3px 12px rgba(26,29,35,0.05); }
.workspace-queue-item.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201,79,101,0.10); }
.queue-item-thumb { width: 42px; height: 52px; display: grid; place-items: center; overflow: hidden; border-radius: 4px; background: #eef0f2; color: var(--teal); }
.queue-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-item-thumb svg { width: 18px; height: 18px; }
.queue-item-main { min-width: 0; }
.queue-item-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 5px; min-width: 0; }
.queue-item-title strong { min-width: 0; overflow: hidden; color: var(--ink); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-status { flex: 0 0 auto; padding: 3px 4px; border-radius: 3px; background: #f1f2f4; color: var(--ink-soft); font-size: 9px; line-height: 1; }
.queue-item-status.is-generating { background: #eef5ff; color: #3565a8; }
.queue-item-status.is-completed { background: #eaf8f5; color: var(--teal); }
.queue-item-status.is-failed { background: #fff0f1; color: var(--danger); }
.queue-item-main p { margin: 4px 0 0; overflow: hidden; color: var(--ink-soft); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-meta { display: flex; align-items: center; gap: 4px; min-width: 0; margin-top: 6px; overflow: hidden; color: #9a9da4; font-size: 9px; }
.queue-item-meta > span:first-child { flex: 0 0 auto; }
.queue-item-progress { color: #3565a8; font-family: Consolas, monospace; }
.queue-item-tag { max-width: 64px; overflow: hidden; padding: 2px 3px; border-radius: 2px; background: #f3f3f5; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-progress-track { height: 3px; margin-top: 6px; overflow: hidden; border-radius: 4px; background: #e7e9ed; }
.queue-item-progress-track span { display: block; height: 100%; border-radius: inherit; background: #4f8be8; }
.queue-item-actions { grid-column: 2; min-height: 17px; display: flex; align-items: center; justify-content: flex-end; margin-top: 1px; }
.queue-claim-button { height: 24px; padding: 0 7px; border: 1px solid #b8dcd7; border-radius: 4px; background: #eef9f7; color: var(--teal); font-size: 9px; font-weight: 700; cursor: pointer; }
.queue-claim-button:hover { border-color: var(--teal); background: #e3f5f1; }
.queue-claim-state { color: #9a9da4; font-size: 9px; }
.queue-empty { min-height: 220px; display: grid; align-content: center; justify-items: center; gap: 7px; padding: 20px 10px; color: var(--ink-soft); text-align: center; }
.queue-empty svg { width: 27px; height: 27px; color: var(--accent); }
.queue-empty strong { color: var(--ink); font-size: 12px; }
.queue-empty span { max-width: 180px; font-size: 10px; line-height: 1.5; }
.queue-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--line); background: white; color: var(--ink-soft); font-size: 9px; }
.queue-open-intake { display: inline-flex; align-items: center; gap: 3px; padding: 0; border: 0; background: transparent; color: var(--teal); font-size: 9px; cursor: pointer; white-space: nowrap; }
.queue-open-intake:hover { color: var(--accent-dark); }
.queue-open-intake svg { width: 12px; height: 12px; }
.chat-materials { padding: 9px 11px 10px; border-bottom: 1px solid var(--line); background: #fbfbfc; }
.chat-materials-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: var(--ink-soft); font-size: 10px; }
.chat-materials-heading > span:first-child { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-weight: 700; }
.chat-materials-heading svg { width: 13px; height: 13px; color: var(--teal); }
.chat-materials-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.chat-material-thumb { position: relative; min-width: 0; height: 49px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #e8eaed; cursor: pointer; }
.chat-material-thumb:hover { border-color: var(--accent); }
.chat-material-thumb img { width: 100%; height: 100%; object-fit: cover; }
.chat-material-thumb span { position: absolute; right: 2px; bottom: 2px; left: 2px; overflow: hidden; padding: 2px 3px; border-radius: 2px; background: rgba(20,21,24,0.68); color: white; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.asset-group-select { min-width: 132px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); font-size: 11px; }
.asset-group-select:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px rgba(201,79,101,0.08); }

@media (min-width: 1200px) {
  .studio-view { grid-template-columns: minmax(238px, 268px) minmax(0, 1fr) minmax(316px, 352px); grid-template-rows: minmax(390px, 54vh) minmax(340px, 1fr); min-height: calc(100vh - var(--header-height)); align-items: stretch; }
  .order-queue-panel { grid-column: 3; grid-row: 1 / span 2; height: calc(100vh - var(--header-height)); border-right: 0; border-left: 1px solid var(--line); }
  .config-panel { grid-column: 2; grid-row: 1; max-height: none; min-height: 0; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line); display: block; }
  .config-panel > .config-section { min-width: 0; }
  .config-panel > .generate-bar { min-width: 0; }
  .workspace-panel { grid-column: 2; grid-row: 2; position: static; min-height: 0; overflow-y: auto; padding: 20px 22px 28px; border-bottom: 0; }
  .workspace-toolbar { margin-bottom: 12px; }
  .workspace-toolbar h1 { font-size: 19px; }
  .preview-stage { height: 360px; min-height: 360px; max-height: none; }
  .chat-panel { grid-column: 1; grid-row: 1 / span 2; position: static; height: calc(100vh - var(--header-height)); min-height: 0; grid-template-rows: auto auto minmax(180px, 1fr) auto auto; border-right: 1px solid var(--line); border-left: 0; }
  .chat-messages { min-height: 0; }
}

@media (min-width: 981px) and (max-width: 1199px) {
  .studio-view { grid-template-columns: 224px minmax(0, 1fr) 292px; grid-template-rows: minmax(360px, 53vh) minmax(320px, 1fr); }
  .order-queue-panel { grid-column: 3; grid-row: 1 / span 2; height: calc(100vh - var(--header-height)); border-right: 0; border-left: 1px solid var(--line); }
  .config-panel { grid-column: 2; grid-row: 1; max-height: none; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line); display: block; }
  .workspace-panel { grid-column: 2; grid-row: 2; min-height: 0; overflow-y: auto; padding: 18px; }
  .chat-panel { grid-column: 1; grid-row: 1 / span 2; height: calc(100vh - var(--header-height)); grid-template-rows: auto auto minmax(160px, 1fr) auto auto; border-right: 1px solid var(--line); border-left: 0; }
  .preview-stage { height: 320px; min-height: 320px; }
}

@media (max-width: 980px) {
  .order-queue-panel { min-height: 280px; max-height: 420px; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace-queue-list { max-height: 290px; }
  .chat-panel { grid-template-rows: auto auto minmax(240px, 1fr) auto auto; }
}

@media (max-width: 760px) {
  .asset-group-select { flex: 1 1 150px; min-width: 0; }
}

/* Wide desktop workbench: keep the main generation flow on one screen. */
/* Compact popover-style controls are shared by desktop widths. */
.quick-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #f7f8fa; }
.quick-control-field { min-width: 0; margin: 0 !important; }
.quick-control-field > label, .quick-control-field > .field-label-row > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.quick-control-field > .field-label-row { margin: 0; }
.quick-control-field select, .quick-control-field .aspect-trigger, .quick-control-field .stepper { height: 32px; min-width: 0; border-radius: 5px; font-size: 10px; }
.quick-control-field select { width: auto; max-width: 150px; padding: 0 8px; }
.quick-control-field .stepper { width: 92px; grid-template-columns: 28px 1fr 28px; }
.quick-control-field .aspect-picker { min-width: 118px; }
.quick-control-field .aspect-trigger { padding: 0 7px; }
.quick-control-field .segmented-control { height: 32px; padding: 2px; gap: 2px; border-radius: 5px; }
.quick-control-field .segment { height: 27px; min-width: 34px; padding: 0 7px; font-size: 9px; border-radius: 4px; }
.prompt-framework { margin-top: 9px; }
.prompt-framework-field { margin: 0 !important; }
.prompt-framework-field textarea { min-height: 70px; max-height: 118px; }
.prompt-framework-field small { display: none; }
.prompt-framework-field .prompt-file-picker { margin-top: 6px; }

@media (min-width: 1280px) {
  .studio-view {
    grid-template-columns: minmax(248px, 290px) minmax(320px, 390px) minmax(420px, 1fr) minmax(228px, 270px) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    overflow: hidden;
  }
  .chat-panel {
    grid-column: 1 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
  }
  .config-panel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    scrollbar-gutter: stable;
  }
  .workspace-panel {
    grid-column: 3 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px 18px;
    border-right: 1px solid var(--line);
  }
  .order-queue-panel {
    grid-column: 4 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    border-right: 0;
    border-left: 1px solid var(--line);
  }
  .config-section { padding: 16px 16px 14px; }
  .config-panel {
    display: grid !important;
    grid-template-columns: minmax(0, 1.35fr) minmax(132px, .65fr);
    align-content: start;
  }
  .config-panel > .config-section:first-child,
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .config-panel > #styleSection { grid-column: 1; }
  .config-panel > #lookSection { grid-column: 2; }
  #styleSection .style-upload { height: 156px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 7px; }
  #lookSection .addon-upload { min-height: 70px; padding: 8px; gap: 4px; }
  #lookSection .addon-icon { width: 23px; height: 23px; }
  #lookSection .addon-name { font-size: 10px; }
  #lookSection .addon-file { font-size: 9px; }
  #lookSection .upload-hint { display: none; }
  .quick-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 13px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7f8fa;
  }
  .quick-control-field { min-width: 0; margin: 0 !important; }
  .quick-control-field > label,
  .quick-control-field > .field-label-row > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .quick-control-field > .field-label-row { margin: 0; }
  .quick-control-field select,
  .quick-control-field .aspect-trigger,
  .quick-control-field .stepper { height: 32px; min-width: 0; border-radius: 5px; font-size: 10px; }
  .quick-control-field select { width: auto; max-width: 132px; padding: 0 8px; }
  .quick-control-field .stepper { width: 92px; grid-template-columns: 28px 1fr 28px; }
  .quick-control-field .stepper output { font-size: 11px; }
  .quick-control-field .aspect-picker { min-width: 118px; }
  .quick-control-field .aspect-trigger { padding: 0 7px; }
  .quick-control-field .segmented-control { height: 32px; padding: 2px; gap: 2px; border-radius: 5px; }
  .quick-control-field .segment { height: 27px; min-width: 34px; padding: 0 7px; font-size: 9px; border-radius: 4px; }
  .prompt-framework { margin-top: 9px; }
  .prompt-framework-field { margin: 0 !important; }
  .prompt-framework-field textarea { min-height: 70px; max-height: 118px; }
  .prompt-framework-field small { display: none; }
  .prompt-framework-field .prompt-file-picker { margin-top: 6px; }
  .advanced-settings { margin-top: 12px; }
  .section-heading { margin-bottom: 10px; }
  .section-heading h2 { font-size: 14px; }
  .people-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .upload-hint, .workflow-note { margin-top: 7px; font-size: 9px; }
  .style-upload { height: 112px; }
  .addon-upload { min-height: 92px; padding: 10px; }
  .field-group { margin-top: 11px; }
  .field-group > label, .range-field label, .field-label-row label { margin-bottom: 5px; font-size: 10px; }
  .profile-grid { gap: 8px; }
  .profile-grid .field-group { margin-top: 11px; }
  .workflow-section textarea { min-height: 62px; }
  .compact-section { padding-bottom: 12px; }
  .advanced-settings { margin-top: 10px; }
  .generate-bar { padding: 12px 16px 14px; }
  .primary-button { height: 42px; }
  .workspace-toolbar { height: 42px; margin-bottom: 0; flex: 0 0 auto; }
  .workspace-toolbar h1 { font-size: 18px; }
  .preview-stage.generation-board { flex: 0 0 auto; max-height: 228px; padding: 9px; }
  .generation-task-list { max-height: 180px; gap: 5px; }
  .generation-task-card { grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; padding: 6px; }
  .generation-task-thumbs { max-width: 168px; }
  .generation-task-thumb { flex-basis: 38px; width: 38px; height: 50px; }
  .generation-task-title strong { font-size: 11px; }
  .generation-task-meta, .generation-task-foot { font-size: 8px; }
  .generation-task-progress { margin-top: 5px; }
  .generation-task-open { height: 25px; padding: 0 6px; font-size: 9px; }
  .results-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 6px;
    margin-top: 0;
    align-content: start;
  }
  .result-card { aspect-ratio: 3 / 4; border-radius: 4px; }
  .result-actions .icon-button { width: 26px; height: 26px; }
  .result-actions .icon-button svg { width: 13px; height: 13px; }
}

/* Medium desktop window: keep configuration and generation side by side. */
@media (min-width: 760px) and (max-width: 1279px) {
  .studio-view {
    display: grid !important;
    grid-template-columns: minmax(330px, 42%) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    overflow: hidden;
  }
  .order-queue-panel,
  .chat-panel { display: none !important; }
  .config-panel {
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1.35fr) minmax(132px, .65fr);
    align-content: start;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    scrollbar-gutter: stable;
  }
  .config-panel > .config-section:first-child,
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .config-panel > #styleSection { grid-column: 1; }
  .config-panel > #lookSection { grid-column: 2; }
  .config-section { padding: 14px 14px 12px; }
  .section-heading { margin-bottom: 9px; }
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .upload-hint { margin-top: 6px; font-size: 9px; }
  #styleSection .style-upload { height: 142px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 6px; }
  #lookSection .addon-upload { min-height: 62px; padding: 7px; gap: 3px; }
  #lookSection .addon-icon { width: 22px; height: 22px; }
  #lookSection .addon-name { font-size: 9px; }
  #lookSection .addon-file { font-size: 8px; }
  #lookSection .upload-hint { display: none; }
  .compact-section { padding-bottom: 10px; }
  .compact-section .field-group { margin-top: 9px; }
  .compact-section .profile-grid { gap: 7px; }
  .compact-section select { height: 34px; font-size: 10px; }
  .quick-toolbar { margin-top: 9px; padding: 6px; gap: 5px; }
  .quick-control-field select { max-width: 122px; }
  .prompt-framework { margin-top: 7px; }
  .prompt-framework-field textarea { min-height: 62px; max-height: 88px; }
  .advanced-settings { margin-top: 8px; }
  .generate-bar { padding: 10px 14px 12px; }
  .primary-button { height: 40px; }
  .workspace-panel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 16px 16px 18px;
  }
  .workspace-toolbar { height: 40px; margin-bottom: 0; flex: 0 0 auto; }
  .workspace-toolbar h1 { font-size: 18px; }
  .preview-stage.generation-board { flex: 0 0 auto; max-height: 176px; padding: 8px; }
  .generation-task-list { max-height: 128px; gap: 5px; }
  .generation-task-card { gap: 6px; padding: 6px; }
  .generation-task-thumbs { max-width: 150px; }
  .generation-task-thumb { flex-basis: 34px; width: 34px; height: 46px; }
  .generation-task-title strong { font-size: 10px; }
  .generation-task-meta, .generation-task-foot { font-size: 8px; }
  .generation-task-open { height: 24px; padding: 0 5px; font-size: 9px; }
  .results-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 6px;
    margin-top: 0;
    align-content: start;
  }
  .result-card { aspect-ratio: 3 / 4; border-radius: 4px; }
  .result-actions { opacity: 1; transform: none; }
}

/* Final compact workbench: keep the main flow horizontal and reserve a small bottom strip for output. */
@media (min-width: 760px) {
  .people-grid .upload-slot,
  #partnerGrid .upload-slot { aspect-ratio: 1 / 1; }

  .advanced-settings {
    position: relative;
    display: inline-block;
    margin-top: 6px;
    border: 0;
  }

  .advanced-settings summary {
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: white;
    color: var(--ink-soft);
    gap: 6px;
    font-size: 10px;
    white-space: nowrap;
  }

  .advanced-settings summary:hover,
  .advanced-settings[open] summary {
    border-color: var(--accent);
    background: #fff7f8;
    color: var(--ink);
  }

  .advanced-settings[open] .advanced-body {
    position: absolute;
    z-index: 80;
    left: 0;
    bottom: calc(100% + 6px);
    width: min(360px, 70vw);
    max-height: min(420px, 58vh);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
    box-shadow: 0 14px 34px rgba(26, 29, 35, .16);
  }

  .advanced-settings[open] .advanced-body .range-field {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .advanced-settings[open] .advanced-body .field-group {
    min-width: 0;
    margin-top: 0;
  }

  .advanced-settings[open] .advanced-body select { height: 32px; font-size: 10px; }
  .advanced-settings[open] .advanced-body .prompt-file-picker { margin-top: 5px; }
}

@media (min-width: 1280px) {
  .studio-view {
    align-content: start;
  }

  .config-panel { overflow-y: auto; }
  .config-panel > .config-section:first-child { padding-bottom: 10px; }
  .people-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }

  .quick-toolbar {
    margin-top: 8px;
    padding: 5px;
    gap: 5px;
    border-radius: 5px;
  }

  .quick-control-field select,
  .quick-control-field .aspect-trigger,
  .quick-control-field .stepper,
  .quick-control-field .segmented-control { height: 30px; }
  .quick-control-field .segment { height: 25px; }

  .workspace-panel {
    height: 100%;
    overflow: hidden;
    gap: 5px;
    padding: 6px 14px 8px;
  }

  .workspace-toolbar { height: 24px; margin-bottom: 0; }
  .workspace-toolbar h1 { font-size: 16px; }
  .toolbar-actions .secondary-button { height: 28px; padding: 0 8px; font-size: 10px; }

  .preview-stage.generation-board {
    flex: 0 0 76px;
    height: 76px;
    max-height: 76px;
    padding: 6px;
  }
  .generation-task-list { max-height: 48px; gap: 4px; }
  .generation-empty { min-height: 42px; padding: 5px; gap: 3px; }
  .generation-empty strong { font-size: 11px; }
  .generation-empty > span:last-child { max-width: 95%; overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  .generation-task-card { min-height: 46px; gap: 5px; padding: 4px; }
  .generation-task-thumbs { max-width: 132px; }
  .generation-task-thumb { flex-basis: 28px; width: 28px; height: 38px; }
  .generation-task-title strong { font-size: 10px; }
  .generation-task-meta, .generation-task-foot { font-size: 8px; }
  .generation-task-open { height: 22px; padding: 0 5px; font-size: 8px; }

  .results-grid {
    flex: 0 0 56px;
    height: 56px;
    min-height: 0;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    grid-template-columns: none;
    align-content: stretch;
  }
  .result-card { flex: 0 0 42px; width: 42px; height: 56px; aspect-ratio: auto; border-radius: 4px; }
}

@media (min-width: 760px) and (max-width: 1279px) {
  .studio-view { grid-template-rows: minmax(0, 1fr) 170px !important; align-content: start; }
  .config-panel > .config-section:first-child { padding-bottom: 9px; }
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }

  .workspace-panel {
    height: 170px;
    overflow: hidden;
    gap: 4px;
    padding: 6px 12px 7px;
  }
  .workspace-toolbar { height: 24px; }
  .workspace-toolbar h1 { font-size: 15px; }
  .preview-stage.generation-board { flex: 0 0 68px; height: 68px; max-height: 68px; padding: 5px; }
  .generation-task-list { max-height: 42px; gap: 4px; }
  .generation-empty { min-height: 36px; padding: 4px; gap: 2px; }
  .generation-empty strong { font-size: 10px; }
  .generation-empty > span:last-child { max-width: 95%; overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
  .generation-task-card { min-height: 42px; gap: 4px; padding: 4px; }
  .generation-task-thumbs { max-width: 112px; }
  .generation-task-thumb { flex-basis: 26px; width: 26px; height: 35px; }
  .generation-task-title strong { font-size: 9px; }
  .generation-task-meta, .generation-task-foot { font-size: 7px; }
  .generation-task-open { height: 20px; padding: 0 4px; font-size: 8px; }

  .results-grid {
    flex: 0 0 48px;
    height: 48px;
    min-height: 0;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    grid-template-columns: none;
  }
  .result-card { flex: 0 0 35px; width: 35px; height: 48px; aspect-ratio: auto; border-radius: 4px; }
}

/* Keep the primary controls in view: quick choices first, secondary details behind one button. (earlier block) */
@media (min-width: 760px) {
  .compact-section { position: relative; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .compact-section > .quick-toolbar {
    grid-column: 1 / span 3;
    grid-row: 2;
    margin-top: 0;
  }
  .compact-section > .advanced-settings {
    grid-column: 4;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    margin: 0;
  }
  .compact-section > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
  .compact-section > .profile-grid { grid-column: 3 / -1; grid-row: 3; }
  .compact-section > .prompt-framework { grid-column: 1 / -1; grid-row: 4; }
  .compact-section > .consent-row { grid-column: 1 / -1; grid-row: 5; }
  .prompt-framework-field textarea { min-height: 58px; max-height: 72px; }
  .advanced-settings[open] .advanced-body { top: calc(100% + 6px); bottom: auto; }
}

@media (min-width: 1280px) {
  .people-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
  #styleSection .style-upload { height: 104px; min-height: 104px; }
  #lookSection .addon-upload { min-height: 64px; }
}

@media (min-width: 760px) and (max-width: 1279px) {
  .people-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  #styleSection .style-upload { height: 108px; min-height: 108px; }
  #lookSection .addon-upload { min-height: 57px; }
}

@media (min-width: 1280px) {
  .config-panel {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(180px, .7fr);
  }
  .config-panel > .config-section:first-child { grid-column: 1; grid-row: 1; }
  .config-panel > #styleSection { grid-column: 2; grid-row: 1; }
  .config-panel > #lookSection { grid-column: 3; grid-row: 1; }
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .config-section { padding: 13px 14px 11px; }
  #styleSection .style-upload { height: 96px; min-height: 96px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 5px; }
  #lookSection .addon-upload { min-height: 56px; padding: 7px; }
  #styleSection .asset-library-inline { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 9px; white-space: nowrap; }
  #styleSection .asset-library-inline > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #styleSection .asset-library-inline .secondary-button { height: 28px; flex: 0 0 auto; padding: 0 8px; font-size: 9px; }
}

@media (min-width: 1280px) {
  .config-panel {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(180px, .7fr);
  }
  .config-panel > .config-section:first-child { grid-column: 1; grid-row: 1; }
  .config-panel > #styleSection { grid-column: 2; grid-row: 1; }
  .config-panel > #lookSection { grid-column: 3; grid-row: 1; }
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .config-section { padding: 13px 14px 11px; }
  #styleSection .style-upload { height: 96px; min-height: 96px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 5px; }
  #lookSection .addon-upload { min-height: 56px; padding: 7px; }
}

/* Keep face references readable: four medium slots are easier to inspect than a dense strip. */
#peopleGrid,
#partnerGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#peopleGrid .upload-slot,
#partnerGrid .upload-slot { min-height: 64px; }

/* Keep the second-person reference slots as compact as the primary-person slots. */
@media (min-width: 1280px) {
  #peopleGrid,
  #partnerGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
}

@media (min-width: 760px) and (max-width: 1279px) {
  #peopleGrid,
  #partnerGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
}

/* Pack the configuration controls into predictable rows so the workbench stays scannable. */
@media (min-width: 760px) {
  .compact-section {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 10px;
    row-gap: 8px;
    align-content: start;
  }
  .compact-section > .section-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .compact-section > :nth-child(2) { grid-column: span 2; }
  .compact-section > :nth-child(3),
  .compact-section > :nth-child(4) { grid-column: span 1; }
  .compact-section > .field-group { margin-top: 0; }
  .compact-section > .profile-grid,
  .compact-section > .quick-toolbar,
  .compact-section > .prompt-framework,
  .compact-section > .advanced-settings,
  .compact-section > .consent-row { grid-column: 1 / -1; }
}

/* Centered generation workbench: horizontal inputs above, compact results below. */
@media (min-width: 1280px) {
  .studio-view {
    grid-template-columns: minmax(260px, 300px) minmax(680px, 1fr) minmax(238px, 280px) !important;
    grid-template-rows: minmax(0, 1fr) 128px !important;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    overflow: hidden;
  }
  .studio-view:has(#resultsGrid:not([hidden])) {
    grid-template-rows: minmax(0, 1fr) 190px !important;
  }
  .chat-panel { grid-column: 1 !important; grid-row: 1 / span 2 !important; height: 100%; min-height: 0; }
  .config-panel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    display: grid !important;
    grid-template-columns: minmax(0, 1.35fr) minmax(150px, .65fr);
    align-content: start;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .config-panel > .config-section:first-child,
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .config-panel > #styleSection { grid-column: 1; }
  .config-panel > #lookSection { grid-column: 2; }
  .workspace-panel {
    grid-column: 2 !important;
    grid-row: 2 !important;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 12px 18px 16px;
    border-right: 0;
  }
  .order-queue-panel { grid-column: 3 !important; grid-row: 1 / span 2 !important; height: 100%; min-height: 0; }
  .workspace-toolbar { height: 36px; margin-bottom: 0; flex: 0 0 auto; }
  .workspace-toolbar h1 { font-size: 18px; }
  .preview-stage.generation-board { flex: 0 0 auto; max-height: 174px; padding: 8px; }
  .generation-task-list { max-height: 122px; gap: 5px; }
  .generation-task-thumb { flex-basis: 34px; width: 34px; height: 46px; }
  .results-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 6px; margin-top: 0; align-content: start; }
  .result-card { aspect-ratio: 3 / 4; border-radius: 4px; }
  .result-actions { opacity: 1; transform: none; }
}

@media (min-width: 760px) and (max-width: 1279px) {
  .studio-view {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) 190px !important;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    overflow: hidden;
  }
  .order-queue-panel, .chat-panel { display: none !important; }
  .config-panel {
    grid-column: 1 !important;
    grid-row: 1 !important;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    display: grid !important;
    grid-template-columns: minmax(240px, 1.1fr) minmax(250px, 1fr) minmax(210px, .85fr);
    align-content: start;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .config-panel > .config-section:first-child { grid-column: 1; }
  .config-panel > #partnerSection { grid-column: 1 / -1; }
  .config-panel > #styleSection { grid-column: 2; }
  .config-panel > #lookSection { grid-column: 3; }
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .config-section { padding: 13px 14px 11px; }
  #styleSection .style-upload { height: 142px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 6px; }
  #lookSection .addon-upload { min-height: 62px; padding: 7px; }
  #lookSection .upload-hint { display: none; }
  .workspace-panel {
    grid-column: 1 !important;
    grid-row: 2 !important;
    height: 190px;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 9px 14px 12px;
  }
  .workspace-toolbar { height: 30px; margin-bottom: 0; flex: 0 0 auto; }
  .workspace-toolbar h1 { font-size: 16px; }
  .preview-stage.generation-board { flex: 0 0 auto; max-height: 112px; padding: 7px; }
  .generation-task-list { max-height: 88px; gap: 4px; }
  .generation-task-thumb { flex-basis: 30px; width: 30px; height: 40px; }
  .generation-task-card { padding: 5px; gap: 5px; }
  .generation-task-open { height: 22px; padding: 0 5px; font-size: 8px; }
  .results-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; margin-top: 0; align-content: start; }
  .result-card { aspect-ratio: 3 / 4; border-radius: 4px; }
  .result-actions { opacity: 1; transform: none; }
}

/* Keep the primary controls in view: quick choices first, secondary details behind one button. */
@media (min-width: 760px) {
  .compact-section { position: relative; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .compact-section > .quick-toolbar {
    grid-column: 1 / span 3;
    grid-row: 2;
    margin-top: 0;
  }
  .compact-section > .advanced-settings {
    grid-column: 4;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    margin: 0;
  }
  .compact-section > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
  .compact-section > .profile-grid { grid-column: 3 / -1; grid-row: 3; }
  .compact-section > .prompt-framework { grid-column: 1 / -1; grid-row: 4; }
  .compact-section > .consent-row { grid-column: 1 / -1; grid-row: 5; }
  .prompt-framework-field textarea { min-height: 58px; max-height: 72px; }
  .advanced-settings[open] .advanced-body { top: calc(100% + 6px); bottom: auto; }
}

@media (min-width: 1280px) {
  .people-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
  #styleSection .style-upload { height: 104px; min-height: 104px; }
  #lookSection .addon-upload { min-height: 64px; }
}

@media (min-width: 760px) and (max-width: 1279px) {
  .people-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  #styleSection .style-upload { height: 108px; min-height: 108px; }
  #lookSection .addon-upload { min-height: 59px; }
}

@media (min-width: 1280px) {
  .config-panel { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(180px, .7fr); }
  .config-panel > .config-section:first-child { grid-column: 1; grid-row: 1; }
  .config-panel > #styleSection { grid-column: 2; grid-row: 1; }
  .config-panel > #lookSection { grid-column: 3; grid-row: 1; }
  .config-panel > #partnerSection,
  .config-panel > .compact-section,
  .config-panel > .generate-bar { grid-column: 1 / -1; }
  .people-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .config-section { padding: 13px 14px 11px; }
  #styleSection .style-upload { height: 96px; min-height: 96px; }
  #lookSection .addon-grid { grid-template-columns: 1fr; gap: 5px; }
  #lookSection .addon-upload { min-height: 56px; padding: 7px; }
}

/* Unified portrait generation status: one heading, one content surface. */
@media (min-width: 981px) {
  .workspace-panel .preview-stage.generation-board {
    flex: 0 0 76px;
    height: 76px;
    max-height: 76px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .workspace-panel .generation-board-count { font-size: 9px; }
  .workspace-panel .generation-task-list { max-height: 76px; gap: 3px; padding-right: 0; }
  .workspace-panel .generation-empty {
    min-height: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 3px 8px;
    border-width: 1px;
    text-align: left;
  }
  .workspace-panel .generation-empty .empty-kicker { font-size: 8px; }
  .workspace-panel .generation-empty strong { font-size: 10px; white-space: nowrap; }
  .workspace-panel .generation-empty > span:last-child {
    max-width: 40%;
    overflow: hidden;
    font-size: 8px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workspace-panel .generation-task-card { min-height: 70px; gap: 5px; padding: 4px; }
  .workspace-panel .generation-task-thumb { flex-basis: 38px; width: 38px; height: 50px; }
}

@media (min-width: 1280px) {
  .workspace-panel {
    gap: 4px;
    padding: 5px 14px 7px;
  }
  .workspace-toolbar { height: 30px; }
  .workspace-toolbar h1 { margin-top: 1px; font-size: 16px; }
}
