/* ==========================================================================
   app.css — 基础样式 / 通用组件 / 页面布局
   全部取值引用 theme.css 的令牌，不写死颜色与尺寸
   ========================================================================== */

/* ---------------------------------------------------------------- 1. 基础 */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
select { font: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* #main 是路由切换后的程序化焦点目标（tabindex="-1"）：
   它本身不是可操作元素，聚焦时不画轮廓，否则整页会多出一圈描边。
   键盘用户仍可通过顶部「跳到主要内容」链接到达并继续 Tab。 */
.app-main:focus,
.app-main:focus-visible { outline: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 99;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: var(--sp-2); top: var(--sp-2); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------ 2. 应用外壳 */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--page-max);
  margin: 0 auto;
  background: var(--bg-page);
}

@media (min-width: 700px) {
  .app-shell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.app-main { flex: 1; }

/* 移动端固定的底部导航 / 购买栏会盖住内容：由外壳统一预留安全区，
   PC 端 --tabbar-h 归零，这里自动失效 */
.app-shell { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
body.is-detail .app-shell { padding-bottom: calc(60px + var(--safe-b)); }

/* 页脚（版权 / 客服 / 备案信息，移动端紧凑显示）
   备案信息单独占一行，便于备案核查时一眼看到 */
.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: center;
}
.app-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.app-footer__row--legal { gap: var(--sp-3); }
.app-footer__dot {
  flex: 0 0 auto;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
}
/* 备案号：可点击跳转官方备案系统（法规要求），沿用页脚弱化配色 */
.app-footer__beian {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
.app-footer__beian:hover { color: var(--brand); text-decoration: underline; }
.app-footer__police { width: 14px; height: 14px; flex: 0 0 auto; }
body.is-detail .app-tabbar { display: none; }

/* 顶部栏 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--header-h);
  padding: 0 var(--sp-3);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.app-header--brand {
  background: var(--brand);
  border-bottom-color: transparent;
  color: var(--brand-contrast);
}

.app-header__title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1;
}

/* 品牌区与横向导航：仅 PC 端显示，移动端由底部导航承担 */
.app-header__brand {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
}
.app-header__logo {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: var(--fs-base);
  font-weight: 600;
}
.app-header__brandname { white-space: nowrap; }
/* 品牌色顶栏上，logo 块换成半透明白底，避免红底红块糊在一起 */
.app-header--brand .app-header__logo {
  background: rgba(255, 255, 255, .24);
  color: var(--brand-contrast);
}

.app-nav { display: none; align-items: center; gap: var(--sp-1); }
.app-nav__item {
  padding: 6px var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-base);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.app-nav__item:hover { background: var(--bg-muted); color: var(--text-1); }
.app-nav__item[aria-current="page"] {
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 500;
}
.app-header__spacer { flex: 1; }

.app-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  margin-left: calc(var(--sp-2) * -1);
  border-radius: var(--radius-full, var(--radius-pill));
}
.app-header__search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .22);
  color: inherit;
  font-size: var(--fs-md);
  text-align: left;
}
.app-header--plain .app-header__search {
  background: var(--bg-muted);
  color: var(--text-3);
}
.app-header__search::before {
  content: "";
  width: 14px; height: 14px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: 5px 5px 0 -3.5px currentColor;
  opacity: .75;
}

/* 底部导航 */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  width: 100%;
  max-width: var(--page-max);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.app-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.app-tabbar__item[aria-current="page"] { color: var(--brand); }
.app-tabbar__item svg { width: 20px; height: 20px; }

/* -------------------------------------------------------- 3. 通用：区块 */
.section { margin-top: var(--sp-3); background: var(--bg-card); }
.section--gap { margin-top: var(--sp-3); }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.section__title {
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: var(--lh-tight);
}
.section__title::before {
  content: "";
  display: inline-block;
  width: 3px; height: 14px;
  margin-right: var(--sp-2);
  vertical-align: -1px;
  border-radius: 2px;
  background: var(--brand);
}
.section__more { font-size: var(--fs-md); color: var(--text-3); }

.panel {
  margin-top: var(--sp-3);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg-card);
}

/* -------------------------------------------------------- 4. 通用：价格 */
.price { display: inline-flex; align-items: baseline; color: var(--price); font-weight: 500; }
.price__sym { font-size: var(--fs-sm); }
.price__num { font-size: var(--fs-lg); line-height: 1; letter-spacing: -.02em; }
.price--lg .price__sym { font-size: var(--fs-lg); }
.price--lg .price__num { font-size: var(--fs-2xl); }
.price__was {
  margin-left: var(--sp-2);
  font-size: var(--fs-md);
  font-weight: 400;
  color: var(--text-4);
  text-decoration: line-through;
}
.price__unit { margin-left: var(--sp-2); font-size: var(--fs-sm); font-weight: 400; color: var(--text-3); }

.tag {
  display: inline-block;
  padding: 1px var(--sp-2);
  border: 1px solid var(--brand-soft);
  border-radius: var(--radius-xs);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: var(--fs-xs);
  line-height: 1.6;
}
.tag--muted { border-color: var(--border-strong); background: var(--bg-muted); color: var(--text-2); }

/* -------------------------------------------------------- 5. 通用：控件 */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 6px var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: var(--fs-md);
  color: var(--text-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.chip[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 500;
}
.chip__price { font-size: var(--fs-sm); color: var(--text-3); }
.chip[aria-pressed="true"] .chip__price { color: var(--brand-dark); }
/* 该商品对某渠道设了专属运费时的小标记 */
.chip__tag {
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: 10px;
  line-height: 16px;
}
.chip[aria-pressed="true"] .chip__tag { background: var(--brand); color: #fff; }
.chip[disabled] { opacity: .45; cursor: not-allowed; }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stepper__btn {
  width: 34px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  color: var(--text-2);
  background: var(--bg-muted);
}
.stepper__btn:disabled { color: var(--text-4); cursor: not-allowed; }
.stepper__input {
  width: 48px; height: 32px;
  border: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-size: var(--fs-base);
  color: var(--text-1);
  background: var(--bg-card);
  -moz-appearance: textfield;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.select {
  height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  font-size: var(--fs-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-4);
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn--brand { background: var(--brand); color: var(--brand-contrast); }
.btn--brand:active { background: var(--brand-dark); }
.btn--ghost { border: 1px solid var(--border-strong); color: var(--text-2); background: var(--bg-card); }

/* -------------------------------------------------------- 6. 商品卡片 */
.goods-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-3);
}
@media (min-width: 560px) {
  .goods-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.goods-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  text-align: left;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
@media (hover: hover) {
  .goods-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
}
.goods-card:active { transform: scale(.985); }

.goods-card__thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-muted);
}
.goods-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.goods-card__badge {
  position: absolute;
  top: 0; left: 0;
  padding: 2px var(--sp-2);
  border-bottom-right-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: var(--fs-xs);
  line-height: 1.7;
}
.goods-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}
.goods-card__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.4em * 2);
  font-size: var(--fs-md);
  line-height: 1.4;
  color: var(--text-1);
}
.goods-card__point {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.goods-card__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}
.goods-card__ship { font-size: var(--fs-xs); color: var(--text-3); }

/* -------------------------------------------------------- 7. 骨架 / 空态 */
.skeleton { background: var(--bg-muted); border-radius: var(--radius-sm); }
.skeleton--thumb { aspect-ratio: 1 / 1; border-radius: 0; }
.skeleton--line { height: 12px; margin: var(--sp-2) 0; }
.skeleton--line.is-short { width: 60%; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-md);
}
.empty__mark {
  width: 56px; height: 56px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xl);
  color: var(--text-4);
}

/* --------------------------------------------------- 8. 首页：轮播 / 宫格 */
.banner {
  position: relative;
  overflow: hidden;
  background: var(--bg-muted);
}
.banner__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.banner__track::-webkit-scrollbar { display: none; }
.banner__slide {
  flex: 0 0 100%;
  height: clamp(140px, 42vw, 220px);
  scroll-snap-align: center;
}
.banner__slide { position: relative; }
.banner__slide img { width: 100%; height: 100%; object-fit: cover; }

.banner__caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: var(--sp-6) var(--sp-4) var(--sp-5);
  background: linear-gradient(to top, rgba(0, 0, 0, .46), rgba(0, 0, 0, 0));
  color: #fff;
  pointer-events: none;
}
.banner__caption strong { display: block; font-size: var(--fs-lg); font-weight: 500; line-height: 1.4; }
.banner__caption span { font-size: var(--fs-sm); opacity: .88; }

.banner__dots {
  position: absolute;
  left: 0; right: 0; bottom: var(--sp-3);
  display: flex;
  justify-content: center;
  gap: 5px;
}
.banner__dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .6);
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease);
}
.banner__dot[aria-current="true"] { width: 16px; background: #fff; }

.quicknav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-card);
}
.quicknav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-md);
  color: var(--text-2);
}
.quicknav__mark {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: var(--fs-base);
  font-weight: 500;
}

.notice {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: var(--fs-md);
}
.notice__label {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: var(--fs-xs);
  line-height: 1.8;
}
.notice__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------- 9. 列表页：筛选 */
.catebar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.catebar::-webkit-scrollbar { display: none; }
.catebar__item {
  flex: 0 0 auto;
  padding: 5px var(--sp-3);
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  font-size: var(--fs-md);
  color: var(--text-2);
  white-space: nowrap;
}
.catebar__item[aria-current="true"] {
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 500;
}

.sortbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card);
  font-size: var(--fs-md);
  color: var(--text-2);
}
.sortbar__item { position: relative; padding: 2px 0; }
.sortbar__item[aria-pressed="true"] { color: var(--brand); font-weight: 500; }
.sortbar__count { margin-left: auto; color: var(--text-3); font-size: var(--fs-sm); }

/* ------------------------------------------------------- 10. 详情页：图集 */
.gallery { position: relative; background: var(--bg-card); }
.gallery__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.gallery__track::-webkit-scrollbar { display: none; }
.gallery__slide {
  flex: 0 0 100%;
  height: clamp(240px, 60vw, 360px);
  scroll-snap-align: center;
  background: var(--bg-muted);
}
.gallery__slide img { width: 100%; height: 100%; object-fit: cover; }
.gallery__counter {
  position: absolute;
  right: var(--sp-3);
  bottom: var(--sp-3);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.gallery__dots {
  position: absolute;
  left: 0; right: 0; bottom: var(--sp-3);
  display: flex;
  justify-content: center;
  gap: 5px;
}
.gallery__dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .55);
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease);
}
.gallery__dot[aria-current="true"] { width: 14px; background: #fff; }

/* --------------------------------------------------- 11. 详情页：信息区 */
/* 商品视频：管理端上传过才出现，位置在主图下方 */
.goods-video {
  margin-top: var(--sp-3);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.goods-video__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) 0;
}
.goods-video__title { font-size: var(--fs-md); font-weight: 500; color: var(--text-1); }
.goods-video__name {
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.goods-video__player {
  display: block;
  width: 100%;
  max-height: 62vh;
  margin-top: var(--sp-2);
  background: #000;
}

.pricebox {
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-card);
}
.pricebox__row { display: flex; align-items: flex-end; flex-wrap: wrap; }
.pricebox__title {
  margin-top: var(--sp-3);
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1.45;
}
.pricebox__point {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: var(--fs-md);
  line-height: 1.5;
}

.field {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.field:last-child { border-bottom: 0; }
.field__label {
  flex: 0 0 60px;
  padding-top: 6px;
  font-size: var(--fs-md);
  color: var(--text-3);
}
.field__body { flex: 1; min-width: 0; }
.field__hint { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); }

.cost { padding: var(--sp-2) 0; background: var(--bg-card); }
.cost__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  font-size: var(--fs-md);
  color: var(--text-2);
}
.cost__row span:last-child { font-variant-numeric: tabular-nums; color: var(--text-1); }
.cost__row--total {
  margin-top: var(--sp-1);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border-strong);
  font-size: var(--fs-base);
  color: var(--text-1);
}
.cost__row--total span:last-child { color: var(--price); font-weight: 500; font-size: var(--fs-lg); }
.cost__note { padding: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); }

.detail-content {
  padding: var(--sp-4) var(--sp-3) var(--sp-5);
  color: var(--text-2);
  font-size: var(--fs-base);
  line-height: 1.9;
}
.detail-content p + p { margin-top: var(--sp-3); }
.detail-content h3 {
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-1);
}
.detail-content img { margin: var(--sp-3) 0; border-radius: var(--radius-sm); }
.detail-content table { width: 100%; border-collapse: collapse; margin: var(--sp-3) 0; font-size: var(--fs-md); }
.detail-content th, .detail-content td {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  text-align: left;
}
.detail-content th { background: var(--bg-muted); font-weight: 500; color: var(--text-1); }

/* --------------------------------------------------- 12. 详情页：操作栏 */
.actionbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 31;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  max-width: var(--page-max);
  padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + var(--safe-b));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.actionbar__ghost {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  padding: 0 var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.actionbar__ghost svg { width: 18px; height: 18px; }
.actionbar__cta {
  flex: 1;
  height: 42px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: var(--fs-lg);
  font-weight: 500;
}
.actionbar__cta:active { background: var(--brand-dark); }
.actionbar__cta[disabled] { opacity: .5; }

/* --------------------------------------------------- 13. 浮层：提示/回顶 */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--sp-5));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(80vw, 380px);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  background: rgba(20, 20, 20, .88);
  color: #fff;
  font-size: var(--fs-md);
  text-align: center;
  animation: toast-in var(--dur) var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.backtop {
  position: fixed;
  right: max(var(--sp-4), calc(50% - var(--page-max) / 2 + var(--sp-4)));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--sp-5));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-2);
  box-shadow: var(--shadow-card);
}
body.is-detail .backtop { bottom: calc(60px + var(--safe-b) + var(--sp-5)); }

/* --------------------------------------------------------- 14. 动效降级 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   15. 响应式适配：PC（≥900px）与宽屏（≥1200px）
   —— 上面全部是手机端基础样式；本节只做「增强」，不改手机端表现。
   —— 断点策略：手机 <700 单列 · 平板 700~899 容器放宽 · PC ≥900 顶部导航
                宽屏 ≥1200 商品 5 列、详情页图集更大
   ========================================================================== */

@media (min-width: 900px) {

  /* ---- 15.1 顶栏：品牌 + 横向导航 + 搜索，一个视觉行 ---- */
  .app-header { gap: var(--sp-4); padding: 0 var(--sp-4); }
  .app-header__brand { display: inline-flex; }
  .app-nav { display: flex; }

  /* 移动端的标题与返回箭头由导航替代 */
  .app-header__title,
  .app-header__back { display: none; }

  .app-header__search { flex: 0 1 300px; margin-left: auto; }

  /* 底部导航在 PC 端隐藏（--tabbar-h 已在 theme.css 归零） */
  .app-tabbar { display: none; }

  /* ---- 15.2 容器：左右留白 + 卡片化圆角 ---- */
  .app-shell {
    padding: 0 var(--sp-4) var(--sp-5);
    border-left: 0;
    border-right: 0;
  }
  body.is-detail .app-shell { padding-bottom: var(--sp-5); }

  .notice,
  .banner,
  .quicknav,
  .section,
  .panel,
  .gallery,
  .pricebox { border-radius: var(--radius-md); }

  /* ---- 15.3 首页：轮播与分类宫格左右并排 ---- */
  .home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
  }
  .home-hero .banner__slide { height: clamp(240px, 24vw, 340px); }
  .home-hero .quicknav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
    padding: var(--sp-4);
  }

  /* 只配置了分类、还没有轮播图时：宫格铺满整行，避免右侧空出一列
     （提高一级特异性，确保不被 1200px 断点的 .home-hero 规则覆盖） */
  .home-hero.home-hero--plain { grid-template-columns: minmax(0, 1fr); }
  .home-hero.home-hero--plain .quicknav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: var(--sp-4) var(--sp-5);
  }

  /* ---- 15.4 商品网格：PC 4 列 ---- */
  .goods-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-4);
    padding: var(--sp-4);
  }

  /* ---- 15.5 详情页：图集与购买信息左右分栏 ---- */
  .detail-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr);
    gap: var(--sp-3);
    align-items: start;
    margin-top: var(--sp-3);
  }
  .detail-info { display: grid; gap: var(--sp-3); }
  .detail-wrap .pricebox,
  .detail-wrap .panel { margin-top: 0; }
  .detail-wrap .gallery__slide { height: clamp(320px, 34vw, 520px); }

  /* 购买栏：PC 端从「固定底部」改为跟在信息栏之后的卡片 */
  .actionbar {
    position: sticky;
    bottom: var(--sp-4);
    left: auto;
    transform: none;
    width: auto;
    max-width: none;
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
  }
  .actionbar__cta { flex: 1 1 auto; }

  /* ---- 15.6 图文详情：PC 端限制阅读宽度 ---- */
  .detail-content { max-width: 900px; margin: 0 auto; }

  /* ---- 15.7 浮层位置随之调整 ---- */
  .toast { bottom: var(--sp-6); }
  .backtop { bottom: var(--sp-6); }
  body.is-detail .backtop { bottom: var(--sp-6); }
}

@media (min-width: 1200px) {
  .goods-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .home-hero { grid-template-columns: minmax(0, 1fr) 360px; }
  .detail-wrap { grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
  .detail-wrap .gallery__slide { height: clamp(360px, 32vw, 560px); }
}

/* 高分辨率 PC：卡片阴影更清晰 */
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
  .goods-card:hover { box-shadow: var(--shadow-card); }
}

/* ===================================================== 16. 下单与订单 */

/* ---- 16.1 补充按钮态（.btn 基础样式见第 5 节） ---- */
.btn { border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--brand:disabled { background: var(--brand); }
.btn--sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-md); flex: 0 0 auto; }

/* ---- 16.2 表单控件 ---- */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: var(--sp-3);
}
.form-row__label { font-size: var(--fs-md); color: var(--text-2); }
.form-row__err { min-height: 1.1em; font-size: var(--fs-sm); color: var(--danger); }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}
.input::placeholder { color: var(--text-4); }
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.input.invalid { border-color: var(--danger); }
.input--area { resize: vertical; min-height: 58px; }

/* 移动端表单字号不小于 16px，避免 iOS 聚焦时自动放大页面 */
@media (max-width: 699px) {
  .input, .select { font-size: 16px; }
}

/* ---- 16.3 下单弹窗 ---- */
.dlg {
  width: min(520px, calc(100vw - 2 * var(--sp-4)));
  max-width: 100%;
  max-height: min(88vh, 780px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.dlg:not([open]) { display: none; }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }

.dlg__form { display: flex; flex-direction: column; max-height: min(88vh, 780px); }
.dlg__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex: 0 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.dlg__title { font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; }
.dlg__close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.dlg__close:hover { background: var(--bg-sunken); color: var(--text-1); }
.dlg__body {
  flex: 1 1 auto;
  padding: var(--sp-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dlg__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  flex: 0 0 auto;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}

.cost__head {
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-1);
  border-bottom: 1px dashed var(--border);
  font-size: var(--fs-md);
  color: var(--text-2);
}

/* ---- 16.4 订单卡片 ---- */
.order-card {
  margin-bottom: var(--sp-3);
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-card);
}
.order-card:last-child { margin-bottom: 0; }
.order-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.order-card__no {
  font-size: var(--fs-md);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.order-card__body { display: flex; align-items: center; gap: var(--sp-3); }
.order-card__thumb {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.order-card__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.order-card__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-base);
  color: var(--text-1);
}
.order-card__meta { font-size: var(--fs-sm); color: var(--text-3); }
.order-card__amount {
  flex: 0 0 auto;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--price);
  font-variant-numeric: tabular-nums;
}
.order-card__foot {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.order-card__addr {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态标签：配色全部走主题令牌，亮/暗主题下都保持可读 */
.status {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: 1.7;
  white-space: nowrap;
}
.status--warn { background: var(--brand-tint); color: var(--brand); }
.status--ok { color: var(--success); }
.status--muted { color: var(--text-4); }

/* ---- 16.5 我的：账户头 + 功能行 ---- */
.mine-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-card);
}
.mine-head__avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: var(--fs-lg);
  font-weight: 600;
}
.mine-head__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mine-head__info strong { font-size: var(--fs-lg); font-weight: 600; }
.mine-head__info span { font-size: var(--fs-sm); color: var(--text-3); }

.linkrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-base);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.linkrow:last-child { border-bottom: 0; }
.linkrow__label { color: var(--text-1); }
.linkrow__hint { font-size: var(--fs-md); color: var(--text-3); }

.app-footer__link { color: inherit; text-decoration: none; }
.app-footer__link:hover { color: var(--brand); }

/* ---- 16.6 PC 端收尾 ---- */
@media (min-width: 900px) {
  .dlg { width: min(560px, calc(100vw - 2 * var(--sp-6))); }
  .mine-head { padding: var(--sp-5) var(--sp-4); }
  .order-card { padding: var(--sp-4); }
  .linkrow:hover .linkrow__label { color: var(--brand); }
}
