@import url("./tokens.css");
@import url("./base.css");

/* ---------- shell ---------- */
.tf-shell {
  width: min(100%, var(--tf-shell));
  margin: 0 auto;
  padding: 0 var(--tf-gutter);
}

.tf-main {
  min-height: 40vh;
  padding: 32px 0 32px;
}

.tf-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.tf-sidebar-off .tf-layout {
  grid-template-columns: minmax(0, 1fr);
}

.tf-sidebar-off .tf-sidebar {
  display: none;
}

/* 侧栏模块全部关闭（aside 内无任何元素）时自动收起，避免右侧留白 */
.tf-layout:not(:has(.tf-sidebar > *)) {
  grid-template-columns: minmax(0, 1fr);
}

.tf-layout:not(:has(.tf-sidebar > *)) .tf-sidebar {
  display: none;
}

/* 老浏览器无 :has() 时的 JS 兜底 */
.tf-layout-no-sidebar {
  grid-template-columns: minmax(0, 1fr);
}

.tf-layout-no-sidebar .tf-sidebar {
  display: none;
}

.tf-stack {
  min-width: 0;
  display: grid;
  gap: 24px;
}

/* ---------- header ---------- */
.tf-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--tf-bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--tf-line);
}

.tf-topbar-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.tf-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tf-brand-logo {
  height: 32px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  border-radius: 4px;
  align-self: center;
  flex: none;
}

.tf-brand-has-logo::before {
  display: none;
}

.tf-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--tf-accent);
  transform: rotate(45deg);
}

.tf-brand:hover {
  color: var(--tf-text);
}

.tf-nav {
  order: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0 0 0 auto;
}

.tf-nav a {
  font-size: 14px;
  color: var(--tf-muted);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}

.tf-nav a:hover,
.tf-nav a[aria-current="page"] {
  color: var(--tf-text);
  border-bottom-color: var(--tf-accent);
}

/* 顶栏下方的分类频道条：hairline 分栏，当前频道用强调色下划线 */
.tf-category-nav-inner {
  padding: 0;
}

.tf-category-nav-track {
  display: flex;
  align-items: stretch;
  gap: 28px;
  padding: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tf-category-nav-track::-webkit-scrollbar {
  display: none;
}

/* 窄屏溢出时右缘渐隐，提示横向可滚 */
.tf-category-nav-track.tf-cat-scrollable {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}

.tf-category-nav-track a {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 9px 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--tf-muted);
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
}

.tf-category-nav-track a:hover {
  color: var(--tf-text);
}

.tf-category-nav-track a[aria-current="page"] {
  color: var(--tf-text);
  font-weight: 650;
  border-bottom-color: var(--tf-accent);
}

/* 分类行随滚动自动收起，回到顶部恢复，给悬浮广告让出完整高度 */
html.js .tf-category-nav {
  max-height: 90px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.26s ease, opacity 0.2s ease;
}

html.js .tf-category-nav.tf-cat-nav-hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.tf-topbar-actions {
  order: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tf-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
  color: var(--tf-muted);
}

.tf-icon-btn:hover {
  color: var(--tf-accent);
  border-color: var(--tf-accent);
}

.tf-console-btn {
  text-decoration: none;
}

.tf-search-form {
  display: flex;
  align-items: center;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
  overflow: hidden;
}

.tf-search-form input {
  width: 150px;
  padding: 7px 10px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.tf-search-form button {
  width: 34px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--tf-muted);
}

.tf-nav-toggle {
  display: none;
}

/* ---------- hero: 编辑化头版（刊头 + 主稿 + 本期要目） ---------- */
.tf-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 32px;
  border-radius: var(--tf-radius-lg);
  background: linear-gradient(135deg, var(--tf-hero), var(--tf-hero-2));
  color: var(--tf-hero-text);
  box-shadow: var(--tf-shadow);
}

.tf-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.75fr);
  gap: 48px;
  align-items: start;
  padding: 52px 48px 40px;
}

.tf-hero h1 {
  margin: 0;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.12;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.tf-hero-standfirst {
  max-width: 34em;
  margin: 14px 0 0;
  color: var(--tf-hero-muted);
  font-size: 15px;
  line-height: 1.7;
}

.tf-hero-lead {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.tf-hero-lead h2 {
  margin: 0;
  font-size: clamp(21px, 2.1vw, 27px);
  line-height: 1.35;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.tf-hero-lead h2 a {
  color: var(--tf-hero-text);
}

.tf-hero-lead h2 a:hover {
  color: #93c5fd;
}

.tf-hero-lead-excerpt {
  max-width: 36em;
  margin: 12px 0 0;
  color: var(--tf-hero-muted);
  font-size: 14px;
  line-height: 1.8;
}

.tf-hero-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-top: 16px;
  font-family: var(--tf-font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--tf-hero-muted);
  font-variant-numeric: tabular-nums;
}

/* 本期要目：主稿之外的其余稿件，密度高于下方列表 */
.tf-hero-index-title {
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  font-family: var(--tf-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--tf-hero-muted);
}

.tf-hero-index ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tf-hero-index li + li {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tf-hero-index a {
  display: block;
  padding: 13px 0;
  color: var(--tf-hero-text);
}

.tf-hero-index a:hover .tf-hero-index-headline {
  color: #93c5fd;
}

.tf-hero-index time {
  display: block;
  margin-bottom: 5px;
  font-family: var(--tf-font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--tf-hero-muted);
  font-variant-numeric: tabular-nums;
}

.tf-hero-index-headline {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.5;
}

.tf-hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 48px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-family: var(--tf-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--tf-hero-muted);
  font-variant-numeric: tabular-nums;
}

.tf-hero-archive {
  color: var(--tf-hero-text);
}

.tf-hero-archive:hover {
  color: #93c5fd;
}

/* ---------- section heading ---------- */
.tf-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tf-section-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.tf-section-head span {
  font-family: var(--tf-font-mono);
  font-size: 12px;
  color: var(--tf-muted);
}

/* ---------- post list ---------- */
.tf-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
}

.tf-card {
  min-width: 0;
  border-bottom: 1px solid var(--tf-line);
  background: var(--tf-surface);
  transition: background-color 0.2s ease;
}

.tf-card:last-child {
  border-bottom: 0;
}

.tf-card:hover {
  background: var(--tf-surface-2);
}

.tf-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
}

.tf-card-title {
  min-width: 0;
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.tf-card-title a {
  color: var(--tf-text);
}

.tf-card-excerpt {
  margin: 0;
  color: var(--tf-muted);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.tf-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-family: var(--tf-font-mono);
  font-size: 12px;
  color: var(--tf-muted);
  font-variant-numeric: tabular-nums;
}

.tf-card-author {
  color: var(--tf-text);
  font-family: var(--tf-font-sans);
}

.tf-card-author::after {
  content: " 发布于";
  font-family: var(--tf-font-sans);
  color: var(--tf-muted);
}

.tf-card-title a:hover {
  color: var(--tf-accent);
}

@media (max-width: 767px) {
  .tf-card-body {
    padding: 16px;
  }

  .tf-card-title {
    font-size: 18px;
  }
}

.tf-card-grid > .tf-ad {
  margin: 12px;
}

/* ---------- article ---------- */
.tf-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-breadcrumb a:hover {
  color: var(--tf-accent);
}

.tf-article {
  min-width: 0;
  padding: 36px 40px 44px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  box-shadow: var(--tf-shadow);
}

.tf-article-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--tf-line);
}

.tf-article-header h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.tf-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-family: var(--tf-font-mono);
  font-size: 12px;
  color: var(--tf-muted);
}

/* 正文占满文章卡片内容区，不再按 36em 居中收窄（代码块/表格/长图可完整利用横向空间） */
.tf-article-content {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: break-word;
}

/* 破格豁免：代码块、表格、引用不受行宽约束，占满卡内容区；图片单独限制，不按原始像素撑大 */
.tf-article-content pre,
.tf-article-content table,
.tf-article-content blockquote {
  max-width: none;
}

.tf-article-content h2 {
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--tf-line);
  font-size: 24px;
}

.tf-article-content h3 {
  margin: 30px 0 12px;
  font-size: 19px;
}

.tf-article-content p,
.tf-article-content ul,
.tf-article-content ol,
.tf-article-content pre,
.tf-article-content blockquote {
  margin-bottom: 20px;
}

.tf-article-content pre {
  padding: 18px 20px;
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface-2);
  overflow-x: auto;
  font-family: var(--tf-font-mono);
  font-size: 14px;
}

/* 行内 code：底色 + hairline，与 pre 内代码块区分 */
.tf-article-content code {
  padding: 2px 6px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface-2);
  font-family: var(--tf-font-mono);
  font-size: 0.85em;
}

.tf-article-content pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: inherit;
}

/* 代码块复制按钮：由 main.js 注入 */
.tf-article-content pre {
  position: relative;
}

.tf-code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--tf-line-strong);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
  color: var(--tf-muted);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tf-article-content pre:hover .tf-code-copy,
.tf-code-copy:focus-visible {
  opacity: 1;
}

.tf-code-copy:hover {
  color: var(--tf-accent);
  border-color: var(--tf-accent);
}

.tf-code-copy.tf-copied {
  color: var(--tf-accent);
  border-color: var(--tf-accent);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tf-code-copy {
    transition: none;
  }
}

.tf-article-content blockquote {
  padding-left: 18px;
  border-left: 3px solid var(--tf-accent);
  color: var(--tf-muted);
}

.tf-article-content img,
.tf-article-content figure img,
.tf-article-content picture img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: var(--tf-radius-sm);
}

/* 正文图片灯箱：点击放大，不依赖插件 */
.tf-article-content img[data-tf-zoomable] {
  cursor: zoom-in;
}

html.tf-lightbox-open,
html.tf-lightbox-open body {
  overflow: hidden;
}

.tf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 72px 72px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
}

.tf-lightbox[hidden],
.tf-lightbox-nav[hidden] {
  display: none;
}

.tf-lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 1400px);
  max-height: 84vh;
  margin: 0;
}

.tf-lightbox-image {
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--tf-radius-sm);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.tf-lightbox-caption {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.tf-lightbox-caption[hidden] {
  display: none;
}

.tf-lightbox-close,
.tf-lightbox-nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(248, 250, 252, 0.28);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  color: #f8fafc;
  line-height: 1;
}

.tf-lightbox-close:hover,
.tf-lightbox-nav:hover {
  background: rgba(248, 250, 252, 0.16);
}

.tf-lightbox-close {
  top: 16px;
  right: 16px;
  font-size: 24px;
}

.tf-lightbox-prev,
.tf-lightbox-next {
  top: 50%;
  font-size: 30px;
  transform: translateY(-50%);
}

.tf-lightbox-prev {
  left: 16px;
}

.tf-lightbox-next {
  right: 16px;
}

.tf-lightbox-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  color: #cbd5e1;
  font-size: 13px;
  transform: translateX(-50%);
}

@media (max-width: 640px) {
  .tf-lightbox {
    padding: 64px 12px 68px;
  }

  .tf-lightbox-prev {
    left: 8px;
  }

  .tf-lightbox-next {
    right: 8px;
  }

  .tf-lightbox-image {
    max-height: 68vh;
  }
}

/* 深色模式：插件注入块（付费阅读 / 评论）跟随主题，不再出现米白亮斑 */
.tf-dark .tf-article-content .paid-reading-paywall,
.tf-dark .tf-article-content [class*="paywall"] {
  background: var(--tf-surface-2);
  color: var(--tf-text);
}

.tf-dark .tf-article-content .paid-reading-paywall h2,
.tf-dark .tf-article-content .paid-reading-paywall h3,
.tf-dark .tf-article-content .paid-reading-paywall p,
.tf-dark .tf-article-content [class*="paywall"] :is(h2, h3, p, span, small, label) {
  color: var(--tf-text);
}

.tf-dark .tf-article-content .paid-reading-paywall :is(input, textarea) {
  background: var(--tf-surface);
  border-color: var(--tf-line);
  color: var(--tf-text);
}

/* 付费徽章：深色跟随 + 窄屏取消浮动（插件样式，主题侧兜底） */
.tf-dark .tf-article-content .pr-stamp,
.tf-dark .tf-article-content [class*="stamp"] {
  background: var(--tf-surface);
  border-color: var(--tf-line-strong);
  color: var(--tf-muted);
}

@media (max-width: 767px) {
  .tf-article-content .pr-stamp,
  .tf-article-content [class*="stamp"] {
    float: none !important;
    display: inline-block;
    margin: 0 0 10px;
  }
}

.tf-dark .comment-children,
.tf-dark .halo-comment,
.tf-dark [class*="comment"] {
  color: var(--tf-text);
}

.tf-dark .halo-comment :is(input, textarea, select) {
  background: var(--tf-surface);
  border-color: var(--tf-line);
  color: var(--tf-text);
}

.tf-dark .halo-comment ::placeholder,
.tf-dark [class*="comment"] ::placeholder {
  color: var(--tf-muted);
  opacity: 1;
}

.tf-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--tf-line);
}

.tf-tag {
  padding: 4px 10px;
  border: 1px solid var(--tf-line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--tf-muted);
}

.tf-tag:hover {
  border-color: var(--tf-accent);
  color: var(--tf-accent);
}

/* ---------- 文章结尾：上下篇 + 相关阅读 ---------- */
.tf-post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--tf-line);
}

.tf-post-nav-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  transition: border-color 0.2s ease;
}

.tf-post-nav-item:hover {
  border-color: var(--tf-accent);
}

.tf-post-nav-next {
  text-align: right;
  justify-items: end;
}

.tf-post-nav-dir {
  font-family: var(--tf-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--tf-muted);
}

.tf-post-nav-item:hover .tf-post-nav-dir {
  color: var(--tf-accent);
}

.tf-post-nav-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--tf-text);
}

.tf-related {
  margin-top: 28px;
}

.tf-related-title {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.tf-related-grid {
  display: grid;
  gap: 12px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  overflow: hidden;
}

.tf-related-grid .tf-card {
  border-bottom: 1px solid var(--tf-line);
}

.tf-related-grid .tf-card:last-child {
  border-bottom: 0;
}

.tf-related-grid .tf-card-body {
  padding: 16px 18px;
}

.tf-related-grid .tf-card-title {
  font-size: 16px;
}

.tf-related-grid .tf-card-excerpt {
  display: none;
}

@media (max-width: 767px) {
  .tf-post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .tf-post-nav-next {
    text-align: left;
    justify-items: start;
  }
}

/* ---------- reading anchors: 文章底部悬浮工具条 ---------- */
.tf-read-anchors {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px;
  transform: translateX(-50%);
  border: 1px solid var(--tf-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tf-surface) 90%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--tf-shadow);
  transition: opacity 0.22s ease, transform 0.26s ease;
}

.tf-read-anchors[hidden] {
  display: none;
}

/* 滚动到页脚时自动淡出下移，避免遮挡页脚内容 */
.tf-read-anchors.tf-anchors-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(calc(100% + 32px));
  pointer-events: none;
}

.tf-anchor {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--tf-muted);
  font-size: 13px;
  line-height: 1;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.tf-anchor:hover,
.tf-anchor[aria-current] {
  border-color: var(--tf-accent);
  background: var(--tf-accent-soft);
  color: var(--tf-accent);
}

@media (max-width: 767px) {
  .tf-read-anchors {
    bottom: 16px;
    gap: 4px;
    padding: 5px;
  }

  .tf-anchor {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tf-anchor,
  .tf-post-nav-item {
    transition: none;
  }
}

/* ---------- sidebar ---------- */
.tf-sidebar {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.tf-widget {
  padding: 20px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
}

.tf-widget h2 {
  margin: 0 0 14px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.tf-widget ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.tf-widget li a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--tf-muted);
}

/* 分类/标签：名称 + 数量横排行 */
.tf-taxonomy li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.tf-taxonomy li a {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  justify-content: flex-start;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  color: var(--tf-text);
}

.tf-taxonomy .tf-count {
  margin-left: auto;
  color: var(--tf-muted);
  font-variant-numeric: tabular-nums;
}

.tf-widget time,
.tf-widget .tf-count {
  font-family: var(--tf-font-mono);
  font-size: 11px;
  flex: none;
}

.tf-widget .tf-recent li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.tf-widget .tf-recent time {
  color: var(--tf-muted);
  font-variant-numeric: tabular-nums;
}

.tf-widget .tf-recent a {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  color: var(--tf-muted);
}

.tf-widget .tf-recent a:hover {
  color: var(--tf-accent);
}

.tf-toc {
  max-height: 52vh;
  overflow-y: auto;
  font-size: 13px;
}

.tf-toc ul {
  gap: 6px;
}

.tf-toc a {
  display: block;
  padding: 4px 0 4px 10px;
  border-left: 2px solid var(--tf-line);
  color: var(--tf-muted);
}

.tf-toc a[data-level="3"] {
  padding-left: 22px;
}

.tf-toc a:hover,
.tf-toc a.tf-active {
  border-left-color: var(--tf-accent);
  color: var(--tf-accent);
}

/* ---------- ads ---------- */
.tf-ad {
  position: relative;
  overflow: hidden;
  border: 1px dashed var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface-2);
}

.tf-ad-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 16px 32px;
  text-align: center;
  color: var(--tf-muted);
  font-size: 14px;
}

/* 文字链：自适应高度，不再套图片位固定框 */
.tf-ad-text .tf-ad-inner {
  height: auto;
  min-height: 0;
  padding: 13px 24px;
}

.tf-ad-inner:hover {
  color: var(--tf-accent);
}

.tf-ad-inner img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.tf-ad-header,
.tf-ad-footer {
  height: 90px;
  margin: 16px 0;
}

.tf-ad-text.tf-ad-header,
.tf-ad-text.tf-ad-footer {
  height: auto;
}

.tf-ad-feed {
  height: 120px;
}

.tf-ad-text.tf-ad-feed {
  height: auto;
}

.tf-ad-sidebar {
  min-height: 220px;
  max-height: 320px;
}

.tf-ad-text.tf-ad-sidebar {
  min-height: 0;
  max-height: none;
}

/* ---------- ad zones / rails ---------- */
.tf-ad-zone {
  margin-bottom: 24px;
}

.tf-ad-zone:empty {
  display: none;
}

.tf-ad-zone-bottom {
  margin: 24px 0 0;
}

.tf-ad-zone .tf-ad {
  margin: 0 0 16px;
}

.tf-ad-zone .tf-ad:last-child {
  margin-bottom: 0;
}

.tf-ad-frame {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.tf-ad-frame-main {
  flex: 1 1 auto;
  min-width: 0;
}

.tf-ad-rail {
  width: 160px;
  display: grid;
  gap: 16px;
  align-content: start;
  flex: none;
  /* 左/右侧广告随页面滚动常驻悬浮；top 由 JS 按顶栏实际高度设置，确保完整显示在顶栏下方 */
  position: sticky;
  top: var(--tf-rail-top, 84px);
  align-self: start;
  max-height: calc(100vh - var(--tf-rail-top, 84px) - 24px);
  overflow: auto;
  scrollbar-width: none;
}

.tf-ad-rail::-webkit-scrollbar {
  display: none;
}

/* 页面上方广告：下滑后收起，回到顶部再显示 */
html.js .tf-ad-zone-top {
  max-height: 800px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.2s ease, margin-bottom 0.28s ease;
}

html.js .tf-ad-zone-top.tf-ad-hidden {
  max-height: 0;
  margin-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

/* 页面下方广告：滚动到该位置时才淡入 */
html.js .tf-ad-zone-bottom {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

html.js .tf-ad-zone-bottom.tf-ad-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.tf-ad-rail .tf-ad {
  margin: 0;
}

.tf-ad-rail .tf-ad-inner {
  padding: 12px;
}

.tf-ad-rail .tf-ad-inner img {
  width: 100%;
}

.tf-ad-pos-left,
.tf-ad-pos-right {
  min-height: 200px;
  max-height: 400px;
}

.tf-ad-header.tf-ad-pos-top,
.tf-ad-footer.tf-ad-pos-top {
  height: 90px;
  margin: 0;
}

.tf-ad-text.tf-ad-pos-top,
.tf-ad-text.tf-ad-pos-bottom {
  height: auto;
}

.tf-ad-feed.tf-ad-pos-top,
.tf-ad-feed.tf-ad-pos-bottom {
  height: 120px;
  margin: 0;
}

.tf-ad-sidebar.tf-ad-pos-top,
.tf-ad-sidebar.tf-ad-pos-bottom {
  min-height: 220px;
  max-height: 320px;
  margin: 0;
}

@media (max-width: 1199px) {
  .tf-ad-rail {
    display: none;
  }
}

/* ---------- responsive hardening ---------- */
.tf-article-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.tf-article-content th,
.tf-article-content td {
  padding: 8px 12px;
  border: 1px solid var(--tf-line);
  text-align: left;
}

.tf-list-item {
  flex-wrap: wrap;
  min-width: 0;
}

.tf-list-item a {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- footer ---------- */
.tf-footer {
  margin-top: 0;
  padding: 24px 0 28px;
  border-top: 1px solid var(--tf-line);
  color: var(--tf-muted);
  font-size: 13px;
  line-height: 1.7;
}

.tf-footer-inner {
  text-align: center;
}

.tf-footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  max-width: 100%;
}

.tf-footer-row + .tf-footer-row {
  margin-top: 8px;
}

/* 版权行与侵权声明共用同一字体样式（颜色/字号/字重/字距全部继承页脚基准） */
.tf-footer-brand,
.tf-footer-intro {
  color: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

.tf-footer-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0;
  min-width: 0;
  max-width: 100%;
}

.tf-footer-item + .tf-footer-item::before {
  content: "·";
  margin: 0 4px;
  color: currentColor;
  opacity: 0.5;
}

.tf-footer-row-secondary,
.tf-footer-row-tertiary {
  color: var(--tf-muted);
  font-size: 13px;
}

.tf-footer-link {
  color: inherit;
  text-decoration: none;
}

.tf-footer a:hover {
  color: var(--tf-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 标签索引页：hairline 行，与归档同密度 */
.tf-tag-index {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  overflow: hidden;
}

.tf-tag-index li + li {
  border-top: 1px solid var(--tf-line);
}

.tf-tag-index a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  color: var(--tf-text);
}

.tf-tag-index a:hover {
  background: var(--tf-surface-2);
}

.tf-tag-index .tf-tag-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 550;
}

.tf-tag-index a:hover .tf-tag-name {
  color: var(--tf-accent);
}

.tf-tag-index .tf-count {
  flex: none;
  font-family: var(--tf-font-mono);
  font-size: 12px;
  color: var(--tf-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- list / archive pages ---------- */
.tf-page-head {
  margin-bottom: 28px;
}

.tf-page-head h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: -0.03em;
}

.tf-page-head p {
  margin: 0;
  color: var(--tf-muted);
}

.tf-list {
  display: grid;
  gap: 14px;
}

.tf-page-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

/* 归档：年份为组，行内日期只补月.日 */
.tf-archive-year h2 {
  margin: 0 0 10px;
  font-family: var(--tf-font-mono);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--tf-muted);
  font-variant-numeric: tabular-nums;
}

.tf-archive-year h3 {
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--tf-muted);
  font-weight: 600;
}

.tf-archive-year .tf-list {
  gap: 0;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  overflow: hidden;
}

.tf-archive-year .tf-list-item {
  border: 0;
  border-bottom: 1px solid var(--tf-line);
  border-radius: 0;
}

.tf-archive-year .tf-list-item:last-child {
  border-bottom: 0;
}

.tf-list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 18px;
  border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
}

.tf-list-item a {
  font-size: 16px;
}

.tf-list-item time,
.tf-list-item .tf-count {
  flex: none;
  font-family: var(--tf-font-mono);
  font-size: 12px;
  color: var(--tf-muted);
}

.tf-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--tf-line);
}

.tf-page-numbers {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tf-pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--tf-line-strong);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
  color: var(--tf-text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.tf-pagination a:hover {
  border-color: var(--tf-accent);
  color: var(--tf-accent);
}

.tf-pagination a.is-current {
  border-color: var(--tf-accent);
  background: var(--tf-accent);
  color: var(--tf-accent-contrast);
  font-weight: 600;
}

.tf-page-gap {
  min-width: 24px;
  text-align: center;
  color: var(--tf-muted);
  font-size: 14px;
}

/* ---------- 404 ---------- */
.tf-404 {
  padding: 80px 0;
  text-align: center;
}

.tf-404 code {
  font-family: var(--tf-font-mono);
  font-size: 72px;
  color: var(--tf-accent);
}

.tf-404 h1 {
  margin: 12px 0;
}

.tf-404-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.tf-404-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border: 1px solid var(--tf-accent);
  border-radius: 999px;
  background: var(--tf-accent);
  color: var(--tf-accent-contrast);
  font-size: 14px;
  font-weight: 600;
}

.tf-404-btn:hover {
  background: var(--tf-accent);
  color: var(--tf-accent-contrast);
  opacity: 0.92;
}

.tf-404-btn-ghost {
  background: transparent;
  border-color: var(--tf-line-strong);
  color: var(--tf-text);
  font-weight: 500;
}

.tf-404-btn-ghost:hover {
  background: var(--tf-surface-2);
  border-color: var(--tf-accent);
  color: var(--tf-accent);
  opacity: 1;
}

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .tf-layout,
  .tf-sidebar-off .tf-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .tf-sidebar,
  .tf-sidebar-off .tf-sidebar {
    display: none;
  }

  .tf-hero-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }
}

@media (max-width: 1023px) {
  .tf-nav {
    gap: 12px;
  }

  .tf-nav a {
    font-size: 13px;
  }
}

@media (max-width: 767px) {
  :root {
    --tf-gutter: 16px;
  }

  .tf-topbar-inner {
    min-height: 60px;
    gap: 12px;
  }

  .tf-brand {
    min-width: 0;
    flex: 0 1 auto;
    gap: 6px;
    font-size: 17px;
    overflow: hidden;
  }

  .tf-brand-logo {
    height: 28px;
    max-width: 84px;
  }

  .tf-brand span {
    min-width: 0;
    max-width: 104px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tf-topbar-actions {
    margin-left: auto;
    gap: 6px;
    flex: none;
  }

  .tf-icon-btn {
    width: 32px;
    height: 32px;
  }

  .tf-nav-toggle {
    display: inline-flex;
  }

  .tf-footer-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .tf-footer {
    padding: 22px 0 26px;
  }

  .tf-footer-meta {
    max-width: 100%;
    justify-content: center;
  }

  .tf-footer-item + .tf-footer-item::before {
    margin: 0 4px;
  }

  .tf-nav {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    display: none;
    margin: 0;
    padding: 12px 16px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--tf-surface);
    border-bottom: 1px solid var(--tf-line);
  }

  .tf-nav.tf-open {
    display: flex;
  }

  .tf-nav a {
    padding: 8px 0;
    width: 100%;
  }

  .tf-category-nav-inner {
    padding-bottom: 0;
  }

  .tf-category-nav-track {
    gap: 20px;
  }

  .tf-category-nav-track a {
    padding: 8px 0;
    font-size: 13px;
  }

  .tf-search-form {
    display: none;
  }

  .tf-hero {
    border-radius: var(--tf-radius);
  }

  .tf-hero-inner {
    padding: 32px 22px 28px;
    gap: 26px;
  }

  .tf-hero h1 {
    font-size: 30px;
  }

  .tf-hero-lead {
    margin-top: 26px;
    padding-top: 20px;
  }

  .tf-hero-index {
    display: none;
  }

  .tf-hero-foot {
    padding: 12px 22px;
  }

  .tf-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tf-article {
    padding: 24px 20px 32px;
  }

  .tf-article-content h2 {
    font-size: 21px;
  }

  .tf-ad-header,
  .tf-ad-footer,
  .tf-ad-feed {
    height: 80px;
    margin: 12px 0;
  }

  .tf-ad-zone {
    margin-bottom: 16px;
  }

  .tf-ad-zone-bottom {
    margin-top: 16px;
  }

  .tf-list-item {
    padding: 14px 16px;
  }
}

@media (max-width: 480px) {
  .tf-brand-has-logo span {
    display: none;
  }
}
