#auth-controls {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

#auth-open-button,
#auth-account-button {
    border: 1px solid white;
    border-radius: 4px;
    background: transparent;
    color: white;
    padding: 8px 14px;
    font-weight: bold;
    cursor: pointer;
}

#auth-open-button:hover,
#auth-account-button:hover {
    background: white;
    color: #0066cc;
}

#auth-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

#auth-account-button {
    max-width: 280px;
}

.auth-account-mobile-label {
    display: none;
}

#auth-account-menu {
    position: fixed;
    z-index: 100001;
    min-width: 190px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#auth-account-menu[hidden] {
    display: none;
}

#auth-account-menu button {
    width: 100%;
    border: 0;
    background: white;
    padding: 11px 14px;
    text-align: left;
    font-weight: bold;
    cursor: pointer;
}

#auth-account-menu button:hover {
    background: #f2f6fa;
}

#auth-delete-open-button {
    border-top: 1px solid #eee !important;
    color: #b00020;
}

#auth-user[hidden] {
    display: none;
}

#auth-user-email {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
}

.auth-modal[hidden] {
    display: none;
}

.auth-dialog {
    position: relative;
    width: min(420px, 100%);
    border-radius: 8px;
    background: white;
    padding: 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    box-sizing: border-box;
}

.auth-close-button {
    position: absolute;
    top: 8px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #555;
    font-size: 28px;
    cursor: pointer;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0 22px;
    border-bottom: 1px solid #ddd;
}

.auth-tab {
    flex: 1;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    padding: 10px;
    color: #555;
    font-weight: bold;
    cursor: pointer;
}

.auth-tab.active {
    border-bottom-color: #0066cc;
    color: #0066cc;
}

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

.auth-form[hidden] {
    display: none;
}

.auth-form h2 {
    margin: 0 0 12px;
    color: #0066cc;
}

.auth-form input {
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: 11px;
    font-size: 16px;
}

.auth-form small {
    color: #666;
}

.auth-submit-button {
    margin-top: 14px;
    border: 0;
    border-radius: 4px;
    background: #0066cc;
    color: white;
    padding: 12px;
    font-weight: bold;
    cursor: pointer;
}

.auth-submit-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.auth-link-button {
    align-self: center;
    border: 0;
    background: transparent;
    color: #0066cc;
    padding: 6px;
    text-decoration: underline;
    cursor: pointer;
}

.auth-form-description {
    margin: 0 0 8px;
    color: #555;
    line-height: 1.45;
}

.auth-message {
    min-height: 20px;
    margin: 16px 0 0;
    color: #b00020;
}

.auth-message.success {
    color: #167000;
}

.auth-danger-title {
    color: #b00020 !important;
}

.auth-delete-warning {
    margin: 0 0 12px;
    color: #555;
    line-height: 1.45;
}

.auth-delete-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.auth-cancel-button,
.auth-delete-button {
    border-radius: 4px;
    padding: 11px 14px;
    font-weight: bold;
    cursor: pointer;
}

.auth-cancel-button {
    border: 1px solid #777;
    background: white;
    color: #444;
}

.auth-delete-button {
    border: 1px solid #b00020;
    background: #b00020;
    color: white;
}

.auth-delete-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 768px) {
    #auth-controls {
        left: 8px;
    }

    #auth-open-button,
    #auth-account-button {
        padding: 6px 8px;
        font-size: 11px;
    }

    #auth-user {
        gap: 6px;
    }

    #auth-user-email {
        display: none;
    }

    .auth-account-mobile-label {
        display: inline;
    }

    #auth-account-menu {
        min-width: 170px;
    }

    .auth-dialog {
        padding: 24px 20px;
    }

    .auth-delete-actions {
        flex-direction: column-reverse;
    }
}


/* Avvertenze e consenso all'accesso */
:is(#auth-consent-modal, #auth-disclaimer-modal) {
    z-index: 200000;
    padding: 24px;
    background: rgba(10, 28, 48, .72);
}
.auth-consent-dialog {
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    padding: 0;
    overflow: hidden;
    border: 1px solid #dbe5ef;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 20, 45, .35);
}
:is(#auth-consent-form, #auth-disclaimer-form) {
    gap: 0;
    max-height: inherit;
    min-height: 0;
}
.auth-consent-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-shrink: 0;
    padding: 28px 32px 24px;
    border-bottom: 1px solid #dbe5ef;
    background: #f3f8fd;
}
.auth-consent-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    height: 48px;
    border-radius: 12px;
    background: #dfeeff;
    color: #0066cc;
}
.auth-consent-eyebrow {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #466581;
}
:is(#auth-consent-title, #auth-disclaimer-title) {
    margin: 0;
    color: #173b5e;
    font-size: 23px;
    line-height: 1.3;
}
.auth-consent-text {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 32px;
    color: #33465a;
    font-size: 15px;
    line-height: 1.65;
    scrollbar-color: #a6bdd3 #f3f8fd;
    scrollbar-width: thin;
}
.auth-consent-list {
    display: grid;
    gap: 18px;
    padding-left: 20px;
    margin: 0;
}
.auth-consent-list li { padding-left: 6px; }
.auth-consent-list li::marker { color: #0066cc; }
.auth-consent-source {
    margin: 24px 0 0;
    padding: 16px 18px;
    border-left: 3px solid #0066cc;
    border-radius: 0 8px 8px 0;
    background: #f3f8fd;
    font-size: 14px;
}
.auth-consent-footer {
    flex-shrink: 0;
    padding: 20px 32px 24px;
    border-top: 1px solid #dbe5ef;
    background: white;
}
.auth-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #c8d7e6;
    border-radius: 9px;
    background: #f8fafc;
    color: #173b5e;
    font-size: 14px;
    line-height: 1.5;
    font-weight: bold;
    cursor: pointer;
}
.auth-consent-label:has(input:checked) {
    border-color: #0066cc;
    background: #edf5ff;
}
.auth-consent-label input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: #0066cc;
}
.auth-consent-actions {
    display: flex;
    flex-direction: row-reverse;
    gap: 12px;
    margin-top: 18px;
}
.auth-consent-actions button {
    min-height: 44px;
    margin: 0;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
}
#auth-consent-continue { flex: 1; }
#auth-consent-continue:disabled {
    background: #e4ebf2;
    color: #64768a;
    opacity: 1;
    cursor: not-allowed;
}
#auth-consent-continue:hover:not(:disabled) { background: #0055aa; }
#auth-consent-cancel { border-color: #c8d7e6; color: #466078; }
#auth-consent-cancel:hover:not(:disabled) { background: #f3f6fa; }
#auth-consent-message { margin-top: 12px; min-height: 0; }
#auth-consent-message:empty { display: none; }
:is(#auth-consent-modal, #auth-disclaimer-modal) :focus-visible { outline: 3px solid #0066cc; outline-offset: 3px; }
@media (max-width: 600px) {
    :is(#auth-consent-modal, #auth-disclaimer-modal) { padding: 12px; }
    .auth-consent-dialog {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: 12px;
    }
    .auth-consent-header { padding: 20px; gap: 12px; }
    .auth-consent-icon { flex-basis: 38px; height: 38px; border-radius: 9px; }
    :is(#auth-consent-title, #auth-disclaimer-title) { font-size: 19px; }
    .auth-consent-eyebrow { font-size: 10px; }
    .auth-consent-text { padding: 20px; font-size: 14px; line-height: 1.6; }
    .auth-consent-list { gap: 16px; }
    .auth-consent-source { padding: 12px 14px; font-size: 13px; }
    .auth-consent-footer { padding: 16px 20px 20px; }
    .auth-consent-label { padding: 12px; }
    .auth-consent-actions { flex-direction: column; gap: 8px; margin-top: 14px; }
    .auth-consent-actions button { width: 100%; }
}

/* Registrazione con avvertenze complete e scorrimento su schermi piccoli. */
#auth-modal:has(#auth-register-form:not([hidden])) .auth-dialog {
    width: min(720px, 100%);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
}
#auth-register-disclaimer {
    padding: 16px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}
#auth-register-disclaimer h3 { margin: 0 0 12px; color: #0066cc; }
#auth-register-disclaimer .auth-consent-list { margin: 0; padding-left: 20px; }
#auth-register-disclaimer .auth-consent-source { margin-top: 16px; }
#auth-register-exit { padding: 11px; cursor: pointer; }
