:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --line: #e6e4de;
  --text: #191919;
  --muted: #8b8b84;
  --accent: #0a66c2;
  --accent-soft: #eaf2fb;
  --warn: #b45309;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* ── 顶栏 ── */
/* 标题栏 + 标签栏整体固定在页面顶部，滚动时始终可见 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 246, 244, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top { background: transparent; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.top h1 { font-size: 17px; font-weight: 700; margin: 12px 0; letter-spacing: .5px; }
.top h1 em { font-style: normal; color: var(--accent); margin: 0 4px; }
.top h1 span { font-weight: 400; color: var(--muted); font-size: 14px; }

.meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  padding: 4px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.loading { opacity: .55; pointer-events: none; }

/* ── 标签页 ── */
.tabs { border-bottom: 0; }
.tabs .bar { padding-top: 0; padding-bottom: 0; }
.tabs .group { display: flex; gap: 2px; }

.tab, .chip {
  border: 0; background: none; cursor: pointer;
  font-size: 14px; padding: 9px 12px; color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.chip { border-radius: 999px; padding: 4px 12px; margin: 8px 0 8px 4px; border-bottom: 0; font-size: 13px; }
.chip:hover { background: var(--line); color: var(--text); }
.chip.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ── 左侧快速定位 ── */
.layout { max-width: 1040px; display: flex; gap: 28px; align-items: flex-start; }
.content { flex: 1; min-width: 0; }
.toc {
  position: sticky; top: 100px;
  width: 178px; flex-shrink: 0;
  font-size: 13px;
  padding: 20px 0; /* 与内容区第一个分区小标题水平对齐 */
  max-height: calc(100vh - 124px);
  overflow-y: auto;
}
.toc a {
  display: block;
  color: var(--muted); text-decoration: none;
  padding: 5px 10px; border-radius: 6px;
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s;
}
.toc a:hover { background: var(--line); color: var(--text); }
.toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc em { font-style: normal; font-size: 11px; opacity: .7; margin-left: 3px; }

.hgroup { scroll-margin-top: 100px; }

@media (max-width: 900px) {
  .layout { display: block; }
  .toc { display: none; }
}

/* ── 列表 ── */
.status { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 0 8px; }
.status:empty { display: none; } /* 加载完成后隐藏空状态栏，避免占位把内容顶下去 */
.status.error { color: var(--warn); }

.hgroup {
  display: flex; align-items: baseline; gap: 8px;
  margin: 20px 0 10px;
}
.hgroup h3 { font-size: 13px; margin: 0; color: var(--muted); font-weight: 600; letter-spacing: 1px; }
.hgroup span { font-size: 12px; color: var(--muted); }
.hgroup .warn { color: var(--warn); }

.item {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .1s;
}
.item:hover { border-color: #cfccc4; transform: translateY(-1px); }

.item .t { font-size: 15px; font-weight: 500; line-height: 1.45; }
.item .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .m { display: flex; gap: 8px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--muted); }
.item .s {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.item .t:hover { color: var(--accent); }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }

/* ── 翻译 / 摘要按钮 ── */
.sp { flex: 1; }
.act {
  border: 0; background: none; cursor: pointer;
  color: var(--accent); font-size: 12px; padding: 0 2px;
}
.act:hover { text-decoration: underline; }
.act:disabled { color: var(--muted); cursor: default; text-decoration: none; }

.sum {
  margin-top: 6px;
  font-size: 13px; color: #444;
  background: #f6f6f3;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 8px 10px;
  line-height: 1.65;
}
.sum.loading { color: var(--muted); }
.sum.err { border-left-color: var(--warn); color: #7c3f3f; }
.summeta { margin-top: 4px; font-size: 11px; color: var(--muted); }

/* ── 垃圾箱 ── */
.chips { display: flex; }
.no-chips .chips { display: none; }
.item.junk { border-style: dashed; border-color: #e2c9c9; background: #fdfaf8; }
.badge {
  display: inline-block;
  font-size: 11px; color: #b45309;
  background: #fdf3e0; border: 1px solid #f0dcb8;
  border-radius: 999px; padding: 0 8px; margin-bottom: 4px;
}

/* ── 精选 ── */
.pick {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  font-size: 11px; color: #1a7f4d;
  background: #eafaf0; border: 1px solid #c9ecd6;
  border-radius: 999px; padding: 2px 9px; margin-bottom: 5px;
}
.pickchange {
  color: #2f6b4a; opacity: .85;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 底部数据源 ── */
footer { padding-top: 8px; padding-bottom: 48px; }
footer h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 28px 0 10px; }
footer h2 small { font-weight: 400; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; }
.sources a {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 10px; text-decoration: none;
  background: var(--card);
}
.sources a:hover { color: var(--accent); border-color: var(--accent); }
.note { font-size: 12px; color: var(--muted); margin-top: 16px; }

@media (max-width: 480px) {
  .item .s { max-width: 150px; }
  .top h1 { font-size: 16px; }
}

/* ── 手机 / PWA 窄屏优化 ── */
@media (max-width: 640px) {
  .wrap { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .layout { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }

  /* 标签栏可横向滑动，避免 6 个标签挤爆 */
  .tabs .bar { display: block; }
  .tabs .group {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabs .group::-webkit-scrollbar { display: none; }
  .tab, .chip { flex: 0 0 auto; white-space: nowrap; }

  .item { padding: 10px 12px; }
  .item .t { font-size: 14px; }
  .item .d { font-size: 12px; }

  /* 手机上按钮更大更好点 */
  .act { padding: 4px 6px; min-height: 30px; }
  .btn { min-height: 30px; }

  .hgroup { flex-wrap: wrap; }
  footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
