/* ============ 值买优选 前台样式 ============ */
:root {
  --primary: #e8432f;
  --primary-dark: #d23a26;
  --blue: #3488e0;
  --bg: #f5f6f7;
  --card: #fff;
  --text: #333;
  --muted: #999;
  --border: #ececec;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* 页面级横向滚动条统一裁掉（clip 不产生滚动容器，不影响 sticky 顶栏） */
html, body { max-width: 100%; overflow-x: clip; }
body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }
img, video, canvas, table { max-width: 100%; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
/* 宽表格/长文本在容器内横向滚动，不撑破页面 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 内容 + 右侧栏两栏布局（小屏自动单列） */
.community-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }

/* ---------- 顶部 ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.logo { font-size: 22px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.logo span { color: var(--blue); }
.topbar .search { flex: 1; max-width: 360px; display: flex; }
.topbar .search input { flex: 1; height: 36px; border: 2px solid var(--primary); border-radius: 18px 0 0 18px; padding: 0 14px; outline: none; font-size: 13px; }
.topbar .search button { width: 58px; border: none; background: var(--primary); color: #fff; border-radius: 0 18px 18px 0; cursor: pointer; font-size: 14px; }
.user-bar { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-bar .user-chip { display: flex; align-items: center; gap: 6px; }
.user-bar .user-chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.bar-unread b { background: var(--primary); color: #fff; border-radius: 8px; padding: 1px 6px; font-size: 11px; margin-left: 3px; }

/* ---------- 导航 ---------- */
.mainnav { background: #fff; border-bottom: 1px solid var(--border); }
.mainnav-inner { display: flex; align-items: center; gap: 4px; height: 46px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -ms-overflow-style: none; }
.mainnav-inner::-webkit-scrollbar { display: none; }
.mainnav a { padding: 10px 14px; font-size: 15px; color: #444; font-weight: 500; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: var(--primary); }

/* ---------- 首页 Hero：左侧产品分类竖列 + 右侧轮播 ---------- */
.hero-layout { display: grid; grid-template-columns: 216px 1fr; gap: 16px; align-items: stretch; margin-top: 14px; }
.hero-cats { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.hero-cats::-webkit-scrollbar { display: none; }
.hero-cats-title { font-weight: 700; font-size: 15px; padding: 12px 16px 10px; border-bottom: 1px solid var(--border); color: #333; }
.hero-cat-item { display: flex; align-items: center; gap: 9px; padding: 9px 16px; font-size: 13.5px; color: #444; border-bottom: 1px solid #f6f6f6; transition: background .15s, color .15s; }
.hero-cat-item:hover { color: var(--primary); background: #fff7f5; }
.hero-cat-item .hero-cat-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.hero-cat-item:last-child { border-bottom: none; }
/* 小屏：竖列变横滑一行 */
@media (max-width: 860px) {
  .hero-layout { grid-template-columns: 1fr; }
  .hero-cats { flex-direction: row; overflow-x: auto; max-height: none; }
  .hero-cats-title { display: none; }
  .hero-cat-item { border-bottom: none; white-space: nowrap; padding: 10px 12px; }
}

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 16px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 13px; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-outline:hover { background: #fff5f3; }
.btn-ghost { color: #666; }
.btn-ghost:hover { color: var(--primary); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { opacity: .9; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; overflow-wrap: anywhere; }
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 4px; height: 18px; background: var(--primary); border-radius: 2px; }

/* ---------- 好价卡片 ---------- */
.deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }
.deal-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; cursor: pointer; }
.deal-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0, 0, 0, .1); }
.deal-thumb { height: 150px; background: linear-gradient(135deg, #f7f7f7, #eee); display: flex; align-items: center; justify-content: center; font-size: 42px; color: #ccc; position: relative; }
.deal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.deal-ai-badge { position: absolute; left: 8px; top: 8px; z-index: 2; background: linear-gradient(135deg, #7a4fd0, #9b6bff); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; box-shadow: 0 2px 6px rgba(122, 79, 208, .35); }
.deal-rec-badge { position: absolute; left: 8px; top: 8px; z-index: 2; background: linear-gradient(135deg, #ff6a4a, #ff3b30); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; box-shadow: 0 2px 6px rgba(255, 59, 48, .35); }
/* 吸底购买栏（商品详情页转化增强） */
.buybar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; box-shadow: 0 -2px 12px rgba(0,0,0,.08); display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.buybar .bb-price { display: flex; flex-direction: column; line-height: 1.1; }
.buybar .bb-price b { color: var(--primary); font-size: 22px; }
.buybar .bb-price small { color: var(--muted); font-size: 12px; }
.buybar .bb-btn { margin-left: auto; }
.deal-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.deal-title { font-size: 14px; line-height: 1.45; min-height: 40px; color: #222; }
.deal-title:hover { color: var(--primary); }
.deal-price-row { display: flex; align-items: baseline; gap: 8px; }
.deal-price { color: var(--primary); font-weight: 800; font-size: 22px; }
.deal-price small { font-size: 13px; font-weight: 600; }
.deal-old { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.deal-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.deal-tag { background: #fff3f1; color: var(--primary); border: 1px solid #ffd9d2; border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.deal-tag.blue { background: #eef5ff; color: var(--blue); border-color: #cfe4ff; }
.deal-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.worth-badge { color: var(--primary); font-weight: 600; }

/* ---------- 文章卡片 ---------- */
.article-card { display: flex; gap: 14px; padding: 14px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; cursor: pointer; transition: transform .15s; }
.article-card:hover { transform: translateX(3px); }
.article-cover { width: 140px; height: 92px; border-radius: 6px; background: linear-gradient(135deg, #eef2f7, #e2e8f0); display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; overflow: hidden; }
.article-cover img { width: 100%; height: 100%; object-fit: cover; }
.article-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.article-info h3 { font-size: 15px; line-height: 1.4; }
.article-info h3:hover { color: var(--primary); }
.article-summary { color: #777; font-size: 13px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.article-meta { display: flex; gap: 14px; color: var(--muted); font-size: 12px; align-items: center; }
.avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

/* ---------- 详情 ---------- */
.detail-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding-top: 16px; }
.main-col { min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.deal-hero { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.deal-hero h1 { font-size: 20px; line-height: 1.5; margin-bottom: 12px; }
.price-line { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.price-now { font-size: 34px; font-weight: 800; color: var(--primary); }
.price-origin { color: var(--muted); text-decoration: line-through; font-size: 15px; }
.price-off { background: var(--primary); color: #fff; font-size: 13px; padding: 3px 10px; border-radius: 12px; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.buy-row { display: flex; gap: 12px; align-items: center; margin: 16px 0; }
.buy-btn { flex: 1; max-width: 320px; padding: 13px 0; font-size: 16px; }
.deal-desc { background: #fafafa; border-radius: 8px; padding: 14px; color: #555; line-height: 1.8; white-space: pre-wrap; margin-top: 14px; }
.vote-box { display: flex; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.vote-btn { padding: 10px 28px; border-radius: 24px; font-size: 15px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.vote-btn.worth:hover, .vote-btn.worth.active { border-color: var(--primary); color: var(--primary); background: #fff5f3; }
.vote-btn.unworth:hover, .vote-btn.unworth.active { border-color: #888; color: #666; background: #f7f7f7; }

/* ---------- 评论 ---------- */
.comment-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f2f2f2; }
.comment-item img { width: 38px; height: 38px; border-radius: 50%; }
.comment-body { flex: 1; }
.comment-head { display: flex; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; margin-bottom: 5px; }
.comment-head .name { color: var(--blue); font-weight: 600; }
.comment-content { line-height: 1.7; color: #444; }
.reply-item { margin-top: 8px; margin-left: 42px; background: #f8f8f8; border-radius: 8px; padding: 10px; font-size: 13px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form input, .form textarea, .form select { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; font-family: inherit; }
.form input:focus, .form textarea:focus, .form select:focus { border-color: var(--primary); }
.form label { font-size: 13px; color: #666; margin-bottom: -6px; }
.form-tip { font-size: 12px; color: var(--muted); text-align: center; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

/* ---------- 登录弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: none; align-items: center; justify-content: center; z-index: 999; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 28px; width: 340px; position: relative; }
.modal h3 { margin-bottom: 18px; font-size: 18px; }
.modal-close { position: absolute; right: 12px; top: 8px; border: none; background: none; font-size: 22px; color: #aaa; cursor: pointer; }

/* ---------- 页面头 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 14px; }
.page-head h2 { font-size: 20px; }
.tabs { display: flex; gap: 6px; }
.tabs .tab { padding: 7px 18px; border-radius: 20px; background: #fff; border: 1px solid var(--border); cursor: pointer; font-size: 13px; color: #666; }
.tabs .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tabs .tab.blue.active { background: var(--blue); border-color: var(--blue); }

/* ---------- 工具条 ---------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: #fff; padding: 12px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.filter-bar select, .filter-bar input { height: 34px; border: 1px solid #ddd; border-radius: 6px; padding: 0 10px; font-size: 13px; outline: none; }
.chip { padding: 5px 12px; border-radius: 16px; background: #f2f2f2; color: #555; cursor: pointer; font-size: 12px; border: 1px solid transparent; }
.chip.active { background: #fff3f1; color: var(--primary); border-color: var(--primary); }

/* ---------- 列表页 ---------- */
.pagination { display: flex; justify-content: center; gap: 8px; margin: 20px 0; }
.pagination button { min-width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty .icon { font-size: 48px; display: block; margin-bottom: 10px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 侧边 ---------- */
.side-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.side-box h4 { font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; }
.rank-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f6f6f6; cursor: pointer; }
.rank-item:last-child { border-bottom: none; }
.rank-no { width: 22px; height: 22px; border-radius: 4px; background: #f0f0f0; color: #888; text-align: center; line-height: 22px; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.rank-item:nth-child(2) .rank-no, .rank-item:nth-child(3) .rank-no, .rank-item:nth-child(4) .rank-no { background: var(--primary); color: #fff; }
.rank-item:hover .rank-name { color: var(--primary); }
.rank-name { flex: 1; min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
/* 走势图 canvas 由 Chart.js 写入内联宽度，用 max-width 封顶防止撑宽页面 */
#priceChart { max-width: 100%; display: block; }
.rank-val { color: var(--primary); font-weight: 700; font-size: 13px; }

/* ---------- 个人中心 ---------- */
.user-hero { background: linear-gradient(135deg, var(--primary), #ff7a5c); color: #fff; border-radius: var(--radius); padding: 26px; display: flex; gap: 20px; align-items: center; box-shadow: var(--shadow); }
.user-hero img.avatar-lg { width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff; object-fit: cover; }
.user-hero .u-name { font-size: 22px; font-weight: 700; }
.user-stats { display: flex; gap: 28px; margin-top: 10px; }
.user-stats b { font-size: 20px; display: block; }
.user-stats span { font-size: 12px; opacity: .85; }
.user-grid { display: grid; grid-template-columns: 240px 1fr; gap: 16px; margin-top: 16px; }
.user-menu { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 0; height: fit-content; }
.user-menu a { display: flex; align-items: center; gap: 10px; padding: 12px 18px; color: #555; font-size: 14px; }
.user-menu a:hover, .user-menu a.active { background: #fff5f3; color: var(--primary); }
.user-content { min-width: 0; }

/* ---------- 签到 ---------- */
.signin-btn { width: 100%; padding: 16px; font-size: 16px; border-radius: 10px; }
.streak-info { text-align: center; color: #fff; opacity: .9; font-size: 13px; margin-top: 8px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f2f2f2; font-size: 13px; }
.table th { background: #fafafa; color: #666; font-weight: 600; }
.table tr:hover td { background: #fbfbfb; }

/* ---------- 底部 ---------- */
.footer { margin-top: 40px; background: #fff; border-top: 1px solid var(--border); padding: 24px 0; text-align: center; color: var(--muted); font-size: 13px; }
.footer a { color: #888; margin: 0 8px; }

/* ---------- Toast ---------- */
#toastBox { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: rgba(0, 0, 0, .78); color: #fff; padding: 9px 20px; border-radius: 20px; font-size: 13px; animation: fadeIn .2s; }
.toast.error { background: rgba(190, 45, 30, .92); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* ---------- 响应式 ---------- */
/* 平板 / 窄屏：两栏合并为单栏 */
@media (max-width: 900px) {
  .detail-page { grid-template-columns: minmax(0, 1fr); }
  .user-grid { grid-template-columns: 1fr; }
  .community-layout { grid-template-columns: 1fr; }
  .deal-grid { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); }
  .topbar .search { display: none; }
  .user-bar .btn { padding: 5px 10px; font-size: 12px; }
  .article-cover { width: 90px; height: 68px; }
}

/* 手机：整体收缩，双列卡片 */
@media (max-width: 640px) {
  .container { padding: 0 12px; }
  .topbar-inner { height: 54px; gap: 10px; }
  .logo { font-size: 18px; }
  .user-bar { gap: 6px; }
  .user-bar .user-chip span { display: none; }
  .mainnav-inner { height: 42px; }
  .mainnav a { padding: 9px 11px; font-size: 14px; }
  .deal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .deal-thumb { height: 118px; font-size: 32px; }
  .deal-thumb img { height: 100%; }
  .deal-body { padding: 10px; gap: 6px; }
  .deal-title { font-size: 13px; min-height: 36px; }
  .deal-price { font-size: 19px; }
  .deal-old, .deal-meta, .deal-bottom { font-size: 11px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .card-title { font-size: 15px; margin-bottom: 10px; }
  .deal-hero { padding: 14px; }
  .deal-hero h1 { font-size: 17px; margin-bottom: 8px; }
  .price-line { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .price-now { font-size: 27px; }
  .price-origin { font-size: 13px; }
  .buy-row { flex-wrap: wrap; margin: 12px 0; }
  .buy-btn { max-width: none; }
  .vote-box { gap: 10px; }
  .vote-btn { padding: 8px 16px; font-size: 14px; }
  .article-card { padding: 10px; gap: 10px; }
  .article-cover { width: 76px; height: 56px; font-size: 22px; }
  .article-info h3 { font-size: 14px; }
  .article-summary { font-size: 12px; }
  .article-meta { gap: 10px; flex-wrap: wrap; }
  .user-hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
  .user-hero img.avatar-lg { width: 60px; height: 60px; }
  .user-hero .u-name { font-size: 18px; }
  .user-stats { gap: 18px; }
  .user-stats b { font-size: 17px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; margin: 14px 0 10px; }
  .page-head h2 { font-size: 17px; }
  .tabs { flex-wrap: wrap; }
  .filter-bar { padding: 10px; gap: 6px; }
  .filter-bar select, .filter-bar input { height: 32px; font-size: 12px; }
  .form-row { flex-direction: column; gap: 12px; }
  .modal { width: calc(100vw - 32px); max-width: 340px; padding: 22px; }
  .modal h3 { font-size: 16px; }
  .comment-item { gap: 8px; }
  .comment-item img { width: 32px; height: 32px; }
  .reply-item { margin-left: 12px; }
  .table th, .table td { padding: 9px 10px; font-size: 12px; }
  .side-box { padding: 12px; }
  .rank-name { font-size: 12.5px; }
  .footer { margin-top: 24px; padding: 18px 0; }
}

/* 小屏手机：单列卡片 */
@media (max-width: 400px) {
  .deal-grid { grid-template-columns: 1fr; }
  .deal-thumb { height: 160px; }
  .user-stats { gap: 14px; }
}
