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

:root {
  --primary: #6c5ce7;
  --primary-hover: #5a4bd1;
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #2a2a40;
  --error: #e74c3c;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header { text-align: center; padding: 2.5rem 1rem 1rem; }
h1 { font-size: 2rem; font-weight: 700; }
.subtitle { color: var(--text-muted); margin-top: .4rem; font-size: 1.1rem; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.section { width: 100%; }

/* Drop Zone */
#drop-zone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--surface);
}
#drop-zone:hover, #drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, .08);
}
.drop-icon { font-size: 3rem; margin-bottom: .8rem; }
.drop-text { font-size: 1.1rem; font-weight: 500; }
.drop-hint { color: var(--text-muted); margin-top: .3rem; }
.drop-formats { color: var(--text-muted); font-size: .85rem; margin-top: .8rem; }

.error { color: var(--error); text-align: center; margin-top: .8rem; font-size: .9rem; }

/* Error Card */
.error-card {
  background: var(--surface);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}
.error-icon { font-size: 3rem; margin-bottom: 1rem; }
.error-card h2 { font-size: 1.3rem; color: var(--error); margin-bottom: .6rem; }
.error-detail { color: var(--text-muted); line-height: 1.5; margin-bottom: 1.5rem; }
.error-tips {
  background: rgba(108, 92, 231, 0.08);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  text-align: left;
  margin-bottom: 1.5rem;
}
.tips-title { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.error-tips ul {
  list-style: none;
  padding: 0;
}
.error-tips li {
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.6;
  padding-left: 1.2rem;
  position: relative;
}
.error-tips li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
}
#btn-retry { margin-top: .5rem; }

/* Processing */
#processing-section { text-align: center; padding: 3rem 0; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#progress-text { color: var(--text-muted); }

/* Compare */
#compare-container { margin-top: 1rem; }
#compare-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: repeating-conic-gradient(#2a2a2a 0% 25%, #1a1a1a 0% 50%) 0 0 / 20px 20px;
}
#compare-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
}
#canvas-result {
  position: absolute;
  top: 0; left: 0;
  clip-path: inset(0 0 0 0);
}

/* Image labels - always visible */
.img-label {
  position: absolute;
  top: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 4;
  opacity: 1;
}
#label-original {
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
#label-result {
  left: 12px;
  background: rgba(108, 92, 231, 0.8);
  color: #fff;
}

/* Slider line & handle - always visible */
#slider-line {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  background: rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 2;
  opacity: 1;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
#slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  user-select: none;
}

#compare-slider {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 3;
}

.compare-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: .6rem;
}

/* Buttons */
.actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.btn {
  padding: .75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

/* Footer */
footer {
  max-width: 800px;
  margin: 3rem auto 0;
  padding: 2rem 1rem;
  width: 100%;
}
.copyright { text-align: center; color: var(--text-muted); font-size: .85rem; margin-top: 2rem; padding-bottom: 2rem; }

/* Mobile */
@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  #drop-zone { padding: 2rem 1rem; }
  .actions { flex-direction: column; }
  .btn { width: 100%; }
}
