/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #252836;
  --border:    #2e3147;
  --accent:    #5b8dee;
  --accent2:   #7c6ff7;
  --text:      #e2e4f0;
  --text-muted:#8b90a8;
  --tag-bg:    #1e2540;
  --tag-text:  #7eb3ff;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.35);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg:        #f3f5fb;
  --bg2:       #ffffff;
  --bg3:       #eaecf5;
  --border:    #d0d5e8;
  --accent:    #3b6fd4;
  --accent2:   #6254d4;
  --text:      #1a1e2e;
  --text-muted:#5a6080;
  --tag-bg:    #e2e8f8;
  --tag-text:  #3b6fd4;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout ────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─── Header ────────────────────────────────────────────── */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 60px;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-inner::-webkit-scrollbar { display: none; }

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.main-nav {
  display: flex;
  gap: .25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .75rem;
  border-radius: 20px;
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover   { background: var(--bg3); color: var(--text); }
.nav-link.active  { background: var(--accent); color: #fff; }

.nav-badge {
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  padding: 0 .4rem;
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}
.nav-link.active .nav-badge { background: rgba(255,255,255,.25); }

/* ─── Theme toggle ──────────────────────────────────────── */
.site-theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background .15s;
}
.site-theme-toggle:hover { background: var(--bg); }

/* ─── Main content ──────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 2rem 1.25rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-count {
  font-size: .9rem;
  color: var(--text-muted);
}

/* ─── Article grid ──────────────────────────────────────── */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ─── Card ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow);
  transition: border-color .2s, transform .15s;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .78rem;
  color: var(--text-muted);
}

.card-source {
  font-weight: 600;
  color: var(--accent);
}

.card-category {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: .1rem .5rem;
  border-radius: 10px;
  font-size: .74rem;
}

.card-time { margin-left: auto; }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}
.card-title a:hover { color: var(--accent); }

.card-summary {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .5rem;
  margin-top: auto;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: .75rem;
  padding: .15rem .55rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.card-link {
  font-size: .82rem;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.card-link:hover { text-decoration: underline; }

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
}

.pag-btn {
  padding: .5rem 1.25rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  transition: background .15s;
}
.pag-btn:hover { background: var(--bg3); }

.pag-info {
  font-size: .9rem;
  color: var(--text-muted);
}

/* ─── Empty state ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 0;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-hint { margin-top: .75rem; font-size: .9rem; }
.empty-hint code {
  background: var(--bg3);
  padding: .2rem .5rem;
  border-radius: 5px;
  color: var(--accent);
  font-family: monospace;
}

/* ─── Footer ────────────────────────────────────────────── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .article-grid { grid-template-columns: 1fr; }
  .page-header  { flex-direction: column; gap: .25rem; }
}

/* ─── News sections (main page) ─────────────────────────── */
.news-section {
  margin-bottom: 3rem;
}

.news-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--accent);
}

.news-section-title-wrap {
  flex: 1;
  min-width: 0;
}

.news-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.5;
  font-style: italic;
}

.news-section-desc {
  margin-top: .3rem;
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.news-section-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3rem;
  flex-shrink: 0;
  padding-top: .15rem;
}

.news-section-count {
  font-size: .76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.news-section-all {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.news-section-all:hover { color: var(--accent); }

/* ─── Vertical news list ────────────────────────────────── */
.news-list {
  display: flex;
  flex-direction: column;
}

.news-item {
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.news-item:last-child { border-bottom: none; }

.news-item-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .76rem;
  color: var(--text-muted);
}

.news-item-source {
  font-weight: 600;
  color: var(--accent);
}

.news-item-time { margin-left: auto; }

.news-item-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}
.news-item-title a:hover { color: var(--accent); }

.news-item-summary {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ─── Category page ─────────────────────────────────────── */

.page-back {
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: .2rem;
}
.page-back:hover { color: var(--accent); }

.page-title-wrap { flex: 1; min-width: 0; }

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1.5;
}

.page-title-desc {
  margin-top: .35rem;
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Article page ──────────────────────────────────────── */
.article-page {
  max-width: 780px;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.article-source-link {
  font-size: .85rem;
  color: var(--accent);
}
.article-source-link:hover { text-decoration: underline; }

.article-header {
  margin-bottom: 2rem;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
  flex-wrap: wrap;
}

.article-category {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: .1rem .5rem;
  border-radius: 10px;
  font-size: .74rem;
}

.article-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: .9rem;
}

.article-summary {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.65;
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  font-style: italic;
}

.article-body {
  font-size: .975rem;
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.article-body p {
  color: var(--text);
}

.article-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.btn-original {
  display: inline-block;
  padding: .5rem 1.25rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn-original:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.article-no-text {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.news-section-hint {
  margin-top: .75rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.news-section-hint a {
  color: var(--accent);
}
.news-section-hint a:hover { text-decoration: underline; }

/* ─── Category feeds list ───────────────────────────────── */
.cat-feeds {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .35rem;
}

.cat-feed-item {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: .74rem;
  padding: .1rem .45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.btn-xs {
  padding: .15rem .5rem;
  font-size: .75rem;
}

/* ─── Feed picker modal ─────────────────────────────────── */
.feed-picker-list {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  max-height: 340px;
  overflow-y: auto;
}

.feed-picker-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  width: 100%;
  box-sizing: border-box;
}
.feed-picker-row:hover { background: var(--bg3); }
.feed-picker-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--tag-bg);
}
.feed-picker-current { opacity: .55; }

.feed-picker-name { flex: 1; font-size: .9rem; font-weight: 500; }
.feed-picker-cat  { font-size: .78rem; }

/* ─── Source tabs ───────────────────────────────────────── */
.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .6rem 0 .75rem;
}

.source-tab {
  padding: .25rem .75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.source-tab:hover { background: var(--bg); color: var(--text); }
.source-tab.active {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-color: var(--accent);
}

.source-tab-all {
  font-weight: 600;
}
.source-tab-all.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
