/* ── In-app legal page (tabs) ── */
.legal-app-page {
    padding: 12px 14px 28px;
    direction: rtl;
}

.legal-app-header {
    margin-bottom: 12px;
}

.legal-tabs {
    display: grid;
    grid-template-columns: 1fr 1.35fr 1fr;
    gap: 6px;
    margin-bottom: 14px;
}

.legal-tab {
    border: none;
    padding: 12px 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: #ededed;
    background: url("/shop/shop-gender.png") center / 100% 100% no-repeat;
    cursor: pointer;
    line-height: 1.35;
    transition: filter 0.15s ease, color 0.15s ease;
}

.legal-tab:hover:not(.is-active) {
    filter: brightness(1.06);
}

.legal-tab.is-active {
    color: #f0c15a;
    background: url("/shop/shop-gender.png") center / 100% 100% no-repeat;
    filter: none;
}

@media (max-width: 360px) {
    .legal-app-page {
        padding: 10px 10px 24px;
    }

    .legal-tabs {
        gap: 4px;
    }

    .legal-tab {
        padding: 10px 4px;
        font-size: 11px;
        line-height: 1.3;
    }
}

.legal-app-body {
    margin-bottom: 70px;
    padding: 4px 2px 8px;
}

.legal-app-body[hidden],
.legal-app-body:not(.is-visible) {
    display: none !important;
}

.legal-app-body.is-visible {
    display: block;
}

.legal-app-loading,
.legal-app-error {
    text-align: center;
    opacity: 0.8;
    padding: 24px 8px;
}

.legal-app-error {
    color: #ffb4b4;
    opacity: 1;
}

.legal-modal-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 16px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.legal-modal-tab {
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: rgba(235, 235, 235, 0.78);
    background: rgba(28, 30, 36, 0.75);
    cursor: pointer;
}

.legal-modal-tab.is-active {
    color: #fff;
    border-color: rgba(224, 184, 58, 0.55);
    background: linear-gradient(180deg, rgba(91, 45, 158, 0.55), rgba(36, 28, 56, 0.9));
    color: #f5d76e;
}

.legal-page {
    align-items: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.legal-page-card {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: linear-gradient(165deg, #1C1C1E 0%, #121213 100%);
    border: 1px solid #2B2B2D;
    padding: 24px 22px 28px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}

.legal-page-header {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.legal-page-back {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.875rem;
    color: #e0474b;
    text-decoration: none;
    font-weight: 600;
}

.legal-page-back:hover {
    text-decoration: underline;
}

.legal-page-header h1 {
    margin: 0;
    font-size: 1.35rem;
    color: #EDEDED;
}

.legal-body,
.legal-modal-body {
    color: #d8d8da;
    font-size: 0.9rem;
    line-height: 1.85;
}

.legal-body h2,
.legal-modal-body h2 {
    margin: 1.35rem 0 0.55rem;
    font-size: 1rem;
    color: #f2f2f2;
}

.legal-body h2:first-child,
.legal-modal-body h2:first-child {
    margin-top: 0;
}

.legal-body p,
.legal-modal-body p {
    margin: 0 0 0.85rem;
}

.legal-body ul,
.legal-modal-body ul {
    margin: 0 0 0.85rem;
    padding-right: 1.25rem;
}

.legal-body li,
.legal-modal-body li {
    margin-bottom: 0.45rem;
}

.legal-updated {
    font-size: 0.78rem;
    color: #888 !important;
    margin-bottom: 1rem !important;
}

.legal-permissions {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.legal-permissions > li {
    margin-bottom: 1.1rem;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.18);
}

.legal-permissions code {
    display: inline-block;
    font-size: 0.78rem;
    color: #c8ecff;
    word-break: break-all;
}

.legal-perm-title {
    display: block;
    margin-top: 4px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #f0f0f0;
}

.legal-permissions p {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #c4c4c8;
    line-height: 1.75;
}

.auth-legal-note {
    margin: 14px 0 14px;
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #A6A6A6;
    text-align: center;
}

.auth-legal-note a,
.auth-legal-note button,
.auth-legal-links a,
.auth-legal-links button {
    color: #d4af37;
    text-decoration: none;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.auth-legal-note a:hover,
.auth-legal-note button:hover,
.auth-legal-links a:hover,
.auth-legal-links button:hover {
    text-decoration: underline;
}

.auth-legal-links {
    margin-top: 18px;
    margin-bottom: 0;
    text-align: center;
    font-size: 0.8125rem;
    color: #888;
}

.auth-legal-sep {
    margin: 0 0.35rem;
    color: #666;
}

.legal-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

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

.legal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(3px);
}

.legal-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, #1C1C1E 0%, #121213 100%);
    border: 1px solid #2B2B2D;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.65);
    overflow: hidden;
}

.legal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.legal-modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
    color: #EDEDED;
}

.legal-modal-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #444;
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.legal-modal-close:hover {
    background: #555;
}

.legal-modal-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.legal-modal-loading {
    padding: 24px;
    text-align: center;
    color: #888;
}

.legal-modal-error {
    padding: 24px;
    text-align: center;
    color: #ffb4b4;
}
