:root {
  --bg: #f8fafc;
  --ink: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --radius: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.shell { width: min(1180px, 100% - 32px); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar__row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand__dot { width: 12px; height: 12px; border-radius: 999px; background: #2563eb; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.14); }
.topbar__nav { display: flex; gap: 14px; }
.topbar__nav a { color: #1e293b; font-size: 14px; font-weight: 600; text-decoration: none; }
.topbar__nav a:hover { color: var(--brand-strong); }

.workspace { padding: 24px 0 34px; }
.hero { margin-bottom: 18px; }
.hero__kicker { margin: 0 0 8px; color: #2563eb; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.hero h1 { margin: 0 0 8px; font-size: clamp(30px, 6vw, 44px); line-height: 1.06; }
.hero p { margin: 0; max-width: 760px; color: var(--muted); font-size: 16px; }
.hero__chips { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #1e40af;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}
.chip--loading { border-color: #cbd5e1; background: #f8fafc; color: #334155; }
.chip--ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.chip--error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.model-progress {
  margin-top: 12px;
  width: min(460px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.model-progress__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: #334155;
}

.model-progress__row strong {
  color: #2563eb;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 18px; }

.dropzone {
  display: block;
  border: 1.5px dashed #93c5fd;
  border-radius: 14px;
  background: #f8fbff;
  padding: 18px;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
}
.dropzone:hover,
.dropzone.is-over { transform: translateY(-2px); border-color: #38bdf8; }
.dropzone__inner { text-align: center; }
.dropzone__inner strong { display: block; font-size: 18px; }
.dropzone__inner span { display: block; margin-top: 6px; color: #334155; }
.dropzone__inner small { display: block; margin-top: 8px; color: #64748b; }

.compare {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%), linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e2e8f0 75%), linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.compare img { width: 100%; height: 100%; object-fit: contain; display: block; }
.compare img { object-fit: cover; object-position: center; }
.compare__before-wrap { position: absolute; top: 0; right: 0; bottom: 0; width: 50%; overflow: hidden; }
.compare__before { position: absolute; inset: 0; }
.compare__after-wrap { position: absolute; inset: 0; width: 50%; overflow: hidden; }
.compare__after { position: absolute; inset: 0; }
.compare__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(15,23,42,.18);
  transform: translateX(-1px);
  pointer-events: none;
}

.compare__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.32);
  pointer-events: none;
}

.compare__slider {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  width: calc(100% - 20px);
}

.control { margin-bottom: 12px; }
.control label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: #334155; }
.control input[type='range'],
.control select,
.control input[type='color'] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #dbe3f3;
  background: #fff;
}
.control select { padding: 10px; font-family: inherit; }
.control input[type='color'] { height: 44px; padding: 4px; }

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dbe3f3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  background: #fff;
  cursor: pointer;
}

.actions { display: grid; gap: 9px; margin-top: 14px; }
.btn {
  border: 1px solid #dbe3f3;
  background: #fff;
  color: #0f172a;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { border-color: transparent; background: linear-gradient(135deg, #0f766e 0%, #0ea5e9 100%); color: #fff; }
.btn--primary { border-color: transparent; background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #fff; }
.btn--primary:hover:not(:disabled) { filter: brightness(0.95); }

.note { min-height: 20px; color: #64748b; font-size: 12px; margin: 8px 0 0; }
.note.error { color: #b91c1c; }
.note.ok { color: #166534; }

.processing {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  z-index: 90;
}
.processing.is-open { display: flex; }
.processing__box {
  width: min(92vw, 360px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 18px;
  text-align: center;
}
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 10px;
  border: 3px solid #dbeafe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.progress { width: 100%; height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.progress__bar { width: 0; height: 100%; background: linear-gradient(90deg, #2563eb, #1d4ed8); transition: width .2s ease; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.3);
  transition: transform .2s ease, opacity .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1020px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar__nav { display: none; }
  .shell { width: calc(100% - 22px); }
  .panel { padding: 14px; }
}
