.person-portrait {
    --person-portrait-size: 2.75rem;
    align-items: center;
    background: #235b78;
    border: 2px solid rgb(255 255 255 / 85%);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgb(35 91 120 / 28%);
    color: #fff;
    display: inline-flex;
    flex: 0 0 var(--person-portrait-size);
    font-size: calc(var(--person-portrait-size) * 0.36);
    font-weight: 800;
    height: var(--person-portrait-size);
    justify-content: center;
    line-height: 1;
    overflow: hidden;
    position: relative;
    vertical-align: middle;
    width: var(--person-portrait-size);
}

.person-portrait--tiny {
    --person-portrait-size: 2rem;
}

.person-portrait--small {
    --person-portrait-size: 2.75rem;
}

.person-portrait--medium {
    --person-portrait-size: 4rem;
}

.person-portrait--large {
    --person-portrait-size: 7rem;
}

.person-character-avatar {
    display: block;
    height: 100%;
    width: 100%;
}

.person-silhouette-avatar {
    display: block;
    height: 100%;
    width: 100%;
}

.person-portrait__photo {
    height: 100%;
    left: 50%;
    object-fit: cover;
    object-position:
        calc(50% + var(--portrait-photo-x, 0%))
        calc(50% + var(--portrait-photo-y, 0%));
    position: absolute;
    top: 50%;
    transform:
        translate(-50%, -50%)
        scale(var(--portrait-photo-zoom, 1))
        rotate(var(--portrait-photo-rotation, 0deg));
    transform-origin: center;
    width: 100%;
}

.person-portrait--character {
    background: transparent;
}

.person-portrait--silhouette {
    background: transparent;
}

.person-portrait--avatar-initials {
    background: #235b78;
}

.person-portrait--avatar-paw,
.person-portrait--avatar-sun {
    background: #fff3a3;
    color: #183849;
}

.person-portrait--avatar-cat {
    background: #d9ccff;
    color: #3f2b66;
}

.person-portrait--avatar-dog {
    background: #bfe7cc;
    color: #1d5533;
}

.person-portrait--avatar-heart {
    background: #ffd2df;
    color: #8b2648;
}

.person-portrait--avatar-flower {
    background: #ffd5b8;
    color: #7a3b17;
}

.person-portrait--avatar-star {
    background: #bfe4f5;
    color: #174d68;
}

.person-portrait--avatar-home {
    background: #bde8e1;
    color: #14564f;
}

.person-avatar-options {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(
        auto-fit,
        minmax(8.5rem, 1fr)
    );
    margin: 0.45rem 0;
    max-width: 50rem;
}

.person-avatar-options > div {
    min-width: 0;
}

.person-avatar-options label {
    align-items: center;
    background: var(--body-bg, #fff);
    border: 1px solid var(--hairline-color, #d7e3e9);
    border-radius: 0.55rem;
    cursor: pointer;
    display: flex;
    font-weight: 700;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.65rem;
}

.person-avatar-options label:has(input:checked) {
    background: rgb(121 188 220 / 18%);
    border-color: #235b78;
    box-shadow: 0 0 0 0.12rem rgb(35 91 120 / 16%);
}

.person-avatar-options input {
    accent-color: #235b78;
    margin: 0;
}

.people-ordering-help {
    background: rgb(121 188 220 / 14%);
    border: 1px solid rgb(35 91 120 / 24%);
    border-radius: 0.65rem;
    color: var(--body-fg);
    line-height: 1.45;
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
}

.model-person.change-list #result_list th.sortable a {
    align-items: center;
    display: flex;
    gap: 0.4rem;
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.2em;
}

.model-person.change-list #result_list th.sortable .text a::after {
    align-items: center;
    background: rgb(35 91 120 / 12%);
    border: 1px solid rgb(35 91 120 / 25%);
    border-radius: 999px;
    content: "↕";
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.85rem;
    height: 1.4rem;
    justify-content: center;
    line-height: 1;
    text-decoration: none;
    width: 1.4rem;
}

.model-person.change-list #result_list th.sorted .sortoptions,
.model-person.change-list #result_list th.sorted .sortoptions a,
.model-person.change-list #result_list th.sorted a.sortremove {
    opacity: 1 !important;
    visibility: visible !important;
}

.model-person.change-list #result_list th.sorted .sortoptions {
    align-items: center;
    display: flex;
    gap: 0.25rem;
    min-width: 3.3rem;
}

.model-person.change-list #result_list th.sorted .sortoptions a {
    background-color: rgb(255 255 255 / 72%);
    border: 1px solid rgb(35 91 120 / 25%);
    border-radius: 0.3rem;
}

.field-portrait_preview {
    text-align: center;
}

.portrait-editor {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1rem;
    max-width: 38rem;
}

.portrait-editor__portrait-button {
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    padding: 0;
    position: relative;
}

.portrait-editor__portrait-button:focus-visible {
    outline: 0.2rem solid #235b78;
    outline-offset: 0.25rem;
}

.portrait-editor__camera {
    align-items: center;
    background: #235b78;
    border: 0.16rem solid #fff;
    border-radius: 50%;
    bottom: 0.1rem;
    box-shadow: 0 0.15rem 0.35rem rgb(20 50 67 / 28%);
    color: #fff;
    display: inline-flex;
    font-size: 1rem;
    font-weight: 900;
    height: 2rem;
    justify-content: center;
    line-height: 1;
    position: absolute;
    right: 0.1rem;
    transform: none;
    width: 2rem;
}

.portrait-editor__open-button {
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.portrait-editor__help {
    color: var(--body-quiet-color, #5a6a73);
    flex-basis: 100%;
    line-height: 1.45;
    margin: 0;
}

.portrait-editor__errors,
.portrait-editor-server-errors {
    background: #fff0f0;
    border: 1px solid #c82929;
    border-radius: 0.55rem;
    color: #8c1e1e;
    flex-basis: 100%;
    font-weight: 700;
    padding: 0.65rem 0.8rem;
}

.profile-portrait-section {
    background: rgb(121 188 220 / 12%);
    border: 1px solid rgb(35 91 120 / 22%);
    border-radius: 0.8rem;
    margin: 1.25rem 0;
    padding: 1rem;
}

.profile-portrait-section h2 {
    margin-top: 0;
}

.portrait-editor-dialog {
    background: var(--body-bg, #fff);
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 1.5rem 5rem rgb(18 43 57 / 35%);
    color: var(--body-fg, #24333b);
    max-height: min(90vh, 56rem);
    max-width: min(94vw, 58rem);
    overflow: auto;
    padding: 0;
    width: 58rem;
}

.portrait-editor-dialog::backdrop {
    background: rgb(15 34 45 / 66%);
}

.portrait-editor-dialog__inner {
    padding: clamp(1rem, 3vw, 1.8rem);
}

.portrait-editor-dialog__header {
    align-items: flex-start;
    border-bottom: 1px solid var(--hairline-color, #d7e3e9);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
}

.portrait-editor-dialog__header h2 {
    margin: 0 0 0.25rem;
}

.portrait-editor-dialog__header p {
    color: var(--body-quiet-color, #5a6a73);
    margin: 0;
}

.portrait-editor-dialog__close {
    align-items: center;
    background: transparent;
    border: 1px solid var(--hairline-color, #d7e3e9);
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 2.5rem;
    font-size: 1.5rem;
    height: 2.5rem;
    justify-content: center;
    padding: 0;
}

.portrait-editor-tabs {
    background: rgb(121 188 220 / 12%);
    border-radius: 0.75rem;
    display: grid;
    gap: 0.4rem;
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 1rem;
    padding: 0.35rem;
}

.portrait-editor-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.55rem;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 0.7rem 0.9rem;
}

.portrait-editor-tab[aria-selected="true"] {
    background: var(--body-bg, #fff);
    border-color: rgb(35 91 120 / 25%);
    box-shadow: 0 0.15rem 0.4rem rgb(35 91 120 / 12%);
    color: #235b78;
}

.portrait-editor-panel[hidden] {
    display: none;
}

.portrait-photo-layout,
.portrait-avatar-layout,
.portrait-silhouette-layout {
    align-items: start;
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(17rem, 22rem) minmax(16rem, 1fr);
}

.portrait-photo-workspace,
.portrait-avatar-preview {
    align-items: center;
    background:
        linear-gradient(45deg, #eef3f5 25%, transparent 25%),
        linear-gradient(-45deg, #eef3f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eef3f5 75%),
        linear-gradient(-45deg, transparent 75%, #eef3f5 75%);
    background-position: 0 0, 0 0, 0.6rem 0.6rem, -0.6rem -0.6rem;
    background-size: 1.2rem 1.2rem;
    border: 1px solid var(--hairline-color, #d7e3e9);
    border-radius: 0.9rem;
    display: flex;
    justify-content: center;
    min-height: 23rem;
    padding: 1rem;
}

.portrait-photo-crop {
    background: #dce7ec;
    border: 0.3rem solid #fff;
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgb(35 91 120 / 28%),
        0 0.8rem 2rem rgb(35 91 120 / 18%);
    cursor: grab;
    height: min(72vw, 19rem);
    overflow: hidden;
    position: relative;
    touch-action: none;
    width: min(72vw, 19rem);
}

.portrait-photo-crop:active {
    cursor: grabbing;
}

.portrait-photo-crop img {
    height: 100%;
    left: 50%;
    object-fit: cover;
    object-position:
        calc(50% + var(--portrait-editor-x, 0%))
        calc(50% + var(--portrait-editor-y, 0%));
    position: absolute;
    top: 50%;
    transform:
        translate(-50%, -50%)
        scale(var(--portrait-editor-zoom, 1))
        rotate(var(--portrait-editor-rotation, 0deg));
    transform-origin: center;
    user-select: none;
    width: 100%;
}

.portrait-photo-empty {
    align-items: center;
    color: #53636c;
    display: flex;
    font-weight: 800;
    height: 100%;
    justify-content: center;
    padding: 1rem;
    text-align: center;
}

.portrait-avatar-preview .person-character-avatar {
    filter: drop-shadow(0 0.8rem 1rem rgb(35 91 120 / 18%));
    height: min(72vw, 20rem);
    width: min(72vw, 20rem);
}

.portrait-avatar-preview .person-silhouette-avatar {
    filter: drop-shadow(0 0.8rem 1rem rgb(35 91 120 / 18%));
    height: min(72vw, 20rem);
    width: min(72vw, 20rem);
}

.portrait-avatar-preview-column {
    min-width: 0;
}

.portrait-avatar-credit {
    color: var(--body-quiet-color, #5a6a73);
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 0.6rem 0 0;
    text-align: center;
}

.portrait-avatar-credit a {
    color: #235b78;
}

.portrait-editor-controls {
    display: grid;
    gap: 1rem;
}

.portrait-photo-original {
    background: rgb(121 188 220 / 10%);
    border: 1px solid var(--hairline-color, #d7e3e9);
    border-radius: 0.65rem;
    padding: 0.65rem;
}

.portrait-photo-original strong {
    display: block;
    margin-bottom: 0.45rem;
}

.portrait-photo-original img {
    background: #eef3f5;
    border-radius: 0.45rem;
    display: block;
    max-height: 9rem;
    object-fit: contain;
    width: 100%;
}

.portrait-editor-control {
    border: 0;
    margin: 0;
    padding: 0;
}

.portrait-editor-control legend,
.portrait-editor-control > label {
    display: block;
    font-weight: 800;
    margin-bottom: 0.45rem;
}

.portrait-editor-control input[type="range"] {
    accent-color: #235b78;
    width: 100%;
}

.portrait-editor-control__hint {
    color: var(--body-quiet-color, #5a6a73);
    display: block;
    font-size: 0.88rem;
    line-height: 1.35;
    margin-top: 0.35rem;
}

.portrait-editor-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.portrait-editor-choice-grid {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}

.portrait-editor-choice-grid--visual {
    grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr));
    max-height: 24rem;
    overflow: auto;
    padding: 0.15rem;
}

.portrait-editor-choice {
    align-items: center;
    background: var(--body-bg, #fff);
    border: 1px solid var(--hairline-color, #cbd9df);
    border-radius: 0.55rem;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    gap: 0.45rem;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.45rem 0.55rem;
}

.portrait-editor-choice--visual {
    flex-direction: column;
    min-height: 8.5rem;
    padding: 0.45rem;
}

.portrait-editor-choice__preview {
    background: #eef3f5;
    border-radius: 0.45rem;
    display: block;
    height: 5.75rem;
    object-fit: contain;
    width: 5.75rem;
}

.portrait-editor-choice[aria-pressed="true"] {
    background: rgb(121 188 220 / 20%);
    border-color: #235b78;
    box-shadow: 0 0 0 0.12rem rgb(35 91 120 / 14%);
}

.portrait-editor-swatch {
    border: 1px solid rgb(20 40 50 / 22%);
    border-radius: 50%;
    flex: 0 0 1.25rem;
    height: 1.25rem;
    width: 1.25rem;
}

.portrait-editor-dialog__footer {
    align-items: center;
    border-top: 1px solid var(--hairline-color, #d7e3e9);
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
}

.portrait-editor-dialog__message {
    color: #a32222;
    flex: 1 1 16rem;
    font-weight: 700;
    margin: 0 auto 0 0;
}

.portrait-editor-dialog button {
    min-height: 2.5rem;
}

.inline-related .field-photo,
.inline-related .field-portrait_remove_photo,
.inline-related .field-portrait_mode,
.inline-related .field-photo_zoom,
.inline-related .field-photo_offset_x,
.inline-related .field-photo_offset_y,
.inline-related .field-photo_rotation,
.inline-related .field-avatar_choice,
.inline-related .field-avatar_skin_tone,
.inline-related .field-avatar_eye_color,
.inline-related .field-avatar_hair_color,
.inline-related .field-avatar_hair_variant,
.inline-related .field-avatar_eyes_variant,
.inline-related .field-avatar_mouth_variant,
.inline-related .field-avatar_glasses_variant,
.inline-related .field-avatar_background {
    display: none;
}

.inline-related .field-portrait_editor {
    align-items: flex-start;
}

.inline-related .field-portrait_editor .readonly {
    overflow: visible;
}

@media (max-width: 600px) {
    .person-avatar-options {
        grid-template-columns: 1fr;
    }

    .portrait-photo-layout,
    .portrait-avatar-layout,
    .portrait-silhouette-layout {
        grid-template-columns: 1fr;
    }

    .portrait-editor-dialog {
        border-radius: 0;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        width: 100%;
    }
}
