:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1e293b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

body.dark-mode {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --secondary: #94a3b8;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-light: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
}

* {
    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-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

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

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.logo .subtitle {
    font-size: 12px;
    color: var(--text-light);
}

.nav-menu {
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-item .icon {
    font-size: 18px;
}

.tags-section {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.tags-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.tag-item:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(4px);
}

.tag-item.active {
    background: rgba(59, 130, 246, 0.3);
}

.tag-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.tag-count {
    font-size: 12px;
    color: var(--text-light);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-theme, .btn-export, .btn-import {
    padding: 10px 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-theme:hover, .btn-export:hover, .btn-import:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 8px 16px;
    width: 500px;
    gap: 8px;
}

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

.search-box select {
    border: none;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

.btn-search {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.top-actions {
    display: flex;
    gap: 12px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-1px);
}

.btn-small {
    padding: 6px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--border);
}

.btn-icon {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.knowledge-grid.list-view {
    grid-template-columns: 1fr;
}

.knowledge-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.knowledge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.knowledge-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.knowledge-card:hover::before {
    opacity: 1;
}

.knowledge-card.priority-high {
    border-left: 4px solid var(--danger);
}

.knowledge-card.priority-medium {
    border-left: 4px solid var(--warning);
}

.knowledge-card.priority-low {
    border-left: 4px solid var(--success);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 8px;
    line-height: 1.4;
}

.card-favorite {
    color: var(--warning);
    font-size: 18px;
}

.card-category {
    display: inline-block;
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.card-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.card-tag {
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.card-links {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--primary);
    margin-bottom: 8px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-light);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s;
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.editor-modal {
    max-width: 800px;
}

.small-modal {
    max-width: 400px;
}

.detail-modal {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    min-height: 200px;
    resize: vertical;
    font-family: 'Monaco', 'Menlo', monospace;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.file-upload input[type="file"] {
    width: 100%;
}

.file-list {
    margin-top: 12px;
    text-align: left;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.color-picker {
    margin-top: 16px;
}

.color-picker label {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
}

.colors {
    display: flex;
    gap: 8px;
}

.color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color:hover,
.color.active {
    transform: scale(1.1);
    border-color: var(--text-primary);
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.meta-info {
    font-size: 12px;
    color: var(--text-light);
}

.detail-content {
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.detail-links {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.detail-links h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.detail-link-item {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-right: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.detail-link-item:hover {
    background: var(--primary);
    color: #fff;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.detail-tag {
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.graph-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

#knowledgeGraph {
    width: 100%;
    height: 100%;
}

.graph-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    background: var(--bg-primary);
    padding: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stats-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 40px;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.stats-timeline {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stats-timeline h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.template-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border);
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.template-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.template-tag {
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.template-actions {
    display: flex;
    justify-content: center;
    padding: 20px;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .search-box {
        width: 100%;
    }
    
    .top-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-charts {
        grid-template-columns: 1fr;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.btn-share {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-share:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.share-info {
    margin-bottom: 24px;
}

.share-info p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.share-url-box {
    display: flex;
    gap: 8px;
}

.share-url-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: monospace;
}

.btn-copy {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-copy:hover {
    background: var(--primary-dark);
}

.share-steps {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.share-steps h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.share-steps ol {
    margin: 0;
    padding-left: 20px;
}

.share-steps li {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 8px;
}

.share-steps code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.share-warning {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 16px;
    border-radius: var(--radius);
}

.share-warning p {
    color: var(--warning);
    font-size: 14px;
    margin: 0 0 12px 0;
}

.share-warning ul {
    margin: 0;
    padding-left: 20px;
}

.share-warning li {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 6px;
}