:root {
  --bg: #0a0e1a;
  --bg-soft: #0d1220;
  --panel: #141a2e;
  --panel-2: #1a2138;
  --border: #2a3252;
  --border-soft: #232b47;
  --text: #e9ecf8;
  --text-dim: #aab0d6;
  --text-faint: #6c749e;
  --accent: #4f6dff;
  --accent-2: #7a88cf;
  --accent-glow: rgba(79, 109, 255, 0.35);
  --radius: 18px;
  --radius-sm: 10px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 300px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(79, 109, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 110% 10%, rgba(122, 136, 207, 0.10), transparent 60%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Inline icon SVGs only carry a viewBox, so without this they render at the
   browser's default replaced-element size (300x150). 1em scales them with
   whatever text they sit next to; spots that need a fixed size (the brand
   mark, the hero mark) override this further down. */
svg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex: none; }

::selection { background: var(--accent-glow); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

#app { min-height: 100vh; }

/* ---------- Top bar (shown on landing/year pages) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  max-width: 1180px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--panel-2), var(--panel));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 4px 14px rgba(0,0,0,.35);
  flex: none;
  overflow: hidden;
}
.brand-mark .mascot-img { width: 100%; height: 100%; object-fit: contain; object-position: center 78%; transform: scale(1.35); display: block; }

.brand-word b { color: #fff; }
.brand-word span.notes-word { color: var(--accent-2); font-weight: 500; }

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

/* ---------- Buttons / chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--accent-2); color: var(--text); background: var(--panel-2); }

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.85rem;
  min-width: 220px;
}
.searchbox:hover { border-color: var(--accent-2); }
.searchbox kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-faint);
}

/* ---------- Landing hero ---------- */
/* ---------- Hero marquee background ---------- */
.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-marquee {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 0 6px;
  z-index: 0;
  pointer-events: none;
}
.marquee-col {
  width: 190px;
  flex: none;
  overflow: hidden;
  height: 100%;
  opacity: 0.5;
}
.marquee-col:nth-child(odd) { margin-top: -120px; }
.marquee-track {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: marquee-up 46s linear infinite;
  will-change: transform;
}
.marquee-col.reverse .marquee-track { animation-name: marquee-down; }
@keyframes marquee-up { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@keyframes marquee-down { from { transform: translateY(-50%); } to { transform: translateY(0); } }

.marquee-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  flex: none;
}
.marquee-card .mc-subject {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.marquee-card .mc-title {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-marquee-fade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 60% at 50% 42%, var(--bg) 0%, rgba(10,14,26,0.85) 45%, transparent 75%),
    linear-gradient(to bottom, var(--bg) 0%, transparent 16%, transparent 78%, var(--bg) 100%);
}

.hero-section:hover .marquee-track { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

@media (max-width: 880px) {
  .marquee-col { width: 130px; }
  .marquee-col:nth-child(n+4) { display: none; }
}
@media (max-width: 560px) {
  .hero-marquee { gap: 8px; }
  .marquee-col { width: 108px; }
  .marquee-col:nth-child(n+3) { display: none; }
}

.hero {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 28px 10px;
  text-align: center;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent-2);
  font-size: 0.8rem;
  margin-bottom: 22px;
}
.hero-mark {
  position: relative;
  width: 168px; height: 168px;
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
}
.hero-mark::before {
  content: "";
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 68%);
  filter: blur(4px);
  z-index: 0;
}
.hero-mark .mascot-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0,0,0,.5));
}

.hero h1 {
  font-size: clamp(2.3rem, 6vw, 3.8rem);
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: #fff;
}
.hero h1 .accent { color: var(--accent-2); }
.hero p.lead {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 30px;
  line-height: 1.6;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #2d43c9);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px var(--accent-glow);
  margin-bottom: 40px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.hero-cta:hover { transform: translateY(-1px); box-shadow: 0 14px 34px -10px var(--accent-glow); }
.hero-cta svg { width: 16px; height: 16px; }

.hero-stats {
  display: flex; gap: 28px; justify-content: center; margin-bottom: 44px; flex-wrap: wrap;
}
.hero-stats .stat { text-align: center; }
.hero-stats .stat b { display: block; font-size: 1.5rem; color: #fff; }
.hero-stats .stat span { font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Scroll-pinned note preview reveal ---------- */
.reveal-section {
  position: relative;
  height: 250vh;
}
.reveal-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  overflow: hidden;
}
.reveal-label {
  text-align: center;
  transition: opacity .1s linear;
}
.reveal-label .kicker {
  color: var(--accent-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.reveal-label h2 {
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  color: #fff;
  margin: 0;
}
.reveal-frame {
  width: min(1000px, 90vw);
  height: min(600px, 62vh);
  flex: none;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: 0 50px 100px -30px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.03) inset;
  overflow: hidden;
  transform: scale(0.55);
  transform-origin: center center;
  will-change: transform;
}
.reveal-frame .chrome {
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-soft);
}
.reveal-frame .chrome .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.reveal-frame .chrome .url {
  margin-left: 10px;
  font-size: 0.7rem;
  color: var(--text-faint);
  background: var(--panel);
  padding: 3px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
}
.reveal-frame iframe {
  display: block;
  width: 100%;
  height: calc(100% - 34px);
  border: 0;
  background: var(--bg-soft);
  pointer-events: none;
}

/* prefers-reduced-motion / no-JS fallback: show the final framed state as
   plain static content instead of a scroll-driven pin+scale. */
.reveal-section.reveal-static {
  height: auto;
}
.reveal-static .reveal-sticky {
  position: static;
  height: auto;
  padding: 20px 20px 60px;
}
.reveal-static .reveal-frame {
  transform: none;
  border-radius: 20px;
}
.reveal-static .reveal-label { opacity: 1 !important; }

@media (max-width: 700px) {
  .reveal-section { height: 200vh; }
  .reveal-frame { width: 94vw; height: 56vh; border-radius: 18px; }
}

.section-title {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

/* ---------- Card grids ---------- */
.grid {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: block;
  padding: 26px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 18px 40px -16px var(--accent-glow);
}
.card::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120px 80px at 90% -10%, var(--accent-glow), transparent 70%);
  opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.card:hover::after { opacity: 1; }

.card .kicker {
  color: var(--accent-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 10px;
}
.card .card-icon {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  background: linear-gradient(155deg, rgba(79,109,255,.22), rgba(79,109,255,.06));
  border: 1px solid rgba(79,109,255,.25);
  color: var(--accent-2);
}
.card .card-icon::before {
  content: "";
  position: absolute; inset: -14px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  z-index: -1;
  opacity: .8;
}
.card .card-icon svg { width: 22px; height: 22px; }
.card h3 {
  margin: 0 0 8px;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.card .meta { color: var(--text-faint); font-size: 0.82rem; }
.card .go {
  position: absolute; right: 18px; top: 20px;
  color: var(--text-faint);
  transition: transform .15s ease, color .15s ease;
}
.card:hover .go { transform: translateX(3px); color: var(--accent-2); }

.card.topic .icon, .card.note .icon {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(155deg, rgba(79,109,255,.22), rgba(79,109,255,.06));
  border: 1px solid rgba(79,109,255,.25);
  margin-bottom: 14px; color: var(--accent-2);
}
.card.topic .icon::before, .card.note .icon::before {
  content: "";
  position: absolute; inset: -12px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  z-index: -1;
  opacity: .8;
}
.card.topic .icon svg, .card.note .icon svg { width: 20px; height: 20px; }

/* ---------- Breadcrumb ---------- */
.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 0.82rem; color: var(--text-faint);
  padding: 0 28px;
  max-width: 1180px; margin: 0 auto 18px;
}
.crumbs a:hover { color: var(--accent-2); }
.crumbs .sep { opacity: 0.5; }
.crumbs .current { color: var(--text-dim); }

/* ---------- App shell (subject viewer) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  border-right: 1px solid var(--border-soft);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
}
.sidebar-resize-handle:hover, .sidebar-resize-handle.active { background: var(--accent-glow); }
.sidebar-resizing, .sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
  display: flex;
  flex-direction: column;
}
.sidebar-header .brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-header .brand { font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-header .header-btns { display: flex; gap: 2px; flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--panel); border-color: var(--border); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; transition: transform .15s ease; }
#quickswitchToggleBtn.collapsed svg { transform: rotate(180deg); }

/* the year/subject/search block under the brand row; collapses on its own,
   independent of the whole-sidebar collapse, so only the current subject's
   note tree stays on screen. */
.sidebar-quickswitch {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-quickswitch.collapsed { display: none; }

/* floating button to bring a collapsed sidebar back */
.sidebar-reopen {
  display: none;
  position: fixed;
  left: 14px; top: 14px;
  z-index: 25;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.5);
}
.sidebar-reopen:hover { color: #fff; border-color: var(--accent-2); }
.sidebar-reopen svg { width: 17px; height: 17px; }

.year-switch {
  display: flex; gap: 6px;
}
.year-switch button {
  flex: 1;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-faint);
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.year-switch button.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(79,109,255,.22), rgba(79,109,255,.06));
}

.subject-switch { display: flex; flex-direction: column; gap: 4px; }
.subject-switch a {
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 0.83rem;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: space-between;
}
.subject-switch a:hover { background: var(--panel); color: #fff; }
.subject-switch a.active {
  background: var(--panel-2);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.subject-switch a .n { color: var(--text-faint); font-size: 0.72rem; font-weight: 400; }

.sidebar-search {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-faint);
  font-size: 0.8rem;
  cursor: pointer;
}
.sidebar-search:hover { border-color: var(--accent-2); }
.sidebar-search kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.tree-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 30px;
}

.tree-subject-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  padding: 6px 8px 8px;
}

.tree-node { margin: 1px 0; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  user-select: none;
}
.tree-row:hover { background: var(--panel); color: #fff; }
.tree-row.active { background: var(--panel-2); color: #fff; font-weight: 600; }
.tree-row .twisty {
  width: 14px; height: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: transform .15s ease;
}
.tree-row .twisty.open { transform: rotate(90deg); }
.tree-row .twisty.leaf { visibility: hidden; }
.tree-row .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--border);
  flex: none;
}
.tree-row.active .dot { background: var(--accent); }
.tree-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { margin-left: 15px; border-left: 1px solid var(--border-soft); padding-left: 4px; display: none; }
.tree-children.open { display: block; }

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  flex: none;
}
.sidebar-footer a { font-size: 0.78rem; color: var(--text-faint); }
.sidebar-footer a:hover { color: var(--accent-2); }

/* desktop-only sidebar collapse: on mobile the sidebar already lives
   off-canvas by default (see the responsive block below), so this only
   needs to do anything above that breakpoint. */
@media (min-width: 881px) {
  .app-shell.sidebar-collapsed .sidebar { display: none; }
  .app-shell.sidebar-collapsed .sidebar-reopen { display: flex; }
}

/* ---------- Main content ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}

.content-wrap {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 34px 32px 90px;
}

.content-crumbs {
  font-size: 0.8rem; color: var(--text-faint);
  margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.content-crumbs a:hover { color: var(--accent-2); }
.content-crumbs .sep { opacity: .5; }

.content-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: #fff;
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}

.note-body {
  color: var(--text);
  line-height: 1.75;
  font-size: 1rem;
}
.note-body h1, .note-body h2, .note-body h3, .note-body h4 {
  color: #fff;
  line-height: 1.35;
  margin: 1.7em 0 0.6em;
  scroll-margin-top: 80px;
}
.note-body h1:first-child, .note-body h2:first-child, .note-body h3:first-child { margin-top: 0; }
.note-body h1 { font-size: 1.5rem; border-bottom: 1px solid var(--border-soft); padding-bottom: .35em; }
.note-body h2 { font-size: 1.28rem; }
.note-body h3 { font-size: 1.1rem; }
.note-body h4 { font-size: 1rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85rem; }
.note-body p { margin: 0.9em 0; }
.note-body ul, .note-body ol { padding-left: 1.4em; margin: 0.8em 0; }
.note-body li { margin: 0.3em 0; }
.note-body li > p { margin: 0.3em 0; }
.note-body strong { color: #fff; font-weight: 650; }
.note-body em { color: var(--text-dim); }
.note-body hr { border: none; border-top: 1px solid var(--border-soft); margin: 2em 0; }
.note-body a:not(.callout-title) { color: var(--accent-2); border-bottom: 1px solid rgba(122,136,207,.4); }
.note-body a:not(.callout-title):hover { color: #fff; border-color: #fff; }
.note-body img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  display: block;
  margin: 1.2em auto;
  background: #fff;
}
.note-body code {
  font-family: var(--font-mono);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  font-size: 0.87em;
  color: #d8dcf6;
}
.note-body pre {
  background: #0c1122;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1.1em 0;
}
.note-body pre code { background: none; border: none; padding: 0; }
.note-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}
.note-body th, .note-body td {
  border: 1px solid var(--border-soft);
  padding: 8px 12px;
  text-align: left;
}
.note-body th { background: var(--panel); color: #fff; }
.note-body tr:nth-child(even) td { background: rgba(255,255,255,0.015); }

.note-body blockquote {
  margin: 1.1em 0;
  padding: 0;
  border: none;
}

/* plain (non-callout) blockquote fallback */
.note-body blockquote.plain-quote {
  padding: 10px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
}

/* ---------- Callouts ---------- */
.callout {
  margin: 1.2em 0;
  border-radius: 10px;
  border: 1px solid var(--co-border, var(--border));
  background: var(--co-bg, var(--panel));
  overflow: hidden;
}
.callout-title {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  font-weight: 650;
  color: var(--co-fg, var(--text));
  background: var(--co-bg-strong, var(--panel-2));
  font-size: 0.92rem;
}
.callout-title .callout-icon {
  width: 18px; height: 18px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--co-fg, var(--accent));
}
.callout-body { padding: 4px 16px 14px; }
.callout-body > *:first-child { margin-top: 0.6em; }
.callout-body > *:last-child { margin-bottom: 0.4em; }

.callout-note    { --co-border: #3a5fd9; --co-bg: rgba(79,109,255,.08); --co-bg-strong: rgba(79,109,255,.16); --co-fg: #9db2ff; }
.callout-info    { --co-border: #2d8fd9; --co-bg: rgba(45,143,217,.08); --co-bg-strong: rgba(45,143,217,.16); --co-fg: #7cc4f2; }
.callout-abstract{ --co-border: #7a5cf0; --co-bg: rgba(122,92,240,.08); --co-bg-strong: rgba(122,92,240,.16); --co-fg: #b6a3f7; }
.callout-tip     { --co-border: #17a394; --co-bg: rgba(23,163,148,.08); --co-bg-strong: rgba(23,163,148,.16); --co-fg: #5fd7c4; }
.callout-important{--co-border: #d9932d; --co-bg: rgba(217,147,45,.09); --co-bg-strong: rgba(217,147,45,.17); --co-fg: #f0b862; }
.callout-success { --co-border: #2fa66b; --co-bg: rgba(47,166,107,.08); --co-bg-strong: rgba(47,166,107,.16); --co-fg: #6fd99c; }
.callout-question{ --co-border: #a3c62d; --co-bg: rgba(163,198,45,.08); --co-bg-strong: rgba(163,198,45,.16); --co-fg: #cbe86f; }
.callout-warning { --co-border: #d97d2d; --co-bg: rgba(217,125,45,.09); --co-bg-strong: rgba(217,125,45,.17); --co-fg: #f2a05f; }
.callout-failure  { --co-border: #d9432d; --co-bg: rgba(217,67,45,.08); --co-bg-strong: rgba(217,67,45,.16); --co-fg: #f37e6a; }
.callout-danger  { --co-border: #c22b4d; --co-bg: rgba(194,43,77,.09); --co-bg-strong: rgba(194,43,77,.18); --co-fg: #f2648a; }
.callout-example { --co-border: #7a5cf0; --co-bg: rgba(122,92,240,.06); --co-bg-strong: rgba(122,92,240,.13); --co-fg: #b6a3f7; }
.callout-quote   { --co-border: #6c749e; --co-bg: rgba(108,116,158,.08); --co-bg-strong: rgba(108,116,158,.16); --co-fg: var(--text-dim); }

/* ---------- Prev / next ---------- */
.pagenav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 3em;
}
.pagenav a {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--panel);
  transition: border-color .15s ease, background .15s ease;
}
.pagenav a:hover { border-color: var(--accent); background: var(--panel-2); }
.pagenav .lbl { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 4px; }
.pagenav .ttl { color: #fff; font-size: 0.9rem; }
.pagenav .next { text-align: right; grid-column: 2; }
.pagenav .prev:only-child { grid-column: 1; }

/* auto-generated overview list (topic/subject landing inside app shell) */
.overview-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 12px; margin-top: 10px; }

/* ---------- Command palette ---------- */
.palette-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 7, 15, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 100;
}
.palette {
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
  overflow: hidden;
}
.palette input {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1rem;
  padding: 16px 18px;
  outline: none;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--font-sans);
}
.palette input::placeholder { color: var(--text-faint); }
.palette-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.palette-item.active { background: var(--panel-2); }
.palette-item .t { color: #fff; font-size: 0.92rem; }
.palette-item .b { color: var(--text-faint); font-size: 0.76rem; }
.palette-empty { padding: 24px; text-align: center; color: var(--text-faint); font-size: 0.88rem; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1180px; margin: 0 auto; padding: 20px 28px 50px;
  color: var(--text-faint); font-size: 0.8rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-faint); }
.empty-state h2 { color: #fff; margin-bottom: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(var(--sidebar-w), 86vw) !important;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-resize-handle { display: none; }
  .mobile-topbar { display: flex; }
  .content-wrap { padding: 24px 18px 70px; }
  .sidebar-scrim {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30;
  }
  .sidebar-scrim.open { display: block; }
}

@media (max-width: 560px) {
  .topbar { padding: 14px 16px; }
  .hero { padding: 26px 16px 6px; }
  .grid { padding: 0 16px 40px; gap: 12px; }
  .searchbox { min-width: 0; }
  .pagenav { grid-template-columns: 1fr; }
  .pagenav .next { text-align: left; grid-column: 1; }
}
