.feedback-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: calc(8px * var(--space-scale));
    background: linear-gradient(180deg, var(--accent-bright), var(--accent));
    color: var(--text-strong);
    padding: calc(12px * var(--space-scale)) calc(22px * var(--space-scale));
    border-radius: calc(10px * var(--radius-scale));
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 1000;
    border: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.feedback-button::before {
    content: "\1F4AC";
    font-size: 1.05em;
    line-height: 1;
}

.feedback-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(var(--accent-bright-rgb), 0.45);
}

.popup {
    display: none;
    position: fixed;
    bottom: 70px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    padding: calc(30px * var(--space-scale));
    width: 100%;
    max-width: 400px;
    /* Content (~755px tall) is routinely taller than the viewport -- without a cap
       this fixed-position box just renders past the top of the screen with no way
       to scroll to it. Cap to what actually fits below the 70px bottom anchor. */
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    z-index: 1001;
    opacity: 1;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-sizing: border-box;
    visibility: hidden;
}

.popup.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.popup h1 {
    margin-bottom: calc(20px * var(--space-scale));
    color: var(--text);
    text-align: center;
    font-size: 1.6em;
}

.popup label {
    display: block;
    margin-bottom: calc(10px * var(--space-scale));
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    width: 100%;
}

.popup input,
.popup textarea {
    width: calc(100% - 22px);
    padding: calc(12px * var(--space-scale));
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid var(--border);
    margin-bottom: calc(20px * var(--space-scale));
    font-size: 1rem;
    background: var(--surface-alt);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.popup input:focus,
.popup textarea:focus {
    outline: none;
    border-color: var(--accent-bright);
}

.popup button {
    width: 100%;
}

.popup button.popup-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: color 0.2s ease;
}

.popup button.popup-close-btn:hover {
    color: var(--accent-bright);
    transform: none;
    box-shadow: none;
}

.feedback-disabled-notice {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-bright);
    border-radius: calc(8px * var(--radius-scale));
    padding: calc(12px * var(--space-scale)) calc(14px * var(--space-scale));
    margin-bottom: calc(20px * var(--space-scale));
    color: var(--text-muted);
    font-size: 0.9em;
    line-height: 1.5;
}

.feedback-disabled-notice a {
    font-weight: 600;
}

.notification {
    margin-top: calc(20px * var(--space-scale));
    background: var(--surface-alt);
    color: var(--text);
    padding: calc(14px * var(--space-scale)) calc(20px * var(--space-scale));
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid var(--accent-bright);
    opacity: 0;
    display: none;
    transition: opacity 0.4s ease-out;
    font-weight: 600;
    text-align: center;
}

.notification.show {
    display: block;
    opacity: 1;
    transition: opacity 0.4s ease-in;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
}

.checkbox-container {
    display: flex;
    align-items: center;
    padding: calc(14px * var(--space-scale));
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    margin-bottom: calc(15px * var(--space-scale));
    cursor: pointer;
    transition: border-color 0.2s ease;
    position: relative;
}

.checkbox-container input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.checkbox-container:hover {
    border-color: var(--accent-bright);
}

.checkbox-container input:checked~.label-text {
    color: var(--accent-bright);
    font-weight: 700;
}

.checkbox-container.checked {
    border-color: var(--accent-bright) !important;
    background: var(--surface) !important;
}

.label-text {
    color: var(--text);
    cursor: pointer;
    transition: color 0.2s ease;
}

@media (max-width: 600px) {
    .feedback-button {
        position: relative;
        bottom: auto;
        right: auto;
        display: flex;
        justify-content: center;
        width: calc(100% - 20px);
        font-size: 1.05rem;
        padding: calc(14px * var(--space-scale)) calc(22px * var(--space-scale));
        margin: calc(20px * var(--space-scale)) calc(10px * var(--space-scale)) 0 calc(10px * var(--space-scale));
    }

    .popup {
        width: 90%;
        padding: calc(20px * var(--space-scale));
        bottom: auto;
        top: 50%;
        right: 50%;
        transform: translate(50%, -50%);
        /* Centered here (not bottom-anchored like desktop), so the margin needed
           to stay on-screen is symmetric top and bottom. */
        max-height: calc(100vh - 40px);
    }

    .popup.show {
        transform: translate(50%, -50%);
    }
}

/* Hidden field that only spam bots fill in (never shown to people). */
.popup .hp-field {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Fields added to the pop-up in the form builder (none by default). */
.popup .site-form-field {
    margin: 0 0 calc(20px * var(--space-scale)) 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.popup .site-form-field input,
.popup .site-form-field textarea {
    margin-bottom: 0;
}

.popup .site-form-field select {
    width: 100%;
    padding: calc(12px * var(--space-scale));
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid var(--border);
    font-size: 1rem;
    background: var(--surface-alt);
    color: var(--text);
    font-family: inherit;
}

.popup .site-form-field legend {
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: calc(10px * var(--space-scale));
    padding: 0;
}

.popup .site-form-check {
    display: flex;
    gap: calc(10px * var(--space-scale));
    align-items: center;
    margin-bottom: calc(6px * var(--space-scale));
    font-weight: 400;
    color: var(--text);
}

.popup .site-form-check input {
    width: auto;
    margin: 0;
}

.popup .site-form-required {
    color: var(--accent-bright);
}

.popup .site-form-help {
    color: var(--text-muted);
    font-size: 0.85em;
    margin: calc(6px * var(--space-scale)) 0 0 0;
}
