:host {
    color: var(--text);
    display: contents;
}

dialog {
    box-sizing: border-box;
    width: min(
        var(--app-modal-width, 90vw),
        var(--app-modal-max-width, 600px)
    );
    max-height: var(--app-modal-max-height, 85vh);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    flex-direction: column;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.75);
}

[hidden] {
    display: none !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.2;
}

.modal-close {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    border-color: var(--border);
}

.modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal-body {
    flex: 1 1 auto;
    max-height: 50vh;
    padding: 1rem;
    overflow: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}
