/* ============================================================
   热榜聚合 — 模块样式
   复用主站 design token（颜色/圆角/阴影），
   仅在 :root 覆盖本页强调色（红橙）。
   ============================================================ */

:root {
  --thb-accent: #ef4444;        /* 红 */
  --thb-accent-2: #f97316;      /* 橙 */
  --thb-accent-soft: #fef2f2;
  --thb-rank-1: #ef4444;
  --thb-rank-2: #f97316;
  --thb-rank-3: #eab308;
  --thb-tag-hot: #ef4444;
  --thb-tag-new: #3b82f6;
  --thb-tag-boom: #f97316;
  --thb-tag-boil: #a855f7;
  --thb-tag-rec: #22c55e;
}
[data-theme='dark'] {
  --thb-accent-soft: rgba(239, 68, 68, .12);
}

.thb-main {
  padding: calc(var(--header-h) + 16px) 0 56px;
  min-height: 70vh;
}
.thb-container { }

/* ---- 顶部广告横幅 ---- */
.thb-banner {
  display: block;
  margin-bottom: 18px;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  box-shadow: var(--shadow-sm);
  background: var(--bg-soft);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.thb-banner:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.thb-banner img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 110px;
  object-fit: cover;
  object-position: center;
}
@media (max-width: 640px) {
  .thb-banner img { max-height: 70px; }
}

/* ---- 顶栏 ---- */
.thb-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.thb-title-block { min-width: 0; flex: 1 1 320px; }
.thb-title {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: 1px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.thb-fire { font-size: 22px; }
.thb-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}
.thb-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.thb-updated {
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
#thbRefresh {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 50%;
}
#thbRefresh svg { width: 16px; height: 16px; fill: var(--text-2); }
#thbRefresh:hover svg { fill: var(--thb-accent); transform: rotate(120deg); transition: transform .4s; }

/* ---- 主区双列布局 ---- */
.thb-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.thb-main-area { min-width: 0; }
@media (max-width: 900px) {
  .thb-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* ---- 侧栏（分类）---- */
.thb-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 0;
  max-height: calc(100vh - var(--header-h) - 24px);
  overflow-y: auto;
}
.thb-sidebar::-webkit-scrollbar { width: 4px; }
.thb-sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.thb-cat {
  margin-bottom: 4px;
}
.thb-cat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.thb-cat-head .ico { font-size: 15px; }
.thb-cat-head .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-soft);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 500;
}
.thb-cat.is-open > .thb-cat-head { color: var(--thb-accent); }
.thb-cat.is-open > .thb-cat-head .count { background: var(--thb-accent-soft); color: var(--thb-accent); }

.thb-sources {
  display: none;
  padding: 0 8px 6px 36px;
}
.thb-cat.is-open .thb-sources { display: block; }
.thb-source {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  margin: 1px 0;
  transition: all .12s;
}
.thb-source:hover { background: var(--bg-soft); color: var(--text); }
.thb-source.is-active {
  background: var(--thb-accent-soft);
  color: var(--thb-accent);
  font-weight: 600;
}

/* ---- 移动端：分类折叠为顶部滚动 tab ---- */
.thb-mobile-tabs {
  display: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.thb-mobile-tabs::-webkit-scrollbar { display: none; }
.thb-mobile-tabs .mtab {
  background: none; border: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  position: relative; bottom: -1px;
  font-family: inherit;
}
.thb-mobile-tabs .mtab.is-active {
  color: var(--thb-accent);
  border-bottom-color: var(--thb-accent);
  font-weight: 600;
}
@media (max-width: 900px) {
  .thb-sidebar { display: none; }
  .thb-mobile-tabs { display: flex; }
}

/* ---- 来源头部（主区顶部）---- */
.thb-source-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.thb-source-avatar {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--thb-accent), var(--thb-accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.thb-source-info { min-width: 0; flex: 1; }
.thb-source-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}
.thb-source-sub {
  font-size: 12px;
  color: var(--text-3);
}
.thb-source-home {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-2);
  text-decoration: none;
  transition: all .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.thb-source-home:hover { border-color: var(--thb-accent); color: var(--thb-accent); }

/* ---- 条目列表 ---- */
/* ---- 卡片网格视图（默认）---- */
.thb-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.thb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  min-width: 0;
}
.thb-card:hover {
  border-color: var(--thb-accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.thb-card.is-focus {
  border-color: var(--thb-accent);
  box-shadow: 0 0 0 3px var(--thb-accent-soft), var(--shadow);
  animation: thbFocusPulse 1.4s ease-out 2;
}
@keyframes thbFocusPulse {
  0%   { box-shadow: 0 0 0 0   var(--thb-accent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

.thb-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  gap: 6px;
  min-width: 0;
}
.thb-card-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  min-width: 0;
}
.thb-card-mark {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--thb-accent), var(--thb-accent-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.thb-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}
.thb-card-tag {
  font-size: 10px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.thb-card-list {
  list-style: none;
  padding: 4px 0;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.thb-card-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.45;
  min-width: 0;
  transition: background .1s;
}
.thb-card-item:hover { background: var(--bg-soft); }
.thb-card-rank {
  width: 18px;
  flex-shrink: 0;
  text-align: center;
  font-weight: 700;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  color: var(--text-3);
  font-size: 12px;
  padding-top: 1px;
}
.thb-card-rank.thb-rank-1 { color: var(--thb-rank-1); }
.thb-card-rank.thb-rank-2 { color: var(--thb-rank-2); }
.thb-card-rank.thb-rank-3 { color: var(--thb-rank-3); }
.thb-card-link {
  flex: 1;
  color: var(--text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: color .12s;
  line-height: 1.45;
}
.thb-card-link:hover { color: var(--thb-accent); }
.thb-card-meta {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-3);
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  font-weight: 500;
}

.thb-card-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}
.thb-card-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--thb-accent);
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 4px;
  animation: thbSpin 1s linear infinite;
}
@keyframes thbSpin { to { transform: rotate(360deg); } }

.thb-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 11px;
  color: var(--text-3);
}
.thb-card-stat { color: var(--text-3); }
.thb-card-more {
  color: var(--thb-accent);
  text-decoration: none;
  font-weight: 600;
}
.thb-card-more:hover { text-decoration: underline; }

/* 返回卡片视图按钮 */
.thb-back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 12px;
  font-family: inherit;
}
.thb-back-btn:hover { border-color: var(--thb-accent); color: var(--thb-accent); }

/* ---- 条目列表（详情视图）---- */
.thb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.thb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.thb-item:last-child { border-bottom: 0; }
.thb-item:hover { background: var(--bg-soft); }

.thb-rank {
  width: 28px;
  font-size: 18px;
  font-weight: 800;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-3);
}
.thb-item:nth-child(1) .thb-rank { color: var(--thb-rank-1); }
.thb-item:nth-child(2) .thb-rank { color: var(--thb-rank-2); }
.thb-item:nth-child(3) .thb-rank { color: var(--thb-rank-3); }

.thb-title-cell {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.thb-link {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  transition: color .12s;
}
.thb-link:hover { color: var(--thb-accent); }
.thb-link::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: -1px;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7zM19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7z'/></svg>") no-repeat center / contain;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7zM19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7z'/></svg>") no-repeat center / contain;
  opacity: .4;
}
.thb-link:hover::after { opacity: 1; background: var(--thb-accent); }

.thb-tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}
.thb-tag.tag-热 { background: var(--thb-tag-hot); }
.thb-tag.tag-新 { background: var(--thb-tag-new); }
.thb-tag.tag-爆 { background: var(--thb-tag-boom); }
.thb-tag.tag-沸 { background: var(--thb-tag-boil); }
.thb-tag.tag-荐, .thb-tag.tag-推荐 { background: var(--thb-tag-rec); }
.thb-tag.tag-default { background: var(--text-3); }

/* 缓存角标（出现在来源名称旁）*/
.thb-cache-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-3);
  font-weight: 500;
  margin-left: 4px;
  vertical-align: 1px;
}

/* 发布时间（条目右侧的小字）*/
.thb-time {
  font-size: 11px;
  color: var(--text-3);
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  flex-shrink: 0;
  min-width: 90px;
  text-align: right;
}

/* 来源平台 tag（条目右侧） */
.thb-srctag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-3);
  font-weight: 500;
  flex-shrink: 0;
  text-transform: lowercase;
  letter-spacing: .3px;
}

/* 重试按钮 */
.thb-empty button { font-family: inherit; }

.thb-heat {
  font-size: 12px;
  color: var(--text-3);
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

/* ---- 空状态 ---- */
.thb-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 14px;
}
.thb-empty .emo { font-size: 36px; margin-bottom: 8px; }

/* ---- 响应式 ---- */
@media (max-width: 1200px) {
  .thb-cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .thb-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thb-topbar { padding-bottom: 12px; }
  .thb-title { font-size: 22px; }
  .thb-source-head { padding: 12px 14px; gap: 10px; }
  .thb-source-avatar { width: 32px; height: 32px; font-size: 14px; }
  .thb-source-name { font-size: 15px; }
  .thb-source-home { font-size: 11px; padding: 5px 10px; }
  .thb-item { padding: 10px 14px; gap: 10px; }
  .thb-rank { width: 24px; font-size: 16px; }
  .thb-heat { min-width: 70px; }
}
@media (max-width: 640px) {
  .thb-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .thb-title { font-size: 20px; }
  .thb-fire { font-size: 18px; }
  .thb-subtitle { font-size: 12px; }
  .thb-item { padding: 9px 12px; gap: 8px; }
  .thb-link { font-size: 13px; }
  .thb-heat { font-size: 11px; min-width: 60px; }
  .thb-tag { font-size: 10px; padding: 1px 5px; }
  .thb-card-name { font-size: 12px; max-width: 90px; }
  .thb-card-link { font-size: 12px; }
}
@media (max-width: 400px) {
  .thb-cards-grid { grid-template-columns: 1fr; }
  .thb-title { font-size: 18px; }
  .thb-item { flex-wrap: wrap; }
  .thb-heat { width: 100%; text-align: left; padding-left: 40px; min-width: 0; }
  .thb-source-home { font-size: 10px; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .thb-sidebar { width: 200px; }
}