:root {
  --bg: #f7f7f5;
  --fg: #141412;
  --muted: #77776f;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ecebe6;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 20px;
  --gap: 18px;
  --gap-v: 28px;
  --max: 2400px;
}

html[data-theme='dark'] {
  --bg: #100f0e;
  --fg: #f2f1ed;
  --muted: #9a9a91;
  --line: rgba(255, 255, 255, 0.1);
  --card: #1d1c1a;
  --glass: rgba(24, 23, 21, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* 打开弹层时会给 body 加 overflow:hidden，页面滚动条消失 → 整页横向跳 15px。
     给 html 常驻滚动条占位，就不会跳。 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(255, 210, 60, 0.5); }

/* ---------- 玻璃质感 ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow);
}

/* ---------- 顶栏 ---------- */
.brand {
  position: fixed;
  top: 14px;
  left: 18px;
  z-index: 30;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  max-width: 100%;
}

.bar .divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: none;
}

.select-wrap { position: relative; display: flex; align-items: center; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 10px;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}

select,
input[type='search'] {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
}

.select-wrap select { padding-right: 26px; }

input[type='search'] {
  cursor: text;
  width: 210px;
  padding-left: 14px;
}

select:hover,
input[type='search']:hover { background: rgba(127, 127, 127, 0.08); }
select:focus-visible,
input[type='search']:focus-visible { background: rgba(127, 127, 127, 0.1); }
input[type='search']::placeholder { color: var(--muted); }

.top-actions { position: fixed; top: 14px; right: 18px; z-index: 30; display: flex; gap: 8px; }

.round {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--fg);
  cursor: pointer;
  border: 1px solid var(--glass-brd);
}
.round:hover { background: rgba(127, 127, 127, 0.1); }

/* ---------- 瀑布流 ---------- */
.board-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px 22px 80px;
}

.board-intro { padding: 6px 4px 18px; max-width: 720px; }
.board-intro h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.board-intro p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* 纯文字帖：原站不给媒体框，直接把正文顶上去 */
.card.no-media .card-body { padding-top: 2px; }
.card.no-media .card-title { font-size: 16px; }

.board {
  /* 和原站 grid 的 minmax(242px,1fr) 同源：按容器宽度自动决定列数 */
  column-width: 242px;
  column-gap: var(--gap);
}

.card { break-inside: avoid; margin: 0 0 var(--gap-v); display: block; }
.card[hidden] { display: none !important; }

.card-media {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  aspect-ratio: var(--ratio, 1.5);
}

.card-media img,
.card-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-media video[hidden] { display: none; }
.card-media .no-media { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.card.no-media .card-body { border-top: 1px solid var(--line); }

.badge {
  position: absolute;
  z-index: 2;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 7px;
  border-radius: 7px;
  backdrop-filter: blur(6px);
}
.badge-duration { left: 8px; bottom: 8px; }

.icon-btn {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--fg);
  opacity: 0;
  transition: opacity 0.16s ease;
  border: 1px solid var(--glass-brd);
}
.card:hover .icon-btn { opacity: 1; }
.source { text-decoration: none; }

.card .play {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--fg);
  cursor: pointer;
  border: 1px solid var(--glass-brd);
  transition: opacity 0.16s ease;
}
.card.playing .play { opacity: 0; }
.card.playing .card-media img { opacity: 0; }

.card-body { padding: 11px 7px 0; }
.card-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: -0.14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}
.card-title:hover { text-decoration: underline; text-underline-offset: 3px; }

.card-excerpt {
  margin: 5px 0 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 4.5em;
}

.card-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  min-width: 0;
}
.card-author span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 作者行 + 点赞数：点赞数放在卡片右下角，一眼能看到热度 */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}
.card-likes {
  flex: none;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: rgba(127, 127, 127, 0.1);
  border-radius: 7px;
  padding: 2px 7px;
}
.card-author img { width: 20px; height: 20px; border-radius: 999px; object-fit: cover; }
.card-author:hover { color: var(--fg); }

.board-foot { display: grid; place-items: center; gap: 12px; padding: 26px 0; }
.empty { color: var(--muted); }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { background: rgba(127, 127, 127, 0.12); }
.btn[hidden] { display: none; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 20, 18, 0.42);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 88vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 0;
  /* 滚动条常驻占位：不占位的话它会“出现→内容变矮→消失→内容变高”来回震荡，
     视频容器宽度跟着变，看起来就是画面在抖。 */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

/* 滚动条隐蔽化：轨道透明，拇指默认不可见，鼠标移到弹层上才淡淡浮现 */
.sheet:hover { scrollbar-color: rgba(127, 127, 127, 0.42) transparent; }
.sheet::-webkit-scrollbar { width: 8px; height: 8px; }
.sheet::-webkit-scrollbar-track { background: transparent; }
.sheet::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
.sheet:hover::-webkit-scrollbar-thumb { background: rgba(127, 127, 127, 0.32); }
.sheet::-webkit-scrollbar-thumb:hover { background: rgba(127, 127, 127, 0.6); }

/* 帖子视图（弹层与静态详情页共用）：窄栏 + 作者头 + 正文 + 媒体 + 操作行，
   对齐 X 单帖的阅读习惯 */
.sheet.post { max-width: 620px; }
.modal .sheet.post { max-height: 90vh; }
.detail .sheet.post { margin: 24px auto 60px; max-height: none; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 0;
}
.post-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  display: block;
}
.post-id { flex: 1; min-width: 0; }
.post-name { display: block; font-weight: 700; font-size: 15.5px; letter-spacing: -0.01em; }
.post-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.post-handle { display: block; font-size: 13.5px; color: var(--muted); }
.post-x {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
}
.post-x:hover { background: rgba(127, 127, 127, 0.12); color: var(--fg); }

.post-body { padding: 0 18px; }
.post-title {
  margin: 12px 0 0;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}
.post-title-en { display: block; font-size: 13.5px; font-weight: 400; color: var(--muted); margin-top: 4px; }
.post-text { margin: 8px 0 0; font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* 正文里的链接（t.co 已被还原成真地址）*/
.inline-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(127, 127, 127, 0.5);
  word-break: break-all;
}
.inline-link:hover { text-decoration-color: currentColor; }
.post-summary {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.09);
  font-size: 14px;
  color: var(--muted);
}
.post-summary-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  background: rgba(127, 127, 127, 0.16);
  border-radius: 5px;
  padding: 1px 6px;
  margin-right: 7px;
  vertical-align: 1px;
}

.post-media {
  position: relative;
  margin: 14px 0 4px;
  width: 100%;
  aspect-ratio: var(--ratio, 1.5);
  max-height: 68vh;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}
.post-media img, .post-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---------- 自制播放器 ---------- */
.post-media .player { position: absolute; inset: 0; outline: none; }
.player video { cursor: pointer; }

.player .pv-big {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.player .pv-big:hover { transform: translate(-50%, -50%) scale(1.06); }
.player .pv-big[hidden] { display: none; }

.player .pv-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  transition: opacity 0.2s ease;
  opacity: 1;
}
.player.is-idle .pv-bar { opacity: 0; }
.player.is-idle { cursor: none; }

.pv-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.92;
}
.pv-btn:hover { background: rgba(255, 255, 255, 0.16); opacity: 1; }
.pv-btn.is-off { color: #ff8f8f; }

.pv-time {
  flex: none;
  font-size: 12.5px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  opacity: 0.92;
  min-width: 74px;
}

/* 进度条 / 音量条：始终可交互，永远不会因为"没有音轨"而置灰 */
.pv-range {
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
.pv-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #fff 0 var(--fill, 0%),
    rgba(255, 255, 255, 0.32) var(--fill, 0%) 100%
  );
}
.pv-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.pv-range::-moz-range-track { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.32); }
.pv-range::-moz-range-progress { height: 4px; border-radius: 999px; background: #fff; }
.pv-range::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 999px; background: #fff; }
.pv-seek { flex: 1 1 auto; min-width: 60px; }
.pv-vol { flex: none; width: 72px; }

@media (max-width: 560px) {
  .pv-vol { width: 52px; }
  .pv-time { min-width: 62px; font-size: 12px; }
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 13px 18px 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.post-act { font-variant-numeric: tabular-nums; white-space: nowrap; }
.post-rank { font-size: 12.5px; }
.post-x-link { margin-left: auto; color: var(--fg); font-weight: 600; }
.post-x-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 子推文（线程）---------- */
.badge-thread {
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.thread {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.thread-label { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.thread-item { display: flex; gap: 10px; }
.thread-rail { flex: none; width: 32px; display: flex; flex-direction: column; align-items: center; }
.thread-rail img { width: 32px; height: 32px; border-radius: 999px; object-fit: cover; }
.thread-line { flex: 1; width: 2px; min-height: 12px; margin-top: 6px; border-radius: 2px; background: var(--line); }
.thread-item:last-child .thread-line { display: none; }
.thread-body { flex: 1; min-width: 0; padding-bottom: 16px; }
.thread-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.thread-name { font-weight: 700; font-size: 14.5px; }
.thread-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.thread-meta { font-size: 12.5px; color: var(--muted); }
.thread-text {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.thread-media {
  position: relative;
  margin-top: 10px;
  aspect-ratio: var(--ratio, 1.5);
  max-height: 52vh;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
}
.thread-media img,
.thread-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.thread-media .player { position: absolute; inset: 0; }
.thread-media .pv-big { width: 46px; height: 46px; }
.thread-foot { display: flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.thread-link { margin-left: auto; color: var(--fg); font-weight: 600; }
.thread-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 来源切换与平滑过渡 ---------- */
.seg-count {
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.seg-btn.is-on .seg-count { color: var(--fg); opacity: 0.6; }
.seg-source .seg-btn { display: inline-flex; align-items: center; gap: 5px; }

/* 切换来源/视图时淡出再淡入 */
.board,
.leaderboard {
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.board.is-switching,
.leaderboard.is-switching {
  opacity: 0;
  transform: translateY(6px);
}
@media (prefers-reduced-motion: reduce) {
  .board,
  .leaderboard { transition: none; }
  .board.is-switching,
  .leaderboard.is-switching { transform: none; }
}

/* ---------- GitHub 项目 ---------- */
.badge-repo {
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.lb-owner { color: var(--muted); font-weight: 400; font-size: 12.5px; }

.repo-media img { object-fit: cover !important; }

.repo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.repo-head img { width: 32px; height: 32px; border-radius: 8px; }
.repo-head a { color: var(--muted); }
.repo-head a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.repo-flag {
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}
.post-body .repo-title { margin-top: 8px; }

.repo-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}
.repo-stats > div {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 13px;
}
.repo-stats dt { margin: 0; font-size: 13px; }
.repo-stats dd { margin: 0; font-variant-numeric: tabular-nums; }

.repo-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.repo-topics a {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(127, 127, 127, 0.1);
  border-radius: 7px;
  padding: 3px 9px;
}
.repo-topics a:hover { color: var(--fg); background: rgba(127, 127, 127, 0.18); }

.media-fallback {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  padding: 7px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

/* 弹层的静态回退（投稿说明等）还用这两个 */
.sheet-title { margin: 20px 22px 0; font-size: 18px; }
.sheet-text { margin: 8px 22px; color: var(--muted); font-size: 14px; }
.code {
  margin: 8px 22px 22px;
  padding: 12px 14px;
  background: rgba(127, 127, 127, 0.1);
  border-radius: 10px;
  font-size: 12.5px;
  overflow-x: auto;
}

/* ---------- 视图切换 ---------- */
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.1);
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn.is-on {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
html[data-theme='dark'] .seg-btn.is-on { background: #2a2926; }

/* ---------- 排名徽章 / 编辑推荐 ---------- */
.rank-badge {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  min-width: 30px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  padding: 3px 7px;
  border-radius: 7px;
  backdrop-filter: blur(6px);
  display: none; /* 只在「最热」排序下出现 */
}
.board.show-ranks .rank-badge { display: block; }

.rec-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  color: #8a5a00;
  background: #ffe9b3;
  border-radius: 6px;
  padding: 2px 7px;
  margin-bottom: 5px;
}
html[data-theme='dark'] .rec-badge { color: #ffd979; background: rgba(255, 205, 92, 0.16); }

/* ---------- 顶部本周最热 ---------- */
.top-week { margin: 0 0 22px; }
.top-week h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.tw-list {
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(168px, 1fr);
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tw-card {
  position: relative;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: block;
}
.tw-card:hover { border-color: rgba(127, 127, 127, 0.4); }
.tw-card img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--card); }
.tw-thumb-empty {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(127, 127, 127, 0.08) 8px 16px), var(--card);
}
.tw-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.tw-list li:first-child .tw-rank { background: #e0a800; }
.tw-title,
.tw-meta { display: block; padding: 0 10px; }
.tw-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin: 8px 0 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tw-meta { font-size: 12px; color: var(--muted); padding-bottom: 10px; }

/* ---------- 榜单视图 ---------- */
.leaderboard { display: flex; flex-direction: column; }
.leaderboard[hidden],
.board[hidden] { display: none !important; }

.lb-head,
.lb-row {
  display: grid;
  grid-template-columns: 42px 88px 1fr auto;
  align-items: center;
  gap: 12px;
}
.lb-head {
  padding: 0 12px 8px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.lb-head .lb-rank { font-weight: 600; }

.lb-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
}
.lb-row:hover { background: rgba(127, 127, 127, 0.07); }
.lb-row[hidden] { display: none !important; }

.lb-rank {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  color: var(--muted);
}
.lb-row:nth-child(2) .lb-rank,
.lb-row:nth-child(3) .lb-rank,
.lb-row:nth-child(4) .lb-rank { color: var(--fg); }
.lb-rank.lb-top { color: var(--fg); font-size: 17px; }
.lb-rank.lb-top1::after { content: ''; }
.lb-rank.lb-top1 { color: #b8860b; }
.lb-rank.lb-top2 { color: #8a8a8a; }
.lb-rank.lb-top3 { color: #a9713f; }
html[data-theme='dark'] .lb-rank.lb-top1 { color: #ffd166; }
html[data-theme='dark'] .lb-rank.lb-top2 { color: #cfcfcf; }
html[data-theme='dark'] .lb-rank.lb-top3 { color: #d9a06a; }

.lb-thumb { display: block; }
.lb-thumb img {
  display: block;
  width: 88px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  background: var(--card);
}
.lb-main { min-width: 0; }
.lb-title {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.lb-stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.lb-trend.up { color: #1c8f4a; font-weight: 600; }
.lb-trend.down { color: #c0392b; }
html[data-theme='dark'] .lb-trend.up { color: #4ade80; }
html[data-theme='dark'] .lb-trend.down { color: #f87171; }

@media (max-width: 720px) {
  .lb-head { display: none; }
  .lb-row { grid-template-columns: 30px 64px 1fr; gap: 8px; }
  .lb-thumb img { width: 64px; }
  .lb-stats { grid-column: 3; gap: 8px; font-size: 12px; }
}

/* ---------- 顶栏里的文字入口 ---------- */
.bar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
}
.bar-link:hover { background: rgba(127, 127, 127, 0.1); color: var(--fg); }
.bar-link.is-on { color: var(--fg); font-weight: 600; background: rgba(127, 127, 127, 0.12); }

.drawer-btn {
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.drawer-btn:hover { background: rgba(127, 127, 127, 0.12); }

/* ---------- 内页布局 ---------- */
.docs-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 10px 22px 100px;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
}

.docs-side {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  font-size: 13.5px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.docs-side:hover { scrollbar-color: rgba(127, 127, 127, 0.35) transparent; }
.docs-side::-webkit-scrollbar { width: 6px; }
.docs-side::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.docs-side:hover::-webkit-scrollbar-thumb { background: rgba(127, 127, 127, 0.3); }

.side-search { margin-bottom: 14px; }
.side-search input {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border-radius: 10px;
  outline: none;
}
.side-search input:focus { border-color: rgba(127, 127, 127, 0.45); }

.side-group { margin: 0 0 16px; }
.side-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.16s ease;
}
.side-group[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.side-group > summary:hover { background: rgba(127, 127, 127, 0.08); }

.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 15px;
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.45;
}
.side-item:hover { background: rgba(127, 127, 127, 0.09); color: var(--fg); }
.side-item.is-on {
  background: rgba(127, 127, 127, 0.14);
  color: var(--fg);
  font-weight: 600;
}
.side-item[hidden] { display: none; }
.side-count {
  flex: none;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.side-more { margin: 10px 8px 0; font-size: 12.5px; color: var(--muted); }
.side-more a { color: var(--fg); }

.docs-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(20, 20, 18, 0.42);
  backdrop-filter: blur(2px);
}
.docs-scrim[hidden] { display: none; }

/* ---------- 正文 ---------- */
.doc {
  max-width: 724px;
  font-size: 15.5px;
  line-height: 1.75;
}
.doc-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
}
.doc-group {
  background: rgba(127, 127, 127, 0.12);
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: 600;
  color: var(--fg);
}
.doc h1 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.doc-lede {
  margin: 0 0 28px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--muted);
}
.doc h2 {
  margin: 38px 0 12px;
  font-size: 19px;
  letter-spacing: -0.015em;
}
.doc p { margin: 0 0 15px; }
.doc ul,
.doc ol { margin: 0 0 18px; padding-left: 22px; }
.doc li { margin-bottom: 7px; }
.doc strong { font-weight: 650; }
.doc code {
  background: rgba(127, 127, 127, 0.14);
  padding: 1.5px 5px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.doc .table-wrap { overflow-x: auto; margin: 0 0 18px; }
.doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  line-height: 1.6;
}
.doc th,
.doc td {
  text-align: left;
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.doc th {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid rgba(127, 127, 127, 0.35);
  white-space: nowrap;
}
.doc tr:last-child td { border-bottom: none; }
.table-footnote { font-size: 13px; color: var(--muted); margin-top: -8px; }

.doc blockquote {
  margin: 0 0 18px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid rgba(127, 127, 127, 0.38);
}
.doc blockquote p { margin: 0 0 6px; font-size: 15px; }
.doc blockquote cite { font-size: 12.5px; color: var(--muted); font-style: normal; }

.code-block {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.06);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.code-copy {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.code-copy:hover { color: var(--fg); }
.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.65;
}
.code-block code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: normal;
}

/* 实测块：与官方引文视觉上明确区分 */
.measured {
  margin: 0 0 20px;
  padding: 14px 16px 16px;
  border: 1px solid rgba(176, 132, 20, 0.32);
  background: rgba(255, 214, 102, 0.1);
  border-radius: 14px;
}
html[data-theme='dark'] .measured { background: rgba(255, 205, 92, 0.08); }
.measured-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 14px; }
.measured-tag {
  background: #ffe9b3;
  color: #8a5a00;
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  padding: 2px 7px;
}
html[data-theme='dark'] .measured-tag { background: rgba(255, 205, 92, 0.2); color: #ffd979; }
.measured-note { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.measured-rows { margin: 0; font-size: 13.5px; }
.measured-rows > div {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(127, 127, 127, 0.25);
}
.measured-rows > div:last-child { border-bottom: none; }
.measured-rows dt { flex: none; width: 46%; color: var(--muted); }
.measured-rows dd { margin: 0; font-variant-numeric: tabular-nums; }
.measured-conclusion {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid rgba(176, 132, 20, 0.28);
  font-size: 14px;
}

.doc-cases { margin: 40px 0 0; }
.doc-cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.doc-case { display: block; }
.doc-case-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}
.doc-case-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-case-title {
  display: block;
  margin-top: 7px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-case:hover .doc-case-title { text-decoration: underline; text-underline-offset: 3px; }
.doc-case-meta { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.doc-cases-more { font-size: 14px; }

.doc-sources { margin: 44px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.doc-sources-note { font-size: 13.5px; color: var(--muted); }
.doc-sources ul { font-size: 14px; }

.doc-nav {
  margin-top: 46px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 960px) {
  .docs-wrap { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 6px 16px 90px; }
  .docs-side {
    position: fixed;
    z-index: 60;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82vw;
    max-width: 320px;
    max-height: none;
    background: var(--bg);
    padding: 18px 14px 30px;
    transform: translateX(-102%);
    transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }
  .docs-side.is-open { transform: none; }
  .drawer-btn { display: grid; }
  .doc h1 { font-size: 24px; }
  .doc-lede { font-size: 16px; }
  .measured-rows dt { width: 50%; }
}

/* ---------- 响应式（断点与间距对齐原站）---------- */
@media (max-width: 1100px) {
  .board { column-width: auto; column-count: 3; column-gap: 14px; }
  .card { margin-bottom: 22px; }
}
@media (max-width: 960px) {
  input[type='search'] { width: 150px; }
}
@media (max-width: 720px) {
  .board { column-count: 2; column-gap: 12px; }
  .card { margin-bottom: 22px; }
  .board-wrap { padding: 6px 16px 70px; }
  .card-body { padding: 10px 4px 0; }
  .card-author { min-height: 40px; }
  .card-media, .post-media { border-radius: 17px; }
  .board-intro h1 { font-size: 21px; }
  .brand { display: none; }
  .topbar { padding: 10px 10px; }
  .bar { gap: 0; }
  input[type='search'] { width: 110px; }
  .detail-body { padding: 16px; }
}
@media (max-width: 480px) {
  .board { column-count: 2; column-gap: 10px; }
  .board-wrap { padding: 6px 10px 60px; }
  .top-actions { display: none; }
  .card-body { padding: 9px 3px 0; }
  .card-title { font-size: 13px; }
  .card-excerpt { font-size: 12px; }
  .card-author { min-height: 44px; }
  .card-author img { width: 18px; height: 18px; }
}
