/* ======================================================================
   彩虹云商城 · Store 焕新版 设计系统
   视觉基准：原包 template/store（公告条 / 搜索 / 分类九宫格 / 排序 Tab /
   商品列表卡片 / 底部 5 项 TabBar），全新重绘为统一协调的设计语言。
   ====================================================================== */
:root {
  --brand: #f0453f;
  --brand-soft: #fff1f0;
  --brand-deep: #d8372f;
  --accent: #2f7cf6;
  --accent-soft: #eef4ff;
  --success: #16a34a;
  --success-soft: #eafaf0;
  --warning: #e98900;
  --warning-soft: #fff6e6;
  --ink: #1b2233;
  --ink-2: #3c465b;
  --muted: #7a8395;
  --muted-2: #a2aab8;
  --line: #e9edf3;
  --line-2: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --bg: #f4f6fa;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(27, 34, 51, .04);
  --shadow: 0 4px 18px rgba(27, 34, 51, .07);
  --shadow-lg: 0 16px 44px rgba(27, 34, 51, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.6;
  color: var(--ink); background: var(--bg);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- 布局 ---------- */
.app-shell { min-height: 100vh; max-width: 520px; margin: 0 auto; background: var(--bg); position: relative; box-shadow: 0 0 60px rgba(27,34,51,.05); }
.page { padding: 14px 14px calc(var(--tabbar-h) + 26px); min-height: 60vh; }
.page--plain { padding-bottom: 30px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card--pad { padding: 16px; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.section-title::before { content: ""; width: 3px; height: 14px; border-radius: 3px; background: var(--brand); }
.section-more { font-size: 12px; color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-main { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 800; box-shadow: 0 4px 10px rgba(240,69,63,.28); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- 公告条（store 特征，重绘） ---------- */
.notice-bar { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--brand-soft); color: var(--brand-deep); font-size: 12.5px; }
.notice-tag { flex: none; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 11px; }
.notice-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.notice-bar svg { width: 15px; height: 15px; flex: none; }

/* ---------- 搜索 ---------- */
.search-bar { padding: 12px 14px 6px; background: var(--surface); }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 8px 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); transition: .18s; }
.search-box:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-box svg { width: 18px; height: 18px; color: var(--muted-2); flex: none; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search-box input::placeholder { color: var(--muted-2); }
.btn-search { flex: none; padding: 6px 14px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; }

/* ---------- 分类九宫格（store 特征） ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 4px; padding: 14px; background: var(--surface); }
.cat-item { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.cat-icon { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 20px; background: var(--surface-2); border: 1px solid var(--line); transition: .18s; }
.cat-icon svg { width: 23px; height: 23px; }
.cat-item.active .cat-icon { background: var(--brand-soft); border-color: rgba(240,69,63,.25); color: var(--brand); }
.cat-item:active .cat-icon { transform: scale(.94); }
.cat-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 排序栏（store 特征） ---------- */
.sort-bar { display: flex; align-items: center; background: var(--surface); border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line); padding: 0 6px; }
.sort-item { flex: 1; text-align: center; padding: 12px 0; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: 4px; }
.sort-item.active { color: var(--brand); font-weight: 600; }
.sort-item i { font-style: normal; font-size: 9px; color: var(--muted-2); line-height: 1; }
.sort-item.active i { color: var(--brand); }
.sort-divider { width: 1px; height: 15px; background: var(--line); }
.sort-grid { width: 46px; display: grid; place-items: center; color: var(--muted); }
.sort-grid svg { width: 17px; height: 17px; }
.count-strip { padding: 10px 14px; font-size: 12.5px; color: var(--muted); text-align: center; }
.count-strip b { color: var(--warning); font-weight: 700; }

/* ---------- 商品列表（store 特征，重绘） ---------- */
.goods-list { display: flex; flex-direction: column; gap: 10px; }
.goods-card { display: flex; gap: 12px; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: .18s; }
.goods-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.goods-thumb { width: 86px; height: 86px; flex: none; border-radius: 11px; overflow: hidden; background: linear-gradient(135deg, var(--surface-2), #e9edf5); display: grid; place-items: center; color: var(--muted-2); font-size: 11px; }
.goods-thumb img { width: 100%; height: 100%; object-fit: cover; }
.goods-thumb svg { width: 30px; height: 30px; opacity: .55; }
.goods-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.goods-name { font-size: 14px; font-weight: 600; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.goods-sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.goods-meta { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 12px; color: var(--muted); }
.goods-bottom { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 6px; }
.price { color: var(--brand); font-weight: 700; font-size: 18px; letter-spacing: -.4px; }
.price small { font-size: 12px; font-weight: 600; margin-right: 1px; }
.price--sm { font-size: 15px; }
.btn-buy { padding: 7px 17px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 3px 8px rgba(240,69,63,.22); }
.btn-buy:hover { background: var(--brand-deep); }
.btn-buy:active { transform: scale(.97); }

/* ---------- 通用组件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 10px; font-size: 14px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); transition: .18s; }
.btn:hover { border-color: var(--muted-2); }
.btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 4px 12px rgba(240,69,63,.2); }
.btn--primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn--accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--ghost { background: transparent; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; transition: .18s; font-size: 14px; }
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: var(--muted-2); }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge--brand { background: var(--brand-soft); color: var(--brand-deep); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warn { background: var(--warning-soft); color: var(--warning); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.divider { height: 1px; background: var(--line-2); margin: 12px 0; }

.empty { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 10px; }
.empty p { font-size: 13px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: 13.5px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-row-extra { text-align: right; flex: none; font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.5px; }
.stat-card.tone-brand .stat-value { color: var(--brand); }
.stat-card.tone-accent .stat-value { color: var(--accent); }
.stat-card.tone-green .stat-value { color: var(--success); }
.stat-card.tone-warn .stat-value { color: var(--warning); }

.rank-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rank-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.rank-item:last-child { border-bottom: 0; }
.rank-no { width: 26px; height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.rank-item:nth-child(1) .rank-no { background: var(--brand); color: #fff; }
.rank-item:nth-child(2) .rank-no { background: #ff9d57; color: #fff; }
.rank-item:nth-child(3) .rank-no { background: #ffc65c; color: #fff; }

.hero { padding: 18px; border-radius: var(--radius-lg); background: linear-gradient(120deg, var(--brand), #ff8a5c); color: #fff; box-shadow: 0 10px 26px rgba(240,69,63,.24); }
.hero h2 { font-size: 18px; font-weight: 700; }
.hero p { font-size: 12.5px; opacity: .9; margin-top: 4px; }
.hero .btn { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.35); color: #fff; height: 34px; margin-top: 14px; }

.kv-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kv { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv-label { width: 96px; flex: none; color: var(--muted); }
.kv-value { flex: 1; word-break: break-all; }

.notice-box { padding: 12px 14px; border-radius: 10px; background: var(--warning-soft); color: #8a5a00; font-size: 12.5px; border: 1px solid #f6e3bd; }
.notice-box--info { background: var(--accent-soft); color: #1c57b5; border-color: #d8e6ff; }

/* ---------- 底部 TabBar（store 特征，重绘） ---------- */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; height: var(--tabbar-h); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); }
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar a.active svg { stroke-width: 2.2; }

/* ---------- Toast ---------- */
.toast { position: fixed; top: 22px; left: 50%; transform: translate(-50%, -16px); z-index: 999; min-width: 180px; max-width: 86vw; padding: 11px 18px; border-radius: 11px; background: rgba(27,34,51,.92); color: #fff; font-size: 13px; text-align: center; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: #c9342c; }
.toast--success { background: #12833b; }

/* ---------- 表单页 / 详情页 ---------- */
.form-card { padding: 18px 16px; }
.form-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.form-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; }
.detail-hero { padding: 20px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-price { font-size: 26px; color: var(--brand); font-weight: 700; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.qty button { width: 34px; height: 34px; background: var(--surface-2); font-size: 17px; color: var(--ink-2); }
.qty input { width: 48px; height: 34px; text-align: center; border: 0; outline: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.pay-bar { position: sticky; bottom: calc(var(--tabbar-h) + 6px); z-index: 15; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 14px; }
.pay-bar .total { flex: 1; font-size: 12px; color: var(--muted); }
.pay-bar .total b { display: block; font-size: 19px; color: var(--brand); }

/* ---------- 商品网格（PC 宽屏） ---------- */
.goods-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.goods-grid .goods-card { flex-direction: column; }
.goods-grid .goods-thumb { width: 100%; height: 130px; }
.goods-grid .goods-body { min-height: 108px; }

/* ---------- 响应式 ---------- */
@media (min-width: 900px) {
  body { background: #eef1f7; }
  .app-shell { max-width: 1080px; box-shadow: var(--shadow-lg); }
  .topbar-main { height: 60px; padding: 0 26px; }
  .page { padding: 20px 26px 40px; }
  .cat-grid { grid-template-columns: repeat(10, 1fr); padding: 18px 26px; }
  .search-bar { padding: 14px 26px 8px; }
  .tabbar { position: sticky; top: 60px; bottom: auto; max-width: 1080px; height: 46px; grid-template-columns: repeat(5, 92px); justify-content: start; padding: 0 20px; gap: 6px; border-top: 0; border-bottom: 1px solid var(--line); }
  .tabbar a { flex-direction: row; gap: 6px; font-size: 12.5px; }
  .tabbar a svg { width: 17px; height: 17px; }
  .page { padding-bottom: 40px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .front-columns { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
  .front-side { position: sticky; top: 116px; }
}

/* ---------- 深色模式（系统偏好） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9edf5; --ink-2: #c6cede; --muted: #93a0b5; --muted-2: #6f7c92;
    --line: #2b3547; --line-2: #232c3c; --surface: #1b2433; --surface-2: #222d40;
    --bg: #131a26; --brand-soft: #3a2326; --accent-soft: #1d2c4a;
    --success-soft: #173528; --warning-soft: #3a2c12;
  }
  .hero { box-shadow: none; }
  .goods-thumb { background: #263145; }
  .tabbar { background: rgba(27,36,51,.96); }
}
