:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-sidebar: #f8f8f8;
    --bg-hover: #e8e8e8;
    --bg-active: #d4e8f0;
    --bg-topbar: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --accent-color: #15c1ce;
    --accent-hover: #0ea5e9;
    --tree-line: #cccccc;
    --sidebar-width: 280px;
    --topbar-height: 50px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body.dark-mode {
    --bg-primary: #1e1e2e;
    --bg-secondary: #181825;
    --bg-sidebar: #181825;
    --bg-hover: #313244;
    --bg-active: #2a3a4a;
    --bg-topbar: #1e1e2e;
    --text-primary: #cdd6f4;
    --text-secondary: #a6adc8;
    --text-muted: #6c7086;
    --border-color: #313244;
    --accent-color: #15c1ce;
    --accent-hover: #0ea5e9;
    --tree-line: #45475a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: none;
    align-items: center;
    justify-content: center;
}

.menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.top-bar-center {
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent-color);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    justify-content: flex-end;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-dark {
    display: none;
}

body.dark-mode .icon-light {
    display: none;
}

body.dark-mode .icon-dark {
    display: block;
}

.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: transform 0.3s ease, width 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    width: 0;
    overflow: hidden;
}

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

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.tree-nav {
    padding: 8px 0;
}

.tree-item {
    user-select: none;
    position: relative;
}

.tree-header {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
    font-size: 14px;
    height: 28px;
}

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

.tree-header.active {
    background: var(--bg-active);
    color: var(--accent-color);
    font-weight: 500;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    margin-right: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-toggle.leaf {
    visibility: hidden;
}

.tree-icon {
    margin-right: 6px;
    font-size: 14px;
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-status {
    margin-left: 6px;
    font-size: 12px;
    flex-shrink: 0;
}

.tree-children {
    display: none;
    position: relative;
}

.tree-children.expanded {
    display: block;
}

.tree-children::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 8px;
    width: 1px;
    background: var(--tree-line);
}

.tree-children .tree-item::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 14px;
    width: 12px;
    height: 1px;
    background: var(--tree-line);
}

.tree-children .tree-header {
    padding-left: 28px;
}

.tree-children .tree-children::before {
    left: 36px;
}

.tree-children .tree-children .tree-item::before {
    left: 36px;
}

.tree-children .tree-children .tree-header {
    padding-left: 44px;
}

.tree-children .tree-children .tree-children::before {
    left: 52px;
}

.tree-children .tree-children .tree-children .tree-item::before {
    left: 52px;
}

.tree-children .tree-children .tree-children .tree-header {
    padding-left: 60px;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.content-body {
    padding: 32px;
    max-width: 960px;
    margin: 0 auto;
}

.welcome-page {
    padding: 20px 0;
}

.welcome-top {
    margin-bottom: 16px;
}

.welcome-top h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.welcome-slogan {
    font-size: 15px;
    color: var(--text-primary);
}

.welcome-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-sep {
    color: var(--text-muted);
}

.subject-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.subject-card {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg-primary);
}

.subject-card:hover {
    border-color: var(--accent-color);
}

.card-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-range {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-progress {
    font-size: 12px;
    color: var(--text-muted);
}

.welcome-footer {
    margin-top: 24px;
    text-align: center;
}

.footer-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-meta a {
    color: var(--accent-color);
    text-decoration: none;
}

.footer-meta a:hover {
    text-decoration: underline;
}

.content-article {
    padding: 32px;
}

.content-article h1 {
    font-size: 26px;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--accent-color);
    font-weight: 800;
}

.content-article h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin: 28px 0 14px;
    font-weight: 700;
}

.content-article h3 {
    font-size: 17px;
    color: var(--text-primary);
    margin: 20px 0 10px;
    font-weight: 600;
}

.content-article p {
    margin-bottom: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.content-article ul, .content-article ol {
    margin: 14px 0;
    padding-left: 24px;
}

.content-article li {
    margin-bottom: 6px;
    line-height: 1.7;
    color: var(--text-primary);
}

.content-article code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: var(--accent-color);
}

.content-article pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
}

.content-article pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.content-article blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 12px 16px;
    margin: 16px 0;
    background: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.content-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.content-article th, .content-article td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
}

.content-article th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.content-article td {
    color: var(--text-primary);
}

.content-article img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
}

.article-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.article-footer p {
    margin-bottom: 4px;
    font-style: italic;
}

.search-highlight {
    background: #fef3c7;
    padding: 2px 4px;
    border-radius: 2px;
}

body.dark-mode .search-highlight {
    background: rgba(254, 243, 199, 0.2);
}

.search-results-info {
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    max-width: 360px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    z-index: 9999;
    display: none;
}

.cookie-banner.show {
    display: block;
}

.cookie-banner-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.cookie-banner-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.cookie-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cookie-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.cookie-btn-allow {
    background: var(--accent-color);
    color: #fff;
}

.cookie-btn-allow:hover {
    background: var(--accent-hover);
}

.cookie-btn-deny {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.cookie-btn-deny:hover {
    background: var(--bg-hover);
}

@media (max-width: 768px) {
    .menu-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .top-bar-center {
        margin: 0 12px;
    }

    .content-body {
        padding: 20px 16px;
    }

    .content-article {
        padding: 20px;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .hero-section {
        padding: 24px;
    }

    .hero-section h1 {
        font-size: 24px;
    }

    .top-bar-left {
        min-width: auto;
    }

    .top-bar-right {
        min-width: auto;
    }
}