/**
 * Feedback → Formspree. FAB sits bottom-left (saved charts uses bottom-right on narrow viewports).
 */
.feedback-fab {
    position: fixed;
    left: max(16px, env(safe-area-inset-left, 0px));
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    z-index: 10050;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: #2d2d2d;
    color: #fffef7;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.feedback-fab:hover {
    background: #6d8fa3;
}

.feedback-fab:focus-visible {
    outline: 2px solid rgba(109, 143, 163, 0.65);
    outline-offset: 3px;
}

.feedback-fab:active {
    transform: scale(0.96);
}

.feedback-fab-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

.feedback-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10055;
    background: rgba(45, 45, 45, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.feedback-backdrop.is-open {
    display: block;
    opacity: 1;
}

.feedback-modal {
    display: none;
    flex-direction: column;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -48%) scale(0.98);
    z-index: 10060;
    width: min(420px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px));
    overflow: auto;
    box-sizing: border-box;
    padding: 28px 22px 22px;
    background: #fffef7;
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    font-family: 'Montserrat', sans-serif;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.feedback-modal.is-open {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.feedback-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.feedback-modal-close .feedback-close-icon {
    display: block;
    width: 26px;
    height: 26px;
}

.feedback-modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #2d2d2d;
}

.feedback-modal h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 22px;
    font-weight: 600;
    color: #2d2d2d;
    margin: 0 48px 16px 0;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.feedback-modal-intro {
    font-size: 14px;
    line-height: 1.5;
    color: #555;
    margin: 0 0 28px;
    flex-shrink: 0;
}

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

.feedback-form label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d2d2d;
    margin-bottom: 6px;
}

.feedback-form label:first-of-type {
    margin-top: 2px;
}

.feedback-form label.feedback-email-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.feedback-email-label-main {
    font-weight: 600;
    color: #2d2d2d;
}

.feedback-email-label-hint {
    font-weight: 400;
    color: #666;
    line-height: 1.35;
}

.feedback-form input[type='email'],
.feedback-form textarea {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    border: 1px solid #c8c4bc;
    border-radius: 4px;
    background: #fff;
}

.feedback-form textarea {
    min-height: 120px;
    resize: vertical;
    margin-bottom: 10px;
    flex: 0 0 auto;
}

.feedback-form input:focus,
.feedback-form textarea:focus {
    outline: none;
    border-color: #9ec3e2;
    box-shadow: 0 0 0 2px rgba(158, 195, 226, 0.35);
}

.feedback-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.feedback-status {
    font-size: 14px;
    line-height: 1.45;
    min-height: 0;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.feedback-status:not(:empty) {
    min-height: 1.45em;
    margin-bottom: 10px;
}

.feedback-status.feedback-status--error {
    color: #8b2323;
}

.feedback-status.feedback-status--ok {
    color: #1b5e20;
}

.feedback-submit {
    width: 100%;
    padding: 12px 16px;
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    color: #2d2d2d;
    background: #9ec3e2;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.feedback-submit:hover:not(:disabled) {
    background: #8db4d6;
}

.feedback-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (min-width: 769px) {
    .feedback-fab {
        bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
        left: max(20px, env(safe-area-inset-left, 0px));
    }
}

/* Mobile: chart-sized type + larger close (same centered modal placement as desktop) */
@media (max-width: 768px) {
    /* Fit centered sheet when mobile browser chrome / keyboard shrink viewport */
    .feedback-modal {
        max-height: min(
            560px,
            calc(92vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
        );
        max-height: min(
            560px,
            calc(92dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
        );
    }

    .feedback-modal-close {
        width: 52px;
        height: 52px;
        top: 2px;
        right: 4px;
        border-radius: 6px;
    }

    .feedback-modal-close .feedback-close-icon {
        width: 34px;
        height: 34px;
    }

    .feedback-modal h2 {
        font-size: 26px;
        margin-right: 58px;
    }

    .feedback-modal-intro,
    .feedback-form label,
    .feedback-email-label-hint,
    .feedback-form input[type='email'],
    .feedback-form textarea,
    .feedback-form textarea::placeholder,
    .feedback-form input::placeholder,
    .feedback-status {
        font-size: 19px;
        line-height: 1.45;
    }

    .feedback-submit {
        font-size: 16px;
        padding: 14px 18px;
    }

    .feedback-form input[type='email'],
    .feedback-form textarea {
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .feedback-modal-intro,
    .feedback-form label,
    .feedback-email-label-hint,
    .feedback-form input[type='email'],
    .feedback-form textarea,
    .feedback-form textarea::placeholder,
    .feedback-form input::placeholder,
    .feedback-status {
        font-size: 17px;
    }
}
