.page-legal .logo-link {
    text-decoration: none !important;
    color: var(--jiilna-logo-color, #000000) !important;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.page-legal .logo-link:hover {
    color: var(--jiilna-logo-hover, #333333) !important;
}

.legal-page-main {
    padding: 120px 10% 80px;
    min-height: 60vh;
    background: #fff;
}

.legal-page-shell {
    max-width: 960px;
    margin: 0 auto;
}

.legal-page-header {
    margin-bottom: 40px;
    border-bottom: 1px solid #eee;
    padding-bottom: 24px;
}

.legal-page-title {
    font-size: clamp(28px, 4vw, 42px);
    color: #005a6a;
    line-height: 1.2;
    margin: 0 0 12px;
    font-weight: 800;
}

.legal-page-meta {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.legal-version {
    color: #999;
}

.legal-page-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 48px;
    direction: ltr;
}

.legal-toc {
    flex: 0 0 280px;
    width: 280px;
    max-width: 280px;
}

.legal-prose {
    flex: 1 1 auto;
    min-width: 0;
}

/* Arabic — prose left, TOC box pinned to the right */
.legal-page-layout--ar .legal-prose {
    order: 1;
    direction: rtl;
    text-align: right;
}

.legal-page-layout--ar .legal-toc {
    order: 2;
    direction: rtl;
    text-align: right;
}

.legal-page-layout--ar .legal-prose h2,
.legal-page-layout--ar .legal-prose h3,
.legal-page-layout--ar .legal-prose p,
.legal-page-layout--ar .legal-prose li {
    text-align: right;
}

html[dir="rtl"] body.page-legal,
html[lang="ar"] body.page-legal {
    text-align: right;
}

html[dir="rtl"] .legal-page-header,
html[dir="rtl"] .legal-page-title,
html[dir="rtl"] .legal-page-meta,
html[lang="ar"] .legal-page-header,
html[lang="ar"] .legal-page-title,
html[lang="ar"] .legal-page-meta {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .legal-toc-list a,
html[lang="ar"] .legal-toc-list a,
.legal-page-layout--ar .legal-toc-list a {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] .legal-prose {
    direction: ltr;
    text-align: left;
}

.legal-toc {
    position: sticky;
    top: 100px;
    padding: 20px 18px;
    background: #f9f9f9;
    border-radius: 16px;
    border: 1px solid #eee;
    max-width: 280px;
}

.legal-toc-title {
    font-size: 14px;
    color: #005a6a;
    margin: 0 0 14px;
    font-weight: 700;
}

html[lang="ar"] .legal-toc-title,
html[dir="rtl"] .legal-toc-title {
    letter-spacing: 0;
    text-transform: none;
}

.legal-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
    line-height: 1.55;
}

.legal-toc-list li {
    margin-bottom: 10px;
}

.legal-toc-list a {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.legal-toc-num {
    flex-shrink: 0;
    min-width: 1.4em;
    color: #005a6a;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.legal-toc-label {
    flex: 1;
    min-width: 0;
}

.legal-toc-list a:hover,
.legal-toc-list a:focus {
    color: #005a6a;
}

.legal-toc-list a:hover .legal-toc-label,
.legal-toc-list a:focus .legal-toc-label {
    text-decoration: underline;
}

.legal-prose {
    font-size: 16px;
    line-height: 1.85;
    color: #333;
    word-wrap: break-word;
}

.legal-prose h2 {
    font-size: 22px;
    color: #005a6a;
    margin: 32px 0 12px;
    font-weight: 700;
    scroll-margin-top: 100px;
    line-height: 1.45;
    word-break: normal;
    overflow-wrap: anywhere;
}

.legal-prose h3 {
    font-size: 18px;
    color: #005a6a;
    margin: 24px 0 10px;
}

.legal-prose p {
    margin: 0 0 16px;
}

.legal-prose ul,
.legal-prose ol {
    margin: 0 0 16px;
    padding-inline-start: 24px;
}

.legal-prose a {
    color: #005a6a;
    text-decoration: underline;
}

.legal-prose a:focus {
    outline: 2px solid #005a6a;
    outline-offset: 2px;
}

.footer-section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #999;
    margin: 0 0 12px;
}

.footer-legal-col .footer-link {
    margin-bottom: 8px;
}

footer .footer-grid {
    grid-template-columns: 2fr 1fr 1.4fr 1fr;
}

@media (max-width: 900px) {
    .legal-page-layout {
        flex-direction: column;
    }

    .legal-page-layout--ar .legal-prose,
    .legal-page-layout--ar .legal-toc {
        order: unset;
        width: 100%;
        max-width: none;
        flex: 1 1 auto;
    }

    .legal-toc {
        position: static;
        flex: 1 1 auto;
        width: 100%;
        max-width: none;
    }

    .legal-page-main {
        padding: 100px 6% 60px;
    }

    footer .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    footer .footer-grid {
        grid-template-columns: 1fr;
        text-align: start;
    }

    .footer-legal-col {
        margin-top: 8px;
    }
}
