:root {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-elev-2: #273548;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --badge-bg: #334155;
  --badge-text: #e2e8f0;
  --link: #7dd3fc;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --bg-elev: #ffffff;
    --bg-elev-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #475569;
    --accent: #0284c7;
    --accent-strong: #0369a1;
    --badge-bg: #e2e8f0;
    --badge-text: #0f172a;
    --link: #0369a1;
    --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  }
}

* { box-sizing: border-box; }

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  padding: 2.25rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.stat.muted { opacity: 0.75; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.stat.muted .stat-value { color: var(--text-muted); }

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

#search {
  flex: 1 1 320px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.toolbar-buttons { display: flex; gap: 0.5rem; }

.toolbar-buttons button {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.toolbar-buttons button:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent);
}

/* Status / errors */
.status {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: none;
}

.status.visible { display: block; }

.status.error {
  border-color: #ef4444;
  color: #fecaca;
  background: color-mix(in srgb, #ef4444 12%, var(--bg-elev));
}

main { padding: 1.5rem 0 3rem; }

/* Section headings */
#categories-section h2,
.timeline-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.section-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Timeline */
.timeline-section { margin-bottom: 2rem; }

.timeline-year {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.6rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.timeline-year > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.8rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  transition: background 0.15s;
  user-select: none;
}

.timeline-year > summary::-webkit-details-marker { display: none; }
.timeline-year > summary:hover { background: var(--bg-elev-2); }

.timeline-year .year-label {
  flex: 0 0 auto;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.timeline-year .year-count {
  flex: 1;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.timeline-months {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.timeline-month {
  display: grid;
  grid-template-columns: 5.5rem auto 1fr;
  column-gap: 0.9rem;
  align-items: baseline;
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.timeline-month:last-child { border-bottom: none; }

.timeline-month .month-label {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.timeline-month .month-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-month .month-categories {
  color: var(--text-muted);
  font-size: 0.88rem;
}

@media (max-width: 600px) {
  .timeline-month {
    grid-template-columns: 4rem auto;
    row-gap: 0.15rem;
  }
  .timeline-month .month-categories { grid-column: 1 / -1; }
}

/* Separate section (e.g. Startup Guide) */
.separate-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 2px dashed var(--border);
}

.separate-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.separate-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Category cards */
.category {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.category > summary,
.subcategory > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  transition: background 0.15s;
  user-select: none;
}

.category > summary::-webkit-details-marker,
.subcategory > summary::-webkit-details-marker { display: none; }

.category > summary:hover,
.subcategory > summary:hover {
  background: var(--bg-elev-2);
}

.chevron {
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}

details[open] > summary > .chevron { transform: rotate(45deg); }

.title { flex: 1; font-size: 1.05rem; }

.subcategory .title { font-size: 0.98rem; font-weight: 500; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--badge-bg);
  color: var(--badge-text);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 1.75rem;
  text-align: center;
}

/* Subcategories */
.subcategories {
  padding: 0.35rem 0.75rem 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.subcategory {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* Articles */
.articles {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.article {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.article:last-child { border-bottom: none; }

.article a {
  color: var(--link);
  text-decoration: none;
  font-size: 0.93rem;
  word-break: break-word;
}

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

.article .date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Hidden by search filter */
.hidden-by-filter { display: none !important; }

.no-results {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Highlighted search match */
mark {
  background: color-mix(in srgb, var(--accent) 40%, transparent);
  color: inherit;
  padding: 0 0.15rem;
  border-radius: 3px;
}

@media (max-width: 600px) {
  .site-header { padding-top: 1.5rem; }
  .site-header h1 { font-size: 1.35rem; }
  .stat-value { font-size: 1.4rem; }
  .article { grid-template-columns: 1fr; }
  .article .date { justify-self: start; }
}
