:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1d1c19;
  --muted: #6e6a61;
  --line: #e6e1d7;
  --green: #2f6b4f;
  --green-soft: #e7f0ea;
  --amber: #9a6a12;
  --amber-soft: #fbf1dc;
  --red: #a8382f;
  --red-soft: #fbe9e6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 28, 25, .05), 0 8px 24px rgba(29, 28, 25, .045);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative;
  padding: calc(14px + env(safe-area-inset-top)) 88px 6px 20px;
}
.brand {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: .04em;
}
.tagline {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.fs-btn {
  position: absolute;
  right: 16px;
  top: calc(15px + env(safe-area-inset-top));
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1;
  color: var(--green);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
}
.fs-btn:active { background: #f3f1ea; }
.fs-btn[hidden] { display: none; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px 24px;
}

.view[hidden] { display: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .02em;
}
.card.warn {
  background: #fffdf8;
  border-color: #eeddb8;
}

/* ---------- 表单 ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 14px 0 6px;
}
label:first-child { margin-top: 0; }
.opt, .req {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}
.req { color: var(--green); }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  border-color: #b9c9bf;
  background: #fff;
}
textarea::placeholder, input::placeholder { color: #a9a49a; }

.linklike {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 0 2px;
  color: var(--green);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
}
.linklike:active { opacity: .6; }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.5;
}
.footnote {
  text-align: center;
  font-size: 12px;
  color: #a9a49a;
  margin: 20px 0 4px;
}

/* ---------- 按钮 ---------- */
button {
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 11px 16px;
  transition: opacity .15s, transform .08s;
}
button:active { transform: scale(.985); }
button:disabled { opacity: .55; cursor: default; }

button.primary {
  background: var(--green);
  color: #fff;
  font-weight: 600;
}
button.primary.big {
  width: 100%;
  margin-top: 18px;
  padding: 15px 16px;
  font-size: 16px;
}
button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row button { flex: 1; }
.card > .row { margin-top: 16px; }

/* ---------- 拍照入口 ---------- */
.photo-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 2px;
  padding: 14px;
  border: 1.5px dashed #ccd8d0;
  border-radius: 13px;
  background: #fbfaf7;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.photo-drop:active { background: #f3f1ea; }
.photo-drop:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.photo-drop svg {
  width: 26px;
  height: 26px;
  flex: none;
  fill: none;
  stroke: var(--green);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.photo-drop b { display: block; font-size: 14.5px; font-weight: 650; }
.photo-drop span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.photo-drop.busy {
  cursor: default;
  justify-content: center;
  border-style: solid;
  background: #fff;
}
.photo-drop .thumb {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.stack { display: grid; gap: 9px; }
.stack[hidden] { display: none; }

.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfaf7;
}
.model-list[hidden] { display: none; }
.model-list .hint { width: 100%; margin: 0 0 2px; }
.model-list .chip { font-size: 12px; padding: 5px 10px; }

#testOut { white-space: pre-line; }

/* ---------- 结论卡 ---------- */
.verdict {
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 12px;
  border: 1px solid;
}
.verdict.buy { background: var(--green-soft); border-color: #c6dccd; }
.verdict.caution { background: var(--amber-soft); border-color: #ecd9ad; }
.verdict.avoid { background: var(--red-soft); border-color: #efc9c3; }

.v-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  margin-bottom: 6px;
}
.verdict.buy .v-label { color: var(--green); }
.verdict.caution .v-label { color: var(--amber); }
.verdict.avoid .v-label { color: var(--red); }

.v-headline {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
}
.v-summary {
  margin: 10px 0 0;
  font-size: 14px;
  color: #45423c;
}

/* ---------- 列表 ---------- */
ul.list, ul.hits {
  margin: 0;
  padding-left: 18px;
}
ul.list li, ul.hits li {
  margin: 6px 0;
  font-size: 14.5px;
}
ul.hits li b { font-weight: 650; }
ul.hits li::marker { color: var(--amber); }

/* ---------- 维度条 ---------- */
.scores { display: grid; gap: 12px; }
.score-row .score-top {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 5px;
}
.score-row .score-name { font-weight: 600; }
.score-row .score-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar {
  height: 7px;
  border-radius: 4px;
  background: #efece4;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--green);
}
.score-row .score-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 5px;
}

/* ---------- 操作行 ---------- */
.actions {
  display: flex;
  gap: 10px;
  margin: 4px 0 8px;
}
.actions button { flex: 1; }

/* ---------- 商品库 ---------- */
.chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.chip {
  background: #fbfaf7;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
}
.chip.on {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}
#cardChips {
  margin: 0 0 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  /* 右边淡出，暗示还能往右滑 */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
}
#cardChips::-webkit-scrollbar { display: none; }
#cardChips .chip { flex: 0 0 auto; }

.tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  background: #eef1ea;
  color: #5d6a57;
  margin-right: 5px;
  vertical-align: 1px;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.item-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  cursor: pointer;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 8px;
  flex: none;
}
.dot.buy { background: var(--green); }
.dot.caution { background: #d19a2a; }
.dot.avoid { background: var(--red); }

.item-title {
  flex: 1;
  min-width: 0;
}
.item-title .t {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-title .m {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}
.chev {
  color: #b8b2a6;
  font-size: 13px;
  margin-top: 2px;
  flex: none;
}

.item-body {
  padding: 0 16px 16px;
  border-top: 1px solid #f2efe8;
  font-size: 14.5px;
}
.item-body .verdict {
  margin: 14px 0 12px;
  padding: 13px 14px;
  box-shadow: none;
}
/* 展开区里的卡片不要第二层边框 */
.item-body > .card {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid #f2efe8;
}
.item-body .v-headline { font-size: 17px; }
.item-body textarea, .item-body input { font-size: 14px; }
.meta-line {
  font-size: 12.5px;
  color: var(--muted);
  margin: 10px 0 0;
  word-break: break-all;
}
.tiny-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.tiny-actions button {
  flex: 1;
  font-size: 13.5px;
  padding: 9px 10px;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 46px 20px;
  line-height: 1.7;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 0;
  padding: 9px 0 8px;
  color: #a29c90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
}
.tab svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab.on { color: var(--green); }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: #24231f;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 82vw;
  text-align: center;
}
.toast.show {
  opacity: .95;
  transform: translate(-50%, 0);
}

/* ---------- 加载态 ---------- */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  padding: 26px 10px;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ddd8cd;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
