.legal-modal {
    position: fixed;
    inset: 0;
    z-index: 10500; /* above terms-consent (10000) so "read the terms" wins if both are open */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

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

.legal-modal__panel {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.legal-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.legal-modal__tabs {
    display: flex;
    gap: 6px;
}

.legal-modal__tab {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.legal-modal__tab:hover {
    background: #eef2f9;
}

.legal-modal__tab[aria-selected="true"] {
    background: #1a1a2e;
    color: #fff;
}

.legal-modal__close {
    font-size: var(--text-2xl);
    line-height: 1;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.legal-modal__close:hover {
    background: #eef2f9;
    color: #1a1a2e;
}

.legal-modal__body {
    padding: 20px 24px 28px;
    overflow-y: auto;
    color: #222;
    font-size: var(--text-sm);
    line-height: 1.6;
}

.legal-modal__doc[hidden] {
    display: none;
}

.legal-modal__doc h1 {
    font-size: var(--text-xl);
    margin: 0 0 8px;
    color: #1a1a2e;
}

.legal-modal__doc h2 {
    font-size: var(--text-base);
    margin: 22px 0 8px;
    color: #1a1a2e;
}

.legal-modal__doc p,
.legal-modal__doc ul {
    margin: 0 0 12px;
}

.legal-modal__doc ul {
    padding-left: 20px;
}

.legal-modal__doc a {
    color: #2563eb;
}

@media (max-width: 480px) {
    .legal-modal__panel {
        max-height: 90vh;
    }

    .legal-modal__header {
        flex-wrap: wrap;
    }

    .legal-modal__body {
        padding: 16px 18px 22px;
    }
}
