/* =========================================================
   نعوات — واجهة الموقع
   الألوان مأخوذة من تدرّج الشعار: أزرق ← فيروزي ← أخضر
   ========================================================= */
:root {
  --blue: #2867A4;
  --teal: #2E7B8B;
  --teal-d: #23626F;
  --green: #3C915C;
  --grad: linear-gradient(135deg, #2867A4 0%, #2E7B8B 50%, #3C915C 100%);
  --teal-50: #EDF5F6;
  --teal-100: #D6E9EC;
  --ink: #17262D;
  --text: #2A3A41;
  --muted: #607078;
  --line: #DCE5E7;
  --bg: #F6F8F8;
  --card: #FFFFFF;
  --danger: #B3261E;
  --danger-50: #FCEDEC;
  --ok: #2F7D4F;
  --ok-50: #EAF5EE;
  --warn: #8A5A00;
  --warn-50: #FFF6E0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 38, 45, .06), 0 6px 20px rgba(23, 38, 45, .06);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.7;
  color: var(--text); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.35; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding: 24px 0 48px; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.hidden { display: none !important; }

/* ---------- الشريط العلوي ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar::before { content: ""; display: block; height: 3px; background: var(--grad); }
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand {
  font-weight: 700; font-size: 1.45rem; letter-spacing: 0; color: var(--ink);
  text-decoration: none !important; display: inline-flex; align-items: center; gap: 10px;
}
.brand::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--grad);
  box-shadow: 0 0 0 4px var(--teal-50);
}
.brand-lg { font-size: 1.8rem; margin-bottom: 12px; }
.nav { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.nav > a:not(.btn), .nav-form button {
  color: var(--text); padding: 8px 12px; border-radius: 8px; font: inherit; font-size: .95rem;
  background: none; border: 0; cursor: pointer; text-decoration: none;
}
.nav > a:not(.btn):hover, .nav-form button:hover { background: var(--teal-50); color: var(--teal-d); }
.nav > a.on { color: var(--teal-d); background: var(--teal-50); font-weight: 600; }
.nav-form { margin: 0; }
.nav .btn { margin-inline-start: 8px; }
.nav-toggle { display: none; margin-inline-start: auto; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; transition: .2s; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute; inset-inline: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--line);
    flex-direction: column; align-items: stretch; padding: 8px 16px 16px; gap: 2px;
    display: none; box-shadow: 0 10px 20px rgba(0,0,0,.06);
  }
  .nav.open { display: flex; }
  .nav > a:not(.btn), .nav-form button { padding: 12px; text-align: start; width: 100%; }
  .nav .btn { margin: 8px 0 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .98rem; line-height: 1.2;
  padding: 12px 20px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  min-height: 44px;
}
.btn:focus-visible { outline: 3px solid var(--teal-100); outline-offset: 2px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-grad { background: var(--grad); color: #fff; }
.btn-grad:hover { filter: brightness(1.05); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-d); }
.btn-light { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.45); }
.btn-light:hover { background: rgba(255,255,255,.26); }
.btn-danger { background: #fff; color: var(--danger); border-color: #EBC7C4; }
.btn-danger:hover { background: var(--danger-50); }
.btn-sm { padding: 8px 14px; font-size: .9rem; min-height: 38px; }
.btn-xs { padding: 5px 10px; font-size: .82rem; min-height: 32px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; font: inherit; font-size: 1rem;
}
.icon-btn:hover { color: var(--teal-d); border-color: var(--teal); }
.icon-btn.danger:hover { color: var(--danger); border-color: #EBC7C4; background: var(--danger-50); }

/* ---------- النماذج ---------- */
.form { display: grid; gap: 14px; }
.form label, .field { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; color: var(--ink); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=search], input:not([type]),
select, textarea {
  width: 100%; font: inherit; font-weight: 400; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid #CBD6D9; border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-100); }
input::placeholder, textarea::placeholder { color: #9AA8AD; }
.check { display: flex !important; align-items: center; gap: 10px; font-weight: 500 !important; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); margin: 0; flex: none; }
.hint { font-weight: 400; font-size: .82rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; background: var(--teal-50); border-radius: 999px; padding: 4px; gap: 4px; }
.seg label { position: relative; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 18px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--teal-d); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--teal); }

/* ---------- التنبيهات ---------- */
.flashes { padding-top: 16px; display: grid; gap: 8px; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: .95rem; }
.alert-error { background: var(--danger-50); border-color: #F1CFCC; color: var(--danger); }
.alert-success { background: var(--ok-50); border-color: #CDE6D6; color: var(--ok); }
.alert-info { background: var(--teal-50); border-color: var(--teal-100); color: var(--teal-d); }
.alert-warn { background: var(--warn-50); border-color: #F2DFAE; color: var(--warn); }

/* ---------- البطاقات والجداول ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--teal-50); color: var(--teal-d); white-space: nowrap; }
.badge-draft { background: #F0F2F3; color: var(--muted); }
.badge-ready { background: var(--ok-50); color: var(--ok); }
.badge-hidden { background: var(--danger-50); color: var(--danger); }
.badge-admin { background: #E7EEF7; color: var(--blue); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #FAFBFB; color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0 8px; }
.pager .on { background: var(--teal); color: #fff; border-color: var(--teal); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1 1 220px; min-width: 0; }
.toolbar select { width: auto; flex: 0 1 auto; }

.empty { text-align: center; padding: 48px 20px; }
.empty .empty-mark { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px; background: var(--teal-50); display: grid; place-items: center; color: var(--teal); font-size: 1.8rem; }

/* ---------- صفحات الدخول ---------- */
.auth-wrap { display: grid; place-items: center; padding: 32px 16px 56px; min-height: calc(100vh - 220px); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.5rem; }
.auth-alt { text-align: center; margin: 18px 0 0; color: var(--muted); }

/* ---------- الصفحة الرئيسية ---------- */
.hero { position: relative; overflow: hidden; background: #fff; border-bottom: 1px solid var(--line); }
.hero::after {
  content: ""; position: absolute; inset-inline-end: -180px; top: -180px; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(46,123,139,.10), rgba(46,123,139,0) 70%); pointer-events: none;
}
.hero-in { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding-top: 56px; padding-bottom: 56px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--teal-d); font-weight: 600; font-size: .9rem; background: var(--teal-50); padding: 4px 12px; border-radius: 999px; margin-bottom: 16px; }
.hero h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3rem); line-height: 1.25; margin-bottom: 16px; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: 1.12rem; color: var(--muted); max-width: 34em; margin-bottom: 28px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-note { margin-top: 18px; font-size: .9rem; color: var(--muted); }
.hero-visual { position: relative; display: flex; justify-content: center; }
.hero-sheet { width: min(360px, 100%); transform: rotate(-2deg); box-shadow: 0 30px 60px rgba(23,38,45,.18), 0 2px 6px rgba(23,38,45,.08); border-radius: 4px; overflow: hidden; }
.hero-sheet-2 { position: absolute; width: min(190px, 52%); bottom: -18px; inset-inline-start: -8px; transform: rotate(4deg); box-shadow: 0 20px 40px rgba(23,38,45,.18); border-radius: 6px; overflow: hidden; }
@media (max-width: 900px) {
  .hero-in { grid-template-columns: 1fr; gap: 40px; padding-top: 36px; }
  .hero-visual { padding-bottom: 18px; }
  .hero-sheet { width: min(300px, 78%); }
  .hero-sheet-2 { width: min(150px, 40%); inset-inline-start: 4%; }
}

.section { padding: 64px 0; }
.section-alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.section-head p { color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; position: relative; }
.step::before {
  counter-increment: step; content: counter(step, arabic-indic);
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--teal-50); color: var(--teal-d); font-weight: 700; font-size: 1.2rem; margin-bottom: 14px;
}
.step h3 { margin-bottom: 6px; }
.step p { color: var(--muted); margin: 0; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }

.tpl-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 250px)); justify-content: center; gap: 28px 24px; align-items: start; }
.tpl-item { text-align: center; }
.tpl-thumb { border-radius: 6px; overflow: hidden; box-shadow: 0 8px 24px rgba(23,38,45,.12); border: 1px solid var(--line); background: #fff; }
.tpl-item h3 { font-size: .98rem; margin: 12px 0 2px; }
.tpl-item p { font-size: .84rem; color: var(--muted); margin: 0; }
@media (max-width: 1000px) { .tpl-gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) {
  .tpl-gallery { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 62%; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 12px; margin-inline: -16px; padding-inline: 16px; }
  .tpl-item { scroll-snap-align: center; }
}

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { display: flex; gap: 14px; align-items: flex-start; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.feature .fi { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-d); }
.feature .fi svg { width: 22px; height: 22px; }
.feature h3 { font-size: 1rem; margin: 0 0 4px; }
.feature p { margin: 0; font-size: .92rem; color: var(--muted); }
@media (max-width: 900px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }

.cta-band { background: var(--grad); color: #fff; border-radius: 20px; padding: 40px 28px; text-align: center; }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.88); max-width: 520px; margin: 0 auto 22px; }
.cta-band .btn-ghost { border-color: #fff; }

/* ---------- التذييل ---------- */
.footer { background: #fff; border-top: 1px solid var(--line); padding: 28px 0 16px; margin-top: auto; }
.footer-in { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.footer-in p { margin: 6px 0 0; font-size: .9rem; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--muted); }
.copy { color: var(--muted); font-size: .82rem; margin-top: 18px; }

/* ---------- صفحة ابدأ ---------- */
.start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.tpl-choice { position: relative; display: block; cursor: pointer; }
.tpl-choice input { position: absolute; opacity: 0; }
.tpl-choice .tpl-card { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; background: #fff; transition: border-color .15s, box-shadow .15s; height: 100%; }
.tpl-choice .tpl-card .tpl-thumb { box-shadow: none; }
.tpl-choice input:checked + .tpl-card { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-100); }
.tpl-choice input:focus-visible + .tpl-card { outline: 2px solid var(--teal); }
.tpl-choice h3 { font-size: .95rem; margin: 10px 0 0; }
.tpl-choice p { font-size: .8rem; color: var(--muted); margin: 0; }
.start-bar { position: sticky; bottom: 0; background: rgba(246,248,248,.94); backdrop-filter: blur(6px); padding: 12px 0; margin-top: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); }
.start-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0 28px; }
.start-steps div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: .92rem; }
.start-steps b { display: block; color: var(--teal-d); }
@media (max-width: 680px) { .start-steps { grid-template-columns: 1fr; } }

/* ---------- نعواتي ---------- */
.ob-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ob-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.ob-card .ob-thumb { background: #F0F3F4; padding: 14px 14px 0; height: 190px; overflow: hidden; }
.ob-card .ob-thumb .obit { width: 70%; margin: 0 auto; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.ob-card .ob-meta { padding: 14px 16px; flex: 1; }
.ob-card h3 { font-size: 1.02rem; margin: 0 0 4px; }
.ob-card .ob-sub { font-size: .84rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ob-card .ob-acts { display: flex; gap: 6px; padding: 0 16px 16px; flex-wrap: wrap; }
.ob-card .ob-acts form { margin: 0; }

/* ---------- المحرر ---------- */
.editor-page .main { padding: 0; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 46%); min-height: calc(100vh - 63px); }
.ed-form { padding: 20px 24px 120px; border-inline-end: 1px solid var(--line); min-width: 0; }
.ed-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ed-top h1 { font-size: 1.2rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.save-state.dirty { color: var(--warn); }
.save-state.err { color: var(--danger); }

.ed-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; margin-bottom: 8px; position: sticky; top: 63px; background: var(--bg); z-index: 5; scrollbar-width: none; }
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tabs button {
  flex: none; font: inherit; font-size: .9rem; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.ed-tabs button .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-d); font-size: .78rem; }
.ed-tabs button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.ed-tabs button.on .n { background: rgba(255,255,255,.22); color: #fff; }
.ed-panel { display: none; }
.ed-panel.on { display: grid; gap: 16px; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ed-panel h2 { font-size: 1.1rem; margin: 4px 0 0; }
.ed-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }

.photo-box { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.photo-box .ph { width: 84px; height: 104px; border-radius: 10px; background: var(--teal-50) center/cover no-repeat; border: 1px dashed #B5CBD0; display: grid; place-items: center; color: var(--teal); font-size: .8rem; text-align: center; flex: none; }
.photo-box .ph.has { border-style: solid; color: transparent; }
.photo-box .acts { display: flex; gap: 8px; flex-wrap: wrap; }

.rel-list { display: grid; gap: 12px; }
.rel-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.rel-head { display: flex; gap: 8px; align-items: center; }
.rel-head input { flex: 1; font-weight: 600; }
.rel-names { display: grid; gap: 8px; }
.name-row { display: flex; gap: 8px; align-items: center; }
.name-row input { flex: 1; min-width: 0; }
.name-row select { width: 104px; flex: none; font-size: .9rem; padding-inline: 8px; }
.add-link { background: none; border: 0; color: var(--teal); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; justify-self: start; }
.add-link:hover { text-decoration: underline; }

.hijri-out { background: var(--teal-50); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .95rem; color: var(--teal-d); }

.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.tpl-pick .tpl-choice .tpl-card { padding: 8px; }
.tpl-pick h3 { font-size: .82rem; }

.ed-preview { position: relative; background: #E9EEEF; min-width: 0; }
.ed-preview-in { position: sticky; top: 63px; height: calc(100vh - 63px); display: flex; flex-direction: column; }
.pv-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid #D6DFE1; background: #EEF2F3; flex-wrap: wrap; }
.pv-bar .pv-title { font-weight: 600; font-size: .9rem; color: var(--muted); margin-inline-end: auto; }
.pv-stage { flex: 1; overflow: auto; padding: 20px; display: flex; justify-content: center; align-items: flex-start; }
.pv-sheet { width: min(100%, 560px, calc((100vh - 150px) / var(--pr, 1.4142))); flex: none; box-shadow: 0 16px 40px rgba(23,38,45,.16); transition: opacity .15s; }
.pv-sheet.loading { opacity: .6; }
.fit-warn { margin: 0 16px 12px; }
.ed-mobilebar { display: none; }

@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .ed-form { border: 0; padding: 16px 16px 110px; }
  .ed-tabs { top: 63px; }
  .ed-preview { position: fixed; inset: 0; z-index: 80; display: none; }
  .ed-preview.open { display: block; }
  .ed-preview-in { top: 0; height: 100%; }
  .pv-close { display: inline-flex !important; }
  .ed-mobilebar {
    display: flex; gap: 10px; position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line); backdrop-filter: blur(6px);
  }
  .ed-mobilebar .btn { flex: 1; }
  .editor-page .footer { display: none; }
}
.pv-close { display: none !important; }

/* اختيار الخط والأحجام */
.font-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.font-choice { position: relative; display: block; cursor: pointer; }
.font-choice input { position: absolute; opacity: 0; }
.fc-card { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: #fff; transition: border-color .15s, box-shadow .15s; }
.fc-sample { font-size: 1.15rem; line-height: 1.5; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-name { font-size: .78rem; color: var(--muted); font-weight: 500; }
.font-choice input:checked + .fc-card { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-100); }
.font-choice input:focus-visible + .fc-card { outline: 2px solid var(--teal); }
.size-card { display: grid; gap: 12px; padding: 16px; box-shadow: none; }
.size-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.size-head h2 { margin: 0; }
.range-row { display: grid !important; grid-template-columns: 120px 1fr 52px; align-items: center; gap: 12px; font-weight: 500 !important; }
.range-row output { font-variant-numeric: tabular-nums; color: var(--teal-d); font-weight: 600; text-align: center; }
.range-row input[type=range] { width: 100%; accent-color: var(--teal); height: 28px; }
.range-row.is-off { opacity: .45; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
@media (max-width: 480px) { .range-row { grid-template-columns: 96px 1fr 46px; gap: 8px; } }

/* صلة القرابة والاقتراحات وخط كل قسم */
.rel-head .rel-select { flex: 1; min-width: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; max-width: 100%; }
.chip:hover { border-color: var(--teal); color: var(--teal-d); background: var(--teal-50); }
.apply-all { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.apply-all select { width: auto; flex: 1 1 180px; }
.sec-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1fr) 48px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.sec-label { font-weight: 600; font-size: .92rem; color: var(--ink); }
.sec-row select { min-height: 40px; padding-block: 6px; font-size: 15px; }
.sec-row input[type=range] { width: 100%; accent-color: var(--teal); height: 28px; }
.sec-row output { font-variant-numeric: tabular-nums; color: var(--teal-d); font-weight: 600; text-align: center; font-size: .9rem; }
@media (max-width: 640px) {
  .sec-row { grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "l o" "f f" "r r"; row-gap: 6px; }
  .sec-row .sec-label { grid-area: l; } .sec-row output { grid-area: o; }
  .sec-row select { grid-area: f; } .sec-row input[type=range] { grid-area: r; }
}

/* ---------- صفحة العرض والطباعة ---------- */
.view-page { background: #E9EEEF; }
.view-bar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 63px; z-index: 20; }
.view-bar-in { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
.view-bar h1 { font-size: 1.05rem; margin: 0 auto 0 0; flex: 1 1 200px; min-width: 0; }
.view-bar select { width: auto; min-height: 40px; padding-block: 6px; }
.view-stage { padding: 28px 16px 56px; display: flex; justify-content: center; }
.view-sheet { width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(23,38,45,.18); }
.share-box { display: flex; gap: 8px; align-items: center; }
.share-box input { min-height: 40px; font-size: .85rem; direction: ltr; }
.public-head { text-align: center; padding: 20px 16px 0; }

/* ---------- لوحة الإدارة ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-tabs a { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; font-size: .92rem; text-decoration: none; }
.admin-tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .v { font-size: 1.8rem; font-weight: 700; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .85rem; color: var(--muted); }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: .9rem; }
.bar-track { background: var(--teal-50); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--teal); height: 100%; border-radius: 999px; }
.log-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.log-list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; }
.log-list li:last-child { border: 0; }

/* بطاقات الجداول على الهاتف */
@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-bottom: 1px solid var(--line); padding: 10px 4px; }
  .table.stack td { border: 0; padding: 4px 12px; }
  .table.stack td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .82rem; }
  .table.stack .actions { justify-content: flex-start; padding-top: 8px; }
}

/* صفحات نصية */
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; font-size: 1.2rem; }

/* الطباعة: تُخفى الواجهة ولا تظهر إلا النعوة */
@media print {
  .topbar, .footer, .view-bar, .flashes, .no-print, .public-head { display: none !important; }
  body, .view-page { background: #fff !important; }
  .view-stage { padding: 0 !important; display: block; }
  .view-sheet { box-shadow: none !important; max-width: none !important; margin: 0 auto; }
}
