.login-modal {
    --auth-surface: var(--bg-secondary, #f4f1ec);
    --auth-surface-2: var(--button-color, #f7f3ee);
    --auth-border: var(--accent-color, #ded2c0);
    --auth-text: var(--text-primary, #554638);
    --auth-text-muted: var(--text-secondary, #a08165);
    --auth-input-bg: var(--button-color, #aeb8c8);
    --auth-input-border: var(--accent-color, #c9d0dc);
    --auth-input-text: var(--search-bar-color, #2f3a4b);
    --auth-input-placeholder: var(--text-secondary, rgba(242, 246, 255, 0.9));
    --auth-accent: var(--episode-container, #d89568);
    --auth-accent-hover: #cf895c;
    --auth-button-text: var(--text-primary, #ffffff);
    --auth-focus-ring: rgba(var(--episode-container-rgb, 216, 149, 104), 0.28);
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.72);
    background: rgba(0, 0, 0, 0.75);
}

.login-modal,
.login-modal * {
    box-sizing: border-box;
}

.login-modal.show {
    display: flex;
}

.login-modal-content {
    position: relative;
    width: min(460px, calc(100vw - 32px)) !important;
    max-width: 460px !important;
    max-height: min(92vh, 760px);
    overflow: auto;
    border: 1px solid var(--auth-border);
    border-radius: 18px;
    background: var(--auth-surface);
    color: var(--auth-text);
    animation: authModalIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.login-close {
    position: absolute;
    top: 31px;
    right: 30px;
    width: 46px;
    height: 46px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    background: var(--auth-surface-2);
    color: var(--auth-text);
    font-size: 1.85rem;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.login-close:hover {
    border-color: var(--auth-accent);
    transform: translateY(-1px);
}

.login-close:focus-visible,
.login-button:focus-visible,
.signup-link a:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 3px;
}

.login-form,
.signup-form {
    min-height: 100%;
}

.form-switch-active {
    display: flex;
    flex-direction: column;
}

.form-switch-inactive {
    display: none;
}

.login-header {
    padding: 30px 86px 24px 32px;
    border-bottom: 1px solid var(--auth-border);
}

.login-header h2 {
    margin: 0;
    color: var(--auth-text);
    font-size: 1.5rem;
    line-height: 1.12;
    font-weight: 800;
}

.login-header p {
    margin: 8px 0 0;
    color: var(--auth-text-muted);
    font-size: 1rem;
    font-weight: 600;
}

.auth-form-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 26px 32px 32px;
}

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

.form-group label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    color: var(--auth-text);
    font-size: 1rem;
    font-weight: 800;
}

.form-group label small {
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.25;
}

.form-group input {
    width: 100%;
    height: 47px;
    border: 1px solid var(--auth-input-border);
    border-radius: 9px;
    background: var(--auth-input-bg);
    color: var(--auth-input-text);
    padding: 0 20px;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.form-group input::placeholder {
    color: var(--auth-input-placeholder);
    font-weight: 700;
}

.form-group input:focus {
    border-color: var(--auth-accent);
    background: var(--auth-input-bg);
}

.login-button {
    width: 100%;
    height: 50px;
    margin-top: 0;
    border: 0;
    border-radius: 13px;
    background: var(--auth-accent);
    color: var(--auth-button-text);
    font: inherit;
    font-size: 1.08rem;
    font-weight: 900;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease;
}

.login-button:hover {
    background: var(--auth-accent-hover);
    transform: translateY(-1px);
}

.login-button:active {
    transform: translateY(0);
}

#register-button[disabled] {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
}

.signup-link {
    margin-top: 8px;
    text-align: center;
    color: var(--auth-text);
    font-size: 1rem;
    font-weight: 800;
}

.signup-link a {
    color: var(--auth-accent);
    margin-left: 5px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

.signup-link a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

#loginError,
#signupError {
    margin: 0 32px;
    padding: 13px 14px;
    border: 1px solid rgba(188, 61, 61, 0.24);
    border-radius: 10px;
    background: rgba(188, 61, 61, 0.08);
    color: #a93434 !important;
    font-size: 0.95rem !important;
    font-weight: 800;
    text-align: left !important;
}

#loginError + .login-header,
#signupError + .login-header {
    margin-top: 14px;
}

.success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 42px 32px;
    text-align: center;
    gap: 14px;
}

.success-icon {
    width: 86px;
    height: 86px;
}

.success-text {
    color: var(--auth-text);
    font-size: 1.25rem;
    font-weight: 900;
}

.success-subtitle {
    color: var(--auth-text-muted);
    font-size: 0.95rem;
    font-weight: 800;
}

.success-subtitle.countdown {
    animation: subtlePulse 1s ease infinite;
}

@keyframes authModalIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes subtlePulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.62;
    }
}

.turnstile-wrapper {
    display: flex;
    justify-content: center;
    min-height: 65px;
}

.turnstile-container {
    display: flex;
    justify-content: center;
}

.turnstile-container iframe {
    max-width: 100%;
}

@media (max-width: 640px) {
    .turnstile-wrapper {
        min-height: 55px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-modal-content,
    .success-subtitle.countdown {
        animation: none;
    }

    .login-close,
    .login-button,
    .form-group input {
        transition: none;
    }
}

@media (max-width: 640px) {
    .login-modal {
        align-items: flex-end;
        padding: 12px;
        overflow-y: auto;
    }

    .login-modal-content {
        margin: 0;
        max-height: none;
        border-radius: 17px 17px 0 0;
    }

    .login-close {
        top: 20px;
        right: 18px;
        width: 42px;
        height: 42px;
        font-size: 1.65rem;
    }

    .login-header {
        padding: 24px 74px 21px 24px;
    }

    .login-header h2 {
        font-size: 1.38rem;
    }

    .auth-form-body {
        gap: 15px;
        padding: 22px 24px 26px;
    }

    .form-group input {
        height: 46px;
        padding-inline: 16px;
    }

    #loginError,
    #signupError {
        margin-inline: 24px;
    }
}
