/* Modal convention: every modal is .modal > .modal-content holding
   .modal-header (title + optional ✕), .modal-body (the only scroll region),
   and .modal-actions. Form modals wrap body+actions in the <form>. Width
   variants: default 500px, .modal-lg for content-heavy bodies. */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--color-backdrop);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--color-surface);
    padding: 30px;
    border-radius: var(--radius-md);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content.modal-lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-lg);
    line-height: 1;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0 4px;
}

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

.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* The scroll region clips on every edge (overflow-y:auto forces overflow-x to
       auto too), so edge-flush controls lose their focus ring / offset shadow.
       This inset gives them room and aligns body content with the header's 0 4px. */
    padding: 4px;
    margin-bottom: 20px;
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

/* Sub-headings inside a modal body; same minor-heading style as the photo
   sidebar's .detail-section h3. */
.modal-section-title {
    margin: 20px 0 10px;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-section-title:first-child {
    margin-top: 0;
}

.modal-message {
    margin: 0;
    white-space: pre-line;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
    margin-top: auto;
}