:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-soft: #f0f4f1;
  --ink: #1f2326;
  --muted: #697077;
  --line: #d9ded8;
  --teal: #147c75;
  --teal-strong: #0f5d58;
  --coral: #d75c3f;
  --gold: #b7791f;
  --focus: #2f80ed;
  --shadow: 0 18px 45px rgba(28, 35, 37, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 760;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 21px;
}

.status-pill,
.run-state {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-panel {
  overflow: hidden;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.mode-tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 124, 117, 0.12);
}

.generator-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

.quantity-stepper {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 7px;
  align-items: center;
}

.quantity-stepper input {
  padding: 0;
  text-align: center;
  font-weight: 760;
}

.quantity-button {
  width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal-strong);
  font-size: 20px;
  font-weight: 760;
  line-height: 1;
}

.quantity-button:hover {
  border-color: var(--teal);
  background: rgba(20, 124, 117, 0.07);
}

.quantity-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

textarea {
  resize: vertical;
  min-height: 96px;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}

.prompt-field textarea {
  min-height: 156px;
}

.negative-prompt-field textarea {
  min-height: 104px;
}

.merged-prompt-field textarea {
  min-height: 128px;
  background: var(--surface-soft);
  color: var(--muted);
}

.merged-prompt-field textarea:read-only {
  cursor: default;
}

.field-help {
  margin: -1px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.preset-button {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.preset-button.is-active {
  border-color: rgba(20, 124, 117, 0.45);
  background: rgba(20, 124, 117, 0.09);
  color: var(--teal-strong);
}

.image-fields {
  display: grid;
  gap: 14px;
  padding-top: 2px;
}

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

.reference-field,
.mask-field {
  display: grid;
  gap: 9px;
}

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

.field-label,
.field-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.field-count {
  font-variant-numeric: tabular-nums;
}

.field-notice {
  margin: 0;
  color: var(--coral);
  font-size: 12px;
  line-height: 1.35;
}

.field-notice:empty {
  display: none;
}

input[type="file"] {
  min-height: 44px;
  padding: 8px;
  color: var(--muted);
  font-size: 13px;
}

input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  border: 1px solid rgba(20, 124, 117, 0.32);
  border-radius: 7px;
  background: rgba(20, 124, 117, 0.08);
  color: var(--teal-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
}

.reference-empty {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 13px;
}

.reference-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reference-card.is-primary {
  border-color: rgba(20, 124, 117, 0.48);
  box-shadow: inset 0 0 0 1px rgba(20, 124, 117, 0.12);
}

.reference-media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--surface-soft);
}

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

.reference-order {
  position: absolute;
  left: 7px;
  top: 7px;
  max-width: calc(100% - 14px);
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 760;
}

.reference-name {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.reference-action,
.text-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 760;
}

.reference-action:hover,
.text-action:hover {
  border-color: var(--teal);
  background: rgba(20, 124, 117, 0.07);
}

.reference-action:disabled {
  cursor: default;
  border-color: rgba(20, 124, 117, 0.24);
  background: rgba(20, 124, 117, 0.08);
  color: var(--teal-strong);
}

.reference-action-danger {
  color: var(--coral);
}

.reference-action-danger:hover {
  border-color: var(--coral);
  background: rgba(215, 92, 63, 0.07);
}

.text-action {
  width: auto;
  min-height: 28px;
  padding: 0 9px;
}

.mask-preview {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.mask-preview img {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
  background:
    linear-gradient(45deg, #dfe5df 25%, transparent 25% 75%, #dfe5df 75%),
    linear-gradient(45deg, #dfe5df 25%, transparent 25% 75%, #dfe5df 75%),
    #fff;
  background-position:
    0 0,
    8px 8px,
    0 0;
  background-size: 16px 16px;
}

.mask-preview span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 760;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-strong);
  border-color: var(--teal-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.secondary-button:hover {
  border-color: var(--coral);
  color: var(--coral);
}

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

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

.result-panel {
  min-height: 640px;
  padding: 18px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.run-duration {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgba(20, 124, 117, 0.28);
  border-radius: 8px;
  background: rgba(20, 124, 117, 0.07);
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.history-save-state {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.history-save-state.is-success {
  border-color: rgba(20, 124, 117, 0.28);
  background: rgba(20, 124, 117, 0.07);
  color: var(--teal-strong);
}

.history-save-state.is-error {
  border-color: rgba(215, 92, 63, 0.35);
  background: rgba(215, 92, 63, 0.08);
  color: #9a3f2d;
}

.result-view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.result-view-tab {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.result-view-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 124, 117, 0.12);
}

.empty-state {
  min-height: 522px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 124, 117, 0.08), rgba(215, 92, 63, 0.08)),
    #fbfcfa;
  color: var(--muted);
  text-align: center;
}

.empty-preview {
  width: min(260px, 64%);
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(31, 35, 38, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(31, 35, 38, 0.1) 48% 52%, transparent 52%),
    linear-gradient(45deg, rgba(20, 124, 117, 0.16), rgba(183, 121, 31, 0.2));
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.generation-exchange {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.generation-exchange-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.generation-exchange h3,
.generation-exchange h4 {
  margin: 0;
}

.generation-exchange h3 {
  font-size: 15px;
  font-weight: 760;
}

.generation-exchange h4 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

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

.generation-exchange section {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.generation-exchange pre {
  min-height: 180px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.result-image-frame {
  width: 100%;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.result-card img {
  display: block;
  width: auto;
  max-width: none;
  height: 1000px;
  object-fit: contain;
  flex: 0 0 auto;
}

.result-meta {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.revised-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 140px));
  gap: 8px;
}

.result-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.result-link:hover {
  border-color: var(--teal);
  background: rgba(20, 124, 117, 0.07);
}

.result-link-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.result-link-primary:hover {
  border-color: var(--teal-strong);
  background: var(--teal-strong);
}

.notice {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(215, 92, 63, 0.35);
  border-radius: 8px;
  background: rgba(215, 92, 63, 0.08);
  color: #9a3f2d;
  font-size: 14px;
  line-height: 1.35;
}

.history-view {
  display: grid;
  gap: 14px;
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.history-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.compact-field {
  display: grid;
  gap: 6px;
}

.compact-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.compact-field input,
.compact-field select {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.history-clear-button {
  min-height: 38px;
  white-space: nowrap;
}

.history-mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 120px));
  gap: 6px;
  width: fit-content;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.history-mode-tab {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.history-mode-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 124, 117, 0.12);
}

.history-summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

.history-run-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-run-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-run-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.3;
}

.history-run-head time,
.history-run-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-run-prompt {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-thumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.history-thumb-button {
  flex: 0 0 auto;
  min-width: 0;
  width: 320px;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.history-thumb-button:hover {
  box-shadow:
    inset 0 0 0 1px var(--teal),
    0 4px 14px rgba(20, 124, 117, 0.14);
}

.history-thumb-button img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.history-run-actions {
  display: grid;
  grid-template-columns: minmax(0, 180px) auto;
  gap: 8px;
}

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

.history-wall-item {
  width: 100%;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  text-align: left;
}

.history-wall-item:hover {
  box-shadow:
    inset 0 0 0 1px var(--teal),
    0 6px 18px rgba(20, 124, 117, 0.14);
}

.history-wall-item img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-soft);
}

.history-wall-meta {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.history-wall-meta strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.history-wall-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-action {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 760;
}

.history-action:hover {
  border-color: var(--teal);
  background: rgba(20, 124, 117, 0.07);
}

.history-action-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.history-action-primary:hover {
  border-color: var(--teal-strong);
  background: var(--teal-strong);
}

.history-action-danger {
  color: var(--coral);
}

.history-action-danger:hover {
  border-color: var(--coral);
  background: rgba(215, 92, 63, 0.07);
}

.history-image-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.history-image-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 38, 0.58);
}

.history-image-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.history-image-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-image-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.history-image-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.history-image-close:hover {
  border-color: var(--teal);
  color: var(--teal-strong);
}

.history-image-stage {
  min-height: 280px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.history-image-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.history-image-details {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-image-details dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.history-image-details div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.history-image-details div:last-child {
  border-bottom: 0;
}

.history-image-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.history-image-details dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-image-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 150px));
  gap: 8px;
  justify-content: end;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .empty-state {
    min-height: 380px;
  }

  .history-toolbar,
  .history-filters {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .generation-exchange-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding: 18px 0;
  }

  .topbar,
  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

  .field-grid,
  .form-actions {
    grid-template-columns: 1fr;
  }

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

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

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

  .history-toolbar,
  .history-filters,
  .history-run-head,
  .history-run-actions {
    grid-template-columns: 1fr;
  }

  .history-run-head {
    display: grid;
  }

  .history-image-dialog {
    padding: 10px;
  }

  .history-image-panel {
    max-height: calc(100vh - 20px);
    padding: 12px;
  }

  .history-image-head {
    align-items: flex-start;
  }

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

  .history-mode-tabs {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-wall {
    grid-template-columns: 1fr;
  }

  .history-image-details div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
