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

:root {
  --bg: #f9f9f7;
  --surface: #ffffff;
  --border: #e5e5e0;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --tag-bg: #eff6ff;
  --tag-text: #1d4ed8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1c1c1a;
    --border: #2e2e2b;
    --text-primary: #f0f0ec;
    --text-secondary: #9a9a94;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --tag-bg: #1e3a5f;
    --tag-text: #93c5fd;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

.logo svg {
  color: var(--accent);
}

/* Feed filter bar */
.filter-bar {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 0.5rem;
  position: relative;
}

.filter-bar-inner {
  position: relative;
  display: inline-block;
}

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-toggle-btn[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-toggle-btn.is-filtered {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-toggle-btn[aria-expanded="true"].is-filtered {
  color: #fff;
}

.filter-chevron {
  transition: transform 0.15s;
}

.filter-toggle-btn[aria-expanded="true"] .filter-chevron {
  transform: rotate(180deg);
}

.filter-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 0.6rem;
  z-index: 50;
  min-width: 200px;
  max-width: 320px;
  max-height: 360px;
  overflow-y: auto;
}

.filter-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.filter-action-btn {
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.filter-action-btn:hover {
  text-decoration: underline;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 4px;
}

.filter-item:hover {
  color: var(--accent);
}

.filter-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* Main layout */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

/* Status messages */
.status {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Article cards */
.articles {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.article-card {
  display: block;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}

.article-card:first-child {
  border-top: 1px solid var(--border);
}

.article-card:hover .article-title {
  color: var(--accent);
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.feed-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.article-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.article-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 0.4rem;
  transition: color 0.15s;
  letter-spacing: -0.01em;
}

.article-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-author {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Section headers for "All Feeds" view */
.feed-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0 0.5rem;
}

.feed-section-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.feed-section-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 600px) {
  .header-inner {
    padding: 0 1rem;
  }

  main {
    padding: 1rem 1rem 3rem;
  }

  .filter-bar {
    padding: 0.6rem 1rem 0.4rem;
  }

  .article-title {
    font-size: 0.98rem;
  }
}
