:root {
  color-scheme: light;
  --bg: #f7f7f4; --surface: #ffffff; --text: #1f2328; --muted: #5f6670; --line: #e3e3dc;
  --accent: #0b6e99; --accent-soft: #e4f1f7; --brand: #0b4f6c;
  --geo: #9a6b1f; --geo-soft: #f6eedf; --gen: #2f7d4f; --gen-soft: #e3f2e8;
  --warn: #a4471b; --warn-soft: #fbeae2; --why: #6a4c9c; --why-soft: #f0ebf8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.7 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

header.top { background: var(--brand); color: #fff; }
header.top .wrap { display: flex; align-items: center; min-height: 56px; }
.brand { color: #fff; font-size: 1.4rem; font-weight: 700; font-family: "Noto Naskh Arabic", "Amiri", Tahoma, sans-serif; }
.brand:hover { text-decoration: none; }
.brand small { font-size: .85rem; font-weight: 400; opacity: .8; margin-inline-start: .5rem; }

main { padding-bottom: 64px; }
.crumbs { font-size: .9rem; color: var(--muted); padding-top: 14px; margin: 0; }
.eyebrow { font-size: .85rem; font-weight: 600; margin: 18px 0 0; letter-spacing: .02em; }
.eyebrow.u1 { color: var(--geo); } .eyebrow.u2 { color: var(--gen); }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 6px 0 10px; text-wrap: balance; }
h1 small { display: block; font-size: 1.1rem; font-weight: 500; color: var(--muted); margin-top: 4px; }
h1 .num { display: block; font-size: .95rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 24px; }
h2 { font-size: 1.45rem; line-height: 1.3; margin: 44px 0 12px; padding-top: 14px; border-top: 2px solid var(--line); text-wrap: balance; }
h3 { font-size: 1.15rem; margin: 28px 0 8px; }
h2 .tag { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; vertical-align: middle; margin-inline-end: 8px; }
h2.u1 .tag { background: var(--geo-soft); color: var(--geo); }
h2.u2 .tag { background: var(--gen-soft); color: var(--gen); }

.box { border-radius: 10px; padding: 12px 16px; margin: 16px 0; border-inline-start: 4px solid; }
.box > :first-child { margin-top: 0; } .box > :last-child { margin-bottom: 0; }
.box ul, .box ol { padding-inline-start: 22px; }
.obj { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); }
.def { background: var(--accent-soft); border-color: var(--accent); }
.def b:first-child { color: var(--accent); }
.key { background: var(--gen-soft); border-color: var(--gen); }
.warn { background: var(--warn-soft); border-color: var(--warn); }
.why { background: var(--why-soft); border-color: var(--why); }
.why > p:first-child b { color: var(--why); }
.ex { background: var(--geo-soft); border-color: var(--geo); }

.tbl { overflow-x: auto; margin: 14px 0; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--surface); }
th, td { border: 1px solid var(--line); padding: 7px 10px; text-align: start; vertical-align: top; }
th { background: var(--bg); }
.duo-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.eq { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 1.1rem; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 12px 0; overflow-x: auto; }
code, .seq { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
.seq { letter-spacing: .06em; }

figure { margin: 20px 0; }
figure img { display: block; width: 100%; height: auto; max-width: 100%; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
figure.narrow img { max-width: 440px; margin: 0 auto; }
figure.duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
figure.duo img { aspect-ratio: 4 / 3; object-fit: contain; }
figure.duo > div p { margin: 6px 0 0; font-size: .88rem; text-align: center; color: var(--muted); }
figure.duo figcaption { grid-column: 1 / -1; }
figcaption { font-size: .88rem; color: var(--muted); text-align: center; margin-top: 8px; }
.credit { font-size: .78rem; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; margin: 10px 0; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

ol.chapters { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
ol.chapters a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--text); border-inline-start: 4px solid; }
ol.chapters li.u1 a { border-inline-start-color: var(--geo); }
ol.chapters li.u2 a { border-inline-start-color: var(--gen); }
ol.chapters a:hover { text-decoration: none; border-color: var(--accent); }
ol.chapters .num { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
ol.chapters b { display: block; font-size: 1.05rem; color: var(--accent); }
ol.chapters span:last-child { display: block; font-size: .92rem; color: var(--muted); }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; margin-top: 48px; padding-top: 16px; border-top: 2px solid var(--line); }
.pager a { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.pager .next { text-align: end; }
.pager .home { align-self: center; }

footer { color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); margin-top: 48px; padding-top: 16px; }
.top-link { position: fixed; inset-inline-end: 16px; bottom: 16px; background: var(--brand); color: #fff; border-radius: 999px; width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.2rem; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.top-link:hover { text-decoration: none; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: start; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
