:root {
  --bg: #f6f2ee; --card: #fffdfb; --ink: #1f1a1c; --muted: #8c8285; --line: #ebe3dd;
  --accent: #8e2f4f; --accent-soft: #f5e8ec; --gold: #a8875a; --gold-soft: #f4ede3;
  --shadow: 0 1px 2px rgba(60, 30, 40, .04), 0 8px 24px rgba(60, 30, 40, .06);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }

header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 16px 24px; background: rgba(255, 253, 251, .9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
h1 { font: 600 20px/1.2 var(--serif); letter-spacing: .06em; margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
h1 small { font: 500 11px/1 -apple-system, "PingFang SC", sans-serif; letter-spacing: .04em; color: var(--gold);
  background: var(--gold-soft); padding: 5px 9px; border-radius: 999px; }
h1 small:empty { display: none; }
h2 { font: 600 16px/1.3 var(--serif); letter-spacing: .04em; margin: 0 0 12px; }

#tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 999px; }
#tabs button, .seg button { border: none; background: none; color: var(--muted);
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font: inherit; transition: .2s; }
#tabs button.active { background: var(--ink); color: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.seg button { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 6px 13px; font-size: 13px; }
.seg button.active { background: var(--ink); border-color: var(--ink); color: #fff; }

main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; padding: 24px; max-width: 1280px; margin: 0 auto; }
@media (max-width: 860px) { main { grid-template-columns: 1fr; padding: 12px 16px; } }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font: inherit; user-select: none; transition: .2s; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }

.canvas-wrap { position: relative; background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  min-height: 420px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#view { max-width: 100%; max-height: 72vh; display: block; }
#placeholder { position: absolute; color: var(--muted); padding: 24px; text-align: center; line-height: 1.9; }
#placeholder b { color: var(--ink); font-weight: 500; }
#busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  background: rgba(255, 253, 251, .78); backdrop-filter: blur(4px); font: 15px var(--serif); letter-spacing: .05em; }
#busy[hidden] { display: none; }
#cam { width: 100%; border-radius: 20px; margin-top: 12px; transform: scaleX(-1); }
.note { color: var(--muted); font-size: 12px; }

.panel > div { background: var(--card); border-radius: 20px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel > div.msg { background: #fff6ea; color: #7a4b00; box-shadow: none; border: 1px solid #f1d7ad; }
.sub { color: var(--muted); margin: -4px 0 14px; font-size: 13px; }
.empty { color: var(--muted); }
.big { font: 600 30px/1.2 var(--serif); color: var(--accent); letter-spacing: .06em; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; margin: 12px 0 16px;
  padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.kv span:nth-child(odd) { color: var(--muted); }
ul.tags { list-style: none; padding: 0; margin: 8px 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
ul.tags li { background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
ul.tags.avoid li { background: var(--bg); color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.2); }

.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.sw { border: none; background: none; padding: 4px 0; cursor: pointer; font: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; }
.sw i { width: 44px; height: 44px; border-radius: 50%; box-shadow: inset 0 -6px 12px rgba(0,0,0,.18), inset 0 6px 10px rgba(255,255,255,.25), 0 0 0 1px rgba(0,0,0,.06);
  outline: 2px solid transparent; outline-offset: 3px; transition: .2s; }
.sw.active i { outline-color: var(--ink); }
.sw em, .pname em { font-style: normal; font-size: 10px; color: var(--gold); background: var(--gold-soft); padding: 1px 6px; border-radius: 999px; }
.group-title { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.group-title:first-child { border-top: none; padding-top: 0; margin-top: 0; color: var(--accent); font-weight: 600; }

.presets { display: grid; gap: 8px; }
.preset { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; background: var(--card); cursor: pointer; font: inherit; color: var(--ink); text-align: left; transition: .2s; }
.preset.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.preset .dots { display: flex; }
.preset .dots i { width: 22px; height: 22px; border-radius: 50%; margin-right: -6px; border: 2px solid var(--card); }
.pname { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
.preset small { color: var(--accent); margin-left: auto; font-size: 11px; }

.slider { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.slider input { flex: 1; accent-color: var(--ink); }

#report { white-space: pre-wrap; font: 13px/1.85 inherit; font-family: inherit; margin: 0 0 12px; max-height: 340px; overflow: auto; }

/* 手机：仿小程序布局，底部标签栏、照片限高、工具栏一行 */
@media (max-width: 600px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  /* 不能用 backdrop-filter：它会让内部 position:fixed 的底部标签栏相对 header 定位 */
  header { position: sticky; top: 0; z-index: 5; justify-content: center; padding: 12px 16px; backdrop-filter: none; background: var(--card); }
  #tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; gap: 0; border-radius: 0;
    background: rgba(255, 253, 251, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  #tabs button { flex: 1; border-radius: 0; background: none; color: var(--muted); padding: 8px 0; }
  #tabs button.active { background: none; color: var(--ink); font-weight: 600; }
  main { gap: 12px; }
  .toolbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
  .toolbar .btn { padding: 8px 0; text-align: center; font-size: 13px; }
  .canvas-wrap { min-height: 240px; border-radius: 16px; }
  #view { max-height: 48vh; }
  .note { margin: 6px 0 0; }
  .panel > div { padding: 16px; margin-bottom: 12px; border-radius: 16px; }
}

/* 店内推荐与 AI 顾问 */
ul.tags.shop li { background: var(--gold-soft); color: var(--gold); }
.tagline { font: 15px/1.6 var(--serif); color: var(--ink); margin-bottom: 8px; letter-spacing: .04em; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.advice { white-space: pre-wrap; margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--gold-soft);
  font-size: 13.5px; line-height: 1.9; border-left: 3px solid var(--gold); }
.advice.empty { color: var(--muted); }
