:root {
    --primary-navy: #1a237e;
    --primary-sky: #00b4d8;
    --primary-color: var(--primary-navy);
    --bg-color: #ffffff;
    --text-color: #1c1e21;
    --sidebar-bg: #f8f9fa;
    --sidebar-border: #e9ecef;
    --hover-bg: #e2e6ea;
    --code-bg: #f4f4f4;
    --header-height: 70px;
    --sidebar-width: 300px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-color: #0b0e14;
    --text-color: #e3e3e3;
    --sidebar-bg: #12141d;
    --sidebar-border: #1f222e;
    --hover-bg: #1f222e;
    --code-bg: #1f222e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

[data-theme="dark"] body {
    background-color: var(--bg-color);
}

/* Layout */
header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: space-between;
}

[data-theme="dark"] header {
    background: rgba(11, 14, 20, 0.8);
}

/* Progress Bar */
.progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-navy), var(--primary-sky));
    width: 0%;
    transition: width 0.1s;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sticker-btn {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1.2rem;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sticker-btn:hover {
    transform: translateY(-2px);
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    margin-right: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 0.9;
}

.lumi {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-navy);
    letter-spacing: -0.5px;
}

.learn {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--primary-sky);
    letter-spacing: 0.5px;
}

[data-theme="dark"] .lumi {
    color: #ffffff;
}

.main-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
aside.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: 2rem 1.5rem;
    position: fixed;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    transition: var(--transition);
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}

aside.sidebar::-webkit-scrollbar {
    width: 4px;
}

aside.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 10px;
}

.nav-item {
    list-style: none;
    margin-bottom: 4px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: var(--transition);
    cursor: pointer;
}

.nav-link:hover {
    background: var(--hover-bg);
}

.nav-link.active {
    color: var(--primary-sky);
    font-weight: 600;
    background: var(--hover-bg);
    border-left: 3px solid var(--primary-sky);
}

.nav-group-title {
    font-weight: 700;
    padding: 8px 12px;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--primary-color);
    opacity: 0.8;
    margin-top: 1rem;
}

/* Content Area */
main.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 3rem 5rem;
    max-width: 1000px;
}

/* TOC Sidebar */
.toc {
    width: 260px;
    padding: 2rem 1rem;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    border-left: 1px solid var(--sidebar-border);
    font-size: 0.9rem;
}

.toc-title {
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--primary-color);
}

#toc-nav ul {
    list-style: none;
}

#toc-nav li {
    margin-bottom: 8px;
}

#toc-nav a {
    text-decoration: none;
    color: var(--text-color);
    opacity: 0.8;
    transition: var(--transition);
    display: block;
    border-left: 2px solid transparent;
    padding-left: 10px;
}

#toc-nav a:hover {
    opacity: 1;
    color: var(--primary-color);
}

#toc-nav a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    opacity: 1;
    font-weight: 500;
}

.markdown-body h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.markdown-body p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.85rem;
    margin-bottom: 2rem;
    opacity: 0.7;
}

.breadcrumbs a {
    color: var(--text-color);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--primary-color);
}

.breadcrumbs span {
    margin: 0 8px;
}

.reading-time {
    display: inline-block;
    padding: 4px 10px;
    background: var(--hover-bg);
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Article Footer Navigation */
.article-footer {
    margin-top: 4rem;
}

.article-footer hr {
    border: 0;
    border-top: 1px solid var(--sidebar-border);
    margin-bottom: 2rem;
}

.next-prev-nav {
    display: flex;
    justify-content: space-between;
}

.nav-btn {
    padding: 12px 24px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-color);
}

.nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--hover-bg);
}

.nav-btn.hidden {
    visibility: hidden;
}

/* Code Copy Button */
.code-block-wrapper {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.code-block-wrapper:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--primary-color);
}

.markdown-body pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sidebar-border);
}

.markdown-body code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
}

/* Buttons and Controls */
.theme-toggle {
    background: none;
    border: 1px solid var(--sidebar-border);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

/* Search */
.search-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
}

#docs-search {
    width: 100%;
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    color: var(--text-color);
    outline: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

#docs-search:focus {
    border-color: var(--primary-sky);
    box-shadow: 0 0 0 2px rgba(0, 180, 216, 0.2);
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, var(--sidebar-bg) 25%, var(--hover-bg) 50%, var(--sidebar-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 1rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-title {
    height: 40px;
    width: 60%;
    margin-bottom: 2rem;
}

.skeleton-line {
    height: 20px;
    width: 100%;
}

.skeleton-line.short {
    width: 40%;
}

/* Code Block Enhancements */
.code-header {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-bottom: none;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-family: var(--font-main);
    color: var(--primary-sky);
    font-weight: 600;
}

.markdown-body pre {
    background: var(--code-bg);
    padding: 1rem;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sidebar-border);
}

/* Search Highlight */
.search-highlight {
    background: rgba(0, 180, 216, 0.2);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
    color: var(--primary-sky);
}

/* Sidebar Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--sidebar-border);
    border-radius: 4px;
    margin-top: 5px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1001;
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--sidebar-border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--hover-bg);
}

.search-result-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.search-result-context {
    font-size: 0.8rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 1024px) {
    .toc {
        display: none;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0 1rem;
    }

    .mobile-toggle-btn {
        display: block;
    }

    aside.sidebar {
        transform: translateX(-100%);
        z-index: 1001;
        width: 85%;
        max-width: 320px;
        box-shadow: none;
    }

    aside.sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    main.content {
        margin-left: 0;
        padding: 1.5rem;
        width: 100%;
    }

    .search-container {
        width: 40px;
        position: relative;
        left: unset;
        transform: none;
        transition: width 0.3s ease;
        overflow: hidden;
    }

    .search-container.expanded {
        position: absolute;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100% - 100px);
        z-index: 1002;
    }

    #docs-search {
        padding: 8px 12px;
    }

    .logo span {
        display: none;
    }

    .logo svg {
        width: 32px;
        height: 32px;
    }

    .article-footer {
        margin-top: 2rem;
    }

    .next-prev-nav {
        flex-direction: column;
        gap: 10px;
    }

    .nav-btn {
        width: 100%;
        text-align: center;
    }
}