:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2532;
  --muted: #5e677a;
  --primary: #ff5a45;
  --primary-dark: #e14a37;
  --border: #dde2ec;
  --shadow: 0 12px 40px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #fff 10%, var(--bg) 100%);
}

.app { width: min(1100px, 92vw); margin: 2rem auto 3rem; }
.hero { text-align: center; margin-bottom: 1.6rem; }
.hero h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); font-weight: 600; }
.hero h1 span { font-weight: 800; }
.hero p { margin: .7rem 0 0; color: var(--muted); }

.uploader-panel,
.dashboard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.dashboard { margin-top: 1rem; }
.uploader-header,.dashboard-header { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1rem; }
h2,h3 { margin: 0; }
.subtle { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.upload-status { min-height: 1.2rem; margin-bottom: .4rem; color: #c0392b; font-weight: 600; }
.upload-status.ok { color: #1b8d5e; }


.header-actions {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}

.url-panel {
  border: 1px dashed #b7c0d8;
  border-radius: 12px;
  padding: .8rem;
  background: #fbfcff;
  margin-bottom: .8rem;
}

.url-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .5rem;
}

.url-input {
  border: 1px solid #c4cde0;
  border-radius: 8px;
  padding: .55rem .7rem;
  font-size: .95rem;
}

.url-list {
  margin: .6rem 0 0;
  padding-left: 1.1rem;
  color: #2b3657;
}

.url-list li {
  margin: .22rem 0;
  word-break: break-all;
}

.dropzone {
  border: 2px dashed var(--primary);
  border-radius: 14px;
  display:grid;
  place-items:center;
  min-height:170px;
  text-align:center;
  padding:1rem;
  cursor:pointer;
  transition: transform .2s ease, background-color .2s ease;
}
.dropzone.drag-active { transform: translateY(-1px); background: #fff4f2; }
.dropzone input { display:none; }
.dropzone strong { font-size: 1.1rem; color: var(--primary); }
.dropzone small { color: var(--muted); margin-top: .5rem; }

.image-grid { display:grid; gap:.85rem; }
.image-grid.empty { min-height:120px; border:1px dashed var(--border); border-radius:10px; place-items:center; }
.empty-state { color: var(--muted); }

.image-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .9rem;
  display: grid;
  grid-template-columns: 96px 1fr 240px;
  gap: 1rem;
  align-items: center;
  background: linear-gradient(180deg, #fff 0%, #f9fbff 100%);
}

.file-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.card-main { min-width: 0; }
.file-title { font-weight: 700; margin-bottom: .55rem; color: #23305f; }

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #dde4f2;
  overflow: hidden;
  margin-bottom: .55rem;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4e40ff 0%, #6d5cff 100%);
}

.progress-fill.negative {
  background: linear-gradient(90deg, #ff6d4b 0%, #ff9d5c 100%);
}

.file-meta { display: flex; flex-wrap: wrap; gap: .6rem; color: var(--muted); font-size: .9rem; }
.file-meta b { color: var(--text); }

.card-summary {
  border: 1px solid #e2e7f5;
  border-radius: 12px;
  background: #f8faff;
  padding: .7rem;
  position: relative;
}

.remove-icon {
  position: absolute;
  top: .35rem;
  right: .45rem;
  border: 0;
  background: transparent;
  color: #67718a;
  font-size: 1.25rem;
  cursor: pointer;
}

.summary-top {
  font-size: 1.2rem;
  font-weight: 800;
  color: #4f46e5;
  margin-bottom: .45rem;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: .86rem;
  color: #6a748f;
  margin: .15rem 0;
}

.summary-line b { color: #1c2b54; }

.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  margin-top: .5rem;
}

.btn { border:1px solid transparent; border-radius:8px; font-weight:600; padding:.55rem .8rem; background:#f2f4f8; cursor:pointer; }
.btn:disabled { cursor:not-allowed; opacity:.55; }
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background:#ebeff5; }
.btn-ghost { border-color:var(--border); background:#fff; }

.modal { position:fixed; inset:0; background:rgba(9,15,25,.65); display:none; align-items:center; justify-content:center; padding:1rem; z-index:20; overflow:auto; }
.modal.open { display:flex; }
.modal-content {
  width:min(1120px,95vw);
  max-height:90vh;
  overflow:auto;
  background:#20232c;
  border-radius:14px;
  color:#f5f7fb;
  display:grid;
  grid-template-columns:minmax(0,1fr) 330px;
  position:relative;
}
.modal-content.processing { cursor: progress; }
.modal-close { position:absolute; top:.3rem; right:.7rem; background:transparent; color:#fff; border:0; font-size:2rem; }
.modal-preview-wrap {
  padding:1rem;
  min-height:340px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#111318;
  position: relative;
  min-height: min(72vh, 760px);
}
.modal-preview-wrap img { max-width:100%; max-height:72vh; object-fit:contain; border-radius: 8px; }

.compare-stage {
  position: relative;
  width: min(100%, 860px);
  max-height: 72vh;
  aspect-ratio: 16/10;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: #0b1020;
}

.compare-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.after-layer {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 50%);
}

.compare-label {
  position: absolute;
  top: .8rem;
  z-index: 3;
  background: rgba(17,24,39,.84);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  border-radius: 6px;
  padding: .25rem .55rem;
}

.compare-label.before { left: .8rem; }
.compare-label.after { right: .8rem; }

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  z-index: 4;
  padding: 0;
}

.compare-divider::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: rgba(255,255,255,.9);
}

.divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.85);
  background: rgba(12,17,30,.92);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.divider-icon {
  width: 14px;
  height: 14px;
}

.preview-badge {
  position: absolute;
  left: 1.2rem;
  bottom: 1.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(14, 22, 38, 0.82);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: .22rem .6rem;
}
.modal-controls { border-left:1px solid #343844; padding:1.2rem; }
.stats-row { display:flex; justify-content:space-between; margin:.5rem 0; font-size: 1.02rem; }
.stats-row strong { font-variant-numeric: tabular-nums; }

label { display: block; margin-top: .75rem; font-weight: 600; }
.name-input {
  width: 100%;
  margin-top: .4rem;
  background: #0f172a;
  border: 1px solid #485067;
  color: #fff;
  border-radius: 8px;
  padding: .5rem .55rem;
}
.name-input:focus {
  outline: 2px solid rgba(255,90,69,.45);
  border-color: #ff7b6b;
}

#outputType {
  width:100%;
  margin-top:.4rem;
  background: #111827;
  border: 1px solid #434a5b;
  color: #fff;
  border-radius: 8px;
  padding: .45rem .55rem;
}

#qualitySlider {
  width:100%;
  margin-top:.5rem;
  accent-color: var(--primary);
}
#qualityValue {
  font-weight: 700;
  color: #ffb2a8;
}
.help { color:#b5c1dc; font-size:.95rem; margin: .8rem 0 .3rem; min-height: 2.4em; }
.modal-actions { display:grid; grid-template-columns:1fr 1fr; gap:.6rem; margin-top:.9rem; }

@media (max-width: 860px) {
  .url-input-row { grid-template-columns: 1fr; }
  .header-actions { width: 100%; }
  .image-card { grid-template-columns: 72px 1fr; }
  .file-thumb { width:72px; height:72px; }
  .card-summary { grid-column: span 2; }
  .modal-content { grid-template-columns: 1fr; }
  .modal-controls { border-left:0; border-top:1px solid #343844; }
}
