/* ---------------------------------------------------------------
   NewsPulse — 主题变量
   --------------------------------------------------------------- */
:root {
  --radius: 14px;
  --maxw: 1360px;
  --col-min: 302px;
  --col-gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

html[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-soft: #0f1218;
  --surface: #14171f;
  --surface-2: #1b1f29;
  --line: #232836;
  --line-strong: #313849;
  --text: #e8ecf4;
  --text-dim: #aab3c5;
  --muted: #7d8799;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .14);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .8);
  --header-bg: rgba(11, 13, 18, .78);
}

html[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --line: #e4e7ee;
  --line-strong: #d3d8e3;
  --text: #14171f;
  --text-dim: #414a5c;
  --muted: #6b7488;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .10);
  --shadow: 0 10px 28px -14px rgba(16, 24, 40, .35);
  --header-bg: rgba(247, 248, 250, .82);
}

/* --------------------------------------------------------------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  padding: 10px 16px; background: var(--accent); color: #fff; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------------------------------------
   Header —— GitHub/终端风格：等宽字、1px 线、无渐变、无图标气泡
   --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 24px 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
  white-space: nowrap;
}
.wordmark span { color: var(--muted); font-weight: 400; }
.wordmark:hover { color: var(--accent); }

.search-wrap {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  display: flex;
  align-items: center;
  padding-left: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
  transition: border-color .12s, box-shadow .12s;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-wrap .prompt {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
  color: #3fb950;
  padding-right: 7px;
  margin-right: 8px;
  border-right: 1px solid var(--line);
  user-select: none;
}

#search {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
}
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 15px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 5px;
  margin-right: 6px;
}
.search-wrap:focus-within .kbd { opacity: 0; }

.header-actions { display: flex; gap: 6px; margin-left: auto; flex: 0 0 auto; }

.tbtn {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 20px;
  padding: 2px 9px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.tbtn:hover { color: var(--text); border-color: var(--line-strong); }
.tbtn:active { transform: translateY(1px); }
.tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 板块 tab：GitHub 仓库导航那种下划线 */
.tabs {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 10px 9px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.tab[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: #fd8c73;
}
.tab .n {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tab[aria-pressed="true"] .n { color: var(--text-dim); }

/* 工具栏：source 下拉 + 更新时间 */
.subbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 24px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.src-pick { display: inline-flex; align-items: center; gap: 7px; }

.src-pick .lbl {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}

select#source {
  height: 26px;
  max-width: 260px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' fill='none' stroke='%237d8799' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 7px center / 10px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  appearance: none;
  cursor: pointer;
  outline: none;
}
select#source:hover { border-color: var(--line-strong); }
select#source:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stamp {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------------------------------------------
   列表
   --------------------------------------------------------------- */
main { padding-top: 18px; padding-bottom: 8px; }

.status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  min-height: 12px;
  font-variant-numeric: tabular-nums;
}
.status b { color: var(--text-dim); font-weight: 600; }
.status .warn { color: #d29922; }

/* JS 未执行时的静态列表（板块静态页 / 爬虫读的就是这份） */
.static-list { list-style: none; margin: 0; padding: 0; }
.static-list li {
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.static-list li a { font-weight: 600; }
.static-list li a:hover { color: var(--accent); }
.static-list li span {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--col-min), 1fr));
  gap: var(--col-gap);
  align-items: start;
}

/* JS 接管后的真·瀑布流（无 JS 时退化成上面的网格布局） */
.grid.is-masonry { display: block; position: relative; }
.grid.is-masonry .card { position: absolute; top: 0; left: 0; margin: 0; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s var(--ease), background .2s;
}
.card::before {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 3px;
  background: var(--cat, var(--accent));
  opacity: .85;
  transition: opacity .2s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }
.card:focus-within { border-color: var(--cat, var(--accent)); }

.card-media {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.92);
  transition: transform .5s var(--ease), filter .3s;
}
.card:hover .card-media img { transform: scale(1.035); filter: saturate(1); }

.card-body {
  padding: 13px 16px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}

.card-top {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--muted);
}
.card-cat {
  color: var(--cat, var(--accent));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 10.5px;
}
.card-src {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 62%;
}
.card-top .sep { opacity: .45; }

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 640;
  line-height: 1.38;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-title a { transition: color .16s; }
.card-title a:hover { color: var(--accent); }
.card-title a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.card-excerpt {
  margin: 0;
  font-size: 13px;
  line-height: 1.56;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.card-foot .host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot time { white-space: nowrap; font-variant-numeric: tabular-nums; }

.also {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

/* 加载更多 */
.more-wrap { display: flex; justify-content: center; padding: 26px 0 10px; }

.more {
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.more:hover { color: var(--text); background: var(--surface); border-color: var(--line-strong); }

/* 空状态 */
.empty { text-align: center; padding: 70px 20px 40px; color: var(--muted); }
.empty .big { font-size: 17px; color: var(--text-dim); margin: 0 0 6px; }
.empty .sub { font-size: 13px; margin: 0 0 18px; }

/* 骨架屏 */
.skeleton {
  height: 210px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: shine 1.3s infinite linear;
}
@keyframes shine { to { background-position: -220% 0; } }

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */
.site-footer {
  padding-top: 30px;
  padding-bottom: 56px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}
.disclaimer { margin: 22px 0 16px; max-width: 780px; line-height: 1.65; }
.disclaimer strong { color: var(--text-dim); font-weight: 600; }

#health { border-top: 1px solid var(--line); padding-top: 12px; max-width: 780px; }
#health summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12.5px;
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0;
}
#health summary::-webkit-details-marker { display: none; }
#health summary::before {
  content: "▸"; font-size: 10px; color: var(--muted);
  transition: transform .18s;
  display: inline-block;
}
#health[open] summary::before { transform: rotate(90deg); }

.badge {
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.health-body {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 4px 18px;
  font-size: 11.5px;
}
.health-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.health-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-row .ok { color: #34d399; }
.health-row .err { color: #f87171; }

.build { margin-top: 18px; font-size: 11.5px; color: var(--muted); opacity: .85; }

/* ---------------------------------------------------------------
   响应式
   --------------------------------------------------------------- */
@media (max-width: 900px) {
  .bar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search-wrap { flex: 1 1 100%; max-width: none; order: 3; }
  .wrap, .filters { padding-left: 16px; padding-right: 16px; }
  .filters { gap: 8px; }
  .brand-text small { display: none; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .chip { padding: 5px 10px; font-size: 12.5px; }
  .stamp { display: none; }
  .card-title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* 打印 */
@media print {
  .site-header, .more-wrap, .site-footer, .card-media { display: none !important; }
  body { background: #fff; color: #000; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { break-inside: avoid; border: 1px solid #ddd; }
}

/* ---------------------------------------------------------------
   日刊页 /daily —— 独立页头，不依赖首页 header 的类名
   --------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 13, 18, .82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
html[data-theme="light"] .topbar { background: rgba(247, 248, 250, .85); }

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
  white-space: nowrap;
}
.wordmark span { color: var(--muted); font-weight: 400; }
.wordmark:hover { color: var(--accent); }

.topbar-inner .tabs { padding: 0; margin: 0; }
.topbar-inner .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.digest-main { max-width: 860px; padding-top: 26px; padding-bottom: 64px; }

.digest-title {
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 6px;
}
.digest-week { font-family: var(--sans); font-size: 15px; color: var(--muted); font-weight: 400; }

.digest-sub {
  margin: 0 0 26px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

.digest-section { margin-bottom: 28px; }

.digest-h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 6px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.digest-count {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.digest-list { list-style: none; margin: 0; padding: 0; }

.digest-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.digest-item a {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  transition: color .12s;
}
.digest-item a:hover { color: var(--accent); }
.digest-meta {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.digest-top-list .digest-item { padding: 9px 0; }
.digest-top-list .digest-item a { font-size: 15.5px; font-weight: 600; }

.digest-foot {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
.digest-foot a { color: var(--accent); }

.nav-daily {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 20px;
  padding: 2px 9px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: color .12s, border-color .12s;
}
.nav-daily:hover { color: var(--text); border-color: var(--line-strong); }

@media (max-width: 620px) {
  .digest-item { flex-direction: column; gap: 3px; }
  .digest-meta { padding-top: 0; }
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .digest-title { font-size: 21px; }
  .wrap.digest-main { padding-left: 16px; padding-right: 16px; }
}