/* Reset */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* Theme variables */
:root{
  --bg: #0f1220;
  --surface: #151a2e;
  --elev: #1b2140;
  --glass: rgba(255,255,255,0.06);
  --text: #e9ecf1;
  --muted: #a7afc4;
  --brand: #6aa3ff;
  --brand-2: #8b6cff;
  --accent: #22d3ee;
  --success: #3ddc97;
  --warn: #ffd166;
  --danger: #ff5a5f;
  --border: rgba(255,255,255,0.12);
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --container: 1100px;
  --trans: 200ms ease;

  /* Skeleton */
  --sk-bg: rgba(255,255,255,0.06);
  --sk-shimmer: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

:root.light{
  --bg: #f7f9fc;
  --surface: #ffffff;
  --elev: #f2f5fb;
  --glass: rgba(0,0,0,0.04);
  --text: #0d1321;
  --muted: #4a5568;
  --brand: #2b6cb0;
  --brand-2: #6b46c1;
  --accent: #0089a5;
  --success: #14866c;
  --warn: #a26500;
  --danger: #b32127;
  --border: rgba(0,0,0,0.12);
  --shadow: 0 6px 18px rgba(0,0,0,0.08);

  --sk-bg: rgba(0,0,0,0.06);
  --sk-shimmer: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}

/* Global */
body{
  background: radial-gradient(1200px 800px at 10% -10%, rgba(107,124,255,0.12), transparent 60%),
              radial-gradient(1000px 600px at 90% -20%, rgba(34,211,238,0.10), transparent 60%),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  line-height: 1.6;
}
[dir="rtl"] { direction: rtl; }

/* Container */
.container{ width:min(100%,var(--container)); margin:0 auto; padding:0 16px; }

/* Header */
.hdr{ position:sticky; top:0; z-index:30; backdrop-filter:blur(10px); background:linear-gradient(180deg,rgba(0,0,0,0.25),transparent); border-bottom:1px solid var(--border);}
.header-row{ display:flex; justify-content:space-between; align-items:center; padding:14px 0;}
.brand{ display:flex; align-items:center; gap:12px; }
.logo{ width:200px; height:100%; border-radius:10px; background:linear-gradient(135deg, #ffffff, #484e62); color:#fff; display:grid; place-items:center; font-weight:700; box-shadow:var(--shadow);}
.tagline{ font-size:13px; color:var(--muted); margin:2px 0 0;}
.controls{ display:flex; gap:10px; align-items:center; }

/* Form & Inputs */
.input,.btn{ border-radius:var(--radius-xs); border:1px solid var(--border); padding:10px 12px; background:var(--surface); color:var(--text); transition:all var(--trans);}
.input:focus{ outline:none; border-color:var(--brand); }
.btn{ background:linear-gradient(135deg,var(--brand),var(--brand-2)); border:none; color:#fff; cursor:pointer; font-weight:600;}
.btn:hover{ transform:translateY(-1px);}
.btn.ghost{ background:transparent; border:1px solid var(--border); color:var(--text);}
.btn.danger{ background:var(--danger); color:#fff;}
.btn.small{ padding:6px 10px; font-size:13px;}
#themeToggle{ width:40px; height:40px; }

/* Hero */
.hero{ padding:28px 0 14px;}
.hero-inner{ display:grid; grid-template-columns:1.2fr 1.2fr; gap:20px; background:var(--glass); border-radius:var(--radius); padding:20px; box-shadow:var(--shadow);}
.hero-text h2{ margin:0 0 6px; }
.hero-text p{ margin:0; color:var(--muted);}
.hero-bullets{ margin:8px 0 0; padding-inline-start:20px; font-size:13px; color:var(--muted); }

/* Filters */
.filters{ display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; }
@media(max-width:980px){ .hero-inner{grid-template-columns:1fr;} .filters{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:560px){ .filters{grid-template-columns:1fr;}}

.field{ margin-bottom:12px; }
label{ font-size:13px; color:var(--muted); display:block; margin:4px 0 6px;}
.mini{ font-size:12px; color:var(--muted); }

/* Main */
.main-grid{ display:grid; grid-template-columns:1.6fr .9fr; gap:16px; padding:16px 0 40px;}
@media(max-width:980px){.main-grid{grid-template-columns:1fr;}}

/* Cards */
.card{ border:1px solid var(--border); background:var(--surface); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow);margin-bottom: 20px;}
.glass{ backdrop-filter:blur(10px);}
.section-title{ font-size:14px; color:var(--muted); margin:0 0 8px;}
.result+.result{ margin-top:12px;}
.res-title{ margin:0 0 6px; font-size:18px;}
.res-title a{ color:var(--brand); text-decoration:none;}
.res-title a:hover{ text-decoration:underline; }
.meta{ display:flex; flex-wrap:wrap; gap:8px; margin:6px 0 10px;}
.badge{ font-size:12px; color:var(--muted); border:1px dashed var(--border); border-radius:999px; padding:6px 8px; display:inline-flex; align-items:center; gap:6px;}
.badge.oa{ color:var(--success); border-color:rgba(61,220,151,0.5);}
.abs summary{ cursor:pointer; color:var(--accent);}
.abs-text{ text-align:start; }

/* Actions */
.actions{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-top:10px; padding-top:10px; border-top:1px dashed var(--border);}

/* Summary */
.summary{ margin-top:12px; padding:12px; border:1px solid var(--border); border-radius:var(--radius-xs); background:var(--elev); }
.hidden{ display:none; }

/* Tabs */
.tabs{ display:flex; border-bottom:1px solid var(--border); margin-bottom:10px;}
.tab{ padding:8px 12px; cursor:pointer; border:1px solid var(--border); border-bottom:none; border-top-left-radius:8px; border-top-right-radius:8px; background:var(--surface); margin-inline-end:6px; font-size:13px;}
.tab.active{ background:var(--elev); font-weight:600;}
.tab-panel{ display:none;}
.tab-panel.active{ display:block;}

/* Counters */
.counter{ font-size:12px; color:var(--muted); display:flex; gap:12px;}

/* Footer */
footer{ border-top:1px solid var(--border); padding:16px 0; color:var(--muted); text-align:center; font-size:13px; }

/* Toast */
#toast{ position:fixed; bottom:18px; right:18px; background:var(--surface); color:var(--text); padding:10px 14px; border-radius:10px; border:1px solid var(--border); box-shadow:var(--shadow); opacity:0; pointer-events:none; transform:translateY(8px); transition:opacity .2s ease,transform .2s ease;}
#toast.show{ opacity:1; transform:translateY(0);}

/* Fade-in helper */
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from{opacity:0; transform:translateY(4px)} to{opacity:1; transform:translateY(0)} }

/* ===================== Skeleton Loader ===================== */

/* نتائج البحث: غلاف skeleton يظهر فوق العمود الأيسر */
.skel-overlay {
  position: fixed;
  inset: 72px 0 0 0; /* تحت الهيدر */
  background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.25));
  backdrop-filter: blur(2px);
  display: none;
  z-index: 50;
}

.skel-container{
  width:min(100%,var(--container));
  margin: 0 auto;
  padding: 0 16px;
}

.skel-list{
  max-width: 720px;
  margin: 18px 0;
}

.skel-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.skel-line{
  height: 12px;
  background: var(--sk-bg);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.skel-line + .skel-line { margin-top: 8px; }

.skel-line.thick{ height: 18px; }
.skel-line.thin{ height: 8px; }

.skel-line::after{
  content:"";
  position:absolute; inset:0;
  background: var(--sk-shimmer);
  transform: translateX(-100%);
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer{
  100%{ transform: translateX(100%); }
}

/* ملخص الورقة: Skeleton داخل .summary */
.summary.skel .skel-line { margin: 6px 0; }

/* --- HERO LAYOUT TWEAKS --- */
.hero-inner{
  display:grid;
  grid-template-columns:1.1fr 1fr;   /* text | form */
  gap:24px;
  background:var(--glass);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow);
}

@media(max-width:980px){
  .hero-inner{ grid-template-columns:1fr; }
}

/* the form is a single-column stack; textarea spans fully */
.hero-form{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}

.hero-form .field{ grid-column:1 / -1; }
.hero-form textarea{
  width:100%;
  min-height:140px;
  resize:vertical;
}

/* filters keep their grid but don’t squeeze */
.filters{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:10px;
}
@media(min-width:1100px){
  .filters{ grid-template-columns:repeat(4, minmax(0,1fr)); }
}

/* buttons area */
.cta{ display:flex; gap:10px; align-items:center; }

/* === Filters: responsive grid without overlap === */
.filters{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* كل عنصر ياخذ عرض كافي */
  gap: 12px;
  align-items: end; /* يصف السطر من الأسفل لتوحيد ارتفاعات اللابل/المدخل */
}

/* اجعل كل input/select بعرض كامل وارتفاع موحّد */
.input{
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* select يتصرّف كزر نظيف */
select.input{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;              /* مساحة للسهم */
  line-height: 1.2;
  position: relative;
  z-index: 0;
}

/* عدد النتائج: عرض منطقي وثابت */
.input.results-count{
  max-width: 140px;
}

/* لا تجعل textarea يتأثر بارتفاع 44px */
.hero-form textarea{
  width: 100%;
  min-height: 150px;
  resize: vertical;
}

/* تحسين اللابل والمسافات */
.filters label{
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

/* إصلاح تراكب القوائم المنسدلة فوق عناصر مجاورة */
select.input:focus{
  z-index: 2;
  outline: none;
  border-color: var(--brand);
}

/* المظهر في الشاشات الصغيرة يبقى عمودياً */
@media (max-width: 560px){
  .filters{ grid-template-columns: 1fr; }
}

/* Tabs polish */
.tabs{ display:flex; gap:8px; border-bottom:1px solid var(--border); margin-bottom:10px; }
.tab{
  appearance:none; border:none; cursor:pointer;
  padding:8px 12px; font-size:13px; color:var(--muted);
  background:var(--surface); border:1px solid var(--border); border-bottom:none;
  border-top-left-radius:8px; border-top-right-radius:8px;
}
.tab:hover{ color:var(--text); }
.tab.active{
  background:var(--elev); color:var(--text); font-weight:600;
  box-shadow: inset 0 -2px 0 0 var(--brand);
}
.tab:focus-visible{ outline:2px solid var(--brand); outline-offset:2px; }

.tab-panel{ display:none; }
.tab-panel.active{ display:block; }

/* Library list: clean bullets and spacing */
.library{ list-style:none; margin:0; padding:0; }
.library li{ margin:6px 0; }
.library a{ color:var(--brand); text-decoration:none; }
.library a:hover{ text-decoration:underline; }


/* Flag badge next to language select */
.flag-badge{
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-grid; place-items: center;
  font-size: 18px; line-height: 1;
  background: var(--elev); border:1px solid var(--border);
  user-select: none;
}


/* defaults */
.summary{ text-align:start; direction:ltr; unicode-bidi:plaintext; }

/* when content is Arabic */
.summary[lang="ar"]{
  direction: rtl;
  text-align: right;         /* override start for better control */
  font-family: "Noto Naskh Arabic","Amiri","Segoe UI",system-ui,sans-serif;
}

/* optional: keep bullets/punctuation tidy inside RTL */
.summary[lang="ar"] p, 
.summary[lang="ar"] li{ line-height:1.7; }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; 
         background: rgba(0,0,0,.45); z-index: 9999; }
.modal-dialog { position: relative; background: var(--elev,#111); color: var(--fg,#fff);
  border-radius: 12px; padding: 16px; min-width: 320px; max-width: 480px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none; cursor: pointer; font-size: 16px; }


/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  min-width: 280px;
  max-width: min(560px, 90vw);
  background: #111;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  box-shadow: 0 6px 30px rgba(0,0,0,.35);
  padding: 14px 16px;
  opacity: 0;
  pointer-events: none;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 9999;
  transition: transform .25s ease, opacity .25s ease;
  font-size: 14px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast .icon { font-size: 18px; line-height: 1; }
.toast .msg { flex: 1; }
.toast .close {
  background: transparent;
  border: 0;
  color: #bbb;
  font-size: 18px;
  cursor: pointer;
}

/* Variants */
.toast.info { border-color:#2f4c7f; background:#0e1a2e; }
.toast.warn { border-color:#7f5b2f; background:#2e1b0e; }
.toast.error{ border-color:#7f2f2f; background:#2e0e0e; }

/* Loading hint */
.loading-hint { 
  max-width: 920px; margin: 18px auto 0;
  display: grid; gap: 10px;
}
.loading-hint.hidden { display: none; }
.loading-hint .row {
  height: 16px; border-radius: 8px; overflow: hidden; background: #1e1e1e;
}
.loading-hint .row:nth-child(2){ height: 20px; width: 80%; }
.loading-hint .row:nth-child(3){ height: 16px; width: 60%; }

.shimmer {
  position: relative;
}
.shimmer::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.08), rgba(255,255,255,0));
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to { transform: translateX(100%); }
}
/* ===== Mobile header tidy ===== */
@media (max-width: 640px){
    .brand {margin: auto;}
  .header-row{ padding:10px 0; }
  .brand .logo{ width: 140px; }
  .controls{ gap:8px; flex-wrap: wrap; }
  .controls .btn{ padding:8px 10px; }
}

/* ===== Buttons: loading state (spinner) ===== */
.btn.loading{
  position: relative;
  pointer-events: none;
  opacity: .8;
}
.btn.loading::after{
  content:"";
  position:absolute; right:10px; top:50%;
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.7);
  border-top-color: transparent;
  transform: translateY(-50%);
  animation: spin .8s linear infinite;
}
@keyframes spin{ to{ transform: translateY(-50%) rotate(360deg); } }

/* ===== Larger, centered Toast (override) ===== */
#toast, #toast.toast{
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(0);
  min-width: 280px; max-width: min(560px, 90vw);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  font-size: 15px;
  z-index: 9999;
}

/* ===== Hero & filters on mobile: لا تزدحم ===== */
@media (max-width: 560px){
  .hero-inner{ padding:16px; }
  .filters{ grid-template-columns: 1fr; }
  .input, select.input{ min-height: 44px; }
}


/* ===== Base mobile hygiene ===== */
html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
:root {
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (max-width: 640px){
  .container, .hero-inner { padding-left: 12px; padding-right: 12px; }
  .header-row { padding: calc(8px + var(--safe-top)) 12px 8px; }
}

/* ===== Sticky header (لازم القائمة تبقى داخل الشاشة) ===== */
header.site-header{
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ===== Profile menu (تَقِف على الشاشة – بدون سكرول للصفحة) ===== */
.profile-menu{ display: none; }
.profile-menu.open{
  display: block;
  position: fixed;
  right: 12px; left: 12px;
  top: calc(var(--header-h) + var(--safe-top) + 6px);
  width: auto; max-width: 320px;
  margin-left: auto; /* يلتصق باليمين على الشاشات الواسعة */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--header-h) - 24px - var(--safe-bottom));
  overflow: auto;
  z-index: 1000;
}
@media (min-width: 641px){
  .profile-menu.open{ left: auto; }
}
body.menu-open { overflow: hidden; } /* ما يحرّك الصفحة لما القائمة مفتوحة */

/* ===== Language picker: واضح ومناسب للموبايل ===== */
.langs { display:flex; gap:8px; flex-wrap:wrap; }
.langs .lang-select { flex:1 0 160px; min-width: 46%; }
select, input, textarea{ font-size: 16px; } /* يمنع iOS zoom */
@media (max-width: 560px){
  .langs { overflow-x: auto; scrollbar-width: none; }
  .langs::-webkit-scrollbar{ display:none; }
}

/* ===== Buttons: حالة تحميل موحّدة (سبينر) ===== */
.btn.loading{
  position: relative; pointer-events: none; opacity:.85;
}
.btn.loading::after{
  content:"";
  position:absolute; right:10px; top:50%;
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.8);
  border-top-color: transparent;
  transform: translateY(-50%);
  animation: spin .8s linear infinite;
}
@keyframes spin{ to{ transform: translateY(-50%) rotate(360deg); } }

/* ===== Top progress bar (fallback سريع) ===== */
.top-progress{
  position: fixed; left:0; top:0; height:3px; width:0;
  background: linear-gradient(90deg, #7aa2ff, #f8d66d);
  z-index: 9999; transition: width .35s ease;
}
.top-progress.on{ width: 85vw; }

/* ===== Skeleton overlay (لو عندك) ===== */
.skel-overlay{
  display:none; position: fixed; inset:0;
  background: rgba(0,0,0,.25); z-index: 9998;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.skel-container{ max-width: 960px; margin: 80px auto; padding: 0 16px; }
.skel-card{ background: var(--panel); border:1px solid var(--border);
  border-radius:12px; padding:14px; margin-bottom:10px; }
.skel-line{ height:12px; background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.18), rgba(255,255,255,.08));
  border-radius:6px; margin:8px 0; animation: pulse 1.2s ease-in-out infinite; }
.skel-line.thin{ height:8px; } .skel-line.thick{ height:16px; }
@keyframes pulse{ 50%{ opacity:.55 } }

/* ===== Larger Toast (مقروء وواضح) ===== */
#toast, .toast{
  position: fixed;
  left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  min-width: 280px; max-width: min(560px, 92vw);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px; font-size: 15.5px; line-height: 1.4;
  z-index: 10000;
}


/* منع تمرير أفقي */
html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }

/* تجميع الهيدر */
.header-row{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.header-right{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.lang-select{ min-height: 40px; font-size: 16px; }

/* اخفاء الـ tagline على الشاشات الصغيرة */
@media (max-width: 640px){
  .tagline{ display:none !important; }
}

/* عناصر نخفيها على الموبايل ونُظهرها على الديسكتوب فقط */
.header-item--desktop-only{ display:none; }
@media (min-width: 768px){
  .header-item--desktop-only{ display:inline-flex; }
}

/* زر اسم المستخدم (pill) */
.user-toggle{
  display:flex; align-items:center; gap:8px;
  border-radius: 12px; padding: 8px 12px;
}
.user-toggle .avatar-dot{
  width:10px; height:10px; border-radius:50%;
  background: #7aa2ff; display:inline-block;
}

/* قائمة الحساب المنسدلة: fixed داخل الشاشة */
.profile-menu{
  display:none;
  position: fixed;
  right: 12px; left: 12px;
  top: calc(56px + env(safe-area-inset-top, 0px) + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 96px - env(safe-area-inset-bottom, 0px));
  overflow: auto; z-index: 1000;
  padding: 8px;
}
.profile-menu.open{ display:block; }
.menu-item{
  display:block; width:100%;
  padding:10px 12px; border-radius:10px;
  color: var(--text); text-align:left;
  background: transparent; border: 1px solid transparent;
}
.menu-item:hover{ background: var(--panel); border-color: var(--border); }
.menu-item.danger{ color: #ffb4b4; }
body.menu-open{ overflow:hidden; }

/* تحسينات لمس */
.btn, .menu-item, .lang-select{ min-height: 44px; }


#userBox .mini strong {
  max-width: 160px; display: inline-block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}


/* Dropdown تحت زر المستخدم */
#userBox { position: relative; }
#userMenu.dropdown{
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 1000;
}
#userMenu.open{ display:block; }
#userMenu .dropdown-item{
  display:block; width:100%;
  text-align: left;
  padding:10px 12px;
  border-radius:10px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit; text-decoration: none;
}
#userMenu .dropdown-item:hover{
  background: var(--panel);
  border-color: var(--border);
}
#userMenu .dropdown-item.danger{ color:#ffb4b4; }

/* موبايل: خليه ثابت داخل الشاشة لو الهيدر قريب من الحافة */
@media (max-width: 640px){
  #userMenu.dropdown{
    position: fixed;
    right: 12px; left: 12px;
    top: 64px; /* عدّل حسب ارتفاع هيدرِك */
  }
}


.modal{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:1000; }
.modal.open{ display:block; }
.modal-card{ max-width:520px; margin: 64px auto; position:relative; }
.modal .close{
  position:absolute; right:12px; top:12px; border:0; background:transparent;
  font-size:18px; cursor:pointer;
}
body.modal-open{ overflow:hidden; }
