:root {
  color-scheme: light;
  --bg: #eef4f2;
  --surface: #ffffff;
  --surface-muted: #f5f7f8;
  --line: #d7dee2;
  --text: #172026;
  --muted: #64727d;
  --primary: #116b5f;
  --primary-strong: #0a5048;
  --danger: #b3382c;
  --success: #1f7a4d;
  --shadow: 0 24px 60px rgba(28, 45, 55, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(17, 107, 95, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(77, 102, 118, 0.12), transparent 36%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.tool {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(215, 222, 226, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

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

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

.mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.78) 46% 54%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.78) 46% 54%, transparent 54%),
    var(--primary);
}

.brand p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.select-field select {
  min-width: 132px;
  height: 42px;
  border: 1px solid #aeb9c0;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

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

.primary {
  color: #fff;
  background: var(--primary);
}

.primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.secondary {
  color: #fff;
  background: #59656f;
}

.dropzone {
  min-height: 118px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px dashed #9cb6c2;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 22px;
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.dropzone.dragging {
  border-color: var(--primary);
  background: #f0faf7;
}

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

.drop-text {
  display: grid;
  gap: 8px;
}

.drop-text strong {
  font-size: 20px;
}

.drop-text span {
  color: var(--muted);
}

.status-row {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.status-row p {
  margin: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #8a969d;
}

.status-dot.busy {
  background: #c48922;
}

.status-dot.success {
  background: var(--success);
}

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

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

.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.preview-panel header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.preview-panel h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.preview-panel span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-frame {
  height: min(48vh, 520px);
  min-height: 360px;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
}

.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #dfe7eb 25%, transparent 25%),
    linear-gradient(-45deg, #dfe7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe7eb 75%),
    linear-gradient(-45deg, transparent 75%, #dfe7eb 75%);
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

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

.image-frame img.visible {
  display: block;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 640px);
    align-items: start;
    padding: 10px 0;
  }

  .tool {
    padding: 16px;
  }

  .topbar,
  .dropzone,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .controls {
    justify-content: stretch;
  }

  .select-field,
  .button,
  .select-field select {
    width: 100%;
  }

  .dropzone {
    justify-items: stretch;
  }

  .image-frame {
    height: 360px;
    min-height: 280px;
  }
}

.progress-wrap {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.progress-wrap[hidden] {
  display: none;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-meta strong {
  color: var(--text);
  font-size: 13px;
  min-width: 42px;
  text-align: right;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3eaed;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #3aa58c);
  transition: width 220ms ease;
}
