:root {
  --bg: #f5f4fb;
  --card: #ffffff;
  --ink: #221f33;
  --ink-soft: #6b6880;
  --line: #eceaf5;
  --brand: #7c6cf3;
  --brand-soft: #efecff;
  --brand-ink: #5a49d6;
  --warn: #f0913e;
  --danger: #e8556a;
  --ok: #33b989;
  --radius: 18px;
  --shadow: 0 6px 22px rgba(90, 73, 214, 0.10);
  --tabbar-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-top: calc(52px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* 顶部栏 */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245,244,251,0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  z-index: 50;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: .5px; }
.icon-btn {
  border: none; background: transparent; font-size: 20px;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
}
.icon-btn:active { background: var(--brand-soft); }

/* 页面 */
.page { padding: 16px 16px 4px; max-width: 640px; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.section-title { font-size: 15px; font-weight: 700; margin: 20px 4px 12px; color: var(--ink); }
.section-title:first-child { margin-top: 4px; }
.muted { color: var(--ink-soft); }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* 天气头卡 */
.weather-hero {
  background: linear-gradient(135deg, #8b7cf6 0%, #a48bff 60%, #c9b9ff 100%);
  color: #fff;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(124,108,243,.32);
}
.weather-hero .wh-top { display: flex; justify-content: space-between; align-items: flex-start; }
.weather-hero .wh-city { font-size: 14px; opacity: .92; display:flex; align-items:center; gap:5px;}
.weather-hero .wh-temp { font-size: 46px; font-weight: 700; line-height: 1; margin-top: 6px; }
.weather-hero .wh-desc { font-size: 15px; opacity: .95; margin-top: 6px; }
.weather-hero .wh-emoji { font-size: 52px; line-height: 1; }
.weather-hero .wh-range { font-size: 13px; opacity: .88; margin-top: 4px; }
.weather-hero .wh-advice {
  margin-top: 14px; font-size: 13.5px; line-height: 1.55;
  background: rgba(255,255,255,.16); border-radius: 14px; padding: 10px 12px;
}

/* 八字色卡 */
.bazi-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.color-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 600;
}
.color-chip .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }

/* 推荐 outfit 展示 */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 10px; margin-top: 12px; }
.rec-item { text-align: center; }
.rec-item .thumb {
  width: 100%; aspect-ratio: 1; border-radius: 14px; object-fit: cover;
  background: var(--brand-soft); border: 1px solid var(--line);
}
.rec-item .cap { font-size: 12px; color: var(--ink-soft); margin-top: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-reason { font-size: 13.5px; line-height: 1.6; color: var(--ink); margin-top: 12px;
  background: var(--brand-soft); border-radius: 14px; padding: 12px 14px; }
.rec-reason b { color: var(--brand-ink); }

/* 衣物网格 */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.item-card { cursor: pointer; position: relative; }
.item-card .photo {
  width: 100%; aspect-ratio: 1; border-radius: 16px; object-fit: cover;
  background: linear-gradient(135deg,#f3f1fc,#eae6fb); border: 1px solid var(--line);
  display:flex; align-items:center; justify-content:center; font-size:34px;
}
.item-card .name { font-size: 12.5px; margin-top: 6px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.item-card .badge {
  position: absolute; top: 7px; left: 7px; font-size: 10.5px; padding: 2px 7px;
  border-radius: 999px; background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(4px);
}

/* 分类筛选条 */
.chips-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; -webkit-overflow-scrolling: touch; }
.chips-scroll::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer;
}
.filter-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty .big { font-size: 46px; margin-bottom: 10px; }
.empty .hint { font-size: 14px; margin-top: 6px; line-height: 1.6; }

/* 底部 tab */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; align-items: stretch; justify-content: space-around;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  z-index: 50;
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-soft); font-size: 11px; padding: 8px 0;
}
.tab .tab-ico { font-size: 21px; filter: grayscale(.4) opacity(.65); transition: .15s; }
.tab.active { color: var(--brand-ink); font-weight: 700; }
.tab.active .tab-ico { filter: none; transform: translateY(-1px); }
.tab-add { flex: 0 0 auto; }
.add-plus {
  width: 50px; height: 50px; margin-top: -14px; border-radius: 50%;
  background: linear-gradient(135deg,#8b7cf6,#6c5ce7); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 300; box-shadow: 0 8px 20px rgba(124,108,243,.45);
}
.tab-add:active .add-plus { transform: scale(.94); }

/* 按钮 */
.btn {
  border: none; border-radius: 14px; padding: 13px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; width: 100%; transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: var(--brand-soft); color: var(--brand-ink); }
.btn-danger { background: #fdeef0; color: var(--danger); }
.btn-line { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* 弹层 */
.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-mask {
  position: absolute; inset: 0; background: rgba(30,26,50,.42);
  opacity: 0; transition: opacity .2s; pointer-events: auto;
}
.modal-mask.show { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-radius: 24px 24px 0 0;
  max-height: 92vh; overflow-y: auto; pointer-events: auto;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.3,.9,.3,1);
  padding: 8px 18px calc(24px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.sheet.show { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: #d7d3ea; margin: 10px auto 6px; }
.sheet h2 { font-size: 18px; margin: 4px 4px 16px; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin: 0 4px 7px; font-weight: 600; }
.field input[type=text], .field textarea, .field input[type=date], .field input[type=time], .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px;
  font-size: 15px; background: var(--card); color: var(--ink); font-family: inherit;
}
.field textarea { resize: none; min-height: 60px; }
.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt {
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 13.5px; cursor: pointer; color: var(--ink-soft);
}
.opt.sel { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* 颜色选择 */
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-pick { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; position: relative;
  border: 2px solid var(--line); }
.color-pick.sel { border-color: var(--brand); transform: scale(1.12); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }
.color-pick .ck { position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  color:#fff; font-size:16px; opacity:0; }
.color-pick.sel .ck { opacity: 1; }

/* 拍照区 */
label.photo-drop {
  width: 100%; height: 190px; border-radius: 18px; border: 2px dashed #d3cdf0;
  background: var(--brand-soft); display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--brand-ink); cursor: pointer; overflow: hidden; position: relative;
}
.photo-drop img { width: 100%; height: 100%; object-fit: cover; }
.photo-drop .ph-ico { font-size: 40px; }
.photo-drop .ph-txt { font-size: 13px; margin-top: 6px; }
.photo-drop .retake { position:absolute; right:10px; bottom:10px; background:rgba(0,0,0,.55);
  color:#fff; font-size:12px; padding:5px 10px; border-radius:999px; }

/* 详情大图 */
.detail-photo { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 18px; background: var(--brand-soft); }
.kv { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-weight: 600; text-align: right; }

/* 选择衣物（搭配） */
.pick-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.pick-cell { position: relative; cursor: pointer; }
.pick-cell .photo { width:100%; aspect-ratio:1; border-radius:14px; object-fit:cover;
  background: var(--brand-soft); border:1px solid var(--line); display:flex;align-items:center;justify-content:center;font-size:28px;}
.pick-cell.sel .photo { outline: 3px solid var(--brand); outline-offset: -1px; }
.pick-cell .tick { position:absolute; top:6px; right:6px; width:22px;height:22px;border-radius:50%;
  background:var(--brand); color:#fff; display:none; align-items:center;justify-content:center;font-size:14px;}
.pick-cell.sel .tick { display:flex; }

/* 统计 */
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.stat-box { background: var(--card); border-radius: 16px; padding: 16px 12px; text-align: center; box-shadow: var(--shadow); }
.stat-box .num { font-size: 26px; font-weight: 700; color: var(--brand-ink); }
.stat-box .lbl { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 13px; }
.bar-row .bl { width: 52px; color: var(--ink-soft); flex: 0 0 auto; }
.bar-track { flex: 1; height: 12px; background: var(--brand-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg,#8b7cf6,#6c5ce7); border-radius: 999px; }
.bar-row .bn { width: 26px; text-align: right; color: var(--ink-soft); flex: 0 0 auto; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(34,31,51,.94); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 颜色圆点小工具 */
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle;
  border: 1px solid rgba(0,0,0,.12); margin-right: 6px; }
