    .#{$prefix}fieldset {
        border: $fieldset-border;
        padding: $fieldset-padding;
        margin: $fieldset-margin;
    }

    // Insane IE bug: Fieldset padding-top is rendered *outside* the border!
    // So we transfer the padding-top to the body element.
    .#{$prefix}ie8m,
    .#{$prefix}quirks .#{$prefix}ie {
        .#{$prefix}fieldset {
            padding-top: 0;
            .#{$prefix}fieldset-body {
                padding-top: top($fieldset-padding);
            }
        }
    }

    .#{$prefix}fieldset-header-checkbox {
        line-height: $fieldset-header-line-height;
        margin: $fieldset-checkbox-margin;
    }

    .#{$prefix}fieldset-header {
        padding: $fieldset-header-padding;

        .#{$prefix}tool {
            margin-top: top($fieldset-collapse-tool-margin);
            padding: $fieldset-collapse-tool-padding;
        }

        @if $form-checkbox-size < $fieldset-collapse-tool-size {
            .#{$prefix}form-cb-wrap {
                padding: round(($fieldset-collapse-tool-size - $form-checkbox-size) / 2) 0;
            }
        }
    }

    .#{$prefix}fieldset-header-text {
        font: $fieldset-header-font;
        color: $fieldset-header-color;
        padding: 1px 0;
    }
    .#{$prefix}fieldset-header-text-collapsible {
        cursor: pointer;
    }

    .#{$prefix}fieldset-with-title {
        .#{$prefix}fieldset-header-checkbox,
        .#{$prefix}tool {
            margin: $fieldset-collapse-tool-margin;
        }
    }

    @if $include-rtl {
        .#{$prefix}fieldset-with-title .#{$prefix}rtl {
            .#{$prefix}fieldset-header-checkbox,
            .#{$prefix}tool {
                margin: rtl($fieldset-collapse-tool-margin);
            }
        }
    }

    // Use Webkit's built-in fieldset legend padding which takes precedence over padding-left/right
    .#{$prefix}webkit {
        .#{$prefix}fieldset-header {
            -webkit-padding-start: #{left($fieldset-header-padding)};
            -webkit-padding-end: #{right($fieldset-header-padding)};
        }
    }

    // opera renders an invisible border above the fieldset in addition to the normal border when the fieldset has a legend.
    // To compensate for this, give the fieldset a negative top margin equal to the top border width.
    @if $include-opera {
        .#{$prefix}opera {
            .#{$prefix}fieldset-with-legend {
                margin-top: -#{top($fieldset-border-width)};
            }
            &.#{$prefix}mac .#{$prefix}fieldset-header-text {
                padding: 2px 0 0;
            }
        }
    }
    // IE8 strict has a problem similar to opera's, except the invisible top border only changes the position of
    // the legend element, so we have to adjust the position of the legend using a negative top margin.
    @if $include-ie {
        .#{$prefix}strict .#{$prefix}ie8 .#{$prefix}fieldset-header {
            margin-bottom: -#{top($fieldset-border-width)};
            .#{$prefix}tool,
            .#{$prefix}fieldset-header-text,
            .#{$prefix}fieldset-header-checkbox {
                position: relative;
                top: -#{top($fieldset-border-width)};
            }
        }
    }

    @if $include-ie {
        .#{$prefix}quirks .#{$prefix}ie,
        .#{$prefix}ie8m {
            .#{$prefix}fieldset-header {
                padding-left: #{left($fieldset-header-padding) - 2};
                padding-right: #{right($fieldset-header-padding) - 2};
            }
        }
    }

    .#{$prefix}fieldset-collapsed {
        .#{$prefix}fieldset-body {
            display: none;
        }
    }

    .#{$prefix}fieldset-collapsed {
        padding-bottom: 0 !important;

        border-width: 1px 1px 0 1px !important;
        border-left-color: transparent !important;
        border-right-color: transparent !important;
    }

    @if $include-ie {
        .#{$prefix}ie6 .#{$prefix}fieldset-collapsed {
            border-width: 1px 0 0 0 !important;

            padding-bottom: 0 !important;
            margin-left: 1px;
            margin-right: 1px;
        }

        .#{$prefix}ie .#{$prefix}fieldset-bwrap {
            zoom: 1;
        }
    }

    .#{$prefix}fieldset {
        .#{$prefix}tool-toggle {
            @if $fieldset-collapse-tool-background-image != null {
                background-image: theme-background-image($fieldset-collapse-tool-background-image);
            }
            background-position: $fieldset-collapse-tool-background-position;
        }
        @if $fieldset-collapse-tool-background-position-over != null {
            .#{$prefix}tool-over .#{$prefix}tool-toggle {
                background-position: $fieldset-collapse-tool-background-position-over;
            }
        }
    }

    .#{$prefix}fieldset-collapsed {
        .#{$prefix}tool-toggle {
            background-position: $fieldset-collapse-tool-background-position-collapsed;
        }

        @if $fieldset-collapse-tool-background-position-collapsed-over != null {
            .#{$prefix}tool-over .#{$prefix}tool-toggle {
                background-position: $fieldset-collapse-tool-background-position-collapsed-over;
            }
        }
    }

    @if $include-ie {
        /* IE legend positioning bug */
        .#{$prefix}ie .#{$prefix}fieldset-noborder legend {
            position: relative;

            margin-bottom: 23px;
        }

        .#{$prefix}ie .#{$prefix}fieldset-noborder legend span {
            position: absolute;
            left: 16px;
        }
    }

    .#{$prefix}fieldset {
        overflow: hidden;
    }

    .#{$prefix}fieldset-bwrap {
        overflow: hidden;

        zoom: 1;
    }

    .#{$prefix}fieldset-body {
        overflow: hidden;
    }