@media screen and (max-width: 1500px) {
    .ai3d-shell {
        grid-template-columns: 340px minmax(0, 1fr);
    }

    .ai3d-preview-head {
        align-items: flex-start;
    }

    .ai3d-preview-head-metrics {
        min-width: 300px;
    }

    .ai3d-preview-stage-body {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .ai3d-preview-hud {
        max-width: calc(100% - 310px);
    }
}

@media screen and (max-width: 1200px) {
    .ai3d-shell {
        grid-template-columns: 320px minmax(0, 1fr);
    }

    .ai3d-preview-head {
        flex-direction: column;
    }

    .ai3d-preview-head-metrics {
        width: 100%;
        min-width: 0;
    }

    .ai3d-preview-stage {
        min-height: 700px;
    }

    .ai3d-preview-stage-body {
        grid-template-columns: 1fr;
    }

    .ai3d-preview-stage-viewport,
    .ai3d-preview-mount,
    .ai3d-preview-canvas-frame,
    .ai3d-model-viewer {
        min-height: 540px;
    }

    .ai3d-preview-hud {
        max-width: calc(100% - 36px);
    }
}

@media screen and (max-width: 960px) {
    .ai3d-page {
        padding: 12px;
    }

    .ai3d-left {
        position: relative;
        top: auto;
        max-height: none;
    }

    .ai3d-right {
        min-height: auto;
        padding: 12px;
    }

    .ai3d-preview-wrap {
        min-height: auto;
        padding: 18px;
    }

    .ai3d-preview-head-metrics {
        grid-template-columns: 1fr;
    }

    .ai3d-preview-stage {
        min-height: 620px;
        padding: 14px;
    }

    .ai3d-preview-stage-body {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .ai3d-preview-stage-viewport,
    .ai3d-preview-mount,
    .ai3d-preview-canvas-frame,
    .ai3d-model-viewer {
        min-height: 440px;
        height: 440px;
    }

    .ai3d-preview-viewport-card {
        width: calc(100% - 32px);
    }

    .ai3d-preview-stage-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .ai3d-preview-stage-statusline {
        width: 100%;
    }

    .ai3d-preview-tips {
        justify-content: flex-start;
    }
}

.ai3d-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ai3d-right-toolbar {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 112px;
    min-width: 0;
    max-width: 112px;
}

.ai3d-debug-stl-btn {
    /* AI3D_BUTTON_VISIBILITY_GUARD */
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid rgba(138, 162, 204, 0.2);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(18, 24, 35, 0.96), rgba(10, 15, 24, 0.96));
    color: #dbe5f7;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 24px rgba(4, 10, 20, 0.22);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ai3d-debug-stl-btn:hover {
    border-color: rgba(160, 188, 236, 0.3);
    background: linear-gradient(180deg, rgba(22, 30, 44, 0.98), rgba(12, 18, 29, 0.98));
    transform: translateY(-1px);
}

.ai3d-debug-stl-btn:focus {
    outline: none;
}

.ai3d-debug-stl-btn:focus-visible {
    border-color: rgba(120, 179, 255, 0.4);
    box-shadow:
        0 12px 24px rgba(4, 10, 20, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 3px rgba(66, 139, 255, 0.16);
}

.ai3d-render-mode-control {
    /* AI3D_BUTTON_VISIBILITY_GUARD */
    position: relative;
    min-width: 0;
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(138, 162, 204, 0.2);
    background: linear-gradient(180deg, rgba(18, 24, 35, 0.96), rgba(10, 15, 24, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 24px rgba(4, 10, 20, 0.22);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.ai3d-render-mode-control::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(219, 229, 247, 0.92);
    border-bottom: 2px solid rgba(219, 229, 247, 0.92);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.ai3d-render-mode-control:focus-within {
    border-color: rgba(120, 179, 255, 0.4);
    box-shadow:
        0 12px 24px rgba(4, 10, 20, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 3px rgba(66, 139, 255, 0.16);
}

.ai3d-render-mode-select {
    width: 100%;
    min-height: 52px;
    padding: 0 38px 0 14px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #dbe5f7;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    appearance: none;
    -webkit-appearance: none;
    color-scheme: dark;
    cursor: pointer;
}

.ai3d-render-mode-select:focus {
    outline: none;
}

html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control {
    border-color: var(--xl-theme-border, #211c10);
    background: linear-gradient(180deg, var(--xl-theme-panel, #11100d), var(--xl-theme-bg, #0a0a0a));
    color: var(--xl-theme-fg, #e0d9c8);
    text-shadow: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 24px rgba(4, 10, 20, 0.22);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn:hover,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control:focus-within {
    border-color: var(--xl-theme-accent, #d4a843);
    background: linear-gradient(180deg, var(--xl-theme-panel, #11100d), var(--xl-theme-bg, #0a0a0a));
    box-shadow:
        0 12px 24px var(--xl-theme-soft, rgba(80, 142, 255, 0.18)),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn:focus-visible,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control:focus-within {
    box-shadow:
        0 12px 24px var(--xl-theme-soft, rgba(80, 142, 255, 0.18)),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 3px var(--a9-focus-shadow, var(--xl-theme-soft, rgba(80, 142, 255, 0.18)));
}

html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control::after {
    border-right-color: var(--xl-theme-fg, #e0d9c8);
    border-bottom-color: var(--xl-theme-fg, #e0d9c8);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-select {
    color: var(--xl-theme-fg, #e0d9c8);
}

@supports (background: color-mix(in srgb, #000 50%, #fff)) {
html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control {
    border-color: color-mix(in srgb, var(--xl-theme-accent, #d4a843) 34%, var(--xl-theme-border, #211c10));
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--xl-theme-accent, #d4a843) 10%, var(--xl-theme-panel, #11100d)),
            color-mix(in srgb, var(--xl-theme-accent, #d4a843) 4%, var(--xl-theme-bg, #0a0a0a))
        );
    color: color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 94%, #fff);
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 8%, transparent),
        0 12px 24px color-mix(in srgb, var(--xl-theme-accent, #d4a843) 16%, transparent);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn:hover,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control:focus-within {
    border-color: color-mix(in srgb, var(--xl-theme-accent, #d4a843) 52%, var(--xl-theme-border, #211c10));
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--xl-theme-accent, #d4a843) 16%, var(--xl-theme-panel, #11100d)),
            color-mix(in srgb, var(--xl-theme-accent, #d4a843) 8%, var(--xl-theme-bg, #0a0a0a))
        );
    box-shadow:
        0 12px 24px color-mix(in srgb, var(--xl-theme-accent, #d4a843) 20%, transparent),
        inset 0 1px 0 color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 10%, transparent);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-debug-stl-btn:focus-visible,
html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control:focus-within {
    box-shadow:
        0 12px 24px color-mix(in srgb, var(--xl-theme-accent, #d4a843) 20%, transparent),
        inset 0 1px 0 color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 10%, transparent),
        0 0 0 3px color-mix(in srgb, var(--xl-theme-accent, #d4a843) 18%, transparent);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-control::after {
    border-right-color: color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 96%, #fff);
    border-bottom-color: color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 96%, #fff);
}

html[data-theme-preset] body.ai3d-page-active .ai3d-render-mode-select {
    color: color-mix(in srgb, var(--xl-theme-fg, #e0d9c8) 94%, #fff);
}
}

.ai3d-select option,
.ai3d-render-mode-select option,
.ai3d-upload-item-select option {
    background: #0f1726;
    color: #e8f1ff;
}

