:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --surface-muted: #f1f3f6;
  --line: rgba(25, 28, 34, 0.11);
  --line-strong: rgba(25, 28, 34, 0.2);
  --text: #16181d;
  --muted: #69707d;
  --soft: #8c95a3;
  --blue: #0a84ff;
  --blue-dark: #006bd8;
  --green: #288e5a;
  --amber: #a96b12;
  --rose: #c43d55;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.12);
  --shadow-soft: 0 10px 24px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

#prompt {
  min-height: 240px;
}

html {
  min-width: 320px;
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfbfd 0%, var(--bg) 58%, #eceff3 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

.app-shell {
  width: min(1680px, calc(100% - 28px));
  height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  padding: 14px 0 12px;
  overflow: hidden;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #111318;
  object-fit: cover;
}

h1 {
  font-size: 21px;
  line-height: 1.15;
  font-weight: 760;
}

.brand p,
.panel-head p,
.stage-title span,
.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.brand p {
  margin-top: 3px;
}

.top-actions,
.stage-actions,
.prompt-actions,
.inline-row,
.library-actions,
.queue-actions,
.edit-actions,
.brush-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-button,
.danger-action,
.secondary-action,
.primary-action,
.generate-button,
.side-canvas,
.canvas-primary-action,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.ghost-button,
.danger-action,
.secondary-action,
.primary-action,
.side-canvas,
.canvas-primary-action,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.ghost-button,
.side-canvas {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.danger-action {
  color: #b4233a;
  border-color: rgba(180, 35, 58, 0.24);
  background: rgba(180, 35, 58, 0.08);
}

.secondary-action {
  color: var(--blue);
  border-color: rgba(10, 132, 255, 0.28);
  background: rgba(10, 132, 255, 0.08);
}

.primary-action,
.generate-button,
.canvas-primary-action {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 20px rgba(10, 132, 255, 0.18);
}

button:hover:not(:disabled) {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.primary-action:hover:not(:disabled),
.generate-button:hover:not(:disabled),
.canvas-primary-action:hover:not(:disabled) {
  background: var(--blue-dark);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 9px;
}

.status-strip div,
.retention-notice,
.panel,
.stage-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.status-strip div {
  min-height: 54px;
  padding: 9px 11px;
}

.status-strip span {
  display: block;
  color: var(--soft);
  font-size: 11px;
  font-weight: 760;
}

.status-strip strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.retention-notice {
  margin-bottom: 10px;
  padding: 9px 12px;
  color: #70490a;
  background: rgba(255, 247, 222, 0.88);
  border-color: rgba(183, 120, 25, 0.22);
  font-size: 13px;
}

.workbench {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1 1 auto;
}

.panel,
.stage-panel {
  min-height: 0;
  overflow: hidden;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow-y: auto;
}

.results-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.stage-panel,
.library-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 14px;
}

.stage-panel {
  min-height: clamp(560px, calc(100vh - 220px), 640px);
}

.panel-head,
.stage-toolbar,
.batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2,
.stage-title h2,
.batch-head h3 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 760;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

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

label,
.label-row {
  color: #30343b;
  font-size: 12px;
  font-weight: 720;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 13px;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(10, 132, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

.segmented,
.quality-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: rgba(241, 243, 246, 0.84);
}

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

.quality-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented button,
.quality-row button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.segmented button.active,
.quality-row button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 5px 12px rgba(16, 24, 40, 0.08);
}

.upload-zone {
  min-height: 126px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 1px dashed rgba(10, 132, 255, 0.34);
  border-radius: 8px;
  padding: 12px;
  background: rgba(10, 132, 255, 0.05);
  color: var(--blue);
  text-align: center;
  cursor: pointer;
}

.upload-zone.dragover {
  background: rgba(10, 132, 255, 0.1);
}

.upload-zone em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

#reference-upload {
  display: none;
}

.reference-gallery {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.reference-thumb {
  position: relative;
}

.reference-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
}

.reference-thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
}

.inline-row input {
  min-width: 0;
}

.settings-drawer {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.settings-drawer summary {
  padding: 10px;
  color: #30343b;
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.drawer-content {
  padding: 0 10px 10px;
}

.ratio-grid {
  display: grid;
  gap: 6px;
}

.ratio-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ratio-grid button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.ratio-grid button.active {
  color: var(--blue);
  border-color: rgba(10, 132, 255, 0.35);
  background: rgba(10, 132, 255, 0.08);
}

.size-confirm-button,
.generate-button {
  width: 100%;
}

.generate-button {
  min-height: 42px;
  font-size: 14px;
  font-weight: 760;
}

.preview-layout {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
}

.preview-layout.is-canvas-mode {
  grid-template-columns: minmax(0, 1fr);
}

.stage-panel.is-canvas-mode .result-side {
  display: none;
}

.canvas-shell {
  min-width: 0;
  min-height: 540px;
  height: clamp(540px, calc(100vh - 250px), 740px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage-panel.is-canvas-mode .canvas-shell {
  min-height: 560px;
  height: min(640px, calc(100vh - 260px));
}

.image-frame {
  --active-aspect: 1 / 1;
  --preview-frame-width: 500px;
  --preview-frame-height: 500px;
  position: relative;
  min-height: 0;
  box-sizing: border-box;
  width: min(var(--preview-frame-width), calc(100% - 38px));
  height: min(var(--preview-frame-height), calc(100% - 38px));
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.02), 0 20px 45px rgba(16, 24, 40, 0.08);
}

.image-frame.has-image {
  padding: 0;
}

.image-frame.is-canvas-mode {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 0;
  aspect-ratio: auto;
}

.preview-viewport {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

#main-preview {
  display: block;
  align-self: center;
  justify-self: center;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  aspect-ratio: var(--active-aspect);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.18);
  pointer-events: auto;
}

.empty-preview {
  width: min(340px, 82%);
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-preview strong {
  color: var(--text);
  font-size: 18px;
}

.empty-preview span {
  font-size: 13px;
}

.image-meta {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.image-frame.has-image .image-meta {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  box-sizing: border-box;
  width: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.image-frame.has-image:hover .image-meta {
  opacity: 0.92;
  transform: translateY(0);
}

.image-meta span,
.image-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.image-meta span {
  color: var(--muted);
}

.preview-context {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.preview-context div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-context span,
.preview-context em {
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 760;
}

.preview-context strong,
.preview-context p {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.preview-nav {
  position: absolute;
  z-index: 6;
  top: 50%;
  width: 38px;
  height: 58px;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font-size: 28px;
}

.preview-nav:not(:disabled):hover {
  border-color: rgba(10, 132, 255, 0.38);
  background: rgba(255, 255, 255, 0.94);
  color: var(--blue);
}

.preview-prev {
  left: 12px;
}

.preview-next {
  right: 12px;
}

.preview-group-label {
  position: absolute;
  z-index: 7;
  top: 12px;
  right: 12px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.result-side,
.batch-panel {
  min-height: 0;
}

.batch-panel {
  height: min(528px, calc(100vh - 320px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex-direction: column;
  overflow: hidden;
}

.batch-head span,
.library-title span,
.queue-title span {
  min-width: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.batch-list,
.asset-list,
.queue-list {
  min-height: 0;
  overflow-y: auto;
}

.batch-list {
  display: grid;
  grid-auto-rows: max-content;
  gap: 8px;
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 13px;
}

.batch-card,
.queue-item,
.asset-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.batch-card {
  display: grid;
  gap: 8px;
  padding: 9px;
  color: var(--text);
}

.batch-card.is-active {
  border-color: rgba(10, 132, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.08);
}

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

.batch-title strong,
.batch-title em,
.batch-prompt,
.batch-note {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-title strong {
  font-size: 12px;
}

.batch-title em,
.batch-prompt,
.batch-note,
.batch-stats,
.batch-item span {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

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

.batch-actions span,
.batch-actions button {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 7px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.batch-stats,
.batch-items {
  display: none;
}

.batch-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
}

.batch-card.is-expanded .batch-stats,
.batch-card.is-expanded .batch-items {
  display: grid;
}

.batch-stats {
  margin-top: 0;
}

.batch-stats span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-items {
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}

.batch-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 6px;
  background: var(--surface-muted);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.batch-item:disabled {
  cursor: default;
  opacity: 0.7;
}

.batch-item.is-selected {
  border-color: rgba(10, 132, 255, 0.42);
  background: rgba(10, 132, 255, 0.08);
}

.batch-item strong {
  font-size: 11px;
}

.batch-item-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.batch-item-main strong,
.batch-item-main em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item-main em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.batch-thumb {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.batch-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-thumb i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 760;
}

.batch-item-tools {
  grid-column: 2;
  display: flex;
  gap: 5px;
}

.batch-item-tools span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 7px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.batch-item-tools span:hover {
  color: var(--blue);
  border-color: rgba(10, 132, 255, 0.32);
  background: rgba(10, 132, 255, 0.06);
}

.batch-item.is-done strong {
  color: var(--green);
}

.batch-item.is-failed strong {
  color: var(--rose);
}

.library-panel {
  display: block;
  height: auto;
  min-height: auto;
  overflow: visible;
  padding-bottom: 12px;
}

.library-head {
  align-items: flex-start;
}

.library-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-actions,
.queue-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.library-body {
  display: grid;
}

.library-retention {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  margin-bottom: 8px;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  min-height: auto;
  overflow: visible;
  color: var(--muted);
  font-size: 13px;
}

.asset-item {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  overflow: visible;
  min-height: 70px;
  height: 72px;
  padding: 8px;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.asset-item.active {
  border-color: rgba(10, 132, 255, 0.42);
}

.asset-item.is-selected {
  border-color: rgba(47, 155, 101, 0.46);
}

.asset-item img {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-muted);
}

.asset-item strong,
.asset-item em,
.asset-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-item strong {
  color: var(--text);
  font-size: 12px;
}

.asset-item em,
.asset-item small {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.queue-item-actions button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.asset-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  display: none;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.24);
}

.asset-item.is-selected .asset-check {
  display: block;
}

.queue-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.panel-head.compact {
  align-items: flex-start;
}

.queue-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-list {
  max-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  padding: 8px;
  min-height: 80px;
}

.queue-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.queue-item progress {
  width: 100%;
  height: 7px;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-muted);
  appearance: none;
}

.queue-item progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-muted);
}

.queue-item progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--blue);
}

.queue-item.done progress::-webkit-progress-value {
  background: var(--green);
}

.queue-item.error progress::-webkit-progress-value {
  background: var(--rose);
}

.queue-item-main strong,
.queue-item-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item-main strong {
  color: var(--text);
  font-size: 12px;
}

.queue-item-main span,
.queue-item-actions em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.queue-item.error {
  border-color: rgba(196, 61, 85, 0.28);
}

.queue-item.done {
  border-color: rgba(40, 142, 90, 0.24);
}

.queue-more-button {
  width: 100%;
  margin-top: 8px;
}

.infinite-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #eef1f5;
}

.canvas-toolstrip {
  position: relative;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.canvas-toolstrip button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.canvas-toolstrip button.active {
  color: var(--blue);
  border-color: rgba(10, 132, 255, 0.34);
  background: rgba(10, 132, 255, 0.08);
}

.infinite-canvas-viewport {
  flex: 1 1 auto;
  overflow: auto;
}

.infinite-canvas-surface {
  position: relative;
  width: 2400px;
  height: 1600px;
  background:
    linear-gradient(rgba(13, 18, 28, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 18, 28, 0.07) 1px, transparent 1px);
  background-color: #f8fafc;
  background-size: 40px 40px;
}

.canvas-draw-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 2400px;
  height: 1600px;
  pointer-events: none;
}

.infinite-canvas.is-brush .canvas-draw-layer {
  pointer-events: auto;
}

.canvas-draw-layer path {
  fill: none;
  stroke: #f04457;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.canvas-node,
.canvas-text {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
}

.canvas-node {
  width: 190px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 8px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.16);
}

.canvas-node img {
  display: block;
  width: 100%;
  height: 150px;
  border-radius: 6px;
  object-fit: cover;
}

.canvas-node-actions {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.canvas-node-actions button {
  position: relative;
  z-index: 1;
  min-height: 22px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.canvas-text {
  min-width: 160px;
  max-width: 260px;
  min-height: 42px;
  border: 1px solid rgba(10, 132, 255, 0.28);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.12);
}

.canvas-text.is-editing {
  outline: 3px solid rgba(10, 132, 255, 0.12);
}

.infinite-canvas.is-dragover .infinite-canvas-surface {
  box-shadow: inset 0 0 0 4px rgba(10, 132, 255, 0.2);
}

.modal-open {
  overflow: hidden;
}

.edit-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.edit-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.54);
}

.edit-dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.edit-head h2 {
  font-size: 16px;
}

.edit-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
}

.edit-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 14px;
  padding: 14px;
}

.edit-preview {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.edit-image-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.edit-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 190px);
  border-radius: 6px;
  object-fit: contain;
}

#edit-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.edit-tools {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
}

.edit-tools textarea {
  flex: 1 1 auto;
  min-height: 220px;
}

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

.toast {
  max-width: min(390px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
}

.toast.error {
  border-color: rgba(196, 61, 85, 0.3);
  color: var(--rose);
}

.toast.success {
  border-color: rgba(40, 142, 90, 0.3);
  color: var(--green);
}

.site-footer {
  flex: 0 0 auto;
  padding-top: 8px;
  color: var(--soft);
  text-align: center;
  font-size: 12px;
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

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

  .workbench,
  .results-workspace {
    grid-template-columns: 1fr;
  }

  .preview-layout {
    grid-template-columns: 1fr;
  }

  .canvas-shell,
  .batch-panel {
    height: auto;
  }

  .canvas-shell {
    height: min(528px, calc(100vh - 260px));
  }

  .batch-panel {
    max-height: 340px;
  }

  .library-panel {
    min-height: 520px;
  }

  .asset-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 18px);
    padding-top: 9px;
  }

  .topbar,
  .top-actions,
  .stage-toolbar,
  .stage-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .dimension-row,
  .dimension-slider-grid,
  .preview-layout,
  .edit-body {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    min-height: 720px;
  }

  .canvas-shell {
    height: min(680px, 78vh);
    min-height: 560px;
  }

  .image-frame {
    width: min(var(--preview-frame-width), calc(100% - 18px));
    height: min(var(--preview-frame-height), calc(100% - 18px));
  }

  .asset-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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