:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --ink: #1e2527;
  --muted: #667075;
  --line: #d9dedb;
  --panel: #ffffff;
  --accent: #0d766e;
  --accent-dark: #07564f;
  --wash: #eef4f1;
  --danger: #a33a2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100svh - 48px);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 168px;
  padding: 20px;
  border: 1px dashed #aeb8b5;
  border-radius: 8px;
  background: var(--wash);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.upload-zone:hover,
.upload-zone.is-dragging {
  border-color: var(--accent);
  background: #e4f0ec;
  transform: translateY(-1px);
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 28px;
  line-height: 1;
}

.upload-title {
  font-weight: 760;
}

.upload-meta,
.status,
.pane-header span {
  color: var(--muted);
  font-size: 13px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label,
.settings-grid span {
  color: #384144;
  font-size: 13px;
  font-weight: 720;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
}

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

select {
  height: 40px;
  padding: 0 10px;
}

textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 118, 110, 0.14);
}

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

.settings-grid label {
  display: grid;
  gap: 8px;
}

.primary-action {
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 760;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.primary-action:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status {
  min-height: 38px;
  line-height: 1.45;
}

.status.error {
  color: var(--danger);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-width: 0;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.pane-header a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.image-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(30, 37, 39, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(30, 37, 39, 0.035) 1px, transparent 1px),
    #f6f7f4;
  background-size: 24px 24px;
}

.image-stage img {
  display: none;
  max-width: 100%;
  max-height: calc(100svh - 150px);
  object-fit: contain;
  border: 1px solid rgba(30, 37, 39, 0.12);
  background: white;
}

.image-stage:not(.empty) img {
  display: block;
  animation: imageIn 220ms ease-out both;
}

.image-stage:not(.empty) p {
  display: none;
}

.image-stage p {
  max-width: 220px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.result-stage.is-loading::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  border: 3px solid rgba(13, 118, 110, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

@keyframes imageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

  .image-stage {
    min-height: 340px;
  }
}

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

  .workspace {
    min-height: calc(100svh - 24px);
  }

  .control-panel {
    padding: 16px;
  }

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