/* Dialog, Window and popup surfaces. */
.yess-theme-host .k-overlay,
.yess-theme-host .k-dialog-wrapper .k-overlay,
.yess-theme-host .k-window-wrapper .k-overlay {
    background: var(--yess-overlay-backdrop);
}

.yess-theme-host .k-window,
.yess-theme-host .k-dialog {
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
    border: var(--yess-control-border-width) solid var(--yess-popup-border);
    border-radius: var(--yess-radius-lg);
    background: var(--yess-popup-background);
    color: var(--yess-popup-foreground);
    box-shadow: var(--yess-popup-shadow);
    overflow: hidden;
}

.yess-theme-host .k-window-titlebar,
.yess-theme-host .k-dialog-titlebar {
    min-height: var(--yess-control-height-lg);
    padding: var(--yess-space-3) var(--yess-space-4);
    border-color: var(--yess-color-border);
    background: var(--yess-color-surface-subtle);
    color: var(--yess-color-text);
}

.yess-theme-host .k-window-title,
.yess-theme-host .k-dialog-title {
    color: var(--yess-color-text);
    font-size: var(--yess-font-size-lg);
    font-weight: 700;
}

.yess-theme-host .k-window-titlebar-actions,
.yess-theme-host .k-dialog-titlebar-actions {
    display: flex;
    align-items: center;
    gap: var(--yess-space-1);
}

.yess-theme-host .k-window-titlebar .k-button,
.yess-theme-host .k-dialog-titlebar .k-button {
    min-width: var(--yess-target-size-minimum);
    min-height: var(--yess-target-size-minimum);
    border-color: transparent;
    border-radius: var(--yess-control-radius);
    background: transparent;
    color: var(--yess-color-text);
}

.yess-theme-host .k-window-titlebar .k-button:hover:not(.k-disabled),
.yess-theme-host .k-dialog-titlebar .k-button:hover:not(.k-disabled) {
    background: var(--yess-navigation-item-hover);
    color: var(--yess-color-primary);
}

.yess-theme-host .k-window-content,
.yess-theme-host .k-dialog-content {
    padding: var(--yess-space-5);
    border-color: var(--yess-color-border);
    background: var(--yess-color-surface);
    color: var(--yess-color-text);
    overflow: auto;
}

.yess-theme-host .k-dialog-actions,
.yess-theme-host .k-window-actions,
.yess-theme-host .k-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--yess-space-2);
    min-height: var(--yess-control-height-lg);
    padding: var(--yess-space-3) var(--yess-space-4);
    border-color: var(--yess-color-border);
    background: var(--yess-color-surface-subtle);
    color: var(--yess-color-text);
}

.yess-theme-host .k-window-titlebar .k-button:focus-visible,
.yess-theme-host .k-dialog-titlebar .k-button:focus-visible {
    outline: var(--yess-control-focus-width) solid var(--yess-color-focus);
    outline-offset: var(--yess-control-focus-offset);
    box-shadow: none;
}

@media (max-width: 40rem) {
    .yess-theme-host .k-window,
    .yess-theme-host .k-dialog {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .yess-theme-host .k-dialog-actions,
    .yess-theme-host .k-window-actions,
    .yess-theme-host .k-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .yess-theme-host .k-dialog-actions .k-button,
    .yess-theme-host .k-window-actions .k-button,
    .yess-theme-host .k-actions .k-button {
        width: 100%;
    }
}

@media (forced-colors: active) {
    .yess-theme-host .k-window,
    .yess-theme-host .k-dialog,
    .yess-theme-host .k-window-titlebar,
    .yess-theme-host .k-dialog-titlebar,
    .yess-theme-host .k-window-content,
    .yess-theme-host .k-dialog-content {
        border-color: CanvasText;
        background: Canvas;
        color: CanvasText;
        forced-color-adjust: auto;
    }
}

/* Central modal scrolling contract. Keeps long module forms/wizards usable without module-specific overflow rules. */
.yess-theme-host .k-window.yess-modal {
    display: flex;
    flex-direction: column;
}

.yess-theme-host .k-window.yess-modal .k-window-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.yess-modal-content {
    display: flex;
    flex-direction: column;
    gap: var(--yess-space-4);
    min-width: 0;
}
