:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #17202b;
  --muted: #5d6877;
  --line: #dde2e9;
  --brand: #1f3a5f;
  --brand-2: #2d5a8e;
  --accent: #2f80ed;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #171e27; --surface-2: #1f2833; --text: #e8edf3; --muted: #9aa6b4;
    --line: #2a3542; --brand: #8fb4e3; --brand-2: #a9c6ec; --accent: #5aa0ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
p.lead { color: var(--muted); margin: 0 0 1.25rem; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--surface);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--brand); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { color: var(--muted); font-size: .9rem; }
@media (max-width: 560px) { .who, .brand span { display: none; } }
.icon-btn { border: 0; background: transparent; padding: .35rem; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: .3rem .2rem; text-decoration: none; font-size: .95rem; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem calc(7rem + var(--safe-b)); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px;
  padding: .7rem 1.25rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 600; text-decoration: none; transition: transform .05s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f141a; } }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; font-size: 1.05rem; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .92rem; }
.input, textarea.input { width: 100%; min-height: 48px; padding: .7rem .85rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.error { color: var(--err); font-size: .92rem; min-height: 1.2em; }
.muted { color: var(--muted); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* login */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login { width: min(420px, 100%); padding: 2rem 1.5rem; }
.login .logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.5rem; color: var(--brand); font-weight: 800; font-size: 1.2rem; }

/* home */
.home-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.cons { overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.cons .thumb { aspect-ratio: 4/3; background: var(--surface-2); object-fit: cover; width: 100%; }
.cons .meta { padding: .7rem .85rem; }
.cons .meta strong { display: block; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); }
.badge.full { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* steps */
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; }
.steps span { flex: 1; height: 5px; border-radius: 99px; background: var(--line); }
.steps span.on { background: var(--brand); }

/* photo */
.photo-drop { position: relative; display: grid; place-items: center; text-align: center; aspect-ratio: 4/3;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.photo-drop .cta { display: grid; gap: .75rem; justify-items: center; padding: 1rem; }
.tips { margin: 1rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .92rem; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* scope */
.scope-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .scope-cards { grid-template-columns: 1fr; } }
.scope-card { text-align: left; padding: 1.25rem; cursor: pointer; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.scope-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.scope-card h2 { display: flex; align-items: center; gap: .5rem; }
.scope-card ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .93rem; }

/* selections */
.sel-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .sel-layout { grid-template-columns: 1fr; } }
.sel-preview { position: sticky; top: 76px; overflow: hidden; }
@media (max-width: 900px) { .sel-preview { position: static; } }
.sel-preview img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.sel-preview .summary { padding: .75rem .9rem; font-size: .9rem; }
.sel-preview .summary div { display: flex; justify-content: space-between; gap: .5rem; padding: .2rem 0; border-bottom: 1px dashed var(--line); }
.sel-preview .summary div:last-child { border: 0; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.4rem 0 .4rem; font-weight: 700; }
.cat { margin-bottom: 1.1rem; }
.cat-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .45rem; }
.cat-head h2 { margin: 0; font-size: 1.02rem; }
.req { font-size: .75rem; color: var(--warn); font-weight: 700; }
.opts { display: flex; gap: .65rem; overflow-x: auto; padding: .2rem .1rem .6rem; scroll-snap-type: x proximity; }
.opt { flex: 0 0 auto; width: 118px; scroll-snap-align: start; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; padding: 0; overflow: hidden; text-align: left; position: relative; }
.opt.on { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.opt .sw { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); display: grid; place-items: center;
  font-weight: 800; font-size: 1.6rem; color: var(--muted); }
.opt .nm { padding: .4rem .5rem; font-size: .84rem; font-weight: 600; line-height: 1.2; min-height: 2.6em; }
.opt .check { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand);
  color: #fff; display: none; place-items: center; font-size: 14px; font-weight: 800; }
.opt.on .check { display: grid; }

/* sticky action bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--line);
  padding: .75rem 1rem calc(.75rem + var(--safe-b)); }
.actionbar .inner { max-width: 1100px; margin: 0 auto; display: flex; gap: .75rem; align-items: center; }
.actionbar .grow { flex: 1; color: var(--muted); font-size: .92rem; }

/* result */
.compare { position: relative; overflow: hidden; border-radius: var(--radius); background: #000; user-select: none; touch-action: pan-y; }
.compare img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.compare .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare .after img { width: 100%; height: 100%; }
.compare .handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; background: #fff; transform: translateX(-1.5px); box-shadow: 0 0 6px rgba(0,0,0,.4); }
.compare .handle::after { content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 42px; height: 42px;
  border-radius: 50%; background: #fff; color: #1f3a5f; display: grid; place-items: center; font-weight: 900; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.compare .lbl { position: absolute; top: 10px; padding: .2rem .55rem; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: .8rem; font-weight: 700; }
.compare .lbl.l { left: 10px; } .compare .lbl.r { right: 10px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); padding: .55rem .9rem; cursor: pointer; font-weight: 600; min-height: 44px; }
.view-toggle button.on { background: var(--brand); color: #fff; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.side-by-side figure { margin: 0; } .side-by-side figcaption { font-size: .85rem; color: var(--muted); padding: .3rem 0; }
.side-by-side img { border-radius: 10px; width: 100%; }
.generating { aspect-ratio: 4/3; display: grid; place-items: center; text-align: center; position: relative; overflow: hidden; border-radius: var(--radius); }
.generating img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(6px) brightness(.55); }
.generating .msg { position: relative; color: #fff; display: grid; gap: .8rem; justify-items: center; padding: 1rem; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.history { display: flex; gap: .6rem; overflow-x: auto; padding: .3rem 0; }
.history button { flex: 0 0 auto; width: 110px; border: 2px solid var(--line); border-radius: 10px; padding: 0; overflow: hidden; background: var(--surface); cursor: pointer; position: relative; }
.history button.on { border-color: var(--brand); }
.history img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.history .st { font-size: .75rem; padding: .25rem; text-align: center; }
.history .fav { position: absolute; top: 4px; right: 6px; color: #f5b301; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.result-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.failed { padding: 1.25rem; border-left: 4px solid var(--err); }

.toast { position: fixed; left: 50%; bottom: calc(5.5rem + var(--safe-b)); transform: translateX(-50%); z-index: 50;
  background: #17202b; color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--err); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* real installs */
.installs-box { padding: .75rem .9rem; border-top: 1px solid var(--line); }
.installs-box.wide { border: 0; padding: .5rem 0 1rem; }
.installs-box h3 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.installs { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; }
.inst { flex: 0 0 auto; width: 92px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; cursor: pointer; background: var(--surface-2); }
.installs-box.wide .inst { width: 150px; }
.inst img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.inst .score { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; font-weight: 700; padding: .05rem .35rem; border-radius: 6px; }
.small { font-size: .85rem; }
dialog.lightbox { border: 0; padding: 0; border-radius: 16px; width: min(960px, 96vw); background: var(--surface); color: var(--text); }
dialog.lightbox::backdrop { background: rgba(0,0,0,.7); }
dialog.lightbox img { width: 100%; max-height: 72vh; object-fit: contain; background: #000; }
.lb-meta { padding: 1rem; display: grid; gap: .6rem; }
.lb-meta .badge { margin: 0 .2rem .2rem 0; }
