.contributor-frame-settings {
    display: grid;
    gap: .75rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
    background: color-mix(in srgb, var(--panel-2) 78%, transparent);
}

.contributor-frame-settings[hidden] {
    display: none;
}

.contributor-frame-settings > strong {
    font-size: 1rem;
}

.host-avatar-frame-settings-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.host-avatar-frame-settings-row > .host-avatar-field {
    grid-column: auto;
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 1rem;
    row-gap: .75rem;
}

.host-avatar-frame-settings-row > .host-avatar-field > span:first-child {
    grid-column: 1;
    grid-row: 1;
}

.host-avatar-frame-settings-row > .host-avatar-input-row {
    grid-column: 2;
    grid-row: 1;
}

.host-avatar-frame-settings-row > .host-avatar-field > .host-avatar-input-row {
    grid-column: 2;
    grid-row: 1;
}

.host-avatar-frame-settings-row > .host-avatar-field > .host-avatar-frame-preview {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
}

.host-avatar-frame-settings-row > .contributor-frame-settings {
    min-width: 0;
    height: 100%;
    box-sizing: border-box;
}

.host-avatar-frame-preview {
    --host-avatar-frame-preview-inset: 0px;
    position: relative;
    display: block;
    width: 13rem;
    height: 13rem;
    margin-top: 0rem;
    flex: 0 0 auto;
}

.host-avatar-frame-preview[hidden] {
    display: none;
}

.host-avatar-frame-preview > .host-avatar-preview {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: none;
    padding: var(--host-avatar-frame-preview-inset);
    margin: 0;
    object-fit: cover;
    border-radius: 50%;
}

.host-settings-page .host-avatar-frame-preview > .host-avatar-preview {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.host-avatar-frame-preview-overlay {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    z-index: 2;
}

.host-avatar-frame-preview-overlay[hidden] {
    display: none;
}

.contributor-frame-choice {
    display: grid;
    gap: .35rem;
}

.contributor-frame-choice-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

.contributor-frame-cycle-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    flex: 0 0 44px;
}

.contributor-frame-choice-preview {
    width: 5rem;
    height: 5rem;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.contributor-frame-status {
    min-height: 1.25em;
    color: var(--muted);
}

.contributor-frame-option-grid {
    max-height: min(65vh, 38rem);
    overflow-y: auto;
}

.contributor-frame-option {
    aspect-ratio: 1;
    background: color-mix(in srgb, var(--panel-2) 88%, transparent);
}

.contributor-frame-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.contributor-frame-option.is-selected {
    outline: 3px solid var(--red-bright);
    outline-offset: -3px;
}

.contributor-frame-owner {
    position: relative;
}

.contributor-avatar-frame-overlay {
    position: absolute;
    display: block;
    width: 0;
    height: 0;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    z-index: 20;
}

.contributor-frame-owner .contributor-frame-avatar-source {
    box-sizing: border-box;
    padding: var(
        --contributor-frame-scaled-avatar-inset,
        var(--contributor-frame-avatar-inset, 0px));
}

/* Uploaded images and webcam surfaces keep their existing rectangular layout,
 * but the visible pixels are clipped to the exact circular opening of the
 * square frame. The radius is calculated from the filename-native inset. */
.contributor-frame-owner[data-avatar-frame] .contributor-frame-clipped-media {
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    clip-path: circle(var(--contributor-frame-clip-radius, 0px) at 50% 50%) !important;
    overflow: hidden;
    object-fit: cover !important;
}

/* The Player Lobby gives the media preview its own blue circular shell.
 * Once a contributor frame is active that shell is redundant and must not
 * show through behind the decorative frame. */
.player-avatar-control.contributor-frame-owner[data-avatar-frame] > .player-avatar-current {
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Keep avatar-picker titles and close buttons visible while only the picker body scrolls. */
.avatar-picker-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.avatar-picker-card > .dialog-heading {
    flex: 0 0 auto;
    margin: 0;
    padding: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.avatar-picker-card > [data-avatar-category-step],
.avatar-picker-card > [data-avatar-list-step],
.avatar-picker-card > .contributor-frame-option-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 20px;
}

.avatar-picker-card > .contributor-frame-option-grid {
    max-height: none;
}

@media (max-width: 700px) {
    .host-avatar-frame-settings-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .avatar-picker-card > .dialog-heading,
    .avatar-picker-card > [data-avatar-category-step],
    .avatar-picker-card > [data-avatar-list-step],
    .avatar-picker-card > .contributor-frame-option-grid {
        padding: 12px;
    }

    .avatar-picker-card > .dialog-heading {
        padding-bottom: 10px;
    }
}
