:root {
  --bg: #FCFAF8;
  --card: #ffffff;
  --ink: #2B2B35;
  --ink-soft: #9A8F98;
  --line: #F0E6EC;
  --brand: #EE7D93;
  --brand-soft: #FCE7ED;
  --rail-bg: #FDEEF2;
  --gold: #C9A35B;
  --green: #5BB98C;
  --radius: 16px;
  --topbar-h: 52px;
  --nav-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-soft); cursor: pointer;
}

/* content */
.page { padding: 16px; }
.section-title { font-size: 15px; font-weight: 600; margin: 18px 0 10px; color: var(--ink); }
.muted { color: var(--ink-soft); font-size: 13px; }
.empty { text-align: center; color: var(--ink-soft); padding: 48px 16px; }
.empty .em { font-size: 44px; display: block; margin-bottom: 10px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: 0 6px 24px rgba(43,43,53,.05); }

/* chips / tags */
.chips { display: flex; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 7px 14px; margin: 0 8px 8px 0;
  background: #F1EDE7; color: #6F685C; border-radius: 999px; font-size: 13px;
  cursor: pointer; user-select: none; border: 1px solid transparent;
}
.tag.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.chip-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; margin: 0 8px 8px 0; background: #fff;
  border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer;
}
.chip-pill.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.chip-pill .x { color: var(--ink-soft); font-size: 14px; }

/* item grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.cell { background: var(--card); border-radius: 12px; overflow: hidden; cursor: pointer; box-shadow: 0 4px 16px rgba(43,43,53,.05); }
.cell .img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #eee; display: block; }
.cell .name { font-size: 12px; padding: 6px 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .wear { text-align: center; font-size: 12px; color: var(--brand); padding-bottom: 6px; }

/* stats row */
.stats { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: 0 4px 16px rgba(43,43,53,.05); }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* buttons */
.btn { display: block; width: 100%; border: none; border-radius: 999px; padding: 13px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: var(--brand-soft); color: var(--brand); }
.btn-line { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: #fff; border: 1px solid #E5A1A8; color: #D6455A; }
.btn:disabled { opacity: .5; }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  max-width: 560px; width: calc(100% - 32px);
  z-index: 15;
}

/* inputs */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.ro { padding: 10px 12px; background: var(--brand-soft); color: var(--brand); border-radius: 12px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=date], input[type=number], textarea, select {
  width: 100%; padding: 12px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 12px; background: #FAF8F5; color: var(--ink); font-family: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }

/* bottom nav */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 560px; height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; z-index: 30;
}
.bottom-nav button {
  flex: 1; border: none; background: none; color: var(--ink-soft);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.bottom-nav button .ic { font-size: 20px; line-height: 1; }
.bottom-nav button.on { color: var(--brand); }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  width: 100%; max-width: 560px; background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px; animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .row { display: flex; gap: 10px; margin-top: 14px; }
.modal .row .btn { width: auto; flex: 1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(43,43,53,.92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100; max-width: 90%;
}
.toast.show { opacity: 1; }

/* lang sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; align-items: flex-end; }
.sheet .box { width: 100%; max-width: 560px; margin: 0 auto; background: #fff; border-radius: 20px 20px 0 0; padding: 16px; }
.sheet .box .opt { padding: 14px; font-size: 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; }
.sheet .box .opt:last-child { border-bottom: none; }
.sheet .box .opt.on { color: var(--brand); font-weight: 600; }

/* tryon */
.tryon-stack img { width: 100%; border-radius: 12px; margin-bottom: 10px; }

/* checkin list */
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-item img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.check-item .nm { flex: 1; font-size: 14px; }
.check-item .box { width: 22px; height: 22px; border: 2px solid var(--brand); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; }
.check-item .box.on { background: var(--brand); }

/* topbar inner bar */
.topbar .bar { display: flex; align-items: center; gap: 8px; width: 100%; }
.topbar .title { flex: 1; font-size: 20px; font-weight: 700; }
.topbar .back { background: none; border: none; font-size: 26px; line-height: 1; color: var(--ink); cursor: pointer; padding: 0 4px; margin-right: 2px; }

/* horizontal scroller for closets / wardrobes */
.hscroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.hscroll > * { flex: 0 0 auto; }

/* closet / wardrobe chip */
.cw-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; background: #fff; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.cw-chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.cw-chip .ed, .cw-chip .x { color: var(--ink-soft); font-size: 14px; padding: 0 2px; }
.cw-add { display: inline-flex; align-items: center; padding: 8px 12px; border: 1px dashed var(--brand); color: var(--brand); border-radius: 999px; font-size: 13px; cursor: pointer; white-space: nowrap; }

/* item detail image thumbnails */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .rm { position: absolute; top: -4px; right: -4px; width: 20px; height: 20px; border-radius: 50%; background: #D6455A; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; }
.thumb-add { width: 72px; height: 72px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--ink-soft); cursor: pointer; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }

/* tryon picked stack */
.tryon-stack { padding: 0 0 8px; }
.tryon-stack img, .tryon-stack > div { width: 100%; border-radius: 12px; margin-bottom: 8px; }

/* setup screen */
.setup { padding: 28px 20px; }
.setup h2 { font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.setup .sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 4px; }
.setup .hint { color: var(--ink-soft); font-size: 12px; margin: 0 0 18px; }
.setup .err { color: #D6455A; font-size: 13px; margin: 10px 0; }

/* confirm modal body */
.confirm-body { padding: 4px 4px 8px; font-size: 15px; }

/* lang / option sheet */
.sheet .box .opt { padding: 14px; font-size: 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sheet .box .opt:last-child { border-bottom: none; }
.sheet .box .opt.on { color: var(--brand); font-weight: 600; }

/* ---------- wardrobe: left category rail + right item panel ---------- */
.screen-wardrobe { display: flex; align-items: flex-start; }
.wd-rail {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  align-self: flex-start;
  flex: 0 0 116px;
  max-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px) - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background: var(--rail-bg);
  border-right: 1px solid var(--line);
  padding: 6px 6px 16px;
}
.screen-wardrobe.collapsed .wd-rail { flex-basis: 56px; }
.wd-rail-list { display: flex; flex-direction: column; gap: 4px; }
.rl-toggle { text-align: center; color: var(--ink-soft); font-size: 18px; line-height: 1; cursor: pointer; padding: 4px 0 8px; user-select: none; }
.rl {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px; border-radius: 12px; cursor: pointer; user-select: none;
  color: var(--ink); font-size: 14px;
}
.rl .rl-ic { font-size: 18px; flex: 0 0 auto; }
.rl .rl-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl .rl-count { font-size: 12px; color: var(--ink-soft); background: rgba(0,0,0,.045); border-radius: 999px; padding: 1px 7px; }
.rl.on { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(238,125,147,.35); }
.rl.on .rl-count { background: rgba(255,255,255,.28); color: #fff; }
.rl-add { color: var(--brand); font-size: 13px; border: 1px dashed var(--brand); margin-top: 6px; justify-content: center; }
.screen-wardrobe.collapsed .rl .rl-name,
.screen-wardrobe.collapsed .rl .rl-count { display: none; }
.screen-wardrobe.collapsed .rl { justify-content: center; padding: 12px 0; }

.wd-closets { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.wd-closets > * { flex: 0 0 auto; }

.wd-main { flex: 1; min-width: 0; padding: 12px 12px calc(var(--nav-h) + 16px); }
.wd-main-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 15px; font-weight: 700; color: var(--brand); margin-bottom: 10px; }
.wd-main-head .wd-head-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-main-head .wd-total { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--brand-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.screen-wardrobe.collapsed .wd-main-head .wd-total { font-size: 12px; padding: 2px 8px; }
.wd-grid { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 520px) { .wd-grid { grid-template-columns: repeat(3, 1fr); } }

/* raised circular + FAB */
.wd-fab {
  position: fixed;
  right: max(18px, calc(50vw - 282px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  font-size: 30px; line-height: 1; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(238,125,147,.5);
  z-index: 25;
}
.wd-fab:active { transform: scale(.94); }

/* topbar tools (search / filter) */
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 11px; font-size: 15px; cursor: pointer; color: var(--ink-soft);
}
.tool-btn:active { background: var(--brand-soft); }
.tool-btn .badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 10px; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--bg);
}

/* wardrobe search row */
.wd-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.wd-search input { flex: 1; }
.wd-search-x { color: var(--ink-soft); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* filter sheet */
.sheet .box { max-height: 78vh; overflow-y: auto; }
.fl-sec { padding: 12px 4px; border-bottom: 1px solid var(--line); }
.fl-sec:last-of-type { border-bottom: none; }
.fl-title { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }

/* move sheet */
.mv-list { max-height: 56vh; overflow-y: auto; }
.mv-closet { font-size: 13px; font-weight: 700; color: var(--ink-soft); padding: 10px 4px 6px; }
.mv-row { display: flex; align-items: center; gap: 8px; padding: 12px 10px; border-radius: 12px; cursor: pointer; font-size: 15px; }
.mv-row:active { background: var(--brand-soft); }
.mv-row.on { color: var(--brand); font-weight: 600; }

/* batch import review list */
.bi-list { max-height: 52vh; overflow-y: auto; margin: 4px 0 6px; }
.bi-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.bi-row:last-child { border-bottom: none; }
.bi-thumb { width: 52px; height: 52px; flex: 0 0 auto; border-radius: 10px; overflow: hidden; background: #eee; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.bi-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bi-info { flex: 1; min-width: 0; }
.bi-name { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.bi-catwrap { display: flex; }
.bi-cat { width: 100%; padding: 8px 10px; font-size: 14px; border-radius: 10px; }
.bi-rm { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: #F1EDE7; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; font-size: 15px; cursor: pointer; line-height: 1; }

/* ---------- wardrobe: left rail + right item grid + circular FAB (mini-program style) ---------- */

/* crop / edit image modal */
.crop-mask { align-items: center; background: rgba(0,0,0,.72); padding: 16px; }
.crop-modal {
  width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 16px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: pop .18s ease; box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.crop-head { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.crop-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.crop-prog { font-size: 13px; color: var(--ink-soft); }
.crop-stage {
  position: relative; background: #111; border-radius: 12px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.crop-img {
  position: absolute; transform-origin: center center; will-change: transform;
  pointer-events: none; max-width: none;
}
.crop-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.95); border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none;
}
.crop-hint { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.4; }
.crop-zoomrow { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 16px; }
.crop-zoomrow input[type=range] { flex: 1; accent-color: var(--brand); }
.crop-tools { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.crop-btn {
  flex: 1 1 auto; min-width: 64px; padding: 10px 8px; border: none; border-radius: 10px;
  font-size: 14px; cursor: pointer; background: #F1EDE7; color: var(--ink);
}
.crop-btn:active { transform: scale(.97); }
.crop-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); }
.crop-primary { background: var(--brand); color: #fff; font-weight: 600; flex-basis: 100%; }
.crop-skipall { flex-basis: 100%; }

/* backup status bar */
.wd-backupbar { padding: 6px 14px; font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
