.spark-profile-trigger {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
}

.spark-avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: inherit;
    font-weight: 800;
    line-height: 1;
}

.spark-avatar img,
.spark-profile-preset img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.spark-avatar img[hidden],
#profileModal [hidden] { display: none !important; }

#profileModal {
    --profile-anchor: calc(100vw - 12px);
    inset: var(--profile-top, 70px) auto auto max(8px, calc(var(--profile-anchor) - 24rem));
    width: min(24rem, calc(var(--profile-anchor) - 8px));
    margin: 0;
}

#profileModal::backdrop {
    background: transparent;
    opacity: 1;
    transition: none;
    backdrop-filter: none;
}

#profileModal .spark-morph-panel {
    height: min(42rem, var(--profile-available, calc(100dvh - 78px)));
    max-height: none;
    padding: 0;
    overflow: hidden;
    background: color-mix(in srgb, var(--lg-dialog-fill) 95%, var(--lg-content-fill)) !important;
    -webkit-backdrop-filter: blur(18px) saturate(145%);
    backdrop-filter: blur(18px) saturate(145%);
}

.spark-profile-pages {
    height: 100%;
    overflow: hidden;
}

.spark-profile-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(.25,.8,.25,1);
}

.spark-profile-page[data-profile-page="home"] { transform: translateX(-100%); }
.spark-profile-page.is-outgoing,
.spark-profile-page.is-current { visibility: visible; }
.spark-profile-page.is-current { pointer-events: auto; transform: translateX(0); }
#profileModal:not([open]) .spark-profile-page { transition: none; }

@media (prefers-reduced-motion: reduce) {
    .spark-profile-page { transition: none; }
}

.spark-profile-heading {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: .35rem;
    padding: .5rem .75rem 0;
}

[data-profile-page="home"] .spark-profile-title { grid-column: 1 / -1; }
.spark-profile-heading h2:focus { outline: none; }
.spark-profile-title {
    margin: 0;
    grid-column: 2;
    color: var(--lg-ink);
    font-size: 1.08rem;
    font-weight: 750;
    line-height: 1.15;
    text-align: center;
    text-wrap: balance;
}

#profileModal .spark-profile-page-body {
    flex: 1;
    padding: .5rem 1rem 1rem;
    scrollbar-width: thin;
    scrollbar-gutter: stable both-edges;
    scroll-padding-block: .5rem;
}

.spark-profile-identity {
    display: grid;
    justify-items: center;
    gap: .55rem;
    margin: 0 0 .85rem;
    text-align: center;
}

.spark-profile-avatar {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: var(--lg-radius-pill);
    background: var(--lg-accent-fill);
    color: #fff;
    font-size: 1.65rem;
}

.spark-profile-avatar:focus-visible,
.spark-profile-account-link:focus-visible,
.spark-profile-logout:focus-visible,
.spark-profile-delete-button:focus-visible,
.spark-profile-confirm-delete input:focus-visible {
    outline: 2px solid var(--lg-focus);
    outline-offset: 2px;
}

.spark-profile-avatar-edit {
    position: absolute;
    inset: auto -2px -2px auto;
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border: 2px solid var(--lg-dialog-fill);
    border-radius: var(--lg-radius-pill);
    background: var(--lg-active-fill);
    color: var(--lg-link);
}

.spark-profile-avatar-edit svg { width: 13px; height: 13px; }
.spark-profile-avatar:hover .spark-profile-avatar-edit { background: var(--lg-secondary-hover); }

#profileName {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 750;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

#profileEmail {
    margin: .15rem 0 0;
    color: var(--lg-muted);
    font-size: .875rem;
    overflow-wrap: anywhere;
}

.spark-profile-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
    margin: 0 0 .85rem;
    padding: .5rem;
    border-radius: var(--lg-radius-control);
    background: var(--lg-secondary-fill);
    text-align: center;
}

.spark-profile-stats > div {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: .15rem;
    padding: .2rem .25rem;
}

.spark-profile-stats > div + div {
    border-inline-start: 1px solid var(--lg-field-edge);
}

.spark-profile-stats dt {
    color: var(--lg-muted);
    font-size: .8rem;
    line-height: 1.3;
}

.spark-profile-stats dd {
    align-self: end;
    font-size: 1.15rem;
    font-weight: 800;
}

.spark-profile-edit { margin-block: .7rem; }
.spark-profile-edit .spark-profile-status:not(:empty) { margin-top: .3rem; }

.spark-profile-section {
    display: grid;
    gap: .45rem;
    padding-block: .7rem;
    border-top: 1px solid var(--lg-field-edge);
}

.spark-profile-section h3 {
    margin: 0;
    font-size: .9rem;
    font-weight: 700;
}

[data-profile-page="credentials"] .spark-profile-section:first-child { border-top: 0; }
.spark-profile-school-fields > :is(p, ul) { grid-column: 1 / -1; }

.spark-profile-account {
    padding-block: .25rem;
    border-block: 1px solid var(--lg-field-edge);
    margin-block-start: .85rem;
}
.spark-profile-account-link,
.spark-profile-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    min-height: 44px;
    padding: .35rem .5rem;
    border: 0;
    border-radius: var(--lg-radius-small);
    background: transparent;
    color: var(--lg-ink);
    font-size: .875rem;
    font-weight: 650;
    text-align: start;
}

.spark-profile-account-link { justify-content: space-between; }
.spark-profile-account-link::after {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    margin-inline-end: .4rem;
    border: solid currentColor;
    border-width: 1.5px 1.5px 0 0;
    transform: rotate(45deg);
}
.spark-profile-account-link:hover, .spark-profile-logout:hover { background: var(--lg-icon-hover); }
.spark-profile-delete { color: var(--lg-danger); }
.spark-profile-logout { color: var(--lg-muted); }

.spark-profile-name-fields,
.spark-profile-avatar-controls {
    display: grid;
    min-width: 0;
    gap: .55rem;
}

.spark-profile-name-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spark-profile-school-fields { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.spark-profile-email-fields,
.spark-profile-password-fields,
.spark-profile-delete-fields {
    grid-template-columns: minmax(0, 1fr);
    margin-top: .6rem;
}
.spark-profile-password-fields { margin-top: 0; gap: .35rem; }

.spark-profile-name-fields label {
    display: grid;
    gap: .3rem;
    color: var(--lg-ink);
    font-size: .875rem;
    font-weight: 650;
}

.spark-profile-name-fields input {
    width: 100%;
    padding: .5rem .65rem;
    font-weight: 600;
}

.spark-profile-name-fields button { grid-column: 1 / -1; }

.spark-profile-presets {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

#profilePasswordForm { gap: .35rem; }
#profilePasswordForm input { padding: .5rem .65rem; }
#profilePasswordForm button { margin-top: .25rem; }
.spark-profile-field-label {
    color: var(--lg-ink);
    font-size: .875rem;
    font-weight: 650;
}
.spark-profile-field-label:not(:first-of-type) { margin-top: .3rem; }

#profileModal .spark-profile-preset {
    width: 44px;
    height: 44px;
    padding: 3px;
    border-radius: var(--lg-radius-pill);
    color: var(--lg-ink);
    font-weight: 800;
}

.spark-profile-preset[aria-pressed="true"] {
    outline: 2px solid var(--lg-focus);
    outline-offset: 1px;
}

.spark-profile-preset:focus-visible {
    outline: 2px solid var(--lg-focus);
    outline-offset: 3px;
}

.spark-profile-button {
    justify-self: start;
    min-height: 40px;
    padding: .42rem .75rem;
    font-size: .85rem;
    font-weight: 750;
}

.spark-profile-status {
    color: var(--lg-muted);
    font-size: .8rem;
    overflow-wrap: anywhere;
}

.spark-profile-status:empty { display: none; }
.spark-profile-status.is-error { color: var(--lg-danger); }
.spark-profile-status.is-success { color: #06704e; font-weight: 700; }
.dark .spark-profile-status.is-success { color: #a7f3d0; }
#profileDeleteWarning { margin-top: .55rem; }

.spark-profile-delete-fields .spark-profile-confirm-delete {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .5rem;
}

.spark-profile-confirm-delete input { width: 1rem; height: 1rem; }

.spark-profile-mentors { display: grid; gap: .5rem; }
.spark-profile-mentors > li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .35rem;
    padding: .5rem;
    border: 1px solid var(--lg-field-edge);
    border-radius: var(--lg-radius-control);
    overflow-wrap: anywhere;
}

.spark-profile-delete-button {
    border: 1px solid var(--lg-danger-edge);
    border-radius: var(--lg-radius-control);
    color: var(--lg-danger);
    background: var(--lg-danger-fill);
}

.spark-profile-delete-button:hover { background: var(--lg-danger-hover); }

@media (max-width: 360px) and (pointer: fine) {
    #profileModal .spark-profile-preset { width: 40px; height: 40px; }
}
@media (pointer: coarse) {
    .spark-profile-button { min-height: 44px; }
}
.spark-profile-teacher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-block: .75rem;
    color: var(--lg-muted);
    font-size: .9rem;
}

.spark-profile-teacher p { margin: 0; overflow-wrap: anywhere; }
.spark-profile-teacher a { display: inline-flex; min-height: 44px; align-items: center; gap: .5rem; text-decoration: none; }
