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

:root {
    --bg: #fafafa;
    --bg-card: #fff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --code-bg: #f3f4f6;
    --alert-error-bg: #fef2f2;
    --alert-error-border: #fecaca;
    --radius: 6px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --bg-card: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --border: #30363d;
    --code-bg: #1f2428;
    --primary: #388bfd;
    --primary-hover: #58a6ff;
    --danger: #f85149;
    --success: #3fb950;
    --alert-error-bg: #1c0608;
    --alert-error-border: #6e1c20;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1117;
        --bg-card: #161b22;
        --text: #e6edf3;
        --text-muted: #8b949e;
        --border: #30363d;
        --code-bg: #1f2428;
        --primary: #388bfd;
        --primary-hover: #58a6ff;
        --danger: #f85149;
        --success: #3fb950;
        --alert-error-bg: #1c0608;
        --alert-error-border: #6e1c20;
    }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user { color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    text-decoration: none;
}

.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.btn-outline {
    background: transparent;
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}
.btn-link:hover { color: var(--text); }
.btn-oauth {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    display: block;
    text-align: center;
    margin-bottom: 0.5rem;
}
.btn-oauth:hover { background: var(--border); }

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--alert-error-bg);
    color: var(--danger);
    border: 1px solid var(--alert-error-border);
}

/* Auth pages */
.auth-page {
    max-width: 400px;
    margin: 2rem auto;
}

.auth-form label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.auth-form input, .auth-form select, .auth-form textarea {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.auth-form textarea { resize: vertical; }
.auth-form .btn { width: 100%; margin-top: 0.5rem; }

.auth-divider {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider span {
    background: var(--bg);
    padding: 0 1rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Landing */
.landing {
    text-align: center;
    padding: 4rem 0;
}

.landing h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.landing p { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 2rem; }
.landing-actions { display: flex; gap: 1rem; justify-content: center; }

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.repo-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.repo-card {
    display: block;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: border-color 0.15s;
}

.repo-card:hover { border-color: var(--primary); text-decoration: none; }
.repo-card h3 { margin-bottom: 0.5rem; }
.repo-card p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 0.5rem; }
.repo-vis { font-size: 0.75rem; background: var(--bg); padding: 0.15rem 0.5rem; border-radius: 999px; }
.repo-card time { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; }

/* File browser */
.repo-page { }
.repo-header { margin-bottom: 1.5rem; }
.repo-header h2 { margin-bottom: 0.25rem; }
.repo-header p { color: var(--text-muted); }

.file-browser {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.file-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.file-list { list-style: none; }

.file-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
}

.file-list li:last-child { border-bottom: none; }
.file-actions { display: flex; gap: 0.5rem; }

/* File page */
.file-page, .history-page, .diff-page { }

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

/* Version table */
.version-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.version-table th, .version-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.version-table th { background: var(--bg); font-weight: 600; }

.diff-controls { margin-bottom: 1rem; }

/* Dialog */
dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
}

dialog::backdrop { background: rgba(0,0,0,0.3); }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Status indicators */
.status-unsaved { color: #d97706; font-size: 0.8rem; }
.status-saved { color: var(--success); font-size: 0.8rem; }
.status-error { color: var(--danger); font-size: 0.8rem; }
