* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --pink: #FF4D6D;
  --pink-bg: #FFE3EA;
  --pink-dark: #C9184A;
  --border: rgba(255, 77, 109, 0.16);
  --border-light: rgba(255, 77, 109, 0.10);
  --muted: #8E8E93;
  --tertiary: #AEAEB2;
  --danger: #C9184A;
  --radius: 12px;
}
html {
  /* 画布底色：任何被拖出来露出的区域都与应用同色（此前未设，系统深色模式下露黑） */
  background: #F2F2F7;
  color-scheme: light;   /* 应用只有浅色主题，避免系统深色模式把画布/控件变深色 */
}
html, body {
  height: 100%; width: 100%;
  overflow-x: hidden;          /* 禁止页面级横向滚动，挡住 iOS 横向橡皮筋 */
  overscroll-behavior-x: none; /* 禁止横向过滚动回弹 */
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #F2F2F7; color: #1D1D1F;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
#app {
  position: relative; height: 100dvh; max-width: 560px;
  margin: 0 auto; background: #fff; overflow: hidden;
}

/* ---------- 视图 ---------- */
.view {
  position: absolute; top: 0; left: 0; right: 0;
  bottom: calc(58px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: none; background: #fff;
}
.view.active { display: block; }

/* ---------- 顶部 ---------- */
.hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px 8px;
}
.hdr .t { font-size: 22px; font-weight: 500; }
.hdr .hint { font-size: 12px; color: var(--tertiary); }
.link { background: none; border: none; color: var(--pink); font-size: 14px; font-weight: 500; }
.sub { font-size: 12px; color: var(--tertiary); padding: 0 16px 8px; }

/* ---------- 分类标签 ---------- */
.chiprow { display: flex; align-items: center; gap: 8px; padding: 4px 16px 10px; }
.chips { display: flex; gap: 6px; overflow: hidden; flex: 1; min-width: 0; }
.chip {
  font-size: 12px; padding: 5px 12px; border-radius: 15px;
  border: 0.5px solid var(--border); color: #5A5A5E;
  white-space: nowrap; flex-shrink: 0; background: #fff;
}
.chip.on { background: var(--pink-bg); color: var(--pink); border-color: var(--pink); font-weight: 500; }
.more {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  border: 0.5px solid rgba(0,0,0,0.2); background: #fff; color: #5A5A5E;
  font-size: 15px; line-height: 1; padding-bottom: 2px;
}
.mchips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mchips .chip { font-size: 13px; padding: 9px 0; text-align: center; width: 100%; }

/* ---------- 衣物网格 ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 2px 16px 100px; }
.grid .cell { display: flex; flex-direction: column; }
.grid .pic {
  background: #FFE3EA url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20120'%3E%3Cpath%20d='M33%2012%2020%2018%208%2034%2021%2044%2027%2037%2027%20110%2073%20110%2073%2037%2079%2044%2092%2034%2080%2018%2067%2012C63%2020%2057%2023%2050%2023%2043%2023%2037%2020%2033%2012Z'%20fill='%23FFD2DF'%20stroke='%23F4A6BC'%20stroke-width='2.4'%20stroke-linejoin='round'/%3E%3C/svg%3E") center / 56% auto no-repeat;
  border-radius: var(--radius); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
/* 有照片时 img 铺满并盖住占位简笔画；照片缺失/解码失败时移除 img，露出下面的简笔画 */
.grid .pic img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.grid .nm { font-size: 12px; color: #5A5A5E; margin-top: 5px; text-align: center; }
.empty {
  text-align: center; color: var(--tertiary); font-size: 14px; line-height: 1.8;
  padding: 48px 20px;
}
.empty::before {
  content: ""; display: block; width: 76px; height: 76px; margin: 0 auto 14px;
  background: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20120%20120'%20fill='none'%20stroke='%23F4A6BC'%20stroke-width='3.6'%20stroke-linejoin='round'%3E%3Crect%20x='26'%20y='16'%20width='68'%20height='88'%20rx='9'/%3E%3Cpath%20d='M60%2016v88'/%3E%3Ccircle%20cx='50.5'%20cy='62'%20r='3.2'%20fill='%23F4A6BC'%20stroke='none'/%3E%3Ccircle%20cx='69.5'%20cy='62'%20r='3.2'%20fill='%23F4A6BC'%20stroke='none'/%3E%3C/svg%3E") center / contain no-repeat; opacity: .85;
}

/* ---------- 悬浮添加按钮 ---------- */
.fab {
  position: absolute; right: 18px; z-index: 3;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--pink); color: #fff; border: none;
  font-size: 26px; font-weight: 500; line-height: 1;
}
.fab[hidden] { display: none; }

/* ---------- 账户 ---------- */
.prof {
  display: flex; align-items: center; gap: 5px;
  border: 0.5px solid var(--border); background: #FFF8FA;
  border-radius: 16px; padding: 6px 12px;
  font-size: 14px; font-weight: 500; color: #1D1D1F; font-family: inherit;
}
.prof .caret { font-size: 10px; color: var(--tertiary); }
.prow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 2px; border-bottom: 0.5px solid var(--border-light); font-size: 14px;
}
.prow:last-child { border-bottom: none; }
.prow .cur { font-size: 11px; color: var(--pink); border: 0.5px solid var(--pink); border-radius: 10px; padding: 2px 8px; }
.prow .sw { border: none; background: var(--pink-bg); color: var(--pink); font-size: 12px; border-radius: 10px; padding: 4px 12px; font-family: inherit; }
.prow .del { border: none; background: none; color: var(--danger); font-size: 12px; }
.prof-hint { font-size: 11px; color: var(--tertiary); margin-top: 10px; line-height: 1.6; }
.cloud-status { font-size: 13px; color: #2C2C2E; margin-bottom: 6px; }
.about-body .code {
  font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; line-height: 1.6;
  background: #FFF0F4; border-radius: 8px; padding: 10px; white-space: pre-wrap;
  word-break: break-all; color: #5A5A5E;
}

/* ---------- 底部导航 ---------- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; border-top: 0.5px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; height: calc(58px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; border: none; background: none;
  font-size: 10.5px; color: var(--tertiary); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--pink); font-weight: 500; }

/* ---------- 搭配列表（紧凑卡片，点开看大图） ---------- */
.card {
  display: flex; align-items: center; gap: 12px;
  margin: 0 14px 10px; padding: 10px;
  border: 0.5px solid var(--border); border-radius: 16px; background: #fff;
}
.card:active { background: #FFF8FA; }
.card .stage { width: 88px; flex: none; border-radius: 10px; }
.card-info { flex: 1; min-width: 0; }
.card-info .t2 { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-info .date { font-size: 11px; color: var(--tertiary); margin-top: 4px; }
.card-info .cnt { font-size: 11px; color: var(--pink); margin-left: 6px; }
.card-del {
  flex: none; border: none; background: none; color: var(--tertiary);
  font-size: 13px; padding: 4px 6px;
}
.stage {
  position: relative; background: #FFF8FA; width: 100%;
  aspect-ratio: 3 / 4; overflow: hidden;
  touch-action: pan-y;   /* 画面区域仍可上下滚动，避免弹窗卡住 */
}
.stage img.placed {
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: none;
}
.stage img.placed.selectable { pointer-events: auto; touch-action: none; }
.stage img.placed.selected { outline: 2px solid var(--pink); outline-offset: 1px; border-radius: 4px; }
.stage-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.stage-wrap .stage { width: 100%; max-width: 240px; border-radius: var(--radius); }
.stage-wrap .stage.stage-lg { max-width: 280px; }
.view-meta { padding: 0 0 10px; text-align: center; }
.card-empty-stage { padding: 14px; text-align: center; color: var(--tertiary); font-size: 12px; }

/* ---------- 我的 ---------- */
.stat-card { margin: 4px 16px 16px; background: var(--pink-bg); border-radius: var(--radius); padding: 14px; }
.stat-label { font-size: 12px; color: var(--pink-dark); }
.stat-value { font-size: 22px; font-weight: 500; color: var(--pink-dark); margin-top: 3px; }
.stat-sub { font-size: 12px; color: var(--pink); margin-top: 2px; }
.menu { margin: 0 16px; border: 0.5px solid var(--border); border-radius: 14px; overflow: hidden; }
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 0.5px solid var(--border-light);
  font-size: 14px; background: #fff;
}
.row:last-child { border-bottom: none; }
.row .ch { color: var(--tertiary); }
.row select { font-size: 13px; color: var(--pink); border: none; background: none; }
.foot-hint { font-size: 11px; color: var(--tertiary); text-align: center; margin: 16px 20px 30px; line-height: 1.7; }

/* ---------- 弹窗 ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, 0.4);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.sheet {
  background: #fff; border-radius: 16px; width: 100%;
  max-height: 86%; overflow-y: auto; padding: 16px;
}
.sheet.big { max-width: 340px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { font-size: 15px; font-weight: 500; }
.close { border: none; background: #FFF0F4; width: 28px; height: 28px; border-radius: 50%; font-size: 16px; color: #5A5A5E; line-height: 1; }

/* ---------- 底部抽屉式弹窗（头部/底部固定，内容区独立滚动） ---------- */
.modal.sheet-modal { align-items: flex-end; padding: 0; }
.modal.sheet-modal .sheet {
  max-width: 560px; border-radius: 20px 20px 0 0; padding: 0;
  max-height: 92%; display: flex; flex-direction: column; overflow: hidden;
}
.modal.sheet-modal .sheet-head { flex: none; margin-bottom: 0; padding: 16px 16px 10px; }
.sheet-body {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding: 0 16px 4px;
}
.sheet-body::-webkit-scrollbar { width: 0; }
.sheet-foot {
  flex: none; padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--border-light); background: #fff;
}
.sheet-foot button {
  width: 100%; padding: 13px 0; border-radius: 12px;
  font-size: 15px; font-family: inherit; border: 0.5px solid var(--border); background: #fff;
}
.sheet-foot button.primary { background: var(--pink); border-color: var(--pink); color: #fff; font-weight: 500; }

/* ---------- 选项按钮 / 粘贴框（导出·导入） ---------- */
.opt {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; margin-bottom: 10px;
  border: 0.5px solid var(--border); border-radius: 14px;
  background: #fff; font-size: 14.5px; font-family: inherit; color: #1D1D1F;
}
.opt.primary { background: var(--pink-bg); border-color: var(--pink); color: var(--pink-dark); font-weight: 500; }
.opt[hidden] { display: none; }
.imp-sum { font-size: 13px; color: #2C2C2E; line-height: 1.65; margin-bottom: 14px; }
.paste-area {
  display: block; width: 100%; min-height: 190px; resize: vertical;
  border: 0.5px solid var(--border); border-radius: 12px; background: #FFF8FA;
  padding: 12px; font-size: 12px; line-height: 1.5; color: #2C2C2E;
  font-family: ui-monospace, Menlo, monospace;
  user-select: text; -webkit-user-select: text;
}

/* ---------- 衣物编辑器 ---------- */
.edit-stage {
  position: relative; background: #FFF0F4; border-radius: var(--radius);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: 10px; touch-action: none;
}
.edit-stage canvas { max-width: 100%; max-height: 100%; }
#cropBox {
  position: absolute; border: 2px solid var(--pink);
  background: rgba(255, 77, 109, 0.12); pointer-events: none;
}
.edit-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.edit-tools button {
  flex: 1; min-width: 70px; padding: 9px 0; border-radius: 10px;
  border: 0.5px solid var(--border); background: #fff; font-size: 13px; font-family: inherit;
}
.edit-tools button.primary, .sheet-actions button.primary, .add-row button.primary {
  background: var(--pink-bg); color: var(--pink); border-color: var(--pink); font-weight: 500;
}
/* ---------- 编辑衣物：名称 / 分类胶囊（对齐原型稿，替代原来的下拉框） ---------- */
.flabel { font-size: 12px; color: var(--tertiary); margin: 0 0 6px 2px; }
#itemName {
  display: block; width: 100%; padding: 11px 12px;
  border: 0.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #FFF8FA; color: #1D1D1F;
  user-select: text; -webkit-user-select: text;
}
.cchips { display: flex; flex-wrap: wrap; gap: 8px; }
.cchips .chip { font-size: 13px; padding: 8px 16px; border-radius: 16px; }
#itemModal .edit-stage { max-width: 260px; margin: 0 auto 12px; }
#itemModal .sheet-foot { display: flex; gap: 10px; }
#itemModal .sheet-foot button { width: auto; }
#itemModal .sheet-foot .primary { flex: 1; }
#itemModal .sheet-foot .danger {
  flex: 0 0 90px; color: var(--danger); background: #fff;
  border-color: rgba(201, 24, 74, 0.3); font-weight: 500;
}
#itemModal .sheet-foot .plain { flex: 0 0 90px; color: #5A5A5E; background: #fff; }

.field { display: block; font-size: 12px; color: #5A5A5E; margin-bottom: 10px; }
.field input, .field select, #outfitName {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 0.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #FFF8FA;
  user-select: text; -webkit-user-select: text;
}
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions button { flex: 1; padding: 12px 0; border-radius: 10px; font-size: 14px; font-family: inherit; border: 0.5px solid var(--border); }
.sheet-actions .danger { color: var(--danger); background: #fff; }

/* ---------- 搭配编辑器 ---------- */
#outfitName { margin-bottom: 10px; }
.picker-hint { font-size: 11px; color: var(--tertiary); margin-bottom: 6px; }
.picker {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px;
  overscroll-behavior-x: contain;   /* 横向滚到边界后不把滚动传给页面（否则整页跟着橡皮筋） */
}
.picker img {
  width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  background: #FFF0F4 url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20120'%3E%3Cpath%20d='M33%2012%2020%2018%208%2034%2021%2044%2027%2037%2027%20110%2073%20110%2073%2037%2079%2044%2092%2034%2080%2018%2067%2012C63%2020%2057%2023%2050%2023%2043%2023%2037%2020%2033%2012Z'%20fill='%23FFD2DF'%20stroke='%23F4A6BC'%20stroke-width='2.4'%20stroke-linejoin='round'/%3E%3C/svg%3E") center / 58% auto no-repeat; flex-shrink: 0;
}
.slider-label { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 13px; color: #5A5A5E; }
.slider-label input { flex: 1; }

/* ---------- 分类管理 ---------- */
.cat-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 2px; border-bottom: 0.5px solid var(--border-light); font-size: 14px; }
.cat-row .cnt { font-size: 12px; color: var(--tertiary); margin-left: auto; margin-right: 12px; }
.cat-row .del { border: none; background: none; color: var(--danger); font-size: 12px; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row input {
  flex: 1; padding: 10px 12px; border: 0.5px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; background: #FFF8FA;
  user-select: text; -webkit-user-select: text;
}
.add-row button { padding: 0 18px; border-radius: 10px; font-size: 13px; font-family: inherit; }

/* ---------- 关于 ---------- */
.about-body p { font-size: 13px; line-height: 1.7; margin-bottom: 10px; color: #2C2C2E; }
.about-body .muted { color: var(--tertiary); font-size: 12px; }

/* ---------- Toast ---------- */
#toast {
  position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 40;
  background: rgba(29, 29, 31, 0.88); color: #fff;
  font-size: 13px; padding: 9px 18px; border-radius: 20px;
  max-width: 80%; text-align: center;
}
