:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #777777;
  --accent: #409eff;
  --accent-dark: #337ecc;
  --border: #e8e8e8;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

/* 防止组件的 display 样式覆盖 hidden 属性 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── 顶部导航 ─────────────────────────── */
.nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 18px;
  font-weight: 700;
}

.nav-right { display: flex; gap: 4px; }

.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-light);
  transition: all 0.15s;
}

.nav-link:hover { color: var(--accent); background: rgba(64, 158, 255, 0.08); }

/* ── 公告区 ───────────────────────────── */
main.container { flex: 1; padding-top: 20px; padding-bottom: 40px; }

.announcement {
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 14px;
}

.announcement-title {
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.announcement-body { color: var(--text-light); white-space: pre-wrap; word-break: break-word; }
.announcement-body a { color: var(--accent); }

/* ── 分类标签 ─────────────────────────── */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.tab:hover { color: var(--accent); border-color: var(--accent); }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 商品网格 ─────────────────────────── */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.loading { grid-column: 1 / -1; text-align: center; color: var(--text-light); padding: 48px 0; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--text-light); padding: 48px 0; }

.product-card { overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }

.product-link { display: block; height: 100%; }

.product-thumb {
  aspect-ratio: 4 / 3;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-noimg { color: #c0c4cc; font-size: 13px; }

.product-info { padding: 12px 14px 14px; }

.product-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
  height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-price-row {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.product-price { color: #e6a23c; font-weight: 700; font-size: 16px; }
.product-price:empty { display: none; }
.product-buy { color: var(--accent); font-size: 13px; white-space: nowrap; }

/* ── 页脚 ─────────────────────────────── */
.footer { border-top: 1px solid var(--border); background: var(--card-bg); }
.footer-inner { padding: 16px; text-align: center; color: var(--text-light); font-size: 13px; }

/* ── 商品详情弹窗 ─────────────────────── */
.detail-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.detail {
  width: 680px;
  max-width: 100%;
  position: relative;
  padding: 24px 28px;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
}

.detail-close:hover { color: var(--text); }

.detail-thumb {
  aspect-ratio: 16 / 9;
  max-height: 340px;
  background: #f0f2f5;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.detail-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

.detail-name { margin: 0 0 6px; font-size: 22px; }

.detail-price { color: #e6a23c; font-weight: 700; font-size: 18px; margin-bottom: 12px; }
.detail-price:empty { display: none; }

.btn-detail-link {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-detail-link:hover { background: var(--accent-dark); }

/* ── Markdown 内容 ────────────────────── */
.md-content { font-size: 15px; color: var(--text); }
.md-content img { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 12px 0; }
.md-content h3, .md-content h4, .md-content h5, .md-content h6 { margin: 16px 0 8px; }
.md-content h3 { font-size: 19px; }
.md-content h4 { font-size: 17px; }
.md-content p { margin: 10px 0; }
.md-content ul, .md-content ol { margin: 10px 0; padding-left: 24px; }
.md-content blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
  color: var(--text-light);
}
.md-content code { background: #eef1f4; border-radius: 4px; padding: 1px 6px; font-size: 13px; }
.md-content pre { background: #2d2d2d; color: #f0f0f0; border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.md-content pre code { background: none; color: inherit; padding: 0; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-content a { color: var(--accent); word-break: break-all; }

/* ── 响应式 ───────────────────────────── */
@media (max-width: 640px) {
  .products { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-info { padding: 10px 10px 12px; }
  .product-name { font-size: 14px; }
}
