/* 衣搭 - 样式（移动端优先） */
:root {
  --bg: #faf8f5;
  --ink: #201d19;
  --ink-2: #6f6a62;
  --line: #e8e3da;
  --card: #ffffff;
  --accent: #b4552d;
  --accent-ink: #8f3f1d;
  --ok: #3e7d4f;
  --radius: 18px;
  --shadow: 0 2px 14px rgba(60, 45, 30, 0.07);
  --serif: Georgia, "Songti SC", "Noto Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

#app { max-width: 560px; margin: 0 auto; padding-bottom: 76px; }

/* 顶部 */
.topbar { padding: 18px 20px 8px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-zh { font-family: var(--serif); font-size: 1.45rem; font-weight: 700; letter-spacing: 0.12em; }
.brand-en { font-size: 0.68rem; letter-spacing: 0.34em; color: var(--ink-2); }
.topbar-sub { color: var(--ink-2); font-size: 0.82rem; margin-top: 4px; }

main { padding: 8px 20px; }
.view { animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 首页 hero */
.hero { text-align: center; padding: 26px 0 8px; position: relative; }
.hero h1 { font-family: var(--serif); font-size: 2rem; line-height: 1.35; letter-spacing: 0.04em; }
.hero-sub { color: var(--ink-2); font-size: 0.9rem; margin: 12px 0 26px; line-height: 1.7; }
.hero-art { position: relative; height: 110px; margin-bottom: 10px; }
.swatch { position: absolute; border-radius: 50%; opacity: 0.9; }
.s1 { width: 64px; height: 64px; background: #d9cdb7; left: 18%; top: 22px; }
.s2 { width: 44px; height: 44px; background: #243251; left: 46%; top: 6px; }
.s3 { width: 34px; height: 34px; background: #b0352e; left: 63%; top: 52px; }
.hero-ring { position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; border: 1px solid var(--line); border-radius: 50%; transform: translate(-50%, -46%); }

/* 按钮 */
.camera-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  font-size: 1rem; padding: 15px 22px; border-radius: 999px; width: min(100%, 320px);
  margin: 0 auto; transition: transform 0.12s ease;
}
.camera-btn:active { transform: scale(0.97); }
.camera-btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-top: 12px; font-size: 0.88rem; padding: 11px 22px; }
.camera-btn.small { width: 100%; padding: 13px; }
.primary-btn {
  width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 14px;
  padding: 15px; font-size: 1rem; cursor: pointer; margin-top: 18px; font-weight: 600;
}
.primary-btn:active { transform: scale(0.98); }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 11px 16px; cursor: pointer; font-size: 0.9rem; margin-top: 12px;
}
.ghost-btn.wide { width: 100%; margin: 18px 0 8px; padding: 14px; }
.ghost-btn.danger { color: #a33; border-color: #e5c8c8; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .ghost-btn { margin-top: 6px; flex: 1; }
.filelike { display: inline-flex; align-items: center; justify-content: center; }

/* 最近添加 */
.recent { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 12px; }
.section-head h2 { font-family: var(--serif); font-size: 1.12rem; letter-spacing: 0.06em; }
.linklike { background: none; border: none; color: var(--ink-2); cursor: pointer; font-size: 0.85rem; }
.thumb-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.thumb-row .thumb { flex: 0 0 auto; width: 74px; height: 74px; border-radius: 14px; background: #fff; border: 1px solid var(--line); object-fit: cover; }
.empty-hint { color: var(--ink-2); font-size: 0.85rem; padding: 8px 0; }

/* 确认页 */
.confirm-grid { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }
.cutout-box { position: relative; background: repeating-conic-gradient(#f1ede6 0 25%, #fff 0 50%) 0 0 / 22px 22px; border-radius: var(--radius); border: 1px solid var(--line); display: grid; place-items: center; min-height: 240px; overflow: hidden; }
.cutout-box img { max-width: 78%; max-height: 300px; object-fit: contain; }
.badge { position: absolute; left: 12px; top: 12px; background: var(--ok); color: #fff; font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; }
.badge.low { background: #c08a2d; }
.confirm-form h2 { font-family: var(--serif); font-size: 1.05rem; margin: 14px 0 10px; letter-spacing: 0.05em; }
.confirm-form h2:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 7px 14px; font-size: 0.88rem; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.colors-read { display: flex; gap: 10px; flex-wrap: wrap; }
.color-pill { display: flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px 7px 8px; font-size: 0.84rem; }
.color-dot { width: 22px; height: 22px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.08); }
.color-ratio { color: var(--ink-2); font-size: 0.75rem; }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 0.8rem; color: var(--ink-2); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; font-size: 0.95rem; color: var(--ink);
}
.field input:focus { outline: 2px solid #d8c9b8; border-color: transparent; }

/* 方案页 */
.anchor-bar {
  display: flex; align-items: center; gap: 13px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
}
.anchor-bar img { width: 62px; height: 62px; object-fit: cover; border-radius: 12px; background: #f3efe8; }
.anchor-name { font-weight: 600; }
.anchor-meta { color: var(--ink-2); font-size: 0.8rem; margin-top: 3px; }
.filter-row { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.chips.seasons .chip.on { background: var(--accent); border-color: var(--accent); }
.outfits { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.outfit-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.outfit-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.outfit-title { font-family: var(--serif); font-size: 1.05rem; letter-spacing: 0.04em; }
.outfit-score { color: var(--ink-2); font-size: 0.78rem; }
.outfit-items { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 4px; }
.oitem { flex: 0 0 auto; width: 88px; text-align: center; }
.oitem img { width: 88px; height: 88px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); background: #f3efe8; }
.oitem .swatch-only {
  width: 88px; height: 88px; border-radius: 14px; border: 1px dashed #d5cec2;
  display: grid; place-items: center;
}
.swatch-only .inner { width: 54px; height: 54px; border-radius: 12px; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(0,0,0,0.06); }
.oitem .lbl { font-size: 0.75rem; color: var(--ink-2); margin-top: 5px; line-height: 1.35; }
.oitem .role { display: inline-block; font-size: 0.66rem; color: var(--accent-ink); background: #f6e8df; padding: 1px 7px; border-radius: 999px; margin-bottom: 3px; }
.oitem.placeholder .swatch-only { border-color: #e0a98c; }
.oitem.placeholder .lbl { color: #b07a55; }
.outfit-reasons { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.outfit-reasons li { list-style: none; color: var(--ink-2); font-size: 0.82rem; line-height: 1.75; padding-left: 14px; position: relative; }
.outfit-reasons li::before { content: "·"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }
.outfit-tags { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 0.7rem; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.save-outfit { margin-top: 12px; width: 100%; background: #f2ede4; border: none; border-radius: 10px; padding: 10px; font-size: 0.85rem; color: var(--ink); cursor: pointer; }
.save-outfit.saved { color: var(--ok); }
.llm-comment { margin-top: 10px; background: #f7f3ec; border-radius: 10px; padding: 10px 12px; font-size: 0.85rem; line-height: 1.7; color: #4c463d; }
.llm-comment b { color: var(--accent-ink); font-weight: 600; }
.missing-tip { margin-top: 12px; background: #fbf6ea; border: 1px solid #eddfc2; border-radius: 10px; padding: 10px 12px; font-size: 0.82rem; line-height: 1.65; color: #6d5c33; }

/* 衣橱 */
.wardrobe-group { margin-bottom: 20px; }
.wardrobe-group h3 { font-size: 0.92rem; color: var(--ink-2); margin: 14px 0 10px; letter-spacing: 0.08em; }
.wgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wcell { position: relative; }
.wcell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); background: #f3efe8; }
.wcell .nm { font-size: 0.72rem; color: var(--ink-2); margin-top: 4px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcell .del { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(30,25,20,0.55); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.empty-tip { color: var(--ink-2); font-size: 0.88rem; padding: 26px 0; text-align: center; }

/* 设置 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 0.98rem; margin-bottom: 6px; }
.small-p { font-size: 0.8rem; margin-bottom: 10px; }
.switch-row { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; padding: 6px 0 2px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.foot-note { font-size: 0.76rem; text-align: center; padding: 8px 0 20px; }
.muted { color: var(--ink-2); font-size: 0.82rem; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 560px); display: flex; background: rgba(255,255,255,0.94);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.68rem; padding: 6px 0;
}
.tab.active { color: var(--ink); }
.tab.active svg { stroke-width: 2.2; }

/* 遮罩与提示 */
.overlay {
  position: fixed; inset: 0; background: rgba(250, 248, 245, 0.92); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--ink-2); font-size: 0.9rem;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: rgba(32, 29, 25, 0.92); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 0.85rem; z-index: 60; max-width: 86%;
  text-align: center; animation: fadein 0.2s ease;
}

@media (min-width: 480px) {
  .confirm-grid { flex-direction: row; }
  .cutout-box { flex: 1; }
  .confirm-form { flex: 1; }
  .wgrid { grid-template-columns: repeat(4, 1fr); }
}

/* 实拍效果图（AI 生成） */
.photo-wrap { margin: 14px 0 4px; }
.photo-box { width: 100%; border-radius: 16px; overflow: hidden; background: #f3efe8; min-height: 180px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(60,42,24,0.08); }
.photo-box[data-empty="1"] { border: 1.5px dashed var(--line); }
.photo-img { width: 100%; height: auto; display: block; }
.photo-placeholder { color: var(--ink-2); font-size: 0.82rem; padding: 30px 12px; text-align: center; }
.photo-loading { color: var(--ink-2); font-size: 0.82rem; padding: 30px 12px; }
.photo-actions { display: flex; gap: 10px; margin-top: 10px; }
.gen-photo-btn, .tryon-btn { flex: 1; border: none; border-radius: 10px; padding: 10px; font-size: 0.82rem; cursor: pointer; }
.gen-photo-btn { background: var(--accent); color: #fff; }
.tryon-btn { background: #f2ede4; color: var(--ink); }
.gen-photo-btn:disabled { opacity: 0.6; }

/* 全网穿搭参考 */
.webrefs { margin: 12px 0 6px; }
.webrefs-head { font-size: 0.78rem; color: var(--ink-2); margin-bottom: 6px; }
.webrefs-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.webref { flex: 0 0 auto; width: 84px; height: 112px; border-radius: 10px; overflow: hidden; background: #f3efe8; border: 1px solid var(--line); }
.webref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.webref-note { font-size: 0.74rem; color: var(--ink-2); padding: 8px 2px; }
.webrefs-row::-webkit-scrollbar { height: 5px; }
.webrefs-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* 虚拟试穿弹窗 */
.modal-overlay { position: fixed; inset: 0; background: rgba(40,28,16,0.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 18px; width: 100%; max-width: 360px; max-height: 86vh; overflow-y: auto; }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.modal-preview { margin-top: 10px; }
.modal-preview img { width: 100%; border-radius: 12px; display: block; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .primary-btn, .modal-actions .ghost-btn { flex: 1; padding: 10px; border-radius: 10px; font-size: 0.85rem; cursor: pointer; }
.modal-actions .primary-btn { background: var(--accent); color: #fff; border: none; }
.modal-actions .ghost-btn { background: #f2ede4; color: var(--ink); border: none; }
.modal-result { margin-top: 12px; }
.tryon-img { width: 100%; border-radius: 12px; display: block; box-shadow: 0 4px 14px rgba(60,42,24,0.1); }

/* 旧插画样式（已弃用，保留不报错） */
.look-wrap { display: none; }
