/* ============================================================
   新知源 · 基础样式 + 通用组件
   ============================================================ */

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: var(--font-family);
  font-size: var(--font-md);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;  /* 去掉点击高亮 */
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; outline: none; }

/* ---------- 页面容器 ---------- */
.page {
  min-height: 100vh;
  max-width: var(--content-max-width);
  margin: 0 auto;
  background: var(--bg-page);
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 8px);
}
.page--no-tabbar { padding-bottom: 0; }
.page--has-actionbar { padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 72px); } /* tabbar + 底部操作栏 */
.page--no-tabbar.page--has-actionbar { padding-bottom: calc(var(--safe-bottom) + 72px); } /* 沉浸页(exam): 无 tabbar,操作栏贴底 */

/* ---------- 顶部导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  background: var(--bg-card);
  border-bottom: 1px solid var(--divider);
}
.navbar__logo {
  height: 24px;
  width: auto;
  flex-shrink: 0;
  margin-right: var(--space-sm);
}
.navbar__title {
  flex: 1;
  text-align: center;
  font-size: var(--font-lg);
  font-weight: 600;
  margin-right: 48px; /* 抵消左侧logo宽度,让标题居中 */
}
.navbar__title--solo { margin-right: 0; } /* 只有标题没有logo时 */
.navbar__back {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-primary);
}
.navbar__right {
  min-width: 24px;
  font-size: var(--font-md);
  color: var(--text-secondary);
}

/* ---------- 内容区块 ---------- */
.section { padding: var(--space-lg); }
.section__title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section__title .more {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 400;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
}
.card--flat { box-shadow: none; border: 1px solid var(--divider); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: var(--font-md);
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--brand-primary); color: #fff; }
.btn--primary:active { background: var(--brand-primary-dark); }
.btn--gradient { background: var(--brand-gradient); color: #fff; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:active { background: var(--accent-dark); }
.btn--outline { background: #fff; color: var(--brand-primary); border: 1px solid var(--brand-primary); }
.btn--ghost { background: var(--brand-primary-light); color: var(--brand-primary); }
.btn--block { display: flex; width: 100%; padding: 13px; font-size: var(--font-lg); }
.btn--sm { padding: 6px 14px; font-size: var(--font-sm); }

/* ---------- 标签 Tag ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  line-height: 1.6;
}
.tag--brand { background: var(--brand-primary-light); color: var(--brand-primary); }
.tag--accent { background: var(--accent-light); color: var(--accent); }
.tag--grade { background: #EEF4FF; color: #3B6FE0; }

/* ---------- 底部 Tab 栏 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 200;
  max-width: var(--content-max-width);
  margin: 0 auto;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--bg-card);
  box-shadow: var(--shadow-tab);
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: var(--font-xs);
}
.tabbar__item.active { color: var(--brand-primary); }
.tabbar__icon { font-size: 22px; line-height: 1; }

/* ---------- 底部固定操作栏 ---------- */
.action-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-height) + var(--safe-bottom)); /* 避让底部 Tab 栏 */
  z-index: 200;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-fixed);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.action-bar--bottom { bottom: 0; } /* 不需要避让 tabbar 时(纯详情页底部操作) */

/* ---------- 搜索框 ---------- */
.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: 40px;
  padding: 0 var(--space-lg);
  background: var(--bg-page);
  border-radius: var(--radius-pill);
  color: var(--text-placeholder);
  font-size: var(--font-md);
}
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--font-md);
  color: var(--text-primary);
}

/* ---------- Toast 提示 ---------- */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  padding: 12px 20px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  max-width: 70%;
  text-align: center;
  animation: toast-fade 1.8s forwards;
}
@keyframes toast-fade {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  15%, 85% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -50%); }
}

/* ---------- 通用工具类 ---------- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: var(--font-sm); }
.text-center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.price { color: var(--accent); font-weight: 600; }
.price__symbol { font-size: var(--font-sm); }

/* ---------- 滚动隐藏横向滚动条 ---------- */
.scroll-x {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }
