:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: #d2d2d7;
  --accent: #0071e3;
  --accent-light: #e8f0fe;
  --header-bg: rgba(255, 255, 255, 0.82);
  --card-hover: #f5f5f7;
  --tag-bg: #f0f0f3;
  --tag-text: #6e6e73;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg: #111113;
  --bg-card: #1c1c1e;
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;
  --border: #38383a;
  --accent: #5b9cf6;
  --accent-light: #1c2b3e;
  --header-bg: rgba(17, 17, 19, 0.82);
  --card-hover: #2c2c2e;
  --tag-bg: #2c2c2e;
  --tag-text: #a1a1a6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --bg-card: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --border: #38383a;
    --accent: #5b9cf6;
    --accent-light: #1c2b3e;
    --header-bg: rgba(17, 17, 19, 0.82);
    --card-hover: #2c2c2e;
    --tag-bg: #2c2c2e;
    --tag-text: #a1a1a6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}


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

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  text-decoration: none;
  color: var(--text);
  display: block;
}

.brand h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

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

.tagline {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: -2px;
  letter-spacing: 0.02em;
}

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

.count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
#theme-toggle:hover { color: var(--text); border-color: var(--text-secondary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }


/* --- Main --- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
}

/* --- Date dividers (inserted client-side) --- */
.day-divider {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* --- Card grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* --- Card --- */
.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card:visited { color: inherit; }

/* Card with image */
.card--has-img .card-img {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tag-bg);
}

.card--has-img .card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.card--has-img:hover .card-img img {
  transform: scale(1.03);
}

/* Featured card */
.card--featured {
  grid-column: 1 / -1;
  flex-direction: row;
  margin-bottom: 16px;
}

.card--featured .card-img {
  flex: 0 0 50%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--tag-bg);
}

.card--featured .card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.card--featured:hover .card-img img {
  transform: scale(1.03);
}

.card--featured .card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 32px;
}

.card--featured .card-title {
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 700;
}

.card--featured .card-desc {
  font-size: 0.9rem;
  -webkit-line-clamp: 3;
}

/* Card body */
.card-body {
  padding: 16px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.source-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sep { color: var(--text-tertiary); }

.time-ago {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.card-author {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* --- Empty / Loading --- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}
.empty-state h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text);
}

.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Footer --- */
footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  max-width: 900px;
  margin: 0 auto;
}
footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
footer a:hover { text-decoration: underline; }
.footer-sources { margin-bottom: 16px; }
.footer-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.footer-list { line-height: 1.8; }
.footer-disclaimer {
  margin-bottom: 16px;
  line-height: 1.6;
  font-size: 0.72rem;
}
.footer-prism { font-size: 0.78rem; }

/* --- Mobile --- */
@media (max-width: 700px) {
  .header-inner { padding: 10px 14px; }
  .tagline { display: none; }
  .brand h1 { font-size: 1.2rem; }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card--featured {
    flex-direction: column;
  }
  .card--featured .card-img {
    flex: none;
    aspect-ratio: 16 / 9;
  }
  .card--featured .card-body {
    padding: 16px 18px;
  }
  .card--featured .card-title {
    font-size: 1.15rem;
  }

  main { padding: 16px 14px; }
  .day-section { margin-bottom: 28px; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
