:root {
    --ink: #0b0d17;
    --bg: #0f111c;
    --surface: #14161f;
    --border: #23273a;
    --border-strong: #2b3048;
    --primary: #2b44f0;
    --primary-light: #5b72ff;
    --white: #ffffff;
    --muted: #9aa0ae;
    --faint: #3a3f52;
    --ring-dim: #12172b;
    --ring-dim-2: #141a33;
    --danger: #f27373;
    --danger-bg: #2e1214;
    --danger-border: #5a2427;
    --ok: #7ddea0;
    --ok-bg: #10261a;
    --ok-border: #1e4a32;
    --font-display: "Sora", system-ui, sans-serif;
    --font-ui: "Cairo", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html,
body {
    height: 100%;
}

html {
    color-scheme: dark;
}

body.brovl-login {
    margin: 0;
    background: var(--ink);
    color: var(--white);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: rgba(91, 114, 255, 0.35);
    color: var(--white);
}

a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    color: #8195ff;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
}

.page {
    position: relative;
    min-height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 48px 64px;
    padding-top: max(48px, env(safe-area-inset-top));
    padding-bottom: max(48px, env(safe-area-inset-bottom));
}

.page::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(900px 480px at 18% -8%, rgba(91, 114, 255, 0.14), transparent 58%),
        radial-gradient(720px 420px at 108% 108%, rgba(43, 68, 240, 0.16), transparent 52%);
}

.grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.045;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.ambient {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient svg {
    position: absolute;
    will-change: transform;
}

.ambient .r1 {
    left: -260px;
    top: -140px;
    width: 1180px;
    height: 1180px;
    opacity: 0.55;
    animation: drift 90s linear infinite;
}

.ambient .r2 {
    right: -190px;
    bottom: -230px;
    width: 760px;
    height: 760px;
    opacity: 0.4;
    animation: drift 120s linear infinite reverse;
}

.ambient .r3 {
    left: 42%;
    top: 18%;
    width: 420px;
    height: 420px;
    opacity: 0.18;
    animation: drift 70s linear infinite;
}

html[dir="rtl"] .ambient .r1 {
    left: auto;
    right: -260px;
}

html[dir="rtl"] .ambient .r2 {
    right: auto;
    left: -190px;
}

.masthead,
.colophon {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: inherit;
}

.brand:hover {
    color: inherit;
}

.brand span {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.locales {
    display: flex;
    align-items: center;
    gap: 4px;
}

.locales a {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faint);
    padding: 6px 10px;
}

.locales a:hover {
    color: var(--muted);
}

.locales a.is-active {
    color: var(--white);
}

.colophon {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.12em;
    color: var(--faint);
}

main {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.auth {
    width: 520px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 34px;
    animation: rise 0.65s ease both;
}

.greeting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.mark {
    filter: drop-shadow(0 0 28px rgba(91, 114, 255, 0.38));
    animation: breathe 6.5s ease-in-out infinite;
}

.greeting h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 2.85rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.greeting p {
    margin: 0;
    max-width: 28rem;
    font-size: 17px;
    line-height: 1.5;
    color: var(--muted);
}

.card {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 44px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-shadow:
        0 0 0 1px rgba(91, 114, 255, 0.04),
        0 40px 80px rgba(0, 0, 0, 0.35);
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(91, 114, 255, 0.45), transparent);
    pointer-events: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
}

.field label,
.field-head label {
    font-size: 16px;
    color: var(--muted);
}

.field-head a {
    font-size: 14px;
    font-weight: 500;
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    padding: 17px;
    font: inherit;
    font-size: 18px;
    color: var(--white);
    border-radius: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
    color: #5c6274;
}

.field input:hover {
    border-color: #3a415c;
}

.field input:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 114, 255, 0.16);
}

.field input.is-invalid {
    border-color: var(--danger);
}

.field input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(242, 115, 115, 0.18);
}

.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--white);
    caret-color: var(--white);
    box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-out;
}

.password {
    position: relative;
}

.password input {
    padding-inline-end: 52px;
}

.eye {
    position: absolute;
    inset-inline-end: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
}

.eye svg {
    grid-area: 1 / 1;
    display: block;
}

.eye [data-eye-off],
.eye.is-visible [data-eye] {
    display: none;
}

.eye.is-visible [data-eye-off] {
    display: block;
}

.eye:hover {
    color: var(--white);
}

.eye:focus-visible {
    outline-offset: 1px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.check input {
    appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.check input:checked {
    background: var(--primary-light);
    border-color: var(--primary-light);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='white' stroke-width='2' d='M3.5 8.5 6.5 11.5 12.5 4.5'/></svg>");
    background-size: 12px 12px;
    background-repeat: no-repeat;
    background-position: center;
}

.check input:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.btn {
    font: inherit;
    font-size: 18px;
    font-weight: 500;
    border: 0;
    border-radius: 0;
    padding: 18px;
    text-align: center;
    cursor: pointer;
    background: var(--primary-light);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover {
    background: #7286ff;
}

.btn:active {
    transform: translateY(1px);
}

.btn[aria-busy="true"] {
    pointer-events: none;
    opacity: 0.85;
}

.btn .spinner {
    display: none;
}

.btn[aria-busy="true"] .spinner {
    display: block;
    animation: spin 1.1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    padding: 14px 16px;
    font-size: 15px;
    line-height: 1.45;
}

.alert[data-tone="ok"] {
    background: var(--ok-bg);
    border-color: var(--ok-border);
    color: var(--ok);
}

.alert .mark-alert {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

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

@keyframes drift {
    to {
        transform: rotate(360deg);
    }
}

@keyframes breathe {
    0%,
    100% {
        filter: drop-shadow(0 0 22px rgba(91, 114, 255, 0.28));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 36px rgba(91, 114, 255, 0.5));
        transform: scale(1.03);
    }
}

@media (max-width: 900px) {
    .page {
        padding: 28px 20px;
        padding-top: max(28px, env(safe-area-inset-top));
        padding-bottom: max(28px, env(safe-area-inset-bottom));
    }

    .brand span {
        font-size: 22px;
    }

    .greeting h1 {
        font-size: 32px;
    }

    .greeting p {
        font-size: 15px;
    }

    .card {
        padding: 28px 22px;
    }

    .colophon {
        justify-content: center;
        font-size: 11px;
    }

    .ambient .r1 {
        left: -200px;
        top: -160px;
        width: 780px;
        height: 780px;
    }

    html[dir="rtl"] .ambient .r1 {
        right: -200px;
        left: auto;
    }

    .ambient .r2,
    .ambient .r3 {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth,
    .ambient svg,
    .mark,
    .btn[aria-busy="true"] .spinner {
        animation: none;
    }

    .btn[aria-busy="true"] .spinner {
        opacity: 0.6;
    }
}
