/* =========================================================
   Bawabat Maroc — public stylesheet
   Colours: Moroccan green #006233, red #C1272D, gold #C9A227
   ========================================================= */
:root {
  --green: #006233;
  --green-600: #00552c;
  --green-50: #e8f3ed;
  --red: #c1272d;
  --red-50: #fbeceb;
  --gold: #c9a227;
  --sand: #faf6ef;
  --sand-2: #f3ece0;
  --ink: #1d1a16;
  --ink-2: #3d3730;
  --muted: #6c6358;
  --line: #e7dfd2;
  --white: #fff;
  --surface: #fff;
  --link: #006233;
  --link-hover: #00552c;
  --note-bg: #fffaf0;
  --note-line: #efe1b8;
  --row-alt: #fcfaf6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 26, 22, .05), 0 6px 20px rgba(29, 26, 22, .06);
  --shadow-lg: 0 10px 30px rgba(29, 26, 22, .12);
  --wrap: 1280px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--sand);
  text-rendering: optimizeLegibility;
}
[dir="rtl"] body { font-size: 18px; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 750; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 1em; }
.ico { flex: none; vertical-align: middle; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .wrap { padding-inline: 24px; } }
.narrow { max-width: 820px; }
.center-text { text-align: center; }
.muted { color: var(--muted); }
.skip-link { position: absolute; inset-inline-start: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { inset-inline-start: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 650; font-size: .95rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-600); color: #fff; }
.btn-ghost { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--green); color: var(--green); }
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: transparent; border: 0; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--sand-2); color: var(--green); }
.chip {
  --c: var(--green);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px; font-size: .88rem; font-weight: 600;
  background: color-mix(in srgb, var(--c) 9%, var(--surface)); color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 22%, var(--surface));
  text-decoration: none; white-space: nowrap;
}
.chip:hover { background: var(--c); color: #fff; border-color: var(--c); }
.chip-sm { padding: 3px 10px; font-size: .78rem; }

/* ---------- Zellige strip (pure CSS pattern) ---------- */
.zellige {
  height: 6px;
  background:
    linear-gradient(135deg, var(--green) 25%, transparent 25%) -6px 0 / 12px 12px,
    linear-gradient(225deg, var(--green) 25%, transparent 25%) -6px 0 / 12px 12px,
    linear-gradient(315deg, var(--red) 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(45deg, var(--red) 25%, transparent 25%) 0 0 / 12px 12px,
    var(--gold);
}

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--line); }
body.nav-open .site-header { z-index: 80; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 66px; }
.header-search { flex: 1; max-width: 520px; margin-inline-start: auto; display: flex; align-items: center; gap: 8px; background: var(--sand); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; color: var(--muted); }
.header-search:focus-within { border-color: var(--green); background: var(--surface); }
.header-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: .92rem; padding: 10px 0; color: var(--ink); }
.header-actions { margin-inline-start: auto; }
.header-search + .header-actions { margin-inline-start: 0; }
.nav-row { border-top: 1px solid var(--line); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-img { height: 44px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; font-size: 1.22rem; letter-spacing: -.02em; color: var(--ink); }
.brand-name b { color: var(--red); font-weight: 800; }
.brand-ar { font-size: .78rem; color: var(--muted); margin-top: 3px; font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }
.main-nav { margin: 0; }
.nav-list { list-style: none; margin: 0 -8px; padding: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.nav-list > li { position: relative; }
.nav-list > li > a {
  display: inline-flex; align-items: center; gap: 3px; padding: 9px 7px; border-radius: 10px;
  color: var(--ink-2); font-weight: 600; font-size: .88rem; text-decoration: none; white-space: nowrap;
}
.nav-list > li > a:hover, .nav-list > li:focus-within > a { color: var(--green); background: var(--green-50); }
.nav-list .caret { opacity: .55; width: 12px; height: 12px; }
.sub {
  list-style: none; margin: 0; padding: 8px; position: absolute; top: 100%; inset-inline-start: 0;
  min-width: 250px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.has-sub:hover > .sub, .has-sub:focus-within > .sub { opacity: 1; visibility: visible; transform: none; }
.nav-list > li:nth-last-child(-n+4) > .sub { inset-inline-start: auto; inset-inline-end: 0; }
html { overflow-x: clip; }
.sub a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-size: .93rem; font-weight: 550; }
.sub a:hover { background: var(--sand); color: var(--green); }
.sub .ico { color: var(--green); }
.header-actions { display: flex; align-items: center; gap: 4px; }
.menu-toggle, .nav-head, .nav-search { display: none; }

.lang-banner { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 90; max-width: 560px; margin-inline: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #15120e; color: #fff; padding: 12px 14px 12px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: .95rem; animation: bannerIn .25s ease; }
.lang-banner span { flex: 1 1 200px; }
.lang-banner .lang-x { background: none; border: 0; color: #cfc6b8; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px; }
@keyframes bannerIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.nav-overlay { position: fixed; inset: 0; background: rgba(20, 16, 12, .45); z-index: 60; }

@media (min-width: 1200px) { .search-btn { display: none; } }
@media (max-width: 1199px) {
  .header-search { display: none; }
  .nav-row { border: 0; }
  .menu-toggle { display: inline-grid; }
  .main-nav {
    display: none; position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(88vw, 360px); z-index: 70;
    background: var(--surface); padding: 14px 16px 30px; overflow-y: auto; margin: 0; box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: block; animation: navIn .2s ease; }
  @keyframes navIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  [dir="rtl"] .main-nav.open { animation-name: navInRtl; }
  @keyframes navInRtl { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .nav-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 1.1rem; margin-bottom: 10px; }
  .nav-search { display: block; margin-bottom: 12px; }
  .nav-search input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: var(--sand); }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-list > li { border-bottom: 1px solid var(--line); }
  .nav-list > li > a { padding: 13px 4px; font-size: 1rem; justify-content: space-between; border-radius: 0; }
  .nav-list > li > a:hover { background: transparent; }
  .nav-list .caret { display: none; }
  .sub { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 0 0 10px; min-width: 0; }
  .sub a { padding: 8px 6px; font-size: .92rem; }
  body.nav-open { overflow: hidden; }
}
@media (max-width: 420px) {
  .brand-ar { display: none; }
  .brand-name { font-size: 1.1rem; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 400px at 85% -10%, rgba(201, 162, 39, .16), transparent 60%),
    radial-gradient(900px 380px at 0% 110%, rgba(0, 98, 51, .12), transparent 60%),
    var(--sand);
  border-bottom: 1px solid var(--line);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23006233' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M32 4l8 20 20 8-20 8-8 20-8-20-20-8 20-8z'/%3E%3Crect x='22' y='22' width='20' height='20' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E");
}
.hero-inner { position: relative; z-index: 1; padding-block: 56px 50px; text-align: center; max-width: 900px; }
.hero h1 { margin-bottom: .45em; }
.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 720px; }
.hero .lead { margin-inline: auto; }
.hero-search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow-lg); max-width: 680px; margin: 26px auto 18px;
}
[dir="rtl"] .hero-search { padding: 6px 18px 6px 6px; }
.hero-search .ico { color: var(--muted); }
.hero-search input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 1rem; padding: 10px 4px; background: transparent; color: var(--ink); }
.hero-search-sm { margin: 18px 0 8px; box-shadow: var(--shadow); max-width: 620px; }
.center-text .hero-search-sm { margin-inline: auto; }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
@media (max-width: 560px) {
  .hero-inner { padding-block: 36px 34px; }
  .hero-search { border-radius: 16px; padding: 6px; }
  .hero-search .ico { display: none; }
  .hero-search .btn { padding: 11px 14px; }
  .hero-chips span { width: 100%; }
}

/* ---------- Sections ---------- */
.section { padding-block: 52px; }
.section-tight { padding-block: 28px 52px; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.section-head h2 { margin: 0; position: relative; padding-inline-start: 14px; }
.section-head h2::before { content: ""; position: absolute; inset-inline-start: 0; top: .2em; bottom: .2em; width: 5px; border-radius: 4px; background: linear-gradient(var(--red), var(--gold)); }
.section-head.center { justify-content: center; }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; text-decoration: none; white-space: nowrap; }
[dir="rtl"] .link-more .ico, [dir="rtl"] .cat-go, [dir="rtl"] .tool-go { transform: scaleX(-1); }

/* ---------- Category cards ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cat-card { --c: var(--green); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: border-color .15s, transform .15s; }
.cat-card:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--surface)); transform: translateY(-2px); }
.cat-main { display: flex; align-items: center; gap: 14px; padding: 18px; text-decoration: none; color: var(--ink); }
.cat-ico { display: inline-grid; place-items: center; width: 50px; height: 50px; border-radius: 14px; flex: none; background: color-mix(in srgb, var(--c, var(--green)) 12%, var(--surface)); color: var(--c, var(--green)); }
.cat-ico-lg { width: 62px; height: 62px; border-radius: 18px; }
.cat-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cat-name { font-weight: 750; font-size: 1.06rem; }
.cat-count { font-size: .85rem; color: var(--muted); }
.cat-go { color: var(--muted); }
.cat-kids { list-style: none; margin: 0; padding: 0 18px 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.cat-kids a { display: inline-block; font-size: .82rem; padding: 4px 10px; border-radius: 999px; background: var(--sand); color: var(--ink-2); text-decoration: none; border: 1px solid var(--line); }
.cat-kids a:hover { color: var(--c); border-color: var(--c); }

/* ---------- Post cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card-grid-2 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-media { --c: var(--green); display: block; aspect-ratio: 16 / 8; background: var(--sand-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-visual {
  width: 100%; height: 100%; display: grid; place-items: center; color: #fff;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M24 3l6 15 15 6-15 6-6 15-6-15-15-6 15-6z' fill='none' stroke='%23fff' stroke-opacity='.14' stroke-width='1.3'/%3E%3C/svg%3E"),
    linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 62%, #000));
}
.card-visual .ico { width: 46px; height: 46px; opacity: .95; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body .chip { align-self: flex-start; }
.card-title { font-size: 1.08rem; margin: 0; line-height: 1.35; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--green); }
.card-desc { color: var(--muted); font-size: .93rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---------- Tools ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tool-card { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.section-alt .tool-card { background: var(--sand); }
.tool-card:hover { border-color: var(--gold); }
.tool-card > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.tool-card strong { font-size: 1.05rem; }
.tool-card span span { color: var(--muted); font-size: .9rem; }
.tool-ico { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(135deg, var(--gold), #a8831a); color: #fff; flex: none; }
.tool-go { color: var(--muted); }

/* ---------- Why ---------- */
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-bottom: 26px; }
.why { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-align: center; }
.why-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--green-50); color: var(--green); margin-bottom: 10px; }
.why h3 { margin-bottom: .3em; }
.why p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Notices ---------- */
.notice { display: flex; gap: 14px; align-items: flex-start; background: var(--note-bg); border: 1px solid var(--note-line); border-inline-start: 4px solid var(--gold); border-radius: var(--radius-sm); padding: 16px 18px; margin: 28px 0 0; font-size: .93rem; color: var(--ink-2); }
.notice .ico { color: #a8831a; margin-top: 2px; }
.notice p { margin: .2em 0 0; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .ico { margin: 0 auto 8px; display: block; }
.alert { display: flex; gap: 10px; align-items: center; padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 550; }
.alert-ok { background: var(--green-50); color: var(--green-600); border: 1px solid #bfdccb; }
.alert-err { background: var(--red-50); color: #9b1c21; border: 1px solid #f0c4c6; }

/* ---------- Page hero / breadcrumb ---------- */
.page-hero { --c: var(--green); background: linear-gradient(180deg, var(--surface), var(--sand)); border-bottom: 1px solid var(--line); padding-block: 22px 28px; }
.page-hero h1 { margin-bottom: .25em; }
.page-hero .lead { margin: 0; }
.page-hero-row { display: flex; align-items: center; gap: 18px; margin-top: 8px; }
.sub-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.breadcrumb ol { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: .84rem; color: var(--muted); }
.breadcrumb li:not(:last-child)::after { content: "›"; margin-inline-start: 6px; color: #b2a898; }
[dir="rtl"] .breadcrumb li:not(:last-child)::after { content: "‹"; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--green); text-decoration: underline; }
.breadcrumb li { max-width: 100%; min-width: 0; }
.breadcrumb li[aria-current] span { color: var(--ink-2); display: inline-block; max-width: min(46ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (max-width: 560px) { .page-hero-row .cat-ico-lg { width: 50px; height: 50px; } }

/* ---------- Post layout ---------- */
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; padding-block: 26px 56px; align-items: start; }
@media (max-width: 980px) { .post-layout { grid-template-columns: minmax(0, 1fr); } }
.post { --c: var(--green); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(18px, 3vw, 38px); box-shadow: var(--shadow); min-width: 0; }
.post-head { margin-bottom: 18px; }
.narrow .post-head { padding-top: 26px; }
.post-head .chip { margin-bottom: 12px; }
.post-head .lead { color: var(--ink-2); }
.post-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .86rem; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--line); }
.post-meta span { display: inline-flex; align-items: center; gap: 6px; }
.official { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: var(--green-50); border: 1px solid #c5e0d0; border-radius: var(--radius); padding: 14px 18px; margin: 18px 0; }
.official-txt { display: flex; flex-direction: column; min-width: 0; }
.official-label { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--green-600); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.official-txt strong { overflow-wrap: anywhere; }
.post-cover { margin: 18px 0; }
.post-cover img { border-radius: var(--radius); width: 100%; }
.toc { background: var(--sand); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 22px 0; }
.toc summary { cursor: pointer; font-weight: 750; display: flex; align-items: center; gap: 8px; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { margin: 10px 0 0; padding-inline-start: 22px; }
.toc li { margin: 4px 0; font-size: .95rem; }
.toc li.lv3 { margin-inline-start: 16px; list-style: circle; font-size: .9rem; }
.toc a { text-decoration: none; color: var(--ink-2); }
.toc a:hover { color: var(--green); text-decoration: underline; }

/* ---------- Prose (article content) ---------- */
.prose { font-size: 1.04rem; overflow-wrap: break-word; }
.prose h2 { margin-top: 1.8em; padding-bottom: .3em; border-bottom: 2px solid var(--sand-2); }
.prose h3 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: 0 0 1.1em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--green); font-weight: 700; }
.prose blockquote { margin: 1.4em 0; padding: 12px 18px; border-inline-start: 4px solid var(--gold); background: var(--note-bg); border-radius: 0 10px 10px 0; color: var(--ink-2); }
[dir="rtl"] .prose blockquote { border-radius: 10px 0 0 10px; }
.prose img { border-radius: 12px; margin: 1.2em 0; }
.prose figure { margin: 1.4em 0; }
.prose figcaption { font-size: .85rem; color: var(--muted); text-align: center; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 12px; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; min-width: 480px; }
.prose th, .prose td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--green); color: #fff; font-weight: 650; }
.prose tr:nth-child(even) td { background: var(--row-alt); }
.prose tr:last-child td { border-bottom: 0; }
.prose .note, .prose .tip { background: var(--green-50); border: 1px solid #c5e0d0; border-radius: 12px; padding: 14px 18px; margin: 1.3em 0; }
.prose .warning { background: var(--red-50); border: 1px solid #f0c4c6; border-radius: 12px; padding: 14px 18px; margin: 1.3em 0; }
.prose .note > :last-child, .prose .tip > :last-child, .prose .warning > :last-child { margin-bottom: 0; }
.prose ol.steps { list-style: none; counter-reset: s; padding: 0; }
.prose ol.steps > li { counter-increment: s; position: relative; padding: 2px 0 14px; padding-inline-start: 50px; margin: 0; }
.prose ol.steps > li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .95rem; }
.prose ol.steps > li:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 16px; top: 36px; bottom: 0; width: 2px; background: var(--green-50); }

/* ---------- FAQ ---------- */
.faq { margin-top: 34px; }
.faq-item { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--surface); }
.faq-item summary { cursor: pointer; padding: 14px 18px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--green); flex: none; }
.faq-item[open] summary::after { content: "−"; }
.faq-item[open] summary { border-bottom: 1px solid var(--line); }
.faq-a { padding: 12px 18px 4px; color: var(--ink-2); }

/* ---------- Share & related ---------- */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 26px; font-size: .9rem; color: var(--muted); }
.share > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.share a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .85rem; }
.share a:hover { border-color: var(--green); color: var(--green); }
.related { margin-top: 38px; padding-top: 26px; border-top: 1px solid var(--line); }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 92px; }
@media (max-width: 980px) { .sidebar { position: static; } }
.side-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.side-title { font-size: 1rem; margin-bottom: 12px; }
.side-search { display: flex; gap: 6px; }
.side-search input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--sand); }
.side-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 10px; font-size: .93rem; }
.side-list li::marker { color: var(--red); font-weight: 800; }
.side-list a { color: var(--ink-2); text-decoration: none; }
.side-list a:hover { color: var(--green); }
.side-cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.side-cats a { --c: var(--green); display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .93rem; }
.side-cats a:hover { background: var(--sand); color: var(--c); }
.side-cats .dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); }
.side-tool { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); text-decoration: none; color: #fff; background: linear-gradient(135deg, var(--green), #013d21); box-shadow: var(--shadow); }
.side-tool:hover { color: #fff; filter: brightness(1.08); }
.side-tool span { display: flex; flex-direction: column; }
.side-tool span span { font-size: .85rem; opacity: .85; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 30px; }
.pg { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 650; }
.pg.current { background: var(--green); color: #fff; border-color: var(--green); }
.pg.dots { border: 0; background: transparent; }

/* ---------- Forms ---------- */
.contact-form { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 22px 0 50px; box-shadow: var(--shadow); }
.contact-form label, .calc label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .93rem; }
.contact-form input, .contact-form textarea, .calc input {
  font: inherit; font-weight: 400; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--sand); color: var(--ink); width: 100%;
}
.contact-form input:focus, .contact-form textarea:focus, .calc input:focus { outline: 2px solid var(--green); outline-offset: 0; background: var(--surface); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-note { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; margin: 0; }
.contact-form .btn { align-self: flex-start; }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Calculator ---------- */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(18px, 3vw, 30px); box-shadow: var(--shadow-lg); margin-bottom: 30px; }
.calc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 680px) { .calc-grid { grid-template-columns: 1fr; } }
.calc input { font-size: 1.15rem; font-weight: 650; }
.calc-result { margin-top: 18px; text-align: center; padding: 20px; border-radius: 14px; background: var(--green-50); border: 1px solid #c5e0d0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.calc-result.is-fail { background: var(--red-50); border-color: #f0c4c6; }
.calc-label { font-size: .9rem; color: var(--muted); font-weight: 600; }
.calc-value { font-size: 2.4rem; font-weight: 850; color: var(--green-600); line-height: 1.1; }
.is-fail .calc-value { color: var(--red); }
.calc-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badge { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: .88rem; }
.badge.ok { background: var(--green); color: #fff; border-color: var(--green); }
.badge.ko { background: var(--red); color: #fff; border-color: var(--red); }
.calc-err { color: var(--red); font-weight: 600; margin: 12px 0 0; }
.calc-nat { margin-top: 20px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--sand); }
.calc-nat summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.nat-table { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.nat-head, .nat-row { display: grid; grid-template-columns: 1.6fr 1fr .8fr 40px; gap: 8px; align-items: center; }
.nat-head { font-size: .8rem; color: var(--muted); font-weight: 700; }
.nat-row input { padding: 8px 10px; font-size: .95rem; font-weight: 500; }
.nat-table .btn-sm { align-self: flex-start; }
.nat-out { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.calc-note { font-size: .86rem; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; }

/* ---------- 404 ---------- */
.big-404 { font-size: clamp(4rem, 10vw, 7rem); font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--green), var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 10px; }

/* ---------- Footer ---------- */
.site-footer { background: #15120e; color: #cfc6b8; margin-top: 0; font-size: .93rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 34px; padding-block: 44px 28px; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } .f-about { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.brand-footer .brand-name { color: #fff; font-size: 1.35rem; }
.f-about p { margin-top: 12px; color: #b7ad9e; max-width: 46ch; }
.f-title { color: #fff; font-size: 1rem; margin-bottom: 12px; }
.f-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.site-footer a { color: #e6ddcf; text-decoration: none; }
.site-footer a:hover { color: var(--gold); text-decoration: underline; }
.social { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.social a { display: inline-block; padding: 6px 12px; border: 1px solid #3a332b; border-radius: 999px; font-size: .85rem; }
.f-disclaimer { display: flex; gap: 10px; align-items: flex-start; font-size: .84rem; color: #a59b8c; border-top: 1px solid #2b251f; padding-block: 16px; }
.footer-bottom { border-top: 1px solid #2b251f; padding-block: 16px 24px; font-size: .84rem; color: #9a907f; }

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .sidebar, .share, .related, .official .btn { display: none !important; }
  .post { border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Top bar (disclaimer, dark mode, language) ---------- */
.topbar { background: #15120e; color: #e6ddcf; font-size: .84rem; }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.topbar-note { flex: 1; min-width: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.topbar-note { text-align: center; }
.nav-row .wrap { display: flex; align-items: center; gap: 12px; }
.nav-row .main-nav { flex: 1; min-width: 0; }
.nav-controls, .mobile-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.mobile-controls { display: none; }
.nav-controls .theme-btn { padding: 0 10px; }
.nav-controls .theme-btn span { display: none; }
.theme-btn, .lang-menu summary {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font: inherit; font-size: .85rem; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.theme-btn:hover, .lang-menu summary:hover, .lang-menu[open] summary { background: var(--sand); color: var(--link); border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 95; list-style: none; margin: 0; padding: 6px; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
.lang-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .93rem; }
.lang-menu a:hover { background: var(--sand); color: var(--link); }
.lang-menu a.active { color: var(--link); background: var(--green-50); }
.flag { width: 21px; height: 14px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); display: block; }
@media (max-width: 1199px) {
  .nav-controls { display: none; }
  .mobile-controls { display: flex; gap: 6px; }
  .theme-btn span, .mobile-controls .lang-name { display: none; }
  .theme-btn, .lang-menu summary { padding: 0 9px; height: 36px; }
}
@media (max-width: 640px) {
  .topbar-note { font-size: .76rem; }
  .topbar-inner { min-height: 32px; }
}

/* ---------- Dark mode ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --sand: #12100d; --sand-2: #1f1b16; --surface: #1a1713;
  --ink: #f1ece4; --ink-2: #d8cfc2; --muted: #a59b8c; --line: #302a23;
  --green-50: #10291c; --red-50: #2b1515;
  --link: #5fd39a; --link-hover: #86e3b5;
  --note-bg: #241f14; --note-line: #4a3f22; --row-alt: #1f1b16;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
}
:root[data-theme="dark"] .hero::after { opacity: .25; }
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .cat-ico,
:root[data-theme="dark"] .side-cats .dot,
:root[data-theme="dark"] .sub .ico,
:root[data-theme="dark"] .cdot { color: color-mix(in srgb, var(--c, var(--green)) 45%, #fff); }
:root[data-theme="dark"] .chip:hover { color: #fff; }
:root[data-theme="dark"] .why-ico,
:root[data-theme="dark"] .official-label,
:root[data-theme="dark"] .alert-ok,
:root[data-theme="dark"] .calc-value,
:root[data-theme="dark"] .prose li::marker,
:root[data-theme="dark"] .faq-item summary::after { color: var(--link); }
:root[data-theme="dark"] .official,
:root[data-theme="dark"] .prose .note,
:root[data-theme="dark"] .prose .tip,
:root[data-theme="dark"] .calc-result { border-color: #23533a; }
:root[data-theme="dark"] .prose .warning,
:root[data-theme="dark"] .alert-err { border-color: #5a2626; color: #f3c5c7; }
:root[data-theme="dark"] .notice .ico { color: var(--gold); }
:root[data-theme="dark"] .brand-ar { color: #b9ae9e; }
:root[data-theme="dark"] .nav-overlay { background: rgba(0, 0, 0, .6); }
:root[data-theme="dark"] img { opacity: .94; }
:root[data-theme="dark"] .lang-banner { background: #2a241d; border: 1px solid #4a4237; }
@media (max-width: 480px) {
  .search-btn { display: none; } /* search stays available inside the menu panel */
  .header-inner { gap: 8px; }
  .mobile-controls { gap: 4px; }
  .theme-btn, .lang-menu summary { padding: 0 7px; gap: 4px; }
}
