/* Hallmark · pre-emit critique: P5 H5 E4 S5 R5 V4
 * genre: atmospheric · macrostructure: Workbench · theme: Midnight
 * tone: luxury + austere · audience: fashion visual teams · use: generate model styling
 * enrichment: supplied fashion photography · nav: N9 edge-aligned · footer: none (application shell)
 * contrast: pass (40–41) · slop: pass (42–49) · mobile: pass (34, 49, 50–57)
 */
@import url("tokens.css");

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
body { background: var(--color-canvas); color: var(--color-ink); font-family: var(--font-body); font-size: var(--text-sm); }
button, input, textarea, select { font: inherit; }
button, label[for], summary, select { cursor: pointer; }
button, select, textarea { color: inherit; }
button:focus-visible, label[tabindex]:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-focus); outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .45; }

.topbar { height: 72px; padding-inline: clamp(var(--space-4), 3vw, var(--space-10)); display: flex; align-items: center; justify-content: space-between; border-block-end: var(--rule-thin) solid var(--color-rule); background: var(--color-canvas); color: var(--color-ink); }
.brand { display: flex; gap: var(--space-3); align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: var(--rule-thin) solid var(--color-rule-strong); font-family: var(--font-display); font-size: var(--text-lg); }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .13em; font-size: var(--text-xs); }
.brand small { margin-block-start: 2px; color: var(--color-muted); font-size: 10px; letter-spacing: .18em; }
.topbar-meta { display: flex; align-items: center; gap: var(--space-4); }
.status-dot { color: var(--color-ink-soft); font-size: var(--text-xs); white-space: nowrap; }
.status-dot i { display: inline-block; width: 6px; height: 6px; margin-inline-end: var(--space-2); border-radius: var(--radius-pill); background: var(--color-accent); }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: var(--radius-pill); background: var(--color-panel); color: var(--color-ink-soft); }

.workbench { width: min(100%, 1700px); height: calc(100dvh - 72px); margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 430px); }
.control-panel { order: 2; min-height: 0; padding: clamp(var(--space-6), 3vw, var(--space-10)); overflow-y: auto; border-inline-start: var(--rule-thin) solid var(--color-rule); display: flex; flex-direction: column; gap: var(--space-8); background: var(--color-panel); color: var(--color-ink); }
.control-panel { scrollbar-width: thin; scrollbar-color: var(--color-rule-strong) var(--color-panel); }
.control-panel::-webkit-scrollbar { width: 8px; }
.control-panel::-webkit-scrollbar-track { background: var(--color-panel); }
.control-panel::-webkit-scrollbar-thumb { border: 2px solid var(--color-panel); border-radius: var(--radius-pill); background: var(--color-rule-strong); }
.panel-heading > div { display: flex; align-items: baseline; gap: var(--space-3); }
.step-count { font-family: var(--font-mono); color: var(--color-accent); font-size: var(--text-xs); letter-spacing: .08em; }
h1, h2 { margin: 0; font-family: var(--font-display); font-style: normal; font-weight: 400; }
h1 { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-xl); letter-spacing: -.02em; }
.panel-heading p { margin: var(--space-3) 0 0 35px; max-width: 32ch; color: var(--color-muted); line-height: 1.65; }
.field-group { display: grid; gap: var(--space-3); }
.field-label { display: flex; justify-content: space-between; color: var(--color-ink-soft); font-size: var(--text-xs); }
.field-label span:last-child { font-family: var(--font-mono); color: var(--color-muted); }
.dropzone { min-height: 96px; padding: var(--space-4); display: flex; align-items: center; gap: var(--space-4); border: var(--rule-thin) dashed var(--color-rule-strong); border-radius: var(--radius-md); background: var(--color-panel); color: var(--color-ink); transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.dropzone.is-dragging { background: var(--color-panel-hover); transform: translateY(-1px); }
.dropzone-plus { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-xl); font-weight: 300; }
.dropzone strong, .dropzone small { display: block; }
.dropzone strong { font-size: var(--text-sm); }
.dropzone small { margin-block-start: var(--space-1); color: var(--color-muted); font-size: var(--text-xs); }
.thumb-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.thumb-card { min-width: 0; margin: 0; overflow: clip; border-radius: var(--radius-sm); background: var(--color-panel-raised); color: var(--color-ink); }
.thumb-card img { width: 100%; height: 100px; display: block; object-fit: cover; }
.thumb-card figcaption { min-width: 0; height: 30px; padding-inline: var(--space-2); display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); font-size: 10px; }
.thumb-card figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-card button { width: 28px; height: 28px; flex: 0 0 auto; border: 0; background: transparent; color: var(--color-muted); font-size: var(--text-lg); }

.advanced { border-block: var(--rule-thin) solid var(--color-rule); }
.advanced summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; list-style: none; font-weight: 600; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary span { color: var(--color-muted); font-size: var(--text-xs); font-weight: 400; }
.advanced[open] summary span::after { content: "收起"; font-size: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.settings-grid label, .prompt-field { display: grid; gap: var(--space-2); color: var(--color-ink-soft); font-size: var(--text-xs); }
.settings-grid .model-field { grid-column: 1 / -1; }
.model-control { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
.quota-badge { min-height: 44px; padding-inline: var(--space-3); display: inline-grid; place-items: center; border: var(--rule-thin) solid var(--color-rule-strong); border-radius: var(--radius-sm); background: var(--color-panel-raised); color: var(--color-accent); font-family: var(--font-body); font-size: var(--text-xs); white-space: nowrap; }
.quota-badge.is-hidden { display: none; }
select, textarea { width: 100%; border: var(--rule-thin) solid var(--color-rule); border-radius: var(--radius-sm); outline: 2px solid transparent; outline-offset: 1px; background: var(--color-canvas); color: var(--color-ink); }
select { min-height: 44px; padding-inline: var(--space-3); }
textarea { min-height: 116px; padding: var(--space-3); resize: vertical; line-height: 1.55; }
.prompt-field { margin-block: var(--space-4) var(--space-6); }
.prompt-field small { min-height: 1lh; color: var(--color-muted); }
.action-area { margin-block-start: auto; }
.generate-button { width: 100%; min-height: 54px; padding-inline: var(--space-5); display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: var(--radius-sm); background: var(--color-accent); color: var(--color-accent-ink); font-weight: 700; white-space: nowrap; transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.generate-button:active { transform: translateY(1px); }
.generate-button[data-state="loading"] .button-arrow { animation: spin 1s linear infinite; }
.generate-button[data-state="success"] { background: var(--color-success); }
.generate-button[data-state="error"] { background: var(--color-error); color: var(--color-ink); }
.action-area p { margin: var(--space-2) 0 0; text-align: center; color: var(--color-muted); font-size: 10px; }

.canvas-panel { order: 1; min-width: 0; min-height: 0; padding: clamp(var(--space-4), 2.5vw, var(--space-8)); overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--space-4); background: var(--color-canvas); color: var(--color-ink); }
.canvas-toolbar { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.view-tabs { display: flex; align-items: center; gap: var(--space-1); }
.view-tab, .text-action, .download-button { min-height: 44px; padding-inline: var(--space-3); border: 0; background: transparent; color: var(--color-muted); white-space: nowrap; }
.view-tab { position: relative; }
.view-tab.is-active { color: var(--color-ink); }
.view-tab.is-active::after { content: ""; position: absolute; inset: auto var(--space-3) 5px; height: 1px; background: var(--color-accent); }
.canvas-actions { display: flex; align-items: center; gap: var(--space-1); }
.text-action { display: inline-grid; place-items: center; }
.download-button { border: var(--rule-thin) solid var(--color-rule-strong); border-radius: var(--radius-sm); color: var(--color-ink-soft); }
.stage { position: relative; min-height: 0; overflow: clip; display: grid; place-items: center; border-radius: var(--radius-lg); background: var(--color-panel-raised); color: var(--color-ink); }
.stage::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 72% 18%, var(--color-panel-hover), transparent 36%); pointer-events: none; }
.stage-image { position: relative; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.stage-note { position: absolute; z-index: 3; inset: var(--space-5) auto auto var(--space-5); padding-inline-start: var(--space-3); border-inline-start: 2px solid var(--color-accent); }
.stage-note span, .stage-note small { display: block; }
.stage-note span { font-size: var(--text-xs); font-weight: 600; }
.stage-note small { margin-block-start: var(--space-1); color: var(--color-muted); font-size: 10px; }
.compare-mask { position: absolute; z-index: 2; inset: 0 50% 0 0; overflow: hidden; background: var(--color-panel-raised); }
.compare-mask img { width: 100%; height: 100%; max-width: none; object-fit: contain; object-position: center; }
.compare-range { position: absolute; z-index: 4; inset: 0 auto 0 50%; width: 2px; height: 100%; margin: 0; padding: 0; appearance: none; background: var(--color-accent); color: var(--color-accent-ink); }
.compare-range::-webkit-slider-thumb { appearance: none; width: 44px; height: 44px; border: 0; border-radius: var(--radius-pill); background: var(--color-accent); }
.generation-state { position: absolute; z-index: 5; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-3); background: var(--color-backdrop); color: var(--color-ink); }
.generation-state[hidden] { display: none; }
.generation-state strong { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 400; }
.generation-state span { font-family: var(--font-mono); color: var(--color-accent); font-size: var(--text-xs); }
.spinner { width: 34px; height: 34px; border: 2px solid var(--color-rule-strong); border-block-start-color: var(--color-accent); border-radius: var(--radius-pill); animation: spin 1s linear infinite; }
.progress-track { width: 220px; height: 2px; overflow: hidden; background: var(--color-rule); }
.progress-track i { display: block; width: 12%; height: 100%; background: var(--color-accent); transition: width var(--dur-base) var(--ease-out); }
.reference-strip { min-height: 76px; padding: var(--space-3); display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); border-radius: var(--radius-md); background: var(--color-panel); color: var(--color-ink); }
.reference-strip > div { display: flex; align-items: center; gap: var(--space-3); }
.reference-strip strong, .reference-strip small { display: block; }
.reference-strip strong { font-size: var(--text-xs); }
.reference-strip small { margin-block-start: var(--space-1); color: var(--color-muted); font-size: 10px; }
.reference-thumb { position: relative; width: 54px; height: 54px; overflow: clip; border-radius: var(--radius-sm); }
.reference-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reference-thumb span { position: absolute; inset: auto 0 0; padding-block: 2px; text-align: center; background: var(--color-backdrop); color: var(--color-ink); font-size: 9px; }

dialog { position: fixed; inset: 0; width: min(90%, 440px); max-height: min(80dvh, 40rem); margin: auto; padding: var(--space-8); border: var(--rule-thin) solid var(--color-rule-strong); border-radius: var(--radius-lg); background: var(--color-panel); color: var(--color-ink); }
dialog::backdrop { background: var(--color-backdrop); }
dialog h2 { font-size: var(--text-xl); }
dialog ol { padding-inline-start: var(--space-5); color: var(--color-ink-soft); line-height: 1.8; }
dialog p { color: var(--color-muted); line-height: 1.6; }
.dialog-close { position: absolute; inset: var(--space-3) var(--space-3) auto auto; width: 44px; height: 44px; border: 0; background: transparent; color: var(--color-muted); font-size: var(--text-xl); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (hover: hover) and (pointer: fine) {
  .icon-button:hover, .view-tab:hover, .text-action:hover { background: var(--color-panel-hover); color: var(--color-ink); }
  .dropzone:hover { background: var(--color-panel-hover); transform: translateY(-1px); }
  .generate-button:hover { background: var(--color-accent-hover); transform: translateY(-1px); }
  .download-button:hover:not(:disabled) { background: var(--color-panel-hover); color: var(--color-ink); }
}
@media (max-width: 59.99rem) {
  .workbench { height: auto; min-height: calc(100dvh - 72px); grid-template-columns: minmax(0, 1fr); }
  .control-panel { overflow: visible; border-inline-start: 0; border-block-start: var(--rule-thin) solid var(--color-rule); }
  .canvas-panel { min-height: 760px; overflow: visible; }
  .stage { min-height: 560px; }
}
@media (max-width: 39.99rem) {
  .topbar { height: 64px; }
  .status-dot { display: none; }
  .control-panel { padding: var(--space-5); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .model-control { grid-template-columns: minmax(0, 1fr); }
  .canvas-toolbar { align-items: flex-start; flex-direction: column; }
  .canvas-actions { width: 100%; justify-content: space-between; }
  .text-action, .download-button { padding-inline: var(--space-2); }
  .stage { min-height: 470px; }
  .stage-note { inset: var(--space-3) auto auto var(--space-3); }
  .reference-strip small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
