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

.ombox-modal {
    --ombox-modal-gutter: 16px;
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    box-sizing: border-box;
    place-items: center;
    padding: var(--ombox-modal-gutter);
    padding-left: max(var(--ombox-modal-gutter), env(safe-area-inset-left, 0px));
    padding-right: max(var(--ombox-modal-gutter), env(safe-area-inset-right, 0px));
}

.ombox-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.ombox-modal-panel {
    position: relative;
    z-index: 1;
    width: min(640px, 100%);
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    max-height: calc(100vh - 2 * var(--ombox-modal-gutter));
    max-height: min(720px, calc(100dvh - 32px));
    box-sizing: border-box;
    overflow: auto;
    overflow-wrap: anywhere;
    background: var(--color-white, #fff);
    border-radius: var(--radius-lg, 10px);
    box-shadow: var(--shadow-xl);
}

.ombox-modal-sm .ombox-modal-panel {
    width: min(420px, 100%);
}

.ombox-modal-md .ombox-modal-panel {
    width: min(640px, 100%);
}

.ombox-modal-lg .ombox-modal-panel {
    width: min(860px, 100%);
}

.ombox-modal-xl .ombox-modal-panel {
    width: min(1080px, 100%);
}

.ombox-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4, 16px) var(--space-5, 24px);
    border-bottom: var(--border-width-thin) solid var(--color-border);
}

.ombox-modal-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
}

.ombox-modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xl);
    cursor: pointer;
}

.ombox-modal-body {
    padding: var(--space-5, 24px);
}

.ombox-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4, 16px) var(--space-5, 24px);
    border-top: var(--border-width-thin) solid var(--color-border);
}

body.eye-protection .ombox-modal-panel {
    background: #faf8f3;
    border-color: #d9cbb8;
}

.ombox-modal-close-row { display: flex; justify-content: flex-end; padding: 8px 12px 0; }
.ombox-modal-close { min-width: 44px; min-height: 44px; flex-shrink: 0; }
.ombox-modal-close-guard { padding: 16px 24px; border-top: 1px solid var(--color-border, #dbe3ec); background: var(--color-white, #fff); }
.ombox-modal-close-guard[hidden], .ombox-modal-close-guard [hidden] { display: none; }
.ombox-modal-close-guard p { margin: 0 0 12px; }
.ombox-modal-close-guard [data-modal-discard-actions] { display: flex; flex-wrap: wrap; gap: 12px; }
.ombox-modal-close-guard button { min-height: 44px; }
.ombox-modal-footer { flex-wrap: wrap; }
body.eye-protection .ombox-modal-close-guard { background: #faf8f3; }
@media (max-width: 640px) {
    .ombox-modal { --ombox-modal-gutter: 12px; }
    .ombox-modal-panel { max-height: calc(100dvh - 24px); }
    .ombox-modal-body, .ombox-modal-header, .ombox-modal-footer, .ombox-modal-close-guard { padding: 16px; }
}
