/* =========================
   QUIZ MODAL
========================= */

.quiz-modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.quiz-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.quiz-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 23, 34, 0.72);
    backdrop-filter: blur(6px);
}

.quiz-modal__dialog {
    position: relative;
    z-index: 2;
    width: min(860px, 100%);
    height: min(820px, calc(100vh - 48px));
    background: #ffffff;
    border-radius: 30px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.18);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.quiz-modal.is-open .quiz-modal__dialog {
    transform: translateY(0) scale(1);
}

.quiz-modal__body {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 40px 42px 34px;
    overflow-y: auto;
}

.quiz-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.96);
    color: #222;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.quiz-modal__title {
    margin: 0 0 14px;
    padding-right: 64px;
    font-size: clamp(34px, 4vw, 56px);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.quiz-modal__subtitle {
    margin-bottom: 24px;
    padding-right: 64px;
    font-size: 17px;
    line-height: 1.7;
    color: #6b7280;
    max-width: 650px;
    flex-shrink: 0;
}

.quiz-progress {
    margin-bottom: 28px;
    flex-shrink: 0;
}

.quiz-progress__bar {
    height: 10px;
    border-radius: 999px;
    background: #e9edf5;
    overflow: hidden;
}

.quiz-progress__fill {
    width: 20%;
    height: 100%;
    background: var(--color-accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.quiz-progress__text {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
}

.quiz-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.quiz-step {
    display: none;
    flex: 1;
    min-height: 320px;
}

.quiz-step.is-active {
    display: block;
}

.quiz-step__title {
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.quiz-step__text {
    margin-bottom: 22px;
    font-size: 15px;
    line-height: 1.65;
    color: #6b7280;
    max-width: 560px;
}

.quiz-range-card {
    padding: 26px 26px 20px;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
}

.quiz-range-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.quiz-range-card__label {
    font-size: 15px;
    font-weight: 600;
    color: #6b7280;
}

.quiz-range-card__value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-accent);
}

.quiz-range-card__scale {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #8a93a3;
}

.quiz-range {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    height: 8px;
    border-radius: 999px;
    background: #e3e8f1;
    outline: none;
}

.quiz-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 26px;
    height: 26px;
    border: 4px solid #ffffff;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 6px 18px rgba(60, 76, 109, 0.25);
    cursor: pointer;
}

.quiz-range::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border: 4px solid #ffffff;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 6px 18px rgba(60, 76, 109, 0.25);
    cursor: pointer;
}

.quiz-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.quiz-check {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 16px 18px;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.quiz-check:hover {
    border-color: rgba(60, 76, 109, 0.35);
    transform: translateY(-1px);
}

.quiz-check__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.quiz-check__box {
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(60, 76, 109, 0.35);
    border-radius: 6px;
    background: #fff;
}

.quiz-check__input:checked + .quiz-check__box {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.quiz-check__input:checked + .quiz-check__box::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

.quiz-check__input:checked ~ .quiz-check__text {
    color: var(--color-accent);
    font-weight: 700;
}

.quiz-check__text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
}

.quiz-options {
    display: grid;
    gap: 14px;
}

.quiz-options--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quiz-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 64px;
    padding: 16px 18px;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: #fff;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.quiz-option:hover {
    border-color: rgba(60, 76, 109, 0.35);
    transform: translateY(-1px);
}

.quiz-option.is-selected {
    border-color: rgba(60, 76, 109, 0.45);
    background: rgba(60, 76, 109, 0.06);
    color: var(--color-accent);
    box-shadow: inset 0 0 0 1px rgba(60, 76, 109, 0.12);
}

.quiz-option:focus-visible {
    outline: none;
    border-color: rgba(60, 76, 109, 0.55);
    box-shadow: 0 0 0 4px rgba(60, 76, 109, 0.08);
}

.quiz-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.quiz-field {
    display: grid;
    gap: 8px;
}

.quiz-field__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.quiz-field__input {
    height: 58px;
    padding: 0 18px;
    border: 1px solid var(--color-border);
    border-radius: 16px;
}

.quiz-actions {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 28px;
    flex-shrink: 0;
}

.quiz-actions__btn {
    min-width: 150px;
}

.quiz-actions__btn--back {
    background: #fff;
    color: var(--color-accent);
    border: 1px solid rgba(60, 76, 109, 0.22);
}

.quiz-actions__btn--back:hover {
    background: #f4f7fb;
    border-color: var(--color-accent);
}

.quiz-actions__btn--submit {
    display: none;
}

.quiz-actions-mobile {
    display: none;
    width: 100%;
}

.quiz-actions-mobile__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
}

.quiz-actions-mobile__arrow {
    position: relative;
    display: none;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 1px solid rgba(60, 76, 109, 0.55);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--color-accent);
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
    flex: 0 0 58px;
}

.quiz-actions-mobile__arrow::before {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}

.quiz-actions-mobile__arrow:hover {
    background: #ffffff;
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

.quiz-actions-mobile__submit {
    display: none;
    width: 100%;
}

@media (max-width: 960px) {
    .quiz-modal__dialog {
        width: min(760px, 100%);
        height: min(760px, calc(100vh - 32px));
        border-radius: 24px;
    }

    .quiz-modal__body {
        padding: 32px 26px 26px;
    }

    .quiz-modal__title {
        font-size: 36px;
    }

    .quiz-checks,
    .quiz-form-grid {
        grid-template-columns: 1fr;
    }

    .quiz-step {
        min-height: 280px;
    }
}

@media (max-width: 640px) {
    .quiz-modal {
        align-items: flex-start;
        padding: 8px;
    }

    .quiz-modal__dialog {
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
        margin: 0;
        overflow: hidden;
    }

    .quiz-modal__body {
        height: auto;
        max-height: calc(100dvh - 16px);
        padding: 14px 16px 14px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .quiz-modal__close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }

    .quiz-modal__title {
        margin: 0 0 8px;
        padding-right: 54px;
        font-size: 19px;
        line-height: 1.08;
        letter-spacing: -0.02em;
        max-width: 270px;
    }

    .quiz-modal__subtitle {
        margin-bottom: 12px;
        padding-right: 48px;
        font-size: 13px;
        line-height: 1.4;
        max-width: 100%;
    }

    .quiz-progress {
        margin-bottom: 14px;
    }

    .quiz-progress__bar {
        height: 8px;
    }

    .quiz-progress__text {
        margin-top: 8px;
        font-size: 12px;
    }

    .quiz-form {
        min-height: 0;
    }

    .quiz-step {
        min-height: auto;
        padding-bottom: 0;
    }

    .quiz-step__title {
        font-size: 20px;
        line-height: 1.12;
        margin-bottom: 6px;
    }

    .quiz-step__text {
        margin-bottom: 14px;
        font-size: 14px;
        line-height: 1.45;
    }

    .quiz-range-card {
        padding: 16px 14px 14px;
        border-radius: 16px;
    }

    .quiz-range-card__top {
        margin-bottom: 16px;
    }

    .quiz-range-card__label {
        font-size: 14px;
    }

    .quiz-range-card__value {
        font-size: 20px;
    }

    .quiz-range-card__scale {
        margin-top: 8px;
        font-size: 12px;
    }

    .quiz-checks,
    .quiz-options--compact,
    .quiz-form-grid {
        grid-template-columns: 1fr;
    }

    .quiz-check,
    .quiz-option {
        min-height: 48px;
        padding: 13px 14px;
        border-radius: 14px;
    }

    .quiz-check__text,
    .quiz-option {
        font-size: 14px;
        line-height: 1.4;
    }

    .quiz-field__label {
        font-size: 13px;
    }

    .quiz-field__input {
        min-height: 48px;
        height: 48px;
        border-radius: 14px;
        padding: 0 14px;
        font-size: 14px;
    }

    .quiz-actions {
        margin-top: 12px;
        padding-top: 12px;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 2;
    }

    .quiz-actions__btn {
        display: none !important;
    }

    .quiz-actions-mobile {
        display: block;
        width: 100%;
    }

    .quiz-actions-mobile__nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        width: 100%;
    }

    .quiz-actions-mobile__arrow {
        display: inline-flex;
        width: 48px;
        height: 48px;
        flex: 0 0 48px;
    }

    .quiz-actions-mobile__submit {
        min-height: 48px;
        width: 100%;
    }
}