:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --card: #ffffff;
  --accent: #2563eb;
  --bg: #f4f6f9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc, var(--bg));
  min-height: 100vh;
}
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.preview {
  position: relative;
  min-height: 320px;
  padding: 24px;
  border-radius: 24px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eef0f3 25%, transparent 25%, transparent 75%, #eef0f3 75%),
    linear-gradient(45deg, #eef0f3 25%, transparent 25%, transparent 75%, #eef0f3 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.compare {
  position: relative;
  max-width: 100%;
  margin-top: 36px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .15);
  line-height: 0;
  user-select: none;
}
.compare[hidden] { display: none; }
.compare > img { display: block; max-width: 100%; height: auto; }
.before-clip {
  position: absolute; inset: 0;
  clip-path: inset(0 calc(100% - var(--pos) * 1%) 0 0);
  background: #0f172a;
}
.before-clip img { width: 100%; height: 100%; object-fit: contain; display: block; }
.divider {
  position: absolute; top: 0; bottom: 0; left: calc(var(--pos) * 1%);
  width: 2px; margin-left: -1px; background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .35);
  pointer-events: none;
}
.knob {
  position: absolute; top: 50%; left: 50%; width: 38px; height: 38px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: #fff; color: var(--ink); font: 700 18px/38px system-ui; text-align: center;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .4);
}
.tag {
  position: absolute; top: 10px; padding: 4px 10px; border-radius: 999px;
  background: rgba(15, 23, 42, .75); color: #fff; font: 600 12px/1.4 system-ui; pointer-events: none;
}
.tag-l { left: 10px; }
.tag-r { right: 10px; }
.compare input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: ew-resize;
}
.compare input[type=range]:focus-visible { opacity: 1; background: none; outline: 2px solid var(--accent); outline-offset: -2px; }
.badge {
  position: absolute; top: 16px; left: 16px;
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
}
.error { color: #b91c1c; font-weight: 600; background: #fff; padding: 12px 16px; border-radius: 12px; }
.spinner {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid #cbd5e1; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.urlbar {
  margin-top: 16px; padding: 14px 18px;
  background: var(--ink); color: #e2e8f0;
  border-radius: 18px; font-size: 14px;
  word-break: break-all; cursor: copy;
}
.stats {
  width: 100%; margin-top: 16px; border-collapse: collapse;
  background: var(--card); border-radius: 18px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}
.stats th, .stats td { text-align: left; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.stats th { font-weight: 700; }
.stats tbody tr:last-child td { border-bottom: 0; }

.right {
  background: var(--card); border-radius: 24px; padding: 24px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}
.lbl { display: block; font-weight: 700; margin: 18px 0 8px; }
.lbl:first-child { margin-top: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
select, input[type=url] {
  width: 100%; padding: 12px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
}
select:focus, input[type=url]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.bgrow { display: flex; gap: 8px; }
input[type=color] { width: 56px; height: 48px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.ghost { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 14px; font: inherit; cursor: pointer; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.thumbs { display: flex; gap: 12px; }
.thumbs button {
  width: 76px; height: 76px; padding: 0; border: 2px solid transparent;
  border-radius: 14px; overflow: hidden; cursor: pointer; background: #e2e8f0;
}
.thumbs button.active { border-color: #7dd3fc; box-shadow: 0 0 0 3px #e0f2fe; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.primary {
  width: 100%; margin-top: 18px; padding: 16px; font: inherit; font-weight: 700;
  color: #fff; background: var(--ink); border: 0; border-radius: 16px; cursor: pointer;
}
.primary:hover { background: #1e293b; }

.drop {
  display: block; text-align: center; padding: 18px 12px; cursor: pointer;
  border: 2px dashed #cbd5e1; border-radius: 14px; color: var(--muted); font-size: 14px;
}
.drop strong { color: var(--ink); }
.drop small { display: block; margin-top: 4px; font-size: 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: #eff6ff; }
.upmsg { margin: 8px 0 0; font-size: 13px; color: #b91c1c; }
.thumbs.wrap { flex-wrap: wrap; margin-top: 12px; }
.thumbs.wrap:empty { display: none; }

.thumbs .cell { position: relative; display: inline-block; }
.thumbs .cell .pick { display: block; }
.thumbs .del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; overflow: visible;
  border: 0; border-radius: 50%; background: var(--ink); color: #fff;
  font: 700 14px/22px system-ui; cursor: pointer; box-shadow: 0 1px 4px rgba(15, 23, 42, .4);
}
.thumbs .del:hover { background: #b91c1c; }
.thumbs .cell.armed .del { width: auto; padding: 0 9px; border-radius: 11px; background: #b91c1c; font-size: 12px; }

.hint { margin: 12px 4px 0; padding: 12px 16px; border-radius: 14px; background: #fffbeb; color: #92400e; font-size: 14px; }
.hint[hidden] { display: none; }
