:root {
    --bg-base: #0f172a;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    
    --color-stable: #10b981;
    --color-wip: #f59e0b;
    --color-broken: #ef4444;
    --color-exp: #8b5cf6;

    --radius: 12px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* subtle background glow */
    background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                      radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
}

.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-glass);
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.projects-list-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
}

.list-header h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.projects-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 8px 12px;
}

.project-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid transparent;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.project-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.project-item-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.project-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    height: 80px;
    z-index: 10;
}

.active-project-info h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.active-project-info p {
    font-size: 0.85rem;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.5;
}

.empty-state svg {
    margin-bottom: 16px;
    color: var(--text-muted);
}

/* Timeline */
.timeline-container {
    max-width: 800px;
    margin: 0 auto;
}

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-glass);
}

.snapshot-card {
    position: relative;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.snapshot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.snapshot-card::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 24px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-base);
    border: 2px solid var(--accent-primary);
    z-index: 2;
}

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

.snapshot-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.snapshot-note {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 16px;
    color: #e2e8f0;
    white-space: pre-wrap;
}

.snapshot-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-glass);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-tag-stable { background: rgba(16, 185, 129, 0.15); color: var(--color-stable); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-tag-progress { background: rgba(245, 158, 11, 0.15); color: var(--color-wip); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-tag-broken { background: rgba(239, 68, 68, 0.15); color: var(--color-broken); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-tag-experiment { background: rgba(139, 92, 246, 0.15); color: var(--color-exp); border: 1px solid rgba(139, 92, 246, 0.3); }

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-wip);
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Buttons & Inputs */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: var(--bg-glass);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn:hover { background: rgba(255,255,255,0.1); }
.btn:active { transform: scale(0.97); }

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

.btn-danger { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

.btn-icon { padding: 6px; border-radius: 6px; }

.input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: var(--transition);
    font-family: inherit;
}

.input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

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

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    width: 100%;
    max-width: 500px;
    border-radius: 16px;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.modal-header h2 { font-size: 1.25rem; }

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-close-modal:hover { color: var(--text-main); }

.modal-body { padding: 24px; }

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

/* Directory Browser Component */
.dir-browser {
    margin-top: 12px;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
    max-height: 200px;
    display: flex;
    flex-direction: column;
}

.dir-header {
    padding: 8px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.02);
}

.dir-list {
    list-style: none;
    overflow-y: auto;
    padding: 4px;
}

.dir-item {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dir-item:hover { background: rgba(255,255,255,0.05); }

/* Diff Viewer */
.diff-list {
    list-style: none;
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 8px;
}
.diff-item {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-family: monospace;
    border-radius: 4px;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
}
.diff-item:last-child { margin-bottom: 0; }
.diff-added { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.diff-modified { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.diff-deleted { background: rgba(239, 68, 68, 0.1); color: #ef4444; text-decoration: line-through; }

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-glass);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 8px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    position: relative;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--accent-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* Markdown Documentation */
.markdown-body {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 24px;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1:first-child, .markdown-body h2:first-child { margin-top: 0; }

.markdown-body p, .markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
}

.markdown-body ul { padding-left: 20px; }

.markdown-body code {
    background: rgba(0,0,0,0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.markdown-body pre {
    background: rgba(0,0,0,0.5);
    padding: 16px;
    border-radius: 8px;
    overflow: auto;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: none;
    padding: 0;
}

.markdown-editor {
    width: 100%;
    height: 400px;
    resize: vertical;
    font-family: monospace;
}

/* Settings View */
.settings-view {
    max-width: 600px;
    margin: 0 auto;
    padding-top: 20px;
}

.settings-section {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.settings-section h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 8px;
}

.theme-options {
    display: flex;
    gap: 16px;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.theme-blue { background: #3b82f6; }
.theme-emerald { background: #10b981; }
.theme-purple { background: #8b5cf6; }
.theme-crimson { background: #ef4444; }
