body.modalOpen {
    overflow: hidden;
}

.preferencesOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(13, 32, 45, 0.72);
}

.preferencesOverlay[hidden] {
    display: none !important;
}

.preferencesPanel {
    width: min(560px, 100%);
    max-height: calc(100dvh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.preferencesPanelHeader {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    align-items: center;
    padding: 24px 24px 12px;
}

.preferencesClose {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-size: 18px;
    color: #181c20;
    cursor: pointer;
    text-align: left;
}

.preferencesTitle {
    margin: 0;
    text-align: center;
    color: #00696b;
    font-size: 28px;
    font-weight: 700;
}

.preferencesForm {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.preferencesBody {
    overflow-y: auto;
    padding: 0 24px 20px;
}

.preferencesSubtitle {
    margin: 12px 0 8px;
    font-size: 24px;
    font-weight: 800;
    color: #181c20;
}

.preferencesIntro {
    margin: 0 0 20px;
    font-size: 16px;
    color: #8a8f98;
}

.preferencesField {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.preferencesField > label {
    font-size: 15px;
    font-weight: 800;
    color: #181c20;
}

.textInput {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 18px;
    background: #f3f9ff;
    padding: 0 18px;
    font: inherit;
    font-size: 16px;
    color: #181c20;
}

.textInput:focus {
    outline: 2px solid #00696b;
}

.preferencesGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.preferencesChoiceList {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 20px;
    background: #f3f9ff;
}

.preferencesChoice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 16px;
    color: #181c20;
}

.preferencesChoice:hover {
    background: #e7f2f7;
}

.preferencesChoiceInput {
    width: 18px;
    height: 18px;
    accent-color: #00696b;
}

.preferenceCheckRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    padding: 16px 18px;
    border-radius: 20px;
    background: #f3f9ff;
}

.preferenceCheckText {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preferenceCheckText strong {
    font-size: 16px;
    color: #181c20;
}

.preferenceCheckText span {
    font-size: 14px;
    color: #8a8f98;
}

.preferenceCheckbox {
    width: 26px;
    height: 26px;
    accent-color: #00696b;
    flex-shrink: 0;
}

.preferencesActions {
    position: sticky;
    bottom: 0;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
    background: #ffffff;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.06);
}

.preferencesSubmit {
    width: 100%;
    min-height: 56px;
    border: 0;
    border-radius: 20px;
    background: #00696b;
    color: #ffffff;
    font: inherit;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
}

.preferencesErrors {
    color: #d24e42;
    font-size: 13px;
}

@media (max-width: 768px) {
    .preferencesOverlay {
        align-items: flex-end;
        padding: 0;
    }

    .preferencesPanel {
        width: 100%;
        max-height: 92dvh;
        border-radius: 32px 32px 0 0;
    }

    .preferencesPanelHeader {
        grid-template-columns: 64px 1fr 64px;
        padding: 22px 20px 10px;
    }

    .preferencesTitle {
        font-size: 24px;
    }

    .preferencesBody {
        padding: 0 20px 18px;
    }

    .preferencesSubtitle {
        font-size: 22px;
    }

    .preferencesGrid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .preferencesActions {
        padding-inline: 20px;
    }
}

body.modalOpen {
    overflow: hidden;
}

.preferencesOverlay {
    z-index: 9999;
}

.preferencesPanel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100dvh - 48px);
    padding: 0;
}

.preferencesForm {
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0;
}

.preferencesBody {
    min-height: 0;
    overflow-y: auto;
    padding: 0 24px 20px;
}

.preferencesActions {
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
    background: white;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.06);
}

.preferencesSubmit {
    width: 100%;
    min-height: 56px;
    margin-top: 0;
}

@media (max-width: 768px) {
    .preferencesPanel {
        max-height: 92dvh;
    }

    .preferencesBody {
        padding: 0 20px 18px;
    }

    .preferencesActions {
        padding-inline: 20px;
    }
}

.preferencesContent {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preferencesContent > .preferencesForm {
    min-height: 0;
    flex: 1;
}

.preferencesForm {
    min-height: 0;
    flex: 1;
}

.preferencesBody {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
}

.preferencesActions {
    flex-shrink: 0;
    z-index: 1;
}

#imagePreferences {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid transparent;
}

/* Keep the preferences overlay above the fixed bottom navigation on mobile. */
body.modalOpen .navbar,
body.modalOpen .transparentNavbar {
    z-index: 1201;
}

body.modalOpen .bottomNav {
    z-index: 1100;
}

@media (max-width: 768px) {
    .preferencesActions {
        padding-bottom: calc(
            16px + env(safe-area-inset-bottom) + var(--bottom-nav-height)
        );
    }
}

.preferencesSubmit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.preferencesFieldError {
    margin-top: 0.35rem;
    color: #b42318;
    font-size: 0.85rem;
    line-height: 1.3;
}

.preferencesFieldError:empty {
    display: none;
}