/* ═══════════════════════════════════════════════════════════════════════════
   FeedMerge 纯净样式表
   内容层级声明（Refactoring UI Workflow B）：
   - Primary   : 每条简报的一句话中文摘要（16px, --text-primary, 最大行宽 68ch）
   - Secondary : 日期主标题（30px, bold）、来源原文链接（14px, --brand, medium）
   - Tertiary  : 采集统计元信息、序号、侧栏历史日期、筛选辅助控件（12-14px, --text-muted）
   - 主操作    : 点击来源原文链接阅读；导航与主题切换克制弱化，不喧宾夺主
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-canvas);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-hover);
}

:focus-visible {
  outline: var(--border-2) solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── 顶部品牌修饰条（§8.1 克制的品牌锚点） ── */
.brand-bar {
  height: 3px;
  background: var(--brand);
}

/* ── 顶部导航栏（参考 auto-trend 磨砂极简顶栏） ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface-header);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: var(--border-1) solid var(--border-subtle);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

.brand-link:hover {
  color: var(--brand);
}

.brand-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-link {
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--border-subtle);
}

.nav-link.is-active {
  color: var(--brand-soft-text);
  background: var(--brand-soft);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ── 主体三栏阅读骨架（左侧日期归档 + 中间简讯流 + 右侧本期概览） ── */
.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
  display: grid;
  grid-template-columns: 204px minmax(0, 1fr) 232px;
  gap: var(--space-8);
  align-items: start;
}

.page-shell--single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1080px;
}

.right-rail {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.rail-card {
  background: var(--surface-card);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.rail-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.rail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.rail-metric {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: var(--border-1) solid var(--border-subtle);
}

.rail-metric-val {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.rail-metric-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.rail-note {
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text-secondary);
}

.rail-cta {
  display: inline-block;
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--brand);
}

/* ── 左侧历史归档栏 ── */
.archive-sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding-right: var(--space-2);
}

.sidebar-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
  padding-left: var(--space-3);
}

.archive-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archive-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  border-left: var(--border-2) solid transparent;
}

.archive-link:hover {
  color: var(--text-primary);
  background: var(--border-subtle);
}

.archive-link.is-active {
  color: var(--brand-soft-text);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: var(--weight-semibold);
}

.archive-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.archive-link.is-active .archive-count {
  color: var(--brand-soft-text);
}

/* ── 主阅读区 ── */
.main-column {
  min-width: 0;
}

.page-head {
  margin-bottom: var(--space-6);
}

.page-kicker {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--brand);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meta-sep {
  color: var(--border-default);
}

/* ── 工具栏（搜索过滤 + 计数） ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.search-input {
  width: 100%;
  max-width: 320px;
  height: 36px;
  padding: 0 var(--space-3);
  border: var(--border-1) solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pill-btn {
  padding: 6px var(--space-3);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.pill-btn.is-active {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-soft-text);
  font-weight: var(--weight-semibold);
}

.filter-status {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── 报刊式每日简报流卡片 ── */
.digest-card {
  background: var(--surface-card);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.digest-list {
  list-style: none;
}

.digest-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: var(--border-1) solid var(--border-subtle);
  transition: background 0.12s ease;
}

.digest-item:last-child {
  border-bottom: none;
}

.digest-item:hover {
  background: var(--surface-subtle);
}

.digest-index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  padding-top: 4px;
  user-select: none;
}

.digest-body {
  min-width: 0;
  max-width: 68ch;
}

.digest-summary {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  overflow-wrap: break-word;
}

.digest-source-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--brand);
}

.source-link:hover {
  color: var(--brand-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.source-link svg {
  width: 13px;
  height: 13px;
  opacity: 0.75;
  flex-shrink: 0;
}

/* ── 日报底部上一期/下一期导航 ── */
.pager {
  margin-top: var(--space-6);
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
}

.pager-link {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  min-width: 160px;
}

.pager-link:hover {
  border-color: var(--brand);
}

.pager-link--next {
  margin-left: auto;
  text-align: right;
}

.pager-dir {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pager-date {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* ── 订阅来源表格页 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--surface-card);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-xs);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.table-card {
  background: var(--surface-card);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.sources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.sources-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: var(--border-1) solid var(--border-default);
  background: var(--surface-subtle);
  white-space: nowrap;
}

.sources-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-1) solid var(--border-subtle);
  vertical-align: middle;
}

.sources-table tbody tr:last-child td {
  border-bottom: none;
}

.sources-table tbody tr:hover {
  background: var(--surface-subtle);
}

.source-name {
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.platform-tag {
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.6;
}

.status-badge--ok {
  background: var(--badge-ok-bg);
  color: var(--badge-ok-text);
}

.status-badge--warn {
  background: var(--badge-warn-bg);
  color: var(--badge-warn-text);
}

.status-badge--err {
  background: var(--badge-err-bg);
  color: var(--badge-err-text);
}

.status-badge--muted {
  background: var(--badge-muted-bg);
  color: var(--badge-muted-text);
}

/* ── 空状态（§8.4 纳入功能本体设计） ── */
.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── 页脚 ── */
.site-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-6);
  border-top: var(--border-1) solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (max-width: 1120px) {
  .page-shell {
    grid-template-columns: 196px minmax(0, 1fr);
  }
  .right-rail {
    display: none;
  }
}

.is-hidden {
  display: none !important;
}

/* ── 移动端适配（≤ 860px） ── */
@media (max-width: 860px) {
  .header-inner {
    padding: 0 var(--space-4);
  }

  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    padding: var(--space-6) var(--space-4) var(--space-12);
  }

  .archive-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .sidebar-label {
    padding-left: 0;
  }

  .archive-list {
    flex-direction: row;
    overflow-x: auto;
    gap: var(--space-2);
    padding-bottom: var(--space-1);
    -webkit-overflow-scrolling: touch;
  }

  .archive-link {
    flex-shrink: 0;
    border-left: none;
    border: var(--border-1) solid var(--border-subtle);
    background: var(--surface-card);
    padding: 6px var(--space-3);
    gap: var(--space-2);
  }

  .archive-link.is-active {
    border-color: var(--brand);
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  .digest-item {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
    padding: var(--space-4);
  }

  .digest-index {
    padding-top: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .stat-card {
    padding: var(--space-3);
  }

  .stat-value {
    font-size: var(--text-xl);
  }

  .search-input {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
