:root {
  --ink: #0b1530;
  --ink-2: #16254d;
  --paper: #f3f6fc;
  --card: #ffffff;
  --mist: #eaeff9;
  --line: #dde4f1;
  --cobalt: #3d63ff;
  --cobalt-d: #2b4be0;
  --mint: #12b886;
  --mint-d: #0b7a5a;
  --mint-bg: #e3f8f0;
  --slate: #5a6987;
  --soft: #b9c6e6;
  --radius: 18px;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 20px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }

/* ---------- Top bar ---------- */
.top { background: var(--ink); border-bottom: 1px solid rgba(255,255,255,0.08); }
.top-in {
  max-width: 1040px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 22px; }
.top nav a { color: var(--soft); text-decoration: none; font-weight: 600; font-size: 0.95rem; padding: 6px 2px; }
.top nav a:hover { color: #fff; }

/* ---------- Hero ---------- */
.hero { background: var(--ink); color: #fff; padding: 56px 20px 130px; }
.hero-in {
  max-width: 1040px; margin: 0 auto;
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center;
}
.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.5rem, 6.4vw, 4.2rem);
  line-height: 1.02; letter-spacing: -0.035em; font-weight: 800;
}
.lede { margin: 0 0 26px; max-width: 46ch; color: var(--soft); font-size: 1.15rem; }

.trust { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.trust li {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border: 1px solid rgba(255,255,255,0.18); border-radius: 99px;
  font-weight: 600; font-size: 0.93rem;
}
.trust svg { width: 18px; height: 18px; fill: none; stroke: var(--mint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Tool card ---------- */
.main { max-width: 1040px; margin: 0 auto; padding: 0 20px 24px; }

.tool {
  position: relative; z-index: 2; margin-top: -92px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 30px;
  box-shadow: 0 30px 70px -28px rgba(11,21,48,0.45);
}

.settings { display: grid; grid-template-columns: 1fr 1.5fr 1.2fr; gap: 24px; }
.set-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.set-label { font-weight: 800; font-size: 0.95rem; }
#qualityOut { color: var(--cobalt); font-weight: 800; font-variant-numeric: tabular-nums; }
.hint { margin: 8px 0 0; color: var(--slate); font-size: 0.85rem; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--mist); border-radius: 12px; }
.seg.wrap { flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; min-height: 44px; padding: 0 8px;
  border: 0; border-radius: 9px; background: transparent; color: var(--slate);
  font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--cobalt); color: #fff; box-shadow: 0 4px 12px -4px rgba(61,99,255,0.7); }

input[type="range"] { width: 100%; height: 28px; margin: 0 0 10px; background: transparent; accent-color: var(--cobalt); cursor: pointer; }

/* ---------- Drop zone ---------- */
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 220px; margin-top: 26px; padding: 28px 20px; text-align: center; cursor: pointer;
  background: #f7f9ff; border: 2px dashed #aebfe6; border-radius: 20px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.drop:hover, .drop.over { border-color: var(--cobalt); background: #eef3ff; }
.drop.over { transform: scale(1.01); }
.drop:focus-within { outline: 3px solid var(--cobalt); outline-offset: 3px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-icon {
  display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 6px;
  border-radius: 50%; background: var(--cobalt); box-shadow: 0 14px 28px -10px rgba(61,99,255,0.8);
}
.drop-icon svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.drop-sub { color: var(--slate); }

.notice { margin: 16px 0 0; padding: 12px 16px; background: #fff4e0; border: 1px solid #f0d6a4; border-radius: 12px; color: #6b4a00; font-weight: 500; }

/* ---------- Results ---------- */
.results { margin-top: 22px; display: grid; gap: 12px; }
.results:empty { display: none; }

.item {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 16px; align-items: center;
  padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px;
}
.thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; background: var(--mist); }
.info { min-width: 0; }
.name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sizes { color: var(--slate); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.bar { height: 8px; margin-top: 9px; background: var(--mist); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--cobalt); border-radius: 99px; transition: width 0.5s cubic-bezier(.2,.8,.2,1); }

.side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pill {
  padding: 3px 12px; border-radius: 99px; background: var(--mint-bg); color: var(--mint-d);
  font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.pill.none { background: var(--mist); color: var(--slate); font-size: 0.85rem; }
.pill.err { background: #fde8e8; color: #a12828; font-size: 0.85rem; }
.side-btns { display: flex; gap: 8px; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  font: inherit; font-weight: 700; font-size: 0.9rem; text-decoration: none; cursor: pointer;
}
.mini:hover { border-color: var(--cobalt); color: var(--cobalt); }
.mini.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.mini.primary:hover { background: var(--cobalt-d); color: #fff; }
.mini[aria-disabled="true"], .mini:disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Action bar ---------- */
.actions {
  position: sticky; bottom: 12px; z-index: 5; margin-top: 18px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; background: var(--ink); color: #fff; border-radius: 16px;
  box-shadow: 0 18px 40px -14px rgba(11,21,48,0.6);
}
.sum { display: flex; align-items: center; gap: 14px; }
.sum-big { display: flex; align-items: baseline; gap: 4px; font-weight: 800; font-size: 2rem; line-height: 1; color: #4be0b3; font-variant-numeric: tabular-nums; }
.sum-big small { font-size: 0.9rem; font-weight: 700; color: var(--soft); }
.sum-text { color: var(--soft); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.act-btns { display: flex; gap: 10px; }
.btn {
  min-height: 46px; padding: 0 22px; border: 0; border-radius: 12px;
  background: var(--cobalt); color: #fff; font: inherit; font-weight: 800; cursor: pointer;
}
.btn:hover { background: var(--cobalt-d); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn.ghost:hover { background: rgba(255,255,255,0.08); }

/* ---------- Compare dialog ---------- */
dialog {
  width: min(920px, 94vw); max-height: 94vh; padding: 0; border: 0; border-radius: 20px;
  background: #fff; color: var(--ink); overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(11,21,48,0.75); backdrop-filter: blur(4px); }
.cmp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; }
.cmp-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--mist); cursor: pointer; }
.x svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }

.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 68vh;
  background: var(--mist); overflow: hidden; user-select: none; -webkit-user-select: none;
  --p: 50%;
}
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
#cmpBefore, .d-before { clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.divider { position: absolute; top: 0; bottom: 0; left: var(--p); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 0 1px rgba(11,21,48,0.25); pointer-events: none; }
.divider span {
  position: absolute; top: 50%; left: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border-radius: 50%; background: #fff; box-shadow: 0 6px 18px rgba(11,21,48,0.4);
}
.divider span::before, .divider span::after { content: ""; position: absolute; top: 50%; margin-top: -5px; border: 5px solid transparent; }
.divider span::before { left: 6px; border-right-color: var(--cobalt); border-left-width: 0; }
.divider span::after { right: 6px; border-left-color: var(--cobalt); border-right-width: 0; }
.tag {
  position: absolute; bottom: 12px; padding: 5px 12px; border-radius: 99px;
  background: rgba(11,21,48,0.85); color: #fff; font-weight: 700; font-size: 0.82rem; pointer-events: none;
}
.tag-l { left: 12px; }
.tag-r { right: 12px; background: rgba(11,122,90,0.92); }
.stage input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; touch-action: pan-y; }
.stage input[type="range"]:focus-visible ~ .divider span { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.cmp-note { margin: 0; padding: 12px 20px 16px; color: var(--slate); font-size: 0.88rem; }

/* ---------- Content ---------- */
.content { max-width: 720px; margin: 72px auto 24px; }
.content section { margin-bottom: 44px; }
.content h2 { margin: 0 0 14px; font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 800; }
.content p, .content li { color: #2b3a5c; }
.content ul { padding-left: 22px; margin: 0 0 14px; }
.content li { margin-bottom: 8px; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { position: relative; padding: 4px 0 4px 48px; margin-bottom: 14px; counter-increment: s; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--cobalt); color: #fff; font-weight: 800; font-size: 0.95rem;
}

details { background: #fff; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; }
summary {
  position: relative; list-style: none; cursor: pointer; padding: 16px 52px 16px 18px; font-weight: 700;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font-size: 1.5rem; font-weight: 600; color: var(--cobalt); line-height: 1;
}
details[open] summary::after { content: "–"; }
details p { margin: 0; padding: 0 18px 18px; }

/* ---------- Footer ---------- */
.foot { margin-top: 40px; background: var(--ink); color: var(--soft); padding: 36px 20px calc(36px + env(safe-area-inset-bottom, 0px)); }
.foot-in { max-width: 1040px; margin: 0 auto; }
.foot strong { color: #fff; font-size: 1.05rem; }
.foot p { margin: 6px 0 0; font-size: 0.92rem; }

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
  .settings { grid-template-columns: 1fr; gap: 22px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .hero { padding: 30px 20px 110px; }
  .hero-in { grid-template-columns: 1fr; gap: 0; }
  .hero-art { margin-top: 30px; }
  .lede { font-size: 1.05rem; }
  .tool { margin-top: -80px; padding: 18px; border-radius: 20px; }
}

@media (max-width: 600px) {
  .top nav { gap: 14px; }
  .top nav a { font-size: 0.88rem; }
  .brand span { font-size: 0.98rem; }
  .trust li { padding: 7px 12px; font-size: 0.85rem; }
  .drop { min-height: 190px; }
  .drop-title { font-size: 1.15rem; }

  .item { grid-template-columns: 60px 1fr; gap: 12px; }
  .thumb { width: 60px; height: 60px; }
  .side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .side-btns { flex: 1; justify-content: flex-end; }

  .actions { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding: 12px; }
  .sum { width: 100%; justify-content: space-between; }
  .act-btns { width: 100%; }
  .act-btns .btn { flex: 1; }

  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; margin: 0; height: 100dvh; }
  dialog .stage { max-height: none; flex: 1; aspect-ratio: auto; }
  .content { margin-top: 52px; }
  .content h2 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 600px) {
  dialog .stage { min-height: 0; }
}

.top nav a, .btn, .mini, .seg button { white-space: nowrap; }

/* Hero demo */
.hero-art { margin: 0; }
.demo {
  aspect-ratio: 451 / 300; max-height: none; border-radius: 22px;
  box-shadow: 0 30px 50px -20px rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.12);
}
.hero-art figcaption { margin-top: 12px; color: var(--soft); font-size: 0.82rem; line-height: 1.5; }
@media (max-width: 820px) {
  .hero { padding-bottom: 100px; }
}

.brand { white-space: nowrap; flex-shrink: 0; }
.demo .tag-l { top: 10px; bottom: auto; left: 10px; }
.demo .tag-r { bottom: 10px; right: 10px; }
@media (max-width: 420px) {
  .brand span { font-size: 0.92rem; }
  .top-in { padding: 12px 16px; }
  .top nav { gap: 12px; }
  .top nav a { font-size: 0.84rem; }
  .demo .tag { font-size: 0.74rem; padding: 4px 10px; }
}
