/* Shared navigation and document-scrolling account layout.
   Keep these rules after the legacy account styles in index.html. */
:root {
    --bottom-nav-space: calc(92px + env(safe-area-inset-bottom, 0px));
}

html {
    scroll-padding-bottom: var(--bottom-nav-space);
}

main {
    padding-bottom: var(--bottom-nav-space);
}

.site-footer,
body.profile-surface-active .site-footer {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    padding: 10px max(20px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom));
}

.footer-inner,
body.profile-surface-active .footer-inner {
    display: flex;
    justify-content: center;
    gap: 0;
}

.glass-dock,
body.profile-surface-active .glass-dock {
    width: min(440px, 100%);
    margin: 0;
}

.page-legal {
    display: block;
    width: fit-content;
    margin: 24px auto 0;
    color: var(--dim);
    font-size: 12px;
    text-align: center;
    text-underline-offset: 4px;
}

body.auth-surface-active .page-legal,
body.profile-surface-active .page-legal {
    display: none;
}

/* A profile can grow with linked accounts, admin controls and larger text. */
body.profile-surface-active {
    height: auto;
    overflow: visible;
}

body.profile-surface-active main {
    height: auto;
    flex: 1 0 auto;
    padding-bottom: var(--bottom-nav-space);
}

body.profile-surface-active #page-profile.active {
    height: auto;
    align-items: flex-start;
}

body.profile-surface-active .profile-shell {
    height: auto;
}

body.profile-surface-active .profile-title-wrap {
    display: flex;
}

body.profile-surface-active .profile-grid {
    flex: none;
    grid-template-rows: auto;
    align-items: start;
}

body.profile-surface-active .profile-avatar-panel,
body.profile-surface-active .profile-details {
    height: auto;
}

body.profile-surface-active .profile-details {
    overflow: visible;
    min-width: 0;
    gap: 20px;
}

.profile-section-title {
    grid-column: 1 / -1;
    margin: 0 0 14px;
    color: #e6f4fa;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.01em;
}

.profile-id-info > .profile-section-title {
    margin-bottom: 3px;
}

.profile-info-row {
    flex-wrap: wrap;
}

.profile-info-row input {
    width: 100%;
    min-width: 0;
}

.profile-info-row .pi-value {
    white-space: normal;
    overflow-wrap: anywhere;
}

#profile-edit-form {
    flex: none;
    margin: 0;
}

@media (max-width: 768px) {
    :root {
        --bottom-nav-space: calc(96px + env(safe-area-inset-bottom, 0px));
    }

    .site-footer,
    body.profile-surface-active .site-footer {
        padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom));
        background: rgba(4, 10, 17, .94);
        border-top-color: rgba(135, 216, 238, .14);
        backdrop-filter: blur(20px);
    }

    .glass-dock,
    body.profile-surface-active .glass-dock {
        width: min(440px, 100%);
        padding: 4px;
        border-radius: 20px;
        gap: 6px;
    }

    .dock-btn,
    body.profile-surface-active .dock-btn {
        min-width: 0;
        min-height: 56px;
        flex-direction: column;
        gap: 4px;
        padding: 6px 12px;
        border-radius: 15px;
        font-size: 12px;
        line-height: 1.2;
        letter-spacing: .01em;
        text-transform: none;
    }

    .dock-btn svg,
    body.profile-surface-active .dock-btn svg {
        width: 22px;
        height: 22px;
    }

    body.profile-surface-active main {
        padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) var(--bottom-nav-space) max(16px, env(safe-area-inset-left));
    }

    body.profile-surface-active header {
        display: block;
        position: relative;
    }

    body.profile-surface-active header .nav {
        padding-block: 4px;
    }

    body.profile-surface-active #go-home {
        min-height: 44px;
        align-items: center;
    }

    body.profile-surface-active .profile-shell {
        max-width: 560px;
    }

    body.profile-surface-active .profile-title-wrap {
        margin: 0 0 20px;
    }

    .profile-title {
        font-size: 28px;
        line-height: 1.15;
    }

    .profile-kicker {
        font-size: 10px;
    }

    .profile-subtitle {
        display: block;
        font-size: 13px;
        line-height: 1.5;
        color: #98b1c0;
    }

    .profile-security-badge {
        display: none;
    }

    body.profile-surface-active .profile-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px;
    }

    .profile-panel {
        border-radius: 22px;
    }

    body.profile-surface-active .profile-avatar-panel {
        display: grid;
        grid-template-columns: 80px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        gap: 10px 14px;
        padding: 16px;
    }

    body.profile-surface-active .profile-avatar-frame {
        grid-column: 1;
        grid-row: 1 / 3;
        width: 80px;
        height: 80px;
        max-height: none;
        aspect-ratio: 1;
        border-radius: 18px;
        align-self: center;
    }

    body.profile-surface-active .avatar-upload-btn {
        grid-column: 1 / -1;
        grid-row: 3;
        min-height: 44px !important;
        margin: 2px 0 0;
    }

    .syndicate-id-tag {
        grid-column: 2;
        flex-wrap: wrap;
        gap: 3px 8px;
        margin: 0;
        padding: 8px 10px;
    }

    .syndicate-id-tag .sid-label {
        font-size: 10px;
        letter-spacing: .04em;
        color: #98b1c0;
    }

    .syndicate-id-tag .sid-value {
        font-size: 12px;
    }

    body.profile-surface-active .profile-details {
        padding: 18px;
        gap: 24px;
    }

    #profile-edit-form {
        margin: 0;
    }

    .profile-form-grid,
    body.profile-surface-active .profile-id-info {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    body.profile-surface-active .profile-id-info {
        margin: 0;
    }

    .profile-shell .form-group {
        margin: 0;
    }

    .profile-shell .form-group label {
        margin-bottom: 7px;
        font-size: 13px;
        letter-spacing: .01em;
        color: #a9c2cf;
        text-transform: none;
    }

    .profile-shell input,
    body.profile-surface-active .profile-shell textarea {
        height: 48px;
        min-height: 48px;
        padding: 12px;
        font-size: 16px;
        scroll-margin-block: 24px var(--bottom-nav-space);
    }

    body.profile-surface-active .profile-shell textarea {
        height: 120px;
        min-height: 120px;
        resize: vertical;
    }

    .profile-shell .btn {
        min-height: 46px;
        padding: 12px;
        font-size: 12px;
        line-height: 1.4;
        letter-spacing: .02em;
        white-space: normal;
        text-transform: none;
    }

    .profile-shell .profile-save-btn {
        margin-top: 18px;
    }

    .profile-info-row {
        position: static;
        padding: 12px;
        gap: 8px 12px;
        align-items: center;
    }

    .profile-info-row .pi-label {
        position: static;
        flex: 0 0 100%;
        font-size: 11px;
        line-height: 1.4;
        letter-spacing: .04em;
        color: #98b1c0;
    }

    .profile-info-row .pi-value {
        padding: 0;
        font-size: 14px;
        line-height: 1.5;
    }

    .profile-info-row .pi-value.muted {
        color: #98b1c0;
    }

    .profile-info-row .pi-btn {
        min-height: 44px;
        margin: 0;
        font-size: 12px;
    }

    #profile-email-connect-row .pi-btn {
        width: 100%;
    }

    .profile-account-actions,
    .profile-account-actions.is-admin {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        margin: 0;
        padding-top: 20px;
        border-top: 1px solid rgba(135, 216, 238, .14);
    }

    .toast-container {
        left: 16px;
        right: 16px;
        top: max(16px, env(safe-area-inset-top));
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }
}
