@charset "UTF-8";
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #6933FA;
  --accent-dark: #5420E0;
  --accent-light: #EDE8FF;
  --bg: #F8F7FC;
  --surface: #FFFFFF;
  --border: #E5E0F5;
  --text-primary: #1A1033;
  --text-secondary: #6B6585;
  --text-muted: #A09CBB;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(105,51,250,0.08);
  --shadow-md: 0 4px 16px rgba(105,51,250,0.12);
  --shadow-lg: 0 12px 40px rgba(105,51,250,0.18);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --ease: 0.2s ease;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: 64px;
}

/* ─── Loading overlay ─── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 247, 252, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 1000;
  transition: opacity 0.35s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.loading-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Header ─── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ─── Layout ─── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-intro {
  text-align: center;
  padding: 4px 0 8px;
}

.page-intro h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.page-intro p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* ─── Upload zone ─── */
#upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

#upload-zone:hover,
#upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(105, 51, 250, 0.04);
}

#file-input {
  display: none;
}

.upload-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent);
}

.upload-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.upload-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease), transform var(--ease);
}

.upload-cta:hover {
  background: var(--accent-dark);
  transform: scale(1.02);
}

.upload-formats {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ─── Preview thumbnail ─── */
#preview-wrap {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 14px;
}

#preview-wrap.visible {
  display: flex;
}

#preview-thumb {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--border);
}

.preview-info {
  flex: 1;
  min-width: 0;
}

.preview-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-dims {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.preview-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  transition: color var(--ease);
  flex-shrink: 0;
}

.preview-remove-btn:hover {
  color: #DC2626;
}

/* ─── Model error ─── */
#model-error-banner {
  display: none;
  padding: 12px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #991B1B;
  margin-top: 14px;
}

#model-error-banner.visible {
  display: block;
}

/* ─── Controls ─── */
#controls {
  display: none;
}

#controls.visible {
  display: block;
}

.scale-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.scale-btn {
  flex: 1;
  padding: 12px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.scale-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.scale-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.scale-btn:hover:not(.active) {
  border-color: var(--accent);
}

.scale-btn:hover:not(.active) .scale-num {
  color: var(--accent);
}

.scale-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: var(--shadow-sm);
}

.scale-btn.active .scale-num {
  color: var(--accent);
}

.scale-btn.active .scale-desc {
  color: var(--accent);
  opacity: 0.7;
}

#upscale-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--ease), transform var(--ease), opacity var(--ease);
}

#upscale-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: scale(1.01);
}

#upscale-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ─── Progress ─── */
#progress-wrap {
  display: none;
}

#progress-wrap.visible {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-title {
  font-size: 14px;
  font-weight: 500;
}

#progress-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.progress-track {
  height: 6px;
  background: var(--accent-light);
  border-radius: 3px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.35s ease;
}

#cancel-btn {
  margin-top: 12px;
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease);
}

#cancel-btn:hover {
  border-color: #DC2626;
  color: #DC2626;
}

/* ─── Result / comparison ─── */
#result-section {
  display: none;
}

#result-section.visible {
  display: block;
}

.comparison-outer {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: ew-resize;
  user-select: none;
  background: #111;
  touch-action: none;
}

.comparison-sizer {
  display: block;
  width: 100%;
}

.comparison-outer canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#before-canvas {
  z-index: 1;
}

#after-canvas {
  z-index: 2;
}

.slider-track {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  width: 48px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.slider-line {
  width: 2px;
  flex: 1;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.slider-grip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.comparison-labels {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px 0;
}

.comp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.image-meta {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin: 16px 0;
}

.image-meta strong {
  color: var(--text-primary);
}

.result-actions {
  display: flex;
  gap: 10px;
}

#download-btn {
  flex: 1;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--ease);
}

#download-btn:hover {
  background: var(--accent-dark);
}

#new-image-btn {
  padding: 13px 20px;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--ease), color var(--ease);
}

#new-image-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Toast ─── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 340px;
  padding: 14px 18px;
  background: #1A1033;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#toast.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#toast.is-info {
  background: #1E3A5F;
}

#toast.is-success {
  background: #065F46;
}

/* ─── Zoom window ─── */
#zoom-win {
  position: fixed;
  z-index: 998;
  width: 304px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

#zoom-win.visible {
  display: flex;
}

.zoom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.zoom-side-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#zoom-pill {
  padding: 3px 12px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--ease), transform var(--ease);
}

#zoom-pill:hover {
  background: var(--accent-dark);
  transform: scale(1.06);
}

.zoom-canvas-wrap {
  position: relative;
  line-height: 0;
}

#zoom-canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.zoom-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  pointer-events: none;
}

.zoom-footer {
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* ─── Crosshair overlay on comparison ─── */
#crosshair {
  position: absolute;
  z-index: 4;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  pointer-events: none;
  display: none;
}

#crosshair.visible {
  display: block;
}

#crosshair::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -60px;
  bottom: -60px;
  width: 1px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

#crosshair::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -60px;
  right: -60px;
  height: 1px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.ch-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.55);
}

/* ─── Footer ─── */
.app-footer {
  text-align: center;
  padding: 32px 24px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--ease);
}

.app-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

@media (max-width: 520px) {
  .container {
    padding: 20px 16px;
  }

  .card {
    padding: 18px 16px;
  }

  .page-intro h1 {
    font-size: 22px;
  }

  .result-actions {
    flex-direction: column;
  }

  #zoom-win {
    width: 260px;
  }
}