/* 前台样式表
 * 设计规范：
 * 1. 只有中性色阶，不用渐变、发光、阴影；强调靠明暗对比（深底按钮 / 主文字加深）。
 * 2. 间距与圆角只用固定档位变量，组内紧凑、组间留白。
 * 3. 同类元素共用同一条左基线（.container 内边距即全局左侧起点）。
 * 4. 不加装饰；图标统一为 24 网格、1.5 描边的线性图标（app.js 里的 i-* 符号）。
 */

:root {
  /* 中性色阶 */
  --ink: #17191c;        /* 主文字、主按钮底色 */
  --ink-2: #565c63;      /* 次级文字 */
  --ink-3: #8a9097;      /* 弱化文字、占位 */
  --line: #e4e6e8;       /* 分隔线、边框 */
  --line-strong: #cfd3d6;
  --surface: #ffffff;    /* 卡片、输入框底色 */
  --surface-2: #f6f7f8;  /* 轻底色：图片位、提示块 */
  --bg: #fbfbfc;         /* 页面底色 */
  --danger: #a4271e;     /* 仅用于错误提示 */
  --success: #1f7a45;    /* 仅用于状态文字 */

  /* 间距档位 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* 圆角档位 */
  --r1: 4px;
  --r2: 8px;
  --r3: 12px;

  /* 兼容旧变量名（个人中心、支付页等仍在引用） */
  --primary: #17191c;
  --primary-dark: #000000;
  --primary-soft: #f1f2f3;
  --text: #17191c;
  --text-2: #565c63;
  --text-3: #8a9097;
  --white: #ffffff;
  --warn: #565c63;
  --radius: 8px;
  --shadow: none;
}

* { box-sizing: border-box; }

/* 防止任何元素把页面撑得比屏幕宽：正常情况下不需要横向滚动 */
html, body { max-width: 100%; }
body { overflow-x: clip; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
table { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
pre, code { overflow-wrap: anywhere; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.container {
  width: 100%; max-width: 1120px; margin: 0 auto;
  /* 刘海屏横屏时左右也有安全区，取两者较大值 */
  padding-left: max(var(--s5), env(safe-area-inset-left, 0px));
  padding-right: max(var(--s5), env(safe-area-inset-right, 0px));
}

/* ---------- 图标 ---------- */
.ic {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 28px; height: 28px; }

.num { font-variant-numeric: tabular-nums; }

/* ---------- 顶部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* 全屏铺满时避让顶部刘海 */
  padding-top: env(safe-area-inset-top, 0px);
}
.header-inner { display: flex; align-items: center; gap: var(--s5); height: 56px; min-width: 0; }

.logo { display: flex; align-items: center; gap: var(--s2); font-size: 15px; font-weight: 600; white-space: nowrap; flex: 0 1 auto; min-width: 0; }
.logo-mark { flex: none; }
.logo-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-mark {
  width: 26px; height: 26px; border-radius: var(--r1);
  background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}

.search-form {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: var(--s2);
  max-width: 440px; height: 36px; padding: 0 var(--s1) 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface); color: var(--ink-3);
  transition: border-color .18s ease-out;
}
.search-form:focus-within { border-color: var(--ink-3); }
.search-form input {
  /* width:100% 覆盖输入框自带的 20 字符固有宽度（约 334px），
     min-width:0 允许它在窄屏里继续压缩，否则会把整页撑宽 */
  flex: 1 1 0; width: 100%; min-width: 0; height: 34px;
  border: 0; background: none; outline: none;
  color: var(--ink);
}
.search-form input::placeholder { color: var(--ink-3); }
.search-form input::-webkit-search-cancel-button { display: none; }

.header-actions { display: flex; align-items: center; gap: var(--s4); margin-left: auto; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  /* 显式锁死宽度：left/right 定位在某些手机上会跟着页面溢出宽度一起被拉宽，
     max-width:100vw 保证永远不超过屏幕宽 */
  width: 100%;
  max-width: 100vw;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabbar-inner { display: flex; width: 100%; max-width: 640px; margin: 0 auto; overflow: hidden; }
.tab-item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 54px;
  padding: 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.2;
  transition: color .18s ease-out, transform .1s ease-out;
}
.tab-item .ic { width: 22px; height: 22px; }
.tab-item:active { transform: scale(.96); }
.tab-item.active { color: var(--ink); font-weight: 500; }
.tab-item span {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 购物车件数：只在有商品时出现的角标，不做彩色胶囊 */
.tabbar .cart-badge {
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: 4px;
  padding: 0 2px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 10px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.tabbar .cart-badge::before,
.tabbar .cart-badge::after { content: none; }
.cart-badge[data-count="0"] { display: none; }

/* 底部导航是 fixed，正文要留出等高的空间，避免被挡住 */
body { padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 40px; padding: 0 var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--r2);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: transform .1s ease-out, background-color .18s ease-out, border-color .18s ease-out, color .18s ease-out;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.btn-sm { height: 28px; padding: 0 var(--s3); font-size: 13px; border-radius: var(--r1); }
.btn-block { width: 100%; }
.btn-link {
  height: auto; padding: 0; border: 0; background: none;
  color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--ink-2); }

/* 图标按钮：只有图标时用它，命中区 32px */
.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r2);
  background: none; color: var(--ink-3);
  transition: color .18s ease-out, border-color .18s ease-out, transform .1s ease-out;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line); }
.icon-btn:active { transform: scale(.94); }

/* ---------- 页面标题区（替代原渐变横幅） ---------- */
.page-head { padding: var(--s6) 0 var(--s5); }
.page-head h1 { font-size: 22px; line-height: 1.35; letter-spacing: -.01em; }
.page-head p { margin-top: var(--s2); color: var(--ink-3); font-size: 13px; }
.page-head .head-notes {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3);
  margin-top: var(--s3); color: var(--ink-3); font-size: 12px;
}
.page-head .head-notes span + span::before { content: "·"; margin-right: var(--s3); color: var(--line-strong); }

.page-title { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s5) 0 var(--s4); }
.page-title h1, .page-title h2 { font-size: 18px; }
.page-title .count { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- 分类 / 排序 ---------- */
.tab-row {
  display: flex; gap: var(--s5); overflow-x: auto;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.tab-row::-webkit-scrollbar { display: none; }
.tab-row .tab {
  flex: 0 0 auto; padding: var(--s3) 0;
  border: 0; border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-3); font-size: 13px; white-space: nowrap;
  cursor: pointer;
  transition: color .18s ease-out, border-color .18s ease-out;
}
.tab-row .tab:hover { color: var(--ink-2); }
.tab-row .tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tab-row .tab .n { margin-left: var(--s1); color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

.toolbar {
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s3) 0; border-bottom: 1px solid var(--line);
}
.toolbar .result { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.sort-group { display: flex; gap: var(--s4); margin-left: auto; }
.sort-group button {
  padding: 0; border: 0; background: none;
  color: var(--ink-3); font-size: 12px;
  transition: color .18s ease-out;
}
.sort-group button:hover { color: var(--ink-2); }
.sort-group button.active { color: var(--ink); font-weight: 500; }

/* ---------- 商品网格 ---------- */
.grid {
  display: grid;
  /* min(...) 兜底：容器比最小列宽还窄时也只占一列，不会把页面撑宽 */
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
  gap: var(--s5) var(--s4); padding: var(--s5) 0 var(--s6);
}
.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface); overflow: hidden;
  transition: border-color .18s ease-out;
}
.card:hover { border-color: var(--line-strong); }
.card .thumb { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.thumb { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--ink-3); }
.card-body { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3); flex: 1; }
.card-title {
  font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub {
  color: var(--ink-3); font-size: 12px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.price-row { display: flex; align-items: baseline; gap: var(--s2); margin-top: auto; padding-top: var(--s2); }
.price { color: var(--ink); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.price::before { content: "¥"; font-size: 11px; font-weight: 500; margin-right: 1px; }
.price-old { color: var(--ink-3); font-size: 12px; text-decoration: line-through; font-variant-numeric: tabular-nums; }
.price-old::before { content: "¥"; }
.price-lg { font-size: 22px; }
.price-lg::before { font-size: 13px; }
.stock-tip { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 空态 / 分页 ---------- */
.empty { padding: var(--s7) var(--s4); text-align: center; color: var(--ink-3); font-size: 13px; }
.empty .ic { margin: 0 auto var(--s3); color: var(--line-strong); }
.empty .empty-actions { display: flex; justify-content: center; gap: var(--s2); margin-top: var(--s4); }

.pager {
  display: flex; gap: var(--s1); justify-content: center; align-items: center;
  padding: var(--s5) 0 var(--s6); flex-wrap: wrap;
}
.pager button {
  min-width: 32px; height: 32px; padding: 0 var(--s2);
  border: 1px solid var(--line); border-radius: var(--r1);
  background: var(--surface); color: var(--ink-2); font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: border-color .18s ease-out, background-color .18s ease-out, color .18s ease-out;
}
.pager button:hover { border-color: var(--line-strong); }
.pager button.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .info { color: var(--ink-3); margin-left: var(--s2); font-size: 12px; }

/* ---------- 面包屑 ---------- */
.crumb { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) 0; color: var(--ink-3); font-size: 12px; }
.crumb a { color: var(--ink-3); }
.crumb a:hover { color: var(--ink); }
.crumb .ic { width: 12px; height: 12px; color: var(--line-strong); }

/* ---------- 详情页 ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s6); padding-bottom: var(--s6); }
.gallery-main {
  aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface-2); overflow: hidden; display: grid; place-items: center;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.gallery-thumbs button {
  width: 56px; height: 56px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface-2);
  transition: border-color .18s ease-out;
}
.gallery-thumbs button.active { border-color: var(--ink); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

.detail-info { min-width: 0; }
.detail-info h1 { font-size: 20px; line-height: 1.4; margin-bottom: var(--s1); }
.detail-sub { color: var(--ink-3); font-size: 13px; }
.detail-sub:empty { display: none; }
.desc-block { white-space: pre-wrap; color: var(--ink-2); font-size: 13px; line-height: 1.8; }

.buy-block { padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.buy-block .price { font-size: 26px; font-weight: 600; }
.buy-block .price::before { font-size: 14px; }
.buy-block .price-old { font-size: 13px; margin-left: var(--s2); }
.buy-block .sales { margin-top: var(--s1); color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* 定义列表：标签定宽，值共用同一条左基线 */
.meta-list { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.meta-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s3); padding: var(--s1) 0; font-size: 13px; }
.meta-row .k { color: var(--ink-3); }
.meta-row .v { color: var(--ink); }

.qty-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) 0; }
.qty-row .k { color: var(--ink-3); font-size: 13px; }
.qty-box {
  display: inline-flex; align-items: center; height: 36px;
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface); overflow: hidden;
}
.qty-box button {
  width: 36px; height: 34px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink);
  transition: background-color .14s ease-out, transform .1s ease-out;
}
.qty-box button:hover { background: var(--surface-2); }
.qty-box button:active { transform: scale(.92); }
.qty-box button:disabled { color: var(--line-strong); cursor: not-allowed; }
.qty-box input, .qty-box .qty {
  width: 44px; height: 34px; padding: 0; border: 0; background: none;
  text-align: center; font-size: 13px; font-variant-numeric: tabular-nums;
  outline: none; -moz-appearance: textfield;
}
.qty-box input::-webkit-outer-spin-button,
.qty-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.buy-row { display: flex; gap: var(--s2); margin: var(--s4) 0; flex-wrap: wrap; }
.buy-row .btn { flex: 1 1 150px; }

/* ---------- 面板 / 表格 / 列表 ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); overflow: hidden; }
.panel + .panel { margin-top: var(--s4); }
.panel-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 500;
}
.panel-body { padding: var(--s4); }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); border-top: 1px solid var(--line);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--s3) var(--s2); text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* 商品清单行：缩略图、标题、单价、数量、小计共用同一条左基线 */
.line-list { display: flex; flex-direction: column; }
.line-item { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: 0; }
.line-item .thumb, .line-item .thumb-sm { width: 64px; height: 64px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r2); }
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.line-title { font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-title:hover { color: var(--ink-2); }
.line-meta { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.line-actions { display: flex; align-items: center; gap: var(--s3); flex: 0 0 auto; }
.line-total { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 兼容旧标记 */
.cart-item { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.cart-item:last-child { border-bottom: 0; }
.cart-thumb { width: 64px; height: 64px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); overflow: hidden; }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-main { flex: 1; min-width: 0; }
.cart-line-total { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.summary {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s3);
  padding: var(--s3) var(--s4); border-top: 1px solid var(--line); flex-wrap: wrap;
}
.summary .total { font-size: 13px; color: var(--ink-3); }
.summary .amount { color: var(--ink); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* 结算：宽屏两栏，窄屏堆叠 */
.checkout-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
/* 两栏里左右面板是并排的，不能再吃到相邻面板的上外边距 */
.checkout-grid > .panel + .panel { margin-top: 0; }

/* 下单完成 */
.done-body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s6) var(--s5); }
.done-mark { color: var(--ink); }
.done-mark .ic { width: 30px; height: 30px; }
.done-mark.is-alert { color: var(--danger); }
.done-title { font-size: 18px; }
.done-title.is-alert { color: var(--danger); }
.done-meta { width: 100%; max-width: 420px; border-bottom: 0; padding: var(--s1) 0; }
.done-hint { color: var(--ink-3); font-size: 13px; max-width: 44em; }
.done-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s3); }

/* 支付方式：整行按钮，文字左对齐，不做选中色块 */
.pay-ways { display: flex; flex-direction: column; gap: var(--s2); }
.pay-way {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  width: 100%; height: 52px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface); color: var(--ink);
  text-align: left; font-size: 14px;
  transition: border-color .18s ease-out, transform .1s ease-out;
}
.pay-way:hover { border-color: var(--line-strong); }
.pay-way:active { transform: scale(.995); }
.pay-way:disabled { opacity: .5; cursor: not-allowed; }
.pay-way .ic { color: var(--ink-3); }

/* 二维码：白底细边框，不加阴影与光晕 */
.qr-box { display: inline-block; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: #fff; }
.qr-box img, .qr-box canvas { display: block; }
.qr-stage { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }


/* ---------- 表单 ---------- */
.field { margin-bottom: var(--s3); min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: var(--s1); color: var(--ink-2); font-size: 12px; font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; height: 40px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface); color: var(--ink); outline: none;
  transition: border-color .18s ease-out;
}
.field textarea { height: auto; min-height: 88px; padding: var(--s2) var(--s3); resize: vertical; line-height: 1.6; }
.field-check { display: flex; align-items: center; gap: var(--s2); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.field-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.form-note { color: var(--ink-3); font-size: 12px; line-height: 1.6; margin-top: var(--s2); }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--ink-3); }
.field .hint { margin-top: var(--s1); color: var(--ink-3); font-size: 12px; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.form-narrow { max-width: 420px; }
.form-sep { border-top: 1px solid var(--line); margin: var(--s4) 0; padding-top: var(--s3); }

/* 登录 / 注册 */
.auth-wrap { max-width: 400px; margin: var(--s7) auto; padding: 0 var(--s5); }
.auth-card { border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); padding: var(--s5); }
.auth-tabs { display: flex; gap: var(--s4); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }
.auth-tabs button {
  padding: var(--s2) 0; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--ink-3); font-size: 14px;
  transition: color .18s ease-out, border-color .18s ease-out;
}
.auth-tabs button.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }

/* ---------- 提示块 ---------- */
.notice {
  padding: var(--s3); border-radius: var(--r2);
  background: var(--surface-2); color: var(--ink-2);
  font-size: 13px; line-height: 1.6;
  margin-bottom: var(--s4);
}
.notice-soft { background: var(--surface-2); color: var(--ink-2); }
.notice .ic { display: inline-block; vertical-align: -3px; margin-right: var(--s1); }

/* ---------- 状态文字（不用彩色胶囊） ---------- */
.badge { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.badge-pending_payment { color: var(--ink); }
.badge-paid { color: var(--ink); }
.badge-shipped { color: var(--ink-2); }
.badge-completed { color: var(--success); }
.badge-cancelled { color: var(--ink-3); }
.badge-on { color: var(--success); }
.badge-off { color: var(--ink-3); }

/* ---------- 订单 ---------- */
.order-card { border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); margin-bottom: var(--s3); overflow: hidden; }
.order-head {
  display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
  color: var(--ink-3); font-size: 12px;
}
.order-head .no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); font-weight: 500; font-size: 12px; }
.order-head .right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.order-head .state-text { color: var(--ink); font-size: 13px; font-weight: 500; }

/* ---------- 订单进度 ---------- */
.order-state { padding: var(--s3) var(--s4) 0; }
.order-state .state-hint { margin-top: var(--s2); color: var(--ink-3); font-size: 12px; line-height: 1.6; }

.steps { display: flex; margin: var(--s3) 0 0; padding: 0; list-style: none; }
.steps .step {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.4;
}
.steps .step .dot {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}
/* 连接线：每步左右各半段，首尾隐藏 */
.steps .step::before,
.steps .step::after {
  content: "";
  position: absolute;
  top: 4px;
  height: 1px;
  background: var(--line);
}
.steps .step::before { left: 0; right: 50%; }
.steps .step::after { left: 50%; right: 0; }
.steps .step:first-child::before,
.steps .step:last-child::after { display: none; }

.steps .step.is-done { color: var(--ink); }
.steps .step.is-done .dot { border-color: var(--ink); background: var(--ink); }
.steps .step.is-done::before,
.steps .step.is-done::after { background: var(--ink); }

.steps .step.is-current { color: var(--ink); font-weight: 500; }
.steps .step.is-current .dot { border: 2px solid var(--ink); background: var(--surface); }
.order-body { padding: var(--s2) var(--s4); }
.order-item-row { display: flex; gap: var(--s3); align-items: center; padding: var(--s2) 0; }
.order-item-row .thumb-sm { width: 52px; height: 52px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); overflow: hidden; }
.order-item-row .thumb-sm img { width: 100%; height: 100%; object-fit: cover; }
.order-item-row .line-main { gap: 1px; }
.order-item-row .amt { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-foot {
  display: flex; gap: var(--s2); align-items: center; justify-content: flex-end;
  padding: var(--s3) var(--s4); border-top: 1px solid var(--line); flex-wrap: wrap;
}
.order-foot .foot-sum { margin-right: auto; color: var(--ink-3); font-size: 12px; }
.order-foot .foot-sum .amt { color: var(--ink); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: var(--s1); }
.order-info { padding: 0 var(--s4) var(--s3); color: var(--ink-3); font-size: 12px; line-height: 1.7; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s6); transform: translate(-50%, 8px);
  max-width: 90vw; padding: var(--s2) var(--s4);
  border-radius: var(--r2); background: var(--ink); color: #fff;
  font-size: 13px; opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity .2s ease-out, transform .2s ease-out;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: var(--s7); padding: var(--s5) 0 var(--s6);
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12px;
}
.site-footer .rows { display: flex; gap: var(--s2) var(--s5); flex-wrap: wrap; justify-content: space-between; align-items: center; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 150;
  display: none; align-items: center; justify-content: center; padding: var(--s4);
  background: rgba(23, 25, 28, .5);
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow: auto;
  padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface);
}
.modal h3 { margin-bottom: var(--s3); font-size: 16px; }
.modal-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s4); }

@media (max-width: 860px) {
  .container {
    padding-left: max(var(--s4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--s4), env(safe-area-inset-right, 0px));
  }
  .header-inner { height: 52px; padding: var(--s2) 0; gap: var(--s3); flex-wrap: nowrap; }
  .search-form { max-width: none; }
  .search-form input { font-size: 16px; }
  .header-actions { gap: var(--s3); }

  /* 输入框保持 16px：iOS 对小于 16px 的输入框会在聚焦时放大整页，
     用户就会觉得「页面显示不全、要缩小才看得到」 */
  .field input, .field textarea, .field select,
  .toolbar input, .toolbar select { font-size: 16px; }
  .field textarea { line-height: 1.6; }

  /* 手机上把小号文字整体抬高一级，保证不靠缩小也能看清 */
  .card-sub,
  .stock-tip,
  .price-old,
  .page-title .count,
  .toolbar .result,
  .pager .info,
  .crumb,
  .form-note,
  .line-meta,
  .order-info,
  .meta-row .k,
  .buy-block .sales,
  .head-notes,
  .notice { font-size: 13px; }
  .tab-item { font-size: 13px; }
  .tab-row .tab, .sort-group button, .tab-row .tab .n { font-size: 14px; }
  .page-head p, .detail-sub, .desc-block, .empty { font-size: 14px; }
  .field label { font-size: 13px; }
  .meta-row { font-size: 14px; }
  .card-title { font-size: 15px; }
  .card-body { padding: var(--s3); }
  .price { font-size: 17px; }
  .btn { font-size: 15px; }
  .btn-sm { font-size: 14px; }

  .page-head { padding: var(--s5) 0 var(--s4); }
  .page-head h1 { font-size: 20px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: var(--s4) var(--s3); }

  .detail { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .detail-info h1 { font-size: 19px; }

  .checkout-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  /* 手机上先看商品清单与合计，再填收货信息 */
  .checkout-col-summary { order: -1; }

  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .auth-wrap { margin: var(--s5) auto; padding: 0 var(--s4); }

  .line-item { gap: var(--s2); }
  .line-actions { flex-wrap: wrap; justify-content: flex-end; }
  .summary { justify-content: space-between; }
  .site-footer { margin-top: var(--s6); }
}

/* ---------- 长串防溢出：订单号、地址这类不能断行的内容不要撑破容器 ---------- */
.order-head .no,
.recent-order .no,
.meta-row .v,
.addr-line,
.done-hint,
.line-meta,
.order-info { overflow-wrap: anywhere; word-break: break-word; }
.order-head .no { min-width: 0; }
.meta-row .v { min-width: 0; }
.recent-order > * { min-width: 0; }

/* ---------- 窄屏（iPhone SE、小屏安卓 320~380px） ---------- */
@media (max-width: 380px) {
  .container {
    padding-left: max(var(--s3), env(safe-area-inset-left, 0px));
    padding-right: max(var(--s3), env(safe-area-inset-right, 0px));
  }
  .header-inner { gap: var(--s2); }
  .logo { font-size: 15px; }

  /* 底栏只有四项，320px 宽下也放得开，字号不再往下压 */
  .tab-item { height: 52px; font-size: 12px; }
  .tab-item .ic { width: 21px; height: 21px; }
  .tabbar .cart-badge { top: 4px; font-size: 10px; }
  body { padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }

  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .card-body { padding: var(--s2) var(--s3) var(--s3); }
  .card-title { font-size: 14px; }
  .price { font-size: 16px; }
  .page-title h1, .page-title h2 { font-size: 18px; }
  .btn { padding: 0 var(--s3); }
  .qty-box input, .qty-box .qty { width: 38px; }
  .qty-box button { width: 34px; }
  .pager button { min-width: 32px; height: 32px; }

  /* 商品行：缩略图与文字占第一行，数量、小计、删除挪到第二行，避免挤成一坨 */
  .line-item { flex-wrap: wrap; }
  .line-actions { flex: 1 1 100%; justify-content: space-between; margin-top: var(--s1); }

  /* 最近订单：单号单独一行，日期/状态/金额排第二行 */
  .recent-order { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); }
  .recent-order .no { flex: 1 1 100%; }
  .recent-order .amt { margin-left: auto; }

  /* 详情页两个主按钮在窄屏保持并排 */
  .buy-row .btn { flex: 1 1 0; min-width: 0; }
}
