:root {
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F6F7FB;
  --ink: #161A33;
  --muted: #595F7E;
  --line: #D9DCE8;
  --accent: #3B4BC8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7E9FA;
  --gold: #B87A14;
  --gold-soft: #FBF1DE;

  --f-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-cond: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-naskh: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", serif;
  --f-amiri: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --f-kufi: "Reem Kufi", "Noto Naskh Arabic", "Geeza Pro", sans-serif;
  --f-arsans: "IBM Plex Sans Arabic", "Geeza Pro", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1022; --surface: #171A31; --surface-2: #1D2140; --ink: #ECEEF8; --muted: #A0A6C8;
    --line: #2C3052; --accent: #8E9BFF; --accent-ink: #0E1022; --accent-soft: #252B5E; --gold: #F0B550; --gold-soft: #2E2616;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1022; --surface: #171A31; --surface-2: #1D2140; --ink: #ECEEF8; --muted: #A0A6C8;
  --line: #2C3052; --accent: #8E9BFF; --accent-ink: #0E1022; --accent-soft: #252B5E; --gold: #F0B550; --gold-soft: #2E2616;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-sans);
  font-size: 15px; line-height: 1.55; padding-inline: 16px; padding-block: 0 48px;
}
.wrap { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ar { font-family: var(--f-naskh); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-family: var(--f-kufi); font-size: 22px; font-weight: 700; line-height: 1; padding-bottom: 4px;
}
.brand b { font-family: var(--f-cond); font-size: 22px; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.1; }
.nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--ink); }

.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

h1 { font-family: var(--f-cond); font-weight: 700; font-size: clamp(30px, 5vw, 44px); line-height: 1.05; margin: 0; text-wrap: balance; }
.lede { margin: 8px 0 0; color: var(--muted); font-size: 17px; max-width: 64ch; }

.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; }
.show { padding: 22px 20px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.big { font-family: var(--f-amiri); font-size: clamp(72px, 16vw, 132px); line-height: 1.5; margin: 0; direction: rtl; overflow-wrap: anywhere; }
.latin { color: var(--muted); margin: 0; }
.styles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px 20px 18px; }
.style {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; font: inherit;
}
.style:hover { border-color: var(--accent); }
.style[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.style .ar { font-size: 34px; line-height: 1.6; direction: rtl; }
.style > span:last-child { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; font: 500 14px/1 var(--f-sans); padding: 10px 13px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
h2 { font-family: var(--f-cond); font-size: 23px; margin: 0; line-height: 1.2; text-wrap: balance; }
.card p { margin: 0; color: var(--muted); max-width: 68ch; }
.card p strong { color: var(--ink); }

.letters { display: flex; gap: 8px; flex-wrap: wrap; direction: rtl; list-style: none; margin: 0; padding: 0; }
.letters li a, .letters li span.box {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 84px; padding: 8px 10px 10px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); text-decoration: none;
}
.letters li a:hover { border-color: var(--accent); }
.letters .ar { font-size: 36px; line-height: 1.5; }
.letters small { font-size: 12px; color: var(--muted); direction: ltr; text-align: center; }
.letters .step { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.warn { background: var(--gold-soft); border-radius: 12px; padding: 12px 14px; color: var(--ink); margin: 0; }

.related { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.related a {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: 14px;
}
.related a:hover { border-color: var(--accent); }
.related .ar { font-size: 17px; }

footer { color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }
footer a { color: var(--muted); }
footer .links { display: flex; gap: 16px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 10; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) { .styles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .nav { display: none; }
  .show, .styles, .actions { padding-inline: 14px; }
  .card { padding: 16px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .letters li a, .letters li span.box { min-width: 72px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
