:root {
  --ink: #e8e3d9;        /* 页面背景：暖象牙白 */
  --ink-2: #f4f0e9;     /* 卡片 / 抽屉 / 输入框表面 */
  --ink-3: #e0d9cd;     /* 图片底板，比页面略深一点 */
  --gold: #b58a45;      /* 主金：浅底上更清晰 */
  --gold-soft: #d9bd86; /* 浅金：仅用于描边 / 极淡背景 */
  --gold-ink: #8a6a30;  /* 金墨：浅底上的金色文字 */
  --text: #26221d;      /* 主文字：暖近黑 */
  --text-2: #8a8175;    /* 次文字 */
  --line: rgba(0, 0, 0, 0.10);  /* 浅底上的分隔线 */
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
#gate {
  position: fixed;
  inset: 0;
  display: flex;
  overflow: auto;
  padding: max(20px, var(--safe-top)) 22px max(20px, var(--safe-bottom));
  background: radial-gradient(ellipse at 32% 17%, #faf7f0, #f1ebe1 90%);
  color: #302522;
  z-index: 50;
}
.gate-card {
  width: min(820px, 100%);
  margin: auto;
  display: grid;
  grid-template-columns: 40% minmax(0, 1fr);
  overflow: hidden;
  background: #fffcf7;
  border: 1px solid #ded4c5;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(70, 44, 24, .08);
}
.brand { text-align: center; }
.gate-brand {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 484px;
  background: linear-gradient(153deg, #faf5eb, #eee5d5);
  border-right: 1px solid #e7ded1;
}
.gate-brand::before {
  content: "";
  position: absolute;
  inset: 23px;
  border: 1px solid #bca68077;
  border-radius: 3px;
  pointer-events: none;
}
.brand-logo-lg { position: relative; display: block; width: 148px; max-width: 62%; height: auto; }
.gate-form {
  min-width: 0;
  align-self: center;
  padding: 58px clamp(28px, 5vw, 62px) 55px;
}
.gate-heading { margin: 0 0 31px; }
.gate-heading h1 {
  margin: 0 0 10px;
  color: #432622;
  font: 400 32px/1.15 "Songti SC", "Noto Serif SC", "SimSun", serif;
  letter-spacing: .07em;
}
.gate-hint { margin: 0; color: #6b5c54; font-size: 14px; }
.gate-form label { display: block; margin: 0 0 8px; color: #302522; font-size: 13px; font-weight: 600; }
.gate-field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  margin: 0 0 19px;
  padding: 0 14px;
  background: #fffdfa;
  border: 1px solid #d9cec1;
  border-radius: 7px;
  color: #7b6559;
}
.gate-field:focus-within { border-color: #875b4b; box-shadow: 0 0 0 2px #875b4b22; }
.gate-field svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gate-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
  color: #302522;
  font-size: 16px;
  caret-color: #302522;
}
.gate-field input::placeholder { color: #807169; }
.gate-field input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #fffdfa inset;
  -webkit-text-fill-color: #302522;
  caret-color: #302522;
}
.gate-field input::-ms-reveal { display: none; }
.gate-eye {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #7b6559;
}
.gate-eye-slash { visibility: hidden; }
.gate-eye[aria-pressed="true"] .gate-eye-slash { visibility: visible; }
.gate-eye:focus-visible, .gate-submit:focus-visible { outline: 2px solid #875b4b; outline-offset: 2px; }
.gate-submit {
  position: relative;
  width: 100%;
  height: 52px;
  margin-top: 5px;
  border: 1px solid #5b302b;
  border-radius: 7px;
  background: #5b302b;
  color: #fff9ef;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .12em;
}
.gate-submit span { position: absolute; right: 17px; top: 50%; transform: translateY(-50%); color: #e9d2ae; font: 20px Georgia, serif; }
.gate-submit:active { background: #472420; }
.gate-submit:disabled { opacity: .72; cursor: progress; }
.gate-error { margin: 12px 0 0; color: #932d24; font-size: 13px; }
.gate-error:empty { margin: 0; }
@media (max-width: 620px) {
  .gate-card { width: min(360px, 100%); grid-template-columns: minmax(0, 1fr); border-radius: 12px; }
  .gate-brand { height: 171px; min-height: 0; border-right: 0; border-bottom: 1px solid #e7ded1; }
  .gate-brand::before { inset: 13px; }
  .brand-logo-lg { width: 81px; }
  .gate-form { padding: 25px 23px 24px; }
  .gate-heading { margin-bottom: 24px; }
  .gate-heading h1 { font-size: 26px; margin-bottom: 9px; }
  .gate-hint { font-size: 13px; }
  .gate-field { margin-bottom: 16px; }
  .gate-field, .gate-submit { height: 49px; }
}
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--gold);
  color: #1a1712;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.btn-primary:active { opacity: 0.86; }

/* ---------- 布局 ---------- */
.app {
  --brand-burgundy: #511e1e;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(240px, 520px) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 24px 12px;
  border-bottom: 1px solid var(--line);
}
/* 顶栏 logo：设计给的源图是透明底（alpha=0 背景），这里只控制高度，宽度按比例走。
   图注：800×221，比例 3.62，38px 高约等于 138px 宽。 */
.brand-compact { text-align: left; display: flex; align-items: center; }
.brand-logo { display: block; height: 38px; width: auto; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  transition: border-color 0.2s;
}
.search:focus-within { border-color: rgba(201, 168, 106, 0.5); }
.search svg {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round;
}
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}
.search input::placeholder { color: var(--text); opacity: .55; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  border: none; background: none; color: var(--text-2); font-size: 20px; line-height: 1; padding: 0 2px;
}


.topbar-actions { display: flex; align-items: center; gap: 10px; justify-self: end; }
.mode-switch {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--ink-2);
  border: 1px solid var(--line);
}
.mode-btn {
  display: grid; place-items: center;
  width: 40px; height: 32px;
  border: none; border-radius: 8px;
  background: transparent;
  transition: background 0.18s;
}
.mode-btn svg {
  width: 17px; height: 17px;
  fill: none; stroke: var(--text-2); stroke-width: 1.7;
}
.mode-btn.is-active { background: rgba(201, 168, 106, 0.16); }
.mode-btn.is-active svg { stroke: var(--gold); }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--line);
}
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: var(--text-2); stroke-width: 1.6; }

/* ---------- 筛选条 ---------- */
.filterbar {
  display: flex;
  align-items: center;
  padding: 4px 16px 10px;
  border-bottom: 1px solid var(--line);
}

/* 筛选触发按钮 */
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: border-color 0.16s, background 0.16s;
}
.filter-trigger:hover { border-color: rgba(201, 168, 106, 0.5); }
#filter-trigger, #store-logout { color: var(--brand-burgundy); }
.gallery-refresh { justify-content: center; width: 44px; min-height: 36px; margin-left: auto; padding: 8px; }
.gallery-refresh:disabled { opacity: .65; cursor: progress; }
.filter-trigger svg {
  width: 15px; height: 15px;
  fill: none; stroke: var(--gold); stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.gallery-refresh svg { width: 17px; height: 17px; stroke: var(--brand-burgundy); }
.filter-trigger-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--gold); color: #1a1712;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* 抽屉 */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.26s ease;
  z-index: 40;
}
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(380px, 88vw);
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0.28s;
  z-index: 41;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}
.drawer.is-open { transform: translateX(0); visibility: visible; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-title {
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px; letter-spacing: 0.12em; color: var(--text);
}
.drawer-close {
  border: none; background: none; color: var(--text-2);
  font-size: 26px; line-height: 1; padding: 0 6px;
}
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.drawer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.drawer-apply { width: auto; padding: 12px 22px; border-radius: 12px; }

/* 抽屉内的筛选区：竖向堆叠 */
.filter-scroll--vertical {
  display: flex; flex-direction: column;
  align-items: stretch; gap: 6px;
  overflow-y: auto; overflow-x: hidden;
  padding: 16px;
}
.facet-divider--h {
  width: auto; height: 1px; align-self: stretch;
  background: var(--line); margin: 8px 0;
}
.filter-scroll--vertical .facet-group {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px;
}
.filter-scroll--vertical .chip { flex: 0 0 auto; }
.filter-scroll {
  display: flex;
  align-items: center;
  gap: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-right: 24px;
  flex: 1;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.facet-group { display: flex; align-items: center; gap: 8px; flex: none; }
.facet-label {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--text-2);
  flex: none;
}
.facet-divider { width: 1px; height: 22px; background: var(--line); flex: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.16s;
}
.chip .n { font-size: 11px; color: var(--text-2); }
.chip.is-on {
  background: rgba(181, 138, 69, 0.14);
  border-color: rgba(181, 138, 69, 0.55);
  color: var(--gold-ink);
  font-weight: 600;
}
.chip.is-on .n { color: rgba(138, 106, 48, 0.8); }
.chip:active { transform: scale(0.97); }
/* 当前筛选组合下数量为 0 的品类/系列：淡化提示，但仍可点（便于清空后重选） */
.chip.is-zero { opacity: 0.4; }
.chip.is-zero .n { opacity: 0.7; }

.filter-summary {
  display: flex; align-items: center; gap: 12px;
  padding-right: 24px; flex: none;
  font-size: 13px; color: var(--gold-ink);
}
.link-btn {
  border: none; background: none;
  color: var(--text-2); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- 舞台 ---------- */
.stage { flex: 1; overflow: hidden; position: relative; }

.grid {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  /* 双列瀑布流：固定两列（手机/桌面皆两列） */
  grid-template-columns: 1fr 1fr;
  /* 关键：容器定高时 auto 行会被压缩到恰好填满（卡片塌成 33px、图片被 overflow 裁成一条），
     max-content 强制每行按内容实际高度撑开；align-content:start 让多行从顶部排布、不拉伸 */
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
  padding: 14px 16px calc(32px + var(--safe-bottom));
  max-width: 860px;
  margin: 0 auto;
}

.card {
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
  padding: 10px;
  overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card:active { transform: scale(0.985); border-color: rgba(201, 168, 106, 0.3); }
.card-media {
  position: relative;
  /* 真实产品图为正方形，缩略图亦保持原比例；用 1/1 方框 + contain，方图满铺、异形图不裁切 */
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--ink-3);
  padding: 8px;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.4s;
}
.card-media img.is-loaded { opacity: 1; }
.card-media .badge {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1712;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.card-media .play {
  position: absolute; right: 10px; bottom: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: grid; place-items: center;
}
.card-media .play::after {
  content: "";
  border-left: 9px solid rgba(255, 255, 255, 0.92);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  margin-left: 2px;
}
.card-body { padding: 12px 4px 4px; }
.card-title {
  font-family: "Songti SC", "STSong", serif;
  font-size: 16px;
  letter-spacing: 0.04em;
  margin: 0 0 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 卡片副标题：商品款号。用小号字 + 微字距，读起来像编号而不是标签块 */
.card-sku {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-2);
}

/* ---------- 批量下载套图 ---------- */
.download-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.dl-summary { font-size: 13px; letter-spacing: 0.04em; color: var(--text-2); }
.dl-summary strong { color: var(--gold-ink); font-weight: 600; }
.dl-actions { display: flex; align-items: center; gap: 14px; }
.dl-run {
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  background: var(--gold);
  color: #1a1712;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: opacity 0.16s, transform 0.16s;
}
.dl-run:disabled { opacity: 0.45; cursor: default; }
.dl-run:not(:disabled):active { transform: scale(0.97); }

/* 卡片勾选：右上角圆圈，选中后打勾 + 金色描边 */
.card.selectable { position: relative; }
.card.selectable .pick {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.26);
  display: grid;
  place-items: center;
  transition: background 0.16s, border-color 0.16s;
}
.card.selectable .pick::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.16s;
}
.card.selectable.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 6px 18px rgba(181, 138, 69, 0.16);
}
.card.selectable.is-selected .pick { background: var(--gold); border-color: var(--gold); }
.card.selectable.is-selected .pick::after { opacity: 1; }

/* 窄屏：统计和按钮压在一行，避免按钮文案变长（一键下载（N 款））时整条换行抖动 */
@media (max-width: 480px) {
  .download-bar { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .dl-summary { font-size: 12px; white-space: nowrap; }
  .dl-actions { gap: 10px; flex-shrink: 0; }
  .dl-run { padding: 8px 14px; font-size: 12px; letter-spacing: 0.04em; }
}

/* ---------- 空状态 ---------- */
.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 15px;
}

/* ---------- 详情 ---------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  animation: fade 0.22s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.detail-close,
.dm-arrow {
  border: 1px solid rgba(122, 96, 74, .18);
  background: rgba(122, 96, 74, .12);
  color: var(--text);
}
.detail-close:hover,
.dm-arrow:hover:not(:disabled) { background: rgba(122, 96, 74, .22); }
.detail-close:focus-visible,
.dm-arrow:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
.detail-close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 16px;
  z-index: 2;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.detail-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* 图片区外面这层是给翻页箭头做定位用的：arrow 绝对不能放进 .detail-media 里面，
   那个容器本身在横向滚动，absolute 子元素会跟着一起被滚走。 */
.detail-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  overflow: hidden;
}
.detail-media {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.detail-media::-webkit-scrollbar { display: none; }
/* PC 端翻页箭头：只有真有鼠标的设备才显示 */
.dm-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  display: none;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.dm-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dm-arrow:disabled { opacity: 0.3; cursor: default; }
.dm-arrow.dm-prev { left: 22px; }
.dm-arrow.dm-next { right: 22px; }
/* 只有一张图时整组箭头不出现 */
.detail-stage.is-single .dm-arrow { display: none !important; }
@media (hover: hover) and (pointer: fine) {
  .dm-arrow { display: grid; }
  .detail-media { cursor: grab; }
  .detail-media.is-dragging { cursor: grabbing; user-select: none; }
  .detail-media.is-dragging img { pointer-events: none; }
}
.detail-media > * {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  height: 100%;
  object-fit: contain;
}
.detail-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px;
  box-sizing: border-box;
}
.detail-figure img,
.detail-figure video {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.detail-download {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(181, 138, 69, 0.12);
  color: var(--gold-ink);
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, transform 0.18s ease;
}
.detail-download:hover { background: rgba(181, 138, 69, 0.22); }
.detail-download:active { transform: scale(0.97); }
.detail-download svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.detail-toolbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(181, 138, 69, 0.12);
  color: var(--gold-ink);
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, transform 0.18s ease;
}
.detail-btn:hover { background: rgba(181, 138, 69, 0.22); }
.detail-btn:active { transform: scale(0.97); }
.detail-btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.detail-btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.detail-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 14px;
}
.detail-info {
  flex: none;
  padding: 16px 32px calc(20px + var(--safe-bottom));
  text-align: center;
  border-top: 1px solid var(--line);
  background: linear-gradient(to top, rgba(244, 240, 233, 1), rgba(244, 240, 233, 0.92));
}
.detail-info h2 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.14em;
  margin: 0 0 6px;
}
.detail-price { color: var(--gold); font-size: 14px; letter-spacing: 0.12em; margin: 0 0 6px; }
.detail-desc { color: var(--text-2); font-size: 13px; margin: 0 0 10px; }
.detail-chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* 详情滑动圆点指示器 */
.detail-dots {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 0 4px;
}
.detail-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(181, 138, 69, 0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: width 0.22s ease, background 0.22s ease, border-radius 0.22s ease;
}
.detail-dot.is-active {
  width: 22px;
  border-radius: 4px;
  background: var(--gold);
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(244, 240, 233, 0.97);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  z-index: 60;
  animation: fade 0.2s ease;
}

/* ---------- 窄屏（竖屏 iPad / 手机） ---------- */
@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "search search";
    gap: 10px 12px;
    padding: 12px 16px 10px;
  }
  .topbar .brand-compact { grid-area: brand; }
  /* 窄屏把 logo 收一档，别把右侧两个视图按钮挤掉 */
  .brand-logo { height: 33px; }
  .topbar .search { grid-area: search; }
  .topbar .topbar-actions { grid-area: actions; }
  .filterbar { padding-left: 16px; }
  .filter-scroll { padding-right: 16px; }
  .filter-summary { padding-right: 16px; }
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 12px calc(24px + var(--safe-bottom));
    max-width: none;
    margin: 0;
  }
  .card { padding: 8px; border-radius: 16px; }
  .card-title { font-size: 14px; }
  .detail-info { padding: 14px 20px calc(18px + var(--safe-bottom)); }
  .detail-info h2 { font-size: 20px; }
}

/* ---------- 桌面端（含企微 PC 工作台 WebView，按宽度分档） ---------- */
@media (min-width: 1000px) {
  /* 桌面端画廊居中并略放宽，避免卡片过宽 */
  .grid { max-width: 1080px; }
  /* 鼠标用户：卡片可点 + 悬停反馈（企微 PC 打开时也能用） */
  .card { cursor: pointer; }
  .card:hover { border-color: rgba(201, 168, 106, 0.35); transform: translateY(-2px); }
  .mode-btn:hover svg { stroke: var(--text); }
}
@media (min-width: 1200px) {
  /* 三列：企微 PC 工作台 / 桌面浏览器 */
  .grid { grid-template-columns: repeat(3, 1fr); max-width: 1280px; }
}
@media (min-width: 1600px) {
  /* 四列：大屏 */
  .grid { grid-template-columns: repeat(4, 1fr); max-width: 1680px; }
}

/* ---------- 备案号页脚（大陆上线合规要求，未备案前可整块删除） ---------- */
.site-footer {
  padding: 8px 24px calc(8px + var(--safe-bottom));
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--gold); }
.site-footer .sep { margin: 0 8px; opacity: 0.5; }

/* ---------- 首页装修（可视化搭建器渲染出来的页面） ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ink);
}
.home-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.home-brand {
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  letter-spacing: 0.18em;
  color: var(--text);
}
.home-link {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--gold-ink);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 13px;
  border-radius: 999px;
}
.home-link:hover { border-color: var(--gold); }
.home-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 24px;
}
.home-tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--ink-2);
  padding: 8px 4px calc(8px + var(--safe-bottom));
}
.home-tabbar button {
  flex: 1;
  border: 0;
  background: none;
  font-size: 11px;
  color: var(--text-2);
  padding: 4px 0;
}
.home-tabbar button.on { color: var(--gold); font-weight: 600; }
.cp-card[data-pid] { cursor: pointer; }
.cp-card[data-pid]:active { transform: scale(0.985); }

/* ---------- 首页装修 · PC 宽屏适配 ----------
   这套规则只写在 style.css 里：后台编辑器（builder.html）不加载这个文件，
   所以编辑器里的手机预览框永远是 1:1 的手机效果，不会被宽屏样式污染。
   思路：内容列按档放宽 + 组件尺度等比跟上，而不是把手机页面简单拉宽。 */
@media (min-width: 1000px) {
  /* --- 内容列宽度（后续断点只改这一个变量，其余规则自动跟随） --- */
  .home { --home-w: 1080px; }

  .home-scroll {
    max-width: var(--home-w);
    padding-bottom: 64px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.16) transparent;
  }
  .home-scroll::-webkit-scrollbar { width: 8px; }
  .home-scroll::-webkit-scrollbar-track { background: transparent; }
  .home-scroll::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.14); border-radius: 8px; }
  .home-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.24); }

  /* --- 顶栏：品牌和按钮收进内容列，不再一头一尾隔着一千像素 --- */
  .home-bar {
    padding-block: 18px;
    padding-inline: max(24px, calc((100% - var(--home-w)) / 2));
  }
  .home-brand { font-size: 22px; letter-spacing: 0.28em; }
  .home-link { font-size: 13px; padding: 9px 20px; transition: background 0.2s ease, border-color 0.2s ease; }
  .home-link:hover { background: rgba(181, 138, 69, 0.08); }

  /* --- 底部 tabbar：三等分通栏在宽屏很怪，收成居中的胶囊导航 --- */
  .home-tabbar {
    justify-content: center;
    gap: 6px;
    padding: 12px 0 calc(12px + var(--safe-bottom));
  }
  .home-tabbar button {
    flex: 0 0 auto;
    padding: 9px 30px;
    font-size: 13.5px;
    letter-spacing: 0.08em;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
  }
  .home-tabbar button:hover { color: var(--gold-ink); background: rgba(181, 138, 69, 0.08); }
  .home-tabbar button.on { background: rgba(181, 138, 69, 0.14); }

  /* --- 组件通用：内边距加大一档 --- */
  .home-scroll .cp { padding: 22px 26px; }
  .home-scroll .cp.tight { padding: 0; }

  /* --- 轮播：用户设的 px 高度是照手机算的，宽屏按内容列宽的比例换算。
         素材是正方形白底产品图，宽屏 cover 会裁得只剩中间一条，
         所以这里换成 contain 完整展示 + multiply 让白底融进米色底，
         和商品卡片同一个手法。手机端维持原来的裁切，一个字没动。
         另外横幅拉到内容列全宽时两侧会空出一大片，收窄居中更像画册跨页。 --- */
  .home-scroll .cp-banner {
    max-width: min(calc(var(--home-w) * 0.62), 100%);
    margin-inline: auto;
    background: var(--p-img);
    /* 横幅底色和页面底几乎同色，加一道内描边让「画框」站住 */
    box-shadow: inset 0 0 0 1px var(--p-line);
  }
  .home-scroll .cp-banner .track img {
    /* 取「用户设的高度」和「按视口算的高度」两者较大的：
       既保证宽屏上不扁成一条，用户主动调高时也照样生效。
       --bn-h 是渲染器写进来的用户设定值。 */
    height: max(var(--bn-h, 0px), min(42vw, 46vh, 520px)) !important;
    object-fit: contain;
    mix-blend-mode: multiply;
  }
  .home-scroll .cp-banner .track { scroll-snap-type: x mandatory; }
  .home-scroll .cp-banner .dots { bottom: 14px; gap: 7px; }
  .home-scroll .cp-banner .dots i { width: 7px; height: 7px; }
  .home-scroll .cp-banner .dots i.on { width: 20px; }

  /* --- 商品列表：2 列在宽屏升 3 列；用户显式设 3/4 列的保持原样 --- */
  .home-scroll .cp-grid { gap: 20px; }
  .home-scroll .cp-grid[data-cols="2"] {
    grid-template-columns: repeat(3, minmax(0, 330px)) !important;
    justify-content: center;
  }
  .home-scroll .cp-card { border-radius: 16px; }
  .home-scroll .cp-card .im { padding: 10px; }
  .home-scroll .cp-card .nm { font-size: 14px; padding: 11px 13px 3px; }
  .home-scroll .cp-card .ct { font-size: 11.5px; padding: 0 13px 13px; }
  .home-scroll .cp-card[data-pid]:hover { border-color: rgba(201, 168, 106, 0.4); transform: translateY(-2px); }
  .home-scroll .cp-card { transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease; }

  /* --- 文字类：整站字号上浮一档，标题按用户设定等比放大（不写死） --- */
  .home-scroll .cp-h { font-size: calc(var(--fs, 21) * 1.18px) !important; }
  .home-scroll .cp-rich { font-size: 14.5px; line-height: 2.05; max-width: 880px; margin-inline: auto; }

  /* --- 图文导航：圆钮放大，整排收窄居中，避免 4 个点散在 1080 里 --- */
  .home-scroll .cp-nav { gap: 20px; max-width: 780px; margin-inline: auto; }
  .home-scroll .cp-nav .ni .cir { width: 58px; height: 58px; font-size: 19px; }
  .home-scroll .cp-nav .ni span { font-size: 12.5px; }

  /* --- 分组标签 --- */
  .home-scroll .cp-tabs { gap: 28px; }
  .home-scroll .cp-tabs button { font-size: 14px; padding: 8px 2px; }
  .home-scroll .cp-tabs button:hover { color: var(--p-ink); }

  /* --- 单图 / 视频：别让一张图撑满整屏 --- */
  .home-scroll .cp-imgwrap img { max-height: 620px; }
  .home-scroll .cp-video video { max-height: 620px; }

  /* --- 门店 / 客服：宽屏下拉满 1080 会显得空，收窄居中更像桌面站点 --- */
  .home-scroll .cp-store,
  .home-scroll .cp-contact { max-width: 860px; margin-inline: auto; }
  /* 门店信息重排：地址整行，电话与营业并排，别让右半边空着 */
  .home-scroll .cp-store {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 28px;
    padding: 24px 28px;
    border-radius: 16px;
  }
  .home-scroll .cp-store h5 { grid-column: 1 / -1; font-size: 17px; margin: 0 0 6px; }
  .home-scroll .cp-store p { font-size: 13.5px; margin: 0; }
  .home-scroll .cp-store p:nth-child(2) { grid-column: 1 / -1; }
  .home-scroll .cp-store p b { min-width: 36px; font-size: 11.5px; }
  .home-scroll .cp-contact { padding: 22px 28px; gap: 20px; border-radius: 16px; justify-content: center; }
  .home-scroll .cp-contact .qr { width: 88px; height: 88px; flex: 0 0 88px; }
  .home-scroll .cp-contact .tx { font-size: 14px; max-width: 320px; }

  /* --- 暗色主题：白底产品图必须有浅底板，宽屏横幅就是一大块浅色，
         给点投影让它像一幅挂画，而不是一块贴上去的白板 --- */
  [data-theme="ink"] .home-scroll .cp-banner {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 16px 44px rgba(0, 0, 0, 0.42);
  }
}

@media (min-width: 1500px) {
  .home { --home-w: 1200px; }
}

@media (min-width: 1900px) {
  .home { --home-w: 1320px; }
}

/* 窄屏一律不出翻页箭头：不依赖 hover/pointer 媒体特性的判断，
   避免某些 WebView 把它误报成鼠标设备、在手机上冒出两个按钮。 */
@media (max-width: 999px) {
  .home-scroll .cp-banner .bn-arrow { display: none !important; }
  .dm-arrow { display: none !important; }
}

