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

:root {
    --brand: rgb(59, 175, 218);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --surface: #f5f5f5;
    --border: rgba(148, 163, 184, 0.2);
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #991b1b;
}

html, body {
    height: 100%;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background: #0c1222;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.site-name, .user-form-links { display: none; }

/* Background */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #0c1222;
}

/* Card */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin: 1.5rem;
    padding: 3rem 2.5rem 2.5rem;
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Accent bar at top of card */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: var(--brand);
    border-radius: 0 0 3px 3px;
}

/* Branding */
.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--brand);
    margin-bottom: 1.25rem;
}

.login-brand p {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Messages */
.login-messages {
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    font-size: 0.825rem;
    color: var(--error-text);
    line-height: 1.5;
}

.login-messages .messages { margin: 0; padding: 0; border: 0; background: none; }
.login-messages ul { margin: 0; padding-left: 1.2em; }

/* Hide unnecessary Backdrop elements */
.studio-form .tabs,
.studio-form .action-links,
.dismiss {
    display: none;
}

/* Footer */
.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    body {
        align-items: flex-start;
        padding-top: env(safe-area-inset-top, 0);
    }

    .login-card {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
        padding: 2.5rem 1.5rem 2rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border: none;
    }

    .login-card::before {
        display: none;
    }

    .login-brand {
        margin-bottom: 2.25rem;
    }
}

@media (max-width: 380px) {
    .login-card {
        padding: 2rem 1.25rem 1.5rem;
    }
}

/* Landscape on short screens */
@media (max-height: 500px) {
    .login-card {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
        justify-content: flex-start;
        overflow-y: auto;
    }

    .login-brand {
        margin-bottom: 1rem;
    }

    .login-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        margin-bottom: 0.75rem;
    }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .login-bg, .login-card {
        animation: none !important;
    }
}
