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

:root {
  --bg:       #f8f8f6;
  --surface:  #ffffff;
  --border:   #e5e5e0;
  --text:     #1a1a1a;
  --muted:    #6b7280;
  --accent:   #2563eb;
  --star-on:  #f59e0b;
  --star-off: #d1d5db;
  --high-bg:  #fffbeb;
  --high-bdr: #fcd34d;
  --serif:    'Georgia', 'Times New Roman', serif;
  --sans:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

html { font-size: 16px; }

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

/* ─── Layout ───────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
}

.topbar-subtitle {
  font-size: .8rem;
  color: var(--muted);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 52px);
}

.sidebar-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: .5rem 1.25rem .25rem;
}

.sidebar a {
  display: block;
  padding: .4rem 1.25rem;
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color .15s, background .15s;
}

.sidebar a:hover { color: var(--text); background: var(--bg); }

.sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.main {
  padding: 2rem 2.5rem;
  max-width: 820px;
}

/* ─── Digest header ────────────────────────────────────────────────────── */
.digest-header { margin-bottom: 1.75rem; }

.digest-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.digest-meta {
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.digest-meta span { display: flex; align-items: center; gap: .3rem; }

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

.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  transition: box-shadow .15s;
}

.article:hover { box-shadow: 0 3px 8px rgba(0,0,0,.08); }

.article.high {
  border-left: 3px solid var(--star-on);
  background: var(--high-bg);
}

/* ─── Article title row ────────────────────────────────────────────────── */
.article-title-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-bottom: .35rem;
}

.article-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.article-title a {
  color: var(--text);
  text-decoration: none;
}

.article-title a:hover { color: var(--accent); text-decoration: underline; }

/* ─── Star rating ──────────────────────────────────────────────────────── */
.stars {
  display: inline-flex;
  gap: 1px;
  flex-shrink: 0;
  align-items: center;
  padding: .1rem .2rem;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}

.star {
  font-size: 1.15rem;
  color: var(--star-off);
  cursor: pointer;
  transition: color .1s, transform .1s;
  user-select: none;
  line-height: 1;
}

.star:hover { transform: scale(1.15); }
.star.on { color: var(--star-on); }

.stars.saving .star { opacity: .5; }
.stars.saved::after {
  content: "✓";
  position: absolute;
  right: -18px;
  font-size: .75rem;
  color: #10b981;
  font-weight: 700;
}

/* ─── Article meta ─────────────────────────────────────────────────────── */
.article-meta {
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}

.tag {
  background: #f0f0ee;
  border-radius: 3px;
  padding: .05rem .4rem;
  font-size: .7rem;
  font-weight: 500;
  color: #555;
}

.score-badge {
  background: #fef3c7;
  color: #92400e;
  border-radius: 3px;
  padding: .05rem .4rem;
  font-size: .7rem;
  font-weight: 600;
}

/* ─── Summary ──────────────────────────────────────────────────────────── */
.summary {
  font-size: .9rem;
  line-height: 1.65;
  color: #2d2d2d;
}

.article.compact .summary {
  color: #4b5563;
}

/* ─── Citations ────────────────────────────────────────────────────────── */
.citations {
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
}

.citations-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .3rem;
}

.citations a {
  display: block;
  font-size: .8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.citations a:hover { text-decoration: underline; }

/* ─── Serendipity section ──────────────────────────────────────────────── */
.serendipity-header {
  margin: 2rem 0 1rem;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.serendipity-header::before,
.serendipity-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Empty state ──────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.empty p { font-size: .875rem; }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 1.25rem 1rem; }
}
