:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #0891b2;
  --accent-soft: #ecfeff;
  --preview-bg: transparent;
  --r: 16px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { width: min(1100px, 92vw); margin: 0 auto; flex: 1; }
a { color: inherit; }

.top { width: min(1100px, 92vw); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.01em; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--ink) 50%, #a5f3fc 50%); }
.tag { color: var(--muted); font-size: 0.9rem; }

.hero { text-align: center; padding: 28px 0 8px; }
h1 { font-size: clamp(2rem, 4.6vw, 3.2rem); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 14px; }
h1 span { color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); max-width: 620px; margin: 0 auto 28px; font-size: 1.08rem; line-height: 1.55; }

.drop {
  border: 2px dashed #cbd5e1; border-radius: 24px; background: var(--card);
  padding: 56px 20px; cursor: pointer; transition: border-color .15s, background .15s, transform .15s;
  outline: none;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.over { transform: scale(1.01); }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop .icon { width: 60px; height: 60px; border-radius: 18px; background: var(--ink); color: #fff; display: grid; place-items: center; margin-bottom: 6px; }
.drop strong { font-size: 1.2rem; }
.drop span { color: var(--muted); }

.model { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 16px auto 0; color: var(--muted); font-size: 0.88rem; max-width: 640px; }
.track { width: 120px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; flex: none; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.track.done .fill { background: #10b981; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 36px 0 14px; }
.bgs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.right { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--c, #fff); cursor: pointer; padding: 0; position: relative; overflow: hidden; }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.checker-sw, .checker { background-color: #fff; background-image: conic-gradient(#e5e7eb 25%, transparent 0 50%, #e5e7eb 0 75%, transparent 0); background-size: 16px 16px; }
.custom { background: conic-gradient(#f43f5e, #f59e0b, #10b981, #06b6d4, #8b5cf6, #f43f5e); }
.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.btn { font: inherit; font-weight: 600; font-size: 0.92rem; border-radius: 10px; padding: 9px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: #94a3b8; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); flex: 1; }
.btn.primary:hover { background: #1e293b; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.frame { position: relative; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; touch-action: none; user-select: none; }
.frame .checker { position: absolute; inset: 0; }
body.solid-bg .frame .checker { background: var(--preview-bg); }
.frame canvas { position: relative; max-width: 100%; max-height: 100%; }
.frame .orig, .frame .out { grid-area: 1 / 1; }
.frame .orig { opacity: .35; filter: grayscale(.4); }
.card.done .frame .orig { opacity: 0; }
.card.done .frame { cursor: pointer; }
.frame.compare .orig { opacity: 1 !important; filter: none; z-index: 2; }
.spinner { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; z-index: 3; }
.card.done .spinner, .card.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state { color: var(--muted); font-size: 0.82rem; }
.card.error .state { color: #dc2626; }
.actions { padding: 10px 14px 14px; display: flex; gap: 8px; }
.samples { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 0.9rem; flex-wrap: wrap; }
.sample { padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; width: 56px; height: 56px; background: none; transition: transform .12s, border-color .12s; }
.sample:hover, .sample:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.sample img { width: 100%; height: 100%; object-fit: cover; display: block; }
.results.single { grid-template-columns: 1fr; max-width: 760px; margin: 0 auto; }
.results.single .frame { aspect-ratio: auto; height: min(68vh, 640px); }
.results.single .actions { max-width: 420px; }

.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 64px 0 24px; }
.why div { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.why h3 { margin: 0 0 6px; font-size: 1.02rem; }
.why p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 0.95rem; }

.faq { max-width: 760px; margin: 40px auto 60px; }
.faq h2 { letter-spacing: -0.02em; }
details { border-bottom: 1px solid var(--line); padding: 14px 2px; }
summary { cursor: pointer; font-weight: 600; }
details p { color: var(--muted); line-height: 1.55; margin: 10px 0 2px; }

footer { width: min(1100px, 92vw); margin: 0 auto; padding: 24px 0 32px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

@media (max-width: 600px) {
  .tag { display: none; }
  .drop { padding: 40px 16px; }
  .model { flex-direction: column; gap: 6px; }
}

.nav { display: flex; gap: 18px; font-size: 0.92rem; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--ink); font-weight: 600; }
@media (max-width: 600px) { .nav { gap: 12px; font-size: 0.85rem; } }
.prose { max-width: 720px; margin: 24px auto 60px; line-height: 1.65; }
.prose h1 { font-size: 2rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.prose h2 { font-size: 1.15rem; margin-top: 28px; }
.prose p { color: #334155; }
.prose .muted { color: var(--muted); font-size: 0.9rem; }
.contact-email { font-size: 1.3rem; font-weight: 600; }
footer a { color: var(--muted); }
@media (max-width: 900px) { .top { flex-wrap: wrap; gap: 10px; } .nav { flex-wrap: wrap; gap: 8px 14px; } }
.prose { max-width: 720px; margin: 24px auto 60px; line-height: 1.65; }
.prose h1 { font-size: 2rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.prose h2 { font-size: 1.15rem; margin-top: 28px; }
.prose p { color: #334155; }
.prose .muted { color: var(--muted); font-size: 0.9rem; }
.contact-email { font-size: 1.3rem; font-weight: 600; }
footer a { color: var(--muted); }
