/* ========================================
   AI Research Blog - Main Stylesheet
   Matching rokmr.github.io portfolio aesthetic exactly
   
   CENTRALIZED PADDING & ALIGNMENT SYSTEM:
   - Single source of truth for all horizontal spacing: --spacing-horizontal
   - Consistent max-widths across all page types
   - Unified responsive breakpoints
   - All containers use the same padding system
   ======================================== */

/* CSS Variables - Exact portfolio values */
:root {
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-elevated: #161616;
  --text: #e8e8e8;
  --text-secondary: #999999;
  --dim: #666666;
  --border: #222222;
  --border-hover: #444444;
  --accent: #4ade80;

  /* Callout colors */
  --tip-bg: rgba(74, 222, 128, 0.1);
  --tip-border: #4ade80;
  --note-bg: rgba(59, 130, 246, 0.1);
  --note-border: #3b82f6;
  --warning-bg: rgba(234, 179, 8, 0.1);
  --warning-border: #eab308;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: #ef4444;
  --question-bg: rgba(168, 85, 247, 0.1);
  --question-border: #a855f7;

  /* Typography */
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-size-base: 16px;
  --line-height: 1.6;

  /* ==========================================================
     CENTRALIZED LAYOUT SYSTEM - SINGLE SOURCE OF TRUTH
     
     Max-Width System:
     - All pages use consistent max-widths
     - Home/Notes Index: 1600px (wide)
     - Posts/Note content: 900px (reading width)
     - All containers inherit from these variables
     
     Spacing System:
     - Horizontal: --spacing-horizontal (80px desktop, 24px mobile)
     - Vertical Top: --spacing-vertical-top (120px from header)
     - Vertical Bottom: --spacing-vertical-bottom (80px above footer)
     - ALL pages use same spacing - no overrides
     
     To adjust spacing site-wide, change these variables only!
     ========================================================== */
  
  /* Layout - Unified Max-Width System */
  --max-width-ultra: 1800px;       /* Ultra-wide layouts (graph, search) */
  --max-width-wide: 1600px;        /* Wide layouts (notes grid, subject pages, home) */
  --max-width-default: 1400px;     /* Reserved for special layouts */
  --max-width-content: 900px;      /* Reading content (posts, notes) */
  --sidebar-width: 280px;          /* TOC sidebar width */
  
  /* Centralized Horizontal Spacing - Controls ALL side padding */
  --spacing-horizontal: 80px;      /* Desktop (auto-responsive via media queries) */
  
  /* Centralized Vertical Spacing - Controls ALL top/bottom padding */
  --spacing-vertical-top: 60px;    /* Distance from header to content start */
  --spacing-vertical-bottom: 60px; /* Distance from content end to footer */
  
  /* Content Spacing */
  --section-margin-top: 4rem;
  --section-margin-bottom: 3rem;
  --section-padding-top: 3rem;
  --section-padding-bottom: 2.5rem;
  
  --card-padding: 1.5rem;
  --card-margin-bottom: 1.5rem;
  --card-gap: 1.5rem;
  
  --content-element-margin: 2rem;
  --paragraph-margin: 1.5rem;
  --heading-margin-top: 3rem;
  --heading-margin-bottom: 1.5rem;
  
  --footer-margin-top: 5rem;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: #fff;
}

/* ========================================
   Header (Portfolio-matched)
   ======================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(10, 10, 10, 0.9);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-container {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--spacing-horizontal);
}

.site-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title .logo {
  font-size: 1.2rem;
}

.site-nav {
  display: flex;
  gap: 2rem;
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.3s;
}

.site-nav a:hover {
  color: #fff;
}

.site-nav .external-link {
  color: var(--accent);
}

/* ========================================
   Base Container System - CENTRALIZED
   All pages use same vertical spacing for consistency
   ======================================== */
.content {
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-vertical-top) var(--spacing-horizontal) var(--spacing-vertical-bottom);
  max-width: var(--max-width-wide);
  display: grid;
  gap: 60px;
}

/* Default: Two-column with sidebar (Posts, Notes) */
.content {
  grid-template-columns: 1fr var(--sidebar-width);
}

/* Home Page: Single column, wider to match other pages */
.content.home-content {
  grid-template-columns: 1fr;
}

.home-content .home-header,
.home-content .posts-container {
  padding: 0;
  margin: 0;
  max-width: 100%;
}

/* Notes Index: Single column, wider */
.content.notes-content {
  grid-template-columns: 1fr;
}

/* Subject/Sub-Subject Pages: Full width */
.content.wide-content {
  grid-template-columns: 1fr;
}

/* Search Page: Single column, centered */
.content.search-content {
  grid-template-columns: 1fr;
  min-height: auto;
}

/* ========================================
   Sidebar (Table of Contents)
   ======================================== */
.sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  align-self: start;
  padding: 0;
  margin: 0;
}

.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 0.5rem;
}

.toc-list a {
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: block;
  padding: 0.25rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid transparent;
  transition: all 0.3s;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-list .toc-h3 {
  padding-left: 1.5rem;
  font-size: 0.75rem;
}

/* KaTeX in sidebar TOC */
.toc-list .katex {
  font-size: 0.75em;
}

.toc-list a .katex-display {
  display: inline;
  margin: 0;
  padding: 0;
}

/* Quick actions */
.quick-actions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.quick-actions-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  margin-bottom: 1rem;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 0.5rem;
  text-decoration: none;
}

.quick-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Home Page
   ======================================== */
.home-header {
  margin: 0 0 var(--section-margin-top) 0;
  padding: 0 0 var(--section-padding-bottom) 0;
  border-bottom: 1px solid var(--border);
}

.home-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  padding: 0;
  letter-spacing: -0.02em;
}

.site-description {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

.home-nav {
  margin: 1.5rem 0 0 0;
  padding: 0;
}

.home-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.home-nav a:hover {
  border-color: var(--text);
  color: var(--text);
}

/* Posts container - two column layout */
.posts-container {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 4rem;
  margin: 2rem 0 0 0;
  padding: 0;
}

/* Category Navigation Sidebar */
.category-nav {
  position: sticky;
  top: 100px;
  height: fit-content;
}

.category-nav-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  margin-bottom: 1rem;
}

.category-list {
  list-style: none;
}

.category-list li {
  margin-bottom: 0.25rem;
}

.category-link {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: all 0.3s;
}

.category-link:hover {
  color: var(--text);
  border-left-color: var(--border-hover);
}

.category-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(74, 222, 128, 0.05);
}

/* Posts Sections */
.posts-sections {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.category-section {
  scroll-margin-top: 100px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-desc {
  color: var(--dim);
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
}

/* Post Cards */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--card-padding);
  margin-bottom: 0.75rem;
  transition: all 0.3s;
}

.post-card:hover {
  border-color: var(--border-hover);
  transform: translateX(4px);
}

.post-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.post-card-title a {
  color: var(--text);
}

.post-card-title a:hover {
  color: var(--accent);
}

.empty-category {
  color: var(--dim);
  font-size: 0.85rem;
  font-style: italic;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .posts-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .category-nav {
    position: relative;
    top: 0;
  }

  .category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .category-list li {
    margin-bottom: 0;
  }

  .category-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }

  .category-link.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }
}

/* Legacy posts list (kept for compatibility) */
.posts-list h2 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.post-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: all 0.3s;
}

.post-preview:hover {
  border-color: var(--border-hover);
}

.post-preview h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.post-preview h3 a {
  color: var(--text);
}

.post-preview h3 a:hover {
  color: var(--accent);
}

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.75rem;
  line-height: 1.6;
}

/* ========================================
   Post Meta
   ======================================== */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  color: var(--dim);
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

.post-tags {
  display: flex;
  gap: 0.5rem;
}

.tag {
  background: var(--bg-elevated);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   Article
   ======================================== */
article {
  margin: 0;
  padding: 0;
}

.post {
  max-width: var(--max-width-content);
  margin: 0;
  padding: 0;
  width: 100%;
}

header.post-header {
  margin: 0 0 3.5rem 0;
  padding: 0 0 var(--section-padding-bottom) 0;
  border-bottom: 1px solid var(--border);
}

.post-header {
  margin: 0 0 3.5rem 0;
  padding: 0 0 var(--section-padding-bottom) 0;
  border-bottom: 1px solid var(--border);
}

h1.post-title,
.post-title {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1.5rem 0;
  padding: 0;
  letter-spacing: -0.02em;
}

/* Post Content */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: var(--section-margin-top);
  margin-bottom: var(--heading-margin-bottom);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 100px;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: var(--heading-margin-top);
  margin-bottom: 0.75rem;
  scroll-margin-top: 100px;
}

.post-content p {
  margin-bottom: var(--paragraph-margin);
  color: var(--text-secondary);
}

.post-content strong {
  color: var(--text);
  font-weight: 600;
}

.post-content ul,
.post-content ol {
  margin-bottom: var(--paragraph-margin);
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.post-content li {
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.post-content li::marker {
  color: var(--accent);
}

/* ========================================
   Callout Blocks
   ======================================== */
.callout {
  padding: 1rem var(--card-padding);
  border-radius: 4px;
  margin: var(--content-element-margin) 0;
  border-left: 3px solid;
}

.callout-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout-content {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.callout-content p:last-child {
  margin-bottom: 0;
}

.callout-tip {
  background: var(--tip-bg);
  border-color: var(--tip-border);
}

.callout-tip .callout-title {
  color: var(--tip-border);
}

.callout-note {
  background: var(--note-bg);
  border-color: var(--note-border);
}

.callout-note .callout-title {
  color: var(--note-border);
}

.callout-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.callout-warning .callout-title {
  color: var(--warning-border);
}

.callout-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.callout-danger .callout-title {
  color: var(--danger-border);
}

.callout-question {
  background: var(--question-bg);
  border-color: var(--question-border);
}

.callout-question .callout-title {
  color: var(--question-border);
}

/* ========================================
   Code Blocks
   ======================================== */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* Inline code */
:not(pre)>code {
  background: var(--bg-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--accent);
  border: 1px solid var(--border);
}

/* Code blocks with header */
.code-block {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.code-language {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}

.code-actions {
  display: flex;
  gap: 0.5rem;
}

.code-action-btn {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Pre block */
pre {
  background: var(--bg-card) !important;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 0;
}

.code-block pre {
  border-radius: 0;
}

pre:not(.code-block pre) {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
}

pre code {
  background: none !important;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  border: none;
}

/* Syntax highlighting - Custom Prism.js overrides to match CodeMirror theme */
.token.keyword {
  color: #c792ea !important;
}

.token.function {
  color: #82aaff !important;
}

.token.class-name {
  color: #ffcb6b !important;
}

.token.string {
  color: #c3e88d !important;
}

.token.number {
  color: #f78c6c !important;
}

.token.operator {
  color: #89ddff !important;
}

.token.punctuation {
  color: #89ddff !important;
}

.token.builtin {
  color: #ffcb6b !important;
}

.token.comment {
  color: #676e95 !important;
  font-style: italic;
}

.token.boolean {
  color: #f78c6c !important;
}

.token.constant {
  color: #f78c6c !important;
}

.token.property {
  color: #82aaff !important;
}

.token.decorator {
  color: #ffcb6b !important;
}

.token.variable {
  color: #e8e8e8 !important;
}

.token.parameter {
  color: #89ddff !important;
}

.token.triple-quoted-string {
  color: #c3e88d !important;
}

/* ========================================
   Math (KaTeX)
   ======================================== */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1.5rem 1rem;
  margin: 1.5rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.katex {
  font-size: 1.1em;
}

/* ========================================
   Tables
   ======================================== */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0;
}

.post-content th,
.post-content td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.post-content th {
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}

.post-content td {
  color: var(--text-secondary);
}

.post-content tr:last-child td {
  border-bottom: none;
}

/* ========================================
   Images
   ======================================== */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.post-content img.invert-dark {
  filter: invert(0.9) hue-rotate(180deg);
}

.post-content figcaption {
  text-align: center;
  color: var(--dim);
  font-size: 0.8rem;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

/* ========================================
   Multi-Image Layouts
   ======================================== */
/* Two-column image layout */
.image-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.image-row figure {
  margin: 0;
}

.image-row img {
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  cursor: pointer;
}

.image-row img:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.image-row figcaption {
  text-align: center;
  color: var(--dim);
  font-size: 0.75rem;
  margin-top: 0.5rem;
  font-style: italic;
}

/* Image grid layout (flexible columns) */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.image-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.image-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.image-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.image-grid figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all 0.3s ease;
}

.image-grid figure:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.image-grid img {
  width: 100%;
  height: auto;
  margin: 0;
  border: none;
  border-radius: 0;
  display: block;
  transition: transform 0.3s ease;
}

.image-grid figure:hover img {
  transform: scale(1.05);
}

.image-grid figcaption {
  padding: 0.75rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  background: var(--bg-elevated);
  margin: 0;
  border-top: 1px solid var(--border);
}

/* Image grid with square aspect ratio */
.image-grid.square figure {
  aspect-ratio: 1;
}

.image-grid.square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Masonry-style grid (varied heights) */
.image-grid.masonry {
  display: block;
  column-count: 3;
  column-gap: 1rem;
}

.image-grid.masonry figure {
  break-inside: avoid;
  margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .image-row {
    grid-template-columns: 1fr;
  }

  .image-grid.cols-3,
  .image-grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .image-grid.masonry {
    column-count: 2;
  }
}

@media (max-width: 480px) {

  .image-grid,
  .image-grid.cols-2,
  .image-grid.cols-3,
  .image-grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .image-grid.masonry {
    column-count: 1;
  }
}

/* ========================================
   Blockquotes
   ======================================== */
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg-card);
  border-radius: 0 4px 4px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ========================================
   Citation Box (Always Visible)
   ======================================== */
.citation-box {
  margin-top: var(--section-margin-top);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.citation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.citation-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.citation-content {
  padding: 0;
}

.citation-content pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  font-size: 0.75rem;
}

.copy-bibtex-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-bibtex-btn:hover {
  background: #22c55e;
}

/* ========================================
   HuggingFace / Gradio Embeds
   ======================================== */
.embed-wrapper {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.embed-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.embed-logo {
  height: 18px;
  opacity: 0.8;
}

.embed-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.embed-body {
  position: relative;
  height: 600px;
  background: var(--bg-card);
  overflow: hidden;
}

.embed-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ========================================
   Run Code (Codespaces)
   ======================================== */
.run-in-codespaces {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #238636;
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
}

.run-in-codespaces:hover {
  background: #2ea043;
  color: #fff;
}

/* ========================================
   Comments
   ======================================== */
.comments {
  margin-top: var(--section-margin-top);
  padding-top: var(--section-padding-top);
  border-top: 1px solid var(--border);
}

.comments h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  margin-top: 2rem;
}

.footer-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 var(--spacing-horizontal);
  text-align: center;
  width: 100%;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footer-links a:hover {
  color: var(--text);
}

.copyright {
  color: var(--dim);
  font-size: 0.7rem;
}

/* ========================================
   Responsive Breakpoints - UNIFIED SYSTEM
   ======================================== */

/* Large Desktop (1441px+) - Extra wide spacing */
@media (min-width: 1441px) {
  :root {
    --spacing-horizontal: 100px;
  }
}

/* Standard Desktop (1025px - 1440px) - Default spacing */
/* Uses :root default of 80px */

/* Tablet (769px - 1024px) - Reduced spacing */
@media (max-width: 1024px) {
  :root {
    --spacing-horizontal: 60px;
  }
  
  .content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}

/* Mobile (up to 768px) - Minimal spacing */
@media (max-width: 768px) {
  :root {
    --spacing-horizontal: 24px;
    --spacing-vertical-top: 50px;   /* Slightly reduced for mobile */
    --spacing-vertical-bottom: 60px;
  }

  .site-nav {
    gap: 1rem;
  }

  .post-title {
    font-size: 1.75rem;
  }
  
  .content {
    gap: 40px;
  }
  
  .home-header h1 {
    font-size: 2rem;
  }
}

/* Small Mobile (up to 480px) - Compact spacing */
@media (max-width: 480px) {
  :root {
    --spacing-horizontal: 20px;
  }
}

/* ========================================
   About Page (single column, no sidebar)
   ======================================== */
.about-page {
  max-width: var(--max-width-content);
  padding: 0;
}

.about-page h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 1.5rem 0;
  padding: 0;
}

.about-page h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.about-page p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.about-page ul {
  color: var(--text-secondary);
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.about-page li {
  margin-bottom: 0.5rem;
}

.about-page li::marker {
  color: var(--accent);
}

.about-page strong {
  color: var(--text);
}

.about-page hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ========================================
   Search Page - Clean & Centered
   ======================================== */
.search-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0;
  width: 100%;
  text-align: center;
}

.search-header {
  margin: 0 0 2.5rem 0;
  padding: 0;
}

.search-header h1 {
  font-size: 2.5rem;
  margin: 0;
  padding: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  color: var(--dim);
  pointer-events: none;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: all 0.3s ease;
  font-family: var(--font-sans);
  text-align: left;
  cursor: text;
}

.search-input:hover {
  border-color: var(--accent);
  background: rgba(17, 17, 17, 0.8);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.08);
}

.search-input:hover + .search-status {
  color: var(--accent);
}

.search-input-wrapper:hover .search-icon {
  color: var(--accent);
  opacity: 0.8;
  transform: scale(1.05);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(17, 17, 17, 0.95);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.search-input:focus + .search-status {
  color: var(--accent);
}

.search-input:focus ~ .search-icon {
  color: var(--accent);
  opacity: 1;
}

.search-input::placeholder {
  color: var(--dim);
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.search-input:hover::placeholder {
  opacity: 0.8;
}

.search-input:focus::placeholder {
  opacity: 0.4;
}

.search-status {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--dim);
  pointer-events: none;
  user-select: none;
  transition: color 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning-border);
  animation: pulse 1.5s infinite;
}

.status-dot.ready {
  background: var(--accent);
  animation: none;
}

.status-dot.error {
  background: var(--danger-border);
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.search-results {
  margin-top: 2rem;
  min-height: 30vh;
}

.search-placeholder {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--dim);
  opacity: 0.6;
}

.search-placeholder svg {
  margin-bottom: 1rem;
}

.search-placeholder p {
  margin: 0.75rem 0 0 0;
  font-size: 0.95rem;
}

.search-hint {
  font-size: 0.8rem;
  opacity: 0.5;
  margin-top: 0.5rem;
}

.search-result {
  display: block;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
  text-decoration: none;
  transition: all 0.2s;
  text-align: left;
}

.search-result:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 222, 128, 0.1);
}

.search-result-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.search-result-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--dim);
}

.search-result-score {
  color: var(--accent);
}

.search-result-tags {
  display: flex;
  gap: 0.5rem;
}

.search-result-tag {
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border-radius: 2px;
}

.search-no-results {
  text-align: center;
  padding: 3rem;
  color: var(--dim);
}

.search-loading {
  text-align: center;
  padding: 2rem;
  color: var(--dim);
}

.search-loading .spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.search-fallback-notice {
  padding: 0.75rem 1rem;
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--note-border);
  text-align: left;
}

/* Search Page Responsive */
@media (max-width: 768px) {
  .search-page {
    max-width: 100%;
  }
  
  .search-header {
    margin: 0 0 2rem 0;
  }
  
  .search-header h1 {
    font-size: 2rem;
  }
  
  .search-input-wrapper {
    max-width: 100%;
  }
  
  .search-input {
    padding: 0.875rem 1rem 0.875rem 3rem;
    font-size: 0.9rem;
    border-radius: 6px;
  }
  
  .search-status {
    font-size: 0.6rem;
  }
  
  .search-placeholder {
    padding: 4rem 1rem;
  }
}

/* Fix: Citation box pre should have no border */
.citation-box pre,
.citation-content pre {
  border: none !important;
  margin: 0 !important;
  background: var(--bg-card) !important;
}

/* Rouge code block styling (Jekyll's highlighter) */
.highlight {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.highlight pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
}

/* Rouge table-based line numbers */
.rouge-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.rouge-table td {
  padding: 0;
  margin: 0;
  vertical-align: top;
}

.rouge-gutter {
  width: 40px;
  min-width: 40px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  user-select: none;
  text-align: right;
}

/* Line numbers - must match code exactly */
.rouge-gutter pre.lineno {
  padding: 0.75rem 0.5rem 0.75rem 0.5rem !important;
  margin: 0 !important;
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1.6;
  font-family: var(--font-mono);
  background: transparent !important;
  border: none !important;
}

.rouge-code {
  width: 100%;
}

/* Code content - must match line numbers exactly */
.rouge-code pre {
  padding: 0.75rem 1rem !important;
  margin: 0 !important;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ========================================
   Runnable Code Blocks (Pyodide)
   ======================================== */
.runnable-code {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.runnable-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.runnable-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}

.runnable-label svg {
  color: var(--accent);
}

.runnable-actions {
  display: flex;
  gap: 0.5rem;
}

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.run-btn:hover {
  background: #22c55e;
}

.run-btn:disabled {
  background: var(--dim);
  cursor: not-allowed;
}

.run-btn.loading {
  background: var(--dim);
  cursor: wait;
}

.run-btn .spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.runnable-code pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
}

.runnable-output {
  border-top: 1px solid var(--border);
  background: #0d0d0d;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}

.output-content {
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.output-content.error {
  color: #ef4444;
}

.output-content.empty {
  color: var(--dim);
  font-style: italic;
}

/* Pyodide loading indicator */
.pyodide-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--note-border);
}

.pyodide-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--note-border);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========================================
   Mermaid Diagrams
   ======================================== */
.mermaid-wrapper {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.mermaid-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}

.mermaid-body {
  padding: 1.5rem;
  background: var(--bg-card);
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.mermaid-body svg {
  max-width: 100%;
  height: auto;
}

.mermaid-error {
  color: var(--danger-border);
  font-size: 0.85rem;
  padding: 1rem;
  margin: 0;
}

/* ========================================
   Copy Button for Code Blocks
   ======================================== */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--dim);
  transition: all 0.2s;
  opacity: 0;
  z-index: 10;
}

pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* ========================================
   Code Editor (CodeMirror for Runnable Blocks)
   ======================================== */
.code-editor-container {
  width: 100%;
  min-height: 150px;
  background: var(--bg-card);
}

.code-editor-container .CodeMirror {
  height: auto;
  min-height: 150px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--bg-card);
  color: var(--text);
  border: none;
}

.code-editor-container .CodeMirror-gutters {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.code-editor-container .CodeMirror-linenumber {
  color: var(--dim);
  padding: 0 8px 0 4px;
}

.code-editor-container .CodeMirror-focused {
  background: #0f0f0f;
}

/* Python syntax highlighting colors */
.code-editor-container .cm-keyword {
  color: #c792ea;
}

.code-editor-container .cm-def {
  color: #82aaff;
}

.code-editor-container .cm-variable {
  color: #e8e8e8;
}

.code-editor-container .cm-variable-2 {
  color: #89ddff;
}

.code-editor-container .cm-variable-3 {
  color: #4ade80;
}

.code-editor-container .cm-string {
  color: #c3e88d;
}

.code-editor-container .cm-string-2 {
  color: #f78c6c;
}

.code-editor-container .cm-number {
  color: #f78c6c;
}

.code-editor-container .cm-operator {
  color: #89ddff;
}

.code-editor-container .cm-builtin {
  color: #ffcb6b;
}

.code-editor-container .cm-property {
  color: #82aaff;
}

.code-editor-container .cm-comment {
  color: #676e95;
  font-style: italic;
}

.code-editor-container .cm-meta {
  color: #ffcb6b;
}

.code-editor-container .cm-atom {
  color: #f78c6c;
}

.code-editor-container .CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

.code-editor-container .CodeMirror-selected {
  background: rgba(74, 222, 128, 0.15);
}

.code-editor-container .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03);
}

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.reset-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.reset-btn.reset-flash {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Interactive Math Tooltips
   ======================================== */
.math-term {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--accent);
}

.math-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-style: normal;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.math-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
}

.math-term:hover .math-tooltip {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   Post Actions Bar (Like, Share, Comments)
   ======================================== */
.post-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.post-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
}

.post-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Like button specific styles */
.like-btn {
  transition: all 0.2s ease;
}

.like-btn.liked {
  border-color: #ef4444;
  color: #ef4444;
}

.like-btn.liked .heart-icon {
  fill: #ef4444;
  stroke: #ef4444;
}

.like-btn .like-count {
  font-weight: 600;
  margin-left: 0.25rem;
}

.like-btn.like-animate {
  transform: scale(1.1);
}

@keyframes heartBeat {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}

.like-btn.liked .heart-icon {
  animation: heartBeat 0.3s ease;
}


/* Share dropdown */
.share-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  min-width: 160px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.share-dropdown a,
.share-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-decoration: none;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}

.share-dropdown a:hover,
.share-dropdown button:hover {
  background: var(--bg-card);
  color: var(--text);
}

/* ========================================
   Related Posts Section
   ======================================== */
.related-posts {
  margin-top: var(--section-margin-top);
  padding-top: var(--section-padding-top);
  border-top: 1px solid var(--border);
}

.related-posts-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.related-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.related-post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  transition: all 0.3s;
}

.related-post-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.related-post-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.related-post-card h4 a {
  color: var(--text);
}

.related-post-card h4 a:hover {
  color: var(--accent);
}

.related-post-card .post-meta {
  font-size: 0.75rem;
}

/* ========================================
   Responsive Adjustments for New Features
   ======================================== */
@media (max-width: 768px) {
  .post-actions {
    flex-wrap: wrap;
  }

  .post-action-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.6rem;
  }

  .related-posts-grid {
    grid-template-columns: 1fr;
  }

  .math-tooltip {
    max-width: 200px;
    white-space: normal;
    font-size: 0.75rem;
  }
}

/* ========================================
   Image Comparison Slider
   ======================================== */
.image-compare {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.compare-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.compare-after,
.compare-before {
  position: relative;
  width: 100%;
}

.compare-after img,
.compare-before img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.compare-before {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  clip-path: inset(0 50% 0 0);
}

.compare-before img {
  height: 100%;
  width: auto;
  min-width: 100%;
  object-fit: cover;
}

.compare-slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--accent);
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 10;
  transition: background 0.2s;
}

.compare-slider:hover {
  background: #22c55e;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: var(--bg-elevated);
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.compare-handle svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.compare-label {
  position: absolute;
  bottom: 12px;
  padding: 0.35rem 0.75rem;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text);
  pointer-events: none;
}

.compare-label-left {
  left: 12px;
}

.compare-label-right {
  right: 12px;
}

/* ========================================
   Image Lightbox
   ======================================== */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
  max-width: 600px;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  z-index: 10;
}

.lightbox-close:hover {
  border-color: var(--text);
  color: var(--text);
  background: var(--bg-elevated);
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  z-index: 10;
}

.lightbox-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lightbox-nav svg {
  width: 24px;
  height: 24px;
}

.lightbox-prev {
  left: 1.5rem;
}

.lightbox-next {
  right: 1.5rem;
}

.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--dim);
}

/* ========================================
   Video Embed Support
   ======================================== */
.video-wrapper {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.video-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
}

.video-body {
  position: relative;
  background: #000;
}

.video-body video {
  display: block;
  width: 100%;
  max-height: 600px;
}

.video-body iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
}

.video-caption {
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ========================================
   Enhanced Callouts (New Types)
   ======================================== */
/* Abstract - Purple gradient */
.callout-abstract {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(168, 85, 247, 0.05) 100%);
  border-color: #8b5cf6;
}

.callout-abstract .callout-title {
  color: #a78bfa;
}

/* Definition - Blue solid */
.callout-definition {
  background: rgba(59, 130, 246, 0.08);
  border-color: #3b82f6;
}

.callout-definition .callout-title {
  color: #60a5fa;
}

/* Proof - Green with serif font for math */
.callout-proof {
  background: rgba(34, 197, 94, 0.08);
  border-color: #22c55e;
}

.callout-proof .callout-title {
  color: #4ade80;
}

.callout-proof .callout-content {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-style: italic;
}

/* Example - Orange */
.callout-example {
  background: rgba(249, 115, 22, 0.08);
  border-color: #f97316;
}

.callout-example .callout-title {
  color: #fb923c;
}

/* Critical - Red with pulsing border */
.callout-critical {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  animation: pulseBorder 2s ease-in-out infinite;
}

@keyframes pulseBorder {

  0%,
  100% {
    border-color: #ef4444;
  }

  50% {
    border-color: #f87171;
  }
}

.callout-critical .callout-title {
  color: #f87171;
}

/* Success - Green checkmark */
.callout-success {
  background: rgba(34, 197, 94, 0.08);
  border-color: #22c55e;
}

.callout-success .callout-title {
  color: #4ade80;
}

/* Gradient border option */
.callout-gradient {
  border-image: linear-gradient(135deg, var(--accent), #a78bfa, #f472b6) 1;
}

/* ========================================
   Collapsible Code Blocks
   ======================================== */
.collapsible-code {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.collapsible-code summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: all 0.2s;
}

.collapsible-code summary::-webkit-details-marker {
  display: none;
}

.collapsible-code summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--dim);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
}

.collapsible-code[open] summary::before {
  transform: rotate(90deg);
}

.collapsible-code summary:hover {
  color: var(--text-secondary);
}

.collapsible-code summary svg {
  width: 14px;
  height: 14px;
}

.collapsible-code .code-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.collapsible-code[open] .code-content {
  max-height: 2000px;
}

.collapsible-code pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
}

/* ========================================
   PDF Export Styles (Print-specific)
   ======================================== */
@media print {

  .site-header,
  .sidebar,
  .post-actions,
  .related-posts,
  .citation-box,
  .comments,
  .giscus,
  .runnable-code .runnable-header,
  .lightbox-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .content {
    max-width: 100%;
    padding: 0;
    display: block;
  }

  .post-content {
    max-width: 100%;
  }

  .post-title {
    color: #000;
    font-size: 1.75rem;
  }

  pre,
  code {
    background: #f5f5f5 !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
  }

  .callout {
    background: #f9f9f9 !important;
    border-left: 4px solid #666 !important;
    color: #333;
    page-break-inside: avoid;
  }

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: #000;
    page-break-after: avoid;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .katex {
    font-size: 1em !important;
  }
}

/* ========================================
   Responsive - Visual Enhancements
   ======================================== */
@media (max-width: 768px) {
  .compare-handle {
    width: 36px;
    height: 36px;
  }

  .compare-handle svg {
    width: 12px;
    height: 12px;
  }

  .compare-label {
    font-size: 0.55rem;
    padding: 0.25rem 0.5rem;
  }

  .lightbox-close,
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }

  .lightbox-nav svg {
    width: 20px;
    height: 20px;
  }

  .lightbox-prev {
    left: 0.75rem;
  }

  .lightbox-next {
    right: 0.75rem;
  }
}

/* ========================================
   Backlinks / Linked Mentions
   ======================================== */
.backlinks-section {
  margin-top: 2.5rem;
  padding-top: var(--section-padding-top);
  border-top: 1px solid var(--border);
}

.backlinks-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 1rem;
}

.backlinks-title svg {
  color: var(--accent);
}

.backlinks-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.backlinks-loading,
.backlinks-empty,
.backlinks-error {
  color: var(--dim);
  font-size: 0.85rem;
  font-style: italic;
}

.backlink-item {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s;
}

.backlink-item:hover {
  border-color: var(--border-hover);
  transform: translateX(4px);
}

.backlink-title {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.backlink-context {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========================================
   Citations & References
   ======================================== */

.citation {
  font-size: 0.8em;
  vertical-align: super;
  margin: 0 0.1em;
}

.citation-link {
  color: var(--accent);
  text-decoration: none;
  padding: 0 0.1em;
  transition: color 0.2s;
}

.citation-link:hover {
  color: #fff;
  text-decoration: underline;
}

  .slides-section + .references-section {
    margin-top: var(--section-margin-bottom);
    padding-top: 0;
    border-top: none;
  }

  .references-section {
    margin-top: var(--section-margin-top);
    padding-top: var(--section-padding-top);
    border-top: 1px solid var(--border);
  }

  .references-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }

  /* ========================================
   Slides Section
   ======================================== */

  .slides-section {
    margin-top: var(--section-margin-top);
    padding-top: var(--section-padding-top);
    border-top: 1px solid var(--border);
  }

  .slides-collapsible {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    overflow: hidden;
  }

  .slides-collapsible + .slides-collapsible {
    margin-top: 1rem;
  }

  .slides-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: all 0.2s;
    background: var(--bg-elevated);
    border-bottom: 1px solid transparent;
  }

  .slides-summary::-webkit-details-marker {
    display: none;
  }

  .slides-summary:hover {
    background: var(--bg-card);
  }

  .slides-summary:hover .slides-icon {
    color: #22c55e;
    transform: scale(1.1);
  }

  .slides-summary:hover .slides-title {
    color: #22c55e;
  }

  .slides-summary::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid var(--dim);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.2s;
    flex-shrink: 0;
  }

  .slides-collapsible[open] .slides-summary::before {
    transform: rotate(90deg);
  }

  .slides-collapsible[open] .slides-summary {
    border-bottom-color: var(--border);
  }

  .slides-icon {
    color: var(--accent);
    flex-shrink: 0;
    transition: all 0.2s;
  }

  .slides-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
  }

  .slides-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--dim);
    margin-left: auto;
  }

  .slides-content {
    padding: 0;
  }

  .slides-content .slide-viewer {
    margin: 0;
    border: none;
    border-radius: 0;
  }

  .slides-content .slide-viewer:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }

.references-list {
  list-style: none;
  counter-reset: ref-counter;
}

.reference-item {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  scroll-margin-top: 100px;
}

.reference-item:target {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.05);
}

.ref-number {
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.ref-text {
  color: var(--text-secondary);
  line-height: 1.5;
}

.ref-authors {
  font-weight: 500;
  color: var(--text);
}

.ref-title {
  font-style: italic;
}

.ref-venue {
  color: var(--dim);
}

.ref-link {
  margin-left: 0.5rem;
  color: var(--accent);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.ref-link:hover {
  opacity: 1;
}

.ref-doi {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--dim);
  padding: 0.1em 0.4em;
  background: var(--bg-elevated);
  border-radius: 2px;
}

.reference-missing {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

/* Simple references (from frontmatter) */
.simple-refs .references-list {
  list-style-type: decimal;
  list-style-position: outside;
  padding-left: 2.5rem;
  margin-left: 0;
}

.simple-refs .reference-item {
  display: list-item;
  padding: 0.5rem 0;
  padding-left: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.simple-refs .reference-item::marker {
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono);
}

.simple-refs .ref-link-text {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.simple-refs .ref-link-text:hover {
  text-decoration: underline;
  color: #fff;
}

.simple-refs .ref-authors {
  margin-right: 0.25em;
}

.simple-refs .ref-year {
  margin: 0 0.25em;
}

.simple-refs .ref-venue {
  margin-left: 0.25em;
}

/* ========================================
   Cross-References
   ======================================== */

.cross-ref {
  color: var(--accent);
  font-weight: 500;
}

.cross-ref:hover {
  text-decoration: underline;
}

.ref-anchor {
  display: block;
  position: relative;
  top: -100px;
  visibility: hidden;
}

.ref-broken {
  color: var(--danger-border);
  font-weight: bold;
}

.eq-ref {
  font-family: var(--font-mono);
}

/* Equation numbering */
.katex-display {
  position: relative;
}

.numbered-equation .equation-number {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.eq-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.25rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, border-color 0.2s;
  color: var(--dim);
}

.katex-display:hover .eq-copy-btn {
  opacity: 1;
}

.eq-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.eq-copy-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========================================
   Inline Formatting
   ======================================== */

.inline-highlight {
  background: rgba(234, 179, 8, 0.3);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  color: #fbbf24;
}

.kbd-combo {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
}

.kbd-combo kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.5em;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text);
  box-shadow: 0 2px 0 var(--border);
}

.kbd-plus {
  color: var(--dim);
  font-size: 0.8em;
}

.inline-abbr {
  border-bottom: 1px dotted var(--dim);
  cursor: help;
  text-decoration: none;
}

.small-caps {
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

/* ========================================
   Theorem Environments
   ======================================== */

.callout-theorem,
.callout-lemma,
.callout-corollary,
.callout-proposition {
  background: rgba(147, 51, 234, 0.1);
  border-color: #9333ea;
}

.callout-theorem .callout-title,
.callout-lemma .callout-title,
.callout-corollary .callout-title,
.callout-proposition .callout-title {
  color: #a855f7;
}

.callout-axiom,
.callout-remark {
  background: rgba(99, 102, 241, 0.1);
  border-color: #6366f1;
}

.callout-axiom .callout-title,
.callout-remark .callout-title {
  color: #818cf8;
}

.theorem-type {
  font-weight: 700;
}

/* ========================================
   Notes Layout
   ======================================== */

.note {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0;
  padding: 0;
}

.note-header {
  margin-bottom: 3.5rem;
  padding-bottom: var(--section-padding-bottom);
  border-bottom: 1px solid var(--border);
}

.note-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.note-subject {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  background: rgba(74, 222, 128, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
}

.note-updated {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--dim);
}

  .note-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
  }

  /* WIP Badge */
  .wip-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
    padding: 0.3rem 0.75rem;
    border-radius: 2px;
  }

  .wip-badge svg {
    width: 12px;
    height: 12px;
    color: #eab308;
  }

  .wip-badge-small {
    font-size: 0.55rem;
    padding: 0.2rem 0.5rem;
    gap: 0.3rem;
  }

  .wip-badge-small svg {
    width: 10px;
    height: 10px;
  }

.note-description {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 0;
  line-height: 1.6;
}

.note-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.note-content {
  font-size: 1rem;
  line-height: 1.8;
}

/* Notes sidebar */
.notes-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.notes-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
}

.notes-nav-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--dim);
  margin-bottom: 1rem;
}

.subject-group {
  margin-bottom: 0.5rem;
}

.subject-group summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  padding: 0.5rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subject-group summary::before {
  content: '▸';
  color: var(--dim);
  font-size: 0.8em;
  transition: transform 0.2s;
}

.subject-group[open] summary::before {
  transform: rotate(90deg);
}

.subject-notes-list {
  list-style: none;
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.subject-notes-list li {
  margin: 0.25rem 0;
}

.subject-notes-list a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: block;
  padding: 0.25rem 0;
}

.subject-notes-list a:hover {
  color: var(--accent);
}

.subject-notes-list li.active a {
  color: var(--accent);
  font-weight: 500;
}

/* Related notes */
.related-notes {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

/* Specific selector for notes with subject */
.note .related-notes,
nav.related-notes {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

.related-notes h3 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 2.5rem;
}

.related-notes ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.related-notes li {
  margin-bottom: 0;
  padding: 0;
}

.related-notes a {
  color: var(--text-secondary);
  display: block;
  padding: 1rem 0;
  transition: all 0.2s;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}

.related-notes li:first-child a {
  padding-top: 0;
}

.related-notes a:hover {
  color: var(--accent);
  transform: translateX(4px);
  border-bottom-color: var(--accent);
}

/* ========================================
   Notes Index Page
   ======================================== */

.notes-index {
  max-width: 100%;
  width: 100%;
  padding: 0;
}

/* Add subtle gradient background for subjects section */
.notes-index .post-content {
  position: relative;
}

.notes-index .post-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 400px;
  background: radial-gradient(ellipse at top, rgba(74, 222, 128, 0.03), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.notes-index .post-header {
  margin: 0 0 2rem 0;
  padding: 0 0 1.5rem 0;
  border-bottom: 1px solid var(--border);
  max-width: 100%;
}

.notes-index .post-content {
  max-width: 100%;
  width: 100%;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.25rem;
  margin: 1.5rem 0 2rem 0;
  padding: 0;
}

.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1rem;
  text-align: center;
  text-decoration: none;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 140px;
  position: relative;
}

.subject-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(74, 222, 128, 0.12);
  background: rgba(17, 17, 17, 0.9);
}

.subject-card.empty {
  opacity: 0.4;
  cursor: not-allowed;
}

.subject-card.empty:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
  background: var(--bg-card);
}

.subject-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 222, 128, 0.08);
  border-radius: 12px;
  color: var(--accent);
  transition: all 0.3s;
}

.subject-icon svg {
  width: 24px;
  height: 24px;
}

.subject-card:hover .subject-icon {
  background: rgba(74, 222, 128, 0.15);
  transform: scale(1.05);
}

.subject-card.empty .subject-icon {
  opacity: 0.5;
}

.subject-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.subject-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.subject-card:hover .subject-count {
  color: var(--accent);
}

/* Subject sections */
.subject-section {
  margin-top: var(--section-margin-top);
  padding-top: var(--section-padding-top);
  border-top: 1px solid var(--border);
  scroll-margin-top: 100px;
}

.subject-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subject-section-title::before {
  content: "";
  width: 4px;
  height: 1em;
  background: var(--accent);
  border-radius: 2px;
}

.notes-list {
  display: grid;
  gap: 1rem;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
  text-decoration: none;
  transition: all 0.3s;
}

.note-card:hover {
  border-color: var(--border-hover);
  transform: translateX(4px);
}

.note-card .note-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.note-card:hover .note-title {
  color: var(--accent);
}

.note-card .note-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.note-card .note-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.note-card .note-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--dim);
}

.note-tags-inline {
  display: flex;
  gap: 0.5rem;
}

.tag-small {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--accent);
  background: rgba(74, 222, 128, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 1200px) {
  .subjects-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .subjects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .subjects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .subject-card {
    padding: 1.5rem 1rem;
  }

  .subject-icon {
    width: 48px;
    height: 48px;
  }

  .subject-icon svg {
    width: 24px;
    height: 24px;
  }
  
  .subject-name {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .subjects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .subject-card {
    padding: 1.25rem 0.875rem;
  }
}

/* ========================================
   Subject & Sub-Subject Page Layouts
   (Consolidated from inline styles)
   ======================================== */

/* Page layout containers */
.subject-page,
.sub-subject-page {
  width: 100%;
  padding: 0;
}

/* Shared page header (subject/sub-subject) */
.subject-page .page-header,
.sub-subject-page .page-header {
  margin: 0 0 3rem 0;
  padding: 0 0 2rem 0;
  border-bottom: 1px solid var(--border);
}

.subject-page .page-header h1,
.sub-subject-page .page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.5rem 0;
  color: var(--text);
}

.subject-page .page-header .description,
.sub-subject-page .page-header .description {
  color: var(--text-secondary);
  margin: 0;
}

/* Breadcrumb Navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--dim);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--dim);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .sep {
  opacity: 0.5;
}

.breadcrumb .current {
  color: var(--text);
}

/* Topics Grid (subject page) */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
}

.topic-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.topic-card.empty {
  opacity: 0.5;
}

.topic-card.empty:hover {
  transform: none;
  border-color: var(--border);
}

.topic-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.topic-card:hover h3 {
  color: var(--accent);
}

.topic-card .count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* General notes section */
.general-notes {
  margin-top: var(--section-margin-top);
  padding-top: var(--section-padding-top);
  border-top: 1px solid var(--border);
}

.general-notes h2 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 2rem;
}

/* Notes grid for subject page */
.general-notes .notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Sub-subject notes list */
.sub-subject-page .notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sub-subject-page .notes-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.sub-subject-page .notes-list li:last-child {
  border-bottom: none;
}

.sub-subject-page .notes-list a {
  color: var(--text);
  font-size: 1rem;
  text-decoration: none;
}

.sub-subject-page .notes-list a:hover {
  color: var(--accent);
}

.sub-subject-page .empty {
  color: var(--dim);
}

/* Accent colored text (for subject codes like CS224R) */
.accent-text {
  color: var(--accent) !important;
}

.sub-subject-page .page-header h1.accent-text {
  color: var(--accent) !important;
}

/* Lecture list styling */
.lecture-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lecture-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem 0;
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
  transition: all 0.2s;
}

.lecture-item:hover {
  transform: translateX(4px);
}

.lecture-number {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--dim);
  font-weight: 600;
  flex-shrink: 0;
  width: 2rem;
}

.lecture-info {
  flex: 1;
}

.lecture-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.lecture-item:hover .lecture-title {
  color: var(--accent);
}

.lecture-topics {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
}

/* Responsive adjustments for subject pages */
@media (max-width: 600px) {
  .topics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .general-notes .notes-grid {
    grid-template-columns: 1fr;
  }
}