:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1f5f4;
  --text: #17201c;
  --muted: #68716b;
  --line: #d9dfda;
  --accent: #0d766f;
  --accent-strong: #0a5f5a;
  --warn: #a34118;
  --shadow: 0 16px 40px rgba(21, 31, 28, 0.1);
}

* {
  box-sizing: border-box;
}

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

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 24px;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.workspace,
.result-panel {
  min-width: 0;
}

.topbar,
.result-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

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

.primary-button:disabled,
.ghost-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.ghost-button {
  color: var(--accent-strong);
  background: #e5f2f0;
  border-color: #c4dfdb;
}

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

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

.panel,
.result-panel {
  padding: 18px;
}

.controls-row {
  margin-top: 18px;
  padding: 18px;
}

input[type="file"] {
  width: min(220px, 50%);
  color: var(--muted);
  font-size: 13px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.thumb,
.target-preview,
.result-box {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.thumb {
  aspect-ratio: 3 / 4;
}

.target-preview {
  display: grid;
  place-items: center;
  min-height: 520px;
  margin-top: 16px;
}

.thumb img,
.target-preview img,
.result-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.target-preview img,
.result-box img {
  object-fit: contain;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 88px;
  resize: vertical;
  padding: 12px;
}

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

.result-panel {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}

.result-box {
  display: grid;
  place-items: center;
  min-height: 0;
  color: var(--muted);
  text-align: center;
}

.result-box.loading {
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent),
    var(--surface-2);
  background-size: 220px 100%, 100% 100%;
  animation: shimmer 1.2s linear infinite;
}

.status-box {
  overflow: auto;
  max-height: 180px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111a17;
  color: #d8f5ef;
  padding: 12px;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
}

.status-box.error {
  color: #ffd8c9;
}

@keyframes shimmer {
  from {
    background-position: -220px 0, 0 0;
  }
  to {
    background-position: calc(100% + 220px) 0, 0 0;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
    height: auto;
    min-height: 640px;
  }
}

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

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

  .panel-grid,
  .controls-row {
    grid-template-columns: 1fr;
  }

  input[type="file"] {
    width: 100%;
  }

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

  .target-preview {
    min-height: 360px;
  }
}
