:root {
  --bg: #fbfaf8;
  --card: #ffffff;
  --line: #e6e3dd;
  --line-soft: #f0ede8;
  --ink: #1b1a18;
  --ink-2: #55514b;
  --ink-3: #8d867c;
  --accent: #2f5fd0;
  /* 平台色不在这里——它们在各平台官方 logo 上，统一放在 app.js 的 PLAT 里 */
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* 组件类里的 display 会盖掉浏览器对 [hidden] 的默认 display:none，统一兜住 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #f2efe9;
  padding: 1px 5px;
  border-radius: 4px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- head ---------- */

.site-head { border-bottom: 1px solid var(--line); padding: 26px 0 20px; background: var(--card); }
.site-head h1 {
  margin: 0 0 4px;
  font-size: 21px;
  line-height: 1.4;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.stamp { margin: 0; font-size: 13px; color: var(--ink-3); font-family: var(--mono); }

/* ---------- sections ---------- */

.section { padding: 28px 0; border-bottom: 1px solid var(--line-soft); }
.section:last-of-type { border-bottom: none; }
#works { padding-top: 22px; }

.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.note { margin: 0; max-width: 76ch; color: var(--ink-2); font-size: 14px; }
.note strong { color: var(--ink); font-weight: 600; }
.hint { margin: 8px 2px 0; font-size: 13px; color: var(--ink-3); }

/* ---------- toolbar ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
/* 两个控件必须等高：原生 select 的盒模型和 input 不是一套，
   不写死同一个 height，实测差 5px，看着就分成两组了。 */
.toolbar input[type="search"] {
  flex: 1 1 240px; min-width: 180px;
  font: inherit; font-size: 14px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink);
}
/* 箭头自己画：浏览器原生那个 chevron 的颜色、粗细、离右边框多远都改不了，
   和输入框的一像素描边不是一种风格。appearance:none 之后 select 退化成
   普通盒子，padding 和 input 走同一套算法，高度也就跟着对齐了。 */
.toolbar select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-size: 14px; height: 38px; padding: 0 32px 0 12px;
  border: 1px solid var(--line); border-radius: 6px; background-color: var(--card); color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238d867c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  cursor: pointer;
}
.toolbar input:focus, .toolbar select:focus { outline: 2px solid rgba(47, 95, 208, 0.35); outline-offset: 1px; }
.count { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

/* 作品表限高，自己在框里滚，不把整页撑长。表头 sticky 在框顶。 */
.works-scroll { max-height: min(72vh, 780px); overflow-y: auto; }

table.works { width: 100%; border-collapse: collapse; font-size: 14px; }
table.works th {
  text-align: left; font-weight: 560; font-size: 12px; color: var(--ink-3);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fcfbf9; position: sticky; top: 0; z-index: 1;
}
table.works td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.works tbody tr { cursor: pointer; }
table.works tbody tr:hover { background: #fafaf8; }
table.works tbody tr:last-child td { border-bottom: none; }
.col-num { text-align: right; }
td.col-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-date { width: 88px; }
td.col-date { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
td.col-topic { min-width: 240px; }
td.col-topic .t { color: var(--ink); }
td.col-topic .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
/* 一个有效平台都没有的期：整行压暗，别和数据行抢注意力。
   这种期仍然要留在表里（「有记录但还没补数」也是真实状态），只是不该看着像有数据。 */
table.works tbody tr.is-empty td.col-topic .t { color: var(--ink-3); }
.col-dim { color: var(--ink-3); }

/* 每个平台一列播放量：竖着扫才能比高低 */
.col-platnum { width: 66px; }
td.col-platnum.none { color: #c9c3b9; }
.col-total { width: 68px; }
td.col-total { font-weight: 620; }
/* 效率列的字比播放数长一点（「1.4%」），窄了会换行 */
.col-rate { width: 86px; }

/* 列头可点排序，所以要有可点的样子 */
table.works th { cursor: pointer; user-select: none; }
table.works th:hover { color: var(--ink); background: #f6f4f0; }
table.works th.sorted { color: var(--ink); }
table.works th .pdot { margin-right: 6px; }

.pdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.empty { color: var(--ink-3); font-size: 14px; padding: 20px 12px; }

/* 那排彩色点没解释就等于没说，所以图例是常驻的，不是可选的装饰 */
.plat-legend {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 2px 10px; font-size: 12.5px; color: var(--ink-2);
}
.plat-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.plat-legend .lg-label { color: var(--ink-3); }
.plat-legend .lg-note { color: var(--ink-3); }
.plat-legend .lg-sep { width: 1px; height: 13px; background: var(--line); }

table.plat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plat-table th {
  text-align: right; font-weight: 560; font-size: 12px; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fcfbf9; white-space: nowrap;
}
table.plat-table th:first-child { text-align: left; }
table.plat-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.plat-table td:first-child { text-align: left; }
table.plat-table tr:last-child td { border-bottom: none; }
table.plat-table .plat-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 560; }
table.plat-table .dim { color: var(--ink-3); }

/* ---------- charts ---------- */

.chart-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-toolbar button {
  font: inherit; font-size: 13px; padding: 5px 12px; cursor: pointer;
  background: var(--card); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 20px;
}
.chart-toolbar button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chart-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .legend-note { flex-basis: 100%; color: var(--ink-3); }

.grid-line { stroke: var(--line-soft); stroke-width: 1; }
.axis-text { fill: var(--ink-3); font-size: 11px; font-family: var(--mono); }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-dot { stroke: #fff; stroke-width: 1.5; }
.hover-band { fill: transparent; }
.hover-band:hover { fill: rgba(47, 95, 208, 0.05); }

.tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #1b1a18; color: #fff; border-radius: 6px;
  padding: 8px 11px; font-size: 12px; line-height: 1.65;
  max-width: 300px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font-variant-numeric: tabular-nums;
}

/* ---------- 平台指标切换 ---------- */

/* 表格的形制不变，只换那四列显示哪个指标。
   展开行试过：一行 44px 一行 400px，扫读节奏全被打断，所以明细回抽屉。 */
.metric-bar { display: inline-flex; gap: 4px; }
.metric-bar button {
  font: inherit; font-size: 12.5px; padding: 3px 10px; cursor: pointer;
  background: var(--card); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 20px;
}
.metric-bar button:hover { background: #f6f4f0; }
.metric-bar button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 平台列表头两行：上行平台名，下行当前指标。表头是 sticky 的，
   滚下去之后这几列是什么指标还得看得见。 */
table.works th .th-plat { display: block; }
table.works th .th-metric {
  display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); margin-top: 1px;
}
table.works th.sorted .th-metric { color: var(--ink-2); }

/* ---------- 详情抽屉 ---------- */

.drawer-mask { position: fixed; inset: 0; background: rgba(20, 19, 17, 0.32); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 94vw);
  background: var(--card); border-left: 1px solid var(--line);
  z-index: 51; overflow-y: auto; padding: 26px 28px 60px;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
}
.drawer-close {
  position: sticky; top: 0; float: right; margin: -8px -12px 8px 0;
  font: inherit; font-size: 13px; padding: 5px 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; color: var(--ink-2);
}
.drawer h3 { margin: 0 0 6px; font-size: 19px; line-height: 1.4; font-weight: 650; }
.drawer .d-meta { font-size: 13px; color: var(--ink-3); font-family: var(--mono); margin-bottom: 20px; }
.drawer h4 {
  margin: 26px 0 10px; font-size: 13px; font-weight: 620;
  color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase;
}
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini th {
  text-align: right; font-weight: 560; font-size: 12px; color: var(--ink-3);
  padding: 7px 9px; border-bottom: 1px solid var(--line);
}
table.mini th:first-child { text-align: left; }
table.mini td { padding: 8px 9px; border-bottom: 1px solid var(--line-soft); text-align: right; font-variant-numeric: tabular-nums; }
/* 抽屉里「收藏率」下面那行算式，和作品表表头小字同一套写法 */
table.mini th .th-metric { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); margin-top: 1px; }
table.mini tbody tr:last-child td { border-bottom: none; }
table.mini td:first-child { text-align: left; }
.plat-name { display: inline-flex; align-items: center; gap: 7px; }
.src-links { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.src-links a { border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; background: var(--card); }
.src-links a:hover { background: #f2f0ec; text-decoration: none; }
.script p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.85; }
mark { background: #fdf0c8; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- 口径表 ---------- */

/* 说明表，和上面几张数字表是两回事：这里的单元格要能换行。
   数字表全是 nowrap，因为那些格子装的是同一个量、要竖着扫；
   这两张装的是句子，挤成一行就读不了了。 */
table.gloss { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.gloss th {
  text-align: left; font-weight: 560; font-size: 12px; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fcfbf9; white-space: nowrap;
}
table.gloss td {
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top; color: var(--ink-2); line-height: 1.7;
}
table.gloss tbody tr:last-child td { border-bottom: none; }
table.gloss td:first-child { color: var(--ink); white-space: nowrap; }
.gloss-sub { margin: 24px 0 12px; }
.gloss-sub h3 { margin: 0; font-size: 15px; font-weight: 620; }

/* 搜索命中的那条平台标题。它和主题不一样，得让人看得出是在哪儿命中的 */
.sub-hit { color: var(--ink-2); }
/* 链接指向创作者后台时不给链接，但也不能什么都不说 */
.src-none {
  border: 1px dashed var(--line); border-radius: 6px; padding: 4px 10px;
  color: var(--ink-3); font-size: 13px;
}

/* 封面：三种比例各自独立上传，不是同一张图裁的。
   横图给宽、竖图给窄，用 object-fit 保比例不裁切。 */
.covers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 10px 0 22px;
}
.covers .cover { margin: 0; display: flex; flex-direction: column; gap: 7px; }
.covers .cover a { display: block; line-height: 0; }
.covers .cover img {
  width: 100%; height: auto; display: block;
  border-radius: 7px; border: 1px solid var(--line-soft);
  background: var(--bg-soft);
}
.covers .cover.is-missing .cover-ph {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; border-radius: 7px;
  border: 1px dashed var(--line); color: var(--ink-3);
  font-size: 12.5px; text-align: center; padding: 8px;
  background: var(--bg-soft);
}
.covers .cover figcaption { display: flex; flex-direction: column; gap: 2px; }
.covers .cover figcaption b { font-size: 13px; font-weight: 600; color: var(--ink); }
.covers .cover figcaption span { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }

.site-foot { padding: 30px 0 56px; border-top: 1px solid var(--line); margin-top: 8px; }
.site-foot p { margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }

@media (max-width: 720px) {
  .site-head { padding: 20px 0 16px; }
  .site-head h1 { font-size: 18px; }
  .wrap { padding: 0 16px; }
  .section { padding: 22px 0; }
  .works-scroll { max-height: 64vh; }
  .drawer { padding: 20px 18px 50px; }
  .metric-bar button { padding: 3px 8px; }
  /* 窄屏上第一列的 nowrap 会把整张表顶出去 */
  table.gloss td:first-child { white-space: normal; }
}

/* ---------- 粉丝 ---------- */

/* 四张卡片等宽，窗口窄了自己折行。粉丝是账号级的存量，
   和下面那张「一行一期」的作品表不是一套东西，所以单独成块、单独排版。 */
.follow-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.follow-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
}
/* 没采到的平台压暗，但卡片照旧占位——缺四个里的哪一个要一眼看得见，
   悄悄少一张卡反而会被当成那个平台不存在。 */
.follow-card.is-missing { background: #fcfbf9; }
.follow-card.is-missing .fc-num { color: #c9c3b9; }
.fc-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-2); font-weight: 560;
}
.fc-num {
  margin-top: 6px;
  font-size: 28px; line-height: 1.15; font-weight: 640;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.fc-sub { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.fc-sub .fc-up { color: #1a7f37; font-variant-numeric: tabular-nums; font-weight: 560; }
.fc-sub .fc-down { color: #b3261e; font-variant-numeric: tabular-nums; font-weight: 560; }
.fc-sub .fc-flat { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fc-sub .fc-since { color: var(--ink-3); }
/* 涨粉曲线的小格标签：平台名照平台色，范围用灰字跟着，
   让人一眼知道这格的纵轴是放大过的。（SVG 里的字号用 fill 控制，不能用 CSS 的 color） */
.facet-label { font-size: 12px; fill: var(--ink-2); font-weight: 560; }
.facet-label .facet-range { fill: var(--ink-3); font-weight: 400; font-family: var(--mono); font-size: 11px; }
