/* Consistent button treatment for tool controls; dimensions stay page-specific. */
body[data-page]:not([data-page="/"]) {
    --tool-button-accent: #254c37;
    --tool-button-accent-text: #254c37;
    --tool-button-hover: #2c6145;
    --tool-button-hover-surface: #f1f6ef;
    --tool-button-soft: #f1f6ef;
    --tool-button-pale: #e8f0e7;
    --tool-button-pale-hover: #dcebdd;
    --tool-button-border: #a9c6ad;
    --tool-button-border-strong: #9cbea1;
    --tool-button-border-soft: #c1d0c4;
}

html[data-extratools-theme="blue"] body[data-page]:not([data-page="/"]) {
    --tool-button-accent: #24588f;
    --tool-button-accent-text: #24588f;
    --tool-button-hover: #2b68a5;
    --tool-button-hover-surface: #f1f6fc;
    --tool-button-soft: #f1f6fc;
    --tool-button-pale: #e8f1fc;
    --tool-button-pale-hover: #dceafa;
    --tool-button-border: #a9c7e6;
    --tool-button-border-strong: #91b5d8;
    --tool-button-border-soft: #c1d5ea;
}

html[data-extratools-theme="red"] body[data-page]:not([data-page="/"]) {
    --tool-button-accent: #983a35;
    --tool-button-accent-text: #983a35;
    --tool-button-hover: #ad453f;
    --tool-button-hover-surface: #fcf2f1;
    --tool-button-soft: #fcf2f1;
    --tool-button-pale: #faeceb;
    --tool-button-pale-hover: #f7dddb;
    --tool-button-border: #e3b9b6;
    --tool-button-border-strong: #d69f9b;
    --tool-button-border-soft: #ebcdca;
}

main :is(
    button:not([role="menuitem"]),
    input[type="button"],
    input[type="reset"],
    input[type="submit"],
    a[role="button"],
    a[class*="button"],
    a[class*="action"],
    a[class*="download-link"]
):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]) {
    box-sizing: border-box !important;
    min-height: 44px !important;
    padding: 9px 14px !important;
    border: 1px solid var(--tool-button-border-soft, #c1d0c4) !important;
    border-radius: 8px !important;
    background-color: var(--paper, #fff) !important;
    color: var(--ink, #28372d) !important;
    box-shadow: none !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    text-decoration: none;
    cursor: pointer !important;
    transform: none !important;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease !important;
}

main :is(
    button:not([role="menuitem"]),
    input[type="button"],
    input[type="reset"],
    input[type="submit"],
    a[role="button"],
    a[class*="button"],
    a[class*="action"],
    a[class*="download-link"]
):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--tool-button-border, #a9c6ad) !important;
    background-color: var(--tool-button-hover-surface, #f1f6ef) !important;
    color: var(--tool-button-accent-text, #254c37) !important;
}

main :is(
    button:not([role="menuitem"]),
    input[type="button"],
    input[type="reset"],
    input[type="submit"],
    a[role="button"],
    a[class*="button"],
    a[class*="action"],
    a[class*="download-link"]
):is([aria-pressed="true"], [aria-selected="true"], .is-active, .active):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):not([role="menuitem"]):not(.primary-button):not(.primary-action):not([class*="--primary"]):not([data-tool-mode-toggle]):not([id="mode-toggle"]):not([id="simple-mode-button"]):not([id="simple-mode-toggle"]):not([id="active-simple-mode-button"]):not([id="active-full-mode-button"]) {
    border-color: var(--tool-button-border-strong, #9cbea1) !important;
    background-color: var(--tool-button-pale, #e8f0e7) !important;
    color: var(--tool-button-accent-text, #254c37) !important;
}

main :is(
    button:not([role="menuitem"]),
    input[type="button"],
    input[type="reset"],
    input[type="submit"],
    a[role="button"],
    a[class*="button"],
    a[class*="action"],
    a[class*="download-link"]
):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):focus-visible {
    outline: 3px solid var(--tool-button-border-strong, #9cbea1) !important;
    outline-offset: 2px !important;
}

main :is(
    button:not([role="menuitem"]),
    input[type="button"],
    input[type="reset"],
    input[type="submit"],
    a[role="button"],
    a[class*="button"],
    a[class*="action"],
    a[class*="download-link"]
):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):is(:disabled, [aria-disabled="true"], .is-disabled, .disabled) {
    cursor: not-allowed !important;
    opacity: 0.55 !important;
}

main :is(
    button.primary-button,
    button.primary-action,
    button[class*="--primary"]:not(.math-button--primary),
    button[data-tool-mode-toggle],
    button[id="mode-toggle"],
    button[id="simple-mode-button"],
    button[id="simple-mode-toggle"],
    button[id="active-simple-mode-button"],
    button[id="active-full-mode-button"],
    a.primary-button,
    a.primary-action,
    a.download-link--zip,
    a[class*="--primary"],
    input[type="submit"]:not([class*="secondary"]):not([class*="danger"]),
    button[type="submit"]:not([class*="secondary"]):not([class*="danger"])
):not(.file-picker):not(.file-button):not(.semantic-file-button):not([data-action="open"]):not([data-action="import"]):not([id^="choose-"]):not([id="html-native-open"]):not([id="site-folder-button"]):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):not([role="menuitem"]) {
    border-color: var(--tool-button-accent, #254c37) !important;
    background-color: var(--tool-button-accent, #254c37) !important;
    color: #fff !important;
    box-shadow: 0 2px 5px rgb(0 0 0 / 16%) !important;
}

main :is(
    button.primary-button,
    button.primary-action,
    button[class*="--primary"]:not(.math-button--primary),
    button[data-tool-mode-toggle],
    button[id="mode-toggle"],
    button[id="simple-mode-button"],
    button[id="simple-mode-toggle"],
    button[id="active-simple-mode-button"],
    button[id="active-full-mode-button"],
    a.primary-button,
    a.primary-action,
    a.download-link--zip,
    a[class*="--primary"],
    input[type="submit"]:not([class*="secondary"]):not([class*="danger"]),
    button[type="submit"]:not([class*="secondary"]):not([class*="danger"])
):not(.file-picker):not(.file-button):not(.semantic-file-button):not([data-action="open"]):not([data-action="import"]):not([id^="choose-"]):not([id="html-native-open"]):not([id="site-folder-button"]):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]):not([role="menuitem"]):hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--tool-button-hover, #2c6145) !important;
    background-color: var(--tool-button-hover, #2c6145) !important;
    color: #fff !important;
}

main :is(
    button.file-picker,
    button.file-button,
    button.semantic-file-button,
    .file-picker,
    .file-button,
    .drop-zone,
    button[id^="choose-"],
    button[id="load-file-button"],
    button[id="load-project"],
    button[id="open-state-button"],
    button[id="html-native-open"],
    button[id="open-file-button"],
    button[id="open-button"],
    button[id="site-folder-button"],
    button[data-action="open"]:not([role="menuitem"]),
    button[data-action="import"]:not([role="menuitem"]),
    label:has(input[type="file"])
):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]) {
    box-sizing: border-box !important;
    border-color: var(--tool-button-border, #a9c6ad) !important;
    background-color: var(--tool-button-soft, #f1f6ef) !important;
    color: var(--tool-button-accent-text, #254c37) !important;
}

main :is(
    .file-picker,
    .file-button,
    .semantic-file-button,
    label:has(input[type="file"])
):not(.drop-zone):not(.site-theme-dot):not(.site-theme-toggle):not([class*="danger"]):not([class*="delete"]):not([data-variant="danger"]) {
    border: 1px solid var(--tool-button-border, #a9c6ad) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    cursor: pointer !important;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease !important;
    transform: none !important;
}

main input[type="file"]::file-selector-button {
    margin-inline-end: 8px;
    padding: 4px 8px;
    border: 1px solid var(--tool-button-border, #a9c6ad);
    border-radius: 6px;
    background-color: var(--tool-button-pale, #e8f0e7);
    color: var(--tool-button-accent-text, #254c37);
    font: inherit;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

main input[type="file"]:hover::file-selector-button {
    border-color: var(--tool-button-border-strong, #9cbea1);
    background-color: var(--tool-button-pale-hover, #dcebdd);
}

main :is(.file-picker, .file-button, .drop-zone):focus-within {
    outline: 2px solid var(--tool-button-border-strong, #9cbea1);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    main :is(
        button,
        input[type="button"],
        input[type="reset"],
        input[type="submit"],
        a[role="button"],
        a[class*="button"],
        a[class*="action"],
        a[class*="download-link"]
    ):not(.site-theme-dot):not(.site-theme-toggle):not([role="menuitem"]) {
        transition: none;
    }

    main input[type="file"]::file-selector-button {
        transition: none;
    }
}



/* Reserve the same footprint for both mode labels, including table tabs. */
body[data-page] :is(button[data-tool-mode-toggle="true"], #active-full-mode-button) {
    box-sizing: border-box !important;
    inline-size: 13rem !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    min-block-size: 2.75rem !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
}
@media (max-width: 760px) {
    body[data-page] .tool-control-layout {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    body[data-page] .tool-control-layout > .site-preferences--toolbar {
        grid-column: 1 !important;
        grid-row: 3 !important;
        justify-self: start;
    }
    body[data-page] [data-tool-mode-group="true"] {
        display: flex !important;
        flex-wrap: wrap !important;
    }
    body[data-page] [data-tool-mode-hint="true"]:not([hidden]) {
        display: block !important;
        flex: 0 0 100% !important;
        inline-size: 100% !important;
        order: 10 !important;
        white-space: normal !important;
        margin-inline: 0 !important;
    }
}
html[data-tool-layout="mobile"] body[data-page] [data-tool-mode-group="true"] {
    display: flex !important;
    flex-wrap: wrap !important;
}
html[data-tool-layout="mobile"] body[data-page] [data-tool-mode-hint="true"]:not([hidden]) {
    display: block !important;
    flex: 0 0 100% !important;
    inline-size: 100% !important;
    order: 10 !important;
    white-space: normal !important;
    margin-inline: 0 !important;
}
