/* MODERN SIMPLISTIC THEME */

/* CSS Custom Properties for Light/Dark Mode */
:root {
  /* Light mode colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-md: rgba(0, 0, 0, 0.15);

  /* Code highlighting - Light mode */
  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --code-text: #334155;
  --code-comment: #64748b;
  --code-keyword: #dc2626;
  --code-string: #059669;
  --code-number: #7c3aed;
  --code-function: #0369a1;
  --code-operator: #475569;

  /* Font settings */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Monaco, Consolas, monospace;

  /* Spacing and sizing */
  --container-width: 1200px;
  --content-width: 800px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --header-height: 70px;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

/* Dark mode colors */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --border: #334155;
  --border-light: #475569;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-md: rgba(0, 0, 0, 0.4);

  /* Code highlighting - Dark mode */
  --code-bg: #1e293b;
  --code-border: #334155;
  --code-text: #e2e8f0;
  --code-comment: #94a3b8;
  --code-keyword: #fca5a5;
  --code-string: #86efac;
  --code-number: #c4b5fd;
  --code-function: #7dd3fc;
  --code-operator: #cbd5e1;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition);
  overflow-x: hidden;
}

body.loaded {
  opacity: 1;
}

body.menu-open {
  overflow: hidden;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: var(--transition-slow);
}

[data-theme="dark"] .site-header {
  background: rgba(15, 23, 42, 0.8);
}

.site-header.scrolled {
  box-shadow: 0 4px 6px -1px var(--shadow);
}

.site-header.hidden {
  transform: translateY(-100%);
}

.navbar {
  height: 100%;
}

.nav-container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
}

.brand-link:hover {
  color: var(--accent);
}

.brand-icon {
  font-size: 1.5rem;
  animation: pulse 2s infinite;
}

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

.nav-menu {
  display: flex;
  align-items: center;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

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

.nav-link::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Theme toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  transform: scale(1.05);
}

.theme-icon {
  font-size: 1.2rem;
  transition: var(--transition);
  position: absolute;
}

.theme-toggle .dark-icon {
  opacity: 0;
  transform: rotate(180deg);
}

.theme-toggle.dark-mode .light-icon {
  opacity: 0;
  transform: rotate(180deg);
}

.theme-toggle.dark-mode .dark-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Main content */
.main-content {
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 2rem 0;
}

/* Home page */
.home-content {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hero-section {
  text-align: center;
  padding: 4rem 0;
  margin-bottom: 3rem;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

.content-section {
  max-width: var(--content-width);
  margin: 0 auto;
}

/* Article page */
.article {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.article-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.article-date {
  font-weight: 500;
}

.reading-time {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

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

.tag {
  background: var(--bg-secondary);
  color: var(--accent);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Typography */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 2rem 0 1rem;
}

.article-content h1 {
  font-size: 2.25rem;
}
.article-content h2 {
  font-size: 1.875rem;
}
.article-content h3 {
  font-size: 1.5rem;
}
.article-content h4 {
  font-size: 1.25rem;
}
.article-content h5 {
  font-size: 1.125rem;
}
.article-content h6 {
  font-size: 1rem;
}

.article-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.8;
}

.article-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.article-content a:hover {
  border-bottom-color: var(--accent);
}

/* Lists */
.article-content ul,
.article-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.article-content li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

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

/* Code blocks */
.article-content code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--code-border);
}

.article-content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 2rem 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  line-height: 1.6;
  position: relative;
}

.article-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--code-text);
  font-size: 0.9rem;
}

/* Prism.js Syntax Highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--code-comment);
  font-style: italic;
}

.token.punctuation {
  color: var(--code-operator);
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--code-keyword);
  font-weight: 600;
}

.token.boolean,
.token.number {
  color: var(--code-number);
  font-weight: 600;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--code-string);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--code-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--code-keyword);
  font-weight: 600;
}

.token.function,
.token.class-name {
  color: var(--code-function);
  font-weight: 600;
}

.token.regex,
.token.important,
.token.variable {
  color: var(--code-number);
  font-weight: 500;
}

.token.important,
.token.bold {
  font-weight: 700;
}

.token.italic {
  font-style: italic;
}

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

.article-content blockquote p {
  margin-bottom: 0;
  font-size: 1.1rem;
}

/* Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

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

.article-content th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

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

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

.footer-content {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-info {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--accent);
}

/* Responsive design */
@media (max-width: 768px) {
  .nav-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    flex-direction: column;
    justify-content: flex-start;
    padding: 2rem 1.5rem;
    transform: translateX(-100%);
    transition: var(--transition-slow);
    border-top: 1px solid var(--border);
  }

  .nav-menu.active {
    transform: translateX(0);
  }

  .nav-links {
    flex-direction: column;
    gap: 2rem;
    width: 100%;
  }

  .nav-link {
    font-size: 1.25rem;
    width: 100%;
    padding: 1rem 0;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .hero-section {
    padding: 2rem 0;
  }

  .article-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }

  .article-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0 1rem;
  }

  .main-content {
    padding: 1rem 0;
  }

  .article {
    padding: 0 1rem;
  }

  .home-content {
    padding: 0 1rem;
  }

  .article-content pre {
    margin: 1.5rem -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* Loading animation */
body:not(.loaded) {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-slow);
  z-index: 999;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* Animation classes */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ACCESSIBILITY STYLES */

/* Skip links for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  z-index: 10000;
  transition: var(--transition);
  transform: translateY(-100%);
}

.skip-link:focus {
  top: 8px;
  transform: translateY(0);
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* Focus styles for accessibility - WCAG 2.2 compliant */
*:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Modern focus-visible support for better UX */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Enhanced focus styles for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--bg-primary);
}

/* Special focus treatment for theme toggle and mobile menu */
.theme-toggle:focus-visible,
.mobile-menu-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  box-shadow:
    0 0 0 1px var(--bg-primary),
    0 0 0 5px var(--accent-hover);
}

/* Navigation link focus styles */
.nav-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Footer link focus styles */
.footer-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Touch target improvements - ensure 44x44px minimum */
.nav-link {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
}

.footer-link {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
}

.brand-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px;
}

/* Ensure adequate color contrast - WCAG 2.2 Level AA */
:root {
  /* Enhanced contrast ratios for accessibility */
  --text-primary: #0f172a; /* 16.75:1 on white */
  --text-secondary: #334155; /* 9.3:1 on white */
  --text-muted: #475569; /* 6.7:1 on white */
  --accent: #2563eb; /* 5.9:1 on white, 3.4:1 on light backgrounds */
  --accent-hover: #1d4ed8; /* 7.1:1 on white */
}

[data-theme="dark"] {
  /* Enhanced contrast ratios for dark mode */
  --text-primary: #f8fafc; /* 18.1:1 on dark background */
  --text-secondary: #e2e8f0; /* 13.4:1 on dark background */
  --text-muted: #cbd5e1; /* 9.8:1 on dark background */
  --accent: #60a5fa; /* 6.2:1 on dark background */
  --accent-hover: #3b82f6; /* 7.8:1 on dark background */
}

/* High contrast focus indicators */
@media (prefers-contrast: high) {
  *:focus-visible {
    outline: 4px solid;
    outline-color: var(--accent);
    outline-offset: 2px;
    box-shadow:
      0 0 0 2px var(--bg-primary),
      0 0 0 6px var(--accent);
  }

  .skip-link:focus {
    outline: 4px solid #ffffff;
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 0 8px #ffffff;
  }
}

/* Motion preferences for focus transitions */
@media (prefers-reduced-motion: reduce) {
  .skip-link,
  *:focus-visible {
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --shadow: rgba(0, 0, 0, 0.5);
  }

  [data-theme="dark"] {
    --border: #ffffff;
    --shadow: rgba(255, 255, 255, 0.3);
  }
}

/* Post previews on homepage */
.posts-preview {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

.post-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.post-preview:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--shadow);
}

.post-preview h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.post-preview h3 a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.post-preview .post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-preview .post-meta time {
  color: var(--text-muted);
}

.post-preview .reading-time {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.post-excerpt {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.post-excerpt p {
  margin: 0;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.read-more:hover {
  color: var(--accent-dark);
}

@media (max-width: 768px) {
  .post-preview .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Table of Contents */
.table-of-contents {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin: 2rem 0;
  position: relative;
}

.table-of-contents::before {
  content: "📋 Table of Contents";
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.table-of-contents ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.table-of-contents > ul {
  margin-left: 0;
}

.table-of-contents li {
  margin: 0.5rem 0;
  position: relative;
}

.table-of-contents a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
  border-radius: 0.25rem;
  transition:
    color 0.2s ease,
    background-color 0.2s ease;
  font-size: 0.95rem;
  line-height: 1.4;
}

.table-of-contents a:hover {
  color: var(--accent);
  background-color: var(--bg-primary);
  padding-left: 0.5rem;
}

.table-of-contents a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Nested TOC items */
.table-of-contents ul ul {
  margin-left: 1.5rem;
  margin-top: 0.25rem;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}

.table-of-contents ul ul a {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.table-of-contents ul ul ul {
  margin-left: 1rem;
  border-left-color: var(--border-light);
}

.table-of-contents ul ul ul a {
  font-size: 0.85rem;
}

/* Responsive TOC */
@media (max-width: 768px) {
  .table-of-contents {
    padding: 1rem;
    margin: 1.5rem 0;
  }

  .table-of-contents ul ul {
    margin-left: 1rem;
    padding-left: 0.75rem;
  }

  .table-of-contents ul ul ul {
    margin-left: 0.75rem;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .post-preview {
    transition: none;
  }

  .post-preview:hover {
    transform: none;
  }
}

/* Mermaid Diagrams */
.mermaid-diagram {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 2rem 0;
  text-align: center;
  overflow-x: auto;
  position: relative;
}

.mermaid-diagram::before {
  content: "📊 Diagram";
  position: absolute;
  top: 0.5rem;
  left: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  z-index: 1;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  background: transparent;
}

/* Override Mermaid's default styling to match theme */
.mermaid-diagram .node rect,
.mermaid-diagram .node circle,
.mermaid-diagram .node ellipse,
.mermaid-diagram .node polygon {
  fill: var(--bg-primary) !important;
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
}

.mermaid-diagram .node .label,
.mermaid-diagram .nodeLabel {
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}

.mermaid-diagram .edgePath .path {
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
  fill: none !important;
}

.mermaid-diagram .edgeLabel {
  background-color: var(--bg-primary) !important;
  color: var(--text-secondary) !important;
  font-family: var(--font-sans) !important;
  font-size: 12px !important;
}

.mermaid-diagram .arrowheadPath {
  fill: var(--accent) !important;
  stroke: var(--accent) !important;
}

/* Flowchart specific styling */
.mermaid-diagram .flowchart-link {
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
}

/* Sequence diagram styling */
.mermaid-diagram .actor {
  fill: var(--bg-primary) !important;
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
}

.mermaid-diagram .actor-line {
  stroke: var(--border) !important;
  stroke-width: 1px !important;
  stroke-dasharray: 5, 5 !important;
}

.mermaid-diagram .messageLine0,
.mermaid-diagram .messageLine1 {
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
}

/* Git diagram styling */
.mermaid-diagram .commit-id,
.mermaid-diagram .commit-type,
.mermaid-diagram .commit-msg {
  fill: var(--text-primary) !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
}

.mermaid-diagram .section {
  fill: var(--bg-tertiary) !important;
}

.mermaid-diagram .branch {
  stroke-width: 4px !important;
  stroke-linecap: round !important;
}

.mermaid-diagram .branch0 {
  stroke: #3b82f6 !important;
}

.mermaid-diagram .branch1 {
  stroke: #10b981 !important;
}

.mermaid-diagram .branch2 {
  stroke: #f59e0b !important;
}

.mermaid-diagram .branch3 {
  stroke: #ef4444 !important;
}

.mermaid-diagram .branch4 {
  stroke: #8b5cf6 !important;
}

/* Accessibility improvements for Mermaid diagrams */
.mermaid-diagram[role="img"] {
  outline: none;
}

.mermaid-diagram:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Dark mode specific Mermaid adjustments */
[data-theme="dark"] .mermaid-diagram {
  background: var(--bg-secondary);
}

[data-theme="dark"] .mermaid-diagram::before {
  background: var(--bg-primary);
  color: var(--text-muted);
}

/* High contrast mode for Mermaid diagrams */
@media (prefers-contrast: high) {
  .mermaid-diagram .node rect,
  .mermaid-diagram .node circle,
  .mermaid-diagram .node ellipse,
  .mermaid-diagram .node polygon {
    stroke-width: 3px !important;
  }

  .mermaid-diagram .edgePath .path,
  .mermaid-diagram .flowchart-link {
    stroke-width: 3px !important;
  }
}

/* Mobile responsive Mermaid diagrams */
@media (max-width: 768px) {
  .mermaid-diagram {
    padding: 1rem;
    margin: 1.5rem 0;
  }

  .mermaid-diagram::before {
    font-size: 0.7rem;
    top: 0.25rem;
    left: 0.75rem;
    padding: 0.2rem 0.4rem;
  }

  .mermaid-diagram svg {
    font-size: 12px;
  }

  .mermaid-diagram .node .label,
  .mermaid-diagram .nodeLabel {
    font-size: 12px !important;
  }

  .mermaid-diagram .edgeLabel {
    font-size: 10px !important;
  }
}

/* Reduced motion for Mermaid animations */
@media (prefers-reduced-motion: reduce) {
  .mermaid-diagram * {
    animation: none !important;
    transition: none !important;
  }
}
