:root {
  color-scheme: light;
  --bg: #eef1f6;
  --stage: #e6ebf3;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --ink: #161c2a;
  --muted: #687284;
  --line: #e1e6ee;
  --primary: #2f6df6;
  --primary-soft: #e6eeff;
  --dark: #1b2233;
  --accent: #e8578a;
  --good: #22a77a;
  --warn: #e29b25;
  --bad: #e0484f;
  --focus: #1f56d6;
  --radius: 20px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --target-size: 24px;
  --tabbar-h: 64px;
  --font: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}
@media (pointer: coarse) { :root { --target-size: 44px; } }

* { box-sizing: border-box; }
html { scroll-padding-bottom: calc(var(--tabbar-h) + 5rem + env(safe-area-inset-bottom, 0px)); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; overflow-wrap: break-word; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p, li { text-wrap: pretty; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 1.25em; height: 1.25em; flex: none; }
img { max-inline-size: 100%; block-size: auto; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
:where(button, select, input:not([type="checkbox"], [type="radio"], [type="range"]), label:has(input[type="radio"], input[type="checkbox"])) { min-block-size: var(--target-size); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.fine-print { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.stack { display: grid; gap: 0.6rem; }
.card { background: var(--surface); border-radius: 18px; padding: 0.9rem; display: grid; gap: 0.75rem; box-shadow: 0 1px 0 var(--line); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-block-size: 50px; padding: 0 1.25rem; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; cursor: pointer; transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.dark { background: var(--dark); color: #fff; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.small { min-block-size: 40px; padding: 0 0.95rem; font-size: 14px; }
.btn.block { inline-size: 100%; }
.btn.danger { color: var(--bad); }
@media (hover: hover) and (pointer: fine) { .btn.dark:hover { background: #2a3348; } .btn.ghost:hover { background: var(--surface-2); } }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 500; font-size: 13px; cursor: pointer; }
.icon-btn { display: grid; place-items: center; inline-size: 44px; block-size: 44px; border: 0; background: none; border-radius: 12px; cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; }
.heart { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; inline-size: 34px; block-size: 34px; min-block-size: 34px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.92); cursor: pointer; color: #7b8496; box-shadow: 0 1px 4px rgb(20 30 50 / 0.12); transition: transform 160ms var(--ease-out), color 160ms ease; }
.heart::after { content: ""; position: absolute; inset: -5px; }
.heart svg { width: 19px; height: 19px; fill: none; }
.heart[aria-pressed="true"] { color: var(--accent); }
.heart[aria-pressed="true"] svg { fill: currentColor; }
.heart:active { transform: scale(0.88); }
.heart-btn[aria-pressed="true"] { color: var(--accent); border-color: #f7c6d7; }
.heart-btn svg { fill: none; }
.heart-btn[aria-pressed="true"] svg { fill: currentColor; }

/* ---------- app shell ---------- */
.app { max-inline-size: 1180px; margin-inline: auto; min-block-size: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
.topbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 0.5rem; padding: max(0.4rem, env(safe-area-inset-top, 0px)) 0.75rem 0.4rem; background: rgb(238 241 246 / 0.88); backdrop-filter: blur(12px); }
.top-title { text-align: center; font-size: 17px; font-weight: 700; }
body[data-screen="home"] .top-title { display: flex; align-items: center; gap: 0.35rem; justify-content: flex-start; font-family: 'Outfit', var(--font); font-size: 22px; font-weight: 600; }
.top-logo { width: 34px; height: 34px; }
body[data-screen="home"] .topbar { grid-template-columns: 0 1fr auto; }
.demo-chip { font-size: 11px; font-weight: 700; color: #8a5a00; background: #fff3d6; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; }
#view { padding: 0 1rem 1.5rem; }
.screen { display: grid; gap: 1rem; align-content: start; transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out); }
@starting-style { .screen { opacity: 0; transform: translateY(8px); } }
.screen h3 { font-size: 17px; }

.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); max-inline-size: 640px; margin-inline: auto; background: rgb(255 255 255 / 0.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 0.35rem 0.5rem max(0.35rem, env(safe-area-inset-bottom, 0px)); }
@media (min-width: 680px) { .tabbar { bottom: 12px; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 10px 30px rgb(20 30 50 / 0.1); } }
.tabbar a { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: #8a93a4; padding: 0.3rem 0; border-radius: 12px; min-block-size: 48px; transition: color 160ms ease; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current] { color: var(--primary); font-weight: 700; }

/* ---------- home ---------- */
.home-brand { display: flex; align-items: center; gap: 0.45rem; font-family: 'Outfit', var(--font); font-size: 22px; font-weight: 600; color: var(--dark); margin-top: -2.4rem; padding-left: 0.25rem; pointer-events: none; }
.home-brand svg { width: 36px; height: 36px; }
.hero { position: relative; display: grid; grid-template-columns: 1fr 44%; gap: 0.5rem; align-items: end; padding: 1.4rem 1.1rem 1.1rem; border-radius: 26px; background: linear-gradient(140deg, #f7f9ff 0%, #dfe8fb 100%); overflow: hidden; }
.hero-copy h2 { font-size: clamp(26px, 7vw, 38px); font-weight: 900; letter-spacing: 0.02em; color: var(--dark); }
.hero-copy > p { color: var(--muted); font-size: 16px; margin: 0.15rem 0 1rem; letter-spacing: 0.1em; }
.hero-feats { list-style: none; padding: 0; margin: 0 0 4.2rem; display: grid; gap: 0.7rem; }
.hero-feats a { display: flex; align-items: center; gap: 0.65rem; }
.hero-feats b { display: block; font-size: 14px; }
.hero-feats small { color: var(--muted); font-size: 12px; }
.feat-ic { display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: 50%; background: #fff; color: var(--dark); box-shadow: 0 2px 8px rgb(30 50 90 / 0.08); }
.hero-img { align-self: stretch; inline-size: 100%; block-size: 100%; max-block-size: 340px; object-fit: contain; filter: drop-shadow(0 12px 18px rgb(30 50 90 / 0.15)); }
.hero-img:not([src]) { visibility: hidden; }
.hero-cta { position: absolute; left: 1.1rem; right: 1.1rem; bottom: 1.1rem; max-inline-size: 320px; margin-inline: auto; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 0.4rem; }
.section-head a { display: inline-flex; align-items: center; font-size: 13px; color: var(--muted); }
.section-head a svg { width: 16px; height: 16px; }
.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 40%); gap: 0.7rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 0.25rem; scrollbar-width: none; }
.hscroll > * { scroll-snap-align: start; }
@media (min-width: 880px) { .hscroll { grid-auto-columns: minmax(170px, 19%); } }

/* product & outfit cards */
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.pcard, .ocard { position: relative; display: block; background: var(--surface); border-radius: 18px; padding: 0.5rem 0.5rem 0.75rem; box-shadow: 0 1px 0 var(--line); transition: transform 160ms var(--ease-out); }
.pcard > a { display: grid; gap: 0.15rem; }
.ocard { display: grid; gap: 0.15rem; }
.pcard:active, .ocard:active { transform: scale(0.98); }
.pimg { display: block; aspect-ratio: 5 / 6; border-radius: 14px; background: radial-gradient(80% 70% at 50% 40%, #fbfcfe, #edf1f7); overflow: hidden; }
.pimg img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.pimg img:not([src]) { visibility: hidden; }
.fit-badge { justify-self: start; margin-top: 0.35rem; font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 0.05rem 0.4rem; }
.pname { font-weight: 700; font-size: 14px; margin-top: 0.2rem; line-height: 1.35; }
.pmeta { font-size: 12px; color: var(--muted); }
.ocard .pimg { aspect-ratio: 3 / 4; }

/* tabs */
.tabs { display: flex; gap: 1.1rem; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 0.55rem 0.1rem; font-size: 15px; color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); font-weight: 700; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; block-size: 2.5px; border-radius: 2px; background: var(--primary); }

/* segmented control (native radios) */
.seg { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.seg-track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.seg label { position: relative; display: flex; align-items: center; justify-content: center; min-block-size: 40px; border-radius: 10px; font-weight: 500; font-size: 14px; color: var(--muted); cursor: pointer; transition: background-color 180ms ease, color 180ms ease; text-align: center; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-track label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 4px rgb(20 30 40 / 0.1); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg.underline { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 1px solid var(--line); }
.seg.underline label { border-radius: 0; min-block-size: 46px; }
.seg.underline label:has(input:checked) { color: var(--primary); font-weight: 700; box-shadow: inset 0 -2.5px 0 var(--primary); }
.field-label { font-size: 14px; font-weight: 700; padding: 0; margin-bottom: 0.4rem; }
.row-between .field-label { margin: 0; }

/* ---------- split screens (stage + sheet) ---------- */
.screen.split { gap: 0; margin-inline: -1rem; }
.stage { position: relative; block-size: 52dvh; min-block-size: 320px; background: radial-gradient(90% 70% at 50% 35%, #fbfcfe 0%, var(--stage) 75%); touch-action: none; overflow: hidden; }
.stage canvas { display: block; inline-size: 100%; block-size: 100%; cursor: grab; }
.stage-hint { position: absolute; left: 50%; bottom: 2.2rem; translate: -50% 0; font-size: 12px; color: var(--muted); background: rgb(255 255 255 / 0.7); padding: 0.2rem 0.6rem; border-radius: 999px; pointer-events: none; white-space: nowrap; }
.stage-badge { position: absolute; top: 0.75rem; left: 0.75rem; background: var(--surface); border-radius: 999px; padding: 0.3rem 0.75rem; font-size: 13px; font-weight: 700; box-shadow: 0 2px 10px rgb(20 30 40 / 0.08); }
.stage-badge:empty { display: none; }
.stage-badge .dot { display: inline-block; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--accent); margin-right: 0.35rem; vertical-align: 1px; }
.legend { position: absolute; top: 3rem; left: 0.75rem; display: grid; gap: 0.2rem; font-size: 12px; background: rgb(255 255 255 / 0.88); padding: 0.5rem 0.65rem; border-radius: 12px; }
.legend span { display: flex; align-items: center; gap: 0.4rem; }
.sw { inline-size: 10px; block-size: 10px; border-radius: 3px; }
.sw.tight { background: #e6454d; } .sw.stretch { background: #f2b33c; } .sw.good { background: #33b88c; } .sw.loose { background: #4d85eb; }
.thumb-rail { position: absolute; top: 0.75rem; right: 0.75rem; display: grid; gap: 0.45rem; max-block-size: calc(100% - 5rem); overflow-y: auto; scrollbar-width: none; }
.thumb-rail a { display: block; inline-size: 56px; block-size: 66px; border-radius: 12px; background: #fff; border: 2px solid transparent; overflow: hidden; box-shadow: 0 1px 4px rgb(20 30 50 / 0.1); }
.thumb-rail a[aria-current] { border-color: var(--primary); }
.thumb-rail img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.fab { position: absolute; left: 0.75rem; bottom: 2rem; display: inline-flex; align-items: center; gap: 0.35rem; border: 0; background: var(--dark); color: #fff; font-weight: 700; font-size: 13px; padding: 0.55rem 0.9rem; border-radius: 999px; cursor: pointer; box-shadow: 0 6px 18px rgb(20 30 50 / 0.25); transition: transform 160ms var(--ease-out); }
.fab:active { transform: scale(0.95); }
.compare-labels { position: absolute; inset-inline: 0; bottom: 4.6rem; display: flex; justify-content: center; gap: 30%; pointer-events: none; }
.compare-labels span { background: var(--surface); padding: 0.2rem 0.7rem; border-radius: 999px; font-weight: 700; font-size: 13px; box-shadow: 0 2px 8px rgb(20 30 50 / 0.1); }

.sheet { position: relative; z-index: 1; margin-top: -22px; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -6px 24px rgb(20 30 40 / 0.06); padding: 1rem 1rem 1rem; display: grid; gap: 1rem; align-content: start; }
.sheet h2 { font-size: 20px; }
.footer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 0.6rem 0 0.25rem; background: linear-gradient(to bottom, rgb(255 255 255 / 0), var(--surface) 35%); }
.screen:not(.split) .footer { background: linear-gradient(to bottom, rgb(238 241 246 / 0), var(--bg) 35%); }
.footer.two { display: grid; grid-template-columns: 1fr 1.5fr; gap: 0.6rem; }

@media (min-width: 880px) {
  .screen.split { grid-template-columns: 1fr 440px; gap: 1.25rem; margin-inline: 0; align-items: start; }
  .split .stage { position: sticky; top: 4rem; block-size: calc(100dvh - 4rem - var(--tabbar-h) - 2rem); border-radius: 28px; }
  .split .sheet { margin-top: 0; border-radius: 28px; }
  #view { padding-inline: 1.25rem; }
}

/* try-on sheet */
.prod-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.7rem; }
.prod-row img { inline-size: 52px; block-size: 62px; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.prod-txt b { display: block; font-size: 16px; }
.prod-txt small { color: var(--muted); }
.rec-banner { display: grid; grid-template-columns: auto 1fr; gap: 0.7rem; align-items: center; background: #e9f8f1; border-radius: 16px; padding: 0.75rem 0.85rem; }
.rec-banner:has(.mini-rec) { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); background: var(--surface-2); }
.rec-banner b { display: block; }
.rec-banner small { color: #3b6656; font-size: 12px; }
.ok-dot { display: grid; place-items: center; inline-size: 34px; block-size: 34px; border-radius: 50%; background: var(--good); color: #fff; }
.mini-rec { display: grid; gap: 0.1rem; background: var(--surface); border-radius: 12px; padding: 0.5rem 0.65rem; }
.mini-rec b { font-size: 18px; color: var(--primary); }
.mini-rec span { font-size: 12px; color: var(--muted); }
.toggles { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.switch-label { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 14px; cursor: pointer; }
input[role="switch"] { appearance: none; margin: 0; inline-size: 42px; block-size: 24px; min-block-size: 24px; border-radius: 999px; background: #c9d1dc; position: relative; cursor: pointer; transition: background-color 180ms ease; flex: none; }
input[role="switch"]::before { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; inline-size: 18px; block-size: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.2); transition: transform 200ms var(--ease-out); }
input[role="switch"]:checked { background: var(--primary); }
input[role="switch"]:checked::before { transform: translateX(18px); }
.fabric-note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 0.55rem 0.75rem; }
.fabric-note:empty { display: none; }

.chips { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.chips label { position: relative; display: grid; place-items: center; min-block-size: 52px; border-radius: 14px; background: var(--surface-2); font-size: 18px; font-weight: 500; cursor: pointer; transition: background-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out); }
.chips label:active { transform: scale(0.96); }
.chips input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chips label:has(input:checked) { background: var(--primary); color: #fff; font-weight: 700; }
.chips label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.chips .star { position: absolute; top: -8px; right: -4px; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 0.05rem 0.4rem; line-height: 1.5; }
.small-chips label { min-block-size: 44px; font-size: 15px; }

.fit-list { list-style: none; margin: 0; padding: 0.5rem 0.9rem; display: grid; background: var(--surface-2); border-radius: 16px; }
.screen:not(.split) .fit-list { background: var(--surface); }
.fit-list:empty { display: none; }
.fit-item { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.25rem 0.75rem; align-items: center; padding: 0.5rem 0; }
.fit-item + .fit-item { border-top: 1px solid var(--line); }
.fit-name { font-weight: 700; font-size: 14px; }
.fit-bar { position: relative; block-size: 8px; border-radius: 999px; background: linear-gradient(to right, #f3c7c9 0%, #f6e3b5 28%, #c9eadc 40%, #c9eadc 60%, #f6e3b5 72%, #f3c7c9 100%); }
.fit-dot { position: absolute; top: 50%; inline-size: 18px; block-size: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #fff; border: 3px solid var(--good); transition: left 300ms var(--ease-out); }
.fit-dot.warn { border-color: var(--warn); } .fit-dot.bad { border-color: var(--bad); }
.fit-meta { grid-column: 2; display: flex; justify-content: space-between; gap: 0.5rem; font-size: 12px; color: var(--muted); }
.fit-meta b { color: var(--good); font-size: 13px; } .fit-meta b.warn { color: #b97a0e; } .fit-meta b.bad { color: var(--bad); } .fit-meta b.info { color: var(--ink); }
.bar-ends { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: #9aa3ad; margin-top: -0.2rem; }

/* ---------- size result ---------- */
.result-hero { display: grid; justify-items: center; text-align: center; gap: 0.35rem; padding-top: 0.5rem; }
.big-check { display: grid; place-items: center; inline-size: 64px; block-size: 64px; border-radius: 50%; background: var(--good); color: #fff; animation: pop 420ms var(--ease-out) both; }
.big-check svg { width: 36px; height: 36px; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.result-hero h2 { font-size: 24px; }
.size-card { background: linear-gradient(160deg, #f4f7ff, #e3ebfd); border-radius: 22px; padding: 1.4rem 1rem 1rem; text-align: center; display: grid; gap: 0.25rem; }
.size-big { font-size: 20px; font-weight: 700; color: var(--dark); }
.size-big b { font-size: 64px; line-height: 1; font-family: 'Outfit', var(--font); }
.size-pct { color: var(--good); font-weight: 700; font-size: 18px; }
.explain { font-size: 13px; color: var(--muted); text-align: left; margin-top: 0.4rem; }
.explain summary { cursor: pointer; text-align: center; color: var(--primary); }
.explain p { margin-top: 0.5rem; }
.ref-card { display: grid; grid-template-columns: 130px 1fr; gap: 1rem; align-items: center; background: var(--surface); border-radius: 18px; padding: 0.8rem; }
.ref-card img { inline-size: 130px; block-size: 156px; object-fit: contain; background: var(--surface-2); border-radius: 14px; }
.ref-list { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem 1rem; margin: 0; }
.ref-list dt { color: var(--muted); }
.ref-list dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.tip-card { display: grid; grid-template-columns: auto 1fr; gap: 0.7rem; background: #fff7e8; border-radius: 16px; padding: 0.85rem; font-size: 14px; }
.tip-card svg { width: 26px; height: 26px; color: #d08a10; }
.tip-card.info { background: #eef3ff; }
.tip-card.info svg { color: var(--primary); }

/* ---------- product ---------- */
.pd-top { display: grid; grid-template-columns: minmax(130px, 42%) 1fr; gap: 1rem; align-items: start; }
.pd-img { position: relative; aspect-ratio: 5 / 6; border-radius: 20px; background: radial-gradient(80% 70% at 50% 40%, #fff, #e9eef6); overflow: hidden; }
.pd-img img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.pd-info { display: grid; gap: 0.35rem; }
.pd-info h2 { font-size: 22px; }
.price { font-size: 20px; font-weight: 700; }
.flags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.flag { font-size: 12px; padding: 0.1rem 0.5rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.flag.good { background: #e3f6ee; color: #1d7d5c; } .flag.warn { background: #fff1d9; color: #9a6400; } .flag.info { background: var(--primary-soft); color: var(--primary); }
.check-size { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.7rem; background: var(--surface); border-radius: 16px; padding: 0.8rem 0.9rem; border: 1.5px solid var(--primary-soft); }
.check-size > svg:first-child { width: 28px; height: 28px; color: var(--primary); }
.check-size b { display: block; }
.check-size small { color: var(--muted); }
.fabric-card { display: grid; grid-template-columns: 96px 1fr; gap: 0.9rem; align-items: center; background: var(--surface); border-radius: 18px; padding: 0.75rem; }
.fabric-swatch { aspect-ratio: 1; border-radius: 14px; background-color: var(--c, #888); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); }
.fabric-swatch[data-pattern="twill"] { background-image: repeating-linear-gradient(45deg, rgb(255 255 255 / 0.14) 0 2px, transparent 2px 6px); }
.fabric-swatch[data-pattern="weave"], .fabric-swatch[data-pattern="canvas"] { background-image: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.08) 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, rgb(255 255 255 / 0.1) 0 1px, transparent 1px 4px); }
.fabric-swatch[data-pattern="knit"] { background-image: repeating-linear-gradient(60deg, rgb(255 255 255 / 0.12) 0 3px, transparent 3px 8px), repeating-linear-gradient(-60deg, rgb(0 0 0 / 0.08) 0 3px, transparent 3px 8px); }
.fabric-swatch[data-pattern="plain"] { background-image: linear-gradient(120deg, rgb(255 255 255 / 0.35), transparent 40%, rgb(255 255 255 / 0.15) 60%, transparent 80%); }
.fabric-swatch[data-pattern="velvet"] { background-image: radial-gradient(circle at 30% 30%, rgb(255 255 255 / 0.25), transparent 60%); }
.fabric-swatch[data-pattern="leather"] { background-image: radial-gradient(circle at 25% 25%, rgb(255 255 255 / 0.22), transparent 50%); }
.fabric-swatch[data-pattern="slub"] { background-image: repeating-linear-gradient(0deg, rgb(255 255 255 / 0.18) 0 1px, transparent 1px 3px, rgb(0 0 0 / 0.05) 3px 4px, transparent 4px 7px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 0.5rem; align-items: center; }
.swatch { inline-size: 30px; block-size: 30px; min-block-size: 30px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; position: relative; transition: transform 140ms var(--ease-out); }
.swatch::after { content: ""; position: absolute; inset: -7px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch:active { transform: scale(0.92); }
.swatch-custom { inline-size: 30px; block-size: 30px; min-block-size: 30px; border-radius: 50%; overflow: hidden; border: 0; padding: 0; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.swatch-custom::-webkit-color-swatch-wrapper { opacity: 0; }
.swatch-custom::-moz-color-swatch { opacity: 0; }
.size-chart summary { cursor: pointer; font-weight: 700; }

/* tables */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.size-table { border-collapse: collapse; inline-size: 100%; font-size: 14px; }
.size-table th, .size-table td { padding: 0.45rem 0.4rem; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.size-table thead th { background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--muted); }
.size-table tr:last-child > * { border-bottom: 0; }
.size-table tr.hl > * { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.size-table input { inline-size: 4.2em; border: 1px solid transparent; border-radius: 8px; padding: 0.3rem 0.2rem; text-align: center; background: transparent; font-variant-numeric: tabular-nums; }
.size-table input:hover { border-color: var(--line); }
.size-table input:focus { border-color: var(--primary); outline: none; background: #fff; }
#sizeTable { min-inline-size: 460px; }
.brand-card { display: grid; gap: 0.6rem; }
.you-line { font-size: 14px; background: var(--surface); border-radius: 12px; padding: 0.6rem 0.8rem; }
.you-line b { color: var(--primary); }

/* ---------- me ---------- */
.me-head { display: flex; align-items: center; gap: 0.9rem; background: var(--surface); border-radius: 20px; padding: 1rem; }
.avatar { display: grid; place-items: center; inline-size: 60px; block-size: 60px; border-radius: 50%; background: linear-gradient(140deg, #dfe8fb, #b9cdf7); color: var(--dark); }
.avatar svg { width: 30px; height: 30px; }
.menu { list-style: none; margin: 0; padding: 0.25rem 0.9rem; background: var(--surface); border-radius: 20px; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 0.75rem; min-block-size: 54px; font-size: 15px; }
.menu a > svg:last-child { color: #a3abb8; width: 18px; height: 18px; }
.menu a:not(:has(.count)) { grid-template-columns: auto 1fr auto; }
.count { font-size: 12px; color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 0 0.5rem; }
.count:empty { display: none; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.hist a { display: grid; grid-template-columns: 56px 1fr; gap: 0.75rem; align-items: center; background: var(--surface); border-radius: 14px; padding: 0.5rem; }
.hist img { inline-size: 56px; block-size: 66px; object-fit: contain; background: var(--surface-2); border-radius: 10px; }
.hist b { display: block; }
.hist small { color: var(--muted); }
.empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 0.75rem; text-align: center; color: var(--muted); padding: 2rem 1rem; background: var(--surface); border-radius: 18px; }
.faq { display: grid; gap: 0.5rem; }
.faq details { background: var(--surface); border-radius: 14px; padding: 0.8rem 0.9rem; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { margin-top: 0.5rem; color: var(--muted); font-size: 14px; }
.nudge { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.7rem; background: var(--primary-soft); border-radius: 14px; padding: 0.7rem 0.85rem; color: var(--primary); }
.nudge b { display: block; } .nudge small { color: #4a6bb3; }

/* ---------- body form ---------- */
.slider-field { display: grid; gap: 0.15rem; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-head label { font-weight: 700; font-size: 14px; }
.slider-head output { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 0.05rem 0.55rem; border-radius: 8px; font-size: 14px; }
.slider-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -0.35rem; }
.slider-field.compact .slider-head label { font-weight: 500; }
input[type="range"] {
  --slider-track-size: 6px; --slider-thumb-size: 22px; --slider-track-color: #cfd6e2; --slider-fill-color: var(--primary);
  --attr-min: 0; --attr-max: 100; --control-value: 50;
  --slider-progress: calc((var(--control-value) - var(--attr-min)) / (var(--attr-max) - var(--attr-min)) * 100%);
  appearance: none; inline-size: 100%; block-size: 2.5rem; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { block-size: var(--slider-track-size); border-radius: 999px; background: linear-gradient(to right, var(--slider-fill-color) var(--slider-progress), var(--slider-track-color) var(--slider-progress)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; inline-size: var(--slider-thumb-size); block-size: var(--slider-thumb-size); margin-block-start: calc((var(--slider-track-size) - var(--slider-thumb-size)) / 2); border-radius: 50%; background: #fff; border: 3px solid var(--slider-fill-color); box-shadow: 0 1px 4px rgb(20 30 40 / 0.2); }
input[type="range"]::-moz-range-track { block-size: var(--slider-track-size); border-radius: 999px; background: var(--slider-track-color); }
input[type="range"]::-moz-range-progress { block-size: var(--slider-track-size); border-radius: 999px; background: var(--slider-fill-color); }
input[type="range"]::-moz-range-thumb { inline-size: var(--slider-thumb-size); block-size: var(--slider-thumb-size); border-radius: 50%; background: #fff; border: 3px solid var(--slider-fill-color); box-sizing: border-box; }
input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; }
.measure { display: grid; gap: 0.15rem; background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px; padding: 0.6rem 0.75rem; transition: border-color 160ms ease; }
.measure:focus-within { border-color: var(--primary); }
.measure span { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 0.25rem; }
.measure em { font-style: normal; font-size: 11px; color: var(--primary); background: var(--primary-soft); padding: 0 0.4rem; border-radius: 6px; }
.measure em.manual { color: var(--accent); background: #fde8ef; }
.measure input { inline-size: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 700; padding: 0; font-variant-numeric: tabular-nums; }
.measure input:focus { outline: none; }
.text-field { display: grid; }
.text-field input, select, textarea { inline-size: 100%; min-block-size: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0.5rem 0.8rem; }
textarea { font-variant-numeric: tabular-nums; resize: vertical; }
.text-field input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
.scan.card { background: var(--surface-2); box-shadow: none; }
.tips { margin: 0; padding-left: 1.1rem; font-size: 13px; color: var(--muted); display: grid; gap: 0.15rem; }
.file-btn { position: relative; }
.cam video, #scanCanvas { inline-size: 100%; max-block-size: 360px; object-fit: contain; border-radius: 12px; background: #dfe4ea; }
.cam { display: grid; gap: 0.5rem; }
.status { font-size: 13px; color: var(--primary); font-weight: 500; }
.status:empty { display: none; }
.status.err { color: var(--bad); }
.small-seg .seg-track label { min-block-size: 36px; font-size: 13px; }

/* dialog */
.sheet-dialog { border: 0; border-radius: 22px; padding: 1.2rem; inline-size: min(92vw, 420px); box-shadow: 0 20px 60px rgb(20 30 50 / 0.25); }
.sheet-dialog::backdrop { background: rgb(15 20 30 / 0.4); }
.sheet-dialog form { display: grid; gap: 0.8rem; }
.sheet-dialog[open] { animation: pop 220ms var(--ease-out); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 1.25rem + env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 10; background: var(--dark); color: #fff; padding: 0.7rem 1.1rem; border-radius: 14px; font-size: 14px; font-weight: 500; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 300ms ease, transform 300ms var(--ease-out); max-inline-size: calc(100vw - 2rem); }
.toast.show { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .screen { transition: opacity 200ms ease; transform: none; }
  @starting-style { .screen { transform: none; } }
  .big-check, .sheet-dialog[open] { animation: none; }
}
.big-check.warn { background: var(--warn); }
.size-pct.warn { color: #b97a0e; }
.menu a > svg:first-child { fill: none; }
.grid3 { grid-template-columns: repeat(auto-fill, minmax(min(150px, 30%), 1fr)); }
@media (max-width: 420px) { .grid3 .pname { font-size: 13px; } .grid3 .pmeta { font-size: 11px; } .grid3 .heart { inline-size: 30px; block-size: 30px; min-block-size: 30px; top: 6px; right: 6px; } }

.chips { grid-template-columns: repeat(auto-fit, minmax(46px, 1fr)); }
.chips .custom-chip { font-size: 14px; background: #fff; border: 1.5px dashed #c5cdd9; }
.chips .custom-chip:has(input:checked) { border-style: solid; border-color: var(--primary); }
.custom-size { background: var(--surface-2); box-shadow: none; }
.custom-size .measure { background: var(--surface); }

.measure em.range { color: var(--muted); background: none; padding: 0; }
.measure.invalid { border-color: var(--bad); }

/* camera */
.cam-view { position: relative; border-radius: 14px; overflow: hidden; background: #111; }
.cam-view video { display: block; inline-size: 100%; max-block-size: 60dvh; object-fit: contain; border-radius: 0; }
.cam-view video.mirror { transform: scaleX(-1); }
.cam-live { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #fff; background: rgb(0 0 0 / 0.55); padding: 4px 10px; border-radius: 999px; }
.cam-live i { inline-size: 8px; block-size: 8px; border-radius: 50%; background: #ff4d4f; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.cam-guide { position: absolute; inset: 8% 30%; border: 2px dashed rgb(255 255 255 / 0.6); border-radius: 40% 40% 12% 12% / 18% 18% 6% 6%; pointer-events: none; }
.cam-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 96px; font-weight: 900; color: #fff; text-shadow: 0 4px 20px rgb(0 0 0 / 0.5); }
@media (prefers-reduced-motion: reduce) { .cam-live i { animation: none; } }
