/* ── Design tokens ─────────────────────────────────────────────────── */
:root {
  --bg-deep:        #0c1220;
  --bg:             #111827;
  --bg-card:        #1a2332;
  --bg-card-hover:  #1f2b3d;
  --border:         rgba(255,255,255,0.08);
  --border-hover:   rgba(255,255,255,0.15);
  --text:           #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --gold:           #d4a017;
  --gold-soft:      #c8961a;
  --gold-glow:      rgba(212,160,23,0.15);
  --green:          #34d399;
  --green-glow:     rgba(52,211,153,0.12);
  --purple:         #a78bfa;
  --rust:           #fb923c;
  --radius:         12px;
  --radius-sm:      8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--gold); }

/* ── Site header ───────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  letter-spacing: -0.5px;
}
.site-title:hover { text-decoration: none; color: var(--gold); }

.header-search { display: flex; gap: 0.4rem; flex: 1; max-width: 480px; }
.header-search input {
  flex: 1;
  padding: 0.35rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.header-search input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212,160,23,0.2);
}
.header-search button {
  padding: 0.35rem 0.9rem;
  background: var(--gold);
  color: var(--bg-deep);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.header-search button:hover { background: var(--gold-soft); }

/* ── Site wrap / footer ────────────────────────────────────────────── */
.site-wrap { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
}

/* ── Homepage hero ─────────────────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  margin-bottom: 2rem;
}
.home-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -1.5px;
  line-height: 1.1;
}
.home-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 1.6rem;
}
.search-bar-wrap {
  display: flex;
  gap: 0.5rem;
  max-width: 600px;
  margin: 0 auto 0.8rem;
}
.search-bar-wrap input {
  flex: 1;
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar-wrap input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,0.15);
}
.search-bar-wrap button {
  padding: 0.65rem 1.4rem;
  background: var(--gold);
  color: var(--bg-deep);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.search-bar-wrap button:hover { background: var(--gold-soft); }
.search-count { font-size: 0.9rem; color: var(--text-muted); min-height: 1.2em; }

/* ── Surprise me button ─────────────────────────────────────────────── */
.surprise-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.9rem;
  padding: 0.5rem 1.2rem;
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--gold);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.surprise-btn:hover {
  background: var(--gold);
  color: var(--bg-deep);
  text-decoration: none;
}

/* ── View toggle ────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 2rem;
}
.toggle-btn {
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border-hover);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.toggle-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.toggle-btn--active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg-deep);
  font-weight: 600;
}

/* ── Graph section ──────────────────────────────────────────────────── */
.graph-section {
  margin-bottom: 2.5rem;
}
#graph-container {
  width: 100%;
  height: 600px;
  background: var(--bg-deep);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.graph-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

/* ── Tag cloud / chips ─────────────────────────────────────────────── */
.topics-section { margin-bottom: 2.5rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 2px 10px;
  background: rgba(212,160,23,0.08);
  border: 1px solid rgba(212,160,23,0.4);
  border-radius: 6px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--gold);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
  text-decoration: none;
}
.chip--lg { font-size: 0.88rem; padding: 4px 12px; }
.chip-count {
  background: rgba(212,160,23,0.25);
  color: var(--gold);
  border-radius: 10px;
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── Section headings ──────────────────────────────────────────────── */
.section-heading {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Card grid + stagger animation ─────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}
.note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.note-card:hover {
  background: var(--bg-card-hover);
  box-shadow: 0 4px 20px var(--gold-glow);
  border-color: var(--border-hover);
}
.note-card.hidden { display: none; }

.card-title { font-size: 1rem; font-weight: 600; line-height: 1.35; }
.card-title a { color: var(--text); transition: color 0.15s; }
.card-title a:hover { color: var(--gold); text-decoration: none; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); }
.card-tldr { font-size: 0.88rem; color: var(--text-secondary); flex: 1; line-height: 1.55; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }

/* ── Breadcrumb ────────────────────────────────────────────────────── */
.breadcrumb {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--gold); }

/* ── Note page layout ──────────────────────────────────────────────── */
.content-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 660px) 220px;
  gap: 1.5rem;
  align-items: start;
}

/* ── Left sidebar ──────────────────────────────────────────────────── */
.sidebar-left {
  font-size: 0.85rem;
  background: var(--bg-deep);
  border-radius: var(--radius);
  padding: 1rem;
}

/* ── Right sidebar ─────────────────────────────────────────────────── */
.sidebar-right { font-size: 0.85rem; }

/* ── Shared sidebar box ────────────────────────────────────────────── */
.sidebar-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 1rem;
}
.sidebar-heading {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.sidebar-list { list-style: none; }
.sidebar-list li { margin-bottom: 0.35rem; }
.sidebar-list--topics { max-height: 70vh; overflow-y: auto; }
.sidebar-link { color: var(--text-secondary); font-size: 0.84rem; }
.sidebar-link:hover { color: var(--gold); text-decoration: none; }
.sidebar-link--active { font-weight: 600; color: var(--gold); }
.sidebar-meta { color: var(--text-muted); font-size: 0.8rem; }

/* ── Note main ─────────────────────────────────────────────────────── */
.note-main { min-width: 0; }

.note-title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  color: var(--text);
  letter-spacing: -0.5px;
}
.note-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.meta-channel { font-weight: 600; color: var(--text-secondary); }
.meta-sep { color: var(--border-hover); }
.source-link { color: var(--gold); }
.source-link:hover { text-decoration: underline; }
.meta-badge {
  background: rgba(212,160,23,0.1);
  color: var(--gold);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.76rem;
  border: 1px solid rgba(212,160,23,0.25);
}
.note-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1.3rem; }

/* ── TL;DR box ─────────────────────────────────────────────────────── */
.tldr-box {
  background: rgba(212,160,23,0.08);
  border-left: 3px solid var(--gold);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.tldr-text { font-style: italic; color: var(--text-secondary); line-height: 1.7; }

/* ── Key concepts table ────────────────────────────────────────────── */
.concepts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.concepts-table th,
.concepts-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.concepts-table thead tr th {
  background: var(--bg-deep);
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'Inter', system-ui, sans-serif;
}
.concepts-table tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}
.concept-name {
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
}

/* ── Note sections ─────────────────────────────────────────────────── */
.note-section { margin-bottom: 1.5rem; }
.note-h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
}
.note-bullets { padding-left: 1.4rem; margin-bottom: 0.5rem; }
.note-bullets li { margin-bottom: 0.35rem; line-height: 1.6; color: var(--text-secondary); }
.empty-state { color: var(--text-muted); font-style: italic; }

/* ── Takeaways ─────────────────────────────────────────────────────── */
.takeaways-box {
  background: rgba(52,211,153,0.06);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
}
.takeaways-list { padding-left: 1.4rem; }
.takeaways-list li { margin-bottom: 0.4rem; color: var(--text-secondary); }

/* ── Quotes ────────────────────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--purple);
  margin: 0.75rem 0;
  padding: 0.6rem 1rem;
  font-style: italic;
  color: var(--text-secondary);
}

/* ── Topic page ────────────────────────────────────────────────────── */
.topic-header { margin-bottom: 1.5rem; }
.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text);
  letter-spacing: -0.5px;
}
.topic-count { color: var(--text-muted); font-size: 0.9rem; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .sidebar-left { order: 2; padding: 0.75rem; }
  .note-main   { order: 1; }
  .sidebar-right { order: 3; }
  .sidebar-list--topics { max-height: 200px; }

  .home-title { font-size: clamp(1.75rem, 8vw, 2.5rem); }
  .card-grid { grid-template-columns: 1fr; }
  .view-toggle { flex-wrap: wrap; }
  #graph-container { height: 400px; }
}
