:root {
    --ink: #231d18;
    --muted: #6f655d;
    --paper: #fffdfa;
    --paper-soft: #fff8f2;
    --paper-deep: #f8eee5;
    --accent: #e47a4d;
    --accent-deep: #c95d35;
    --accent-soft: rgba(228, 122, 77, 0.12);
    --line: rgba(88, 56, 31, 0.12);
    --line-strong: rgba(88, 56, 31, 0.18);
    --shadow-lg: 0 28px 80px rgba(111, 73, 45, 0.12);
    --shadow-md: 0 18px 48px rgba(111, 73, 45, 0.10);
    --radius-xl: 34px;
    --radius-lg: 26px;
    --radius-md: 20px;
    --radius-sm: 15px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top, rgba(228, 122, 77, 0.10), transparent 34%),
        linear-gradient(180deg, #fffdfa 0%, #fff7f1 100%);
    -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body { font-family: "Cairo", sans-serif; }
html[lang="en"] body { font-family: "Manrope", sans-serif; }

a { color: inherit; }
img { max-width: 100%; display: block; }

.shell {
    width: min(1140px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(14px);
    background: rgba(255, 250, 246, 0.82);
    border-bottom: 1px solid rgba(88, 56, 31, 0.08);
}

.topbar-inner {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(140deg, #ef8d66, #d76339);
    box-shadow: 0 14px 28px rgba(211, 99, 57, 0.24);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost-link,
.app-link {
    text-decoration: none;
    border-radius: 999px;
    padding: 11px 18px;
    font-size: 0.95rem;
    font-weight: 800;
}

.ghost-link {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    color: var(--muted);
}

.app-link {
    color: white;
    background: var(--accent);
    box-shadow: 0 16px 30px rgba(228, 122, 77, 0.24);
}

.library-hero {
    padding: 46px 0 28px;
}

.hero-panel {
    padding: clamp(24px, 4vw, 42px);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(88, 56, 31, 0.08);
    background:
        radial-gradient(circle at top left, rgba(228, 122, 77, 0.14), transparent 38%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(251, 244, 237, 0.96));
    box-shadow: var(--shadow-lg);
}

.hero-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(280px, 0.82fr);
    gap: 24px;
    align-items: stretch;
}

.hero-kicker,
.section-kicker,
.article-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 0.82rem;
    font-weight: 900;
}

.hero-title,
.section-title,
.article-title {
    margin: 18px 0 14px;
    line-height: 1.02;
    letter-spacing: -0.04em;
}

html[lang="en"] .hero-title,
html[lang="en"] .section-title,
html[lang="en"] .article-title,
html[lang="en"] .cta-band h2 {
    font-family: "Fraunces", serif;
}

html[lang="ar"] .hero-title,
html[lang="ar"] .section-title,
html[lang="ar"] .article-title,
html[lang="ar"] .cta-band h2 {
    font-family: "Cairo", sans-serif;
}

.hero-title {
    font-size: clamp(2.1rem, 4.5vw, 4.3rem);
    max-width: 12ch;
}

.hero-copy,
.section-copy,
.article-intro,
.cta-band p {
    margin: 0;
    color: var(--muted);
    line-height: 1.95;
}

.hero-copy { max-width: 60ch; }

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 26px;
}

.hero-note-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 26px;
}

.hero-note {
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(88, 56, 31, 0.08);
    background: rgba(255, 255, 255, 0.72);
}

.hero-note strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.98rem;
}

.hero-note span {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.72;
}

.hero-aside {
    display: grid;
    gap: 14px;
    align-self: stretch;
}

.hero-aside-card {
    border-radius: 24px;
    border: 1px solid rgba(88, 56, 31, 0.08);
    background: rgba(255, 255, 255, 0.82);
    padding: 20px;
}

.hero-aside-card strong {
    display: block;
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.hero-aside-card p,
.hero-aside-card li {
    margin: 0;
    color: var(--muted);
    line-height: 1.85;
}

.hero-aside-card ul {
    margin: 0;
    padding-inline-start: 18px;
}

.section {
    padding: 28px 0;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
}

.section-title {
    margin: 10px 0 0;
    font-size: clamp(1.7rem, 3vw, 2.8rem);
}

.section-copy { max-width: 62ch; }

.editorial-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: 20px;
    align-items: start;
}

.stack-grid {
    display: grid;
    gap: 18px;
}

.post-card {
    position: relative;
    display: grid;
    gap: 18px;
    align-content: start;
    text-decoration: none;
    color: inherit;
    padding: 22px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(88, 56, 31, 0.08);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 54px rgba(111, 73, 45, 0.14);
}

.post-card::before {
    content: "";
    position: absolute;
    inset: auto auto 0 -40px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(228, 122, 77, 0.12), transparent 70%);
    pointer-events: none;
}

.post-card--featured {
    min-height: 0;
    align-self: start;
    padding: clamp(24px, 4vw, 34px);
    background:
        radial-gradient(circle at top left, rgba(228, 122, 77, 0.14), transparent 34%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(255, 247, 241, 0.96));
}

.card-chip-row,
.meta-row,
.article-chip-row,
.article-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(88, 56, 31, 0.08);
    background: rgba(255, 255, 255, 0.82);
    font-size: 0.82rem;
    font-weight: 800;
}

.chip.is-type {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.chip.is-scope {
    color: var(--muted);
}

.meta-row {
    color: var(--muted);
    font-size: 0.9rem;
}

.meta-row span,
.article-meta-row span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 248, 242, 0.82);
    border: 1px solid rgba(88, 56, 31, 0.08);
}

.post-title {
    margin: 0;
    font-size: clamp(1.25rem, 2.3vw, 2.1rem);
    line-height: 1.12;
}

html[lang="en"] .post-title,
html[lang="en"] .catalog-card h3,
html[lang="en"] .article-section h2,
html[lang="en"] .aside-card h3,
html[lang="en"] .takeaways h2,
html[lang="en"] .faq-inline h2 {
    font-family: "Fraunces", serif;
}

html[lang="ar"] .post-title,
html[lang="ar"] .catalog-card h3,
html[lang="ar"] .article-section h2,
html[lang="ar"] .aside-card h3,
html[lang="ar"] .takeaways h2,
html[lang="ar"] .faq-inline h2 {
    font-family: "Cairo", sans-serif;
    font-weight: 800;
}

html[lang="ar"] .post-title,
html[lang="ar"] .catalog-card h3 {
    line-height: 1.18;
}

.post-card--featured .post-title {
    font-size: clamp(1.9rem, 3.2vw, 3.2rem);
    max-width: 22ch;
    text-wrap: balance;
}

html[lang="ar"] .post-card--featured .post-title {
    max-width: 19ch;
    line-height: 1.14;
}

.post-card--featured .post-excerpt {
    max-width: 60ch;
}

.post-excerpt {
    margin: 0;
    color: var(--muted);
    line-height: 1.88;
}

.post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(88, 56, 31, 0.08);
}

.post-cta {
    color: var(--accent-deep);
    font-weight: 900;
}

.post-hint {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.catalog-card {
    display: grid;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    border-radius: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(88, 56, 31, 0.08);
}

.catalog-card h3 {
    margin: 0;
    font-size: 1.22rem;
    line-height: 1.24;
}

html[lang="ar"] .catalog-card h3 {
    line-height: 1.3;
}

.catalog-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.82;
    font-size: 0.95rem;
}

.cta-band {
    padding: 30px 0 56px;
}

.cta-band-inner {
    padding: clamp(24px, 4vw, 40px);
    border-radius: 30px;
    background: linear-gradient(135deg, #fff1e8, #fffdfb);
    border: 1px solid rgba(88, 56, 31, 0.08);
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
}

.cta-band h2 {
    margin: 0 0 10px;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    line-height: 1.08;
}

.cta-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.article-page {
    padding: 36px 0 22px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.article-head-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.72fr);
    gap: 22px;
    align-items: stretch;
    margin-bottom: 22px;
}

.article-head-card,
.article-summary-card,
.article-content-card,
.aside-card {
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(88, 56, 31, 0.08);
    box-shadow: var(--shadow-md);
}

.article-head-card {
    padding: clamp(24px, 4vw, 38px);
    background:
        radial-gradient(circle at top left, rgba(228, 122, 77, 0.12), transparent 34%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(255, 247, 241, 0.96));
}

.article-summary-card {
    padding: 22px;
    display: grid;
    align-content: start;
    gap: 16px;
}

.article-summary-card h2,
.takeaways h2,
.faq-inline h2 {
    margin: 0;
    font-size: 1.2rem;
}

.article-summary-card p,
.article-summary-card li,
.aside-card p,
.aside-card li {
    color: var(--muted);
    line-height: 1.85;
}

.article-summary-card ul,
.aside-card ul,
.takeaways ul,
.article-section ul {
    margin: 0;
    padding-inline-start: 20px;
}

.article-title {
    font-size: clamp(2rem, 4vw, 4rem);
    max-width: 13ch;
}

.article-intro {
    max-width: 62ch;
}

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
}

.article-content-card {
    padding: clamp(24px, 4vw, 38px);
}

.takeaways {
    padding: 20px 22px;
    border-radius: 24px;
    background: linear-gradient(180deg, #fff8f2, #fffdf9);
    border: 1px solid rgba(88, 56, 31, 0.08);
    margin-bottom: 24px;
}

.takeaways p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.88;
}

.article-section {
    padding: 22px 0;
    border-top: 1px solid rgba(88, 56, 31, 0.08);
}

.article-section:first-of-type {
    padding-top: 0;
    border-top: none;
}

.article-section h2 {
    margin: 0 0 12px;
    font-size: 1.52rem;
    line-height: 1.22;
}

.article-section p {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 2;
}

.aside-stack {
    display: grid;
    gap: 16px;
    align-self: start;
    position: sticky;
    top: 90px;
}

.aside-card {
    padding: 20px;
}

.aside-card h3 {
    margin: 0 0 12px;
    font-size: 1.08rem;
}

.related-list {
    display: grid;
    gap: 10px;
}

.related-item {
    text-decoration: none;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 248, 242, 0.82);
    border: 1px solid rgba(88, 56, 31, 0.08);
    font-weight: 800;
}

.faq-inline {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid rgba(88, 56, 31, 0.08);
}

.faq-inline details {
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: 18px;
    background: rgba(255, 248, 242, 0.76);
    border: 1px solid rgba(88, 56, 31, 0.08);
}

.faq-inline summary {
    cursor: pointer;
    font-weight: 900;
}

.faq-inline p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.82;
}

.footer {
    padding: 18px 0 56px;
    color: var(--muted);
    font-size: 0.92rem;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 22px;
    border-top: 1px solid rgba(88, 56, 31, 0.08);
}

.footer-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
}

@media (max-width: 1080px) {
    .catalog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .hero-panel-grid,
    .editorial-grid,
    .cta-band-inner,
    .article-head-grid,
    .article-layout {
        grid-template-columns: 1fr;
    }

    .aside-stack {
        position: static;
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100%, calc(100% - 20px));
    }

    .topbar-inner {
        padding: 10px 0;
        align-items: flex-start;
    }

    .hero-note-grid,
    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .hero-title,
    .article-title {
        max-width: none;
    }

    .post-card,
    .catalog-card,
    .hero-panel,
    .article-head-card,
    .article-summary-card,
    .article-content-card,
    .aside-card,
    .cta-band-inner {
        border-radius: 24px;
    }

    .post-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
