:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #15181c;
  --muted: #5b6370;
  --line: #e3e0d8;
  --accent: #0b6e5f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ed;
  --warn-soft: #f3efe4;
  --radius: 14px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #16191e;
    --ink: #eceef1;
    --muted: #98a1ad;
    --line: #262a31;
    --accent: #41c2aa;
    --accent-ink: #06231e;
    --accent-soft: #11302b;
    --warn-soft: #1d1f24;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
}
a { color: var(--accent); text-underline-offset: 3px; }
bdi { unicode-bidi: isolate; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* الرأس */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.head-row { display: flex; align-items: center; padding-block: 12px 6px; }
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 700; font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.brand small { font-weight: 400; font-size: 0.82rem; color: var(--muted); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; align-self: center;
  background:
    linear-gradient(var(--accent-ink), var(--accent-ink)) 5px 100% / 3px 45% no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) 50% 100% / 3px 75% no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) calc(100% - 5px) 100% / 3px 30% no-repeat,
    var(--accent);
  background-origin: content-box; padding: 4px 0;
}
.nav-row { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-block: 4px 8px; }
.nav-row::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: none; padding: 5px 12px; border-radius: 999px; font-size: 0.9rem;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); background: var(--bg); }
.site-nav a[aria-current='page'] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* المقدمة */
.hero { padding-block: 40px 8px; }
.stamp {
  display: inline-block; margin: 0 0 14px; padding: 2px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.85rem; font-weight: 600;
}
h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); line-height: 1.3; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; line-height: 1.4; margin: 0 0 12px; }
.lead { font-size: 1.2rem; max-width: 62ch; margin: 0 0 10px; }
.note { color: var(--muted); max-width: 62ch; margin: 0 0 26px; font-size: 0.98rem; }

.podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1.25fr 1fr 1fr; }
.podium-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.podium-card.is-first { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.podium-place { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.is-first .podium-place { color: var(--accent); }
.podium-model { font-weight: 700; font-size: 1.15rem; line-height: 1.4; overflow-wrap: anywhere; }
.is-first .podium-model { font-size: 1.35rem; }
.podium-org { color: var(--muted); font-size: 0.9rem; }
.podium-score { margin-top: 8px; font-size: 0.95rem; color: var(--muted); }
.podium-score b { font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.podium-score small { font-size: 0.85rem; }

/* الأقوى في كل مجال */
section { margin-block: 44px; }
.hero { margin-block: 0; }
.field-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.field-card {
  display: flex; flex-direction: column; gap: 1px; padding: 14px 16px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.field-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.field-name { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.field-model { font-weight: 700; overflow-wrap: anywhere; line-height: 1.45; }
.field-meta { font-size: 0.85rem; color: var(--muted); }

.measures p, .explain ul, .faq p { max-width: 70ch; }
.measures { background: var(--warn-soft); border-radius: var(--radius); padding: 18px 20px; }
.measures h2 { font-size: 1.05rem; margin-bottom: 4px; }
.measures p { margin: 0; }

/* التبويبات */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; font: inherit; font-size: 0.93rem; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); white-space: nowrap;
}
.tabs button[aria-selected='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }

/* الجدول */
.board { margin-block: 28px; scroll-margin-top: 110px; }
.board-lead { color: var(--muted); margin: 0 0 14px; max-width: 70ch; }
.board-lead strong { color: var(--ink); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.field-search { flex: 1 1 240px; }
.controls input[type='search'], .controls select {
  width: 100%; font: inherit; font-size: 0.95rem; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.controls input:focus-visible, .controls select:focus-visible, .tabs button:focus-visible, .more:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.check { display: flex; align-items: center; gap: 6px; font-size: 0.95rem; cursor: pointer; white-space: nowrap; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
th, td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--surface); }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.c-rank { width: 52px; text-align: center; }
.rank { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 999px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.rank-top { background: var(--accent); color: var(--accent-ink); }
.c-model { min-width: 200px; }
.model { display: block; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.org { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.c-score { width: 190px; white-space: nowrap; }
.score { display: inline-block; min-width: 3.2em; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.bar { display: inline-block; width: 100px; height: 6px; border-radius: 999px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.c-ci, .c-votes { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; direction: ltr; text-align: end; }
th.c-ci, th.c-votes { direction: rtl; text-align: start; }
td.c-ci, td.c-votes { text-align: right; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag-open { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.empty td { text-align: center; color: var(--muted); padding-block: 28px; }

.board-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-top: 12px; }
.more {
  font: inherit; font-weight: 600; font-size: 0.95rem; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--accent); border: 1px solid var(--accent);
}
.more:hover { background: var(--accent); color: var(--accent-ink); }
.board-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* الشرح والأسئلة */
.explain ul { padding-inline-start: 1.2em; margin: 0; }
.explain li { margin-bottom: 8px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--accent); font-size: 1.3rem; line-height: 1.2; flex: none; }
.faq details[open] summary::after { content: '−'; }
.faq p { margin: 0 0 16px; color: var(--muted); }

.prose { padding-block: 40px 20px; max-width: 72ch; }
.prose h2 { margin-top: 36px; }
.prose ul { padding-inline-start: 1.2em; }
.prose li { margin-bottom: 6px; }

.site-foot { border-top: 1px solid var(--line); margin-top: 56px; padding-block: 24px 36px; font-size: 0.88rem; color: var(--muted); }
.site-foot p { margin: 0 0 6px; max-width: 80ch; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .brand small { display: none; }
  .hero { padding-top: 28px; }
  .podium { grid-template-columns: 1fr; }
  .c-votes, .c-lic { display: none; }
  .c-score { width: auto; }
  .bar { display: none; }
  .c-model { min-width: 0; }
  th, td { padding: 9px 10px; }
  .c-rank { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .field-card { transition: none; }
}
