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

:root {
  --primary: #b02a2a;
  --primary-dark: #8e2020;
  --bg: #f5f4f1;
  --card: #ffffff;
  --text: #1f2328;
  --text-sub: #6b7280;
  --border: #e8e5e0;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius: 12px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.header {
  background: linear-gradient(135deg, #b02a2a 0%, #8e2020 100%);
  color: #fff; padding: 20px 16px 56px; position: relative;
}
.header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0;
  height: 40px; background: var(--bg); border-radius: 40px 40px 0 0;
}
.header-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex: none;
}
.brand-text h1 { font-size: 21px; font-weight: 700; letter-spacing: 1px; }
.brand-text p { font-size: 12px; opacity: .82; margin-top: 1px; }
.update-info { text-align: right; font-size: 12px; line-height: 1.5; opacity: .9; flex: none; }
.update-info .date { font-weight: 600; font-size: 13px; }

.container { max-width: 860px; margin: -36px auto 0; padding: 0 16px 40px; position: relative; z-index: 1; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  background: var(--card); border-radius: 14px; padding: 14px 6px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.stat { text-align: center; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat-num { display: block; font-size: 20px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-label { display: block; font-size: 11px; color: var(--text-sub); margin-top: 2px; }

/* ---------- Panel(筛选) ---------- */
.panel {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px 14px; margin-bottom: 12px;
}
.panel-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.panel-row + .panel-row { border-top: 1px dashed var(--border); }
.panel-label { font-size: 13px; font-weight: 600; color: var(--text-sub); flex: none; width: 34px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: #faf9f7; color: var(--text-sub);
  padding: 6px 12px; border-radius: 18px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.region-selects { display: flex; gap: 8px; flex: 1; }
.region-selects select {
  flex: 1; min-width: 0; border: 1px solid var(--border); background: #faf9f7;
  color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 13px;
  font-family: inherit; outline: none;
}
.region-selects select:focus { border-color: var(--primary); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; background: var(--card); padding: 6px;
  border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: 64px; border: none; background: transparent; color: var(--text-sub);
  padding: 10px 8px; border-radius: 9px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all .18s ease; font-family: inherit;
}
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(176,42,42,.28); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; box-shadow: var(--shadow);
}
.icon { width: 18px; height: 18px; fill: none; stroke: #9ca3af; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#search { border: none; outline: none; background: transparent; width: 100%; padding: 11px 0; font-size: 14px; color: var(--text); font-family: inherit; }
#search::placeholder { color: #b0b5bd; }
.sort-toggle {
  display: flex; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; box-shadow: var(--shadow); flex: none;
}
.sort-btn {
  border: none; background: transparent; color: var(--text-sub); padding: 6px 11px;
  border-radius: 7px; font-size: 13px; cursor: pointer; font-family: inherit;
  transition: all .15s; white-space: nowrap;
}
.sort-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.refresh-btn {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-sub); padding: 0 14px; border-radius: 10px;
  cursor: pointer; font-size: 14px; font-family: inherit; box-shadow: var(--shadow);
  white-space: nowrap; transition: all .18s;
}
.refresh-btn:active { transform: scale(.96); }
.refresh-btn.loading .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Content ---------- */
.content { min-height: 200px; }
.group-title { display: flex; align-items: center; gap: 8px; margin: 22px 2px 12px; font-size: 16px; font-weight: 700; }
.group-title:first-child { margin-top: 4px; }
.group-title .dot { width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }
.group-title .count { font-size: 12px; font-weight: 500; color: var(--text-sub); background: #ece9e4; padding: 1px 8px; border-radius: 10px; }

.news-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.load-more {
  display: block; width: 100%; margin-top: 10px; padding: 13px; text-align: center;
  background: var(--card); color: var(--primary); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; box-shadow: var(--shadow); transition: background .15s;
}
.load-more:active { background: #faf8f5; }
.news-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 15px 16px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
  transition: background .15s; position: relative; cursor: pointer;
}
.news-item:last-child { border-bottom: none; }
.news-item:active { background: #faf8f5; }
@media (hover: hover) {
  .news-item:hover { background: #faf8f5; }
  .news-item:hover .news-title { color: var(--primary); }
}
.news-index { font-size: 13px; font-weight: 700; color: #c9c5bf; min-width: 22px; text-align: center; padding-top: 2px; font-variant-numeric: tabular-nums; }
.news-item:nth-child(-n+3) .news-index { color: var(--primary); }
.news-body { flex: 1; min-width: 0; }
.news-title { font-size: 15px; font-weight: 600; line-height: 1.5; color: var(--text); transition: color .15s; word-break: break-word; }
.news-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; color: var(--text-sub); flex-wrap: wrap; }
.news-meta .source { background: #f3f0ec; color: #8a8378; padding: 1px 7px; border-radius: 4px; }
.news-meta .source-hot { background: #fdeeee; color: #b02a2a; }
.news-meta .region-tag { background: #eef3f8; color: #51708f; padding: 1px 7px; border-radius: 4px; }
.news-meta .hot-badge { background: #fff3e6; color: #d4760a; padding: 1px 7px; border-radius: 4px; font-weight: 600; }
.score-wrap { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.score-track { width: 46px; height: 5px; background: #ece9e4; border-radius: 3px; overflow: hidden; }
.score-fill { display: block; height: 100%; background: linear-gradient(90deg, #e8a04a, #b02a2a); border-radius: 3px; }
.score-num { font-size: 11px; color: #b02a2a; font-weight: 700; min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.news-arrow { color: #c9c5bf; flex: none; margin-top: 3px; }
.news-arrow svg { width: 16px; height: 16px; }

/* ---------- States ---------- */
.loading, .empty { text-align: center; padding: 60px 20px; color: var(--text-sub); }
.spinner { width: 32px; height: 32px; border: 3px solid #e8e5e0; border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 14px; animation: spin .8s linear infinite; }
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty p { margin-bottom: 6px; }
.empty-action { display: inline-block; margin-top: 12px; padding: 8px 16px; background: var(--primary); color: #fff; border-radius: 8px; font-size: 13px; cursor: pointer; border: none; font-family: inherit; }

/* ---------- Source panel ---------- */
.source-panel { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); margin-top: 24px; overflow: hidden; }
.source-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; background: none; border: none; cursor: pointer; font-family: inherit; }
.source-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text); }
.source-title .icon { stroke: var(--primary); }
.source-hint { font-size: 12px; color: var(--text-sub); }
.source-body { padding: 0 16px 16px; }
.source-group-title { font-size: 12px; font-weight: 700; color: var(--text-sub); padding: 14px 0 6px; }
.source-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.source-item:first-child { border-top: none; }
.source-dot { width: 7px; height: 7px; border-radius: 50%; background: #4caf50; flex: none; }
.source-dot.fail { background: #e0a020; }
.source-item .sname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item .scat { font-size: 11px; color: var(--text-sub); background: #f3f0ec; padding: 1px 6px; border-radius: 4px; }
.source-item .scount { font-size: 12px; color: var(--text-sub); min-width: 40px; text-align: right; }
.source-item .slink { font-size: 11px; color: #5079a8; text-decoration: none; }
.source-note { font-size: 11px; color: #a39c92; line-height: 1.7; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }

/* ---------- Footer ---------- */
.footer { text-align: center; color: #a39c92; font-size: 12px; margin-top: 32px; line-height: 1.8; }

/* ---------- Reader(内嵌阅读) ---------- */
.reader { position: fixed; inset: 0; z-index: 100; background: #fff; display: flex; flex-direction: column; }
.reader[hidden] { display: none; }
.reader-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: #fff; border-bottom: 1px solid var(--border); flex: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.reader-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-actions { display: flex; gap: 8px; flex: none; }
.reader-btn { padding: 6px 12px; font-size: 13px; border-radius: 7px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-family: inherit; text-decoration: none; white-space: nowrap; }
.reader-btn:hover { border-color: var(--primary); color: var(--primary); }
#readerClose { background: var(--primary); color: #fff; border-color: var(--primary); }
#readerClose:hover { color: #fff; background: var(--primary-dark); }
.reader-frame-wrap { flex: 1; position: relative; }
#readerFrame { flex: 1; width: 100%; border: none; background: #fff; }
.reader-loading { position: absolute; inset: 56px 0 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-sub); z-index: -1; }
.reader-loading[hidden] { display: none; }
.reader-tip { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 6px 12px; border-radius: 16px; pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; }
.reader-tip.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .header { padding: 16px 14px 54px; }
  .brand-text h1 { font-size: 19px; }
  .brand-text p { font-size: 11px; }
  .update-info { font-size: 11px; }
  .container { padding: 0 12px 32px; }
  .stat-num { font-size: 17px; }
  .stat-label { font-size: 10px; }
  .panel { padding: 10px 12px; }
  .panel-row { gap: 8px; }
  .chip { padding: 6px 10px; font-size: 12px; }
  .tab { font-size: 13px; padding: 9px 6px; }
  .news-item { padding: 14px 12px; gap: 10px; }
  .news-title { font-size: 14px; }
  .refresh-btn span { display: none; }
  .refresh-btn { padding: 0 12px; }
  .sort-btn { padding: 6px 8px; font-size: 12px; }
  .score-track { width: 30px; }
  .news-meta { gap: 6px; }
  .reader-title { font-size: 12px; }
  .reader-btn { padding: 6px 9px; font-size: 12px; }
}
