* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --brand-orange: #f5942e;
    --bg-dark: #262525;
    --bg-darker: #0a0a0a;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e5e5e5;
    --sidebar-width: 280px;
    --header-height: 65px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Nunito', Roboto, sans-serif;
    background: #f5f5f5;
    color: var(--text-primary);
    line-height: 1.65;
    transition: margin-left 0.3s ease;
}

body.dark {
    background: #1a1a1a;
    color: #e5e5e5;
    --text-primary: #e5e5e5;
    --text-secondary: #999;
    --border-color: #333;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: #f8f8f8;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    z-index: 1000;
    transition: all 0.3s ease;
}

body.dark .header {
    background: var(--bg-darker);
    border-bottom-color: #333;
}

body.sidebar-collapsed .header {
    left: 0;
}

.search-container {
    max-width: 250px;
    width: 100%;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

body.dark .search-input {
    background: #2a2a2a;
    border-color: #404040;
    color: #e5e5e5;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand-orange);
}

.search-input::placeholder {
    color: #999;
}

.quick-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 2001;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

body.dark .quick-search-results {
    background: #2a2a2a;
    border-color: #404040;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.quick-search-loading,
.quick-search-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.quick-search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

body.dark .quick-search-item {
    border-bottom-color: #404040;
}

.quick-search-item:last-of-type {
    border-bottom: none;
}

.quick-search-item:hover {
    background: rgba(245, 148, 46, 0.1);
    color: var(--brand-orange);
}

.quick-search-item mark {
    background: var(--brand-orange);
    color: #fff;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 600;
}

.quick-search-footer {
    padding: 0.5rem 1rem;
    background: #f9f9f9;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

body.dark .quick-search-footer {
    background: #333;
    border-top-color: #404040;
}

.header-controls {
    position: absolute;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    padding: 0.5rem 0.7rem;
    background: #f5f5f5;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
}

body.dark .control-btn {
    background: #2a2a2a;
    border-color: #404040;
    color: #e5e5e5;
}

.control-btn:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

body.dark .control-btn:hover {
    background: #333;
    border-color: #555;
}

.search-btn, .menu-btn {
    display: none;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-dark);
    color: #fff;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1001;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.logo {
    padding: 2rem;
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    height: var(--header-height);
}

.logo-g {
    color: var(--brand-orange);
}

.logo-text {
    color: #fff;
}

.nav-items {
    padding: 1rem 0;
}

.nav-item {
    padding: 0.8rem 2rem 0.8rem 2.5rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
    font-size: 0.95rem;
    position: relative;
    white-space: nowrap;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--brand-orange);
    border-radius: 2px;
    transition: height 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active::before {
    height: 20px;
}

.sidebar-toggle {
    position: fixed;
    bottom: 2rem;
    left: calc(var(--sidebar-width) - 36px - 1.5rem);
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s;
    z-index: 1002;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

body.sidebar-collapsed .sidebar-toggle {
    position: fixed;
    left: 1rem;
    bottom: 2rem;
    background: var(--bg-dark);
    border-color: #404040;
}

body.sidebar-collapsed .sidebar-toggle:hover {
    background: #333;
}

/* Main content */
.main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 3rem 0;
    min-height: calc(100vh - var(--header-height));
    transition: all 0.3s ease;
}

body.sidebar-collapsed .main {
    margin-left: 0;
}

.section {
    display: none;
}

.section.active {
    display: block;
    max-width: 850px;
    margin: 0 auto;
    padding: 0 2%;
    width: 100%;
}

.content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    scroll-margin-top: calc(var(--header-height) + 2rem);
}

.content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.content p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.content ul, .content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

body.dark .content code {
    background: #2a2a2a;
}

.content pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

body.dark .content pre {
    background: #2a2a2a;
}

.content pre code {
    background: transparent;
    padding: 0;
}

.content blockquote {
    border-left: 3px solid var(--brand-orange);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.content th, .content td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.content th {
    background: #f5f5f5;
    font-weight: 600;
}

body.dark .content th {
    background: #2a2a2a;
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1rem 0;
    display: block;
}

/* TOC Desktop */
.toc-desktop {
    position: fixed;
    right: 2rem;
    top: calc(var(--header-height) + 2rem);
    width: 200px;
    max-height: calc(100vh - var(--header-height) - 4rem);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.toc-item {
    padding: 0.5rem 0 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-left: 2px solid var(--border-color);
    transition: all 0.2s;
    margin-bottom: 0.3rem;
}

.toc-item:hover {
    color: var(--brand-orange);
    border-left-color: var(--brand-orange);
}

.toc-item.active {
    color: var(--brand-orange);
    border-left-color: var(--brand-orange);
    font-weight: 600;
}

/* TOC Mobile */
.toc-mobile {
    display: none;
    position: sticky;
    top: calc(var(--header-height) + 1rem);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0 0 2rem;
    z-index: 100;
    transition: all 0.2s;
}

@media (max-width: 1400px) {
    .toc-mobile {
        display: block;
    }
}

body.dark .toc-mobile {
    background: #2a2a2a;
    border-color: #404040;
}

.toc-mobile-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 1.2rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 0;
}

.toc-mobile.expanded .toc-mobile-breadcrumb {
    border-bottom-color: var(--border-color);
    border-radius: 8px 8px 0 0;
}

body.dark .toc-mobile.expanded .toc-mobile-breadcrumb {
    border-bottom-color: #404040;
}

.toc-mobile-breadcrumb:hover {
    background: rgba(0,0,0,0.02);
}

body.dark .toc-mobile-breadcrumb:hover {
    background: rgba(255,255,255,0.05);
}

.breadcrumb-section {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.breadcrumb-separator {
    color: var(--text-light);
    margin: 0 0.2rem;
    flex-shrink: 0;
}

.breadcrumb-current {
    color: var(--brand-orange);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.breadcrumb-icon {
    color: var(--text-light);
    font-size: 0.7rem;
    margin-left: auto;
    transition: transform 0.2s;
}

.toc-mobile.expanded .breadcrumb-icon {
    transform: rotate(180deg);
}

.toc-mobile-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

body.dark .toc-mobile-content {
    background: #2a2a2a;
    border-color: #404040;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toc-mobile.expanded .toc-mobile-content {
    max-height: 500px;
}

.toc-mobile-items {
    padding: 0.5rem;
}

.toc-mobile-item {
    padding: 0.2rem 1rem;
    margin-bottom: 0.2rem;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: var(--text-primary);
    border-left: 3px solid transparent;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-mobile-item:hover {
    background: rgba(245, 148, 46, 0.1);
    border-left-color: var(--brand-orange);
    color: var(--brand-orange);
}

.toc-mobile-item.active {
    background: rgba(245, 148, 46, 0.15);
    border-left-color: var(--brand-orange);
    color: var(--brand-orange);
    font-weight: 600;
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.search-modal.active {
    display: flex;
}

.search-modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 700px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

body.dark .search-modal-content {
    background: #2a2a2a;
}

.search-modal-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: #f5f5f5;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

body.dark .search-modal-input {
    background: #333;
    border-color: #404040;
    color: #e5e5e5;
}

.search-modal-input:focus {
    outline: none;
    border-color: var(--brand-orange);
}

.search-results {
    overflow-y: auto;
    max-height: calc(70vh - 120px);
}

.search-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.search-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.search-results-header {
    padding: 0.5rem 0 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.search-result-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

body.dark .search-result-item {
    background: #333;
}

.search-result-item:hover {
    background: #f0f0f0;
    border-left-color: var(--brand-orange);
    transform: translateX(4px);
}

body.dark .search-result-item:hover {
    background: #3a3a3a;
}

.search-result-section {
    font-size: 0.85rem;
    color: var(--brand-orange);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.search-result-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.search-result-text mark {
    background: var(--brand-orange);
    color: #fff;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 600;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar,
.toc-desktop::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

.toc-desktop::-webkit-scrollbar-track {
    background: transparent;
}

.toc-desktop::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

body.dark .toc-desktop::-webkit-scrollbar-thumb {
    background: #444;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1600px) {
    .section.active {
        max-width: 750px;
        padding: 0 5%;
    }
}

@media (max-width: 1400px) {
    .toc-desktop {
        display: none;
    }

    .section.active {
        max-width: 700px;
        padding: 0 6%;
    }

    body.sidebar-collapsed .section.active {
        max-width: 800px;
    }
}

@media (max-width: 1024px) {
    .header {
        left: 0;
    }

    .main {
        margin-left: 0;
        padding: 2rem 0;
    }

    .section.active {
        max-width: 90%;
        padding: 0 5%;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: none;
    }

    .menu-btn {
        display: flex;
    }

    body.sidebar-collapsed .section.active {
        max-width: 90%;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
        --header-height: 60px;
    }

    .header {
        padding: 0 1rem;
    }

    .header-controls {
        right: 1rem;
    }

    .search-container {
        display: none;
    }

    .search-btn {
        display: flex;
    }

    .control-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        min-width: 32px;
    }

    .header-controls {
        gap: 0.4rem;
    }

    .main {
        padding: 1.5rem 0;
    }

    .section.active {
        max-width: 100%;
        padding: 0 1rem;
    }

    .toc-mobile {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    body.sidebar-collapsed .section.active {
        max-width: 100%;
        padding: 0 1rem;
    }

    .content h1 {
        font-size: 1.8rem;
    }

    .content h2 {
        font-size: 1.2rem;
    }

    .logo {
        padding: 1.5rem;
    }

    .toc-mobile-breadcrumb {
        font-size: 0.85rem;
        padding: 0.2rem 1rem;
        gap: 0.4rem;
    }

    .breadcrumb-section {
        font-size: 0.8rem;
    }

    .breadcrumb-separator {
        margin: 0 0.15rem;
    }

    .toc-mobile-item {
        font-size: 0.85rem;
        padding: 0.2rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem 0;
    }

    .section.active {
        max-width: 100%;
        padding: 0 1rem;
    }

    .toc-mobile {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    body.sidebar-collapsed .section.active {
        max-width: 100%;
        padding: 0 1rem;
    }

    .toc-mobile-breadcrumb {
        font-size: 0.8rem;
        padding: 0.2rem 0.8rem;
        gap: 0.3rem;
    }

    .breadcrumb-section {
        font-size: 0.75rem;
    }

    .breadcrumb-separator {
        margin: 0 0.1rem;
        font-size: 0.75rem;
    }

    .breadcrumb-icon {
        font-size: 0.65rem;
    }

    .toc-mobile-item {
        font-size: 0.8rem;
        padding: 0.2rem 0.7rem;
    }
}
/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.image-modal-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    transition: all 0.2s;
}

.image-modal-close:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.content img {
    cursor: zoom-in;
    transition: opacity 0.2s;
}

.content img:hover {
    opacity: 0.9;
}

@media (max-width: 480px) {
    .image-modal-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}