/* ============================================================
   学习乐园 · 前台样式（橙色主题）
   主色：#FF7A1A（橙）  辅色：#FFB347（浅橙）
   背景：#FFF8F2（暖白）  文字：#3D2B1F（深棕）
   ============================================================ */
:root {
  --brand: #FF7A1A;
  --brand-dark: #E85D04;
  --brand-light: #FFB347;
  --brand-soft: #FFE8D6;
  --bg: #FFF8F2;
  --card: #FFFFFF;
  --text: #3D2B1F;
  --text-sub: #8A7566;
  --border: #F0E2D4;
  --success: #22A06B;
  --danger: #E5484D;
  --star: #FFB400;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(255, 122, 26, 0.08);
  --shadow-hover: 0 8px 24px rgba(255, 122, 26, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ==================== 顶部导航 ==================== */
.topbar {
  background: linear-gradient(135deg, #FF8C2B, #FF6B00);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255, 107, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.logo {
  font-size: 20px; font-weight: 800; letter-spacing: 1px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.logo-badge {
  background: #fff; color: var(--brand-dark);
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
}
.search-box {
  flex: 1; display: flex; max-width: 520px;
  background: #fff; border-radius: 22px; overflow: hidden;
  height: 38px;
}
.search-box input {
  flex: 1; border: 0; outline: 0; padding: 0 16px; font-size: 14px; color: var(--text);
}
.search-box button {
  border: 0; background: var(--brand-dark); color: #fff;
  padding: 0 22px; font-size: 14px; font-weight: 600;
}
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-btn {
  background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255,255,255,0.35);
  color: #fff; padding: 7px 14px; border-radius: 20px; font-size: 13px;
  transition: background .2s;
}
.top-btn:hover { background: rgba(255, 255, 255, 0.32); }
.user-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.2); border-radius: 20px; padding: 5px 12px; font-size: 13px;
}
.user-chip b { font-weight: 600; }

/* ==================== 公告条 ==================== */
.announce {
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 13px; padding: 8px 16px; text-align: center;
}

/* ==================== 分类导航 ==================== */
.cats {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 0 4px;
}
.cat-item {
  background: #fff; border: 1px solid var(--border);
  padding: 7px 18px; border-radius: 20px; font-size: 14px; color: var(--text-sub);
  transition: all .18s;
}
.cat-item:hover { border-color: var(--brand-light); color: var(--brand-dark); }
.cat-item.active {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}

/* ==================== 排序栏 ==================== */
.sort-bar {
  display: flex; align-items: center; gap: 8px; padding: 12px 0;
  font-size: 13px; color: var(--text-sub);
}
.sort-item { padding: 5px 14px; border-radius: 16px; cursor: pointer; }
.sort-item:hover { color: var(--brand-dark); }
.sort-item.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ==================== 商品网格（淘宝风卡片） ==================== */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  padding: 8px 0 40px;
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: all .22s;
  display: flex; flex-direction: column; cursor: pointer; position: relative;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card-cover {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--brand-soft);
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 15px; font-weight: 700; line-height: 1.35; }
.card-sub { font-size: 12px; color: var(--brand-dark); }
.card-summary {
  font-size: 12px; color: var(--text-sub); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 36px;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: var(--brand-soft); color: var(--brand-dark);
}
.tag-type-material { background: #E7F3FF; color: #1F6FB2; }
.tag-login { background: #FFF0E0; color: #B25E00; }
.tag-paid { background: #FFE7E7; color: #C62828; }
.card-metrics {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px dashed var(--border); padding-top: 8px; margin-top: auto;
  font-size: 12px; color: var(--text-sub);
}
.metric { display: flex; align-items: center; gap: 3px; }
.metric b { color: var(--brand-dark); font-weight: 700; }
.good-rate { color: var(--success); font-weight: 700; }
.stars { color: var(--star); letter-spacing: -1px; }

/* ==================== 空状态 / 加载 ==================== */
.empty { text-align: center; padding: 60px 20px; color: var(--text-sub); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.loading { text-align: center; padding: 60px; color: var(--text-sub); }

/* ==================== 详情页 ==================== */
.detail { display: grid; grid-template-columns: 380px 1fr; gap: 28px; padding: 20px 0 60px; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }

.detail-cover {
  width: 100%; border-radius: var(--radius); background: var(--brand-soft);
  box-shadow: var(--shadow);
}
.detail-panel {
  background: #fff; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-top: 14px;
}
.detail-title { font-size: 24px; font-weight: 800; line-height: 1.3; }
.detail-sub { color: var(--brand-dark); font-size: 14px; margin-top: 4px; }
.detail-meta { display: flex; gap: 20px; flex-wrap: wrap; margin: 14px 0; font-size: 13px; color: var(--text-sub); }
.detail-meta b { color: var(--brand-dark); font-size: 16px; }
.detail-actions { display: flex; gap: 12px; margin: 18px 0; flex-wrap: wrap; }

.btn {
  border: 0; border-radius: 10px; padding: 12px 28px; font-size: 15px;
  font-weight: 600; transition: all .18s; display: inline-flex;
  align-items: center; gap: 6px; justify-content: center;
}
.btn-primary { background: linear-gradient(135deg, #FF8C2B, #FF6B00); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-outline { background: #fff; border: 1.5px solid var(--brand); color: var(--brand-dark); }
.btn-outline:hover { background: var(--brand-soft); }
.btn-gray { background: #F5F0EA; color: var(--text-sub); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.section-title {
  font-size: 16px; font-weight: 700; margin: 22px 0 10px;
  padding-left: 10px; border-left: 4px solid var(--brand);
}
.detail-desc { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  line-height: 1.8; color: #5A463A; white-space: pre-wrap; }

.rating-item {
  border-bottom: 1px solid var(--border); padding: 12px 0;
}
.rating-item:last-child { border-bottom: 0; }
.rating-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.rating-user { font-weight: 600; }
.rating-time { color: var(--text-sub); font-size: 12px; margin-left: auto; }
.rating-comment { font-size: 13px; color: #5A463A; margin-top: 4px; }

/* ==================== 运行壳（全屏） ==================== */
.runner {
  position: fixed; inset: 0; background: #fff; z-index: 900;
  display: none; flex-direction: column;
}
.runner.show { display: flex; }
.runner-bar {
  height: 52px; background: linear-gradient(135deg, #FF8C2B, #FF6B00); color: #fff;
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.runner-title { font-weight: 700; font-size: 16px; }
.runner-timer { font-size: 13px; opacity: .9; }
.runner-spacer { flex: 1; }
.runner-btn {
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.4);
  color: #fff; padding: 7px 16px; border-radius: 8px; font-size: 13px;
}
.runner-btn:hover { background: rgba(255,255,255,.36); }
.runner-frame { flex: 1; border: 0; width: 100%; background: #fff; }

/* ==================== 弹层 ==================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(61, 43, 31, .5);
  display: none; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 18px; width: 92%; max-width: 420px;
  padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text-sub); margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; outline: 0; font-family: inherit;
  background: #fff; color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.modal-link { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-sub); }
.modal-link a { color: var(--brand-dark); font-weight: 600; }

/* 评分弹层 */
.rate-stars { display: flex; gap: 8px; justify-content: center; margin: 10px 0 6px; }
.rate-star {
  font-size: 38px; color: #E0D5CB; background: none; border: 0; padding: 0 2px;
  transition: transform .12s, color .12s; line-height: 1;
}
.rate-star:hover { transform: scale(1.15); }
.rate-star.on { color: var(--star); }
.rate-tip { text-align: center; font-size: 14px; color: var(--brand-dark); min-height: 22px; font-weight: 600; }

/* ==================== Toast ==================== */
.toast-wrap {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: rgba(61, 43, 31, .92); color: #fff; padding: 10px 20px;
  border-radius: 22px; font-size: 14px; animation: slideDown .2s;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes slideDown { from { transform: translateY(-12px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ==================== 页脚 ==================== */
.footer {
  background: #FFF1E4; color: var(--text-sub); text-align: center;
  padding: 24px 16px; font-size: 13px; margin-top: 40px;
}

/* ==================== 我的 / 余额 ==================== */
.mini-panel {
  background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 120px; background: var(--brand-soft); border-radius: 12px;
  padding: 14px; text-align: center;
}
.stat-box .num { font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.stat-box .lbl { font-size: 12px; color: var(--text-sub); }

/* 面包屑 */
.crumb { font-size: 13px; color: var(--text-sub); padding: 14px 0 0; }
.crumb a:hover { color: var(--brand-dark); }

/* ==================== 标签筛选区（学科/年级/类型/自定义） ==================== */
.filters {
  background: var(--card); border-radius: var(--radius); padding: 10px 14px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.filter-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-sub); margin-bottom: 6px;
}
.filter-clear { color: var(--brand-dark); cursor: pointer; font-size: 12px; }
.filter-clear:hover { text-decoration: underline; }
.filter-row { display: flex; align-items: flex-start; gap: 10px; padding: 4px 0; font-size: 13px; }
.filter-dim { flex: 0 0 48px; color: var(--text-sub); padding-top: 3px; }
.filter-items { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-item {
  padding: 3px 10px; border-radius: 999px; background: #F5F5F5; color: #555;
  cursor: pointer; font-size: 12px; transition: all .15s; user-select: none;
}
.filter-item:hover { background: var(--brand-soft); color: var(--brand-dark); }
.filter-item.on { background: var(--brand); color: #fff; font-weight: 600; }

/* 标签按维度着色 */
.tag-subject { background: #FFF1E6; color: #C2570A; }
.tag-grade   { background: #EAF3FF; color: #1A56A8; }
.tag-kind    { background: #EAF9EF; color: #1A7F4F; }
.tag-custom  { background: #F3EAFF; color: #6B34C2; }

/* ==================== 排行榜（商品榜 / 全站总榜） ==================== */
.board {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin-top: 18px; box-shadow: var(--shadow);
}
.board-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.board-head h3 { margin: 0; font-size: 16px; }
.board-sub { font-size: 12px; color: var(--text-sub); }
.board-empty { font-size: 13px; color: var(--text-sub); padding: 8px 0; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; font-size: 14px;
}
.rank-item:nth-child(odd) { background: #FAFAFA; }
.rank-item.me { background: #FFF6EC; font-weight: 600; }
.rank-no {
  flex: 0 0 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 50%; background: #EEE; color: #666; font-size: 12px;
}
.rank-no.top { background: var(--star); color: #fff; font-weight: 700; }
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: var(--brand-dark); font-weight: 600; }
.board-me {
  margin-top: 10px; padding: 8px 10px; background: #FFF9F2;
  border-radius: 8px; font-size: 13px; color: #8A4B10;
}
