:root {
    --bg-primary: #0a0e13;
    --bg-secondary: #141b23;
    --bg-tertiary: #1a2332;
    --bg-card: #1e2836;
    --bg-card-hover: #252f3f;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-light: #79c0ff;
    --accent-dark: #4493f8;
    --accent-gradient: linear-gradient(135deg, #58a6ff 0%, #7c3aed 50%, #ec4899 100%);
    --accent-gradient-subtle: linear-gradient(135deg, rgba(88, 166, 255, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    --border: #30363d;
    --border-light: #21262d;
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    --shadow-sm: rgba(0, 0, 0, 0.5);
    --shadow-md: rgba(0, 0, 0, 0.6);
    --shadow-lg: rgba(0, 0, 0, 0.8);
    --glow: rgba(88, 166, 255, 0.4);
    --glow-strong: rgba(88, 166, 255, 0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(124, 58, 237, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
    width: 100%;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, rgba(16, 24, 35, 0.9), rgba(16, 24, 35, 0.8));
    padding: 1.25rem 0 0.75rem;
    margin-bottom: 1.5rem;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-mark {
    font-size: 1.3rem;
}

.header-links a {
    color: var(--text-secondary);
    margin-left: 1rem;
    text-decoration: none;
}

.header-links a:hover {
    color: var(--accent-light);
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding-top: 0.5rem;
}

/* Toolbar */
.toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.toolbar-actions {
    display: flex;
    gap: 0.5rem;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    font-size: 1rem;
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

#search {
    flex: 1;
    width: 100%;
    padding: 0.875rem 1.125rem;
    padding-left: 2.75rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

#search::placeholder {
    opacity: 0.5;
    color: var(--text-muted);
}

#search:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 3px var(--glow);
}

.btn-toggle {
    padding: 0.875rem 1.25rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-toggle:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.btn-toggle span:first-child {
    font-size: 1rem;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    flex: 1;
    margin-bottom: 3rem;
    align-items: start;
}

/* Sidebar */
.sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 4px 16px var(--shadow-sm);
}

.sidebar h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar h2::before {
    content: '📁';
    font-size: 1.25rem;
}

/* File Tree */
.file-tree {
    list-style: none;
}

.file-tree ul,
.file-tree .tree-list {
    list-style: none;
    padding-left: 0;
}

.file-tree .tree-list .tree-list {
    padding-left: 1rem;
}

.file-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    word-break: break-all;
    margin: 0.125rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    position: relative;
}

.file-item:hover {
    background: var(--bg-card-hover);
}

.file-item.active {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-light);
    font-weight: 600;
}

.file-item .icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.file-item .icon.chevron {
    font-size: 0.75rem;
    width: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-family: monospace;
}

.file-item.directory:hover .icon.chevron {
    color: var(--accent-light);
}

.file-item .file-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.directory {
    font-weight: 600;
    color: var(--text-primary);
}

.dir-label {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.dir-name {
    font-weight: 600;
}

.dir-subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: normal;
    word-break: normal;
}

/* Content area */
.content {
    min-width: 0;
}

.content > .welcome,
.content > .code-viewer {
    max-width: 1100px;
    margin: 0 auto;
}

/* Welcome card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-sm);
}

.welcome {
    padding: 2.25rem;
}

.welcome-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.welcome-hero h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.welcome-hero p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Category grid */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    width: 100%;
}

.category-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-sm);
}

.category-card:active {
    transform: translateY(0);
}

.category-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
    width: 2.5rem;
    text-align: center;
}

.category-info {
    flex: 1;
    min-width: 0;
}

.category-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    color: var(--text-primary);
}

.category-info p {
    font-size: 0.825rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.category-arrow {
    color: var(--text-muted);
    font-size: 1.25rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.category-card:hover .category-arrow {
    transform: translateX(3px);
    color: var(--accent);
}

/* Welcome hint */
.welcome-hint {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
    padding-top: 1.25rem;
}

.welcome-hint span {
    margin-right: 0.25rem;
}

.welcome-hint a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.welcome-hint a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

/* Code viewer */
.code-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

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

.code-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
}

.code-header-top {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    font-size: 0.9rem;
    min-width: 0;
}

.breadcrumb-segment {
    color: var(--text-muted);
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb-sep {
    color: var(--text-muted);
    margin: 0 0.25rem;
    opacity: 0.5;
}

/* File description */
.file-description {
    padding: 0.75rem 1.5rem 1rem;
    border-top: 1px solid var(--border-light);
}

.file-description h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 0.25rem;
}

.file-description p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-line;
}

/* Code actions */
.code-actions {
    display: flex;
    gap: 0.875rem;
    flex-shrink: 0;
}

.btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-copy {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

.btn-copy.copied {
    background: var(--success);
    border-color: var(--success);
}

/* File nav (prev/next) */
.file-nav {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

.btn-nav {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.825rem;
    padding: 0.5rem 0.75rem;
}

.btn-nav:hover {
    color: var(--accent-light);
    background: transparent;
    border-color: transparent;
}

/* Code container */
.code-container {
    position: relative;
    overflow-x: auto;
}

pre {
    margin: 0;
    padding: 1.75rem;
    overflow-x: auto;
    background: var(--bg-primary);
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.75;
}

/* Loading and error states */
.loading, .error {
    padding: 2.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
}

.loading::before {
    content: '⏳';
    font-size: 1.75rem;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.error {
    color: var(--error);
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
}

/* Footer */
footer {
    margin-top: auto;
    padding: 2.5rem 0;
    border-top: 1px solid var(--border-light);
    text-align: center;
    color: var(--text-secondary);
}

footer a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
}

footer a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

/* Responsive: tablet */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 280px 1fr;
        gap: 1.5rem;
    }
}

/* Responsive: mobile */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .toolbar {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .toolbar-actions {
        justify-content: flex-end;
    }

    .layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: 350px;
    }

    .welcome {
        padding: 1.5rem;
    }

    .welcome-hero h2 {
        font-size: 1.35rem;
    }

    .welcome-hero p {
        font-size: 0.95rem;
    }

    .category-card {
        padding: 0.875rem 1rem;
    }

    .category-icon {
        font-size: 1.5rem;
        width: 2rem;
    }

    .code-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .file-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-nav {
        text-align: center;
    }
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar,
.code-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.sidebar::-webkit-scrollbar-track,
.code-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb,
.code-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.code-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Flat view styling */
.flat-view .file-item {
    display: inline-block;
    margin: 0.375rem;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.flat-view .file-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}
