:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --panel: #fffaf1;
  --ink: #1d2328;
  --muted: #69707a;
  --line: #d7d0c3;
  --accent: #0b6e69;
  --accent-strong: #054a47;
  --accent-soft: #d9efeb;
  --warm: #be5b2a;
  --blue: #395c92;
  --shadow: 0 18px 48px rgba(39, 43, 44, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(11, 110, 105, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(190, 91, 42, 0.11), transparent 38%),
    var(--bg);
  color: var(--ink);
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto;
}

.panel,
.stage {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.92);
  box-shadow: var(--shadow);
}

.controls-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 22px;
  border-radius: 8px;
}

.stage {
  min-height: calc(100vh - 48px);
  padding: 24px;
  border-radius: 8px;
}

.brand-row,
.stage-toolbar,
.history-head,
.action-row,
.image-actions {
  display: flex;
  align-items: center;
}

.brand-row,
.stage-toolbar,
.history-head {
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand-row p,
.stage-toolbar p,
.empty-state p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-pill {
  min-width: 72px;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill.busy {
  background: #fdeccf;
  color: #8b4b00;
}

.status-pill.error {
  background: #ffe1dd;
  color: #9b271d;
}

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.field span,
.advanced summary {
  color: #394148;
  font-size: 0.82rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9c1b4;
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 105, 0.16);
  background: #ffffff;
}

.two-col,
.settings-grid {
  display: grid;
  gap: 12px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

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

.advanced {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.46);
}

.advanced summary {
  cursor: pointer;
}

.advanced textarea {
  margin-top: 10px;
  min-height: 86px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.action-row {
  gap: 10px;
  justify-content: flex-start;
}

.primary-btn,
.ghost-btn,
.text-btn {
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.primary-btn {
  min-height: 46px;
  gap: 9px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

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

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ghost-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  text-decoration: none;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.text-btn {
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 760;
}

.btn-icon {
  display: inline-grid;
  width: 1.1em;
  place-items: center;
  font-weight: 900;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.empty-state {
  min-height: 460px;
  place-items: center;
  align-content: center;
  border: 1px dashed #bbb1a3;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(11, 110, 105, 0.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(57, 92, 146, 0.07) 25%, transparent 25%),
    #fffaf2;
  background-size: 32px 32px;
}

.empty-art {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  gap: 8px;
  height: 88px;
  align-items: end;
}

.empty-art span {
  display: block;
  border-radius: 6px;
  background: var(--accent-soft);
}

.empty-art span:nth-child(1) {
  height: 64px;
  background: #ffd7bd;
}

.empty-art span:nth-child(2) {
  height: 88px;
  background: #cfe0ff;
}

.empty-art span:nth-child(3) {
  height: 54px;
  background: #d9efeb;
}

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

.image-frame {
  display: grid;
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, #eee7dd 25%, transparent 25%),
    linear-gradient(-45deg, #eee7dd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee7dd 75%),
    linear-gradient(-45deg, transparent 75%, #eee7dd 75%),
    #fffaf1;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-actions {
  justify-content: flex-end;
  gap: 8px;
  padding: 10px;
}

.history-strip {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.history-item {
  max-width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fffdf8;
  color: #394148;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  border-radius: 8px;
  padding: 13px 15px;
  background: #1f2930;
  color: white;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

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

  .controls-panel {
    position: static;
  }

  .stage {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .controls-panel,
  .stage {
    padding: 16px;
  }

  .two-col,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .stage-toolbar {
    align-items: flex-start;
  }

  .gallery {
    grid-template-columns: 1fr;
  }
}
