:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #182026;
  --muted: #6a747d;
  --line: #d8dee3;
  --accent: #24745a;
  --accent-dark: #185640;
  --warn: #a56319;
  --error: #a43a3a;
  --shadow: 0 18px 44px rgba(25, 33, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

h1,
h2,
p,
figure,
pre {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  border: 1px solid var(--line);
  background: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

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

.controls {
  padding: 16px;
  align-self: start;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  border: 1.5px dashed #aab5bc;
  border-radius: 8px;
  background: #fbfcfc;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: #eef7f3;
}

.dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-weight: 700;
}

.drop-hint {
  color: var(--muted);
  font-size: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.field {
  margin-top: 14px;
}

.url-field {
  display: block;
  margin-top: 14px;
}

label span,
.label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(36, 116, 90, 0.2);
  border-color: var(--accent);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 38px;
  margin: 0;
  color: var(--ink);
  background: #fff;
  border-right: 1px solid var(--line);
  font-size: 13px;
  text-transform: none;
}

.segmented label:last-child span {
  border-right: 0;
}

.segmented input:checked + span {
  color: #fff;
  background: var(--accent);
}

.inline-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.6fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
}

.check input {
  width: 18px;
  height: 18px;
}

.check span {
  margin: 0;
  color: var(--ink);
  text-transform: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

button,
.secondary {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
}

button {
  color: #fff;
  background: var(--accent);
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

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

.secondary.disabled {
  pointer-events: none;
  color: #99a4aa;
  border-color: var(--line);
}

.preview-area {
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
  gap: 18px;
  min-width: 0;
}

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

.image-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 360px;
  overflow: hidden;
}

figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

figcaption strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.image-box {
  display: grid;
  place-items: center;
  min-height: 280px;
  background:
    linear-gradient(45deg, #edf0f2 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f2 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f2 75%);
  background-color: #fff;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.image-box img {
  display: none;
  max-width: 100%;
  max-height: calc(100vh - 260px);
  object-fit: contain;
}

.image-box img.ready {
  display: block;
}

.activity {
  padding: 14px;
}

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

.activity h2 {
  font-size: 16px;
  letter-spacing: 0;
}

#taskSummary {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.progress {
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #e8edf0;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

pre {
  margin-top: 12px;
  min-height: 92px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  color: #263238;
  font-size: 12px;
  line-height: 1.5;
}

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

.warn {
  color: var(--warn);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

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

  .preview-area {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 18px 14px;
  }

  .layout {
    padding: 12px;
  }

  .field-grid,
  .inline-row,
  .actions,
  .image-grid {
    grid-template-columns: 1fr;
  }

  .image-box img {
    max-height: 56vh;
  }
}
