:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
}

body {
    box-sizing: border-box;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    display: grid;
    place-items: center;
    background: #f3f4f6;
    color: #111827;
}

.auth-card {
    box-sizing: border-box;
    width: min(400px, 100%);
    padding: clamp(24px, 7vw, 32px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 45px rgba(17, 24, 39, .12);
}

h1 { margin: 0 0 8px; font-size: 1.5rem; }
p { color: #6b7280; line-height: 1.5; }
label { display: grid; gap: 7px; margin-top: 18px; font-weight: 600; }
input {
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font: inherit;
}
select {
    box-sizing: border-box;
    width: 100%;
    padding: 11px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    font: inherit;
}
input:focus { outline: 3px solid #dbeafe; border-color: #2563eb; }
button {
    width: 100%;
    margin-top: 22px;
    padding: 12px;
    border: 0;
    border-radius: 10px;
    background: #111827;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.message { padding: 10px 12px; border-radius: 10px; background: #fef2f2; color: #991b1b; }
.message-success { background: #ecfdf5; color: #166534; }
.setup { padding: 12px; border-radius: 10px; background: #fffbeb; color: #92400e; }
.auth-alternative { margin: 22px 0 0; text-align: center; }
.auth-alternative a { color: #1d4ed8; font-weight: 650; }
.hint { margin: 6px 0 0; font-size: .875rem; }

.account-card { width: min(480px, 100%); }
.account-details { margin: 24px 0 0; }
.account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid #e5e7eb;
}
.account-row:first-child { border-top: 1px solid #e5e7eb; }
.account-row dt { color: #6b7280; font-weight: 600; }
.account-row dd {
    margin: 0;
    overflow-wrap: anywhere;
    text-align: right;
    font-weight: 650;
}
.account-action-row {
    align-items: center;
}
.account-row-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.account-inline-action {
    color: #2563eb;
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.25;
    text-align: right;
    text-decoration: none;
    white-space: nowrap;
}
.account-inline-action:hover,
.account-inline-action:focus-visible {
    text-decoration: underline;
}
.account-inline-action:focus-visible {
    border-radius: 3px;
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}
.account-email-value {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.account-email-address {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-email-edit { flex: 0 0 22px; }
.account-email-form {
    display: flex;
    width: 100%;
    min-width: 0;
    margin: 0;
    align-items: center;
    gap: 5px;
}
.account-email-form[hidden] { display: none; }
.account-email-form input[name="email"] {
    min-width: 0;
    height: 32px;
    margin: 0;
    padding: 5px 7px;
    font-size: .875rem;
}
.account-email-form .account-email-save,
.account-email-form .account-email-cancel {
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border-radius: 7px;
    font-size: 1rem;
    line-height: 1;
}
.account-email-form .account-email-cancel {
    background: #e5e7eb;
    color: #111827;
}
.account-flat-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 3px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #475569;
    text-decoration: none;
}
.account-flat-icon[hidden] { display: none; }
.account-flat-icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.account-flat-icon:hover,
.account-flat-icon:focus-visible {
    background: #e5e7eb;
    color: #111827;
}
.account-flat-icon:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}
.account-primary-action {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border-radius: 10px;
    background: #111827;
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}
.account-primary-action:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.account-secondary-action {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    color: #111827;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}
.account-secondary-action + .account-primary-action { margin-top: 12px; }
.account-studios { margin-top: 28px; }
.account-studios h2 { margin: 0 0 14px; font-size: 1.125rem; }
.account-studio-list { display: grid; gap: 12px; }
.account-studio {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}
.account-studio-active { border-color: #93c5fd; background: #eff6ff; }
.account-studio-summary { display: grid; gap: 4px; min-width: 0; }
.account-studio-heading { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.account-studio-heading strong { min-width: 0; }
.account-studio-name-inline { min-width: 0; flex: 1 1 auto; }
.account-studio-owner-actions { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 2px; }
.account-studio-leave-form { flex: 0 0 auto; margin: 0; }
.account-studio-leave-icon {
    color: #b91c1c;
}
.account-studio-leave-icon:hover,
.account-studio-leave-icon:focus-visible {
    background: #fee2e2;
    color: #991b1b;
}
.account-studio-name-form {
    display: flex;
    width: 100%;
    min-width: 0;
    margin: 0;
    align-items: center;
    gap: 5px;
    box-sizing: border-box;
}
.account-studio-name-form[hidden] { display: none; }
.account-studio-name-form input[name="name"] {
    min-width: 0;
    height: 32px;
    margin: 0;
    padding: 5px 7px;
    font-size: .875rem;
}
.account-studio-name-form .account-studio-name-save,
.account-studio-name-form .account-studio-name-cancel {
    width: auto;
    height: 32px;
    margin: 0;
    padding: 5px 8px;
    border-radius: 7px;
    font-size: .78rem;
    line-height: 1;
}
.account-studio-name-form .account-studio-name-cancel {
    background: #e5e7eb;
    color: #111827;
    font-size: 1.1rem;
}
.account-studio-summary strong { overflow-wrap: anywhere; }
.account-studio-role { color: #6b7280; font-size: .875rem; font-weight: 650; }
.account-studio-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.account-studio-actions form { margin: 0; }
.account-studio-actions button { width: auto; margin: 0; padding: 9px 12px; }
.account-active-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-size: .8rem;
    font-weight: 750;
}
.members-card { width: min(680px, 100%); }
.members-card h2 { margin: 0; font-size: 1.125rem; }
.invitation-panel {
    margin-top: 24px;
    padding: 18px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #f8fbff;
}
.invitation-panel label { margin-top: 14px; }
.invitation-panel button { margin-top: 14px; }
.invitation-panel .setup { margin: 14px 0 0; }
.members-section-title { margin-top: 28px !important; }
.members-list {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}
.member-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.member-management { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; }
.member-management form, .invitation-actions form { display: flex; gap: 8px; margin: 0; }
.member-management select { width: auto; min-width: 140px; }
.member-management button, .invitation-actions button { width: auto; margin: 0; }
.secondary-small { background: #e5e7eb; color: #111827; }
.danger-small { background: #991b1b; color: #fff; }
.member-identity,
.member-meta { display: grid; gap: 5px; min-width: 0; }
.member-identity span,
.member-joined { color: #6b7280; font-size: .875rem; overflow-wrap: anywhere; }
.member-meta { justify-items: end; }
.member-role {
    display: inline-flex;
    width: fit-content;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 750;
}
.member-role-owner { background: #dbeafe; color: #1e40af; }
.member-role-editor { background: #dcfce7; color: #166534; }
.member-role-viewer { background: #f3f4f6; color: #374151; }
.members-empty { margin-top: 24px; }
.pending-invitations { margin-top: 30px; }
.invitation-list { display: grid; gap: 10px; margin-top: 14px; }
.invitation-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.invitation-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.invitation-row > div { display: grid; gap: 5px; min-width: 0; }
.invitation-row strong,
.invitation-row span { overflow-wrap: anywhere; }
.invitation-row > div span,
.empty-copy { color: #6b7280; font-size: .875rem; }
.invitation-status {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 750;
    white-space: nowrap;
}
.invitation-status-in-attesa { background: #dcfce7; color: #166534; }
.invitation-status-scaduto { background: #fef3c7; color: #92400e; }
.invitation-status-revocato { background: #f3f4f6; color: #4b5563; }
.development-link {
    display: grid;
    gap: 5px;
    margin-top: 14px;
    padding: 12px;
    border-radius: 10px;
    background: #ecfdf5;
    color: #166534;
}
.development-link a { color: #166534; overflow-wrap: anywhere; }
.invitation-summary {
    display: grid;
    gap: 8px;
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.invitation-summary span { color: #6b7280; overflow-wrap: anywhere; }
.invitation-accept-card { width: min(460px, 100%); }

@media (max-width: 600px) {
    html.account-root,
    body.account-page {
        background: #fff;
        background-color: #fff;
    }
    body.account-page {
        min-height: 100dvh;
        align-items: start;
    }
    .account-email-form input[name="email"],
    .account-studio-name-form input[name="name"] {
        font-size: 16px;
    }
    body.login-page {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow-y: hidden;
        overscroll-behavior-y: none;
    }
}

@media (max-width: 420px) {
    .account-row { grid-template-columns: 1fr; gap: 4px; }
    .account-row dd { text-align: left; }
    .account-email-row,
    .account-password-row { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
    .account-email-value,
    .account-row-action { justify-content: flex-end; }
    .account-email-value { gap: 5px; }
    .account-email-address { font-size: .72rem; letter-spacing: -.02em; }
    .member-row { grid-template-columns: 1fr; gap: 12px; }
    .member-meta { justify-items: start; }
    .member-management { display: grid; justify-content: stretch; }
    .member-management form { display: grid; }
    .member-management select, .member-management button { width: 100%; }
    .invitation-row { grid-template-columns: 1fr; gap: 10px; }
    .account-studio-actions { display: grid; }
    .account-studio-actions form, .account-studio-actions button { width: 100%; }
}
