:root {
    --primary-color: #1d2d3e;
    --secondary-color: #4a6572;
    --accent-color: #0383c9;
    --accent-color-info: #5b5fdd;
    --background-color: #f5f5f5;
    --background-color-light: rgba(29, 45, 62, 0.1);
    --card-background: #ffffff;
    --text-color: #333333;
    --table-title: #7a0f51;
    --border-color: #e0e0e0;
    --code-background: #3a3b34;
    --danger-background: #f2dede;
    --danger-text: #b96396;
    --note-background: #dff0d8;
    --note-text: #212121;
    --info-background: #d9edf7;
    --info-text: #424242;
    --warning-background: #fcf8e3;
    --hint-background: #E0F2F1;
    color-scheme: light;
}

/* Respect OS preference by default */
@media (prefers-color-scheme: light) {
  :root {
    /* dark tokens */
    --primary-color: #c7d3e0;
    --secondary-color: #9bb0bc;
    --accent-color: #4fb2ff;
    --accent-color-info: #84dd5b;
    --background-color: #0f141a;
    --background-color-light: rgba(79, 96, 115, 0.1);
    --card-background: #19212b;
    --text-color: #e6e6e6;
    --table-title: #c7d3e0;
    --border-color: #2a3441;
    --code-background: #0f141a;
    --danger-background: #4c2a2a;
    --danger-text: #b48183;
    --note-background: #2d3829;
    --note-text: #699269;
    --info-background: #2b383e;
    --info-text: #6da6da;
    --warning-background: #4e4632;
    --hint-background: #384e58;
    color-scheme: dark;
  }
}

/* Explicit overrides take full control */
html[data-theme="dark"] {
  --primary-color: #c7d3e0;
  --secondary-color: #9bb0bc;
  --accent-color: #4fb2ff;
  --accent-color-info: #84dd5b;
  --background-color: #0f141a;
  --background-color-light: rgba(79, 96, 115, 0.1);
  --card-background: #19212b;
  --text-color: #e6e6e6;
  --table-title: #c7d3e0;
  --border-color: #2a3441;
  --code-background: #0f141a;
  --danger-background: #4c2a2a;
  --danger-text: #b48183;
  --note-background: #2d3829;
  --note-text: #699269;
  --info-background: #2b383e;
  --info-text: #6da6da;
  --warning-background: #4e4632;
  --hint-background: #384e58;
  color-scheme: dark;
}

html[data-theme="light"] {
  /* RE-DECLARE the full light token set to override any dark values */
  --primary-color: #1d2d3e;
  --secondary-color: #4a6572;
  --accent-color: #0383c9;
  --background-color: #f5f5f5;
  --background-color-light: rgba(29,45,62,0.1);
  --card-background: #ffffff;
  --text-color: #333333;
  --table-title: #7a0f51;
  --border-color: #e0e0e0;
  --code-background: #3a3b34;
  --danger-background: #f2dede;
  --danger-text: #b96396;
  --note-background: #dff0d8;
  --note-text: #212121;
  --info-background: #d9edf7;
  --info-text: #424242;
  --warning-background: #fcf8e3;
  --hint-background: #E0F2F1;
  color-scheme: light;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.4;
}

/* Main content area - FULL WIDTH */
.main-content {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
}

.content-header {
    background-color: var(--background-color);
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

/* Button-like control shared by link and button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .6rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-background);
  color: var(--text-color);
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  margin: 0.5rem;
}

/* Outline variant uses your variables and hover focus affordances */
.btn:hover {
  border-color: var(--accent-color);
  background: rgba(3,131,201,.06);
  color: #6863b6;
}

.btn:hover .material-icons {
  color: #6863b6; /* Same color as your button text */
}

/* Size Material Icons inside controls */
.btn .material-icons {
  font-size: 20px;
}

/* Remove global external-link pseudo icon for button-like links */
.btn::after { content: none; }

.content-header h2 {
    font-weight: 400;
    color: var(--text-color);
}


/* Reset and base styles */
.toc-summary { display: none; }

/* Desktop: sticky ToC */
@media (min-width: 769px) {
    .content-with-toc {
        display: flex;
        align-items: flex-start;
        gap: 1.5rem;
        padding: 20px;
        position: relative; /* Important for sticky positioning context */
    }

    .toc-disclosure {
        width: 300px;
        flex-shrink: 0;
        position: sticky;
        top: 20px;
        align-self: flex-start;
        height: fit-content;
    }

    .toc-summary { 
        display: none; 
    }

    .toc-sidebar {
        background: var(--card-background);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 1.25rem;
        width: 100%;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }

    .toc-sidebar li {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    flex-wrap: wrap; /* Allow content to wrap to new line */
    }

    .toc-sidebar li::before {
    content: counters(item, ".") ". ";
    flex: 0 0 auto;
    min-width: 2ch;   /* aligns multi-digit numbers */
    text-align: right;
    margin-right: 0.25rem;
    }

    .toc-sidebar a {
    display: block;     /* keep full-row click target */
    flex: 1 1 auto;
    }

    .toc-sidebar ul ul {
        margin-left: 0.5rem; /* Reduced indentation */
        padding-left: 0.5rem;
    }

    .toc-sidebar ul ul li {
        padding-left: 0.5rem; /* Indent nested items */
    }
    .toc-sidebar ul ul li::before {
        min-width: 2.5ch; /* Slightly wider for nested numbers like 1.1 */
    }


}


/* Mobile: disclosure pattern */
@media (max-width: 768px) {
  .content-with-toc {
    flex-direction: column;
    gap: 1rem;
    padding: 10px;
  }

  .toc-disclosure { 
    width: 100%; 
  }

  .toc-summary {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-background);
    cursor: pointer;
  }

  .toc-summary::-webkit-details-marker { display: none; }
  .toc-summary::marker { content: ""; }

  .toc-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: .5rem;
  }
}

/* === UPDATED: Main content area with improved spacing === */
.content-with-toc .content {
    flex: 1;
    background-color: var(--card-background);
    border-radius: 8px;
    padding: 2rem; /* Increased padding */
    border: 1px solid var(--border-color);
}

/* === NEW: Enhanced content typography and spacing === */
.content-with-toc .content p {
    margin-bottom: 1.2rem; /* Increased paragraph spacing */
    line-height: 1.7; /* Better line height for readability */
}

.content-with-toc .content h1,
.content-with-toc .content h2,
.content-with-toc .content h3,
.content-with-toc .content h4,
.content-with-toc .content h5,
.content-with-toc .content h6 {
    margin-top: 2rem; /* Space above headings */
    margin-bottom: 1rem; /* Space below headings */
    color: var(--primary-color);
    line-height: 1.3;
    position: relative;
    padding-right: 30px; /* Make space for the anchor icon */
}

/* Heading anchor links - Chain icon style */
.content-with-toc .content h1 > .heading-anchor,
.content-with-toc .content h2 > .heading-anchor,
.content-with-toc .content h3 > .heading-anchor,
.content-with-toc .content h4 > .heading-anchor,
.content-with-toc .content h5 > .heading-anchor,
.content-with-toc .content h6 > .heading-anchor {
    text-decoration: none;
    color: inherit; /* Inherit color from heading */
}

/* Only the anchor icon is hoverable */
.content-with-toc .content h1 > .heading-anchor:hover,
.content-with-toc .content h2 > .heading-anchor:hover,
.content-with-toc .content h3 > .heading-anchor:hover,
.content-with-toc .content h4 > .heading-anchor:hover,
.content-with-toc .content h5 > .heading-anchor:hover,
.content-with-toc .content h6 > .heading-anchor:hover {
    opacity: 1 !important;
    background-color: rgba(33, 164, 234, 0.1);
    color: var(--accent-color);
    border-radius: 4px; /* Nicely rounded edges */
}

/* SVG icon styling (if using SVG instead) */
/* 
.heading-anchor .anchor-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
} */


a.heading-anchor {
    display: inline-block;
    white-space: normal;
}

a.heading-anchor::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    background-color: currentColor;
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    opacity: 0.6;
    transition: all 0.2s ease;
    vertical-align: middle; /* Keep as middle */
    position: relative;
    top: -1px; /* Fine-tune vertical position */
}



/* Show the chain icon on heading hover */
.content-with-toc .content h1:hover a.heading-anchor::after,
.content-with-toc .content h2:hover a.heading-anchor::after,
.content-with-toc .content h3:hover a.heading-anchor::after,
.content-with-toc .content h4:hover a.heading-anchor::after,
.content-with-toc .content h5:hover a.heading-anchor::after,
.content-with-toc .content h6:hover a.heading-anchor::after {
    opacity: 1;
}

/* Hover effects on the chain icon itself */
a.heading-anchor:hover::after {
    background-color: var(--accent-color);
    transform: scale(1.1);
}

/* Specific heading spacing */
.content-with-toc .content h1 {
    margin-top: 0; /* First heading doesn't need top margin */
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.content-with-toc .content h2 {
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.content-with-toc .content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.content-with-toc .content h4 {
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

/* List spacing */
.content-with-toc .content ul,
.content-with-toc .content ol {
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.content-with-toc .content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.content-with-toc .content li:last-child {
    margin-bottom: 0;
}

/* Blockquote spacing */
.content-with-toc .content blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1.25rem; /* Even smaller vertical padding */
    border-left: 4px solid var(--accent-color);
    background-color: rgba(3, 131, 201, 0.05);
    border-radius: 0 4px 4px 0;
}

.content-with-toc .content blockquote p {
    margin: 0.25rem 0; /* Very small paragraph margins inside blockquotes */
}

/* Code block spacing */
.content-with-toc .content pre {
    margin: 1.2rem 0;
    padding: 1.2rem 1.5rem;
    border-radius: 6px;
    background-color: var(--code-background);
    overflow-x: auto;
    position: relative;
}

.content-with-toc .content code:not(pre code) {
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background-color: var(--code-background);
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
}

.content-with-toc .content pre code {
    padding: 0;
    background-color: transparent;
    display: block;
    line-height: 1.5;
}

/* Adjust for copy button and language label */
.content-with-toc .content pre:has(code) {
    padding-top: 2rem; /* Extra space at top for labels */
}

.content-with-toc .content pre:has(code)::before {
    top: 12px; /* Adjust language label position */
}

.content-with-toc .content pre:has(code) .copy-button {
    top: 12px; /* Adjust copy button position */
}

/* Table spacing */
.content-with-toc .content table {
    margin: 1.2rem 0;
}

/* Horizontal rule spacing */
.content-with-toc .content hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Image spacing */
.content-with-toc .content img {
    margin: 0.95rem 0;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.content-with-toc .content-center {
    display: grid;
    place-items: center;
    height: auto;
    padding-bottom: 1.5rem;
}

.content-with-toc .content-center img {
  max-width: 100%;
  height: auto;
}

/* Reduce spacing for images inside paragraphs */
.content-with-toc .content p img {
    margin: 1rem 0 0.3rem; /* Reduced margin when inside paragraphs */
}

/* Specific spacing for paragraphs that come before/after blockquotes when they contain images */
.content-with-toc .content p:has(img) + blockquote,
.content-with-toc .content blockquote + p:has(img) {
    margin-top: 0.5rem;
}

/* === RESPONSIVE DESIGN: Mobile layout === */
@media (max-width: 768px) {
    .content-with-toc {
        flex-direction: column;
        gap: 1rem;
        padding: 10px;
    }

    .toc-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
    
    .content-with-toc .content {
        padding: 1.5rem; /* Slightly reduced padding on mobile */
    }
}

/* Link styling with hover effects and icons */
a {
    display: inline-flex;
    align-items: center;
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
    line-height: 1;
}

a:hover {
    border-bottom: 1px solid currentColor;
    color: #00a000; /* Green color on hover */
}

a::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    background-color: currentColor;
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-arrow-out-up-right"><path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"/><path d="m21 3-9 9"/><path d="M15 3h6v6"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-arrow-out-up-right"><path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"/><path d="m21 3-9 9"/><path d="M15 3h6v6"/></svg>');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* To change the default icon size */
.material-icons {
  font-size: 20px; /* Adjust to match your design */
  vertical-align: -0.2em; /* Adjust this value as needed */
}

/* Your existing link hover effect will also style the icon! */
a:hover .material-icons {
  color: #00a000; /* Your chosen green hover color */
}

/* Table */

/* Markdown table styling with alternating colors and hover effects */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Make tables responsive on mobile */
@media (max-width: 768px) {
    .content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Optional: Stack table cells for better mobile reading */
    .content table.stack-on-mobile {
        display: table;
        width: 100%;
        white-space: normal;
    }
    
    .content table.stack-on-mobile thead {
        display: none;
    }
    
    .content table.stack-on-mobile tbody,
    .content table.stack-on-mobile tr,
    .content table.stack-on-mobile td {
        display: block;
        width: 100%;
    }
    
    .content table.stack-on-mobile tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 0.5rem;
    }
    
    .content table.stack-on-mobile td {
        border: none;
        padding: 0.5rem;
        position: relative;
        padding-left: 50%;
    }
    
    .content table.stack-on-mobile td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        width: 45%;
        font-weight: 600;
        color: var(--primary-color);
    }
}

.content table thead {
    /* background-color: rgba(29, 45, 62, 0.1);  Lighter version of primary color */
    background-color: var(--background-color-light);
}

.content table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 500;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--table-title);
    background-color: transparent; /* Added to match table background */
}

.content table th:last-child {
    border-right: none;
}

.content table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    transition: all 0.2s ease;
    background-color: transparent; /* Added to match table background */
    word-wrap: break-word;
    color: var(--text-color);
}

.content table td:last-child {
    border-right: none;
}

@media (max-width: 768px) {
    .content table td {
        max-width: none;
    }
}

/* Alternating row colors - REMOVED since we want same as padding */
/* .content table tbody tr:nth-child(even) {
    background-color: var(--background-color);
}

.content table tbody tr:nth-child(odd) {
    background-color: var(--card-background);
} */

/* Hover effect - updated to be more subtle */
.content table tbody tr:hover {
    background-color: rgba(3, 131, 201, 0.05); /* Very light accent color */
    border-left: 3px solid var(--accent-color);
}

/* Remove border from last row */
.content table tbody tr:last-child td {
    border-bottom: none;
}

/* Optional: Add some spacing and styling for table headers */
.content table th { 
    font-weight: 400;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* -------------------------------------------- */
/* Admonition Styles for Eleventy */
/* Admonition base styles */
.admonition {
    border: 1px solid;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: block;
    position: relative;
    overflow: hidden;
}

.admonition-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Only show border bottom if there's content after header */
.admonition:has(.admonition-content) .admonition-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 1.5rem 0rem;
}

.admonition-content {
    padding: 1rem 1.5rem 1rem;
}

.admonition:has(.admonition-header) .admonition-content  {
        padding: 0rem 1.5rem;
}

.admonition-icon {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 1.2em;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;
    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;
    /* Support for IE. */
    font-feature-settings: 'liga';
    transform: translateY(0.05em);
}

/* Content paragraph styles */
.admonition-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.admonition-content p:first-of-type {
    margin-top: 0;
}

.admonition-content p:last-of-type {
    margin-bottom: 0;
}

/* Individual admonition styles */
.note {
    background-color: var(--note-background);
    border-color: #A6A6A6;
    color: var(--note-text);
}

.tip {
    background-color: #F5F5F5;
    border-color: #B9B9B9;
    color: #616161;
}

.info {
    background-color: var(--info-background);
    border-color: #AAAAAA;
    color: var(--info-text);
}

.info a {
    color: var(--accent-color-info);
}

.quote {
    background-color: #ECEFF1;
    border-color: #A9B3B8;
    color: #455A64;
}

.abstract {
    background-color: #E1F5FE;
    border-color: #87C9EC;
    color: #0288D1;
}

.attention {
    background-color: #E3F2FD;
    border-color: #94C7F3;
    color: #1E88E5;
}

.example {
    background-color: #EDE7F6;
    border-color: #B39FDA;
    color: #5E35B1;
}

.hint {
    background-color: var(--hint-background);
    border-color: #86C8C1;
    color: #00897B;
}

.success {
    background-color: #E8F5E9;
    border-color: #A1CBA3;
    color: #388E3C;
}

.question {
    background-color: #FFFDE7;
    border-color: #FCDB99;
    color: #F9A825;
}

.caution {
    background-color: #FFF8E1;
    border-color: #FDCC87;
    color: #FB8C00;
}

.warning {
    background-color: var(--warning-background);
    border-color: #FBC386;
    color: #F57C00;
}

.danger {
    background-color: var(--danger-background);
    border-color: #EFA797;
    color: var(--danger-text);
}

.failure {
    background-color: #FEE2E6;
    border-color: #EC9A9C;
    color: #D32F2F;
}

.bug {
    background-color: #FDDADD;
    border-color: #E58D8F;
    color: #C31A1A;
}

.error {
    background-color: #FDD2D6;
    border-color: #E1898B;
    color: #B71C1C;
}

/* === UPDATED: TOC Sidebar - Now a sticky flex item === */
.toc-sidebar {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* === UPDATED: TOC List Styling with Numbers === */
.toc-sidebar ol {
    list-style: none;
   /* padding-left: 0.3rem; */
    counter-reset: item;
    margin: 0;
}

.toc-sidebar li:before {
  content: counters(item, ".") ". ";
  margin-right: 0.25rem;
}

.toc-sidebar li {
    margin: 0.5rem 0;
    counter-increment: item;
   /* padding-left: 0.5rem; */
}

/* Indent nested list items for hierarchy */
.toc-sidebar ol ol {
    list-style: none;
    padding-left: 0.7rem;
    margin: 0.25rem 0;
}

.toc-sidebar ol ol li {
    margin: 0.25rem 0;
    font-size: 0.9em;
}

/* Further nesting */
.toc-sidebar ol ol ol {
    list-style: none;
}

/* === UPDATED: TOC-specific link styles === */
.toc-sidebar a {
    display: block;
    color: var(--accent-color) !important;
    text-decoration: none;
    border-bottom: none !important;
    transition: color 0.2s ease;
    line-height: 1.3;
}

/* Remove the external link icon for TOC links */
.toc-sidebar a::after {
    display: none !important;
}

.toc-sidebar a:hover {
    color: var(--primary-color) !important;
    text-decoration: underline;
}

/* TOC headings */
.toc-sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* ------------------------------------------------------- */

/* Make the anchor inline-block when it contains centered content */
/*.heading-anchor:has(.center-heading) {
    /* display: inline-block !important; */
/*    display: inline-flex !important;
    text-align: center;
    width: auto;
    margin-left: 50%;
    transform: translateX(-50%);
    white-space: nowrap; /* Prevent text wrapping */
/* }

/*.heading-anchor:has(.center-heading)::after {
/*    margin-left: 4px; /* Reduce from 8px to 4px */
/*    flex-shrink: 0;
/*    vertical-align: middle;
/*    position: relative;
/*    top: 4px; /* Fine-tune if needed */
/* }

/* Make the anchor inline-block when it contains centered content */
.heading-anchor:has(.center-heading) {
    display: inline-flex !important;
    align-items: center;
    text-align: center;
    margin-left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    gap: 4px; /* Consistent spacing control */
}

.heading-anchor:has(.center-heading)::after {
    margin-left: 0 !important; /* Remove margin since gap handles spacing */
    flex-shrink: 0;
    position: relative;
    top: 4px;
}


/* ------------------------------------------------------- */
/* theme-toggle */

#theme-toggle:focus {
  outline: 2px solid var(--accent-color, #007bff);
  outline-offset: 2px;
}

#theme-toggle:active {
  transform: translateY(1px);
}

/* Optional global smooth scroll; disabled for reduced motion */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; } /* no smooth scroll when reduced motion is set */
}

/* Back-to-top button base */
.back-to-top {
  position: fixed;           /* stays in viewport corner */
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;

  padding: .6rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--card-background);
  color: var(--text-color);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  cursor: pointer;

  opacity: 0;                /* hidden by default */
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

/* Visible state toggled by JS */
.back-to-top.back-to-top--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Hover/focus styles */
.back-to-top:hover {
  border-color: var(--accent-color);
  background: rgba(3,131,201,.06);
}
.back-to-top:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
    transform: none;
  }
}

/* Floating TOC Toggle Button - Always visible */
.toc-toggle-wrapper {
  position: sticky;
  top: 20px;
  width: 300px;
  flex-shrink: 0;
  align-self: flex-start;
  height: fit-content;
}

.toc-toggle {
  position: absolute;
  right: -16px;
  top: 20px;
  z-index: 100;
  
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--card-background);
  color: var(--text-color);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  
  opacity: 0.3;
  transition: all 0.3s ease;
}

.toc-toggle:hover {
  opacity: 1;
  border-color: var(--accent-color);
  background: rgba(3, 131, 201, 0.1);
  transform: scale(1.1);
}

.toc-toggle .material-icons {
  font-size: 18px;
}

/* TOC styles */
.toc-disclosure {
  width: 100%;
  position: static;
}

.toc-sidebar {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

/* When TOC is hidden, keep the wrapper but hide only the TOC content */
.toc-disclosure:not([open]) {
  display: none;
}

/* When TOC is hidden, make the wrapper compact and keep toggle visible */
.toc-toggle-wrapper:has(.toc-disclosure:not([open])) {
  width: auto; /* Compact width when TOC is hidden */
}

/* When TOC is hidden, reposition the toggle to be more accessible */
.toc-toggle-wrapper:has(.toc-disclosure:not([open])) .toc-toggle {
  position: static; /* Remove absolute positioning */
  margin: 0;
  right: auto;
  top: auto;
}

/* Content expansion when TOC is hidden */
.toc-toggle-wrapper:has(.toc-disclosure:not([open])) ~ .content {
  flex: 1;
  width: 100%;
  max-width: 100%;
}

/* Hide the header menu toggle on desktop */
@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }
}

/* Mobile styles */
@media (max-width: 768px) {
  .menu-toggle {
    display: inline-flex;
  }
  
  .toc-toggle {
    display: none !important;
  }
  
  .toc-toggle-wrapper {
    width: 100%;
    position: static;
  }
  
  .toc-sidebar {
    max-height: none;
  }
}

/* -------------------------------- */
/* In your main CSS file */
.text-red { color: #dc2626; }
.text-blue { color: #2563eb; }
.text-dark-green { color: #16a34a; }
.text-gray-600 { color: #4b5563; }
.text-green { color: #00ff00; }
.text-yellow { color: #FFE100; }
.text-lightcoral { color: #f08080; }
.doubleUnderline {
    text-decoration:underline;
    border-bottom: 1px solid #dc2626;
}

/* Fix nested spans with higher specificity */
.heading-anchor > span > span[class*="text-"] {
    margin-right: -8px !important;
}

/* -------------------------------- */
/* Markdown Customization */

mark {
  background-color: #79744e;
  color: rgb(255, 255, 255);
  padding: 0.2em 0.3em;
  font-size: 1.1em;
  border-radius: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1); /* Subtle text shadow */
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}


/* Base code block styling */
pre:has(code) {
  position: relative;
  margin: 5px 0;
  padding: 2.5rem 1rem 1.25rem 1rem; /* More top padding for buttons */
  background: #2d2d2d;
  border-radius: 8px;
  overflow-x: auto;
}

/* Language label */
pre:has(code)::before {
  content: attr(data-language);
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 1;
}

/* Copy button - positioned on the right */
.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: white;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-family: system-ui, -apple-system, sans-serif;
  z-index: 2;
  height: 28px; /* Fixed height for perfect alignment */
  box-sizing: border-box;
}

/* Line numbers toggle - positioned with proper spacing from copy button */
.line-numbers-toggle {
  position: absolute;
  top: 12px;
  right: 80px; 
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: white;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 2;
  height: 28px; /* Match copy button height */
  width: 28px; /* Fixed width for square button */
  box-sizing: border-box;
}

/* Line numbers container */
pre:has(code).line-numbers {
  display: flex;
  padding-left: 0;
}

.line-numbers {
  padding: 0.25rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
  user-select: none;
  min-height: 100%;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  font-size: 0.875em;
}

.line-number {
  padding: 0 0.5rem;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.5;
  height: 1.5em; /* Fixed height to match code lines */
}

/* Adjust code block when line numbers are present */
pre:has(code).line-numbers code {
  padding-left: 1rem;
  flex: 1;
  overflow-x: auto;
}

/* Button hover states */
.copy-button:hover,
.line-numbers-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.line-numbers-toggle.active {
  background: rgba(33, 150, 243, 0.2);
  border-color: rgba(33, 150, 243, 0.5);
  color: #2196F3;
}

.copy-button .material-icons,
.line-numbers-toggle .material-icons {
  font-size: 16px;
}

/* Success state for copy button */
.copy-button.copied {
  background: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.5);
  color: #4CAF50;
}

.copy-button.copied .material-icons {
  color: #4CAF50;
  opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .line-numbers-toggle {
    right: 42px; /* Consistent spacing on mobile too */
  }
  
  .copy-button,
  .line-numbers-toggle {
    height: 26px; /* Slightly smaller on mobile */
    width: 26px;
  }
  
  .copy-button {
    right: 8px;
  }
  
  .copy-button .material-icons,
  .line-numbers-toggle .material-icons {
    font-size: 15px; /* Slightly smaller icons */
  }
}

/* Adjust for very small screens */
@media (max-width: 480px) {
  pre:has(code) {
    padding-top: 2.5rem;
  }
  
  pre:has(code)::before {
    top: 8px;
    left: 8px;
    font-size: 10px;
  }
  
  .copy-button,
  .line-numbers-toggle {
    top: 6px;
    height: 24px;
    width: 24px;
  }
  
  .line-numbers-toggle {
    right: 38px; /* Adjust spacing for smaller buttons */
  }
  
  .copy-button .material-icons,
  .line-numbers-toggle .material-icons {
    font-size: 14px;
  }
}