body:has(#mod-operator.active) {
    height: var(--operator-viewport-height, 100dvh);
}

/* viewport-fit=cover applies to the whole OS document. */
body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

/* Keep the existing mobile navigation reserve as well as the safe area. */
@media (max-width: 600px), (max-height: 500px) {
    body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
    .topbar .nav-tabs {
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

#mod-operator { min-height: 0; min-width: 0; }

.operator-embed {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

#operator-frame {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
    border: 0;
    background: var(--bg);
}

#operator-frame[hidden] { display: none; }

.operator-embed-state {
    position: absolute;
    inset: var(--space-6);
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-3);
    min-height: 0;
    overflow: auto;
    padding: var(--space-7);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--bg-card);
    text-align: center;
}

.operator-embed-state[hidden] { display: none; }
.operator-embed-state strong { font-size: var(--font-section); }
.operator-embed-state small { max-width: 440px; color: var(--text-dim); line-height: var(--line-body); }
.operator-embed-state[data-state="error"] strong { color: var(--status-error-text); }
.operator-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: operator-spin .8s linear infinite;
}

@keyframes operator-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .operator-spinner { animation: none; border-top-color: var(--border); } }
@media (max-width: 760px), (max-height: 560px) {
    .operator-embed-state { inset: var(--space-4); padding: var(--space-5); }
    body:has(#mod-operator.active) .topbar button { min-height: 40px; min-width: 40px; }
    .operator-embed-state .bp-button { min-height: 40px; }
}
.operator-native-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    color: var(--text);
}
.operator-native-controls > strong { flex-basis: 100%; font-size: var(--font-body); }
.operator-native-controls[hidden] { display: none; }
.operator-native-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.operator-native-controls .bp-button { min-height: 40px; }
#ws-overlay:has(.operator-native-controls:not([hidden])) .workspace-close {
    min-width: 40px;
    min-height: 40px;
}
.operator-native-controls small {
    color: var(--text-dim);
    font-size: var(--font-caption);
    line-height: var(--line-body);
    overflow-wrap: anywhere;
}
