:root {
    color-scheme: dark;
    --bg: #0f1116;
    --card: #181b23;
    --muted: #8a8fa3;
    --accent: #5a7dff;
    --accent-strong: #7896ff;
    --border: #2a2f3f;
    --text: #f5f7ff;
    --danger: #ff6b6b;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.auth-body,
.app-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand-title {
    font-size: 1.15rem;
    margin: 0;
}

.brand-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: #10131a;
    color: var(--text);
    font-size: 0.95rem;
}

input:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

button,
.logout-link {
    border: none;
    border-radius: 0.75rem;
    padding: 0.7rem 1.2rem;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.2s ease;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button.primary {
    background: var(--accent-strong);
}

button:hover:not(:disabled),
.logout-link:hover {
    opacity: 0.85;
}

.form-error {
    color: var(--danger);
    margin: 0;
    font-size: 0.9rem;
}

.app-shell {
    display: flex;
    width: 100%;
    max-width: 1200px;
    min-height: 80vh;
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    overflow: hidden;
    background: var(--card);
}

.sidebar {
    width: 280px;
    background: #141824;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-chip {
    padding: 0.75rem;
    border-radius: 0.9rem;
    background: #10131a;
    font-size: 0.85rem;
    color: var(--muted);
}

.user-chip strong {
    display: block;
    color: var(--text);
}

.sidebar-actions {
    display: flex;
    gap: 0.75rem;
}

.sidebar-actions button {
    flex: 0 0 auto;
    padding: 0.5rem 0.9rem;
}

.sidebar-search {
    position: relative;
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    overflow-y: auto;
}

.file-list li {
    padding: 0.7rem 0.85rem;
    border-radius: 0.8rem;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.file-list li .name {
    font-weight: 600;
}

.file-list li .meta {
    font-size: 0.8rem;
    color: var(--muted);
}

.file-list li:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.file-list li.active {
    border-color: var(--accent);
    background: rgba(90, 125, 255, 0.15);
}

.file-list li.empty {
    border: 1px dashed var(--border);
    color: var(--muted);
    text-align: center;
    padding: 1rem;
    cursor: default;
}

.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.editor-label {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.15rem;
    font-size: 0.7rem;
    color: var(--muted);
}

.editor-header h1 {
    margin: 0.2rem 0 0;
    font-size: clamp(1rem, 3vw, 1.5rem);
}

.editor-body {
    flex: 1;
    padding: 0 1.5rem 1.5rem;
    display: flex;
}

.editor-body textarea {
    width: 100%;
    height: 100%;
    resize: none;
    border-radius: 1rem;
    background: #0f1118;
    border: 1px solid var(--border);
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.status-bar {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
}

.status-bar.error {
    color: var(--danger);
}

@media (max-width: 960px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

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

@media (max-width: 520px) {
    .auth-card,
    .app-shell {
        border-radius: 1rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .editor-header {
        padding: 1rem;
    }

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