li:not(:last-of-type) {
    margin-block-end: 0.5em;
}

:is(ul, ol)+ :is(ul, ol),
li :is(ul, ol) {
    margin-block-start: 0.5em;
}

/* Reduces the top margin of an H2 that directly follows an H1 */
h1 + h2 {
    margin-top: -2.0rem;
}

/* Version Switcher Styles */
.version-selector-container {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
}

.version-selector {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--theme-popup-border);
    background-color: var(--theme-popup-bg);
    color: var(--fg);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    max-width: 180px;
}

.version-selector:hover {
    border-color: var(--theme-hover);
    background-color: var(--theme-hover);
}

.version-selector:focus {
    outline: 2px solid var(--links);
    outline-offset: 2px;
}

/* Version Badge */
.version-badge {
    display: inline-block;
    margin-left: 0.75rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    background-color: var(--theme-popup-bg);
    border: 1px solid var(--theme-popup-border);
    vertical-align: middle;
}

.version-badge-snapshot {
    background-color: #fbbf24;
    color: #78350f;
    border-color: #f59e0b;
}

.version-badge-stable {
    background-color: #22c55e;
    color: #14532d;
    border-color: #16a34a;
}

/* Outdated Version Warning Banner */
.version-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.version-warning-content {
    color: #78350f;
}

.version-warning-content strong {
    color: #92400e;
}

.version-warning-content p {
    margin: 0.5rem 0 0 0;
    line-height: 1.6;
}

.version-warning-content a {
    color: #c2410c;
    text-decoration: underline;
    font-weight: 600;
}

.version-warning-content a:hover {
    color: #9a3412;
}

/* Responsive adjustments */
@media screen and (max-width: 1080px) {
    .version-selector-container {
        margin-left: 5px;
    }

    .version-selector {
        max-width: 120px;
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .version-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
        margin-left: 0.5rem;
    }
}

@media screen and (max-width: 768px) {
    .version-selector-container {
        display: none; /* Hide on very small screens to save space */
    }

    .version-badge {
        display: none;
    }

    .version-warning {
        padding: 0.75rem 1rem;
        margin: 1rem 0;
    }
}

/* Navigation Sidebar Link */
.nav-show-sidebar {
    color: var(--links);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
}

.nav-show-sidebar:hover {
    color: var(--links-hover);
    text-decoration: underline;
}

.nav-show-sidebar-separator {
    color: var(--fg);
    opacity: 0.5;
}

/* ===== Heading Colors by Theme ===== */

/* Latte (light theme) - uses darker, more saturated colors */
html.latte h1, html.latte .content h1 { color: #1e66f5 !important; } /* Blue */
html.latte h2, html.latte .content h2 { color: #8839ef !important; } /* Mauve */
html.latte h3, html.latte .content h3 { color: #179299 !important; } /* Teal */
html.latte h4, html.latte .content h4 { color: #df8e1d !important; } /* Yellow */
html.latte h5, html.latte .content h5 { color: #40a02b !important; } /* Green */
html.latte h6, html.latte .content h6 { color: #e64553 !important; } /* Maroon */

/* Frappe (dark theme) */
html.frappe h1, html.frappe .content h1 { color: #8caaee !important; } /* Blue */
html.frappe h2, html.frappe .content h2 { color: #ca9ee6 !important; } /* Mauve */
html.frappe h3, html.frappe .content h3 { color: #81c8be !important; } /* Teal */
html.frappe h4, html.frappe .content h4 { color: #e5c890 !important; } /* Yellow */
html.frappe h5, html.frappe .content h5 { color: #a6d189 !important; } /* Green */
html.frappe h6, html.frappe .content h6 { color: #ea999c !important; } /* Maroon */

/* Macchiato (dark theme) */
html.macchiato h1, html.macchiato .content h1 { color: #8aadf4 !important; } /* Blue */
html.macchiato h2, html.macchiato .content h2 { color: #c6a0f6 !important; } /* Mauve */
html.macchiato h3, html.macchiato .content h3 { color: #8bd5ca !important; } /* Teal */
html.macchiato h4, html.macchiato .content h4 { color: #eed49f !important; } /* Yellow */
html.macchiato h5, html.macchiato .content h5 { color: #a6da95 !important; } /* Green */
html.macchiato h6, html.macchiato .content h6 { color: #ee99a0 !important; } /* Maroon */

/* Mocha (dark theme) */
html.mocha h1, html.mocha .content h1 { color: #89b4fa !important; } /* Blue */
html.mocha h2, html.mocha .content h2 { color: #cba6f7 !important; } /* Mauve */
html.mocha h3, html.mocha .content h3 { color: #94e2d5 !important; } /* Teal */
html.mocha h4, html.mocha .content h4 { color: #f9e2af !important; } /* Yellow */
html.mocha h5, html.mocha .content h5 { color: #a6e3a1 !important; } /* Green */
html.mocha h6, html.mocha .content h6 { color: #eba0ac !important; } /* Maroon */

/* Ensure heading links inherit their heading color */
html.latte :is(h1, h2, h3, h4, h5, h6) > a,
html.frappe :is(h1, h2, h3, h4, h5, h6) > a,
html.macchiato :is(h1, h2, h3, h4, h5, h6) > a,
html.mocha :is(h1, h2, h3, h4, h5, h6) > a {
    color: inherit !important;
}