:root {
    --auth-canvas: var(--bg-primary);
    --auth-surface: var(--bg-secondary);
    --auth-button: var(--bg-primary);
    --auth-button-hover: var(--bg-tertiary);
    --auth-button-border: var(--border-color);
    --auth-ink: var(--text-primary);
    --auth-muted: var(--text-secondary);
    --auth-soft-border: var(--border-color);
}

body.auth-page main {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.auth-canvas {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: grid;
    place-items: center;
    padding: 6rem 2.5rem;
    color: var(--auth-ink);
    background-color: var(--auth-canvas);
}

.auth-fluid-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.5;
}

[data-theme="dark"] .auth-fluid-background {
    opacity: 0.62;
}

.auth-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    padding: 1.65rem;
    border: 1px solid var(--auth-soft-border);
    border-radius: 0.75rem;
    background: var(--auth-surface);
    box-shadow: 0 0.5rem 1rem var(--shadow-color);
}

.auth-heading {
    margin-bottom: 1.1rem;
    text-align: center;
}

.auth-eyebrow {
    display: inline-block;
    margin-bottom: 0.65rem;
    color: #746a5e;
    font-size: 0.73rem;
    font-weight: 750;
    letter-spacing: 0.16em;
}

.auth-heading h1 {
    margin: 0;
    color: var(--auth-ink);
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    font-weight: 720;
    letter-spacing: -0.035em;
}

.auth-heading p {
    margin: 0.7rem 0 0;
    color: var(--auth-muted);
}

.microsoft-signin-button {
    width: 100%;
    min-height: 64px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    color: var(--auth-ink);
    border: 1px solid var(--auth-button-border);
    border-radius: 0.5rem;
    background: var(--auth-button);
    box-shadow: 0 2px 6px var(--shadow-color);
    font-size: clamp(0.88rem, 2vw, 0.98rem);
    font-weight: 620;
    text-align: left;
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.microsoft-signin-button:hover {
    transform: translateY(-2px);
    background: var(--auth-button-hover);
    border-color: var(--primary-color);
    box-shadow: 0 0.35rem 0.75rem var(--shadow-color);
}

.microsoft-signin-button:focus-visible,
.role-option:focus-visible,
.auth-cancel-button:focus-visible,
.local-login-panel summary:focus-visible {
    outline: 3px solid rgba(136, 56, 144, 0.25);
    outline-offset: 3px;
}

.microsoft-signin-button > .bi {
    color: var(--auth-muted);
    font-size: 1.05rem;
}

.microsoft-mark {
    width: 25px;
    height: 25px;
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
}

.microsoft-mark span:nth-child(1) { background: #f25022; }
.microsoft-mark span:nth-child(2) { background: #7fba00; }
.microsoft-mark span:nth-child(3) { background: #00a4ef; }
.microsoft-mark span:nth-child(4) { background: #ffb900; }

.local-login-panel {
    overflow: hidden;
    margin-top: 0.9rem;
    border: 1px solid var(--auth-button-border);
    border-radius: 0.5rem;
    background: var(--auth-button);
    box-shadow: 0 2px 6px var(--shadow-color);
}

.local-login-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    color: var(--auth-ink);
    font-size: clamp(0.88rem, 2vw, 0.98rem);
    font-weight: 620;
    list-style: none;
}

.local-login-panel summary::-webkit-details-marker { display: none; }

.local-login-panel summary:hover {
    background: var(--auth-button-hover);
}

.local-login-panel summary span {
    display: grid;
    grid-template-columns: 25px 1fr;
    align-items: center;
    gap: 1rem;
}

.local-login-panel summary span > .bi {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    color: var(--primary-color);
    font-size: 1.15rem;
}

.local-login-chevron { transition: transform 150ms ease; }
.local-login-panel[open] .local-login-chevron { transform: rotate(180deg); }

.local-login-content {
    padding: 0.7rem 1rem 0.85rem;
    border-top: 1px solid var(--auth-soft-border);
    background: var(--auth-surface);
}

.local-login-content .form-label {
    margin-bottom: 0.2rem;
    color: var(--auth-ink);
    font-size: 0.86rem;
}

.local-login-content .form-control,
.local-login-content .btn {
    font-size: 0.9rem;
}

.local-login-content .form-control {
    padding: 0.3rem 0.55rem;
}

.local-login-content .mb-3 {
    margin-bottom: 0.55rem !important;
}

.local-login-content .btn {
    padding-top: 0.32rem;
    padding-bottom: 0.32rem;
}

.role-panel { width: min(100%, 760px); }

.verified-identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2.1rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(25, 135, 84, 0.22);
    border-radius: 0.5rem;
    background: rgba(25, 135, 84, 0.07);
}

.verified-identity > i {
    color: #198754;
    font-size: 1.45rem;
}

.verified-identity div {
    min-width: 0;
    display: grid;
}

.verified-identity span,
.verified-identity small { color: var(--auth-muted); }
.verified-identity span { font-size: 0.77rem; }
.verified-identity strong,
.verified-identity small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-heading { margin-bottom: 1.5rem; }

.role-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.role-option {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.9rem;
    min-height: 116px;
    padding: 1.1rem;
    color: var(--auth-ink);
    border: 1px solid var(--auth-button-border);
    border-radius: 0.5rem;
    background: var(--auth-button);
    text-align: left;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.role-option:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 0.35rem 0.75rem var(--shadow-color);
}

.role-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 1.25rem;
}

.role-icon.student { background: var(--primary-color); }
.role-icon.teacher { background: var(--success-color); }

.role-copy { display: grid; gap: 0.25rem; }
.role-copy strong { font-size: 1.02rem; }
.role-copy small { color: var(--auth-muted); line-height: 1.35; }
.role-option > .bi { color: var(--auth-muted); }

.auth-cancel-form { margin-top: 1.4rem; text-align: center; }

.auth-cancel-button {
    padding: 0.35rem 0.5rem;
    color: var(--auth-muted);
    border: 0;
    background: transparent;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 640px) {
    .auth-canvas { padding: 3rem 1.25rem; }
    .auth-panel { padding: 1.35rem 1rem; border-radius: 0.75rem; }
    .microsoft-signin-button { gap: 0.8rem; padding: 0.85rem; }
    .microsoft-mark { width: 23px; height: 23px; }
    .role-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-fluid-background {
        display: none;
    }
}
