:root {
  /* ---- 毛绒（Plush）：奶油底 / 莓果玫瑰 / 大圆角 / 绒面 ----
     与 theme.css 的 :root 同值；theme.css 后加载，但这里不能留旧值，
     否则单引 styles.css 的页面会回到科技蓝。 */
  --bg: #f5ece1;
  --panel: #fffdfa;
  --line: #ecdfd2;
  --line-strong: #dcc8b6;
  --text: #3b322d;
  --text-2: #6d5f56;
  --text-3: #a2918a;
  --brand: #c94a72;
  --brand-soft: #fdeef4;
  --warn: #b8722e;
  --warn-bg: #fdf4e6;
  --warn-line: #f0d9b3;
  --ok: #4f8a6b;
  --ok-bg: #eef7f1;
  --radius: 16px;

  /* ---- 语义层：主题切换只改这里 ---- */
  --surface: #fffdfa;          /* 卡片 / 面板 / 输入框底 */
  --surface-2: #f6ece1;        /* 次级底：chip / 标签 / 缩略图背板 */
  --surface-3: #fdf8f2;        /* 条带底 */
  --surface-4: #faf3ec;        /* 舞台 / 表头底 */
  --surface-sunken: #fdf7f1;   /* 汇总条底 */
  --hover-bg: #fbf3ea;
  --field-bg: #fffefc;
  --thumb-bg: #f6ece1;
  --line-soft: #f5ece2;
  --brand-hover: #b23f65;
  --brand-weak: rgba(201, 74, 114, .10);
  --brand-ring: rgba(201, 74, 114, .18);
  --brand-line: #f6cedd;
  --on-brand: #fffdfc;
  --btn-disabled-bg: #edcdd8;
  --piece-line: #c94a72;
  --piece-fill: #fdf2f7;
  --seam-line: #e8bccd;
  --grain-line: #b8a294;
  --topbar-bg: linear-gradient(180deg, #fffdfa 0%, #fdf5ed 100%);
  --logo-bg: linear-gradient(135deg, #eeacbc, #b8617a);
  --logo-ink: #fffdfb;
  --pill-glass: rgba(255, 253, 250, .95);
  --overlay: rgba(59, 50, 45, .38);
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font-ui: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: inherit;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--logo-bg);
  display: grid; place-items: center;
  color: var(--logo-ink); font-weight: 700; font-size: 13px;
}
.brand { font-weight: 650; letter-spacing: .2px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--text-3); letter-spacing: 0; }

.topbar .spacer { flex: 1; }

/* 手机上顶栏会被挤成一列竖字：允许换行、把只对桌面有意义的入口收掉。
   「示意图 · 非成品效果」在结果图上还有一条水印，不缺这一条；
   副标题先让路——手机首屏的每一行都该用来干事。 */
@media (max-width: 620px) {
  .topbar { height: auto; min-height: 50px; padding: 7px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar > * { white-space: nowrap; }
  .brand small { display: none; }
  .topbar .demo-chip { display: none; }
  .topbar .link-btn { font-size: 11.5px; padding: 4px 9px; }
  .topbar .lib-entry { font-size: 11.5px; }
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 11.5px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.dot.on { background: #10b981; }
.dot.off { background: #ef4444; }

/* ---------------------------------------------------------------- 布局 */
.layout {
  display: grid;
  grid-template-columns: 264px 348px minmax(420px, 1fr);
  gap: 14px;
  padding: 14px;
  align-items: start;
  max-width: 1680px;
  margin: 0 auto;
}
@media (max-width: 1240px) {
  .layout { grid-template-columns: 240px 1fr; }
  .result-col { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 12.5px;
}
.panel-head .count { color: var(--text-3); font-weight: 400; font-size: 11px; }
.panel-body { padding: 12px 13px; }

/* ---------------------------------------------------------------- 模特库 */
.cat-tabs {
  display: flex; gap: 4px; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button {
  flex: 0 0 auto;
  border: 1px solid transparent; background: var(--surface-2);
  color: var(--text-2);
  padding: 4px 9px; border-radius: 999px; cursor: pointer;
  font-size: 11.5px; white-space: nowrap;
}
.cat-tabs button.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.model-list { max-height: calc(100vh - 168px); overflow-y: auto; padding: 8px; }
.model-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .12s;
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 9px;
  align-items: center;
}
.model-card:hover { border-color: var(--line-strong); background: var(--hover-bg); }
.model-card.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand) inset;
}
/* 卡片里的缩略图例：高度固定，宽度由身高/胖瘦自然决定 */
.model-card .card-fig { height: 60px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.model-card .card-fig svg { height: 60px; width: auto; max-width: 42px; display: block; }
.model-card .card-fig svg .fig-body { fill: #dde6f4; stroke: #8496b0; }
.model-card .card-main { min-width: 0; }
.model-card .row1 { display: flex; align-items: center; gap: 6px; }
.model-card .nm { font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.model-card .dims {
  margin-top: 5px; color: var(--text-2); font-size: 11px;
  display: flex; flex-wrap: wrap; gap: 2px 9px;
}
.model-card .dims b { color: var(--text); font-weight: 600; }

.tag {
  font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.tag.measured { background: var(--ok-bg); color: var(--ok); }
.tag.derived { background: var(--warn-bg); color: var(--warn); }
.tag.legacy { background: var(--surface-2); color: var(--text-2); }
.tag.stale { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }

/* ---------------------------------------------------------------- 参数 */
.field { margin-bottom: 11px; }
.field > label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--text-2); margin-bottom: 5px;
}
.field > label .hint { color: var(--text-3); font-size: 10.5px; }
.segmented { display: flex; gap: 4px; flex-wrap: wrap; }
.segmented button {
  flex: 1 1 auto; min-width: 54px;
  border: 1px solid var(--line); background: var(--field-bg);
  padding: 5px 6px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 11.5px; color: var(--text-2);
}
.segmented button:hover { border-color: var(--line-strong); }
.segmented button.active {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600;
}
input[type="number"], input[type="text"], select {
  width: 100%; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--field-bg); outline: none;
}
input[type="number"]:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.check {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2); cursor: pointer;
}
.check input { accent-color: var(--brand); }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.section-label {
  font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 8px;
}

/* ---------------------------------------------------------------- 结果 */
.result-col { display: flex; flex-direction: column; gap: 14px; }
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
  border-bottom: 1px solid var(--line);
}
.metric { background: var(--surface); padding: 10px 12px; }
.metric .k { font-size: 10.5px; color: var(--text-3); margin-bottom: 3px; }
.metric .v { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.metric .u { font-size: 10.5px; color: var(--text-3); font-weight: 400; margin-left: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
th { color: var(--text-3); font-weight: 500; font-size: 10.5px; background: var(--surface-sunken); }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; }
.src-badge { font-size: 10px; padding: 1px 4px; border-radius: 3px; }
.src-PATTERN { background: var(--ok-bg); color: var(--ok); }
.src-FALLBACK { background: var(--warn-bg); color: var(--warn); }

.warn-box {
  margin: 10px 13px 13px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.55;
}
.warn-box .t { font-weight: 650; margin-bottom: 3px; }
.warn-box ul { margin: 0; padding-left: 16px; }

.cost {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 11px 13px;
  background: var(--surface-sunken); border-top: 1px solid var(--line);
}
.cost .k { font-size: 11.5px; color: var(--text-2); }
.cost .v { font-size: 22px; font-weight: 700; letter-spacing: -.6px; }
.cost .v small { font-size: 11px; font-weight: 400; color: var(--text-3); }

.empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.7; }
.loading-bar {
  height: 2px; background: linear-gradient(90deg, transparent, var(--brand), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: slide 1s infinite linear;
}
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.footnote { color: var(--text-3); font-size: 10.5px; line-height: 1.6; padding: 0 13px 12px; }

/* ===== 版片拆解图 ===== */
.sheet-box { padding: 10px 13px 6px; }
.sheet-frame {
  background:
    linear-gradient(0deg, rgba(37,99,235,.035), rgba(37,99,235,.035)),
    repeating-linear-gradient(0deg, var(--surface), var(--surface) 9px, var(--surface-4) 9px, var(--surface-4) 10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  max-height: 430px;
  display: flex; align-items: center; justify-content: center;
}
.sheet-svg { display: block; width: 100%; height: auto; max-height: 414px; }
.sheet-svg .piece-fill { fill: var(--piece-fill); }
.sheet-svg .piece-line { stroke: var(--piece-line); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.sheet-svg .seam-line { stroke: var(--seam-line); stroke-width: 1; stroke-dasharray: 4 3; fill: none; vector-effect: non-scaling-stroke; }
.sheet-svg .grain { stroke: var(--grain-line); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.sheet-svg .dim { fill: var(--text-2); }
.sheet-svg .tag-qty { fill: var(--brand-hover); font-weight: 700; }
.sheet-svg .piece-name { fill: var(--brand-hover); font-weight: 600; }
.sheet-legend {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 10.5px; color: var(--text-3);
  padding: 7px 3px 2px;
}
.sheet-legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--piece-line); vertical-align: middle; margin-right: 4px; }
.sheet-legend i.dashed { border-top: 2px dashed var(--seam-line); }
.sheet-legend i.grain { border-top: 2px dashed var(--line-strong); }
.piece-note { color: var(--text-3); font-size: 10.5px; }

/* ===== 图例（模特比例示意） ===== */
.mini-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  padding: 3px 9px; border-radius: var(--radius-xs); cursor: pointer; font-size: 11px;
}
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }

.doll-fig { display: block; width: 100%; height: auto; }
.doll-fig .fig-body { }
.fig-dim { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.fig-ruler { stroke: var(--grain-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fig-lbl { fill: var(--text-2); font-family: inherit; }
.fig-lbl-strong { fill: var(--text); font-weight: 600; }
.fig-lbl-dim { fill: var(--text-3); }
.band-edge { stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }

/* ===== 图例对照面板 ===== */
.atlas-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(17, 24, 39, .42);
  display: grid; place-items: center;
  padding: 24px;
}
.atlas {
  background: var(--panel); border-radius: 14px; overflow: hidden;
  width: min(1180px, 100%);
  height: min(860px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(17, 24, 39, .28);
}
.atlas-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.atlas-head b { font-size: 13.5px; }
.atlas-body {
  display: grid; grid-template-columns: 268px 1fr; grid-template-rows: minmax(0, 1fr);
  min-height: 0; flex: 1;
}
@media (max-width: 860px) { .atlas-body { grid-template-columns: 1fr; grid-template-rows: 320px minmax(0, 1fr); } }

.atlas-side {
  border-right: 1px solid var(--line);
  padding: 14px 14px 16px;
  overflow-y: auto;
  background: var(--surface-3);
}
.atlas-fig {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px; display: flex; justify-content: center;
}
.atlas-fig svg { height: 300px; width: auto; max-width: 100%; }
.atlas-name { text-align: center; font-weight: 650; font-size: 12.5px; margin: 9px 0 10px; }
.atlas-tbl { width: 100%; }
.atlas-tbl td { padding: 4px 2px; font-size: 11.5px; border-bottom: 1px dashed var(--line-soft); }
.atlas-tbl td:first-child { color: var(--text-3); }
.atlas-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.atlas-note {
  margin-top: 11px; font-size: 11px; line-height: 1.6;
  color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px;
}
.atlas-note.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }

.atlas-main { padding: 12px 16px 14px; min-width: 0; display: flex; flex-direction: column; }
.cmp-wrap {
  flex: 1; min-height: 0; overflow: hidden;
  background:
    linear-gradient(0deg, rgba(37,99,235,.03), rgba(37,99,235,.03)),
    repeating-linear-gradient(0deg, var(--surface), var(--surface) 9px, var(--surface-4) 9px, var(--surface-4) 10px);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px;
}
.cmp-wrap svg { width: 100%; height: 100%; display: block; }
.cmp-item { cursor: pointer; }
.cmp-item:hover > g:first-of-type { fill: var(--piece-fill); }

/* ===== 换装试衣入口 ===== */
.link-btn {
  color: var(--text-2); text-decoration: none; font-size: 12.5px;
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line);
}
.link-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.tryon-chip { background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-line); }

/* ===== 参考图 / 保存报价 ===== */
.primary {
  background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand);
  border-radius: 7px; padding: 6px 14px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.primary:hover { background: var(--brand-hover); }
.primary:disabled { opacity: .6; cursor: not-allowed; }

.badge {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px;
  background: var(--brand); color: var(--on-brand); border-radius: 999px;
  font-size: 10.5px; line-height: 16px; text-align: center;
}

.ref-shot-body { padding: 10px 12px 12px; }
.ref-shot-body img {
  width: 100%; max-height: 240px; object-fit: contain; display: block;
  border-radius: 8px; background: var(--thumb-bg); cursor: zoom-in;
}
.ref-shot-empty {
  font-size: 11.5px; color: var(--text-3); background: var(--surface-2);
  border-radius: 8px; padding: 18px 12px; text-align: center; line-height: 1.7;
}

.save-row { display: flex; align-items: center; gap: 10px; padding: 0 13px 12px; flex-wrap: wrap; }
.save-msg { font-size: 11.5px; color: #16a34a; }
.warn-text { color: #b45309; padding: 4px 0 0; }

.save-dlg {
  width: min(520px, 94vw); background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
}
.save-dlg .panel-body { padding: 14px 16px 16px; }
.save-dlg textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px;
  font-family: inherit; font-size: 12px; color: var(--text); resize: vertical;
}
.save-sum {
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; margin: 12px 0 6px;
  background: var(--surface-4); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
.save-sum div { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; }
.save-sum span { color: var(--text-3); }
.save-sum b { color: var(--text); font-weight: 600; }
.save-sum b.big { color: var(--brand); font-size: 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.zoom-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .82); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.zoom-mask img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.warn-list { margin: 10px 0 0; padding-left: 18px; font-size: 11.5px; color: #b45309; line-height: 1.7; }
/* 参考图卡片的标签别把"放大"挤出去：图库 note 可能很长 */
.ref-shot .panel-head .count {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%;
}
