/* =====================================================================
   هوية الحرمين — نظام التصميم
   ===================================================================== */
@font-face { font-family: 'Haramain Arabic'; src: url('/assets/arabic-regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Haramain Arabic'; src: url('/assets/arabic-medium.ttf') format('truetype'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: 'Haramain Arabic'; src: url('/assets/arabic-bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  /* هوية النسخة الأولى: الداكن هو الأصل، والفاتح اختياري */
  --gold: #bc9661;
  --gold-2: #b29c65;
  --ink: #1a232d;
  --panel: #1f2a37;
  --bg: #1a232d;
  --surface: #222e3b;
  --soft: #2c3846;
  --text: #ffffff;
  --muted: #c0c7ce;
  --border: #44505c;
  --field: #1a232d;
  --accent-text: #d5bd87;
  --ok: #7fc79a; --ok-bg: #1f3a2b;
  --warn: #f0c27a; --warn-bg: #3d2f18;
  --bad: #ff9a94; --bad-bg: #43201f;
  --info-bg: #2c3846;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: none;
  --font: 'Haramain Arabic', 'IBM Plex Sans Arabic', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff; --surface: #ffffff; --soft: #f5f4f1; --text: #1f2a37; --muted: #62686f;
  --border: #d8dadd; --field: #ffffff; --accent-text: #7b5d31;
  --ok: #2d6846; --ok-bg: #e4efe7; --warn: #9a5b12; --warn-bg: #f8ecd9; --bad: #a3322b; --bad-bg: #f7e1df; --info-bg: #eef0f3;
  --shadow: 0 1px 2px rgb(16 21 27 / 6%), 0 4px 16px rgb(16 21 27 / 5%);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.8 var(--font); }
img { max-width: 100%; }
a { color: var(--accent-text); }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--gold); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { inset-inline-start: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--ink); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- الترويسة (شعار الهيئة | شعار الرئاسة، ثم اسم المنصة) ---------- */
.topbar { background: var(--ink) url('/assets/pattern.png') center; color: #fff; border-bottom: 1px solid #b29c6566; }
.topbar .inner { max-width: 1440px; margin: 0 auto; min-height: 74px; padding: 10px 24px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 22px; color: #fff; text-decoration: none; }
.identity-logos { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.identity-logos img { object-fit: contain; filter: brightness(0) invert(1); }
.identity-logos .authority { width: 94px; height: 50px; }
.identity-logos .presidency { width: 75px; height: 50px; }
.identity-logos .sep { display: block; width: 1px; height: 42px; background: #b5b6b2; }
.brand-copy { border-inline-start: 1px solid #b29c6570; padding-inline-start: 22px; }
.brand-copy b { display: block; font-size: 1.15rem; color: #fff; line-height: 1.5; }
.brand-copy span { display: block; font-size: .875rem; color: #d5bd87; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; text-align: end; }
.topbar .who small { display: block; color: #d1c8b5; }
.topbar .btn { border-color: #b29c6566; color: #fff; background: #ffffff0c; border-radius: 99px; }
.topbar .btn:hover { background: rgb(255 255 255 / 10%); }
@media (max-width: 800px) {
  .topbar .inner { padding: 12px 18px; gap: 12px; }
  .brand { gap: 12px; }
  .brand-copy { border: 0; padding: 0; }
  .brand-copy b { font-size: 1rem; }
  .identity-logos .authority { width: 83px; height: 45px; }
  .identity-logos .presidency { width: 67px; height: 45px; }
  .topbar .who { display: none; }
}
@media (max-width: 520px) { .brand-copy span { display: none; } }

/* ---------- التذييل ---------- */
footer.site { background: var(--ink) url('/assets/pattern.png') center; color: #c9c5ba; border-top: 1px solid #b29c654d; font-size: .875rem; }
footer.site .inner { max-width: 1440px; margin: 0 auto; padding: 20px 24px; display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }

.env-flag { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: .8rem; padding: 4px 12px; }

/* ---------- التخطيط: قائمة جانبية بعرض 225 ---------- */
.layout { max-width: 1488px; margin: 0 auto; display: grid; grid-template-columns: 225px minmax(0, 1fr); align-items: stretch; min-height: calc(100vh - 150px); }
.sidenav { background: var(--bg); border-inline-end: 1px solid var(--border); padding: 22px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidenav a { display: block; padding: 10px 14px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .9375rem; border-inline-start: 3px solid transparent; }
.sidenav a:hover { background: var(--soft); }
.sidenav a[aria-current="page"] { background: #bc966126; color: var(--accent-text); border-inline-start-color: var(--gold); font-weight: 600; }
.layout > main { padding: 28px; }
main { min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .grow { flex: 1; min-width: 220px; }
.eyebrow { color: var(--accent-text); font-size: .85rem; font-weight: 600; margin-bottom: 2px; }
@media (max-width: 650px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { flex-direction: row; flex-wrap: wrap; gap: 5px; padding: 12px; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .sidenav a { flex: 1 1 130px; font-size: .875rem; text-align: center; }
  .layout > main { padding: 18px 14px; }
}

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
:is(.grid, .grid-2, .kpis, .portal-grid) > .card { margin-top: 0; }
.card h3 { margin-bottom: 10px; }
.stack { display: grid; gap: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; }
.kpi b { display: block; font-size: 1.8rem; line-height: 1.2; color: var(--accent-text); }
.kpi span { font-weight: 600; }
.kpi small { display: block; color: var(--muted); font-size: .8rem; }
.kpi.bad { border-top-color: var(--bad); } .kpi.bad b { color: var(--bad); }
.kpi.warn { border-top-color: var(--warn); }
.kpi.ok { border-top-color: var(--ok); }

/* ---------- الأزرار والحقول ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); border-color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a232d; }
.btn.primary:hover { background: #cfad7d; }
.btn.pill { border-radius: 99px; }
.btn.danger { color: var(--bad); border-color: currentColor; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 36px; padding: 4px 14px; font-size: .875rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
label.field > small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; min-height: 46px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: 2px solid color-mix(in srgb, var(--gold) 35%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--gold); }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.err { color: var(--bad); font-size: .88rem; }
.form-errors { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-sm); padding: 10px 14px; }
.form-errors ul { margin: 0; padding-inline-start: 18px; }

/* ---------- الشارات والجداول ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: .8rem; font-weight: 600; background: var(--info-bg); color: var(--text); white-space: nowrap; }
.badge.gold { background: #bc96612b; color: var(--accent-text); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
/* الجداول على الشاشات الضيقة: كل صف بطاقة، وكل خلية معنونة */
@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.responsive td { display: grid; grid-template-columns: 110px 1fr; gap: 8px; border: 0; padding: 4px 12px; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
}
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- شريط المراحل ---------- */
.stages { display: flex; gap: 6px; flex-wrap: wrap; }
.stage { flex: 1 1 120px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--soft); font-size: .85rem; min-width: 110px; }
.stage b { display: block; }
.stage .who { color: var(--muted); }
.stage.done { background: var(--ok-bg); border-color: transparent; }
.stage.active { background: var(--surface); border: 2px solid var(--gold); }
.stage.late .when { color: var(--bad); font-weight: 600; }
.progress { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.late { color: var(--bad); }
.timer.soon { color: var(--warn); }

/* ---------- المحرر ---------- */
.editor { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--field); }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--soft); border-radius: var(--radius-sm) var(--radius-sm) 0 0; position: sticky; top: 0; z-index: 3; }
.tools button, .tools select { min-height: 32px; padding: 2px 8px; font-size: .85rem; width: auto; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-family: inherit; }
.tools button.b { font-weight: 700; } .tools button.i { font-style: italic; } .tools button.u { text-decoration: underline; } .tools button.s { text-decoration: line-through; }
.tools .color input { width: 34px; min-height: 32px; padding: 2px; border-radius: 6px; }
.tools .sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.editor.plain .area { min-height: 260px; padding: 14px; outline: none; line-height: 1.9; font-size: 1.02rem; }
.editor .area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor.plain.readonly .area { background: var(--soft); }
.editor.paged { border: 0; background: transparent; }
.editor.paged .tools { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }

.editor-foot { text-align: center; margin-top: 6px; }
.editor .area table, .lh-body table, .print-body table { border-collapse: collapse; width: 100%; margin: .5em 0; }
.editor .area td, .editor .area th, .lh-body td, .lh-body th, .print-body td, .print-body th { border: 1px solid currentColor; padding: .25em .5em; vertical-align: top; min-width: 2em; }
.lh-body th, .print-body th { background: rgb(188 150 97 / 18%); }
.lh-body hr, .print-body hr { border: 0; border-top: 1px solid #bc9661; margin: 1em 0; }
.source-text { background: var(--soft); border-radius: var(--radius-sm); padding: 14px; line-height: 2; max-height: 70vh; overflow: auto; }

/* ---------- صفحة A4 على الكليشة: مساحة كتابة ثابتة موحّدة ----------
   الصفحة 210×297مم، والكتابة داخل صندوق: أعلى 38 أسفل 32 جانبان 20 (انظر page.js).
   --pt نقطة طباعة واحدة بمقياس عرض الصفحة، فتطابق الأحجامُ الطباعةَ. */
.a4 { position: relative; width: 100%; aspect-ratio: 210 / 297; container-type: inline-size; background: #fff; color: #111; box-shadow: 0 2px 14px rgb(0 0 0 / 35%); border-radius: 2px; overflow: hidden; }
.lh-page::before { content: ''; position: absolute; inset: 0; background: url('/assets/letterhead.jpg') center / 100% 100% no-repeat; pointer-events: none; }
.lh-body { --pt: calc(100cqw / 595.28); position: absolute; top: calc(38 / 297 * 100%); bottom: calc(32 / 297 * 100%); inset-inline: calc(20 / 210 * 100%);
  overflow-y: auto; overscroll-behavior: contain; font-size: calc(var(--pt) * 12); line-height: 1.8; scrollbar-width: thin; }
.lh-body .area { min-height: 100%; outline: none; padding-bottom: 1em; }
.lh-body p, .print-body p { margin: 0 0 .6em; }
.lh-body h2, .print-body h2 { font-size: 1.35em; margin: .4em 0; } .lh-body h3, .print-body h3 { font-size: 1.15em; margin: .4em 0; }
.lh-body blockquote, .print-body blockquote { margin: .4em 2em; }
.a4 .area:empty::before { color: #9aa1a8; }
.editor.readonly .lh-body { cursor: default; }

/* بطاقة البيانات أعلى مساحة الترجمة: صفّان بعرض الصفحة، عرض كل عمود بحسب بيانه */
table.data-card { border-collapse: collapse; table-layout: auto; width: 100%; margin: 0 0 1.1em; font-size: .88em; line-height: 1.45; direction: rtl; text-align: center; user-select: none; }
table.data-card th, table.data-card td { border: 1px solid #bc9661; padding: .35em .5em; vertical-align: middle; text-align: center; }
table.data-card th { background: rgb(188 150 97 / 16%); color: #8a6835; font-weight: 700; white-space: nowrap; letter-spacing: .2px; }
table.data-card td { color: #111; }
.print-body table.data-card { font-size: 10pt; }

/* عارض الأصل */
.pdf-viewer { outline: none; user-select: none; -webkit-user-select: none; }
.pdf-page { background: #fff; }
.pdf-canvas { display: block; width: 100%; height: 100%; }
.pdf-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.pdf-count { font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }

/* تحديد مواضع التعديل على أصل الخطبة (ملاحظة ٢٨) */
.pdf-stage { position: relative; width: 100%; height: 100%; }
.pdf-viewer.drawing .pdf-stage { cursor: crosshair; touch-action: none; }
.pdf-marks { position: absolute; inset: 0; pointer-events: none; }
.pdf-marks .mark { position: absolute; border: 2px solid var(--mark-c, #b3261e); background: color-mix(in srgb, var(--mark-c, #b3261e) 18%, transparent); border-radius: 3px; }
.pdf-marks .mark[data-kind="delete"]   { --mark-c: #b3261e; }
.pdf-marks .mark[data-kind="add"]      { --mark-c: #1f7a3d; }
.pdf-marks .mark[data-kind="rephrase"] { --mark-c: #9a6b00; }
.pdf-marks .mark[data-kind="fix"]      { --mark-c: #1b5fa8; }
.pdf-marks .mark[data-kind="other"]    { --mark-c: #5a4b8a; }
.pdf-marks .mark.draft { --mark-c: #111; border-style: dashed; }
.mark-tag { position: absolute; top: -1.35em; right: -2px; background: var(--mark-c, #b3261e); color: #fff; font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

/* لوحة التعديلات المطلوبة */
.revision-box { border: 1px solid var(--gold); border-radius: 12px; padding: 14px 16px; background: color-mix(in srgb, var(--gold) 10%, transparent); }
ol.marks { margin: 10px 0 0; padding-inline-start: 1.3em; display: grid; gap: 7px; }
ol.marks li { line-height: 1.6; }
.kind-tag { display: inline-block; font-size: .78rem; font-weight: 700; color: #fff; background: var(--mark-c, #b3261e); border-radius: 4px; padding: 1px 7px; margin-inline-end: 6px; }
.kind-tag[data-kind="delete"]   { --mark-c: #b3261e; }
.kind-tag[data-kind="add"]      { --mark-c: #1f7a3d; }
.kind-tag[data-kind="rephrase"] { --mark-c: #9a6b00; }
.kind-tag[data-kind="fix"]      { --mark-c: #1b5fa8; }
.kind-tag[data-kind="other"]    { --mark-c: #5a4b8a; }
.src-page .lh-body { font-family: var(--font); }

/* مساحة العمل: عمودان متساويان بنفس مقاس الصفحة */
.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.ws-col { min-width: 0; }
.ws-col > h3 { margin-bottom: 10px; }
@media (max-width: 980px) { .workspace { grid-template-columns: 1fr; } }
.ws-tools { position: sticky; top: 0; z-index: 5; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; background: var(--bg); }
.ws-tools .tools { position: static; border: 1px solid var(--border); border-radius: var(--radius-sm); flex: 1; min-width: 0; }
.audio-card { border: 2px solid var(--gold); }
.check-list { display: grid; gap: 10px; }
.check-list label { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.check-list input { width: 20px; height: 20px; margin-top: 4px; flex: none; }

/* نسخ التسجيل الصوتي */
.take { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--field); }
.take.ok { border-color: var(--ok); }
.take audio { margin-top: 6px; }

/* ---------- الأرشيف: سطر لكل مادة ---------- */
ol.archive { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.arch-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 52px; }
.arch-row:last-child { border-bottom: 0; }
.arch-row:hover { background: var(--soft); }
.arch-n { font-variant-numeric: tabular-nums; color: var(--accent-text); font-weight: 700; min-width: 2.6em; }
.arch-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arch-name b { margin-inline-end: 8px; }
.arch-meta { white-space: nowrap; }
.arch-badges { display: flex; gap: 4px; white-space: nowrap; }
.arch-actions { display: flex; gap: 2px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--accent-text); cursor: pointer; padding: 0; }
.icon-btn:hover { border-color: var(--border); background: var(--surface); }
.icon-btn.off { color: var(--border); cursor: default; }
.icon-btn.off:hover { background: transparent; border-color: transparent; }
.icon-btn .ico { display: grid; }
@media (max-width: 900px) { .arch-row { flex-wrap: wrap; } .arch-name { flex-basis: calc(100% - 4em); white-space: normal; } .arch-meta { display: none; } }

/* ---------- النوافذ والتنبيهات ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
dialog::backdrop { background: rgb(16 21 27 / 55%); }
dialog .dlg-body { padding: 20px; max-height: 75vh; overflow: auto; }
dialog .dlg-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--soft); }
#toasts { position: fixed; inset-inline-start: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); border-inline-start: 4px solid var(--gold); animation: pop .2s ease-out; }
.toast.bad { border-inline-start-color: #ff6b61; }
.toast.ok { border-inline-start-color: #5fbf85; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- الموقع العام (تصميم النسخة الأولى) ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding-inline: 28px; }
.hero { padding: 28px 0 8px; }
.hero .eyebrow { color: var(--accent-text); font-weight: 700; font-size: 1rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: .3rem 0; }
.hero p { color: var(--muted); max-width: 720px; margin: 0; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 28px; }
.tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; padding: 11px 18px; font: inherit; cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700; }
.tabs .tab-link { display: inline-flex; align-items: center; border: 1px dashed var(--gold); background: transparent; color: var(--accent-text); border-radius: 9px; padding: 11px 18px; min-height: 44px; text-decoration: none; }
.tabs .tab-link:hover { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.public { padding-bottom: 56px; }
.public .section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.public .section-head h2 { font-size: 1.75rem; margin: 0; }
.public .section-head p { margin: 0; color: var(--muted); }
.public .card { background: linear-gradient(145deg, var(--surface), var(--panel)); border-top: 3px solid var(--gold); border-radius: 14px; padding: 22px; }
:root[data-theme="light"] .public .card { background: var(--surface); }
.public .card h3 { font-size: 1.35rem; margin: 4px 0; }
.video { position: relative; aspect-ratio: 16 / 9; background: #0d141c; border-radius: 10px; overflow: hidden; margin-top: 16px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* زر حفظ ثابت مع أدوات المحرر (ملاحظة ٣٦) */
.ws-save { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; padding-inline-start: 10px; }
.ws-save .btn { white-space: nowrap; }

/* رقائق اللغات في إسناد المادة: المختارة عليها علامة صح (ملاحظة ٢٩) */
.lang-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.lang-pills button { border: 1px solid var(--border); background: var(--soft); color: var(--text); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .9rem; cursor: pointer; }
.lang-pills button:hover { border-color: var(--gold); color: var(--accent-text); }
.lang-pills button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700; }
.lang-pills .tick { font-weight: 900; margin-inline-end: 5px; }
.lang-pills.chosen button { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700; }
.lang-pills.chosen .x { margin-inline-start: 7px; font-weight: 900; opacity: .75; }

/* مشغّل الخطب: لا تحكم من داخل الفيديو، والأزرار أسفله (ملاحظة ٣٢) */
.player { margin-top: 14px; }
.vp-frame { position: relative; aspect-ratio: 16 / 9; background: #0d141c; border-radius: 10px; overflow: hidden; }
.vp-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vp-shield { position: absolute; inset: 0; cursor: pointer; background: transparent; }
.vp-poster { position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer; border: 0; padding: 0; }
.vp-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .45; }
.vp-poster-in { position: relative; text-align: center; padding: 16px; }
.vp-poster-title { font-weight: 700; color: #fff; }
.vp-poster-sub { color: #d8d2c6; font-size: .9rem; margin-top: 4px; }
.vp-poster-play { font-size: 2.4rem; color: var(--gold); margin-top: 8px; }
/* أزرار صغيرة متجاورة بأيقونات فقط (ملاحظتا ٤١ و٤٢) */
.vp-bar { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 10px; }
.vp-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 50%; }
.vp-btn.main { width: 44px; height: 44px; background: var(--gold); border-color: var(--gold); color: var(--ink); }
.vp-btn:hover { border-color: var(--gold); color: var(--accent-text); }
.vp-btn.main:hover { color: var(--ink); filter: brightness(1.05); }
.vp-ico { display: grid; place-items: center; line-height: 0; }
.bi { display: inline-flex; align-items: baseline; gap: 6px; }
.bi .en { color: var(--muted); font-size: .82em; font-weight: 400; }
.vp-rows { margin-top: 8px; display: grid; gap: 6px; }
/* الشريطان بالطول نفسه: الصوت مثل شريط التشغيل تمامًا (ملاحظة ٥٣) */
.vp-row { display: grid; grid-template-columns: 1fr 84px; gap: 8px; align-items: center; }
.vp-volrow .vp-btn { width: 28px; height: 28px; border: 0; background: transparent; justify-self: center; }
.vp-range { width: 100%; accent-color: var(--gold); height: 20px; }
.vp-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; white-space: nowrap; text-align: center; }
.vp-slot { margin-top: 10px; }
/* في الأعمدة الضيقة نكتفي بالعربية على الأزرار حتى لا تتكدّس */
.public .card { container-type: inline-size; }
@media (max-width: 560px) { .tabs .bi .en { display: none; } }

/* الأرشيف: صفّ لكل أسبوع — مكة يمينًا والمدينة يسارًا (ملاحظة ٣٣) */
.week { margin-top: 26px; }
.week-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 14px; }
.week-head h3 { margin: 0; font-size: 1.15rem; color: var(--accent-text); }
.empty-slot { display: grid; place-items: center; color: var(--muted); min-height: 160px; text-align: center; }
.section-head.sm h3 { margin: 0; font-size: 1.2rem; }
.section-head.sm p { margin: 0; color: var(--muted); font-size: .92rem; }

/* قائمة اللغات المنسدلة: مكتوبة بالعربية وباللغة نفسها */
label.field.lang-pick { margin-top: 14px; }
select.lang-select { width: 100%; min-height: 46px; font: inherit; font-size: 1rem; }
/* أرشيف الخطب: خطب المسجد الحرام معًا وخطب المسجد النبوي معًا */
.arch-group { margin-top: 30px; }
.arch-group .section-head.sm { margin-bottom: 8px; }
.arch-group .section-head.sm h3 { font-size: 1.25rem; margin: 0; }
.arch-group .section-head.sm p { margin: 0; color: var(--muted); font-size: .92rem; }
.arch-list { margin: 10px 0; }
.arch-list summary { cursor: pointer; padding: 4px 0; }
.translation-text { background: #fff; color: #222b37; border-radius: var(--radius-sm); padding: 16px; line-height: 1.9; }
@media (max-width: 760px) {
  .wrap { padding-inline: 16px; }
  .tabs { display: grid; grid-template-columns: repeat(2, 1fr); }
  .public .section-head { display: block; }
  .public .card { padding: 17px; }
}

/* ---------- صفحة الوجهات «اختر وجهتك» ---------- */
.portals { max-width: 1280px; margin: 0 auto; padding: 40px 28px 70px; }
.portal-title { text-align: center; margin-bottom: 30px; }
.portal-title h1 { font-size: 1.8rem; margin: 6px 0; }
.portal-title p { color: var(--muted); }
.portal-grid { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.portal-card { display: flex; flex-direction: column; gap: 14px; padding: 26px; border: 1px solid var(--border); border-top: 1px solid #b29c65; border-radius: 10px;
  background: linear-gradient(155deg, #ffffff08, transparent), var(--surface); }
.portal-card > .num { color: var(--accent-text); font-size: 1.4rem; line-height: 1.2; font-weight: 700; }
.portal-card h2 { font-size: 1.4rem; margin: 0; }
.portal-card .for { color: var(--muted); font-size: .875rem; }
.portal-card p { flex: 1; margin: 0; }
.portal-card .btn { border-radius: 99px; width: 100%; }
.portals .fine { text-align: center; color: var(--muted); font-size: .875rem; margin-top: 24px; }
@media (max-width: 900px) { .portal-grid { grid-template-columns: 1fr; } .portals { padding: 28px 16px; } }

/* ---------- شريط مساحة العمل ---------- */
.workspace-banner { background: var(--panel) url('/assets/pattern.png') center; border: 1px solid #b29c6550; color: #fff; border-radius: 10px; padding: 18px 22px; margin-bottom: 18px; }
.workspace-banner :is(h1, h2) { color: #fff; margin: 0; }
.workspace-banner .eyebrow { color: #d5bd87; }
.workspace-banner .btn { color: #fff; border-color: #b29c6566; background: #ffffff0c; }
.workspace-banner .sub, .workspace-banner .muted { color: #d1c8b5; }

/* ---------- المصادقة ---------- */
.auth-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(540px, 100%); border-top: 3px solid var(--gold-2); padding: 28px; }
.auth-card.wide { width: min(720px, 100%); }

/* ---------- الطباعة (حفظ PDF) ---------- */
@media print {
  .topbar, .sidenav, footer.site, .no-print, #toasts, .env-flag { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { display: block; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-doc { font-size: 13pt; line-height: 1.9; }
}
