/* ============================================================
   今日热榜（多平台榜单）— 5 模式：实时 / 历史回放 / 时段分析 / 累计排行 / 已下榜
   数据源：ES weibo_trending / hotrank_snapshot（后端 /api/hotrank/es/* 代理）
   颜色复用 layout-styles.css 的主题变量，自适应明暗主题
   ============================================================ */

.hotrank-app { display: flex; flex-direction: column; gap: 12px; height: calc(var(--fit-vh, var(--fit-vh, var(--fit-vh, 100vh))) - var(--header-height, 0px) - 118px); min-height: 520px; }

/* ---------- 顶栏 ---------- */
.hk-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 10px 16px; }
.hk-viewswitch { display: inline-flex; background: var(--bg-input); border-radius: 9px; padding: 3px; gap: 2px; }
.hk-viewswitch .hk-vs { border: none; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; font-family: inherit; transition: .15s; }
.hk-viewswitch .hk-vs:hover { color: var(--accent); }
.hk-viewswitch .hk-vs.on { background: var(--bg-card); color: var(--accent); font-weight: 700; box-shadow: 0 1px 4px rgba(15,23,42,.15); }
.hk-stat { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.hk-livebadge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--success); background: rgba(74,222,128,.12); border: 1px solid rgba(74,222,128,.3); border-radius: 20px; padding: 5px 12px; white-space: nowrap; }
.hk-livebadge i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: hkPulse 1.6s infinite; }
.hk-btn { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-muted); font-size: 15px; cursor: pointer; transition: .15s; line-height: 1; }
.hk-btn:hover { border-color: var(--accent); color: var(--accent); }
@keyframes hkPulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- 主体两栏 ---------- */
.hk-app { display: grid; grid-template-columns: 210px 1fr; gap: 12px; align-items: start; min-height: 0; flex: 1; }

/* ---------- 侧边栏 ---------- */
.hk-side { position: sticky; top: 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 10px; max-height: calc(var(--fit-vh, var(--fit-vh, var(--fit-vh, 100vh))) - 160px); overflow-y: auto; }
.hk-stitle { font-size: 11px; color: var(--text-muted); font-weight: 700; letter-spacing: 2px; padding: 4px 10px 8px; }
.hk-pi { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; flex: 0 0 28px; overflow: hidden; background: var(--bg-input); border: 1px solid var(--border-color); }
.hk-pi .hk-pi-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hk-pn { font-size: 13px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.hk-cnt { font-size: 10.5px; color: var(--text-muted); background: var(--bg-input); border-radius: 20px; padding: 1px 8px; flex: 0 0 auto; font-weight: 600; }

/* 一级平台 */
.hk-plat { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; transition: .15s; position: relative; }
.hk-plat:hover { background: var(--bg-input); }
.hk-plat.active { background: var(--accent-glow); }
.hk-plat.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), #818cf8); }
.hk-plat.active .hk-pn { color: var(--accent); font-weight: 700; }

/* ---------- 主区 ---------- */
.hk-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hk-phead { display: flex; align-items: center; gap: 14px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px; padding: 14px 20px; box-shadow: var(--shadow-sm); }
.hk-pi.big { width: 46px; height: 46px; font-size: 22px; border-radius: 12px; flex: 0 0 46px; background: var(--bg-input); border: 1px solid var(--border-color); }
.hk-pname { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 9px; color: var(--text-primary); }
.hk-psep { color: var(--border-color); font-weight: 400; }
.hk-bname { font-size: 14px; font-weight: 700; color: var(--accent); }
.hk-live { font-size: 11px; color: var(--success); background: rgba(74,222,128,.12); border: 1px solid rgba(74,222,128,.3); border-radius: 20px; padding: 2px 9px; display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.hk-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: hkPulse 1.4s infinite; }
.hk-live.hist { color: var(--warning); background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.3); }
.hk-live.hist i { background: var(--warning); }
.hk-pmeta { font-size: 12.5px; margin-top: 3px; color: var(--text-muted); }

/* ---------- 卡片 ---------- */
.hk-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px 16px 16px; }
.hk-modetabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.hk-tab { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); cursor: pointer; font-size: 12.5px; color: var(--text-muted); transition: .15s; font-family: inherit; }
.hk-tab:hover { border-color: var(--accent); color: var(--accent); }
.hk-tab.active { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.hk-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; min-height: 30px; }
.hk-sbtn { padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); font-size: 12.5px; color: var(--text-muted); cursor: pointer; font-family: inherit; transition: .15s; }
.hk-sbtn:hover { border-color: var(--accent); color: var(--accent); }
.hk-sbtn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.hk-ctl input[type=datetime-local], .hk-ctl input[data-time] { padding: 5px 9px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-input); color: var(--text-primary); }
.hk-ctl input[type=datetime-local]:focus, .hk-ctl input[data-time]:focus { border-color: var(--accent); background: var(--bg-card); }
.hk-ctl select { padding: 5px 10px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-input); cursor: pointer; color: var(--text-primary); }
.hk-frameinfo { font-size: 11.5px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* 时间刻度尺 */
.hk-ruler { display: flex; align-items: flex-start; flex: 1; min-width: 240px; position: relative; padding: 4px 10px 0; margin: 0 4px; }
.hk-ruler::before { content: ""; position: absolute; left: 22px; right: 22px; top: 9px; height: 2px; background: var(--border-color); border-radius: 2px; }
.hk-tick { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; cursor: pointer; gap: 6px; }
.hk-tick-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bg-card); border: 2px solid var(--border-color); position: relative; z-index: 1; transition: .12s; flex: 0 0 12px; }
.hk-tick:hover .hk-tick-dot { border-color: var(--accent); }
.hk-tick.active .hk-tick-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(2,132,199,.16); }
.hk-tick-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1; }
.hk-tick.active .hk-tick-label { color: var(--accent); font-weight: 700; }
.hk-tick-empty { cursor: default; opacity: .35; }
.hk-tick-empty .hk-tick-dot { border-style: dashed; }

.hk-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.hk-searchbox { position: relative; }
.hk-searchbox .hk-sicon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .5; pointer-events: none; line-height: 1; }
.hk-toolbar input { padding: 6px 12px 6px 28px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12.5px; width: 200px; outline: none; font-family: inherit; background: var(--bg-input); color: var(--text-primary); transition: .15s; }
.hk-toolbar input:focus { border-color: var(--accent); background: var(--bg-card); }
.hk-toolbar select { padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12.5px; background: var(--bg-input); font-family: inherit; outline: none; cursor: pointer; color: var(--text-primary); }
.hk-cmpbtn { padding: 6px 13px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); font-size: 12.5px; color: var(--text-muted); cursor: pointer; font-family: inherit; transition: .15s; }
.hk-cmpbtn:hover { border-color: var(--accent); color: var(--accent); }
.hk-cmpbtn.on { background: var(--accent); color: #fff; border-color: transparent; }
.hk-boardmeta { margin-left: auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.hk-boardmeta b { color: var(--accent); font-weight: 700; }

/* ---------- 榜单列表 ---------- */
.hk-cards { display: grid; grid-template-columns: 1fr; gap: 5px; }
/* 榜单列表容器（单平台视图 = .hk-cards，矩阵视图 = .hk-ovl-grid）：
   父级高度受限时在容器内滚动，长榜单不会被裁掉 */
#tbody { min-height: 0; }
.hk-tcard { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 9px; padding: 4px 12px; transition: .15s; cursor: pointer; }
.hk-tcard:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(15,23,42,.08); }
.hk-tcard.zebra { background: var(--bg-input); }
.hk-rk { width: 22px; height: 22px; min-width: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-muted); background: var(--bg-input); font-weight: 700; flex-shrink: 0; }
.hk-rk.hk-r1 { background: linear-gradient(135deg,#FEF3C7,#F59E0B); color: #78350F; }
.hk-rk.hk-r2 { background: linear-gradient(135deg,#F1F5F9,#94A3B8); color: #1E293B; }
.hk-rk.hk-r3 { background: linear-gradient(135deg,#FFEDD5,#D97706); color: #7C2D12; }
.hk-rk.hk-pinned { width: auto; min-width: 28px; padding: 0 2px; background: transparent; box-shadow: none; }
.hk-rk.hk-pinned img { height: 14px; width: auto; display: block; }
.hk-tcard.hk-tcard-pinned { background: rgba(220,38,38,.06); border-color: rgba(220,38,38,.35); box-shadow: 0 2px 8px rgba(220,38,38,.10); }
.hk-tcard.hk-tcard-pinned:hover { border-color: rgba(220,38,38,.55); background: rgba(220,38,38,.09); }
.hk-topic { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hk-tcard:hover .hk-topic { color: var(--accent); }
.hk-tcmeta { display: flex; align-items: baseline; flex-shrink: 0; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.hk-tcmeta .hk-m { display: inline-flex; align-items: baseline; gap: 3px; overflow: hidden; flex: 0 0 auto; }
.hk-tcmeta .hk-m b { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.hk-tcmeta i { font-style: normal; color: var(--border-color); margin: 0 5px; font-weight: 300; }
.hk-empty { text-align: center; color: var(--text-muted); padding: 38px; font-size: 13.5px; grid-column: 1/-1; }

/* 变化徽章 */
.hk-chg { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 6px; font-size: 10.5px; font-weight: 700; flex: 0 0 auto; }
.hk-chg.hk-up { color: var(--success); background: rgba(74,222,128,.15); }
.hk-chg.hk-down { color: var(--danger); background: rgba(248,113,113,.15); }
.hk-chg.hk-same { color: var(--text-muted); background: var(--bg-input); }
.hk-chg.hk-new { color: #b7791f; background: rgba(245,158,11,.15); }

/* ---------- 双帧对比 ---------- */
.hk-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.hk-cmpbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.hk-cmpbar-tip { font-size: 12px; color: var(--text-muted); }
.hk-cpanel { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 12px 14px 14px; }
.hk-chead { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: var(--text-primary); padding: 2px 4px 10px; border-bottom: 1px dashed var(--border-color); margin-bottom: 10px; }
.hk-chead em { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.hk-chead em.new { color: var(--accent); background: rgba(2,132,199,.12); }
.hk-chead em.old { color: var(--text-muted); background: var(--bg-input); }
.hk-clist { display: flex; flex-direction: column; gap: 5px; }

/* ---------- 矩阵总览 ---------- */
.hk-ovl { display: grid; gap: 10px; align-items: start; }
.hk-ovl-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
/* 矩阵卡片：固定高度，榜单在卡内滚动（在榜多少条就展示多少条，不再截断） */
.hk-gridcard { display: flex; flex-direction: column; height: var(--hk-grid-card-h, 460px); overflow: hidden; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 12px 14px; }
.hk-gridbody { flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.hk-gridhead { display: flex; align-items: center; gap: 8px; padding-bottom: 9px; margin-bottom: 8px; border-bottom: 1px solid var(--border-color); flex: none; }
.hk-gridhead .hk-sn { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.hk-gridhead .hk-sc { margin-left: auto; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.hk-gridrow { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.hk-gridrow:hover { background: var(--bg-input); }
.hk-gridrow .hk-gr { width: 18px; height: 18px; border-radius: 50%; background: var(--bg-input); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex: 0 0 18px; }
.hk-gridrow .hk-gr.hk-gr-pinned { width: auto; height: 18px; padding: 0 4px; background: transparent; }
.hk-gridrow .hk-gr.hk-gr-pinned img { height: 12px; width: auto; display: block; }
.hk-gridrow.hk-gridrow-pinned { background: rgba(220,38,38,.06); }
.hk-gridrow.hk-gridrow-pinned:hover { background: rgba(220,38,38,.10); }
.hk-gridrow .hk-gt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); font-weight: 600; }
.hk-gridrow .hk-gh { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 11px; }

/* ---------- 话题画像弹窗 ---------- */
.hk-modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.hk-modal.open { display: flex; }
.hk-mcard { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 20px 50px rgba(16,24,40,.18); width: min(720px, 94vw); max-height: 88vh; overflow: auto; padding: 18px 22px 20px; }
.hk-mhead { display: flex; align-items: center; gap: 10px; margin: -18px -22px 14px; padding: 14px 22px; border-bottom: 1px solid var(--border-color); background: var(--bg-input); }
.hk-mhead .hk-mtag { font-size: 11px; font-weight: 700; color: var(--accent); background: rgba(2,132,199,.12); border-radius: 8px; padding: 3px 9px; flex: 0 0 auto; }
.hk-mhead .hk-topbadge { font-size: 11px; font-weight: 800; color: #78350F; background: linear-gradient(135deg,#FEF3C7,#F59E0B); border-radius: 8px; padding: 3px 9px; flex: 0 0 auto; }
.hk-mhead .hk-mname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 700; color: var(--text-primary); }
.hk-mhead .hk-detail { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(2,132,199,.10); border: 1px solid rgba(2,132,199,.28); border-radius: 8px; padding: 4px 10px; text-decoration: none; white-space: nowrap; transition: .15s; }
.hk-mhead .hk-detail:hover { background: var(--accent); color: #fff; border-color: transparent; }
.hk-mclose { width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--bg-input); color: var(--text-muted); font-size: 14px; cursor: pointer; line-height: 1; flex: 0 0 26px; }
.hk-mclose:hover { background: var(--border-color); }
.hk-offtxt { color: var(--danger); font-size: 12.5px; }
.hk-charttitle { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 16px 0 8px; }
.hk-spark { width: 100%; height: auto; display: block; }
.hk-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.hk-chartempty { color: var(--text-muted); font-size: 12px; padding: 14px; text-align: center; background: var(--bg-input); border-radius: 10px; }
.hk-metricgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.hk-pi2 { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; padding: 8px 10px; }
.hk-pi2 label { display: block; font-size: 10.5px; color: var(--text-muted); margin-bottom: 3px; }
.hk-pi2 b { font-size: 14px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.hk-xrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; font-size: 12px; margin-bottom: 6px; }
.hk-xrow .hk-xt { flex: 1; min-width: 0; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hk-xrow .hk-xr { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hk-xrow .hk-xh { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hk-xrow .hk-xs { width: 34px; text-align: center; }
.hk-xrow .hk-xgo { color: var(--accent); font-weight: 700; text-decoration: none; flex: 0 0 auto; }
.hk-xrow .hk-xgo:hover { text-decoration: underline; }
.hk-on { color: var(--success); }
.hk-off { color: var(--danger); }
/* 上榜明细（话题画像弹窗）：每次上榜的起止时间 */
.hk-spannote { font-size: 12px; color: var(--text-muted); padding: 8px 10px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; }
.hk-spanlist { max-height: 240px; overflow-y: auto; }
.hk-sprow { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; font-size: 12px; margin-bottom: 6px; }
.hk-spidx { flex: 0 0 46px; color: var(--text-muted); font-weight: 700; }
.hk-sptime { flex: 1; min-width: 0; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hk-spsep { color: var(--text-muted); }
.hk-spdur { flex: 0 0 auto; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.hk-mfoot { display: flex; align-items: center; justify-content: space-between; margin: 16px -22px -20px; padding: 12px 22px; border-top: 1px solid var(--border-color); background: var(--bg-input); }
.hk-mhint { font-size: 11px; color: var(--text-muted); }

/* FLIP 回放动效 */
@keyframes hkFlipNew { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.hk-tcard.hk-flip-new { animation: hkFlipNew .4s ease backwards; }

/* ---------- 矩阵导出弹窗（窄版：时间放一排） ---------- */
.hk-mcard.hk-xcard { width: 30vw; min-width: 380px; max-width: 560px; }
.hk-xrow1 { display: flex; align-items: center; gap: 8px; }
.hk-xrow1 input { flex: 1 1 0; min-width: 0; padding: 7px 9px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-input); color: var(--text-primary); cursor: pointer; }
.hk-xrow1 input:focus { border-color: var(--accent); background: var(--bg-card); }
.hk-xtilde { flex: 0 0 auto; color: var(--text-muted); }
.hk-xnote { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }
.hk-mxprog { min-height: 20px; font-size: 12.5px; color: var(--text-primary); margin-top: 8px; }
.hk-mxprog b { color: var(--accent); }
.hk-xerr { color: var(--danger); }
.hk-xhint2 { font-size: 12px; color: var(--text-muted); }
.hk-mfoot2 { display: flex; justify-content: flex-end; gap: 10px; margin: 14px -22px -20px; padding: 12px 22px; border-top: 1px solid var(--border-color); background: var(--bg-input); }
.hk-sbtn[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
html:not([data-fit]) .hk-app { grid-template-columns: 1fr; }
html:not([data-fit]) .hk-side { position: static; max-height: none; }
html:not([data-fit]) .hk-compare { grid-template-columns: 1fr; }
html:not([data-fit]) .hk-stat { margin-left: 0; }
}
@media (max-width: 660px) {
html:not([data-fit]) .hk-tcmeta { display: none; }
html:not([data-fit]) .hk-cards { grid-template-columns: 1fr; }
}
