/* =========================================================================
   Concours Maroc — design system for the whole site
   Identity: exam ink on paper, with the eight-point zellij star as the single
   signature element. Green = the star of the flag; red only for errors.
   One stylesheet, no framework, no web font: fast on 3G and cheap phones.
   ========================================================================= */

:root {
  --pine-900: #081913;
  --pine-800: #0d2620;
  --pine-700: #123329;
  --zellij: #0b6e4f;
  --zellij-l: #16916a;
  --brass: #b98b1f;
  --brass-l: #d9ab3e;
  --flag-red: #b32127;

  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eaeee9;
  --surface-3: #dfe5df;
  --ink: #081913;
  --ink-2: #33463f;
  --muted: #56675f;
  --line: #d3dbd5;
  --accent: var(--zellij);
  --accent-2: #095c42;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ea;
  --gold: #8c6a12;
  --gold-soft: #f7efd9;
  --ok-bg: #dff0e6;
  --ok-line: var(--zellij);
  --ok-ink: #06503a;
  --bad-bg: #fbe4e5;
  --bad-line: var(--flag-red);
  --bad-ink: #8a171c;
  --warn-bg: #fff4dc;
  --warn-line: #d9a21b;
  --warn-ink: #6b4d00;
  --info-bg: #e6f0fb;
  --info-line: #3b78c2;
  --info-ink: #173e6b;
  --shadow: 0 1px 2px rgba(8, 25, 19, .06), 0 6px 20px rgba(8, 25, 19, .07);
  --shadow-lift: 0 2px 4px rgba(8, 25, 19, .08), 0 14px 34px rgba(8, 25, 19, .12);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-ar: "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, "Geeza Pro", "Droid Arabic Naskh", sans-serif;
  --fs-xs: .78rem;
  --fs-sm: .9rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  --tap: 46px;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --gap: 16px;
  --pad: 20px;
  --maxw: 1160px;
  --readw: 760px;
  --header-h: 60px;
  --star: polygon(50% 0%, 62% 27%, 91% 15%, 79% 44%, 100% 50%, 79% 56%, 91% 85%, 62% 73%,
                  50% 100%, 38% 73%, 9% 85%, 21% 56%, 0% 50%, 21% 44%, 9% 15%, 38% 27%);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: var(--pine-900);
  --surface: var(--pine-800);
  --surface-2: var(--pine-700);
  --surface-3: #1a4034;
  --ink: #eaf1ed;
  --ink-2: #c3d2cb;
  --muted: #9bb0a7;
  --line: #1e4438;
  --accent: var(--zellij-l);
  --accent-2: #1fae80;
  --accent-ink: #04120d;
  --accent-soft: #103a2c;
  --gold: var(--brass-l);
  --gold-soft: #3a2f12;
  --ok-bg: #0d3a2a;
  --ok-line: var(--zellij-l);
  --ok-ink: #a8e6c8;
  --bad-bg: #3d1518;
  --bad-line: #e2646a;
  --bad-ink: #ffc4c7;
  --warn-bg: #3a2f12;
  --warn-line: #d9ab3e;
  --warn-ink: #f6dc9c;
  --info-bg: #13283f;
  --info-line: #6aa3e6;
  --info-ink: #cfe3fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 14px 34px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ========================================================== base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
html[dir="rtl"] body { font-family: var(--font-ar); line-height: 1.8; }
[lang="ar"] { font-family: var(--font-ar); }
[lang="fr"], [lang="en"] { font-family: var(--font-ui); }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 750; letter-spacing: -.01em; margin: 0 0 .5em; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { letter-spacing: 0; line-height: 1.45; }
h1 { font-size: clamp(1.6rem, 4.2vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.65rem); margin-top: 1.6em; }
h3 { font-size: 1.15rem; margin-top: 1.3em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }
img, svg { max-width: 100%; }
h1 > svg, h2 > svg, h3 > svg { width: 1.1em; height: 1.1em; vertical-align: -.15em; fill: currentColor; }
ul, ol { padding-inline-start: 1.3em; margin: 0 0 1em; }
li { margin: .25em 0; }
small { font-size: var(--fs-xs); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em;
  background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r-sm); }
.skip-link:focus { top: 10px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }
.narrow { max-width: var(--readw); }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

/* signature: eight-point zellij star as eyebrow rule */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); font-weight: 750; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.eyebrow::before { content: ""; flex: 0 0 10px; width: 10px; height: 10px; background: var(--accent); clip-path: var(--star); }
html[dir="rtl"] .eyebrow { letter-spacing: 0; }

/* ========================================================== header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar { display: flex; align-items: center; gap: 10px; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.08rem; }
.brand svg { width: 34px; height: 34px; flex: 0 0 34px; }
.brand span b { color: var(--accent); }
.brand:hover { color: var(--ink); }
.nav { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.nav a {
  text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm);
  padding: 8px 11px; border-radius: 10px; white-space: nowrap;
}
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.nav a.lang-switch { border: 1px solid var(--line); }
.hdr-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--ink); cursor: pointer; flex: 0 0 auto;
}
.hdr-btn:hover { background: var(--surface-2); }
.hdr-btn svg { width: 22px; height: 22px; fill: currentColor; }
.menu-btn { display: none; }
@media (max-width: 920px) {
  .menu-btn { display: inline-flex; }
  .nav {
    display: none; position: absolute; inset-inline: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lift);
    padding: 8px var(--pad) 14px; margin: 0;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 10px; font-size: var(--fs-md); border-radius: 10px; }
  .site-header .bar { position: relative; }
  .hdr-tools { margin-inline-start: auto; }
}
.hdr-tools { display: flex; align-items: center; gap: 2px; }

/* search */
.search-wrap { position: relative; }
.search-panel {
  display: none; position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
  width: min(92vw, 460px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-lift); padding: 12px; z-index: 60;
}
.search-panel.open { display: block; }
.search-panel input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.search-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.search-results li { margin: 0; }
.search-results a { display: block; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.search-results a:hover, .search-results a.active { background: var(--surface-2); }
.search-results small { display: block; color: var(--muted); }
.big-search { position: relative; max-width: 620px; }
.big-search input {
  width: 100%; min-height: 54px; padding: 12px 16px; padding-inline-start: 46px; font: inherit; font-size: 1.05rem;
  color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.big-search input:focus { border-color: var(--accent); outline: none; }
.big-search svg { position: absolute; inset-inline-start: 15px; top: 16px; width: 22px; height: 22px; fill: var(--muted); }
.big-search .search-results { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-lift); padding: 6px; }
.big-search .search-results:empty { display: none; }

/* ========================================================== hero */
.hero { padding: 34px 0 26px; }
.hero h1 { font-size: clamp(1.75rem, 5vw, 2.9rem); max-width: 18ch; }
html[dir="rtl"] .hero h1 { max-width: 22ch; }
.hero .lead { font-size: clamp(1.02rem, 2.2vw, 1.2rem); color: var(--ink-2); max-width: 62ch; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero-art { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; padding: 0; list-style: none; }
.stat-row li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: var(--fs-sm); margin: 0; }
.stat-row b { color: var(--accent); font-size: 1.05rem; }

/* ========================================================== buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 11px 20px; border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); transition: transform .1s ease, background .15s ease;
}
.btn:hover { background: var(--accent-2); color: var(--accent-ink); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.btn.quiet:hover { background: var(--surface-3); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.danger { background: var(--flag-red); color: #fff; }
.btn.sm { min-height: 38px; padding: 7px 13px; font-size: var(--fs-sm); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ========================================================== sections & cards */
.section { padding: 28px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--pad); box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-top: 0; }
a.card { display: block; color: inherit; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--accent); color: inherit; }
.card .card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card .card-ico {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.card .card-ico svg { width: 22px; height: 22px; fill: currentColor; }
.card .card-title { font-weight: 750; font-size: 1.05rem; line-height: 1.3; }
.card .card-sub { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.card .card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.path-card { position: relative; overflow: hidden; }
.path-card::after {
  content: ""; position: absolute; inset-inline-end: -22px; top: -22px; width: 86px; height: 86px;
  background: var(--accent); opacity: .08; clip-path: var(--star);
}

.badge, .chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.green, .chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge.red { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
.badge.blue { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ========================================================== breadcrumb */
.breadcrumb { font-size: var(--fs-sm); color: var(--muted); padding: 14px 0 0; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "›"; color: var(--muted); }
html[dir="rtl"] .breadcrumb li + li::before { content: "‹"; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }

/* ========================================================== article layout */
.page-head { padding: 10px 0 8px; }
.page-head h1 { margin-bottom: .35em; }
.page-head .lead { font-size: 1.1rem; color: var(--ink-2); max-width: 70ch; }
.updated { font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 34px; align-items: start; padding-bottom: 40px; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } .layout aside { order: -1; } }
@media (max-width: 1000px) { .tool-layout aside { order: 0; } }
.prose { max-width: var(--readw); }
.prose h2 { padding-top: .2em; border-top: 1px solid var(--line); padding-top: 1em; }
.prose h2:first-child { border-top: 0; padding-top: 0; margin-top: .5em; }
.prose table { margin: 1em 0 1.4em; }
.prose img { border-radius: var(--r-md); }
.aside-sticky { position: sticky; top: calc(var(--header-h) + 14px); display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1000px) { .aside-sticky { position: static; } }

.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font-size: var(--fs-sm); }
.toc strong { display: inline; }
.toc summary { cursor: pointer; margin-bottom: 6px; }
.toc ol { margin: 0; padding-inline-start: 1.1em; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 1000px) { .toc details:not([open]) ol { display: none; } }

.cta-box {
  background: linear-gradient(135deg, var(--zellij), #0d5b44);
  color: #fff; border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow);
}
.cta-box h3, .cta-box p { color: #fff; margin-top: 0; }
.cta-box p { opacity: .92; font-size: var(--fs-sm); }
.cta-box .btn { background: #fff; color: var(--zellij); }
.cta-box .btn:hover { background: #eaf6f0; color: #084a35; }
.cta-box .btn.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }

/* key facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 18px 0 8px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.fact .f-lab { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
html[dir="rtl"] .fact .f-lab { letter-spacing: 0; }
.fact .f-val { font-weight: 700; margin-top: 2px; line-height: 1.4; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.table-wrap table { margin: 0; }

/* callouts */
.callout { border-radius: var(--r-md); padding: 13px 16px; margin: 1em 0 1.4em; border: 1px solid; font-size: var(--fs-sm); }
.callout > :last-child { margin-bottom: 0; }
.callout .c-title { display: block; margin-bottom: 3px; font-weight: 800; }
.callout.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.callout.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.callout.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.callout a { color: inherit; font-weight: 700; }

/* steps */
.steps { list-style: none; padding: 0; margin: 1em 0 1.4em; counter-reset: step; }
.steps li { position: relative; padding-inline-start: 46px; margin: 0 0 14px; min-height: 34px; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; inset-inline-start: 0; top: 0; width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: var(--fs-sm);
}

/* checklist */
.checklist { list-style: none; padding: 0; }
.checklist li { position: relative; padding-inline-start: 28px; }
.checklist li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .45em; width: 14px; height: 14px; background: var(--accent); clip-path: var(--star); }

/* FAQ */
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 13px 16px; font-weight: 700; list-style: none; display: flex; gap: 10px; align-items: flex-start; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; flex: 0 0 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.faq details[open] summary::before { content: "−"; }
.faq .faq-a { padding: 0 16px 14px 48px; color: var(--ink-2); }
html[dir="rtl"] .faq .faq-a { padding: 0 48px 14px 16px; }
.faq .faq-a > :last-child { margin-bottom: 0; }

/* sources */
.sources { font-size: var(--fs-sm); }
.sources li { word-break: break-word; }

/* deadlines */
.deadlines { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.deadline {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; margin: 0;
}
.deadline .d-date { text-align: center; background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 6px 4px; line-height: 1.1; }
.deadline .d-date b { display: block; font-size: 1.35rem; }
.deadline .d-date span { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; }
.deadline .d-main a { font-weight: 750; text-decoration: none; color: var(--ink); }
.deadline .d-main a:hover { color: var(--accent); }
.deadline .d-main small { display: block; color: var(--muted); }
.deadline .d-left { font-weight: 800; font-size: var(--fs-sm); color: var(--gold); white-space: nowrap; }
.deadline.soon .d-left { color: var(--flag-red); }
.deadline.past { opacity: .62; }
@media (max-width: 520px) { .deadline { grid-template-columns: 56px 1fr; } .deadline .d-left { grid-column: 2; } }
.hero-art .deadline { grid-template-columns: 56px 1fr; }
.hero-art .deadline .d-left { grid-column: 2; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; align-items: center; }
.filters select, .filters input {
  min-height: 42px; padding: 8px 12px; font: inherit; font-size: var(--fs-sm); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.filters input[type="search"] { flex: 1 1 220px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button, .seg a {
  min-height: 40px; padding: 7px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-decoration: none;
}
.seg button[aria-pressed="true"], .seg a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* forms (tools) */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.result-box { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-md); padding: 16px; margin: 14px 0; }
.result-box .big { font-size: 2.2rem; font-weight: 850; color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums; }
.meter { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warn > i { background: var(--gold); }
.meter.bad > i { background: var(--flag-red); }

/* tools: results */
.result-line { font-weight: 700; margin: 6px 0 12px; }
.wavg-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.wavg-row input { width: 100%; min-height: 42px; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.wavg-row .icon-btn, .tool-icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.field input[aria-invalid="true"] { border-color: var(--flag-red); }
.orient-list { margin-bottom: 18px; }
.orient-card .card-title { display: block; color: var(--ink); text-decoration: none; }
.orient-card .card-title:hover { color: var(--accent); text-decoration: underline; }
.orient-card .card-meta .badge { white-space: normal; text-align: start; }
.orient-card.dim { opacity: .72; }
.check-items { list-style: none; padding: 0; margin: 0 0 8px; }
.check-items li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); margin: 0; }
.check-items input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check-items label { cursor: pointer; }
.check-items input:checked + label { color: var(--muted); text-decoration: line-through; }
.plan-weeks { display: grid; gap: 12px; }
.plan-week { padding: 14px 16px; }
.plan-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 10px; }
.plan-week .checklist { margin: 10px 0; font-size: var(--fs-sm); }
.plan-bars { display: grid; gap: 6px; }
.plan-bar-label { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
@media (max-width: 620px) { .wavg-row { grid-template-columns: minmax(0, 1fr) 72px 72px 40px; } }
@media print { .plan-week { break-inside: avoid; } .check-items input { accent-color: #000; } }

/* QCM sample pages */
.qcm-list { list-style: none; padding: 0; margin: 0; counter-reset: q; }
.qcm-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin: 0 0 14px; }
.qcm-item .q { font-weight: 700; margin-bottom: 10px; }
.qcm-item .q::before { counter-increment: q; content: counter(q) ". "; color: var(--accent); }
.qcm-item ol.opts { list-style: upper-alpha; margin: 0 0 8px; }
html[dir="rtl"] .qcm-item ol.opts { list-style: arabic-indic; }
.qcm-item details { margin-top: 6px; }
.qcm-item details summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: var(--fs-sm); }
.qcm-item .answer { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-ink); font-size: var(--fs-sm); }
.qcm-item .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* ========================================================== footer */
.site-footer { margin-top: 40px; background: var(--pine-900); color: #c9d6cf; padding: 34px 0 calc(24px + env(safe-area-inset-bottom, 0px)); font-size: var(--fs-sm); }
.site-footer a { color: #e9f2ed; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 24px; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-grid h2 { font-size: var(--fs-sm); color: #fff; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .08em; }
html[dir="rtl"] .footer-grid h2 { letter-spacing: 0; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: 6px 0; }
.footer-brand p { color: #9fb3aa; max-width: 40ch; }
.footer-bottom { border-top: 1px solid #1e4438; margin-top: 24px; padding-top: 16px; display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; color: #8fa59b; }

/* ========================================================== ads (disabled until configured) */
.ad-slot { margin: 22px 0; min-height: 100px; display: flex; align-items: center; justify-content: center; }
.ad-slot:empty { display: none; }

/* ========================================================== toast & sheet (shared) */
.toast {
  position: fixed; z-index: 90; inset-inline: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  margin: 0 auto; max-width: 480px; background: var(--pine-800); color: #eaf1ed;
  border-radius: var(--r-md); padding: 12px 16px; box-shadow: var(--shadow-lift); font-size: var(--fs-sm);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ========================================================== print */
@media print {
  .site-header, .site-footer, .aside-sticky .cta-box, .no-print, .ad-slot, .search-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { grid-template-columns: 1fr; }
  a { color: #000; }
  .card, .fact, .table-wrap { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
