/* Formatter-only layout: input → actions → result in DOM and on narrow screens. */
.formatter-page .formatter-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "input output" "actions actions";
    gap: 16px;
    width: 100%;
    max-width: var(--site-content-max, 1120px);
    margin: 0 auto;
    --formatter-editor-height: clamp(260px, 58vh, 540px);
}
.formatter-page .formatter-workspace > :is(.code-editor-column, .code-preview-column) {
    display: flex;
    flex-direction: column;
    float: none !important;
    width: 100%;
    height: var(--formatter-editor-height);
    min-width: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--site-border, #e5e7eb);
    border-radius: 10px;
    background: var(--site-surface, #fff);
}
.formatter-page .formatter-workspace > .code-editor-column {grid-area: input;}
.formatter-page .formatter-workspace > .code-preview-column {grid-area: output;}
.formatter-page .formatter-workspace :is(.code-editor-column, .code-preview-column) > :is(.code-editor, .code-preview) {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    border: 0;
}
.formatter-page .formatter-workspace :is(.code-editor-column, .code-preview-column) > div:not(.code-editor):not(.code-preview) {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 49px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--site-border, #e5e7eb);
    background: var(--site-surface-muted, #f8fafc);
}
.formatter-page .formatter-workspace .code-preview-column > div:not(.code-preview) {justify-content: flex-end;}
.formatter-page .formatter-workspace :is(#btn-load-file, #btn-copy-file, #btn-save-file) {
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 20px;
}
.formatter-page .formatter-actionbar {
    grid-area: actions;
    float: none !important;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--site-border, #e5e7eb);
    border-radius: 10px;
    background: var(--site-surface, #fff);
}
.formatter-page .formatter-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    min-width: 0;
}
.formatter-page .formatter-controls > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 10px 18px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 24px;
    font-weight: 600;
    text-align: center;
    white-space: normal;
}
.formatter-page .formatter-actionbar > .tool-status {margin: 10px 0 0;}
.formatter-page .formatter-actionbar > .tool-status:empty {display: none;}
.formatter-page .formatter-field {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}
.formatter-page .formatter-field > label {
    min-width: 0;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    color: var(--site-text, #111827);
}
.formatter-page .formatter-field-control {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    min-height: 46px;
}
.formatter-page .formatter-field-control > :is(select, input:not([type="checkbox"])) {
    box-sizing: border-box;
    display: block;
    width: 160px;
    min-width: 0;
    max-width: 100%;
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--site-border, #d1d5db);
    border-radius: 7px;
    color: var(--site-text, #111827);
    background-color: var(--site-surface, #fff);
    font-size: 14px;
    line-height: 24px;
}
.formatter-page .formatter-field-control > input:not([type="checkbox"]) {width: 80px;}
.formatter-page .formatter-field-control > select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 34px;
    background-image: var(--site-select-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"));
    background-position: right 10px center;
    background-size: 14px;
    background-repeat: no-repeat;
}
.formatter-page .formatter-field-control > :is(#select-input-syntax, #select-output-syntax, #select-php-version) {width: 112px;}
.formatter-page .formatter-field-control > :is(#select-style, #select-sql-dialect, #select-wrap-attributes, #select-brace-style) {width: 180px;}
.formatter-page .formatter-checkbox-field .formatter-field-control > label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 46px;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--site-text, #111827);
}
.formatter-page .formatter-checkbox-field input {flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--site-accent, #2563eb);}
.formatter-page .formatter-field-help {max-width: 84ch; margin: 8px 0 0; color: var(--site-muted, #6b7280); font-size: 12px; line-height: 1.5;}
/* Keep line numbers adaptive, with a separate slot for the existing fold widget. */
.formatter-page .formatter-workspace .ace_gutter-cell {padding-left: 6px; padding-right: 6px;}
.formatter-page .formatter-workspace .ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}
@media (max-width: 900px) {
    .formatter-page .formatter-workspace {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "input" "actions" "output";
        --formatter-editor-height: 360px;
    }
    .formatter-page .formatter-actionbar {padding: 14px;}
    .formatter-page .formatter-workspace :is(#btn-load-file, #btn-copy-file, #btn-save-file) {min-height: 44px; padding: 10px 12px;}
}
@media (max-width: 640px) {
    .formatter-page .formatter-controls {gap: 10px 12px;}
    .formatter-page .formatter-controls > button {padding-inline: 14px;}
    .formatter-page .formatter-field-control > select {width: 150px;}
    .formatter-page .formatter-field-control > :is(#select-input-syntax, #select-output-syntax, #select-php-version) {width: 112px;}
}
