/* Shared modal shell. The AWS RDS whitelist dialog is the visual baseline. */
:is(
    .rds-whitelist-modal,
    .app-modal,
    .recovery-modal,
    .settings-modal,
    .shell-modal,
    .editor-modal:not(.editor-modal-fullscreen),
    .doc-modal,
    .files-doc-modal,
    .preview-modal
) {
    padding: 20px;
    background: rgba(20, 20, 18, 0.48);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

:is(.doc-modal-backdrop, .files-doc-modal-backdrop) {
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

:is(
    .rds-whitelist-dialog,
    .app-modal-dialog,
    .recovery-modal-dialog,
    .settings-modal-dialog,
    .shell-modal-dialog,
    .doc-modal-dialog,
    .files-doc-modal-dialog,
    .editor-shell:not(.editor-shell-fullscreen),
    .preview-shell
) {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    box-shadow: none;
}

[data-theme='dark'] :is(
    .rds-whitelist-dialog,
    .app-modal-dialog,
    .recovery-modal-dialog,
    .settings-modal-dialog,
    .shell-modal-dialog,
    .doc-modal-dialog,
    .files-doc-modal-dialog
) {
    border-color: var(--line);
    background: var(--surface);
}

:is(
    .rds-whitelist-header,
    .app-modal-header,
    .recovery-modal-header,
    .settings-modal-header,
    .shell-modal-header,
    .doc-modal-header,
    .files-doc-modal-header,
    .editor-shell:not(.editor-shell-fullscreen) > .ws-header,
    .preview-titlebar
) {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
}

:is(
    .rds-whitelist-header h2,
    .app-modal-header h2,
    .recovery-modal-header h3,
    .settings-modal-header h3,
    .shell-modal-header h2,
    .doc-modal-header h3,
    .files-doc-modal-header h3
) {
    margin: 0;
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0;
}

:is(
    .rds-whitelist-close,
    .app-modal-close,
    .doc-modal-close,
    .files-doc-modal-close,
    .preview-close-btn
) {
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid #d4d4d8;
    border-radius: 5px;
    background: #fff;
    color: var(--accent);
    box-shadow: none;
    cursor: pointer;
}

:is(.rds-whitelist-close, .app-modal-close, .preview-close-btn) svg {
    width: 16px;
    height: 16px;
}

:is(.modal-close-btn, .settings-modal-close, .shell-modal-close) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 550;
    line-height: 1.25;
    box-shadow: none;
    cursor: pointer;
}

:is(
    .rds-whitelist-close,
    .app-modal-close,
    .doc-modal-close,
    .files-doc-modal-close,
    .preview-close-btn
):hover:not(:disabled) {
    border-color: #a1a1aa;
    background: #f4f4f5;
    color: var(--accent);
}

:is(.modal-close-btn, .settings-modal-close, .shell-modal-close):hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--surface-soft);
}

.recovery-modal-dialog {
    width: min(448px, 100%);
    max-width: calc(100vw - 40px);
    padding: 0;
}

.rds-whitelist-dialog {
    width: min(448px, 100%);
}

:is(.rds-whitelist-body, .app-modal-body, .recovery-panel, .settings-modal-body, .shell-modal-body) {
    padding: 20px 22px 22px;
}

.recovery-panel {
    display: block;
    border: 0;
    border-radius: 5px;
    background: transparent;
    box-shadow: none;
}

:is(.rds-whitelist-copy, .app-modal-copy, .recovery-modal-copy) {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.55;
}

.app-modal-copy {
    white-space: pre-line;
}

.rds-whitelist-eyebrow,
.settings-modal-header .panel-caption,
.shell-modal-header .panel-caption {
    display: none;
}

.rds-whitelist-address,
.shell-modal-status {
    border-radius: 5px;
}

.rds-whitelist-actions {
    padding: 0 22px 22px;
    border-top: 0;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-modal[hidden] {
    display: none;
}

.app-modal-dialog {
    width: min(448px, 100%);
    max-height: calc(100dvh - 40px);
}

.app-modal-header {
    flex: 0 0 auto;
}

.app-modal-resource {
    display: block;
    margin: 14px 0 0;
    padding: 10px 11px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-soft);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-modal-field[hidden],
.app-modal-resource[hidden] {
    display: none;
}

.app-modal-field {
    margin-top: 18px;
}

.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

:is(
    .rds-whitelist-actions,
    .app-modal-actions,
    .recovery-actions,
    .settings-modal-body .control-buttons,
    .shell-modal-actions
) .btn {
    box-shadow: none;
    transform: none;
}

:is(
    .rds-whitelist-actions,
    .app-modal-actions,
    .recovery-actions,
    .settings-modal-body .control-buttons,
    .shell-modal-actions
) .btn:hover:not(:disabled) {
    box-shadow: none;
    transform: none;
}

.app-modal-actions [hidden] {
    display: none;
}

.doc-modal-dialog,
.files-doc-modal-dialog {
    width: min(1250px, 96vw);
}

.doc-modal-body,
.files-doc-modal-body {
    background: var(--surface);
}

.editor-shell:not(.editor-shell-fullscreen) > .ws-header {
    min-height: 75px;
}

.editor-shell:not(.editor-shell-fullscreen) > .ws-header .ws-project-info strong {
    color: var(--text);
}

.editor-shell:not(.editor-shell-fullscreen) > .ws-header .ws-project-path {
    color: var(--muted);
}

.editor-shell:not(.editor-shell-fullscreen) > .ws-header :is(.editor-btn, .editor-icon-btn) {
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid #d4d4d8;
    border-radius: 5px;
    background: #fff;
    color: var(--accent);
    box-shadow: none;
}

.editor-shell:not(.editor-shell-fullscreen) > .ws-header :is(.editor-btn, .editor-icon-btn):hover:not(:disabled) {
    border-color: #a1a1aa;
    background: #f4f4f5;
    color: var(--accent);
    box-shadow: none;
    transform: none;
}

.preview-titlebar strong {
    color: var(--text);
}

.preview-titlebar .preview-path {
    color: var(--muted);
}

@media (max-width: 720px) {
    :is(
        .rds-whitelist-modal,
        .app-modal,
        .recovery-modal,
        .settings-modal,
        .shell-modal,
        .editor-modal:not(.editor-modal-fullscreen),
        .doc-modal,
        .files-doc-modal,
        .preview-modal
    ) {
        align-items: flex-end;
        padding: 8px;
    }

    :is(
        .rds-whitelist-dialog,
        .app-modal-dialog,
        .recovery-modal-dialog,
        .settings-modal-dialog,
        .shell-modal-dialog,
        .doc-modal-dialog,
        .files-doc-modal-dialog,
        .editor-shell:not(.editor-shell-fullscreen),
        .preview-shell
    ) {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 16px);
        border-radius: 5px;
    }

    :is(.recovery-modal-header, .settings-modal-header, .shell-modal-header) {
        flex-direction: row;
        align-items: flex-start;
    }

    .app-modal-actions,
    .recovery-actions,
    .rds-whitelist-actions,
    .shell-modal-actions {
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
    }

    .editor-shell:not(.editor-shell-fullscreen) > .ws-header {
        flex-wrap: wrap;
    }
}
