:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --heading-color: #222222;
    --accent-color: #1e87f0;
    --sidebar-bg: #f8f9fa;
    --header-bg: #ffffff;
    --loading-overlay: #ffffff;
    --code-bg: #f5f7f9;
    --code-text: #476582;
    --inline-code-bg: #fff0f0;
    --inline-code-text: #c41a16;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #b0b0b0;
    --heading-color: #ffffff;
    --accent-color: #52a9ff;
    --sidebar-bg: #1a1a1a;
    --header-bg: #1a1a1a;
    --loading-overlay: #121212;
    --code-bg: #1e1e1e;
    --code-text: #e0e0e0;
    --inline-code-bg: #2d2d2d;
    --inline-code-text: #ffa39e;
}

h1,
h2,
h3,
h4,
h5,
h6,
.uk-h1,
.uk-h2,
.uk-h3,
.uk-h4,
.uk-h5,
.uk-h6,
.uk-logo {
    color: var(--heading-color) !important;
}

html,
body {
    background-color: var(--bg-color) !important;
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Force UIkit overrides for dark mode consistency */
.uk-navbar,
.uk-navbar-container,
.uk-container {
    background: transparent !important;
}

/* Typography Modes */
.font-s {
    font-size: 14px;
}

.font-m {
    font-size: 16px;
}

.font-l {
    font-size: 18px;
}

/* Menu Bar */
#top-nav {
    position: fixed;
    top: 0 !important;
    left: 0;
    right: 0;
    margin: 0 !important;
    z-index: 1000;
    background: var(--header-bg) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease;
    font-size: 16px !important;
}

.uk-navbar {
    min-height: 52px !important;
}

.uk-navbar-item,
.uk-navbar-nav>li>a,
.uk-navbar-toggle {
    min-height: 52px !important;
    padding: 0 10px;
}

[data-theme="dark"] #top-nav {
    background: rgba(26, 26, 26, 0.8) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] #top-nav {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.uk-logo {
    font-weight: 700;
    letter-spacing: -1.5px;
    color: var(--text-color) !important;
}

.uk-logo span {
    color: var(--accent-color);
}

#mod-version {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    opacity: 0.6;
    font-weight: 500;
    margin-left: 6px;
    letter-spacing: 0.5px;
    color: var(--text-color) !important;
    vertical-align: 1px;
}

/* Global Stats Bar */
.stats-group {
    display: flex;
    gap: 20px;
}

.stats-divider {
    width: 1px;
    height: 30px;
    background: rgba(0, 0, 0, 0.08);
    margin: 0 25px;
}

[data-theme="dark"] .stats-divider {
    background: rgba(255, 255, 255, 0.1);
}

.rings-group {
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
}

.stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    opacity: 0.85;
    text-transform: uppercase;
}

#global-stats {
    display: flex;
    align-items: center;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 800;
    color: var(--accent-color);
}

.rings-group .stat-value {
    color: var(--text-color);
    opacity: 1;
}

.rings-group .stat-item:hover .stat-value {
    color: var(--accent-color);
    opacity: 1;
}

/* Font Switcher */
.font-switcher button {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-color);
    padding: 2px 10px;
    cursor: pointer;
    border-radius: 6px;
    margin-left: 5px;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.font-switcher button.uk-active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 10px rgba(30, 135, 240, 0.3);
}

/* Download Link (Sidebar) */
.download-link a {
    color: var(--accent-color) !important;
    opacity: 0.85;
}

.download-link a:hover {
    opacity: 1;
}

/* Sidebar */

.sidebar-wrapper {
    position: fixed !important;
    top: 80px !important;
    left: 0;
    width: 20%;
    max-width: 280px;
    padding-left: 40px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    z-index: 100;
}

.content-wrapper {
    margin-left: 22% !important;
    width: 75% !important;
}

#sidebar-nav .uk-nav-default>li>a {
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9em;
    font-weight: 500;
    opacity: 0.7;
}

#sidebar-nav .uk-nav-default>li>a:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.03);
}

#sidebar-nav .uk-nav-default>li.uk-active>a {
    background-color: var(--accent-color) !important;
    color: white !important;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(30, 135, 240, 0.2);
}

.uk-nav-header {
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 2px;
    margin-top: 30px;
    margin-bottom: 10px;
    opacity: 0.5;
    color: var(--text-color) !important;
}

/* Content Area */
#content-body {
    padding-bottom: 50vh;
}

/* Content Formatting */
.doc-section {
    margin-bottom: 120px;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-section.visible {
    opacity: 1;
    transform: translateY(0);
}

pre {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow-x: auto;
    font-size: 0.88em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] pre {
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

code {
    font-family: 'JetBrains Mono', monospace;
}

p>code,
li>code {
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: 2px 6px;
    border-radius: 6px;
}

/* Technical Alerts */
.custom-alert {
    margin: 30px 0;
    padding: 16px 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.03);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    border-radius: 4px;
}

[data-theme="dark"] .custom-alert {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 0.65em;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    opacity: 0.8;
}

.alert-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    font-size: 0.7em;
    font-weight: 900;
    border-radius: 4px;
}

.alert-content {
    font-size: 0.95em;
    line-height: 1.7;
    color: var(--text-color);
}

.alert-note {
    border-left: 3px solid var(--accent-color);
}

.alert-note .alert-icon,
.alert-note .alert-title {
    color: var(--accent-color);
}

.alert-tip {
    border-left: 3px solid #28a745;
}

.alert-tip .alert-icon,
.alert-tip .alert-title {
    color: #28a745;
}

.alert-warning {
    border-left: 3px solid #f0ad4e;
}

.alert-warning .alert-icon,
.alert-warning .alert-title {
    color: #f0ad4e;
}

.alert-important {
    border-left: 3px solid #d9534f;
}

.alert-important .alert-icon,
.alert-important .alert-title {
    color: #d9534f;
}

/* Theme Reveal Animation */
#theme-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--loading-overlay);
    z-index: 9999;
    pointer-events: none;
    clip-path: circle(0% at 95% 5%);
    transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

#theme-overlay.revealing {
    clip-path: circle(150% at 95% 5%);
}

.uk-navbar-nav>li>a {
    color: var(--text-color);
}

/* ===================== */
/* Mobile Hamburger      */
/* ===================== */
.mobile-hamburger {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.mobile-hamburger:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .mobile-hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mobile Overlay Backdrop */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===================== */
/* Mobile Responsive     */
/* ===================== */
@media (max-width: 959px) {

    /* Sidebar: off-screen drawer */
    .sidebar-wrapper {
        position: fixed !important;
        top: 0 !important;
        left: -280px;
        width: 280px !important;
        max-width: 280px;
        height: 100vh;
        max-height: 100vh;
        padding: 70px 20px 30px 28px;
        background: var(--bg-color);
        z-index: 600;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        overflow-y: auto;
        border-right: 1px solid rgba(0, 0, 0, 0.08);
    }

    [data-theme="dark"] .sidebar-wrapper {
        border-right-color: rgba(255, 255, 255, 0.08);
    }

    .sidebar-wrapper.mobile-open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* Content: full width with proper padding */
    .content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 20px !important;
        box-sizing: border-box;
    }

    /* Navbar adjustments */
    .uk-navbar {
        min-height: 48px !important;
    }

    .uk-navbar-item,
    .uk-navbar-nav>li>a {
        min-height: 48px !important;
    }

    .uk-logo {
        font-size: 0.95em;
    }

    /* Mobile font sizes bumped up so smallest isn't tiny */
    .font-s {
        font-size: 15px;
    }

    .font-m {
        font-size: 17px;
    }

    .font-l {
        font-size: 19px;
    }

    /* Smaller padding on sections */
    .doc-section {
        margin-bottom: 60px;
    }

    /* Code blocks scroll horizontally */
    pre {
        font-size: 0.82em;
        padding: 1rem;
        border-radius: 8px;
    }

    /* Tables responsive */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Images scale down */
    #content-body img {
        max-width: 100%;
        height: auto;
    }

    /* Controlled padding on main container */
    .uk-container-expand {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Prevent UIkit grid from adding negative margins that clip content */
    .uk-grid-medium {
        margin-left: 0 !important;
    }

    .uk-grid-medium>* {
        padding-left: 0 !important;
    }
}

/* User Badge */
.user-badge {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 10px rgba(30, 135, 240, 0.2);
    transition: transform 0.3s ease;
    cursor: pointer;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-badge:hover {
    transform: scale(1.1);
}

.user-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Slideshow */
.custom-slideshow {
    border-radius: 12px;
    overflow: hidden;
    margin: 30px 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .custom-slideshow {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.05);
}

.custom-slideshow .uk-slideshow-items {
    border-radius: 12px;
}

.custom-slideshow .uk-slideshow-items img {
    object-fit: contain !important;
    background: #1a1a2e;
}

.uk-dotnav>*>* {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.uk-dotnav>.uk-active>* {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.2);
}

.speech-bubble {
    position: absolute;
    bottom: -50px;
    right: 0;
    background: var(--accent-color);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 1100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--accent-color);
}

.user-badge:hover .speech-bubble {
    opacity: 1;
    transform: translateY(0);
}