:root {
  color-scheme: light;
  --ink: #18202e;
  --muted: #657286;
  --line: #d9e1eb;
  --paper: #f4f7fb;
  --white: #ffffff;
  --cyan: #0a9fbd;
  --green: #1eaf72;
  --amber: #d98b19;
  --red: #c94a4a;
  --shadow: 0 18px 48px rgba(24, 32, 46, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 0 clamp(18px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-weight: 850;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: var(--cyan);
  color: var(--white);
}

.nav-links {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.app-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.tool-header {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}

.tool-header p:last-child {
  max-width: 640px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.control-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  border: 2px dashed #b8c6d8;
  border-radius: 8px;
  background: #f8fbfe;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--cyan);
  background: #ecfbff;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.upload-icon svg {
  width: 28px;
  height: 28px;
}

.drop-title {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
}

.drop-meta {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

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

.field,
.slider-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.field input,
.field select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
}

.slider-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slider-field strong {
  color: var(--ink);
}

.slider-field input {
  width: 100%;
  accent-color: var(--green);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--green);
  color: var(--white);
}

.button-secondary {
  width: fit-content;
  margin: 0 20px 20px auto;
  border-color: var(--line);
  background: var(--ink);
  color: var(--white);
}

.button.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.status.is-success {
  color: var(--green);
}

.preview-panel {
  overflow: hidden;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.image-stage {
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
  min-height: 330px;
  margin: 0;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-color: #ffffff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.image-stage img {
  width: 100%;
  height: 100%;
  max-height: 430px;
  object-fit: contain;
  padding: 18px;
}

.image-stage img:not([src]) {
  visibility: hidden;
}

.image-stage figcaption {
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 750;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
}

.metrics div {
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metrics dd {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .site-header {
    min-height: 64px;
    padding: 0 18px;
  }

  .brand span:last-child {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell {
    width: min(100% - 28px, 680px);
    padding-top: 30px;
  }

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

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

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

  .metrics div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics div:last-child {
    border-bottom: 0;
  }

  .button-secondary {
    width: calc(100% - 40px);
    margin-left: 20px;
  }
}
