:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-hint: #a0aec0;
    --accent-color: #4a1d96;
    --accent-light: #5c7cfa;
    --accent-dark: #364fc7;
    --border-color: #dee2e6;
    --code-bg: #f8f9fa;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    --sidebar-bg: #4a1d96;
    --sidebar-text: #f1f5f9;
    --sidebar-hover: rgba(255, 255, 255, 0.15);
    --sidebar-active: rgba(255, 255, 255, 0.25);
    --sidebar-border: rgba(255, 255, 255, 0.2);
    
    --sidebar-width: 280px;
    --header-height: 64px;
    --card-border-radius: 8px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'Fira Code', SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    --content-width: 1200px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--accent-light);
}

ul {
    list-style: none;
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    color: var(--sidebar-text);
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.logo {
    margin-bottom: 2rem;
    text-align: center;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
    transition: transform 0.3s ease;
}

.logo h1 a {
    color: inherit;
    text-decoration: none;
}

.logo h1:hover {
    transform: scale(1.05);
}

.search-box {
    display: flex;
    margin-bottom: 1.5rem;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-box input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.search-box button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: color 0.2s ease;
}

.search-box button:hover {
    color: white;
}

.nav-menu {
    margin-bottom: 1.5rem;
    width: 100%;
    overflow-x: hidden;
}

.nav-item {
    margin-bottom: 0.5rem;
    position: relative;
    list-style: none;
    transition: all 0.2s ease;
}

.nav-item > .section-toggle {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    padding: 0.7rem 0.8rem;
    border-radius: 6px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    text-overflow: ellipsis;
    box-sizing: border-box;
    max-width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    pointer-events: auto;
    z-index: 1;
}

.section-toggle * {
    pointer-events: none;
}

.section-toggle:hover {
    color: white;
    background-color: var(--sidebar-hover);
    transform: translateX(3px);
}

.nav-item.active > .section-toggle {
    color: white;
    font-weight: 600;
    background-color: var(--sidebar-active);
    border-left: 3px solid rgba(255, 255, 255, 0.8);
    padding-left: 0.6rem;
}

.has-pages > .section-toggle::before {
    content: "📁";
    margin-right: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

.submenu {
    margin-left: 1.2rem;
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    display: none;
    border-left: 2px solid var(--sidebar-border);
    position: relative;
    padding-left: 0.8rem;
    width: calc(100% - 2rem);
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 100%;
    box-sizing: border-box;
    margin-right: 0;
    padding-right: 0;
}

.open > .submenu {
    display: block;
    opacity: 1;
    animation: fadeInDown 0.3s ease forwards;
}

.nav-item:hover > .section-toggle {
    background-color: rgba(255, 255, 255, 0.05);
}
        
.nav-item a {
    display: flex;
    align-items: center;
    padding: 0.7rem 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border-radius: 6px;
    line-height: 1.2;
    text-decoration: none;
    text-overflow: ellipsis;
    box-sizing: border-box;
    max-width: 100%;
}

.nav-item a:hover {
    color: white;
    background-color: var(--sidebar-hover);
    transform: translateX(3px);
}

.nav-item.active > a {
    color: white;
    font-weight: 600;
    background-color: var(--sidebar-active);
    border-left: 3px solid rgba(255, 255, 255, 0.8);
    padding-left: 0.6rem;
}

.has-submenu > a::after {
    display: none;
}

.submenu .section-toggle {
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
}

.submenu .section-toggle::before {
    font-size: 0.8rem;
}

.section-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu .submenu .nav-item {
    position: relative;
    padding-left: 0.5rem;
}

.nav-menu .submenu .nav-item::before {
    content: "";
    position: absolute;
    left: -0.5rem;
    top: 50%;
    width: 8px;
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%);
}

.nav-menu .submenu .nav-item a {
    position: relative;
    padding-left: 1rem;
}

.section-menu .nav-item {
    position: relative;
}

.section-menu .nav-item.has-submenu > .section-toggle::after {
    content: "▶";
    position: absolute;
    right: 0.8rem;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.6);
}

.section-menu .nav-item.open > .section-toggle::after {
    transform: rotate(90deg);
}

.section-menu .submenu {
    margin-left: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.section-menu .submenu .submenu {
    margin-left: 1.2rem;
    padding-left: 0.8rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.section-menu .submenu .submenu .submenu {
    margin-left: 1rem;
    padding-left: 0.6rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.page-menu-container {
    margin-left: 0.5rem;
    padding-left: 0.8rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 0.3rem;
}

.page-menu-container .page-item {
    margin-bottom: 0.1rem;
}

.page-menu-container .page-item a {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    color: rgba(255, 255, 255, 0.7);
    position: relative;
}

.page-menu-container .page-item a::before {
    content: "📄";
    margin-right: 0.5rem;
    font-size: 0.7rem;
    opacity: 0.6;
}

.nav-menu .page-item,
.submenu .page-item:not(.page-menu-container .page-item) {
    padding-left: 0;
    margin-bottom: 0.15rem;
}

.nav-menu .page-item a,
.submenu .page-item:not(.page-menu-container .page-item) a {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    color: rgba(255, 255, 255, 0.75);
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    text-overflow: ellipsis;
    box-sizing: border-box;
    max-width: 100%;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav-menu .page-item a:hover,
.submenu .page-item:not(.page-menu-container .page-item) a:hover,
.page-menu-container .page-item a:hover {
    color: white;
    background-color: var(--sidebar-hover);
    transform: translateX(3px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-menu .page-item.active a,
.submenu .page-item.active:not(.page-menu-container .page-item) a,
.page-menu-container .page-item.active a {
    color: white;
    font-weight: 600;
    background-color: var(--sidebar-active);
    border-left: 3px solid rgba(255, 255, 255, 0.8);
    padding-left: 0.6rem;
}

.page-icon {
    margin-right: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.7;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: var(--header-height) 0 0 0;
    display: flex;
    flex-direction: column;
}

header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 5;
}

.breadcrumbs {
    display: flex;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    gap: 0.25em;
    font-size: 0.9em;
    color: var(--text-secondary);
    max-width: calc(100% - 150px);
    transition: all 0.2s ease;
}

.breadcrumbs a, 
.breadcrumbs span {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    max-width: 180px;
    color: inherit;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--accent-color);
}

.breadcrumbs a::after {
    content: '/';
    margin: 0 0.5em;
    color: var(--text-hint);
}

.breadcrumbs a.prev-crumb,
.breadcrumbs span.current-crumb {
    transition: all 0.2s ease;
}

.breadcrumbs span.current-crumb {
    font-weight: 600;
    color: var(--text-primary);
}

.breadcrumbs span:last-child::after,
.breadcrumbs a:last-child::after {
    display: none;
}

.breadcrumbs.mobile-view a,
.breadcrumbs.mobile-view span:not(.current-crumb) {
    display: none;
}

.breadcrumbs.mobile-view span.current-crumb {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 0;
    font-weight: 600;
}

@media screen and (max-width: 768px) {
    .breadcrumbs {
        max-width: calc(100% - 100px);
    }

    .breadcrumbs.mobile-view span.current-crumb {
        max-width: 180px;
    }
}

@media screen and (max-width: 480px) {
    .breadcrumbs {
        max-width: calc(100% - 80px);
    }
    
    .breadcrumbs.mobile-view span.current-crumb {
        max-width: 150px;
    }
}

@media screen and (max-width: 360px) {
    .breadcrumbs.mobile-view span.current-crumb {
        max-width: 120px;
    }
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--bg-tertiary);
}

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

main {
    flex: 1;
    padding: 2rem;
    max-width: var(--content-width);
    margin: 0 auto;
    width: 100%;
}

main h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

main h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

main h3 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
}

main p {
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.intro {
    max-width: 800px;
    margin-bottom: 3rem;
}

.intro p {
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background-color: var(--bg-primary);
    border-radius: var(--card-border-radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--shadow-color);
}

.project-card {
    position: relative;
    border-top: 4px solid;
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.25rem;
    margin: 0 0 0.75rem 0;
    font-weight: 600;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    text-align: center;
    transition: all 0.2s ease;
    color: #fff;
    background-color: var(--accent-color);
    border: none;
    cursor: pointer;
}

.btn:hover {
    background-color: var(--accent-dark);
    color: #fff;
    transform: translateY(-1px);
}

.btn.small {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.dark-theme {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #828282;
    --text-hint: #666666;
    --border-color: #333333;
    --code-bg: #2b2b2b;
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    --sidebar-bg: #2d1b4d;
    --sidebar-text: #e0e0e0;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
}

@media screen and (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}

@media screen and (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        padding: 1rem;
        max-height: 80vh;
    }
    
    .sidebar-open .sidebar {
        transform: translateY(0);
    }
    
    .content {
        margin-left: 0;
        padding-top: calc(var(--header-height) + 1rem);
    }
    
    header {
        left: 0;
        padding: 0 1rem;
    }
    
    main {
        padding: 1.5rem 1rem;
    }
    
    .project-grid,
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .logo {
        margin-bottom: 1rem;
    }
    
    .search-box {
        margin-bottom: 1rem;
    }
    
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
        background: transparent;
    border: none;
        cursor: pointer;
        padding: 0;
        z-index: 20;
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;
        background-color: var(--text-primary);
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle span:nth-child(1) {
        transform-origin: top left;
    }
    
    .mobile-menu-toggle span:nth-child(2) {
        opacity: 1;
    }
    
    .mobile-menu-toggle span:nth-child(3) {
        transform-origin: bottom left;
    }
    
    .sidebar-open .mobile-menu-toggle span:nth-child(1) {
        transform: rotate(45deg);
        width: 120%;
    }
    
    .sidebar-open .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }
    
    .sidebar-open .mobile-menu-toggle span:nth-child(3) {
        transform: rotate(-45deg);
        width: 120%;
    }
    
    .sidebar-open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 5;
    }
}

@media screen and (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { 
        opacity: 0;
        transform: translateY(-10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-link a.btn.small {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
}

.admin-link a.btn.small:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.35rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

pre:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: var(--bg-secondary);
    color: var(--accent-color);
}

footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

.empty-content {
    padding: 2rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--card-border-radius);
    text-align: center;
    color: var(--text-secondary);
    margin-top: 2rem;
}

.project-menu {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--sidebar-border);
    flex: 1;
    overflow-y: auto;
    width: 100%;
    overflow-x: hidden;
}

.project-menu h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-left: 0.8rem;
    color: white;
    font-weight: 500;
    text-align: center;
}

.section-menu {
    list-style: none;
    padding-left: 0;
    width: 100%;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.page-menu-container {
    display: none;
}

.sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

.nav-menu ul,
.section-menu {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.submenu {
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
    margin-right: 0;
    padding-right: 0;
}

.section-toggle, 
.nav-item a,
.page-item a {
    text-overflow: ellipsis;
    box-sizing: border-box;
    max-width: 100%;
}

#search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    overflow-y: auto;
    backdrop-filter: blur(3px);
}

#search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-modal {
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    background-color: var(--bg-primary);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    animation: fadeInDown 0.3s ease-out;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

.search-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent-color);
}

.search-query {
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: white;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
}

.search-status {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.search-results {
    padding: 0 20px 20px;
    overflow-y: auto;
    flex: 1;
}

.search-project {
    margin-top: 20px;
}

.search-project h3 {
    margin: 0 0 15px;
    font-size: 1.1rem;
    color: var(--accent-color);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-result-item {
    margin-bottom: 16px;
}

.search-result-item a {
    display: block;
    padding: 16px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.25s ease;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.search-result-item a:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
}

.search-result-item h4 {
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--accent-color);
}

.search-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.search-excerpt {
    margin: 8px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.search-no-results {
    padding: 30px 0;
    text-align: center;
    color: var(--text-muted);
}

.search-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    #search-overlay {
        padding-top: 2vh;
    }
    
    .search-modal {
        width: 95%;
        max-height: 96vh;
    }
}

.dark-theme #search-overlay {
    background-color: rgba(0, 0, 0, 0.92);
}

.dark-theme .search-modal {
    background-color: var(--bg-primary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    border-color: #333333;
}

.dark-theme .search-header,
.dark-theme .search-status,
.dark-theme .search-results {
    background-color: var(--bg-primary);
}

.dark-theme .search-project {
    background-color: var(--bg-primary);
}

.dark-theme .search-result-item a {
    background-color: var(--bg-secondary);
    border-color: #333333;
}

.dark-theme .search-project h3 {
    border-color: #333333;
}

.search-modal {
    border: 1px solid var(--border-color);
}

@media screen and (max-width: 480px) {
    :root {
        --sidebar-width: 100%;
    }

    main h1 {
        font-size: 1.8rem;
    }
    
    main h2 {
        font-size: 1.4rem;
    }
    
    main h3 {
        font-size: 1.2rem;
    }
    
    .breadcrumbs {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
    
    .sidebar {
        max-height: 85vh;
        padding: 0.8rem;
    }
    
    .logo h1 {
        font-size: 1.4rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .card-icon {
        font-size: 2rem;
    }
    
    .card h2 {
        font-size: 1.3rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    #search-overlay {
        padding-top: 0;
    }
    
    .search-modal {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }
    
    .search-header h2 {
        font-size: 1.1rem;
    }
    
    .search-result-item a {
        padding: 10px 12px;
    }
    
    .search-result-item h4 {
        font-size: 0.95rem;
    }
    
    .search-excerpt {
        font-size: 0.85rem;
    }
}

@media screen and (max-width: 360px) {
    header {
        padding: 0 0.5rem;
    }
    
    .mobile-menu-toggle {
        width: 20px;
        height: 16px;
    }
    
    main {
        padding: 1rem 0.5rem;
    }
    
    .breadcrumbs {
        max-width: 150px;
    }
    
    .theme-toggle {
        width: 28px;
        height: 28px;
    }
    
    .search-header {
        padding: 12px 16px;
    }
    
    .search-query, 
    .search-status {
        padding: 10px 16px;
    }
    
    .search-results {
        padding: 0 16px 16px;
    }
}

@media screen and (max-width: 768px) {
    .sidebar {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-menu {
        margin-bottom: 0.8rem;
    }
    
    .nav-item > .section-toggle {
        padding: 0.6rem 0.7rem;
        font-size: 0.9rem;
    }
    
    .submenu {
        margin-left: 0.5rem;
    }
    
    .nav-item a, 
    .section-toggle, 
    .page-item a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .sidebar-open::before {
        backdrop-filter: blur(2px);
    }
}

.touch-device .nav-item a,
.touch-device .section-toggle,
.touch-device .btn,
.touch-device .card,
.touch-device .theme-toggle {
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.15s;
}

.touch-device .touch-active {
    opacity: 0.7;
    transform: scale(0.98);
}

.touch-device .theme-toggle {
    min-width: 44px;
    min-height: 44px;
}

.touch-device .search-box button {
    width: 44px;
    height: 44px;
        right: 0;
}

.touch-device .close-search {
    min-width: 44px;
    min-height: 44px;
}

* {
    -webkit-tap-highlight-color: transparent;
}

.touch-device .sidebar {
    -webkit-overflow-scrolling: touch;
}

.touch-device .search-modal {
    -webkit-overflow-scrolling: touch;
}

.touch-device a, 
.touch-device button, 
.touch-device .nav-item, 
.touch-device .section-toggle {
    touch-action: manipulation;
}

.more-indicator {
    padding: 6px 8px;
    color: var(--text-secondary);
    font-size: 0.85em;
    border-radius: 4px;
    background-color: rgba(74, 29, 150, 0.1);
    margin: 4px 0;
    cursor: pointer;
    text-align: center;
}

.more-indicator:hover {
    background-color: rgba(74, 29, 150, 0.2);
}

.more-text {
    font-style: italic;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(74, 29, 150, 0.4);
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 29, 150, 0.6);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(74, 29, 150, 0.4) rgba(0, 0, 0, 0.05);
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(74, 29, 150, 0.3);
}

.dark-theme .search-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.dark-theme .search-results::-webkit-scrollbar-thumb {
    background: rgba(107, 70, 193, 0.4);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dark-theme::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.dark-theme::-webkit-scrollbar-thumb {
    background: rgba(107, 70, 193, 0.5);
}

.dark-theme::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 70, 193, 0.7);
}

.dark-theme {
    scrollbar-color: rgba(107, 70, 193, 0.5) rgba(255, 255, 255, 0.05);
}

.search-modal {
    border: 1px solid var(--border-color);
}

.search-result-item a {
    display: block;
    padding: 16px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.25s ease;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.search-result-item a:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
}

.close-search {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-search:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.dark-theme .close-search:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.search-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-error {
    color: #e53935;
}

.page-views {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    gap: 0.5em;
}

.page-views span {
    display: flex;
    align-items: center;
}

.page-views span::before {
    content: '👁️';
    margin-right: 0.5em;
}

.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.page-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.projects-tree {
    max-width: 100%;
}

.project-tree-item {
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--card-border-radius);
    background: var(--bg-secondary);
    overflow: hidden;
    transition: all 0.3s ease;
}

.project-tree-item:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
    transform: translateY(-2px);
}

.project-header {
    padding: 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.project-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.project-icon {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-title {
    flex: 1;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.project-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.project-title a:hover {
    color: var(--accent-color);
}

.expand-project-btn {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    pointer-events: auto;
    z-index: 2;
    position: relative;
}

.expand-project-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
}

.expand-project-btn.expanded .expand-icon {
    transform: rotate(90deg);
}

.expand-project-btn .expand-icon {
    pointer-events: none;
    user-select: none;
}

.project-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.project-tree-content {
    padding: 0;
    background: var(--bg-secondary);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

.project-structure {
    padding: 1.5rem;
}

.project-structure h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.section-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-tree.level-0 {
    border-left: 2px solid var(--accent-color);
    padding-left: 0;
}

.section-tree.level-1,
.section-tree.level-2,
.section-tree.level-3 {
    border-left: 1px solid var(--border-color);
    margin-left: 1rem;
    padding-left: 0;
}

.section-item {
    position: relative;
    margin-bottom: 0.25rem;
}

.section-item.has-children > .section-header {
    cursor: pointer;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.section-header::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.2s ease;
}

.section-header:hover {
    background: var(--bg-tertiary);
}

.section-header:hover::before {
    background: var(--accent-color);
}

.section-header .expand-icon {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
    min-width: 1.2rem;
    text-align: center;
}

.section-item.expanded > .section-header .expand-icon {
    transform: rotate(90deg);
}

.section-header a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    flex: 1;
}

.section-header a:hover {
    color: var(--accent-color);
}

.section-content {
    margin-left: 1.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-color);
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.section-item.expanded > .section-content {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}

.page-item {
    margin-bottom: 0.25rem;
}

.page-item .expand-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 1.2rem;
    text-align: center;
}

.page-item a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.page-item a:hover {
    background: var(--bg-tertiary);
    color: var(--accent-color);
    padding-left: 0.75rem;
}

@media (max-width: 768px) {
    .project-header {
        padding: 1rem;
    }
    
    .project-info {
        gap: 0.75rem;
    }
    
    .project-icon {
        font-size: 1.5rem;
    }
    
    .project-title {
        font-size: 1.25rem;
    }
    
    .project-structure {
        padding: 1rem;
    }
    
    .section-tree.level-1,
    .section-tree.level-2,
    .section-tree.level-3 {
        margin-left: 0.75rem;
    }
    
    .section-content {
        margin-left: 1rem;
    }
}

.dark-theme .project-tree-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-theme .project-header {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

.dark-theme .expand-project-btn {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.dark-theme .section-header:hover {
    background: var(--bg-tertiary);
}

.dark-theme .page-item a:hover {
    background: var(--bg-tertiary);
}

.dark-theme {
    --sidebar-bg: #2d1b69;
    --sidebar-text: #e2e8f0;
    --sidebar-hover: rgba(255, 255, 255, 0.12);
    --sidebar-active: rgba(255, 255, 255, 0.2);
    --sidebar-border: rgba(255, 255, 255, 0.15);
}

.dark-theme .nav-item a,
.dark-theme .section-toggle {
    color: rgba(255, 255, 255, 0.9);
}

.dark-theme .page-item a {
    color: rgba(255, 255, 255, 0.8);
}

.dark-theme .nav-item a:hover,
.dark-theme .section-toggle:hover {
    color: white;
    background-color: var(--sidebar-hover);
}

.dark-theme .page-item a:hover {
    color: white;
    background-color: var(--sidebar-hover);
}

.dark-theme .nav-item.active > a,
.dark-theme .nav-item.active > .section-toggle {
    color: white;
    background-color: var(--sidebar-active);
    border-left: 3px solid rgba(255, 255, 255, 0.9);
}

.dark-theme .page-item.active a {
    color: white;
    background-color: var(--sidebar-active);
    border-left: 3px solid rgba(255, 255, 255, 0.9);
}

.dark-theme .section-menu .submenu {
    border-left-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .section-menu .submenu .submenu {
    border-left-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .section-menu .submenu .submenu .submenu {
    border-left-color: rgba(255, 255, 255, 0.08);
}

.dark-theme .page-menu-container {
    border-left-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .nav-menu .submenu .nav-item::before {
    background: rgba(255, 255, 255, 0.2);
}