:root {
    --sidebar-width: 300px;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --text-color: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary-color);
}

.search-box button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--primary-hover);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.file-list .loading {
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.file-item {
    display: block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9375rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.file-item:hover {
    background: #f1f5f9;
    border-left-color: var(--primary-color);
}

.file-item.active {
    background: #eff6ff;
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.file-item small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.no-results {
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

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

.content-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.content-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.markdown-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Markdown Styles */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 { font-size: 2rem; border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; }
.markdown-body h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3rem; }
.markdown-body h3 { font-size: 1.25rem; }
.markdown-body h4 { font-size: 1.1rem; }

.markdown-body p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.25rem;
}

.markdown-body a {
    color: var(--primary-color);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 0.875em;
}

.markdown-body pre {
    background: #1e293b;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

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

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.markdown-body th {
    background: #f1f5f9;
    font-weight: 600;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Image Figure Styles */
.md-image-figure {
    margin: 1.5rem 0;
    text-align: center;
}

.md-image-link {
    display: inline-block;
    position: relative;
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 8px;
    overflow: hidden;
}

.md-image-link:hover {
    transform: scale(1.01);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.md-image-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s;
    border-radius: 8px;
}

.md-image-link:hover::after {
    background: rgba(0, 0, 0, 0.03);
}

.md-image {
    display: block;
    max-height: 500px;
    object-fit: cover;
    border-radius: 8px;
}

.md-image-caption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 8px;
    animation: zoomIn 0.2s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #f1f5f9;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1001;
    line-height: 1;
}

.lightbox-close:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.lightbox-caption {
    color: #e2e8f0;
    padding: 1rem 2rem;
    font-size: 1rem;
    text-align: center;
    max-width: 80%;
}

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

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.markdown-body hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2rem 0;
}

.welcome {
    text-align: center;
    padding: 4rem 2rem;
}

.welcome h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.welcome p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Search results highlight */
.search-highlight {
    background: #fef3c7;
    padding: 0.1rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-width);
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .markdown-body {
        padding: 1rem;
    }
}
