:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --panel: #fffaf0;
  --ink: #1f2422;
  --muted: #69716b;
  --line: #ded4c0;
  --teal: #2d7f86;
  --teal-dark: #1f5d61;
  --sun: #d29b43;
  --rose: #b96e5f;
  --shadow: 0 22px 60px rgba(43, 35, 25, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(45, 127, 134, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(210, 155, 67, 0.16), transparent 30%),
    var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  min-width: 0;
  background: rgba(255, 250, 240, 0.84);
  border: 1px solid rgba(222, 212, 192, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
}

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

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

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.15rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.icon-button {
  padding: 0 14px;
  background: var(--teal);
  color: white;
  font-weight: 700;
}

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

.icon-button:active,
.view-button:active {
  transform: translateY(0);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

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

.drop-zone {
  min-height: 0;
  padding: 18px;
}

.drop-zone.dragging .stage {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(45, 127, 134, 0.14);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 36, 34, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(31, 36, 34, 0.04) 1px, transparent 1px),
    #eee5d4;
  background-size: 28px 28px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 18px 48px rgba(29, 25, 18, 0.28);
}

.stage:not(.has-image) canvas,
.stage:not(.has-image) .compare-control,
.stage:not(.has-image) .status-text {
  display: none;
}

.stage.has-image .empty-state {
  display: none;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-width: 420px;
  padding: 28px;
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--teal);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.empty-state h2 {
  font-size: 1.45rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.empty-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

#beforeCanvas {
  position: absolute;
  opacity: 0;
  transition: opacity 180ms ease;
}

#afterCanvas {
  transition: opacity 180ms ease;
}

.stage.show-before #beforeCanvas {
  opacity: 1;
  z-index: 2;
}

.stage.show-before #afterCanvas {
  opacity: 0;
}

.compare-control {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 240, 0.68);
  border-radius: 8px;
  background: rgba(31, 36, 34, 0.74);
  backdrop-filter: blur(10px);
}

.view-button {
  min-width: 86px;
  border: 0;
  padding: 10px 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-weight: 700;
}

.view-button.active {
  background: rgba(255, 250, 240, 0.92);
  color: var(--ink);
}

.status-text {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  max-width: min(320px, calc(100% - 32px));
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(31, 36, 34, 0.74);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  backdrop-filter: blur(10px);
}

@media (max-width: 920px) {
  .app-shell {
    min-height: auto;
  }

  .stage {
    min-height: 56vh;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .icon-button {
    flex: 1;
  }

  .drop-zone {
    padding: 10px;
  }

  .stage {
    min-height: 58vh;
  }

  .compare-control {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .status-text {
    right: 10px;
    bottom: 62px;
  }

  .view-button {
    min-width: 0;
  }
}
