:root {
    --primary: #0066FF;
    --primary-dark: #0052CC;
    --primary-light: #E6F0FF;
    --bg: #FAFBFC;
    --surface: #FFFFFF;
    --border: #E1E4E8;
    --text: #24292F;
    --text-secondary: #57606A;
    --text-muted: #8B949E;
    --success: #1A7F37;
    --warning: #9A6700;
    --danger: #CF222E;
    --sidebar-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--text);
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0066FF 0%, #00AAFF 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.header-search {
    flex: 1;
    max-width: 480px;
    margin: 0 40px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238B949E' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 14px center no-repeat;
    transition: all 0.2s;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg);
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.search-result-section {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-avatar:hover {
    background: var(--primary-dark);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.user-dropdown-name {
    font-weight: 600;
    font-size: 14px;
}

.user-dropdown-role {
    font-size: 12px;
    color: var(--text-muted);
}

.user-dropdown-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.user-dropdown-item:hover {
    background: var(--bg);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

/* Layout */
.layout {
    display: flex;
    padding-top: 64px;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px 0;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.sidebar-item:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.sidebar-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.sidebar-item.active svg {
    opacity: 1;
}

/* Main Content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 48px;
    max-width: 960px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
}

/* Article */
.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.article-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.2;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Article Content */
.article-content {
    font-size: 16px;
    line-height: 1.75;
}

.article-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 40px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.article-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 32px 0 12px;
}

.article-content p {
    margin-bottom: 16px;
}

.article-content ul, .article-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.article-content pre {
    background: #1E2329;
    color: #E6EDF3;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.article-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: 13px;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.article-content table th,
.article-content table td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border);
}

.article-content table th {
    background: var(--bg);
    font-weight: 600;
}

/* Info Boxes */
.info-box {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin: 24px 0;
}

.info-box-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.warning-box {
    background: #FFF8E6;
    border-left-color: var(--warning);
}

.danger-box {
    background: #FFEBE9;
    border-left-color: var(--danger);
}

/* Editor */
.editor-container {
    display: none;
}

.editor-container.active {
    display: block;
}

.article-content.hidden {
    display: none;
}

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.toolbar-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.toolbar-divider {
    width: 1px;
    background: var(--border);
    margin: 0 8px;
}

.editor-textarea {
    width: 100%;
    min-height: 500px;
    padding: 20px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.editor-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    background: var(--bg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.version-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.version-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.version-dot {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.version-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.version-info p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1E2329;
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 300;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Responsive */
@media (max-width: 1200px) {
    .toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main {
        margin-left: 0;
        padding: 24px;
    }

    .header-search {
        display: none;
    }
}