*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.6rem;
  color: #e6edf3;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  color: #8b949e;
}

h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-align: center;
}

/* Controls bar */
#controls {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 12px 20px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.control-group label {
  color: #8b949e;
  white-space: nowrap;
}

#threshold {
  width: 140px;
  accent-color: #f78166;
}

#threshold-value {
  color: #f78166;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
}

#diff-mode {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

#stats {
  font-size: 0.85rem;
  color: #8b949e;
  font-variant-numeric: tabular-nums;
}

#stats .diff-count {
  color: #f78166;
  font-weight: 600;
}

#stats .match-count {
  color: #3fb950;
  font-weight: 600;
}

/* Upload panels - two columns */
#upload-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  min-width: 0;
}

/* Diff panel - full width below */
#diff-panel {
  margin-bottom: 12px;
}

.drop-zone, .diff-zone {
  position: relative;
  border: 2px dashed #30363d;
  border-radius: 8px;
  background: #161b22;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone {
  height: 200px;
}

.diff-zone {
  cursor: default;
  border-style: solid;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #58a6ff;
  background: #1c2333;
}

.drop-zone.has-image {
  border-style: solid;
  border-color: #30363d;
  cursor: default;
}

.drop-zone.has-image:hover {
  border-color: #484f58;
}

.drop-label {
  color: #484f58;
  font-size: 0.9rem;
  pointer-events: none;
  position: absolute;
  text-align: center;
  padding: 20px;
}

.drop-zone.has-image .drop-label {
  display: none;
}

.drop-zone canvas, .diff-zone canvas {
  display: none;
  max-width: 100%;
  image-rendering: pixelated;
}

.drop-zone canvas {
  max-height: 100%;
}

.diff-zone canvas {
  max-height: 70vh;
}

.drop-zone.has-image canvas, .diff-zone.has-image canvas {
  display: block;
}

.diff-zone.has-image .drop-label {
  display: none;
}

/* Error banner */
#error-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #da3633;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
}

#error-banner.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Clear button on each image */
.clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(218, 54, 51, 0.85);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.drop-zone.has-image .clear-btn {
  display: flex;
}

.clear-btn:hover {
  background: #da3633;
}

/* Responsive */
@media (max-width: 900px) {
  #upload-panels {
    grid-template-columns: 1fr;
  }
}
