:root {
  --bg: #faf8f4; --surface: #ffffff; --ink: #1d1b17; --muted: #6d675d; --line: #e7e1d6;
  --accent: #b4532a; --accent-ink: #ffffff; --accent-soft: rgba(180, 83, 42, .09);
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 8px 24px rgba(40, 30, 10, .06);
  --font-display: 'Fraunces', 'Noto Naskh Arabic', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans JP', Georgia, serif;
  --font-ui: 'Inter', 'Noto Naskh Arabic', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px; --topbar: 64px;
}
[data-theme="dark"] {
  --bg: #14120f; --surface: #1d1a16; --ink: #ece7dc; --muted: #a39c8e; --line: #2e2a24;
  --accent: #e8946a; --accent-ink: #1b1209; --accent-soft: rgba(232, 148, 106, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
html[lang="ar"], html[lang="ur"] { --font-display: 'Noto Naskh Arabic', 'Fraunces', serif; --font-ui: 'Noto Naskh Arabic', 'Inter', system-ui, sans-serif; }
html[lang="ur"] { --font-display: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif; --font-ui: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', system-ui, sans-serif; }
html[lang="ur"] .prose { line-height: 2.3; }
html[lang="ur"] .card h3, html[lang="ur"] .hero h2 { line-height: 1.9; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { padding-bottom: 52px; margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.6 var(--font-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: inherit; }
img { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ── top bar ── */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; height: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 14px; }
.brand { direction: ltr; display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 1.3rem/1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; }
.brand img { border-radius: 9px; display: block; }
.search { margin-inline-start: auto; position: relative; flex: 0 1 300px; display: flex; align-items: center; }
.search svg { position: absolute; inset-inline-start: 13px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 14px; padding-inline-start: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; outline: none; transition: border-color .15s, box-shadow .15s; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.lang-wrap { display: flex; align-items: center; justify-content: center; gap: 4px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); }
.lang-wrap > svg { display: block; flex: 0 0 18px; }
.lang-wrap select { text-align: center; text-align-last: center; }
.lang-wrap select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer; padding: 0 2px; max-width: 120px; color: var(--ink); outline: none; }
.lang-wrap select option { color: #1d1b17; }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; cursor: pointer; color: var(--ink); transition: border-color .15s, transform .1s; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(.94); }
.menu-btn { display: none; }
[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }

/* ── layout ── */
.layout { width: 100%; max-width: 1240px; margin: 0 auto; padding: 16px 20px 24px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 44px; flex: 1 0 auto; align-items: stretch; }
.main { min-width: 0; }
.sidebar { position: sticky; top: calc(var(--topbar) + 16px); align-self: start; height: calc(100vh - var(--topbar) - 32px); min-height: 0; display: flex; flex-direction: column; padding-inline-end: 18px; padding-bottom: 14px; overflow-y: auto; overscroll-behavior: contain; }
.topics-empty { margin: 0; padding: 8px 18px; color: var(--muted); font-size: .9rem; }
.sidebar-search { display: none; }
.side-title { margin: 0 0 18px; font: 600 .74rem/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
html[lang="ar"] .side-title, html[lang="ur"] .side-title, html[lang="hi"] .side-title, html[lang="bn"] .side-title { letter-spacing: 0; text-transform: none; font-size: .9rem; }
.topic-list { display: flex; flex-direction: column; gap: 2px; }
.topic-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 18px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 500; transition: background .12s; }
.topic-list a:hover { background: var(--accent-soft); }
.topic-list a.active { background: var(--accent); color: var(--accent-ink); }
.topic-list .n { font-size: .78rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.topic-list a.active .n { color: inherit; opacity: .8; }
.about { margin-top: auto; padding-top: 14px; padding-bottom: 14px; border-top: 1px solid var(--line); flex-shrink: 0; }
.about .side-title { margin-bottom: 10px; }
.about p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.7; }

/* ── home ── */
.intro { margin-bottom: 30px; }
.intro h1 { margin: 0 0 8px; font: 700 clamp(2rem, 4.6vw, 3.1rem)/1.1 var(--font-display); letter-spacing: -.025em; }
.intro p { margin: 0; color: var(--muted); font-size: 1.1rem; max-width: 52ch; }
.page-title { margin: 0 0 24px; font: 700 clamp(1.6rem, 3.4vw, 2.2rem)/1.15 var(--font-display); letter-spacing: -.02em; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-title small { font: 500 .95rem var(--font-ui); color: var(--muted); }

.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; text-decoration: none; box-shadow: var(--shadow); margin-bottom: 30px; transition: transform .2s, border-color .2s; }
.hero:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.hero .cover { min-height: 300px; }
.hero .body { padding: 34px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.hero h2 { margin: 0; font: 700 clamp(1.5rem, 2.8vw, 2.1rem)/1.2 var(--font-display); letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; transition: transform .2s, box-shadow .2s, border-color .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card .cover { aspect-ratio: 16 / 10; }
.card .body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card h3 { margin: 0; font: 700 1.2rem/1.3 var(--font-display); letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: .94rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cover { background-size: cover; background-position: center; background-color: var(--accent-soft); position: relative; }
.cover.ph { display: grid; place-items: center; font: 700 4rem/1 var(--font-display); color: color-mix(in srgb, var(--accent) 55%, transparent); background-image: radial-gradient(circle at 20% 15%, var(--accent-soft), transparent 60%), linear-gradient(135deg, var(--accent-soft), transparent); }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: .82rem; color: var(--muted); margin-top: auto; }
.chip { display: inline-block; align-self: flex-start; padding: 4px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 600; text-decoration: none; }
.dot::before { content: '·'; margin-inline-end: 12px; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ── post ── */
.post { max-width: 740px; margin: 0 auto; }
.crumbs { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 22px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.crumbs:hover { color: var(--accent); }
[dir="rtl"] .crumbs svg { transform: scaleX(-1); }
.post h1 { margin: 12px 0 14px; font: 700 clamp(2rem, 5vw, 3rem)/1.12 var(--font-display); letter-spacing: -.025em; }
.post .lede { margin: 0 0 18px; font-size: 1.2rem; color: var(--muted); line-height: 1.6; }
.post .meta { margin: 0 0 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.post .hero-img { width: 100%; border-radius: 18px; margin: 0 0 32px; display: block; box-shadow: var(--shadow); }
.notice { margin: 0 0 22px; padding: 11px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; }
.post-foot { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ── skeleton ── */
.skel { border-radius: var(--radius); background: linear-gradient(100deg, var(--accent-soft) 30%, transparent 50%, var(--accent-soft) 70%); background-size: 300% 100%; animation: sh 1.3s linear infinite; min-height: 280px; border: 1px solid var(--line); }
@keyframes sh { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ── footer / toast ── */
.footer { direction: ltr; position: fixed; inset-inline: 0; bottom: 0; z-index: 25; background: var(--bg); margin-top: auto; border-top: 1px solid var(--line); padding: 8px 18px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px; color: var(--muted); font-size: .88rem; }
.footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--accent); }
.toast { position: fixed; inset-inline: 0; bottom: 24px; margin: auto; width: max-content; max-width: 90vw; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: .9rem; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; z-index: 60; }
.toast.show { opacity: 1; transform: none; }
.scrim { display: none; }

/* ── mobile ── */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding-top: 12px; padding-bottom: 20px; }
  .menu-btn { display: grid; }
  .topbar { z-index: 55; }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: auto; inset-inline-start: 0; width: min(310px, 86vw); height: 100vh; height: 100dvh; max-height: none; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; padding: calc(var(--topbar) + 14px) 18px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-inline-end: 1px solid var(--line); transform: translateX(-102%); transition: transform .25s ease; }
  [dir="rtl"] .sidebar { transform: translateX(102%); }
  .search--desktop { display: none; }
  .sidebar-search { display: block; margin: 0 0 18px; }
  .sidebar-search .search { width: 100%; min-width: 0; margin: 0; flex: 1 1 auto; }
  .sidebar-search .search input { height: 44px; }
  body.menu-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .hero { grid-template-columns: 1fr; }
  .hero .cover { min-height: 0; aspect-ratio: 16 / 9; }
  .hero .body { padding: 22px; }
}
@media (max-width: 640px) {
  body { padding-bottom: 76px; }
  .footer { padding: 6px 18px calc(6px + env(safe-area-inset-bottom)); gap: 6px 16px; font-size: .82rem; }
  .topbar-in { padding: 0 12px; gap: 8px; min-width: 0; }
  .brand { min-width: 0; flex: 1 1 auto; font-size: 1.1rem; }
  .brand span { min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
  .lang-wrap { flex: 0 1 auto; min-width: 0; padding-inline: 8px; }
  .lang-wrap select { width: clamp(50px, 18vw, 74px); max-width: 74px; }
  .prose { font-size: 1.04rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* cover images */
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; margin: 0; border-radius: 0; }
.cover:not(.ph) { background-image: none; }


/* Keep CMS-entered text stable while the interface language changes (including Arabic/Urdu). */
#brandName, #topicList, #aboutBox, #aboutText, #footerText, #footerLinks,
.intro, .intro h1, .intro p, .card, .hero, .page-title, .post {
  direction: ltr;
  text-align: left;
}
.topic-list a, .topic-list a > span, #aboutTitle, #aboutText, #footerText, #footerLinks,
#brandName, .card h3, .card p, .hero h2, .hero p, .post h1, .post .lede, .post .prose {
  direction: ltr;
  text-align: left;
}
.infinite-sentinel { width: 100%; height: 1px; pointer-events: none; }

@media (max-width: 920px) {
  .sidebar { top: 0; height: 100vh; height: 100dvh; padding: calc(var(--topbar) + 14px) 18px calc(14px + env(safe-area-inset-bottom)); }
}
