* { box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --panel: #181b24;
  --panel-border: #2a2e3a;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --text: #e8e9ee;
  --text-dim: #9499a8;
  --success: #2ea043;
  --radius: 14px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(160deg, #11131c 0%, #1a1d2b 100%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

header { text-align: center; margin-bottom: 36px; }
header h1 { font-size: 28px; margin: 0 0 6px; }
.subtitle { color: var(--text-dim); margin: 0; font-size: 14px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 60px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.dropzone:hover { border-color: var(--accent-light); }
.dropzone.dragover {
  border-color: var(--accent);
  background: #1f2333;
  transform: scale(1.01);
}
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-dim); }
.dropzone-inner svg { color: var(--accent-light); margin-bottom: 8px; }
.dz-title { font-size: 17px; color: var(--text); margin: 0; font-weight: 600; }
.dz-sub { font-size: 13px; margin: 0; }

/* ---------- Result section ---------- */
.result-section { margin-top: 36px; }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
}

.pane { display: flex; flex-direction: column; gap: 8px; }
.pane-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}

.img-frame {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}
.img-frame img { max-width: 100%; max-height: 420px; display: block; }

.checkerboard {
  background-image:
    linear-gradient(45deg, #2a2e3a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2e3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2e3a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2e3a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #1d2030;
}

/* ---------- Export bar ---------- */
.export-bar {
  margin-top: 24px;
  display: flex;
  align-items: end;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.export-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.export-field select, .export-field input[type="color"] {
  background: #11131c;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.export-field input[type="color"] { padding: 2px; width: 60px; height: 38px; cursor: pointer; }

.primary-btn, .secondary-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn { background: var(--accent); color: #fff; }
.primary-btn:hover { background: var(--accent-light); }
.secondary-btn { background: transparent; color: var(--text-dim); border: 1px solid var(--panel-border); }
.secondary-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 11, 16, 0.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 999;
  text-align: center;
  padding: 20px;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #2a2e3a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { font-size: 16px; margin: 0; }
.loading-hint { font-size: 13px; color: var(--text-dim); margin: 0; max-width: 320px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #232838;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  border: 1px solid var(--panel-border);
}
.toast.error { background: #3a1620; border-color: #b00020; }
