:root {
  color-scheme: light;
  --bg: oklch(98% 0.004 238);
  --surface: oklch(99.5% 0.002 238);
  --surface-soft: oklch(96.6% 0.006 238);
  --surface-muted: oklch(93.5% 0.008 238);
  --ink: #1d2226;
  --text: #343a40;
  --muted: #7b858d;
  --faint: #a7afb6;
  --line: #e8ecef;
  --line-strong: #d7dde1;
  --accent: #1b1d1f;
  --accent-hover: #08090a;
  --green: #277254;
  --green-soft: #edf8f2;
  --red: #cf3f35;
  --red-soft: #fff1ef;
  --blue: #3c72d9;
  --blue-soft: #eef4ff;
  --shadow: 0 1px 2px rgba(27, 33, 38, 0.035);
  --radius: 7px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--bg);
}

.auth-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 380px);
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.auth-panel h1 {
  margin: 6px 0 6px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.18;
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.auth-tab {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.auth-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 1px 4px rgba(27, 33, 38, 0.06);
}

.auth-form {
  display: grid;
  gap: 0;
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: end;
}

.auth-code-row .secondary-button {
  min-height: 36px;
  margin-bottom: 10px;
  padding: 0 10px;
  white-space: nowrap;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 230px;
  padding: 8px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.account-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.account-strip strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 15px;
}

.account-actions {
  display: flex;
  gap: 6px;
}

.account-compact .secondary-button,
.account-compact .ghost-button {
  min-height: 32px;
  padding: 0 10px;
}

body::-webkit-scrollbar,
.sidebar-scroll::-webkit-scrollbar,
.gallery-shell::-webkit-scrollbar {
  display: none;
}

body,
.sidebar-scroll,
.gallery-shell {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.panel {
  background: var(--surface);
}

.controls {
  display: flex;
  flex: 0 0 304px;
  flex-direction: column;
  width: 304px;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  box-shadow: none;
  z-index: 2;
}

.model-select-row {
  margin-bottom: 16px;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 16px;
}

.sidebar-footer {
  flex: 0 0 auto;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.form-block {
  margin: 0 0 16px;
}

.form-block:last-child {
  margin-bottom: 0;
}

.api-form {
  margin-bottom: 14px;
}

.api-details,
.compact-details {
  background: transparent;
}

.api-details summary,
.compact-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  outline: none;
}

.api-details summary::-webkit-details-marker,
.compact-details summary::-webkit-details-marker {
  display: none;
}

.api-details summary span:first-child,
.compact-details summary span:first-child,
.section-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.api-details summary span:last-child,
.compact-details summary span:last-child,
.section-title span {
  color: var(--faint);
  font-size: 14px;
  white-space: nowrap;
}

.api-details summary::after,
.compact-details summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.api-details[open] summary::after,
.compact-details[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.api-body,
.favorite-body,
.advanced-body {
  padding-top: 10px;
}

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

label {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

label > span:first-child {
  color: var(--muted);
}

label small {
  color: var(--faint);
  font-size: 12px;
  font-weight: 520;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

input,
select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 84px;
  padding: 9px 10px;
  resize: vertical;
}

#prompt {
  min-height: 118px;
}

#negativePrompt {
  min-height: 64px;
}

input::placeholder,
textarea::placeholder {
  color: #b6bdc3;
}

input:focus,
select:focus,
textarea:focus {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(29, 34, 38, 0.055);
}

select {
  cursor: pointer;
}

.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 12px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.mode-option {
  margin: 0;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: grid;
  place-items: center;
  min-height: 32px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 720;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.mode-option input:checked + span {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(27, 33, 38, 0.08);
}

.favorite-panel,
.advanced-details {
  margin-bottom: 12px;
  padding: 0;
}

.favorite-actions,
.api-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.api-actions {
  grid-template-columns: 1fr 1fr;
}

.reference-panel {
  margin-bottom: 12px;
}

.drop-zone {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 11px;
  cursor: pointer;
  background: var(--surface-soft);
  border: 1px dashed #c4ccd2;
  border-radius: var(--radius);
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  background: var(--blue-soft);
  border-color: #9db6ee;
  box-shadow: 0 0 0 2px rgba(60, 114, 217, 0.08);
}

.drop-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
}

.drop-copy,
.drop-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.reference-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin-top: 10px;
  padding: 8px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.reference-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.reference-preview-item {
  min-width: 0;
  margin: 0;
}

.reference-preview-item img {
  display: block;
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--surface-muted);
}

.reference-preview-item figcaption {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-preview p {
  margin: 0 0 8px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dimension-readout {
  margin: -2px 0 12px;
  padding: 7px 10px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 720;
}

.range-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: end;
  gap: 8px;
}

.range-grid output {
  display: grid;
  place-items: center;
  height: 36px;
  margin-bottom: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 720;
}

input[type="range"] {
  height: 28px;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
}

.count-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.count-control span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.count-control input {
  width: 58px;
  height: 28px;
  padding: 0;
  text-align: right;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.secondary-button,
.workflow-launch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease, transform 120ms ease;
}

button:active,
.secondary-button:active,
.workflow-launch:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  color: #fafafa;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.generate-button {
  width: 100%;
  min-height: 42px;
  color: #fafafa;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.generate-button:hover {
  background: var(--accent-hover);
}

.workflow-launch {
  width: 100%;
  min-height: 34px;
  margin-top: 6px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line-strong);
}

.workflow-launch:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.controls button,
.controls .secondary-button,
.controls .workflow-launch {
  font-size: 13px;
}

.ghost-button,
.secondary-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.ghost-button:hover,
.secondary-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.danger-button {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffd5d0;
}

.danger-button:hover {
  background: #ffe5e2;
  border-color: #ffc3bc;
}

.message {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.message.error {
  color: var(--red);
}

.message.ok {
  color: var(--green);
}

.gallery-shell {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 20px 28px;
  background: var(--bg);
}

.gallery-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.gallery-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 760;
}

.gallery-head p {
  margin: 3px 0 0;
  color: var(--faint);
  font-size: 13px;
}

.gallery-main-head {
  align-items: center;
  margin-top: 4px;
  margin-bottom: 12px;
}

.gallery-main-head h2 {
  font-size: 18px;
}

.gallery-main-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.view-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-width: 178px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.view-switch-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.view-switch-button.is-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 1px 4px rgba(27, 33, 38, 0.06);
}

.workspace-launch {
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
}

.task-panel {
  margin-bottom: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.task-panel.collapsed .task-list {
  display: none;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.task-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
}

.task-status.running {
  color: var(--blue);
  background: var(--blue-soft);
}

.task-status.queued {
  color: #80611c;
  background: #fff7df;
}

.task-status.completed {
  color: var(--green);
  background: var(--green-soft);
}

.task-status.failed {
  color: var(--red);
  background: var(--red-soft);
}

.task-status.cancelled {
  color: var(--muted);
  background: var(--surface-muted);
}

.task-prompt {
  margin: 7px 0 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta,
.task-error {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.task-error {
  margin-top: 5px;
  color: var(--red);
}

.task-progress {
  overflow: hidden;
  height: 7px;
  margin-top: 9px;
  background: var(--surface-muted);
  border-radius: 999px;
}

.task-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 180ms ease;
}

.ecommerce-task-item {
  grid-template-columns: minmax(0, 1fr);
}

.ecommerce-plan {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.ecommerce-plan-title {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.ecommerce-plan-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.ecommerce-screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.ecommerce-screen-card {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ecommerce-screen-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--surface-muted);
  border-radius: 6px;
}

.ecommerce-screen-card p {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ecommerce-screen-card span {
  display: -webkit-box;
  min-height: 34px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ecommerce-screen-card .secondary-button {
  min-height: 32px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gallery-thumb-size, 230px)), 1fr));
  gap: 12px;
}

.project-strip {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(180px, 280px) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.project-strip span,
.project-image-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.project-strip strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -4px 0 12px;
  padding: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gallery-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex: 1 1 auto;
  gap: 6px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.gallery-filter-button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 760;
}

.gallery-filter-button:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.gallery-filter-button.is-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: 0 1px 4px rgba(27, 33, 38, 0.06);
}

.gallery-size-control {
  display: grid;
  grid-template-columns: auto 86px 42px;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 30px;
  margin: 0;
  padding: 0 4px 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.gallery-size-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.gallery-size-control input {
  height: 24px;
  padding: 0;
  cursor: ew-resize;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.gallery-size-control output {
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

.project-pick-button {
  width: 100%;
  margin: -2px 0 8px;
}

.project-image-modal {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 20, 23, 0.48);
}

.project-image-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(27, 33, 38, 0.16);
}

.project-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.project-image-head h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 17px;
}

.project-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 10px;
  min-height: 180px;
  padding: 12px;
  overflow: auto;
}

.project-image-option {
  display: grid;
  gap: 6px;
  padding: 6px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.project-image-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.project-image-option img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-muted);
}

.project-image-option span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-marquee {
  position: fixed;
  z-index: 24;
  pointer-events: none;
  border: 1px solid rgba(27, 33, 38, 0.55);
  border-radius: 6px;
  background: rgba(27, 33, 38, 0.08);
  box-shadow: inset 0 0 0 1px rgba(254, 254, 254, 0.35);
}

.batch-menu {
  position: fixed;
  z-index: 25;
  min-width: 148px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(27, 33, 38, 0.08);
}

.batch-menu button {
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  border-radius: 7px;
  font-size: 13px;
}

.batch-menu button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.batch-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.batch-menu button:disabled:hover {
  color: var(--muted);
  background: transparent;
}

.batch-menu .batch-delete {
  color: var(--red);
}

body.is-selecting-images {
  cursor: crosshair;
  user-select: none;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 150px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.gallery-grid > .empty-state {
  grid-column: 1 / -1;
}

.wall-task-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  user-select: none;
}

.wall-task-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(27, 33, 38, 0.14);
}

.wall-task-card.is-selected::after {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 24px;
  padding: 0 9px;
  color: var(--surface);
  background: var(--accent);
  border-radius: 999px;
  content: "已选";
  font-size: 12px;
  font-weight: 760;
  pointer-events: none;
}

.wall-task-visual {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 0;
  aspect-ratio: 3 / 4;
  padding: 18px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(254, 254, 254, 0.48), rgba(254, 254, 254, 0)),
    var(--surface-muted);
}

.wall-task-loader {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  border: 2px solid #cfd6dc;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: wall-spin 820ms linear infinite;
}

.wall-task-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #ffd5d0;
  border-radius: 999px;
  font-weight: 800;
}

.wall-task-status {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
}

.wall-task-hint {
  width: min(100%, 180px);
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 12px;
}

.wall-task-meta,
.wall-task-error {
  display: -webkit-box;
  min-height: 34px;
  margin: 0 0 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wall-task-error {
  color: var(--red);
}

.wall-task-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.wall-task-actions button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.wall-task-actions .task-apply:only-child {
  grid-column: 1 / -1;
}

.wall-task-card.queued .wall-task-loader {
  animation-duration: 1200ms;
  border-top-color: var(--muted);
}

.wall-task-card.failed .wall-task-visual,
.wall-task-card.cancelled .wall-task-visual {
  background:
    linear-gradient(135deg, rgba(255, 241, 239, 0.75), rgba(255, 255, 255, 0)),
    var(--surface-muted);
}

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

.image-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  user-select: none;
}

.image-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(27, 33, 38, 0.14);
}

.image-card.is-selected::after {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 24px;
  padding: 0 9px;
  color: var(--surface);
  background: var(--accent);
  border-radius: 999px;
  content: "已选";
  font-size: 12px;
  font-weight: 760;
  pointer-events: none;
}

.image-frame {
  position: relative;
  overflow: hidden;
  background: var(--surface-muted);
}

.image-link {
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--surface-muted);
  -webkit-user-drag: none;
}

.image-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface-muted);
  transition: transform 220ms ease;
  -webkit-user-drag: none;
}

.image-card:hover img {
  transform: none;
}

.action-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0));
  opacity: 0;
  transition: opacity 160ms ease;
}

.image-card:hover .action-overlay,
.image-card:focus-within .action-overlay {
  opacity: 1;
  pointer-events: none;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  pointer-events: auto;
}

.action-grid button,
.action-grid a {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
}

.action-grid .ghost-button,
.action-grid .secondary-button {
  color: var(--ink);
  background: rgba(254, 254, 254, 0.92);
  border-color: transparent;
}

.action-grid .ghost-button:hover,
.action-grid .secondary-button:hover {
  background: var(--surface);
}

.action-grid .danger-button {
  background: rgba(255, 241, 239, 0.94);
}

.action-grid .image-delete {
  grid-column: 1 / -1;
}

.image-info {
  padding: 10px;
}

.image-prompt {
  margin: 0 0 8px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-rating-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 9px;
}

.image-rating-button {
  min-width: 0;
  min-height: 28px;
  padding: 0 6px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.image-rating-button:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.image-rating-button[data-rating-value="usable"].is-active {
  color: #1f684b;
  background: #edf8f2;
  border-color: #badfce;
}

.image-rating-button[data-rating-value="favorite"].is-active {
  color: #8a5b0c;
  background: #fff6df;
  border-color: #ead08e;
}

.image-rating-button[data-rating-value="reject"].is-active {
  color: #aa352d;
  background: #fff1ef;
  border-color: #efbbb6;
}

dl {
  display: grid;
  gap: 4px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 11px;
}

dt,
dd {
  margin: 0;
}

dd {
  max-width: 68%;
  overflow: hidden;
  color: var(--muted);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-size {
  max-width: 76%;
  overflow: visible;
  white-space: normal;
}

.material-list {
  display: grid;
  gap: 8px;
  margin: -4px 0 14px;
}

.material-empty {
  padding: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed #c8d2d7;
  border-radius: var(--radius);
  font-size: 12px;
}

.material-chip {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.material-chip img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-muted);
}

.material-chip span {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-chip .material-remove {
  min-height: 32px;
  padding: 0 10px;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  background: #111417;
}

.image-preview-blur {
  position: absolute;
  inset: -40px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  filter: blur(24px) saturate(1.02);
  opacity: 0.68;
  transform: translateZ(0) scale(1.04);
  pointer-events: none;
}

.image-preview-stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: 20px;
  contain: layout paint size;
}

.image-preview-stage img {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  object-fit: contain;
  border-radius: 0;
  transform: translate3d(var(--preview-pan-x, 0px), var(--preview-pan-y, 0px), 0) scale(var(--preview-zoom, 1));
  transform-origin: center center;
  will-change: transform;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  contain: paint;
  backface-visibility: hidden;
}

.image-preview-stage img.is-zoomed {
  cursor: grab;
}

.image-preview-overlay.is-panning,
.image-preview-overlay.is-panning .image-preview-stage img {
  cursor: grabbing;
}

.image-preview-nav {
  position: fixed;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 72px;
  padding: 0;
  color: oklch(94% 0.006 238);
  background: oklch(18% 0.018 238 / 0.76);
  border: 1px solid oklch(72% 0.018 238 / 0.28);
  border-radius: 8px;
  font-size: 44px;
  font-weight: 520;
  line-height: 1;
  transform: translateY(-50%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.image-preview-nav:hover {
  background: oklch(24% 0.022 238 / 0.9);
}

.image-preview-nav:disabled {
  opacity: 0.32;
}

.image-preview-prev {
  left: 18px;
}

.image-preview-next {
  right: 18px;
}

.image-preview-rating {
  position: fixed;
  right: 50%;
  bottom: 18px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  width: min(320px, calc(100vw - 132px));
  margin: 0;
  padding: 8px;
  background: oklch(18% 0.018 238 / 0.78);
  border: 1px solid oklch(72% 0.018 238 / 0.26);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  transform: translateX(50%);
}

.image-preview-rating .image-rating-button {
  min-height: 34px;
  color: oklch(86% 0.008 238);
  background: oklch(24% 0.018 238 / 0.9);
  border-color: oklch(72% 0.018 238 / 0.2);
}

.image-preview-rating .image-rating-button:hover {
  color: oklch(96% 0.006 238);
  background: oklch(30% 0.02 238 / 0.95);
  border-color: oklch(82% 0.018 238 / 0.34);
}

.image-preview-rating .image-rating-button[data-rating-value="usable"].is-active {
  color: oklch(93% 0.05 158);
  background: oklch(36% 0.068 158 / 0.88);
  border-color: oklch(70% 0.075 158 / 0.46);
}

.image-preview-rating .image-rating-button[data-rating-value="favorite"].is-active {
  color: oklch(94% 0.06 86);
  background: oklch(40% 0.075 86 / 0.88);
  border-color: oklch(76% 0.09 86 / 0.46);
}

.image-preview-rating .image-rating-button[data-rating-value="reject"].is-active {
  color: oklch(94% 0.045 28);
  background: oklch(38% 0.078 28 / 0.88);
  border-color: oklch(72% 0.086 28 / 0.46);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .controls {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .sidebar-scroll {
    max-height: none;
    overflow: visible;
  }

  .sidebar-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    box-shadow: 0 -3px 10px rgba(27, 33, 38, 0.05);
  }

  .image-preview-nav {
    width: 40px;
    height: 58px;
    font-size: 36px;
  }

  .image-preview-prev {
    left: 10px;
  }

  .image-preview-next {
    right: 10px;
  }

  .image-preview-rating {
    bottom: 12px;
    width: min(300px, calc(100vw - 24px));
  }

  .gallery-shell {
    height: auto;
    min-height: 60vh;
    overflow: visible;
    padding: 18px 14px 28px;
  }
}

@media (max-width: 640px) {
  .sidebar-scroll,
  .sidebar-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .split-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-code-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-code-row .secondary-button {
    width: 100%;
    margin-bottom: 14px;
  }

  .favorite-actions,
  .api-actions {
    grid-template-columns: 1fr;
  }

  .gallery-toolbar {
    align-items: stretch;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gallery-thumb-size, 230px)), 1fr));
  }

  .gallery-size-control {
    border-left: 0;
    padding-left: 0;
  }

  .gallery-head,
  .task-item {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .gallery-head {
    flex-direction: column;
  }

  .gallery-main-actions,
  .account-strip {
    width: 100%;
  }

  .gallery-main-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .view-switch {
    width: 100%;
  }

  .workspace-launch {
    width: 100%;
  }

  .gallery-head .button-row,
  #refreshButton {
    width: 100%;
  }
}
