:root {
  --bg: #0a0a0f;
  --bg-elevated: #14141c;
  --card-bg: #14141c;
  --border: #23232f;
  --text: #e8e8f0;
  --text-dim: #9a9ab0;
  --accent: #00d4aa;
  --accent-text: #0a0a0f;
  --danger: #ff5c7c;
  --focus-ring: #00d4aa;
}

html[data-theme="light"] {
  --bg: #f7f7fa;
  --bg-elevated: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e2ea;
  --text: #14141c;
  --text-dim: #5a5a70;
  --accent: #00a382;
  --accent-text: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 13px;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-summary {
  font-size: 13px;
  color: var(--text-dim);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

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

.new-articles-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
}

.new-articles-banner button {
  background: var(--accent-text);
  color: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 600;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent);
}

.chip[aria-pressed="true"],
.chip.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.filter-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  color: var(--text);
}

.sources-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.source-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-dim);
}

.source-pill.hidden-source {
  text-decoration: line-through;
  opacity: 0.6;
}

.source-pill.disabled-source {
  opacity: 0.5;
  cursor: default;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  padding: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card.is-read {
  opacity: 0.6;
}

.card-image {
  height: 140px;
  position: relative;
  overflow: hidden;
}

.card-image img,
.card-image svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
}

.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1;
  padding: 2px;
}

.bookmark-btn.is-bookmarked {
  color: var(--accent);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  text-decoration: none;
  display: block;
}

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

.card-excerpt {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.card-meta .dot::before {
  content: "·";
  margin-right: 6px;
}

.also-covered {
  font-size: 11px;
  color: var(--text-dim);
}

.empty-state,
.loading-state,
.error-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
}

.error-state {
  color: var(--danger);
}

.site-footer {
  text-align: center;
  padding: 24px 20px 40px;
  font-size: 13px;
}

.site-footer a {
  color: var(--text-dim);
}

@media (max-width: 480px) {
  .site-header,
  .filter-bar {
    padding: 12px 14px;
  }
  .article-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .meta-summary {
    display: none;
  }
  .reader-main {
    padding: 18px 16px 40px;
  }
  .reader-title {
    font-size: 23px;
  }
}

/* ---- Reader page ------------------------------------------------- */

.reader-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.reader-header {
  margin-bottom: 8px;
}

.reader-title {
  font-size: 28px;
  line-height: 1.25;
  margin: 12px 0 8px;
  max-width: 70ch;
}

.reader-subtitle {
  font-size: 17px;
  color: var(--text-dim);
  margin: 0 0 12px;
  max-width: 70ch;
}

.reader-byline {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.reader-byline a {
  color: var(--text-dim);
  text-decoration: underline;
}

.underlying-source-note {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 12px 0 0;
  max-width: 70ch;
}

.underlying-source-note a {
  color: var(--accent);
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.reader-actions .chip {
  font-size: 14px;
  padding: 8px 16px;
}

.read-original-btn {
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.read-original-btn:hover {
  opacity: 0.9;
}

.reader-hero {
  margin: 24px 0;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-elevated);
}

.reader-hero img,
.reader-hero svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reader-body {
  max-width: 70ch;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
}

.reader-body > *:first-child {
  margin-top: 0;
}

.reader-body p {
  margin: 0 0 20px;
}

.reader-body h2,
.reader-body h3,
.reader-body h4 {
  margin: 32px 0 12px;
  line-height: 1.3;
}

.reader-body h2 {
  font-size: 22px;
}

.reader-body h3 {
  font-size: 19px;
}

.reader-body ul,
.reader-body ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.reader-body li {
  margin-bottom: 8px;
}

.reader-body blockquote {
  margin: 24px 0;
  padding: 4px 20px;
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
  font-style: italic;
}

.reader-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: 14px;
}

.reader-body code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.reader-body pre code {
  background: none;
  padding: 0;
}

.reader-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 8px auto;
}

.reader-body figure {
  margin: 24px 0;
}

.reader-body figcaption {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 8px;
}

.reader-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.reader-body th,
.reader-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.reader-body a {
  color: var(--accent);
}

.reader-body iframe {
  max-width: 100%;
  border-radius: 8px;
  margin: 20px 0;
}

.reader-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-dim);
}

.reader-footer a {
  color: var(--accent);
}

.reader-fallback-excerpt {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  max-width: 70ch;
  margin: 20px 0;
}

.reader-fallback-note {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 70ch;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
