:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* 多人实时光标图层 */
.cursor-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  overflow: hidden;
}
.remote-cursor {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  will-change: transform;
  transition: transform 0.07s cubic-bezier(0.2, 0, 0.2, 1);
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.remote-cursor svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  flex-shrink: 0;
}
.cursor-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translate(2px, 12px);
  user-select: none;
}

/* 页面主布局 */
#app { padding: 0 24px 48px; max-width: 1240px; margin: 0 auto; }
#app[hidden] { display: none; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 18px 0 14px;
  border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
.brand-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.brand-sub { color: var(--muted); margin-left: 8px; font-size: 13px; font-weight: 400; }
.spacer { flex: 1; }

/* 实时在线状态胶囊 */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  color: #065f46;
  font-size: 12px;
  font-weight: 600;
}
.live-indicator {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: live-pulse 2s infinite;
}
@keyframes live-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer; font-size: 13px;
  transition: all 0.15s ease;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tab .badge {
  background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px;
  font-size: 11px; margin-left: 6px; display: inline-block;
}
.tab .badge.zero { background: var(--line); color: var(--muted); }

/* KPI 卡片 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05); }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; color: #0f172a; }
.kpi .v.small { font-size: 20px; }
.kpi .hint { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* 面板通用 */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.panel h2 { font-size: 15px; margin: 0; color: #0f172a; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---------- 2. 全球学习地图（精细浅色地图） ---------- */
.map-panel {
  padding: 18px 20px 22px;
  background: var(--panel);
  border-color: var(--line);
}
.map-stats-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 12px;
  color: #15803d;
  font-weight: 600;
}
.pulse-beacon-demo {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}
.map-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 440px;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.world-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.map-beacons {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* 数据读取失败：整块友好提示，替代 KPI/地图/走势 */
#tab-overview.data-error > .kpis,
#tab-overview.data-error > .panel,
#tab-overview.data-error > .dual-grid { display: none; }
.data-fallback {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 44px 28px 40px;
  text-align: center;
  margin-bottom: 16px;
}
.fallback-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fallback-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.fallback-desc {
  margin: 0 auto 8px;
  max-width: 460px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}
.fallback-desc b { color: var(--text); font-weight: 600; }
.fallback-hint {
  margin: 0 auto 22px;
  max-width: 460px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
.fallback-hint b { color: var(--text); font-weight: 600; }
.fallback-btn {
  padding: 8px 22px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.fallback-btn:hover:not(:disabled) { opacity: 0.88; }
.fallback-btn:disabled { opacity: 0.6; cursor: default; }
.fallback-detail {
  margin: 18px auto 0;
  max-width: 520px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: #94a3b8;
  word-break: break-all;
}
.map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 14px;
  border-radius: 999px;
}
.beacon {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
}
.beacon-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  border: 1.5px solid #ffffff;
}
.beacon-ripple {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(16, 185, 129, 0.5);
  opacity: 0;
  animation: beacon-wave 2.2s infinite ease-out;
}
@keyframes beacon-wave {
  0% { transform: scale(0.4); opacity: 0.9; }
  70% { transform: scale(2.0); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
.beacon-label {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.95);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.map-tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 14px;
  color: #1e293b;
  font-size: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transform: translate(-50%, -120%);
  white-space: nowrap;
  line-height: 1.5;
}
.map-tooltip .tt-city { font-weight: 700; color: #0284c7; font-size: 13px; }
.map-tooltip .tt-info { color: #475569; margin-top: 2px; }
.map-tooltip .tt-lec { color: #d97706; font-weight: 600; margin-top: 1px; }

/* ---------- 3. 双列网格：最硬核讲次榜 + 正在发生 ---------- */
.dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 880px) {
  .dual-grid { grid-template-columns: 1fr; }
}

.live-dot-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 2px 8px;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-weight: 600;
}
.live-dot-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
  animation: live-pulse 1.8s infinite;
}

/* 最硬核讲次列表（极简、大方、无花哨标星） */
.hardcore-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hardcore-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}
.hardcore-item:hover {
  border-color: #cbd5e1;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.rank-badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #ffedd5; color: #9a3412; }
.rank-other { background: #f1f5f9; color: #64748b; }
.hc-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-title a { text-decoration: none; color: inherit; }
.hc-title a:hover { color: var(--accent); }
.hc-title small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: 2px; }
.hc-dwell-time {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* 正在发生：浅色优雅动态流 */
.stream-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
  padding-right: 4px;
}
.stream-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  animation: item-slide 0.25s ease-out;
  transition: all 0.15s ease;
}
.stream-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}
@keyframes item-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.stream-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}
.stream-time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.stream-city {
  background: #eff6ff;
  color: #0284c7;
  border: 1px solid #dbeafe;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  flex-shrink: 0;
}
.stream-act { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.stream-act b { color: #0f172a; font-weight: 600; }

.loading-hint {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 13px;
}

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td { vertical-align: top; }
td.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.num { font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* 标签 */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.chip.k { border-color: var(--accent); color: var(--accent); }
.chip.done { border-color: var(--accent-2); color: var(--accent-2); }
.chip.ignored { color: var(--muted); }
.chip.new { border-color: var(--warn); color: var(--warn); }

/* 按钮 */
button { font-size: 13px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.mini { padding: 3px 9px; font-size: 12px; }

/* 柱状图 */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 172px; padding-top: 20px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.chart .col .bar-c { width: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; height: 120px; }
.chart .col .seg { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); display: block; flex: none; }
.chart .col .seg.uv { background: var(--accent-2); }
/* 柱顶 PV 数字：bar-c 为 column-reverse，seg 贴底、数字紧随其后显示在柱顶上方 */
.chart .col .pv-num { flex: none; font-family: var(--mono); font-size: 9px; line-height: 1; color: var(--text); text-align: center; white-space: nowrap; }
.chart .col .lbl { font-size: 9px; color: var(--muted); white-space: nowrap; }
.chart .legend { color: var(--muted); font-size: 11px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 12px; }

.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.detail { border-left: 2px solid var(--accent); margin: 6px 0 0; padding: 4px 0 4px 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 13px; }
  #app { padding: 0 14px 30px; }
  .brand-sub { display: none; }
}
