html {
  overflow-y: scroll;
  /* Always reserve space for scrollbar */
}

:root {
  --bg-color: #ffffff;
  --text-color: #000000;
  --text-muted: #666666;
  --border-color: #e0e0e0;
  --accent-bg: #f8f8f8;
  --accent-bg-hover: #e8e8e8;
  --code-bg: #f5f5f5;
  --accent-red: #dc2626;
}

[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --text-color: #e5e5e5;
  --text-muted: #9ca3af;
  --border-color: #404040;
  --accent-bg: #2a2a2a;
  --accent-bg-hover: #3a3a3a;
  --code-bg: #262626;
  --accent-red: #f87171;
}

/* Text selection */
::selection,
::-moz-selection {
  background-color: var(--accent-red);
  color: #ffffff;
}

body {
  line-height: 1.6;
  font-family: "JetBrains Mono", monospace;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  margin: 0;
  padding: 0;
}

/* Main content container - always centered */
.main-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 1em;
}

/* Toggle buttons (theme and TOC) */
.theme-toggle,
.toc-toggle {
  position: fixed;
  top: 20px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  z-index: 1000;
  color: var(--text-color);
  width: 36px;
  height: 36px;
}

.theme-toggle {
  right: 20px;
}

.toc-toggle {
  left: 20px;
  z-index: 1001;
}

/* TOC Toggle - always visible */
.toc-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 36px;
  height: 36px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  color: var(--text-color);
  transition: all 0.2s ease;
}

.toc-toggle:hover {
  border-color: var(--accent-red);
  background: var(--accent-bg);
}

.toc-toggle:focus {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}

.toc-toggle svg {
  transition: transform 0.2s ease;
}

.toc-toggle.active svg {
  transform: rotate(90deg);
}

.theme-toggle:hover,
.toc-toggle:hover {
  border-color: var(--accent-red);
  background: var(--accent-bg-hover);
}

.toc-toggle svg {
  transition: transform 0.2s ease;
}

.toc-toggle.active svg {
  transform: rotate(90deg);
}

/* header and footer areas */
.menu {
  padding: 0;
  margin: 1.5em 0;
}

.menu li {
  display: inline-block;
  margin: 0 0.5em;
}

.article-meta,
.menu a {
  text-decoration: none;
  background: var(--accent-bg);
  color: var(--text-color);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.menu a:hover {
  background: var(--accent-bg-hover);
}

.menu,
.article-meta,
footer {
  text-align: center;
}

.title {
  font-size: 1.1em;
  font-weight: 600;
}

footer a {
  text-decoration: none;
}

/* Links */
a {
  color: var(--accent-red);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all 0.2s ease;
}

a:hover {
  text-decoration-color: var(--accent-red);
}

/* Menu links should stay neutral */
.menu a {
  color: var(--text-color);
  text-decoration: none;
}

.menu a:hover {
  text-decoration: none;
}

/* Spacing improvements */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

p {
  margin: 1em 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

/* code */
pre {
  border: 1px solid var(--border-color);
  background: var(--code-bg);
  padding: 1em;
  overflow-x: auto;
  border-radius: 4px;
}

code {
  background: var(--code-bg);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

pre code {
  background: none;
  padding: 0;
}

/* misc elements */
img,
iframe,
video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1em 0;
}

main {
  hyphens: auto;
}

blockquote {
  background: var(--accent-bg);
  border-left: 4px solid var(--text-color);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  font-style: italic;
  border-radius: 0 4px 4px 0;
}



/* Post meta styling */
.post-meta {
  color: var(--text-muted);
  font-size: 0.9em;
  margin: 1em 0;
  text-align: center;
}

.post-categories,
.post-tags {
  margin: 1em 0;
  text-align: center;
}

.post-categories a,
.post-tags a {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--text-color);
  padding: 4px 8px;
  margin: 2px;
  border-radius: 12px;
  font-size: 0.8em;
  text-decoration: none;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.post-categories a:hover,
.post-tags a:hover {
  background: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.post-tags a:before {
  content: "#";
}

table {
  margin: auto;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

table thead th {
  border-bottom: 1px solid var(--border-color);
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
}

thead,
tfoot,
tr:nth-child(even) {
  background: var(--accent-bg);
}

/* Custom list styling - only in article content */
article main ul {
  list-style: none;
  padding-left: 1.2em;
}

article main ul>li::before {
  content: "→";
  color: var(--accent-red);
  font-weight: bold;
  position: absolute;
  margin-left: -1.2em;
}

article main ol {
  list-style: none;
  counter-reset: item;
  padding-left: 1.5em;
}

article main ol>li {
  counter-increment: item;
}

article main ol>li::before {
  content: counter(item) " /";
  color: var(--accent-red);
  font-weight: bold;
  position: absolute;
  margin-left: -1.5em;
}

/* Nested lists in article content */
article main ul ul,
article main ol ul,
article main ul ol,
article main ol ol {
  margin: 0.5em 0;
  padding-left: 1.2em;
}

article main ul ul>li::before,
article main ol ul>li::before,
article main ul ol>li::before,
article main ol ol>li::before {
  content: "/";
  color: var(--text-muted);
  font-weight: normal;
  margin-left: -1.2em;
}

/* Site header and logo */
.site-header {
  text-align: center;
  margin: 2em 0 1em 0;
}

.site-logo {
  margin: 0;
  font-size: 1.8em;
  font-weight: 300;
  letter-spacing: 0.5px;
}

.site-logo a {
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-logo a:hover {
  color: var(--accent-red);
}

/* Footer links styling */
.footer-links {
  text-align: center;
  margin: 0.5em 0;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9em;
  margin: 0 1em;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--accent-red);
  text-decoration: underline;
}

/* Category in article meta */
.category-meta {
  color: var(--text-muted);
}

.category-meta a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.category-meta a:hover {
  color: var(--accent-red);
  text-decoration: underline;
}

/* Featured image styling */
.featured-image {
  margin: 0 0 2em 0;
}

.featured-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0;
}

/* Article header styling */
.article-header {
  text-align: center;
  margin-bottom: 2em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid var(--border-color);
}

.article-title {
  font-size: 2.2em;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5em 0;
  color: var(--text-color);
}

.article-meta {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.95em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
}

.article-meta time {
  font-weight: 500;
}

.article-meta .author {
  color: var(--text-muted);
  font-weight: 500;
}

.article-meta .author a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.article-meta .author a:hover {
  color: var(--accent-red);
  text-decoration: underline;
}


/* Post excerpt styling */
.post-excerpt {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent-red);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  border-radius: 0 4px 4px 0;
  font-size: 0.95em;
  color: var(--text-muted);
}

.post-excerpt strong {
  color: var(--accent-red);
  font-weight: 600;
}

/* Author block styling */
.author-block {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid var(--border-color);
}

.author-info h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0 0 1em 0;
  color: var(--text-color);
}

.author-info p {
  color: var(--text-muted);
  font-size: 0.9em;
  line-height: 1.5;
  margin: 0 0 1em 0;
}

.author-info strong {
  color: var(--text-color);
  font-weight: 600;
}

.author-links {
  display: flex;
  gap: 1em;
}

.author-links a {
  color: var(--accent-red);
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 500;
  padding: 0.4em 0.8em;
  border: 1px solid var(--accent-red);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.author-links a:hover {
  background: var(--accent-red);
  color: #ffffff;
}



/* ===== TABLE OF CONTENTS - OutlineWiki Style ===== */

/* Desktop TOC Sidebar - simple show/hide */
.toc-sidebar {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
  padding: 20px;
  z-index: 1000;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: var(--bg-color);
  /* Remove all borders and shadows */
  display: none; /* Hidden by default */
}

/* Show TOC when active - simple visibility toggle */
.toc-sidebar.active {
  display: block;
}

.toc-sidebar::-webkit-scrollbar {
  display: none;
}

/* TOC Label */
.toc-label {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-left: 4px;
}

/* TOC Navigation */
.toc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-nav li {
  margin: 0;
  padding: 0;
}

/* TOC Links - Clean minimal style */
.toc-nav a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 400;
  transition: all 0.2s ease;
  position: relative;
}

/* H1 links */
.toc-nav > ul > li > a {
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.9em;
  margin-bottom: 2px;
}

/* H2 links */
.toc-nav ul ul > li > a {
  padding-left: 16px;
  font-size: 0.8em;
}

/* H3 links */
.toc-nav ul ul ul > li > a {
  padding-left: 24px;
  font-size: 0.75em;
  opacity: 0.8;
}

/* Hover state */
.toc-nav a:hover {
  color: var(--text-color);
  background: var(--accent-bg);
}

/* Active state with smooth animation */
.toc-nav a.active {
  color: var(--accent-red);
  font-weight: 500;
  background: var(--accent-bg);
  transform: translateX(2px);
}

.toc-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--accent-red);
  border-radius: 1px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Focus styles for accessibility */
.toc-nav a:focus {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}



/* Mobile TOC Overlay */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 999;
}

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

/* Responsive behavior */
@media (max-width: 900px) {
  /* On mobile, TOC becomes full-height panel */
  .toc-sidebar {
    top: 0;
    transform: none;
    height: 100vh;
    width: 280px;
    padding: 80px 20px 20px 20px;
    left: -300px;
  }
  
  .toc-sidebar.active {
    left: 0;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .toc-sidebar {
    width: 100%;
    left: -100%;
  }
  
  .toc-sidebar.active {
    left: 0;
  }
}
/* ==
=== TABLE OF CONTENTS - Simple OutlineWiki Style ===== */

/* Desktop TOC Sidebar - positioned in left margin */
.toc-sidebar {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
  padding: 20px;
  z-index: 1000;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: var(--bg-color);
  display: none; /* Hidden by default */
}

/* On smaller screens where there's no room, position differently */
@media (max-width: 1199px) {
  .toc-sidebar {
    /* On smaller screens, overlay with background */
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    left: 70px; /* Position to right of toggle button */
    top: 60px; /* Below toggle button */
    transform: none;
    width: 240px;
    max-height: 60vh;
  }
  
  [data-theme="dark"] .toc-sidebar {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

.toc-sidebar::-webkit-scrollbar {
  display: none;
}

/* Show TOC when active - simple visibility toggle */
.toc-sidebar.active {
  display: block;
}

/* TOC Label */
.toc-label {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-left: 4px;
}

/* TOC Navigation */
.toc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-nav li {
  margin: 0;
  padding: 0;
}

/* TOC Links - Clean minimal style */
.toc-nav a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 400;
  transition: all 0.2s ease;
  position: relative;
}

/* H1 links */
.toc-nav > ul > li > a {
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.9em;
  margin-bottom: 2px;
}

/* H2 links */
.toc-nav ul ul > li > a {
  padding-left: 16px;
  font-size: 0.8em;
}

/* H3 links */
.toc-nav ul ul ul > li > a {
  padding-left: 24px;
  font-size: 0.75em;
  opacity: 0.8;
}

/* Hover state */
.toc-nav a:hover {
  color: var(--text-color);
  background: var(--accent-bg);
}

/* Active state - simple highlight */
.toc-nav a.active {
  color: var(--accent-red);
  font-weight: 500;
}

/* Focus styles for accessibility */
.toc-nav a:focus {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}

/* TOC Overlay - only for mobile */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 999;
}

.toc-overlay.active {
  display: block;
}

/* Mobile behavior - slide-in panel */
@media (max-width: 900px) {
  .toc-sidebar {
    /* Override desktop positioning for mobile */
    top: 0 !important;
    transform: none !important;
    height: 100vh;
    width: 280px;
    padding: 80px 20px 20px 20px;
    left: -300px !important;
    border: none !important;
    border-right: 1px solid var(--border-color) !important;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1) !important;
    border-radius: 0 !important;
    transition: left 0.3s ease;
  }
  
  .toc-sidebar.active {
    left: 0 !important;
    display: block;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .toc-sidebar {
    width: 100% !important;
    left: -100% !important;
  }
  
  .toc-sidebar.active {
    left: 0 !important;
  }
}