/* Typography */
@font-face {
  font-family: 'Mona Sans';
  src: url('/obsidianp/assets/fonts/MonaSans-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Mona Sans';
  src: url('/obsidianp/assets/fonts/MonaSans-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: 'Mona Sans';
  src: url('/obsidianp/assets/fonts/MonaSans-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: 'Mona Sans';
  src: url('/obsidianp/assets/fonts/MonaSans-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: 'Monaspace Krypton';
  src: url('/obsidianp/assets/fonts/MonaspaceKrypton-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}

/* CSS Variables for theming */
:root {
  --font-family-main: 'Mona Sans', system-ui, -apple-system, sans-serif;
  --font-family-heading: var(--font-family-main);
  --font-family-code: 'Monaspace Krypton', monospace;
  
  /* Font sizes */
  --font-size-3xs: 7px;
  --font-size-2xs: 9px;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 24px;
  --font-size-3xl: 32px;
  
  /* Spacing */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Layout */
  --sidebar-width: 280px;
  --right-sidebar-width: 300px;
  --border-radius: 6px;
  --border-radius-sm: 4px;
  --border-radius-lg: 12px;
  --viewport-block: 100vh;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@supports (height: 100svh) {
  :root {
    --viewport-block: 100svh;
  }
}

@supports (height: 100dvh) {
  :root {
    --viewport-block: 100dvh;
  }
}

/* Light Theme */
:root,
[data-theme="light"] {
  /* Colors - Light Theme */
  --color-primary: #8b5cf6;
  --color-primary-hover: #a78bfa;
  --color-accent: #8b5cf6;
  --color-accent-hover: #a78bfa;
  
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #fdfdfd;
  --color-bg-tertiary: #f9f9f9;
  --color-bg-elevated: #ffffff;
  
  --color-text-primary: #200f2a;
  --color-text-secondary: #584769;
  --color-text-muted: #72648b;
  --color-text-faint: #9f94b8;
  
  --color-border: #e9e9e9;
  --color-border-subtle: #f4f4f4;
  --color-border-hover: #a9a9a9;
  --color-border-focus: #8b5cf6;

  --color-link: #8b5cf6;
  --color-link-hover: #a78bfa;
  --color-link-external: #22d3ee;
  
  --color-selection: rgba(124, 58, 237, 0.1);
  --color-highlight: #b08d00;
  
  /* Graph colors - Light theme */
  --color-graph-node: #d1d5db;
  --color-graph-node-active: #9ca3af;
  --color-graph-highlight: #8b5cf6;
  --color-graph-tag: #10b981;
  --color-graph-edge: #e5e7eb;
  --color-graph-edge-active: #8b5cf6;
}

/* Dark Theme */
[data-theme="dark"] {
  /* Colors - Dark Theme */
  --color-primary: #8b5cf6;
  --color-primary-hover: #a78bfa;
  --color-accent: #8b5cf6;
  --color-accent-hover: #a78bfa;
  
  --color-bg-primary: #1e1e1e;
  --color-bg-secondary: #262626;
  --color-bg-tertiary: #333333;
  --color-bg-elevated: #1f1f1f;
  
  --color-text-primary: #ffffff;
  --color-text-secondary: #fdfdfd;
  --color-text-muted: #f1f1f1;
  --color-text-faint: #9f94b8;
  
  --color-border: #565656;
  --color-border-subtle: #2e2e2e;
  --color-border-hover: #868686;
  --color-border-focus: #8b5cf6;

  --color-link: #8b5cf6;
  --color-link-hover: #a78bfa;
  --color-link-external: #22d3ee;
  
  --color-selection: rgba(124, 58, 237, 0.1);
  --color-highlight: #fef3c7;
  
  /* Graph colors - Dark theme */
  --color-graph-node: #9ca3af;
  --color-graph-node-active: #6b7280;
  --color-graph-highlight: #a78bfa;
  --color-graph-tag: #10b981;
  --color-graph-edge: #6b7280;
  --color-graph-edge-active: #a78bfa;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden; /* Prevent html scroll */
}

body {
  font-family: var(--font-family-main);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
  margin: 0;
  padding: 0;
  min-height: var(--viewport-block);
  overflow: hidden; /* Prevent body scroll */
  width: 100%;
  /* iOS Safari: Use relative instead of fixed to avoid layout issues */
  position: relative;
  /* Prevent pull-to-refresh and overscroll */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Layout */
.app-container {
  display: flex;
  overflow: hidden;
  position: relative; /* Ensure proper containment */
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-color: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px; /* Explicit height to match mobile header */
  box-sizing: border-box; /* Include border in height calculation */
}

.sidebar-title-section {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.vault-title-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.vault-title-link:hover,
.vault-title-link:visited,
.vault-title-link:active {
  text-decoration: none;
  color: inherit;
}

.vault-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.sidebar-controls {
  display: flex;
  gap: var(--space-xs);
}

/* Graph button in sidebar - hidden by default, shown when right sidebar is not visible */
.sidebar-graph-button {
  display: none;
}

.icon-button {
  background: none;
  border: none;
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

/* Search */
.search-container {
  padding: var(--space-md);
  position: relative;
}

#search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
}

#search-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: var(--space-md);
  right: var(--space-md);
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
}

.search-result {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background-color: var(--color-bg-secondary);
}

.search-result-title {
  font-weight: 500;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.search-result-excerpt {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* Search highlighting */
mark {
  color: var(--color-bg-primary);
  background-color: var(--color-highlight);
  border-radius: 2px;
  padding: 0;
}

/* Sidebar content */
.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: var(--space-xs) 0; /* Reduced from space-sm to space-xs */
}

.nav-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nav-section-header {
  flex-shrink: 0;
}

#folder-tree {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  max-height: 100%;
  overscroll-behavior: contain; /* Prevent scroll chaining to body */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.nav-section {
  margin-bottom: var(--space-xs);
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  padding: 0 var(--space-md);
}

.nav-section h3 {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0;
  flex: 1;
}

.expand-collapse-button {
  opacity: 0.6;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  padding: 2px;
  border-radius: var(--border-radius-sm);
}

.expand-collapse-button:hover {
  opacity: 1;
  background-color: var(--color-bg-tertiary);
}

.expand-collapse-button.all-expanded {
  opacity: 1;
  background-color: var(--color-primary);
  color: var(--color-bg-primary);
}

.expand-collapse-button.all-expanded:hover {
  background-color: var(--color-primary-hover);
}

.nav-item {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.nav-item.active {
  background-color: var(--color-primary);
  color: white;
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: var(--viewport-block);
}

.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100%;
}

/* Right sidebar */
.right-sidebar {
  width: var(--right-sidebar-width);
  min-width: var(--right-sidebar-width);
  display: none; /* Hidden by default, shown with media query */
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--space-md);
}

/* Show right sidebar on larger screens */
@media (min-width: 1200px) {
  .right-sidebar {
    display: flex;
  }
}

/* Ensure right sidebar is hidden on mobile and tablet */
@media (max-width: 1199px) {
  .right-sidebar {
    display: none !important;
  }
}

.right-sidebar-section {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* margin-bottom: var(--space-lg); Add spacing between sections */
}

.right-sidebar-section:last-child {
  margin-bottom: 0;
  flex: 1;
}

.right-sidebar-header {
  padding: 0 var(--space-md) var(--space-sm) var(--space-md); /* Smaller horizontal padding */
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.right-sidebar-header h3 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.graph-controls {
  display: flex;
  gap: var(--space-xs);
}

.graph-expand-btn {
  padding: 4px;
}

.mini-graph-container {
  height: 200px;
  /* padding: 0 var(--space-xl); Align with note content padding */
  margin: 0 var(--space-md) var(--space-md) var(--space-md); /* Smaller horizontal margins */
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.table-of-contents {
  padding: 0 var(--space-md) var(--space-md); /* Smaller horizontal padding */
  overflow-y: auto;
  flex: 1;
  /* Prevent scroll chaining on iPadOS Safari */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.toc-placeholder {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  /* margin-bottom: var(--space-xs); */
  padding-bottom: var(--space-xs);
  position: relative;
}

.toc-item a {
  display: block;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  padding: var(--space-xs) 0;
  border-radius: var(--border-radius-sm);
  transition: color 0.2s ease;
}

.toc-item a:hover {
  color: var(--color-text-primary);
}

/* Embedded content styling */
.toc-item.toc-embed-title a {
  font-weight: 500;
  opacity: 0.9;
}

.toc-item.toc-embedded:not(.toc-embed-title) a {
  opacity: 0.8;
  font-size: 0.95em;
}

.toc-item.level-2 { padding-left: 0; }
.toc-item.level-3 { padding-left: 20px; }
.toc-item.level-4 { padding-left: 40px; }
.toc-item.level-5 { padding-left: 60px; }
.toc-item.level-6 { padding-left: 80px; }

/* Indentation guides for TOC items - show parent levels only */
.toc-item {
  position: relative;
}

/* Level 2 (h2) - shows 0 guide lines */
.toc-item.level-2::before {
  content: '';
  /* No guides for level 2 */
}

/* Level 3 (h3) - shows 1 guide line at 4px */
.toc-item.level-3::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  height: 100%;
  width: 1px;
  background-color: var(--color-border);
  opacity: 1.0;
}

/* Level 4 (h4) - shows 2 guide lines at 4px and 24px */
.toc-item.level-4::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  height: 100%;
  width: 1px;
  background-color: var(--color-border);
  opacity: 1.0;
  box-shadow: 20px 0 0 var(--color-border);
}

/* Level 5 (h5) - shows 3 guide lines at 4px, 24px, and 44px */
.toc-item.level-5::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  height: 100%;
  width: 1px;
  background-color: var(--color-border);
  opacity: 1.0;
  box-shadow: 
    20px 0 0 var(--color-border),
    40px 0 0 var(--color-border);
}

/* Level 6 (h6) - shows 4 guide lines at 4px, 24px, 44px, and 64px */
.toc-item.level-6::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  height: 100%;
  width: 1px;
  background-color: var(--color-border);
  opacity: 1.0;
  box-shadow: 
    20px 0 0 var(--color-border),
    40px 0 0 var(--color-border),
    60px 0 0 var(--color-border);
}

/* Active state for currently visible section */
.toc-item.active {
  /* background-color: var(--color-bg-tertiary); */
  /* border-radius: var(--border-radius-sm); */
  transition: background-color 0.2s ease;
}

.toc-item.active a {
  color: var(--color-accent);
  font-weight: 600;
  transition: color 0.2s ease;
}

.toc-item.active::before {
  opacity: 1;
}

/* Smooth transitions for all ToC items */
.toc-item {
  transition: background-color 0.2s ease;
}

.toc-item a {
  transition: color 0.2s ease;
}

/* Graph Modal Popups */
.graph-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.graph-modal.hidden {
  display: none;
}

.graph-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.graph-modal-content {
  position: relative;
  width: 90vw;
  height: 85vh;
  max-width: 1200px;
  background-color: var(--color-bg-secondary);
  border-radius: 24px; /* var(--border-radius); */
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Wrapper for close button and view switcher - ensures they stay side by side */
.graph-modal-controls-wrapper {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Container for view switcher - no longer needs absolute positioning */
.graph-modal-controls-container {
  display: flex;
  align-items: center;
  height: 40px;
  background: rgba(28, 28, 30, 0.5);
  backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  -webkit-backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  padding: 4px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 1px 1px rgba(255, 255, 255, 0.15),
              inset 0 -1px 1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .graph-modal-controls-container {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(100px) saturate(200%) brightness(1.2);
  -webkit-backdrop-filter: blur(100px) saturate(200%) brightness(1.2);
  border: 0.5px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
              0 1px 2px rgba(0, 0, 0, 0.05),
              inset 0 1px 1px rgba(255, 255, 255, 0.6),
              inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}

/* Close button - fully circular, inside flex wrapper */
.graph-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 20px;
  background: rgba(28, 28, 30, 0.5);
  backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  -webkit-backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 1px 1px rgba(255, 255, 255, 0.15),
              inset 0 -1px 1px rgba(0, 0, 0, 0.1);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
}

[data-theme="light"] .graph-modal-close {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(100px) saturate(200%) brightness(1.2);
  -webkit-backdrop-filter: blur(100px) saturate(200%) brightness(1.2);
  border: 0.5px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
              0 1px 2px rgba(0, 0, 0, 0.05),
              inset 0 1px 1px rgba(255, 255, 255, 0.6),
              inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}

.graph-modal-close svg {
  width: 16px;
  height: 16px;
}

.graph-modal-close:hover {
  transform: scale(1.05);
}

.graph-modal-close:active {
  transform: scale(0.98);
}

/* Graph view switcher - inside container */
.graph-view-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
}

.graph-view-switcher .view-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
  white-space: nowrap;
  min-width: 70px;
}

.graph-view-switcher .view-button:hover:not(.active) {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
  transform: scale(1.02);
}

[data-theme="light"] .graph-view-switcher .view-button:hover:not(.active) {
  background-color: rgba(0, 0, 0, 0.04);
}

.graph-view-switcher .view-button.active {
  background-color: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.5),
              0 1px 3px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: scale(1.0);
}

.graph-view-switcher .view-button:active {
  transform: scale(0.98);
}

.graph-view-switcher .view-button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.graph-modal-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
}

.graph-canvas {
  width: 100%;
  height: 100%;
  position: relative;
  flex: 1;
  background: var(--color-bg-primary);
  border-radius: 8px;
}

.graph-empty-state {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-lg);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  opacity: 0.75;
}

.graph-parameter-panel {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: min(280px, 32vw);
  max-height: calc(100% - 2 * var(--space-md));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: rgba(28, 28, 30, 0.2);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-lg);
  box-shadow: none;
  z-index: 10;
}

[data-theme="light"] .graph-parameter-panel {
  background: rgba(248, 248, 248, 0.2);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: none;
}

.graph-parameter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.graph-parameter-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.graph-parameter-header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Hide collapse button on desktop */
.graph-parameter-collapse {
  display: none;
}

.graph-parameter-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.graph-parameter-reset {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border: none;
  border-radius: calc(var(--border-radius) - 2px);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.graph-parameter-reset svg {
  width: 14px;
  height: 14px;
}

.graph-parameter-reset:hover {
  color: var(--color-text-primary);
  background-color: var(--color-bg-elevated);
}

.graph-parameter-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.graph-parameter-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.graph-parameter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.graph-parameter-toggle:hover {
  background-color: color-mix(in srgb, var(--color-bg-secondary) 50%, transparent);
}

.graph-parameter-toggle input[type="checkbox"] {
  /* Hide default checkbox */
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Custom toggle switch */
.graph-parameter-toggle input[type="checkbox"] + span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  position: relative;
}

.graph-parameter-toggle input[type="checkbox"] + span::after {
  content: '';
  width: 36px;
  height: 20px;
  background: rgba(28, 28, 30, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  backdrop-filter: blur(40px) saturate(220%) brightness(1.05);
  -webkit-backdrop-filter: blur(40px) saturate(220%) brightness(1.05);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.16),
              inset 0 -1px 1px rgba(0, 0, 0, 0.2);
}

.graph-parameter-toggle input[type="checkbox"] + span::before {
  content: '';
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  position: absolute;
  right: 19px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.graph-parameter-toggle input[type="checkbox"]:checked + span::after {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4),
              inset 0 -1px 2px rgba(0, 0, 0, 0.18);
}

.graph-parameter-toggle input[type="checkbox"]:checked + span::before {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  right: 3px;
}

[data-theme="light"] .graph-parameter-toggle input[type="checkbox"] + span::after {
  background: rgba(240, 239, 247, 0.9);
  border: 1px solid rgba(93, 63, 211, 0.2);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.9),
              inset 0 -1px 1px rgba(93, 63, 211, 0.12),
              0 0 0 0 rgba(93, 63, 211, 0.2);
}

[data-theme="light"] .graph-parameter-toggle input[type="checkbox"] + span::before {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(93, 63, 211, 0.25);
  box-shadow: 0 2px 6px rgba(93, 63, 211, 0.18);
}

[data-theme="light"] .graph-parameter-toggle input[type="checkbox"]:checked + span::after {
  background: rgba(123, 97, 255, 0.18);
  border-color: rgba(123, 97, 255, 0.55);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.85),
              inset 0 -1px 2px rgba(93, 63, 211, 0.35),
              0 0 0 2px rgba(123, 97, 255, 0.2);
}

[data-theme="light"] .graph-parameter-toggle input[type="checkbox"]:checked + span::before {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(93, 63, 211, 0.4);
  box-shadow: 0 3px 8px rgba(93, 63, 211, 0.35),
              0 0 0 1px rgba(109, 72, 238, 0.25);
}

.graph-parameter-toggle strong {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  display: block;
}

.graph-parameter-toggle small {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: block;
}

.graph-parameter-depth {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-sm);
}

.graph-parameter-depth input[type="range"] {
  flex: 1;
  height: 20px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.graph-parameter-depth input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
}

.graph-parameter-depth input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
}

.graph-parameter-depth input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--color-text-secondary);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -5px;
  transition: all 0.2s ease;
}

.graph-parameter-depth input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-text-secondary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.graph-parameter-depth input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--color-text-primary);
  transform: scale(1.1);
}

.graph-parameter-depth input[type="range"]:hover::-moz-range-thumb {
  background: var(--color-text-primary);
  transform: scale(1.1);
}

.graph-parameter-depth-value {
  min-width: 2ch;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: right;
}

.graph-parameter-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  border-radius: var(--border-radius);
  background: transparent;
  border: none;
}

.graph-parameter-slider label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0 var(--space-sm);
}

.graph-parameter-slider input[type="range"] {
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding: 0 var(--space-sm);
}

/* Slider track */
.graph-parameter-slider input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
}

.graph-parameter-slider input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
}

/* Slider thumb */
.graph-parameter-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--color-text-secondary);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -5px;
  transition: all 0.2s ease;
}

.graph-parameter-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-text-secondary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Hover and active states */
.graph-parameter-slider input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--color-text-primary);
  transform: scale(1.1);
}

.graph-parameter-slider input[type="range"]:hover::-moz-range-thumb {
  background: var(--color-text-primary);
  transform: scale(1.1);
}

.graph-parameter-slider input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

.graph-parameter-slider input[type="range"]:active::-moz-range-thumb {
  transform: scale(1.2);
}

.graph-search-input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.graph-search-input::placeholder {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

.graph-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.graph-parameter-description {
  margin: 0;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: var(--color-text-muted);
}

.graph-parameter-toggle--disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.graph-parameter-toggle--disabled input {
  cursor: not-allowed;
}

.graph-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-lg);
  min-height: 280px;
  border-radius: var(--border-radius-lg);
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-bg-secondary) 70%, transparent);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

@media (max-width: 768px) {
  /* Hide main content when graph modal is visible */
  body:has(.graph-modal:not(.hidden)) .main-content {
    visibility: hidden !important;
  }

  /* Graph modal covers full screen edge-to-edge */
  .graph-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 9999 !important;
    background-color: transparent !important;
    overflow: hidden !important;
    display: block !important;
    isolation: isolate !important;
  }

  .graph-modal.hidden {
    display: none !important;
  }

  .graph-modal-overlay {
    display: none !important;
  }

  .graph-modal-content {
    --graph-sheet-height: min(48dvh, 520px);
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: transparent !important;
    overflow: hidden !important;
    display: block !important;
    z-index: 2 !important;
  }

  .graph-modal-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background-color: transparent !important;
    display: block !important;
    z-index: 3 !important;
  }

  .graph-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background-color: var(--color-bg-primary) !important;
    display: block !important;
    z-index: 4 !important;
  }

  .graph-canvas svg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  /* Ensure graph container children fill completely */
  .graph-modal-container > * {
    box-sizing: border-box !important;
  }

  .graph-modal-controls-wrapper {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + var(--space-md) + var(--nav-pill-height) + var(--space-md)) !important;
    left: var(--space-md) !important;
    right: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: var(--space-sm);
    z-index: 10050 !important;
    display: flex !important;
    flex-direction: column !important;
    pointer-events: all !important;
  }

  .graph-modal-controls-container {
    height: 36px;
    padding: 3px;
    border-radius: 18px;
    background: rgba(28, 28, 30, 0.4);
    backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
    -webkit-backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
    border: 0.5px solid rgba(255, 255, 255, 0.25);
    display: flex !important;
    align-items: center !important;
  }

  /* Hide close button on mobile */
  .graph-modal-close {
    display: none;
  }

  .graph-view-switcher {
    gap: 3px;
  }

  .graph-view-switcher .view-button {
    height: 30px;
    border-radius: 15px;
    padding: 0 12px;
    font-size: 12px;
    min-width: 50px;
  }

  .graph-view-switcher .view-button span {
    display: none;
  }

  .graph-view-switcher .view-button svg {
    width: 18px;
    height: 18px;
  }

  .graph-parameter-panel {
    position: fixed !important;
    left: var(--space-md);
    right: var(--space-md);
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-md));
    top: auto;
    width: auto;
    max-width: none;
    max-height: var(--graph-sheet-height);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    background: rgba(28, 28, 30, 0.2);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 0.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: none;
    overflow-y: auto;
    gap: var(--space-md);
    z-index: 10051 !important;
    transition: max-height 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  [data-theme="light"] .graph-parameter-panel {
    background: rgba(248, 248, 248, 0.2);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: none;
  }

  /* Collapsed state for parameters panel */
  .graph-parameter-panel.collapsed {
    max-height: 60px;
    overflow: hidden;
    padding: var(--space-md) var(--space-lg);
  }

  .graph-parameter-header {
    margin-bottom: var(--space-xs);
    cursor: pointer;
  }

  .graph-parameter-header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  /* Animate parameter sections */
  .graph-parameter-section {
    transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 1;
    transform: translateY(0);
  }

  .graph-parameter-panel.collapsed .graph-parameter-section {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
  }

  /* Show collapse button on mobile */
  .graph-parameter-collapse {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 6px;
  }

  .graph-parameter-collapse svg {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  .graph-parameter-panel.collapsed .graph-parameter-collapse svg {
    transform: rotate(-180deg);
  }

  .graph-parameter-panel::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}

/* Tablet layout (769px to 1199px) */
@media (min-width: 769px) and (max-width: 1199px) {
  .graph-modal-controls-container {
    top: var(--space-sm);
    left: var(--space-sm);
  }
}

.breadcrumb {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.note-content {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--color-bg-primary);
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Typography in notes */
.note-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
  line-height: 1.2;
}

.note-body h1 {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: var(--space-xl) 0 var(--space-md) 0;
  line-height: 1.3;
}

.note-body h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: var(--space-lg) 0 var(--space-md) 0;
  line-height: 1.3;
}

.note-body h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: var(--space-lg) 0 var(--space-sm) 0;
  line-height: 1.3;
}

.note-body p {
  margin-bottom: var(--space-md);
  color: var(--color-text-primary);
  line-height: 1.6;
}

.note-body ul,
.note-body ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
}

.note-body li {
  margin-bottom: var(--space-xs);
  color: var(--color-text-primary);
  position: relative;
}

/* Vertical line styling for nested lists */
.note-body ul ul,
.note-body ol ol,
.note-body ul ol,
.note-body ol ul {
  position: relative;
  margin: 0; /* Remove top and bottom margins for nested lists */
}

.note-body ul ul::before,
.note-body ol ol::before,
.note-body ul ol::before,
.note-body ol ul::before {
  content: '';
  position: absolute;
  left: -15px;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: var(--color-border);
}

.note-body blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--color-primary);
  background-color: var(--color-bg-secondary);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.note-body blockquote p {
  margin: 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.note-body code {
  font-family: var(--font-family-code);
  font-size: 0.8em;
  background-color: var(--color-bg-tertiary);
  padding: 2px 4px;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-primary);
  tab-size: 4;
  -moz-tab-size: 4;
}

.note-body pre {
  background-color: var(--color-bg-tertiary);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  margin: var(--space-lg) 0;
  overflow-x: auto;
  max-width: 100%;
  tab-size: 4;
  -moz-tab-size: 4;
}

.note-body pre code {
  background: none;
  padding: 0;
  tab-size: 4;
  -moz-tab-size: 4;
}

/* Tables in markdown content */
/* Table wrapper for responsive behavior */
.note-body table {
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: var(--space-lg) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: var(--font-size-sm);
  table-layout: auto;
  word-wrap: break-word;
}

.note-body table thead tr:first-child th:first-child {
  border-top-left-radius: var(--border-radius);
}

.note-body table thead tr:first-child th:last-child {
  border-top-right-radius: var(--border-radius);
}

.note-body table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--border-radius);
}

.note-body table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--border-radius);
}

.note-body table th {
  background-color: var(--color-bg-tertiary);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 300px;
}

.note-body table th:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.note-body table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 300px;
}

.note-body table td:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.note-body table tbody tr:last-child td {
  border-bottom: none;
}

.note-body table tbody tr:hover {
  background-color: var(--color-bg-tertiary);
}

/* Horizontal rules */
.note-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-xl) 0;
}

/* Links */
.internal-link {
  color: var(--color-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.internal-link:hover {
  color: var(--color-link-hover);
  border-bottom-color: var(--color-link-hover);
}

.external-link {
  color: var(--color-link-external);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.external-link:hover {
  color: var(--color-accent-hover);
  border-bottom-color: var(--color-accent-hover);
}

/* Backlinks panel */
.backlinks-panel {
  width: 100%;
  background-color: transparent;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
  margin-top: var(--space-xl);
}

.backlinks-panel h3 {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.backlinks-count {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-muted);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.backlinks-section {
  margin-bottom: var(--space-lg);
}

.backlinks-source {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  cursor: pointer;
  user-select: none;
}

.backlinks-source-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
}

.backlinks-source-toggle.expanded {
  transform: none;
}

.backlinks-source-title {
  font-weight: 500;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  flex: 1;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.backlinks-source-count {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-muted);
  padding: 1px 5px;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.backlinks-mentions {
  display: none;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.backlinks-mentions.expanded {
  display: block;
}

.backlink-mention {
  display: block;
  background-color: var(--color-bg-primary);
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  padding: 12px;
  margin-bottom: 0;
  font-size: var(--font-size-sm);
  line-height: 1.0;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.backlink-mention:last-child {
  border-bottom: none;
}

.backlink-mention:hover {
  background-color: var(--color-accent-hover);
}

.backlink-mention-content {
  color: var(--color-text-secondary);
}

.backlink-mention-highlight {
  background-color: var(--color-highlight);
  color: var(--color-bg-primary);
  padding: 1px 2px;
  border-radius: 2px;
  font-weight: 500;
}

.unlinked-mentions-section {
  margin-top: var(--space-xl);
}

/* New backlinks section styles */
.backlinks-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  user-select: none;
}

.backlinks-section-header h3,
.backlinks-section-header h4 {
  margin: 0;
  flex: 1;
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.backlinks-section-header.dimmed h3,
.backlinks-section-header.dimmed h4 {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.backlinks-section-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.backlinks-section-toggle.expanded {
  transform: rotate(-45deg);
}

.backlinks-section-content {
  overflow: hidden;
  transition: all 0.3s ease;
}

.backlinks-section-content.collapsed {
  display: none;
}

.backlinks-section-content.expanded {
  display: block;
}

.no-linked-mentions,
.no-unlinked-mentions {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.unlinked-mentions-section h4 {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

/* Legacy backlink item styling - kept for compatibility */
.backlink-item {
  display: block;
  padding: var(--space-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xs);
  transition: all 0.2s ease;
}

.backlink-item:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

/* Folder tree styles */
.folder-tree {
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.folder-item {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
  position: relative;
  /* margin-bottom: 2px; */
  font-weight: 400;
  background: none; /* Remove background */
}

.folder-item:hover {
  color: var(--color-text-primary); /* Darker color on hover */
}

.folder-item.active {
  color: var(--color-accent); /* Use accent color for selected */
  font-weight: 500;
}

.folder-item.folder {
  font-weight: 500;
  color: var(--color-text-primary);
  padding-left: calc(var(--space-md) + 20px); /* Space for chevron + small gap */
  position: relative;
}

.folder-item.folder:hover {
  color: var(--color-text-primary); /* Darker color on hover */
}

.folder-item.folder.active {
  color: var(--color-accent); /* Use accent color for selected */
  font-weight: 500;
}

.folder-item.file {
  padding-left: var(--space-md); /* Align with search bar */
  color: var(--color-text-secondary);
  font-weight: 400;
  position: relative;
}

.folder-item.file:hover {
  color: var(--color-text-primary); /* Darker color on hover */
}

.folder-item.file.active {
  color: var(--color-accent); /* Use accent color for selected */
  font-weight: 500;
}

.folder-toggle {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.folder-toggle::before,
.folder-toggle::after {
  content: none !important;
  display: none !important;
}

.folder-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
  transform: rotate(-90deg); /* Point right when collapsed */
}

.folder-toggle:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.folder-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
  position: relative;
}

.folder-content.collapsed {
  max-height: 0;
}

.folder-content.expanded {
  max-height: none;
}

.folder-item.folder.expanded .folder-toggle svg {
  transform: rotate(0deg); /* Point down when expanded */
}

.folder-children {
  position: relative;
  padding-left: 20px; /* Indent nested items */
}

.folder-content.expanded .folder-content.expanded .folder-children {
  left: 4px;
  border-left: 1px solid var(--color-border);
}

/* Indentation guides - create individual segments for each item */
.folder-children .folder-item::before {
  content: '';
  position: absolute;
  left: 4px; /* Position relative to the indented item */
  top: 0;
  height: 100%;
  width: 1px;
  background-color: var(--color-border);
  opacity: 1.0;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

/* .folder-content.expanded .folder-content.expanded .folder-children .folder-item::before */


/* Hover effect - make the current segment darker */
.folder-children .folder-item:hover::before {
  background-color: var(--color-border-hover);
  opacity: 1.0;
}

/* Active item - highlight its specific guide segment */
.folder-children .folder-item.active::before {
  background-color: var(--color-accent);
  opacity: 1;
}

/* Remove the old continuous guide */
.folder-children::before {
  display: none;
}

/* File icon styles */
.file-icon {
  margin-right: var(--space-xs);
  opacity: 0.7;
}

.folder-icon {
  margin-right: var(--space-xs);
  opacity: 0.7;
}
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* Prevent body scrolling when mobile menu is open on desktop only */
@media (min-width: 769px) {
  body.menu-open {
    overflow: hidden;
  }
}

/* On mobile, keep body scrolling enabled even when menu is open */
@media (max-width: 768px) {
  body.menu-open {
    overflow-y: auto !important; /* Keep scrolling enabled */
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-medium) var(--anim-ease);
  z-index: 1050;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive design - Mobile layout */
@media (max-width: 768px) {
  /* Mobile header toggle visibility */
  
  .backlinks-panel {
    display: none;
  }
}

/* Hide sidebar overlay on desktop */
@media (min-width: 769px) {
  .sidebar-overlay {
    display: none;
  }
}

/* Embed styles */
.embed-note {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin: var(--space-md) 0;
  overflow: hidden;
}

/* Embedded images - similar styling to embedded notes */
.embed-image {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin: var(--space-md) 0;
  overflow: hidden;
  padding: var(--space-sm);
}

.embed-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--border-radius) - 2px);
}

/* Remove embed-image styling when inside base cards view */
.cards-view .embed-image,
.base-content .embed-image {
  background-color: transparent;
  border: none;
  padding: 0;
  margin: var(--space-xs) 0;
}

.embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.embed-header:hover {
  background-color: var(--color-border);
}

.embed-title {
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.embed-title-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.embed-title-link:hover {
  color: var(--color-text-accent);
}

.embed-title-link:hover .embed-icon {
  color: var(--color-text-accent);
}

.embed-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Base-specific embed controls */
.embed-base-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--color-border-secondary);
}

/* === BUTTON SYSTEM - Consolidated === */

/* Note: Legacy button classes (.view-button, .action-button, .embed-*-button) 
   are defined below to maintain compatibility. All button styles consolidated. */

/* Legacy class aliases for backward compatibility */
.view-button {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: none;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-button:hover {
  background-color: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

.view-button.active {
  background-color: var(--color-primary);
  color: white;
}

.view-button svg {
  width: 16px;
  height: 16px;
}

.action-button {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-primary);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-button:hover {
  border-color: var(--color-border-hover);
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

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

.embed-view-button,
.embed-action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.embed-view-button:hover,
.embed-action-button:hover {
  background: var(--color-bg-elevated);
  color: var(--color-bg);
}

.embed-view-button.active {
  background: var(--color-bg-elevated);
  color: var(--color-bg);
}

.embed-view-button svg,
.embed-action-button svg {
  width: 14px;
  height: 14px;
}

.embed-maximize {
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.embed-maximize:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.embed-maximize.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.embed-maximize.disabled:hover {
  background-color: transparent;
  color: var(--color-text-secondary);
}

.embed-maximize svg {
  width: 14px;
  height: 14px;
  transition: all 0.2s ease;
}

.embed-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.embed-title-text {
  flex: 1;
}


.embed-chevron {
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  margin-left: 0.5em;
}

.embed-chevron:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.embed-chevron svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
  transform: rotate(0deg); /* Point down when expanded (default) */
}

.embed-note.collapsed .embed-chevron svg {
  transform: rotate(-90deg); /* Point right when collapsed */
}

.embed-content {
  padding: var(--space-md);
  /* Default maximized state (no height limit) */
  max-height: none;
  overflow-y: auto;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.embed-content.collapsed {
  max-height: 0;
  padding: 0 var(--space-md);
  overflow: hidden;
}

/* When embed is explicitly set to limited height */
.embed-note.limited-height .embed-content:not(.collapsed) {
  max-height: 500px;
  overflow-y: auto;
}

.embed-error {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--color-accent);
  font-size: var(--font-size-sm);
}

/* Selection */
::selection {
  background-color: var(--color-selection);
}

/* Code block wrapper with floating language label */
.code-block-wrapper {
  position: relative;
  margin: var(--space-lg) 0;
}

/* Make plain pre blocks also have position relative for copy button */
.note-body pre {
  position: relative;
}

.code-block-language {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-md);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-code);
  font-size: 10px;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  opacity: 0.6;
  padding: 4px 8px;
  background-color: var(--color-bg-secondary);
  border-radius: 4px;
  pointer-events: none;
  height: 28px;
  box-sizing: border-box;
}

/* Copy button for code blocks */
.code-copy-button {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-md);
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 4px 8px;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  color: var(--color-text-secondary);
  box-sizing: border-box;
}

.code-copy-button:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.code-copy-button:active {
  background-color: var(--color-bg-primary);
}

.code-copy-button.copied {
  color: var(--color-primary);
}

.code-block-wrapper:hover .code-copy-button,
.note-body pre:hover .code-copy-button {
  opacity: 1;
}

.code-copy-button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Adjust language label position when copy button is visible */
.code-block-wrapper:hover .code-block-language,
.note-body pre:hover .code-block-language {
  right: calc(var(--space-md) + 40px);
}

.code-block-wrapper .shiki-container {
  margin: 0;
}

.code-block-wrapper .shiki {
  margin: 0;
}

/* Shiki syntax highlighting theme switching */
.shiki-container {
  position: relative;
}

[data-theme="light"] .shiki-dark {
  display: none !important;
}

[data-theme="dark"] .shiki-light {
  display: none !important;
}

[data-theme="dark"] .shiki-dark {
  display: block !important;
}

/* Ensure Shiki code blocks use our font */
.shiki code,
.shiki pre {
  font-family: var(--font-family-code) !important;
}

/* Override Shiki's default styles to match our theme */
.shiki {
  background-color: var(--color-bg-tertiary) !important;
  border-radius: var(--border-radius);
  margin: var(--space-lg) 0;
}

/* MathJax Styling */
.MathJax {
  font-size: 1.1em !important;
}

/* Display math blocks */
.MathJax_Display {
  margin: 1.5em 0 !important;
  text-align: center !important;
}

/* Inline math */
.MathJax_Element {
  display: inline !important;
}

/* Math in dark theme */
[data-theme="dark"] .MathJax {
  color: var(--color-text-primary) !important;
}

[data-theme="dark"] .MathJax_Display {
  color: var(--color-text-primary) !important;
}

/* Note Properties (Frontmatter) Styling */
.note-properties {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin: 0 0 var(--space-lg) 0;
  font-size: var(--font-size-sm);
}

.properties-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg-tertiary);
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.properties-header:hover {
  background-color: var(--color-bg-elevated);
}

.properties-chevron {
  opacity: 0.7;
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.properties-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.properties-content {
  padding: 0 var(--space-sm);
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.properties-content.collapsed {
  max-height: 0;
  padding: 0 var(--space-sm);
}

.property-row {
  display: grid;
  grid-template-columns: var(--property-name-width, 80px) 1fr;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
  min-height: 24px;
  align-items: baseline;
}

.property-row:first-child {
  padding-top: var(--space-sm);
}

.property-row:last-child {
  padding-bottom: var(--space-sm);
}

.property-row:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.property-name {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: right;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-x: auto;
  white-space: nowrap;
  line-height: 1.5;
}

.property-value {
  min-width: 0; /* Allow grid item to shrink below content size */
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  line-height: 1.5;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
}

.property-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-xs);
  align-items: baseline;
}

/* === SCROLLBAR SYSTEM - Consolidated === */

/* Common scrollbar styling for horizontal scrollers */
.property-tags,
.property-list,
.property-text,
.property-date {
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.property-tags::-webkit-scrollbar,
.property-list::-webkit-scrollbar,
.property-text::-webkit-scrollbar,
.property-date::-webkit-scrollbar {
  height: 4px;
}

.property-tags::-webkit-scrollbar-track,
.property-list::-webkit-scrollbar-track,
.property-text::-webkit-scrollbar-track,
.property-date::-webkit-scrollbar-track {
  background: transparent;
}

.property-tags::-webkit-scrollbar-thumb,
.property-list::-webkit-scrollbar-thumb,
.property-text::-webkit-scrollbar-thumb,
.property-date::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 2px;
}


.property-list {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-xs);
  align-items: baseline;
}

.property-list-item {
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.property-text {
  color: var(--color-text-primary);
}

.property-date {
  color: var(--color-text-secondary);
  font-family: var(--font-family-code);
  font-size: var(--font-size-xs);
}

/* Dark theme adjustments for properties */

[data-theme="dark"] .property-list-item {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

/* Base (Database) Styles */

.base-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
  line-height: 1.2;
}

.view-switcher {
  display: flex;
  gap: var(--space-xs);
  border-radius: var(--border-radius);
  /* padding: var(--space-xs); */
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Base Content Area */
.base-content {
  min-height: 400px;
}

/* Base Error States */
.base-error {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--color-accent);
  font-size: var(--font-size-sm);
  text-align: center;
}

.inline-base-loading {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  font-style: italic;
}

.inline-base-placeholder {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Table View */
.table-view {
   overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
}

.base-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius);
  overflow: hidden; /* Ensure rounded corners are visible */
}

/* Round the external corners of the table */
.base-table thead tr:first-child th:first-child {
  border-top-left-radius: var(--border-radius);
}

.base-table thead tr:first-child th:last-child {
  border-top-right-radius: var(--border-radius);
}

.base-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--border-radius);
}

.base-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--border-radius);
}

.base-table th {
  background-color: var(--color-bg-tertiary);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.base-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.base-table th.sortable:hover {
  background-color: var(--color-bg-secondary);
}

.base-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  vertical-align: top;
}

/* Tag cells in base tables */
.base-table td .tag {
  margin: 0 3px 3px 0;
}

.base-table .table-row {
  transition: background-color 0.2s ease;
}

.base-table .table-row:hover {
  background-color: var(--color-bg-tertiary);
}

.base-table .clickable-row {
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
  font-style: italic;
}

.cards-view {
  width: 100%;
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
  grid-auto-rows: auto;
  align-items: start;
}

.card {
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: auto;
}

.card-top-image,
.card-top-skeleton {
  flex-shrink: 0;
}

.card-title-section,
.card-properties-table {
  flex-shrink: 0;
}

.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Legacy card styles - removed since all cards now use the new structure */

/* New Card Structure */
.card-top-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-secondary);
}

.card-top-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-top-skeleton {
  width: 100%;
  height: 200px;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--color-bg-secondary);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
  gap: 4px;
}

.skeleton-line {
  height: 8px;
  background-color: rgba(128, 128, 128, 0.2);
  border-radius: 2px;
  flex-shrink: 0;
  min-height: 8px;
  animation: skeleton-pulse 6s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.6;
  }
}

/* Heading styles - taller and darker to represent headings */
.skeleton-line-heading-1 {
  width: 70%;
  height: 12px;
  background-color: rgba(128, 128, 128, 0.35);
  border-radius: 3px;
}

.skeleton-line-heading-2 {
  width: 60%;
  height: 10px;
  background-color: rgba(128, 128, 128, 0.3);
  border-radius: 2px;
}

.skeleton-line-heading-3 {
  width: 50%;
  height: 9px;
  background-color: rgba(128, 128, 128, 0.3);
  border-radius: 2px;
}

/* Regular content lines - thin like text */
.skeleton-line-extra-long {
  width: 85%;
  height: 6px;
}

.skeleton-line-long {
  width: 75%;
  height: 6px;
}

.skeleton-line-medium {
  width: 55%;
  height: 6px;
}

.skeleton-line-short {
  width: 35%;
  height: 6px;
}

/* List item style - with a small bullet-like element */
.skeleton-line-list {
  width: 60%;
  height: 6px;
  position: relative;
}

.skeleton-line-list::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 1px;
  width: 3px;
  height: 3px;
  background-color: rgba(128, 128, 128, 0.4);
  border-radius: 50%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Code block style - monospaced feel */
.skeleton-line-code {
  width: 70%;
  height: 7px;
  background-color: rgba(100, 100, 100, 0.15);
  border-radius: 1px;
}

.card-title-section {
  padding: var(--space-md) var(--space-lg) 0;
}

.card-title-section .card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.card-title-section .card-title .internal-link {
  color: var(--color-text-primary);
  text-decoration: none;
}

.card-title-section .card-title .internal-link:hover {
  color: var(--color-link);
  /* text-decoration: underline; */
}

.card-properties-table {
  padding: var(--space-sm) var(--space-md);
}

.properties-table {
  width: 100%;
  border-spacing: 0;
  border-collapse: collapse;
}

.card-property-row {
  border-bottom: 1px solid var(--color-border);
}

.card-property-row:last-child {
  border-bottom: none;
}

.card-property-label {
  padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 500;
  vertical-align: baseline;
  width: 30%;
  text-align: right;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.card-property-value-cell {
  padding: var(--space-xs) 0 var(--space-xs) var(--space-sm);
  vertical-align: baseline;
  width: 70%;
}

.card-property-value {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* Calendar View */
.calendar-view {
    padding: 20px;
}

.calendar-header {
    text-align: center;
    margin-bottom: 20px;
}

.calendar-header h3 {
    margin: 0;
    font-size: 1.5em;
    color: var(--color-text-primary);
}

.calendar-grid {
    max-width: 800px;
    margin: 0 auto;
}

.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 1px;
}

.day-header {
    background: var(--color-bg-secondary);
    padding: 10px;
    text-align: center;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.9em;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--color-border);
}

.calendar-day {
    background: var(--color-bg);
    min-height: 120px;
    padding: 8px;
    position: relative;
    border: 1px solid var(--color-border);
}

.calendar-day.empty {
    background: var(--color-bg-secondary);
    opacity: 0.5;
}

.calendar-day.today {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
}

.day-number {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.day-notes {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-note {
    background: var(--color-accent-bg);
    color: var(--color-accent);
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-note:hover {
    background: var(--color-accent);
    color: white;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  line-height: 1;
}

.card-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-family-code);
}

.card-preview {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Styling for rendered HTML in card previews */
.card-preview h4,
.card-preview h5,
.card-preview h6 {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.card-preview p {
  margin: 0;
  padding: 0;
}

.card-preview strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

.card-preview em {
  font-style: italic;
}

.card-preview code {
  background-color: var(--color-background-secondary);
  color: var(--color-text-primary);
  padding: 2px 4px;
  border-radius: var(--border-radius-xs);
  font-family: var(--font-family-code);
  font-size: calc(var(--font-size-sm) - 1px);
}

.card-preview del {
  opacity: 0.6;
  text-decoration: line-through;
}

.card-preview a {
  color: var(--color-link);
  text-decoration: none;
}

.card-preview a:hover {
  text-decoration: underline;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background-color: var(--color-selection);
  color: var(--color-accent);
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  margin: 0 2px 2px 0;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.tag:hover {
  background-color: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.file-icon {
  display: inline-flex;
  align-items: center;
  margin-right: var(--space-xs);
  color: var(--color-text-muted);
}

/* Base pill styling */
.base-pill {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  font-size: var(--font-size-2xs);
  font-weight: 400;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Ensure folder-item files are flex containers for the pill */
.folder-item.file {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive Design for Bases */
@media (max-width: 768px) {
  .base-controls {
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
    justify-content: space-between;
  }
  
  .view-switcher {
    justify-content: flex-start;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  
  .base-actions {
    width: auto;
    justify-content: flex-end;
  }
  
  .cards-container {
    grid-template-columns: 1fr;
  }
  
  .table-view {
    font-size: var(--font-size-xs);
  }
  
  .base-table th,
  .base-table td {
    padding: var(--space-xs) var(--space-sm);
  }
}

/* Dark theme adjustments for bases */
[data-theme="dark"] .card {
  background-color: var(--color-bg-secondary);
}

[data-theme="dark"] .card:hover {
  background-color: var(--color-bg-tertiary);
}

[data-theme="dark"] .base-table th {
  background-color: var(--color-bg-secondary);
}

[data-theme="dark"] .base-table th.sortable:hover {
  background-color: var(--color-bg-tertiary);
}

/* Base Controls Container - for standalone base pages */
.base-controls-container {
  margin-bottom: var(--space-md);
}

/* Base Controls - simplified flex layout */
.base-controls {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  margin: 0 0 var(--space-lg) 0;
  font-size: var(--font-size-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.base-controls .view-switcher {
  display: flex;
  gap: var(--space-xs);
}

.base-controls .base-actions {
  display: flex;
  gap: var(--space-xs);
  margin-left: auto;
  padding: var(--space-xs);
}

/* Base controls context overrides */
.base-controls .view-button,
.base-controls .action-button {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  padding: var(--space-xs) var(--space-sm);
}

.base-controls .view-button:hover,
.base-controls .action-button:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
}

.base-controls .view-button.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.base-controls .view-button svg,
.base-controls .action-button svg {
  width: 14px;
  height: 14px;
}

/* Sort/Filter Button Active States */
.base-controls .action-button.has-rules {
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.base-controls .action-button.has-rules:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-border-hover);
}

/* Embedded button active states */
.embed-action-button.has-rules {
  background: var(--color-bg-primary) !important;
  color: var(--color-text-primary) !important;
  box-shadow: var(--shadow-sm);
}

/* Sort/Filter Popup Styles */
.base-popup {
  position: fixed;
  min-width: 320px;
  max-width: 400px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  padding: var(--space-md);
  font-size: var(--font-size-sm);
}

.base-popup::before {
  display: none;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.popup-title {
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.popup-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.popup-section {
  margin-bottom: var(--space-md);
}

.popup-section:last-child {
  margin-bottom: 0;
}

.popup-section-title {
  font-weight: 500;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sort Rules Display */
.sort-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-xs);
}

.sort-rule:last-child {
  margin-bottom: 0;
}

.sort-rule-property {
  font-weight: 500;
  color: var(--color-text-primary);
  flex-grow: 1;
}

.sort-rule-direction {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

.sort-rule-arrow {
  display: flex;
  align-items: center;
}

/* Filter Rules Display */
.filter-rule {
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-xs);
}

.filter-rule:last-child {
  margin-bottom: 0;
}

.filter-rule-operator {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.filter-rule-condition {
  font-family: var(--font-family-code);
  font-size: var(--font-size-xs);
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
  padding: 2px 4px;
  border-radius: 2px;
}

.filter-rule-nested {
  margin-left: var(--space-md);
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-sm);
}

.empty-rules {
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-lg);
}

/* Popup overlay for closing on outside click */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99;
  background: transparent;
}

/* ================================================ ABC Music Notation Styles ================================================ */

/* ABC container styling */
.abcjs-container {
  margin: var(--space-md) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--color-bg-secondary);
  cursor: pointer;
}

/* ABC SVG styling - use theme colors */
.abcjs-container svg path {
  fill: var(--color-text-primary);
}

.abcjs-container svg text {
  fill: var(--color-text-primary);
}

.abcjs-brace {
  stroke: var(--color-text-primary);
}

/* Loading state */
.abcjs-loading {
  padding: var(--space-lg);
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Error state */
.abcjs-error {
  background-color: #e74c3c;
  color: white;
  padding: var(--space-md);
  text-align: center;
  font-weight: 500;
}

/* Note highlighting during playback - use accent hover color */
.abcjs-highlight path {
  fill: var(--color-accent-hover) !important;
}

.abcjs-highlight text {
  fill: var(--color-accent-hover) !important;
}

/* Container highlighting when playing - only highlight the specific playing container */
.abcjs-container.is-playing {
  border-color: var(--color-accent-hover) !important;
  box-shadow: 0 0 0 1px var(--color-accent-hover);
  background: var(--color-bg-elevated);
}

/* Interactive feedback */
.abcjs-container:hover {
  border-color: var(--color-border-hover);
}

.abcjs-container:active {
  transform: translateY(1px);
}

/* Hide abcjs warning messages */
.abcjs-css-warning {
  display: none;
}

/* ================================================ Mermaid Diagram Styles ================================================ */

/* Mermaid container styling */
.mermaid-container {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  overflow: visible;
}

/* Mermaid diagram itself */
.mermaid {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
  font-family: var(--font-family-main);
}

/* Override Mermaid's default SVG styles */
.mermaid svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* FORCE all text to be visible with high contrast */
.mermaid text,
.mermaid .nodeLabel,
.mermaid .edgeLabel,
.mermaid .label,
.mermaid tspan {
  fill: var(--color-text-primary) !important;
  font-family: var(--font-family-main) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}

/* Dark theme - ensure white text on ALL elements */
[data-theme="dark"] .mermaid text,
[data-theme="dark"] .mermaid .nodeLabel,
[data-theme="dark"] .mermaid .edgeLabel,
[data-theme="dark"] .mermaid .label,
[data-theme="dark"] .mermaid tspan,
[data-theme="dark"] .mermaid .labelText,
[data-theme="dark"] .mermaid .classLabel text,
[data-theme="dark"] .mermaid .stateLabel text,
[data-theme="dark"] .mermaid foreignObject div {
  fill: #ffffff !important;
  color: #ffffff !important;
}

/* Light theme - ensure dark text on ALL elements */
[data-theme="light"] .mermaid text,
[data-theme="light"] .mermaid .nodeLabel,
[data-theme="light"] .mermaid .edgeLabel,
[data-theme="light"] .mermaid .label,
[data-theme="light"] .mermaid tspan,
[data-theme="light"] .mermaid .labelText,
[data-theme="light"] .mermaid .classLabel text,
[data-theme="light"] .mermaid .stateLabel text,
[data-theme="light"] .mermaid foreignObject div {
  fill: #1e1e1e !important;
  color: #1e1e1e !important;
}

/* DO NOT override rect fills - let Mermaid handle them */

/* DO NOT override rect fills - let Mermaid handle them */

/* Node styling with borders only */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon,
.mermaid .node path {
  stroke-width: 2.5px !important;
}

/* Edge/Line styling - thicker for visibility */
.mermaid .edgePath path,
.mermaid .flowchart-link,
.mermaid path.path {
  stroke-width: 2.5px !important;
}

/* Edge labels - hide background rectangles ONLY for flowcharts */
.mermaid .edgeLabel {
  background-color: transparent !important;
  padding: 2px 4px !important;
  border-radius: 0 !important;
}

/* Only hide edge label rectangles in flowcharts, not other diagram types */
.mermaid.flowchart .edgeLabel rect,
svg[id^="mermaid-"] g.edgeLabel rect[class*="label"] {
  display: none !important;
}

/* Make edge label text simple - just use foreground color, no decorations */
.mermaid .edgeLabel span,
.mermaid .edgeLabel p,
.mermaid .edgeLabel div {
  font-weight: 400 !important;
  text-shadow: none !important;
  background: none !important;
  padding: 0 !important;
}

/* Remove Start/End terminal nodes ONLY in flowcharts */
.mermaid g[id*="flowchart"] g[id*="Start"] rect,
.mermaid g[id*="flowchart"] g[id*="End"] rect,
.mermaid g.nodes g[id*="Start"] rect,
.mermaid g.nodes g[id*="End"] rect {
  display: none !important;
}

/* Also hide Start/End text labels ONLY in flowcharts */
.mermaid g[id*="flowchart"] g[id*="Start"] text,
.mermaid g[id*="flowchart"] g[id*="End"] text,
.mermaid g.nodes g[id*="Start"] text,
.mermaid g.nodes g[id*="End"] text {
  display: none !important;
}

/* Class diagram - let Mermaid theme handle fills, only enforce text */
/* Force class diagram labels to be visible */
[data-theme="dark"] .mermaid .classLabel .label,
[data-theme="dark"] .mermaid .classLabel text,
[data-theme="dark"] .mermaid .classGroup text {
  fill: #ffffff !important;
  color: #ffffff !important;
}

[data-theme="light"] .mermaid .classLabel .label,
[data-theme="light"] .mermaid .classLabel text,
[data-theme="light"] .mermaid .classGroup text {
  fill: #1e1e1e !important;
  color: #1e1e1e !important;
}

/* Class label backgrounds should not obscure text */
.mermaid .classLabel .box {
  fill: transparent !important;
  stroke: none !important;
}

/* ER diagram - let Mermaid theme handle fills */
/* ER diagram labels */
[data-theme="dark"] .mermaid .er .entityLabel,
[data-theme="dark"] .mermaid .er.attributeBoxOdd text,
[data-theme="dark"] .mermaid .er.attributeBoxEven text {
  fill: #ffffff !important;
}

[data-theme="light"] .mermaid .er .entityLabel,
[data-theme="light"] .mermaid .er.attributeBoxOdd text,
[data-theme="light"] .mermaid .er.attributeBoxEven text {
  fill: #1e1e1e !important;
}

/* State diagram - let Mermaid theme handle fills */
/* State diagram labels */
[data-theme="dark"] .mermaid .stateLabel text,
[data-theme="dark"] .mermaid .stateGroup text {
  fill: #ffffff !important;
  color: #ffffff !important;
}

[data-theme="light"] .mermaid .stateLabel text,
[data-theme="light"] .mermaid .stateGroup text {
  fill: #1e1e1e !important;
  color: #1e1e1e !important;
}

/* Sequence diagram */
[data-theme="dark"] .mermaid .actor {
  fill: #374151 !important;
  stroke: #8b5cf6 !important;
  stroke-width: 2px !important;
}

[data-theme="light"] .mermaid .actor {
  fill: #f3f4f6 !important;
  stroke: #8b5cf6 !important;
  stroke-width: 2px !important;
}

.mermaid .actor-line {
  stroke: var(--color-border) !important;
  stroke-width: 2px !important;
}

.mermaid .messageLine0,
.mermaid .messageLine1 {
  stroke-width: 2px !important;
  stroke: #6b7280 !important;
}

/* Gantt chart - ensure all text is visible */
.mermaid .grid .tick text,
.mermaid .taskText,
.mermaid .sectionTitle,
.mermaid .titleText {
  fill: var(--color-text-primary) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}

[data-theme="dark"] .mermaid .grid .tick text,
[data-theme="dark"] .mermaid .taskText,
[data-theme="dark"] .mermaid .sectionTitle,
[data-theme="dark"] .mermaid .titleText {
  fill: #ffffff !important;
}

[data-theme="light"] .mermaid .grid .tick text,
[data-theme="light"] .mermaid .taskText,
[data-theme="light"] .mermaid .sectionTitle,
[data-theme="light"] .mermaid .titleText {
  fill: #1e1e1e !important;
}

/* Git graph - larger, more visible labels */
.mermaid .commit-id,
.mermaid .commit-msg,
.mermaid .branch-label {
  font-size: 13px !important;
  font-weight: 600 !important;
  fill: var(--color-text-primary) !important;
}

[data-theme="dark"] .mermaid .commit-id,
[data-theme="dark"] .mermaid .commit-msg,
[data-theme="dark"] .mermaid .branch-label {
  fill: #ffffff !important;
}

[data-theme="light"] .mermaid .commit-id,
[data-theme="light"] .mermaid .commit-msg,
[data-theme="light"] .mermaid .branch-label {
  fill: #1e1e1e !important;
}

/* Pie chart */
.mermaid .pieTitleText,
.mermaid .legendText {
  fill: var(--color-text-primary) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
}

/* Cluster/Subgraph styling with proper contrast */
[data-theme="dark"] .mermaid .cluster rect {
  fill: #1f2937 !important;
  stroke: #6b7280 !important;
  stroke-width: 2px !important;
}

[data-theme="light"] .mermaid .cluster rect {
  fill: #f3f4f6 !important;
  stroke: #9ca3af !important;
  stroke-width: 2px !important;
}

/* Flowchart - let Mermaid theme handle node fills */

/* Mermaid error state */
.mermaid-error {
  background-color: #ef4444;
  color: white;
  padding: var(--space-md);
  text-align: center;
  font-weight: 500;
  border-radius: var(--border-radius);
  margin: var(--space-md) 0;
}

/* Interactive feedback */
.mermaid-container:hover {
  border-color: var(--color-border-hover);
}

/* Ensure diagrams are responsive */
@media (max-width: 768px) {
  .mermaid-container {
    padding: 0;
  }
  
  .mermaid svg {
    max-width: 100%;
  }
}
/* ============================================================================
   ADAPTIVE NAVIGATION SYSTEM
   Responsive navigation with liquid glass design for ObsidianP
   Transforms from left sidebar (desktop) to top pills (mobile)
   ============================================================================ */

/* ----------------------------------------------------------------------------
   CSS Variables & Breakpoints
   ---------------------------------------------------------------------------- */
:root {
  /* Breakpoints */
  --breakpoint-mobile-sm: 320px;
  --breakpoint-mobile: 480px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1024px;
  
  /* Navigation dimensions */
  --nav-pill-height: 56px;
  --nav-pill-gap: 8px;
  --nav-sidebar-collapsed-width: 70px;
  --sidebar-inset: 16px;
  
  /* Animation timing */
  --anim-fast: 150ms;
  --anim-medium: 250ms;
  --anim-slow: 350ms;
  --anim-ease: cubic-bezier(0.4, 0.0, 0.2, 1);
  --anim-ease-out: cubic-bezier(0.0, 0.0, 0.2, 1);
  --anim-ease-in: cubic-bezier(0.4, 0.0, 1, 1);
  
  /* Elevation levels */
  --elevation-0: none;
  --elevation-1: 0 2px 4px rgba(0, 0, 0, 0.1);
  --elevation-2: 0 4px 12px rgba(0, 0, 0, 0.15);
  --elevation-3: 0 8px 24px rgba(0, 0, 0, 0.2);
  
  /* Pill navigation colors (theme-aware) */
  --nav-pill-bg: var(--color-bg-tertiary);
  --nav-pill-bg-hover: var(--color-bg-tertiary);
  --nav-pill-bg-active: var(--color-primary);
  --nav-pill-text: var(--color-text-secondary);
  --nav-pill-text-active: #ffffff;
  --nav-pill-border: transparent;
  
  /* Touch target minimum */
  --touch-target-min: 44px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  :root {
    --anim-fast: 0ms;
    --anim-medium: 0ms;
    --anim-slow: 0ms;
  }
}

/* ----------------------------------------------------------------------------
   MOBILE PILL NAVIGATION (320px - 768px)
   Top horizontal bar with liquid glass effect
   Only shows: Vault title | Graph | Theme toggle
   ---------------------------------------------------------------------------- */

/* Pill navigation container with liquid glass effect - FLOATING */
.nav-pills-container {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-md));
  left: var(--space-md);
  right: var(--space-md);
  height: var(--nav-pill-height);
  background: rgba(28, 28, 30, 0.5);
  backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  -webkit-backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  border-radius: calc(var(--nav-pill-height) / 2);
  z-index: 3000;
  display: none;
  padding: 0 var(--space-md);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 1px 1px rgba(255, 255, 255, 0.15),
              inset 0 -1px 1px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
}

/* Light theme glass effect */
[data-theme="light"] .nav-pills-container {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(120px) saturate(400%) brightness(1.05);
  -webkit-backdrop-filter: blur(120px) saturate(400%) brightness(1.05);
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
              0 2px 8px rgba(0, 0, 0, 0.05),
              inset 0 1px 1px rgba(255, 255, 255, 1),
              inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}

/* Vault title - left side */
.nav-pills-container .vault-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

/* HIDE center navigation pills on mobile */
.nav-pills-scroll {
  display: none !important;
}

/* Action pills container - RIGHT SIDE */
.nav-pills-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
  margin-left: auto;
}

/* Action pill buttons (theme, graph) - LIQUID GLASS */
.nav-pill-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 38px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  color: var(--color-text-primary);
  border: 0.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--anim-fast) var(--anim-ease-out);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
              inset 0 1px 1px rgba(255, 255, 255, 0.25),
              inset 0 -1px 1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .nav-pill-action {
  background: rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(50px) saturate(250%);
  -webkit-backdrop-filter: blur(50px) saturate(250%);
  border: 0.5px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.9),
              inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}

.nav-pill-action:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.45);
  transform: scale(1.05);
  backdrop-filter: blur(50px) saturate(250%);
  -webkit-backdrop-filter: blur(50px) saturate(250%);
}

[data-theme="light"] .nav-pill-action:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(60px) saturate(300%);
  -webkit-backdrop-filter: blur(60px) saturate(300%);
}

.nav-pill-action:active {
  transform: scale(0.95);
}

/* Icon-only action pills */
.nav-pill-action.icon-only {
  padding: 9px;
  min-width: 38px;
}

/* Light theme glass effect */
[data-theme="light"] .nav-pills-container {
  background: rgba(255, 255, 255, 0.72);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Vault title in pill nav - left side */
.nav-pills-container .vault-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Scrollable pills wrapper - CENTER */
.nav-pills-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 var(--space-sm);
  -ms-overflow-style: none;
}

.nav-pills-scroll::-webkit-scrollbar {
  display: none;
}

/* Pill wrapper */
.nav-pills-wrapper {
  display: flex;
  align-items: center;
  gap: var(--nav-pill-gap);
  min-height: 100%;
  padding: var(--space-xs) 0;
}

/* Action pills container - RIGHT SIDE */
.nav-pills-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
  margin-left: auto;
}

/* Action pill buttons (theme, graph, etc) */
.nav-pill-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-text-primary);
  border: none;
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--anim-fast) var(--anim-ease-out);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}

[data-theme="light"] .nav-pill-action {
  background: rgba(0, 0, 0, 0.08);
}

.nav-pill-action:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

[data-theme="light"] .nav-pill-action:hover {
  background: rgba(0, 0, 0, 0.12);
}

.nav-pill-action:active {
  transform: scale(0.95);
}

/* Icon-only action pills */
.nav-pill-action.icon-only {
  padding: 8px;
  min-width: 36px;
}

/* Individual pill button with liquid glass style */
.nav-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  min-height: 32px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-text-primary);
  border: none;
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--anim-fast) var(--anim-ease-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Light theme pills */
[data-theme="light"] .nav-pill {
  background: rgba(0, 0, 0, 0.08);
  color: var(--color-text-primary);
}

.nav-pill:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

[data-theme="light"] .nav-pill:hover {
  background: rgba(0, 0, 0, 0.12);
}

.nav-pill:active {
  transform: scale(0.95);
}

/* Active pill - prominent with color */
.nav-pill.active {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

[data-theme="light"] .nav-pill.active {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

/* Pill icon */
.nav-pill-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   TABLET (769px - 1023px)
   Full sidebar, hide right panel to maximize content space
   ---------------------------------------------------------------------------- */


@media (min-width: 769px) and (max-width: 1023px) {
  /* Hide pill navigation on tablet */
  .nav-pills-container {
    display: none !important;
  }

  /* Reset sidebar overlay from mobile */
  .sidebar-overlay {
    display: none !important;
  }
  
  /* CRITICAL: Reset ALL mobile-specific styles */
  .content-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0 !important;
  }
  
  .note-content {
    padding-left: var(--space-md) !important;
    padding-right: var(--space-md) !important;
  }
  
  /* Container with padding only on left for sidebar */
  .app-container {
    padding: 0 !important;
    padding-left: var(--sidebar-inset) !important;
    display: flex !important;
    flex-direction: row !important;
    gap: var(--sidebar-inset) !important;
    min-height: var(--viewport-block) !important;
    height: var(--viewport-block) !important;
    overflow: hidden !important; /* Prevent page scrolling */
    box-sizing: border-box !important;
    position: fixed !important; /* Lock container position */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }

  /* Rounded sidebar on the left */
  .sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    margin: var(--sidebar-inset) 0 !important;
    min-height: calc(var(--viewport-block) - (var(--sidebar-inset) * 2)) !important;
    height: calc(var(--viewport-block) - (var(--sidebar-inset) * 2)) !important;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--elevation-2) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    overscroll-behavior: contain !important; /* Prevent scroll chaining on iOS */
  }
  
  /* Main content - NO SHADOW, takes all remaining space */
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;
    overflow-y: auto !important; /* Allow content scroll */
    overflow-x: hidden !important;
    background-color: var(--color-bg-primary) !important;
    height: 100% !important; /* Use percentage instead of vh */
    overscroll-behavior: contain !important; /* Prevent bounce scroll */
    -webkit-overflow-scrolling: touch !important; /* Smooth iOS scrolling */
  }
  
  /* Hide sidebar toggle button */
  .sidebar-toggle {
    display: none !important;
  }
}

/* ----------------------------------------------------------------------------
   DESKTOP (1024px+)
   Full sidebar with rounded container
   ---------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  /* Hide pill navigation on desktop */
  .nav-pills-container {
    display: none !important;
  }

  /* Reset sidebar overlay from mobile */
  .sidebar-overlay {
    display: none !important;
  }
  
  /* CRITICAL: Reset ALL mobile-specific styles */
  .content-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0 !important;
  }
  
  .note-content {
    padding-left: var(--space-lg) !important;
    padding-right: var(--space-lg) !important;
  }
  
  /* Container with padding only on left for sidebar */
  .app-container {
    padding: 0 !important;
    padding-left: var(--sidebar-inset) !important;
    display: flex !important;
    flex-direction: row !important;
    gap: var(--sidebar-inset) !important;
    min-height: var(--viewport-block) !important;
    height: var(--viewport-block) !important;
    overflow: hidden !important; /* Prevent page scrolling */
    box-sizing: border-box !important;
    position: fixed !important; /* Lock container position */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }

  /* Rounded sidebar on the left - ONLY element with shadow */
  .sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    margin: var(--sidebar-inset) 0 !important;
    min-height: calc(var(--viewport-block) - (var(--sidebar-inset) * 2)) !important;
    height: calc(var(--viewport-block) - (var(--sidebar-inset) * 2)) !important;
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--elevation-2) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    overscroll-behavior: contain !important; /* Prevent scroll chaining on iOS */
  }
  
  /* Main content - NO SHADOW, NO BORDER RADIUS */
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;
    overflow-y: auto !important; /* Allow content scroll */
    overflow-x: hidden !important;
    background-color: var(--color-bg-primary) !important;
    height: 100% !important; /* Use percentage instead of vh */
    overscroll-behavior: contain !important; /* Prevent bounce scroll */
    -webkit-overflow-scrolling: touch !important; /* Smooth iOS scrolling */
  }
  
  /* Hide tablet toggle button */
  .sidebar-toggle {
    display: none !important;
  }
}

/* ----------------------------------------------------------------------------
   HIDE RIGHT SIDEBAR (1023px and DOWN)
   For mobile and tablet, hide the right sidebar/backlinks to save space
   ---------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .right-sidebar,
  .backlinks-panel {
    display: none !important;
  }
}

/* Show graph button in sidebar when right sidebar is hidden (tablet and small desktop) */
/* Right sidebar appears at 1200px+, so show button from 1199px and below */
@media (max-width: 1199px) {
  .sidebar-graph-button {
    display: flex !important;
  }
}

/* Hide graph button on large screens where right sidebar is visible */
@media (min-width: 1200px) {
  .sidebar-graph-button {
    display: none !important;
  }
}

/* ----------------------------------------------------------------------------
   DESKTOP (1024px+)
   Full sidebar with rounded container
   ---------------------------------------------------------------------------- */

/* ----------------------------------------------------------------------------
   MOBILE SPECIFIC (< 769px)
   Show pill navigation, content scrolls UNDER glass nav
   ---------------------------------------------------------------------------- */

/* MOBILE: Use full viewport height with safe areas */
@media (max-width: 768px) {
  /* iOS Safari: Allow body scroll for collapsing address bar */
  html {
    width: 100%;
    height: 100%;
    overflow: visible !important; /* CRITICAL: Allow scrolling */
  }

  body {
    width: 100%;
    min-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
    background-color: var(--color-bg-primary) !important;
  }

  /* Prevent body scroll when sidebar is open on mobile */
  body.sidebar-open {
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
  }

  /* App container uses dynamic viewport height */
  .app-container {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    width: 100% !important;
    position: relative !important;
  }

  /* The main content area - allows natural flow for body scroll */
  .main-content {
    flex: 1;
    /* Add top padding to account for floating navigation pills */
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--nav-pill-height) + var(--space-lg)) !important;
    /* Bottom padding only for safe area */
    padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    position: relative !important;
    width: 100%;
    background-color: var(--color-bg-primary) !important;
  }

  /* Content wrapper allows content to flow */
  .content-wrapper {
    display: flex;
    flex-direction: column;
    min-height: auto !important;
  }

  .note-content {
    padding: var(--space-md) !important;
  }

  /* Prevent zoom on form inputs only */
  input,
  textarea,
  select {
    font-size: 16px !important; /* Safari zooms on inputs < 16px */
  }
  
  /* MOBILE: Hide sidebar by default */
  .sidebar {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 10003 !important;
    background: transparent !important;
    border-right: none !important;
    margin: 0 !important;
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--nav-pill-height) + var(--space-lg)) !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .sidebar-content {
    display: flex !important;
    flex-direction: column !important;
    padding: var(--space-sm) var(--space-sm) calc(var(--space-sm) + env(safe-area-inset-bottom, 16px)) var(--space-sm) !important;
    gap: var(--space-md);
    min-height: min-content !important;
    background: var(--color-bg-primary) !important;
    border-radius: var(--border-radius-lg);
    margin: var(--space-sm);
  }

  .nav-section {
    margin-bottom: 0 !important;
  }

  #folder-tree {
    background: rgba(28, 28, 30, 0.55);
    backdrop-filter: blur(40px) saturate(220%) brightness(1.05);
    -webkit-backdrop-filter: blur(40px) saturate(220%) brightness(1.05);
    border: 0.5px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg) var(--space-md);
    box-shadow: none;
  }

  [data-theme="light"] #folder-tree {
    background: rgba(255, 255, 255, 0.72);
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    box-shadow: none;
  }

  /* Hide main content when sidebar is open */
  body.sidebar-open .main-content {
    visibility: hidden !important;
  }

  /* MOBILE: Show sidebar when open class is added */
  .sidebar.open {
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* MOBILE: Hide sidebar header */
  .sidebar .sidebar-header {
    display: none !important;
  }
  
  /* Mobile: Keep skip-to-content truly hidden unless focused */
  .skip-to-content:not(:focus) {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }
  
  /* Pill navigation container with liquid glass effect - FLOATING */
  .nav-pills-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + var(--space-md));
    left: var(--space-md);
    right: var(--space-md);
    height: var(--nav-pill-height);
    background: rgba(28, 28, 30, 0.5);
    backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
    -webkit-backdrop-filter: blur(100px) saturate(300%) brightness(1.1);
    border: 0.5px solid rgba(255, 255, 255, 0.25);
    border-radius: calc(var(--nav-pill-height) / 2);
    z-index: 10100 !important;
    display: flex !important;
    padding: 0 var(--space-md);
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                0 1px 2px rgba(0, 0, 0, 0.2),
                inset 0 1px 1px rgba(255, 255, 255, 0.15),
                inset 0 -1px 1px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
  }

  /* Light theme glass effect */
  [data-theme="light"] .nav-pills-container {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(120px) saturate(400%) brightness(1.05);
    -webkit-backdrop-filter: blur(120px) saturate(400%) brightness(1.05);
    border: 0.5px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
                0 2px 8px rgba(0, 0, 0, 0.05),
                inset 0 1px 1px rgba(255, 255, 255, 1),
                inset 0 -1px 1px rgba(0, 0, 0, 0.05);
  }

  /* Vault title - left side */
  .nav-pills-container .vault-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* HIDE center navigation pills on mobile */
  .nav-pills-scroll {
    display: none !important;
  }

  /* Action pills container - RIGHT SIDE */
  .nav-pills-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-shrink: 0;
    margin-left: auto;
  }

  /* Action pill buttons (theme, graph) - LIQUID GLASS */
  .nav-pill-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    min-height: 38px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    color: var(--color-text-primary);
    border: 0.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 9999px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--anim-fast) var(--anim-ease-out);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
                inset 0 1px 1px rgba(255, 255, 255, 0.25),
                inset 0 -1px 1px rgba(0, 0, 0, 0.1);
  }

  [data-theme="light"] .nav-pill-action {
    background: rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(50px) saturate(250%);
    -webkit-backdrop-filter: blur(50px) saturate(250%);
    border: 0.5px solid rgba(0, 0, 0, 0.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                inset 0 1px 1px rgba(255, 255, 255, 0.9),
                inset 0 -1px 1px rgba(0, 0, 0, 0.05);
  }

  .nav-pill-action:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.45);
    transform: scale(1.05);
    backdrop-filter: blur(50px) saturate(250%);
    -webkit-backdrop-filter: blur(50px) saturate(250%);
  }

  [data-theme="light"] .nav-pill-action:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(60px) saturate(300%);
    -webkit-backdrop-filter: blur(60px) saturate(300%);
  }

  .nav-pill-action:active {
    transform: scale(0.95);
  }

  /* Icon-only action pills */
  .nav-pill-action.icon-only {
    padding: 9px;
    min-width: 38px;
  }

  /* Individual pill button with liquid glass style */
  .nav-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    min-height: 32px;
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary);
    border: none;
    border-radius: 9999px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--anim-fast) var(--anim-ease-out);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  /* Light theme pills */
  [data-theme="light"] .nav-pill {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-text-primary);
  }

  .nav-pill:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
  }

  [data-theme="light"] .nav-pill:hover {
    background: rgba(0, 0, 0, 0.12);
  }

  .nav-pill:active {
    transform: scale(0.95);
  }

  /* Active pill - prominent with color */
  .nav-pill.active {
    background: var(--color-primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
  }

  [data-theme="light"] .nav-pill.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
  }

  /* Pill icon */
  .nav-pill-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
}

/* ----------------------------------------------------------------------------
   SMOOTH TRANSITIONS & MICROINTERACTIONS
   ---------------------------------------------------------------------------- */

/* Hover effect for navigation items */
.nav-item {
  position: relative;
  transition: all var(--anim-fast) var(--anim-ease-out);
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--color-primary);
  opacity: 0;
  transform: scaleY(0);
  transition: all var(--anim-fast) var(--anim-ease-out);
}

.nav-item:hover::before {
  opacity: 0.3;
  transform: scaleY(1);
}

.nav-item.active::before {
  opacity: 1;
  transform: scaleY(1);
}

/* Stagger animation for loading navigation items */
@keyframes navItemFadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.nav-item,
.nav-pill {
  animation: navItemFadeIn var(--anim-medium) var(--anim-ease-out);
  animation-fill-mode: both;
}

/* Stagger delay (applied via JS) */
.nav-item:nth-child(1),
.nav-pill:nth-child(1) { animation-delay: 0ms; }
.nav-item:nth-child(2),
.nav-pill:nth-child(2) { animation-delay: 50ms; }
.nav-item:nth-child(3),
.nav-pill:nth-child(3) { animation-delay: 100ms; }
.nav-item:nth-child(4),
.nav-pill:nth-child(4) { animation-delay: 150ms; }
.nav-item:nth-child(5),
.nav-pill:nth-child(5) { animation-delay: 200ms; }

/* Prevent stagger on subsequent renders */
.nav-item.loaded,
.nav-pill.loaded {
  animation: none;
}

/* Active pill auto-scroll animation */
@keyframes scrollToActive {
  to {
    scroll-behavior: smooth;
  }
}

/* ----------------------------------------------------------------------------
   DARK THEME ADJUSTMENTS
   ---------------------------------------------------------------------------- */

[data-theme="dark"] {
  --nav-pill-bg: rgba(255, 255, 255, 0.08);
  --nav-pill-bg-hover: rgba(255, 255, 255, 0.12);
  --elevation-1: 0 2px 4px rgba(0, 0, 0, 0.3);
  --elevation-2: 0 4px 12px rgba(0, 0, 0, 0.4);
  --elevation-3: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------------------------------------------
   UTILITY CLASSES
   ---------------------------------------------------------------------------- */

/* Hide visually but keep accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Prevent layout shift */
.nav-skeleton {
  height: var(--nav-pill-height);
  background: linear-gradient(
    90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-bg-secondary) 50%,
    var(--color-bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ----------------------------------------------------------------------------
   RESPONSIVE TYPOGRAPHY
   ---------------------------------------------------------------------------- */

@media (max-width: 479px) {
  .nav-pill {
    font-size: var(--font-size-xs);
    padding: 6px 12px;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .nav-pill {
    font-size: var(--font-size-sm);
    padding: 8px 16px;
  }
}

/* ----------------------------------------------------------------------------
   MOBILE GRAPH MODAL LAYOUT
   Top padding for nav clearance, controls as footer card
   ---------------------------------------------------------------------------- */

/* ----------------------------------------------------------------------------
   PRINT STYLES
   ---------------------------------------------------------------------------- */

@media print {
  .nav-pills-container,
  .sidebar-toggle,
  .skip-to-content {
    display: none !important;
  }
  
  .sidebar {
    display: none !important;
  }
}

/* ----------------------------------------------------------------------------
   TABLET & DESKTOP: Ensure skip-to-content stays hidden
   ---------------------------------------------------------------------------- */

@media (min-width: 769px) {
  /* Keep skip-to-content properly hidden on iPad/desktop */
  .skip-to-content:not(:focus) {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }
}
