/* kalameali.ir: Ali's words on the timeline of his life. Static, RTL, mobile first, no framework.
   Fonts: Vazirmatn (Persian), KFGQPC Uthman Taha (Arabic), both self-hosted. Colours are tokens on :root,
   redefined for dark mode. Motion only inside @supports + prefers-reduced-motion: no-preference. */

@font-face { font-family: "Vazirmatn"; src: url("fonts/Vazirmatn-variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "UthmanTaha"; src: url("fonts/UthmanTN_v2-0.ttf") format("truetype"); font-display: swap; }

:root {
  --bg: #f6f0e4; --bg-2: #efe5d1; --surface: #fffaf0; --surface-2: #faf3e4;
  --ink: #1e1914; --ink-2: #463c31; --muted: #6f6355; --line: #ded1b8; --line-2: #cdbd9e;
  --accent: #9b3a2b; --accent-ink: #fffaf0; --gold: #9b7629; --focus: #1d4f7a;
  --shadow: 0 1px 2px rgb(60 40 10 / 6%), 0 8px 28px -12px rgb(60 40 10 / 22%);
  --era-childhood: #b0644a; --era-mecca: #9c6c1c; --era-medina: #3c7652; --era-after_prophet: #56617c;
  --era-caliphate_jamal: #9e3a30; --era-kufa_siffin: #1f6f77; --era-arbitration_nahrawan: #674c8f; --era-last_years: #284a82;
  --era-none: #7a6e60;
  --scale: 1; --measure: 34rem; --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1118; --bg-2: #131823; --surface: #171d29; --surface-2: #1c2331;
    --ink: #ece4d3; --ink-2: #cfc5b2; --muted: #9c937f; --line: #283043; --line-2: #36405a;
    --accent: #e8907a; --accent-ink: #1a0f0b; --gold: #d8b56b; --focus: #8fb6ea;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -14px rgb(0 0 0 / 60%);
    --era-childhood: #e8a088; --era-mecca: #e2b766; --era-medina: #84c79c; --era-after_prophet: #a9b5d3;
    --era-caliphate_jamal: #ee8e81; --era-kufa_siffin: #72c9d2; --era-arbitration_nahrawan: #b9a3e6; --era-last_years: #95b5ef;
    --era-none: #a39a88;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1118; --bg-2: #131823; --surface: #171d29; --surface-2: #1c2331;
  --ink: #ece4d3; --ink-2: #cfc5b2; --muted: #9c937f; --line: #283043; --line-2: #36405a;
  --accent: #e8907a; --accent-ink: #1a0f0b; --gold: #d8b56b; --focus: #8fb6ea;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -14px rgb(0 0 0 / 60%);
  --era-childhood: #e8a088; --era-mecca: #e2b766; --era-medina: #84c79c; --era-after_prophet: #a9b5d3;
  --era-caliphate_jamal: #ee8e81; --era-kufa_siffin: #72c9d2; --era-arbitration_nahrawan: #b9a3e6; --era-last_years: #95b5ef;
  --era-none: #a39a88;
  color-scheme: dark;
}
/* stronger lines and labels for readers who ask for more contrast; after the dark blocks so it wins in both schemes */
@media (prefers-contrast: more) {
  :root { --line: #a8977a; --line-2: #7f6d4f; --muted: #4f463c; }
  :root[data-theme="dark"] { --line: #5a6786; --line-2: #8391b3; --muted: #bdb4a0; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --line: #5a6786; --line-2: #8391b3; --muted: #bdb4a0; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Vazirmatn", Tahoma, sans-serif; font-size: calc(1.0625rem * var(--scale)); line-height: 1.9;
  font-feature-settings: "ss01"; text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: .28em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 1rem; top: -4rem; z-index: 50; background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; }
.skip:focus { top: 1rem; }
.ar, [lang="ar"] { font-family: "UthmanTaha", "Vazirmatn", serif; font-size: 1.2em; line-height: 2.1; font-feature-settings: normal; }
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
.narrow { width: min(100% - 2rem, var(--measure)); margin-inline: auto; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: .5rem; min-height: 3.6rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; font-weight: 800; font-size: 1.18rem; letter-spacing: 0; }
.brand svg { width: 1.9rem; height: 1.9rem; color: var(--accent); flex: none; }
.brand small { font-weight: 500; font-size: .74rem; color: var(--muted); display: block; line-height: 1.2; }
@media (max-width: 26rem) { .brand small { display: none; } }
.nav { display: none; margin-inline-start: auto; gap: .2rem; }
.nav a { text-decoration: none; padding: .45rem .75rem; border-radius: 999px; font-weight: 600; font-size: .95rem; color: var(--ink-2); }
.nav a:hover, .nav a[aria-current="page"] { background: var(--bg-2); color: var(--ink); }
.tools { display: flex; gap: .25rem; margin-inline-start: auto; }
.nav + .tools { margin-inline-start: .4rem; }
.icon-btn { inline-size: 2.75rem; block-size: 2.75rem; display: inline-grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); border-radius: 12px; cursor: pointer; font: inherit; text-decoration: none; }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn svg { width: 1.3rem; height: 1.3rem; }
@media (min-width: 52rem) { .nav { display: flex; } .menu-btn { display: none; } }
dialog.menu { border: none; padding: 0; margin: 0; inset-inline-end: 0; inset-inline-start: auto; height: 100dvh; max-height: none;
  width: min(22rem, 92vw); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog.menu::backdrop { background: rgb(10 10 14 / 45%); }
.menu-body { padding: 1rem 1.25rem 2rem; display: grid; gap: .25rem; }
.menu-body a { padding: .75rem .5rem; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.menu-row { display: flex; gap: .5rem; align-items: center; padding: .75rem .25rem; }
.menu-row button { flex: 1; min-height: 2.75rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; }
.menu-body .close-btn { justify-self: start; border-radius: 50%; border-color: var(--line); background: var(--surface-2); margin-bottom: .4rem; }
.menu-body .close-btn:hover { border-color: var(--line-2); background: var(--bg-2); }
.menu-eras { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; padding: .9rem .25rem .4rem; border-bottom: 1px solid var(--line); }
.menu-eras p { grid-column: 1 / -1; margin: 0 0 .2rem; font-size: .78rem; font-weight: 800; color: var(--muted); }
.menu-body .menu-eras a { --c: var(--era-none); display: flex; align-items: center; gap: .5rem; padding: .55rem .25rem; border: none; min-height: 2.75rem;
  font-size: .88rem; font-weight: 600; color: var(--ink-2); line-height: 1.4; }
.menu-eras a i { flex: none; inline-size: .65rem; block-size: .65rem; border-radius: 50%; background: var(--c); }
.menu-eras a:hover { color: var(--c); }
.to-top { position: fixed; bottom: 1.2rem; inset-inline-start: 1rem; z-index: 40; inline-size: 2.75rem; block-size: 2.75rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); text-decoration: none;
  opacity: 0; translate: 0 .6rem; pointer-events: none; transition: opacity .2s, translate .2s; }
.to-top svg { inline-size: 1.3rem; block-size: 1.3rem; }
.to-top[hidden] { display: none; }
.to-top.on { opacity: 1; translate: 0 0; pointer-events: auto; }
.to-top:hover { color: var(--ink); border-color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } }

/* ---------- footer ---------- */
.foot { margin-top: 5rem; border-top: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2); font-size: .93rem; }
.foot .wrap { padding-block: 2.5rem 3rem; display: grid; gap: 1.5rem; }
@media (min-width: 52rem) { .foot .wrap { grid-template-columns: 2fr 1fr 1fr; } }
.foot h2 { font-size: 1rem; margin: 0 0 .5rem; color: var(--ink); }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.foot .credit { grid-column: 1 / -1; margin: .5rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.foot .credit a { font-weight: 700; color: var(--ink-2); }

/* ---------- common bits ---------- */
.crumbs { font-size: .88rem; color: var(--muted); margin-block: 1.2rem 0; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.crumbs li:not(:last-child)::after { content: "‹"; margin-inline-start: .35rem; color: var(--line-2); }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .7rem; border-radius: 999px; background: var(--bg-2);
  border: 1px solid var(--line); font-size: .86rem; font-weight: 600; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.chips > a.chip { min-block-size: 2.75rem; }
a.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.lost-links { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 3rem; padding: .55rem 1.2rem;
  border-radius: 999px; font-weight: 700; text-decoration: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.04); }
.section-title { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem); font-weight: 850; margin: 0 0 .35rem; line-height: 1.45; }
.section-lede { color: var(--muted); margin: 0 0 1.4rem; max-width: 40rem; }
.conf { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 700; color: var(--muted); }
.conf i { inline-size: .7rem; block-size: .7rem; border-radius: 50%; display: inline-block; border: 2px solid currentColor; }
.conf[data-c="certain"] i { background: currentColor; }
.conf[data-c="likely"] i { background: currentColor; transform: rotate(45deg); border-radius: 2px; inline-size: .6rem; block-size: .6rem; }
.conf[data-c="possible"] i { border-style: dashed; }

/* ---------- home ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4.5rem); }
.hero::before { content: ""; position: absolute; inset: 0; background:
  radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%),
  radial-gradient(40rem 26rem at 0% 110%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%); pointer-events: none; }
.hero .pattern { position: absolute; inset-inline-end: -6rem; top: -4rem; width: 26rem; opacity: .1; color: var(--gold); pointer-events: none; }
.hero h1 { position: relative; font-size: clamp(2.6rem, 1.6rem + 6vw, 5.4rem); line-height: 1.15; font-weight: 900; margin: 0; }
.hero h1 span { color: var(--accent); }
.hero .lede { position: relative; font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); color: var(--ink-2); max-width: 38rem; margin: 1.1rem 0 1.8rem; line-height: 1.85; }
.hero .cta { position: relative; display: flex; flex-wrap: wrap; gap: .7rem; }
.searchbox { position: relative; display: flex; margin-top: 1.4rem; max-width: 34rem; }
.searchbox input { flex: 1; min-height: 3.2rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); padding: .5rem 1.2rem; padding-inline-end: 6.2rem; font: inherit; }
.searchbox button { position: absolute; inset-inline-end: .35rem; top: .25rem; bottom: .25rem; border: none; border-radius: 999px;
  background: var(--ink); color: var(--bg); padding: 0 1rem; font: inherit; font-weight: 700; cursor: pointer; }

.today { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
  padding: clamp(1.4rem, 4vw, 2.6rem); box-shadow: var(--shadow); overflow: hidden; }
.today::after { content: "«"; position: absolute; inset-inline-start: .8rem; top: -1.6rem; font-size: 9rem; line-height: 1;
  color: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 900; pointer-events: none; }
.today .kicker { font-size: .85rem; font-weight: 800; color: var(--accent); margin: 0 0 .6rem; }
.today blockquote { margin: 0; font-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem); line-height: 1.85; font-weight: 600; position: relative; }
.today .ar { display: block; margin-top: .9rem; color: var(--ink-2); font-size: 1.25rem; }
.today .src { margin-top: 1rem; font-size: .9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.era-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); }
.era-card { --c: var(--era-none); position: relative; display: block; text-decoration: none; padding: 1.1rem 1.15rem 1.15rem;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.era-card::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 6px; background: var(--c); }
.era-card .yrs { font-size: .82rem; color: var(--muted); font-weight: 700; }
.era-card h3 { margin: .2rem 0 .3rem; font-size: 1.12rem; line-height: 1.55; color: var(--c); }
.era-card p { margin: 0; font-size: .92rem; color: var(--ink-2); line-height: 1.75; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.era-card .n { position: absolute; inset-inline-end: .9rem; top: .9rem; font-size: .78rem; font-weight: 800; color: var(--c); }
.era-card:hover { border-color: var(--c); }

.book-list { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.book-list a { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .9rem 1rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 700; }
.book-list a span { color: var(--muted); font-weight: 600; font-size: .88rem; }
.block-gap { margin-top: clamp(3rem, 7vw, 5rem); }
/* home: saying-of-the-day actions, key moments, the three ways, the numbers line */
.today-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; position: relative; }
.today-actions[hidden] { display: none; }
.today-btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding: .35rem .95rem; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; }
.today-btn svg { inline-size: 1.1rem; block-size: 1.1rem; }
.today-btn:hover { border-color: var(--accent); color: var(--accent); }
.today-btn:first-child { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.today-btn:first-child:hover { color: var(--accent-ink); filter: brightness(1.06); }
.today.swap blockquote, .today.swap .ar { opacity: .35; }
@media (prefers-reduced-motion: no-preference) { .today blockquote, .today .ar { transition: opacity .18s; } }
.moment-strip { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.moment-card { --c: var(--era-none); position: relative; display: grid; gap: .15rem; min-height: 3rem; padding: .95rem 1.1rem 1rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--c); text-decoration: none; box-shadow: var(--shadow); }
.moment-card .when { font-size: .8rem; font-weight: 800; color: var(--c); line-height: 1.6; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.moment-card strong { font-size: 1.05rem; font-weight: 800; line-height: 1.6; }
.moment-card .era-name { font-size: .82rem; color: var(--muted); }
.moment-card .n { margin-top: .35rem; font-size: .8rem; font-weight: 800; color: var(--c); }
.moment-card:hover { border-color: var(--c); }
.ways { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.way { display: grid; grid-template-columns: 2.6rem 1fr; grid-template-rows: auto auto; column-gap: .8rem; align-items: center; padding: 1rem 1.1rem;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; min-height: 3rem; }
.way svg { grid-row: 1 / 3; inline-size: 2.6rem; block-size: 2.6rem; color: var(--accent); }
.way strong { font-weight: 800; font-size: 1.05rem; line-height: 1.6; }
.way span { font-size: .9rem; color: var(--muted); line-height: 1.75; }
.way:hover { border-color: var(--accent); }
.numbers { list-style: none; margin: 1.2rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; color: var(--muted); font-size: .95rem; }
.numbers b { font-size: 1.35rem; font-weight: 900; color: var(--ink); margin-inline-end: .25rem; }

/* ---------- the timeline ---------- */
.tl-hero { padding: clamp(2.2rem, 6vw, 4.5rem) 0 1.5rem; }
.tl-hero h1 { font-size: clamp(2.2rem, 1.5rem + 4vw, 4rem); margin: 0; line-height: 1.2; font-weight: 900; }
.tl-hero p { color: var(--ink-2); max-width: 40rem; font-size: 1.12rem; }
.ribbon { display: flex; gap: 3px; margin: 1.6rem 0 .4rem; block-size: 2.6rem; border-radius: 10px; overflow: hidden; }
.ribbon a { flex: var(--w) 1 0; min-inline-size: 1.2rem; background: var(--c); display: block; position: relative; }
.ribbon a:hover, .ribbon a:focus-visible { filter: brightness(1.12); }
.ribbon a::after { content: attr(title); position: absolute; inset: 0; display: grid; place-items: center; padding: 0 .3rem; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; font-size: .74rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / 45%); opacity: 0; }
.ribbon a:hover::after, .ribbon a:focus-visible::after, .ribbon a[aria-current="true"]::after { opacity: 1; }
.ribbon a[aria-current="true"] { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ink) 75%, var(--c)); z-index: 1; }
.ribbon a[aria-current="true"]::before { content: ""; position: absolute; inset-inline: 0; bottom: 0; block-size: 5px; background: var(--ink); }
/* dark mode's era colours are pastel, so the ribbon label is dark on them */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ribbon a::after { color: #14110c; text-shadow: none; } }
:root[data-theme="dark"] .ribbon a::after { color: #14110c; text-shadow: none; }
.ribbon-legend { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0 0; font-size: .85rem; color: var(--muted); }
.conf[data-c="disputed"] i { border-style: dotted; border-width: 3px; }
/* phones: a sticky strip of era chips under the header stands in for the desktop rail */
.era-strip { position: sticky; top: 3.6rem; z-index: 6; margin: .4rem 0 .8rem; padding: .3rem 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-block: 1px solid var(--line); }
.era-strip ol { list-style: none; margin: 0; padding: 0 1rem; display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-padding-inline: 1rem; }
.era-strip ol::-webkit-scrollbar { display: none; }
.era-strip li { flex: none; }
.era-strip a { --c: var(--era-none); display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding: 0 .9rem; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line)); background: var(--surface); color: var(--c); font-size: .88rem; font-weight: 700;
  text-decoration: none; white-space: nowrap; }
.era-strip a::before { content: ""; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: var(--c); }
.era-strip a[aria-current="true"] { background: var(--c); color: var(--bg); border-color: var(--c); }
.era-strip a[aria-current="true"]::before { background: var(--bg); }
@media (max-width: 63.99rem) {
  /* the strip names the era, so the era head needs no sticky band of its own on phones */
  .timeline-page .era-head { position: static; margin-inline: 0; padding: .4rem 0 .5rem; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  /* the page's scroll-padding (5.5rem) plus this clears the header and the strip */
  .timeline-page .era, .timeline-page .moment { scroll-margin-top: 1.8rem; }
  .moment .when span.age { display: block; }
  .moment .when span.age::before { display: none; }
}
@media (min-width: 64rem) { .era-strip { display: none; } }

.tl-layout { display: grid; gap: 2rem; }
@media (min-width: 64rem) { .tl-layout { grid-template-columns: minmax(0, 1fr) 14rem; } }
.rail { display: none; }
@media (min-width: 64rem) {
  .rail { display: block; position: sticky; top: 5rem; align-self: start; max-height: calc(100dvh - 6rem); overflow: auto; }
  .rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
  .rail a { --c: var(--era-none); display: grid; grid-template-columns: .5rem 1fr auto; gap: .6rem; align-items: center;
    padding: .45rem .55rem; border-radius: 10px; text-decoration: none; font-size: .87rem; color: var(--muted); line-height: 1.5; }
  .rail a::before { content: ""; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: var(--c); }
  .rail a b { font-weight: 600; }
  .rail a span { font-size: .75rem; }
  .rail a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
  .rail a[aria-current="true"] b { font-weight: 800; color: var(--c); }
}

.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.era { --c: var(--era-none); position: relative; padding-bottom: 2.5rem; }
.era-head { position: sticky; top: 3.6rem; z-index: 5; margin-inline: -1rem; padding: .7rem 1rem .6rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); }
.era-head .yrs { font-size: .8rem; font-weight: 800; color: var(--c); display: block; }
.era-head h2 { margin: 0; font-size: clamp(1.25rem, 1.05rem + 1vw, 1.7rem); line-height: 1.45; font-weight: 850; }
.era-head h2 a { text-decoration: none; }
.era-intro { margin: 1rem 0 1.4rem; color: var(--ink-2); max-width: 42rem; line-height: 1.95; }
.moments { list-style: none; margin: 0; padding: 0 0 0 0; padding-inline-start: 2rem; position: relative; }
.moments::before { content: ""; position: absolute; inset-block: .4rem 0; inset-inline-start: .55rem; inline-size: 2px;
  background: linear-gradient(to bottom, var(--c), color-mix(in srgb, var(--c) 30%, transparent)); border-radius: 2px; }
.moment { position: relative; padding: .2rem 0 1.6rem; }
.moment .node { position: absolute; inset-inline-start: -1.95rem; top: .55rem; inline-size: 1.15rem; block-size: 1.15rem;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--c); box-shadow: 0 0 0 4px var(--bg); }
.moment[data-c="certain"] .node { background: var(--c); }
.moment[data-c="likely"] .node { background: var(--c); border-radius: 4px; transform: rotate(45deg) scale(.86); }
.moment[data-c="possible"] .node, .moment[data-c="disputed"] .node { border-style: dashed; }
.moment.has-texts .node { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px color-mix(in srgb, var(--c) 28%, transparent); }
.moment .when { font-size: .84rem; font-weight: 800; color: var(--c); margin: 0; }
.moment .when .ce { color: var(--muted); font-weight: 600; }
.moment .when .age, .page-head .meta .age { color: var(--muted); font-weight: 600; white-space: nowrap; }
.moment .when .age::before { content: ""; display: inline-block; inline-size: 1px; block-size: .8em; background: currentColor; opacity: .5;
  margin-inline: .25rem .5rem; vertical-align: -.1em; }
.moment[data-c="disputed"] .node { border-style: dotted; }
.moment h3 { margin: .1rem 0 .2rem; font-size: 1.18rem; line-height: 1.55; font-weight: 800; }
.moment h3 a { text-decoration: none; }
.moment .where { font-size: .85rem; color: var(--muted); margin: 0 0 .4rem; }
.moment .desc { margin: 0 0 .6rem; color: var(--ink-2); line-height: 1.9; max-width: 42rem; }
.moment.quiet { padding-bottom: .9rem; }
.moment.quiet .when { font-size: .78rem; }
.moment.quiet h3 { font-size: 1.02rem; font-weight: 700; color: var(--ink-2); margin-block: 0 .1rem; }
.moment.quiet .where { display: none; }
.moment.quiet .desc { font-size: .9rem; color: var(--muted); line-height: 1.75; margin-bottom: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.moment.quiet .node { inline-size: .85rem; block-size: .85rem; inset-inline-start: -1.8rem; top: .62rem; border-width: 2px; }
.moment.quiet + .moment.quiet { margin-top: -.2rem; }
@media (max-width: 40rem) {
  .moment { padding-bottom: 1.3rem; }
  .moment .desc { font-size: .97rem; line-height: 1.85; }
  .era-loose { padding: .85rem .9rem; }
}
.cards { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .6rem; }
@media (min-width: 40rem) { .cards { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); } }
.card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem .9rem; box-shadow: var(--shadow); position: relative; }
.card:hover { border-color: var(--c, var(--line-2)); }
.card .k { font-size: .76rem; font-weight: 800; color: var(--c, var(--accent)); }
.card .t { display: block; font-weight: 750; line-height: 1.6; margin: .15rem 0 .35rem; }
.card .x { display: block; font-size: .92rem; color: var(--ink-2); line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { display: inline-block; margin-top: .55rem; font-size: .9rem; font-weight: 700; color: var(--c); }
.era-loose { margin: .2rem 0 1.4rem; padding: 1rem; border-radius: var(--radius); background: color-mix(in srgb, var(--c) 7%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--c) 45%, var(--line)); }
.era-loose h3 { margin: 0 0 .3rem; font-size: 1.02rem; }
.era-loose p { margin: 0 0 .5rem; font-size: .9rem; color: var(--muted); }

/* ---------- images ----------
   Imagined scenes (no people, no text), always quiet: a muted opener band above a title (home, era, moment) and small
   thumbnails on cards, timeline markers and topic heads. Never over or behind text; text pages carry none.
   The band fades into the page through a mask, so one rule works on light and dark paper. */
.opener { position: relative; margin: 0 0 1rem; }
/* the frame, not the image, carries the mask: its plain paper under the dimmed picture keeps the home pattern from
   showing through, and the whole frame still fades into the page */
.opener-frame { position: relative; aspect-ratio: 16 / 9; max-height: 280px; overflow: hidden; border-radius: 12px; background: var(--bg);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%); }
@media (max-width: 600px) { .opener-frame { max-height: 200px; } }
.hero:has(.opener) { padding-top: clamp(1.25rem, 4vw, 3rem); }
.hero .opener-frame { max-height: 170px; }  /* home only: the buttons stay on the first screen */  /* the band takes the place of the hero's empty top */
.opener .img-label { font-size: .8rem; color: var(--muted); margin: .25rem .5rem 0; }
.opener img { width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: .72; filter: saturate(.75) contrast(.95); }
.thumb { display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85); }
/* a card: a small picture at the far side of its label and title, so a list of cards stays a list of words */
.card:has(> .thumb) { display: flow-root; }
.card > .thumb { float: left; float: inline-end; inline-size: min(7.5rem, 34%); margin-inline-start: .85rem; margin-block: .2rem .3rem; }
@media (max-width: 40rem) { .card > .thumb { inline-size: 6.5rem; } }
/* a timeline marker: a small picture at the far side of the moment's title and description */
.moment { display: flow-root; }
.moment > .thumb { float: left; float: inline-end; inline-size: 160px; margin-inline-start: 1rem; margin-block: .35rem .5rem; }
.moment .cards { clear: both; }
@media (max-width: 40rem) { .moment > .thumb { inline-size: 6.5rem; margin-inline-start: .75rem; } }
/* a topic page: its still life beside the heading */
.page-head.has-thumb { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1.2rem; align-items: center; }
.page-head.has-thumb .thumb { inline-size: 200px; }
@media (max-width: 40rem) { .page-head.has-thumb .thumb { inline-size: 7rem; } }
/* dark mode: dim, never invert; a pointer or focus on the link brings the picture back */
:root[data-theme="dark"] .opener img, :root[data-theme="dark"] .thumb img { filter: brightness(.8) saturate(.7); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .opener img, :root:not([data-theme="light"]) .thumb img { filter: brightness(.8) saturate(.7); } }
:root a:hover .thumb img, :root a:focus-visible .thumb img, :root a.thumb:hover img { filter: none; }
@media (prefers-reduced-motion: reduce) { .opener img, .thumb img { transition: none; transform: none; } }
/* reduced data: an enhancement only (not in every browser); the baseline is already one 800px file per picture */
@media (prefers-reduced-data: reduce) { .opener, .thumb { display: none; } }

/* ---------- audio player ---------- */
/* A calm listening bar under the reading toolbar; once listening, it docks at the bottom when its place scrolls away.
   Without JavaScript only the head line and the native <audio controls> show. */
.pl-slot { margin: 0 0 1.2rem; }
.player { padding: .7rem .85rem .75rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.pl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .6rem; margin: 0 0 .55rem; font-size: .84rem; line-height: 1.6; }
.pl-label { font-weight: 800; color: var(--ink); }
.pl-total { color: var(--muted); font-weight: 700; unicode-bidi: isolate; }
.player.js .pl-total { display: none; }
.pl-note { margin-inline-start: auto; color: var(--muted); font-size: .76rem; }
.player audio { display: block; inline-size: 100%; }
.player audio[hidden], .pl-ui[hidden], .pl-resume[hidden] { display: none; }
.pl-ui { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto auto; grid-template-areas: "play track back fwd rate follow";
  align-items: center; gap: .35rem .45rem; }
.pl-play { grid-area: play; position: relative; inline-size: 3rem; block-size: 3rem; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.pl-play svg { inline-size: 1.4rem; block-size: 1.4rem; }
.pl-play .i-pause, .player.playing .pl-play .i-play { display: none; }
.player.playing .pl-play .i-pause { display: block; }
.pl-play:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.player.loading .pl-play::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent; border-block-start-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .player.loading .pl-play::after { animation: pl-spin .9s linear infinite; }
  @keyframes pl-spin { to { rotate: 1turn; } }
}
.pl-track { grid-area: track; display: grid; gap: .05rem; min-inline-size: 0; }
.pl-track input { -webkit-appearance: none; appearance: none; inline-size: 100%; block-size: 1.75rem; margin: 0; background: transparent; cursor: pointer; --p: 0%; }
.pl-track input::-webkit-slider-runnable-track { block-size: 5px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--line-2) var(--p)); }  /* Blink and WebKit mirror an rtl track */
.pl-track input::-webkit-slider-thumb { -webkit-appearance: none; inline-size: 15px; block-size: 15px; margin-block-start: -5px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.pl-track input::-moz-range-track { block-size: 5px; border-radius: 999px; background: var(--line-2); }
.pl-track input::-moz-range-progress { block-size: 5px; border-radius: 999px; background: var(--accent); }
.pl-track input::-moz-range-thumb { inline-size: 13px; block-size: 13px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.pl-track input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pl-time { display: flex; justify-content: space-between; font-size: .74rem; font-weight: 700; color: var(--muted); line-height: 1.3; }
.pl-time span { unicode-bidi: isolate; direction: ltr; font-variant-numeric: tabular-nums; }
.pl-ui > button:not(.pl-play) { min-inline-size: 2.75rem; min-block-size: 2.75rem; padding: 0 .55rem; border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .15rem; white-space: nowrap; }
.pl-ui > button:not(.pl-play):hover { background: var(--surface-2); border-color: var(--line); }
.pl-ui > button svg { inline-size: 1.2rem; block-size: 1.2rem; flex: none; }
.pl-skip[data-pl-skip="-15"] { grid-area: back; }
.pl-skip[data-pl-skip="15"] { grid-area: fwd; }
.pl-skip svg { transform: scaleX(-1); }  /* the bar fills right to left, so "back" turns to the right */
.pl-skip span { font-size: .72rem; }
.pl-ui > button.pl-rate { grid-area: rate; border-color: var(--line-2); min-inline-size: 3.4rem; unicode-bidi: isolate; }
.pl-follow { grid-area: follow; }
.pl-ui > button.pl-follow[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pl-resume { margin: .45rem 0 0; font-size: .84rem; color: var(--ink-2); display: flex; align-items: center; gap: .4rem; }
.pl-resume .link-btn { min-block-size: 2.75rem; }
@media (max-width: 40rem) {
  .pl-ui { grid-template-columns: auto auto auto 1fr auto; grid-template-areas: "play track track track track" "back fwd rate . follow"; }
  .pl-head { margin-block-end: .35rem; }
}
/* the paragraph being read: a quiet tint, no movement of the text */
.blk.pl-now > p:first-of-type, .text h2.pl-now, .read-head h1.pl-now { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 10px;
  box-shadow: 0 0 0 .45rem color-mix(in srgb, var(--accent) 8%, transparent); }
@media (prefers-reduced-motion: no-preference) { .blk > p:first-of-type, .text h2 { transition: background-color .35s, box-shadow .35s; } }
/* docked while listening */
.player.docked { position: fixed; z-index: 45; inset-inline: 0; bottom: 0; margin: 0; border-radius: 18px 18px 0 0; border-block-end: 0;
  padding-block-end: calc(.65rem + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px -16px rgb(0 0 0 / 35%);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.player.docked .pl-head, .player.docked .pl-resume { display: none; }
@media (min-width: 52.01rem) {
  .player.docked { inset-inline: 1rem; bottom: 1rem; margin-inline: auto; max-inline-size: 46rem; border-radius: 18px; border-block-end: 1px solid var(--line); padding-block-end: .65rem; }
}
body.pl-docked .toast { bottom: 8.6rem; }
body.pl-docked .to-top { bottom: 8.6rem; }
@media (min-width: 40.01rem) { body.pl-docked .toast, body.pl-docked .to-top { bottom: 6.6rem; } }
@media (min-width: 52.01rem) { body.pl-docked .toast, body.pl-docked .to-top { bottom: 7.6rem; } }
body.pl-docked .foot { padding-block-end: 7rem; }
/* share fallback: the address in a small box under the button, when neither share nor the clipboard worked */
.share-pop { position: absolute; z-index: 55; display: flex; gap: .4rem; inline-size: min(22rem, calc(100vw - 24px)); padding: .45rem;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.share-pop input { flex: 1; min-inline-size: 0; min-block-size: 2.75rem; padding: 0 .7rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: .82rem/1.4 ui-monospace, Menlo, Consolas, monospace; }  /* an address keeps its Latin digits */
.share-pop button { min-block-size: 2.75rem; min-inline-size: 2.75rem; padding: 0 .9rem; border-radius: 10px; border: 0; background: var(--ink);
  color: var(--bg); font: inherit; font-weight: 700; cursor: pointer; }
@media print { .pl-slot, .player, .share-pop { display: none !important; } }

/* reveal on scroll: a bonus; the visible end state is the default */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .moment, .card, .era-card, .today { animation: rise both linear; animation-timeline: view(); animation-range: entry 0% entry 55%; }
    @keyframes rise { from { opacity: .001; transform: translateY(18px); } to { opacity: 1; transform: none; } }
    .progress { position: fixed; top: 0; inset-inline: 0; block-size: 3px; z-index: 30; background: var(--accent);
      transform-origin: right; animation: grow linear both; animation-timeline: scroll(root); }
    @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  }
}
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
}
.top { view-transition-name: top; }

/* ---------- moment and era pages ---------- */
.page-head { --c: var(--era-none); padding: clamp(1.6rem, 5vw, 3rem) 0 1rem; }
.page-head .kicker { font-size: .85rem; font-weight: 800; color: var(--c); margin: 0; }
.page-head h1 { margin: .2rem 0 .5rem; font-size: clamp(1.7rem, 1.25rem + 2.4vw, 2.8rem); line-height: 1.35; font-weight: 900; }
.page-head .meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; color: var(--muted); font-size: .92rem; align-items: center; }
.page-head .lede { color: var(--ink-2); max-width: 44rem; font-size: 1.08rem; line-height: 1.95; }
.alts { font-size: .9rem; color: var(--muted); border-inline-start: 3px solid var(--line-2); padding-inline-start: .8rem; margin: .8rem 0; }
.pager { display: flex; justify-content: space-between; gap: .8rem; margin: 2.5rem 0 0; flex-wrap: wrap; }
.pager a { flex: 1 1 14rem; display: block; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; }
.pager a small { display: block; color: var(--muted); font-size: .8rem; font-weight: 700; }
.pager a:last-child { text-align: end; }
.page-head .kicker .place { color: var(--muted); font-weight: 600; }
.page-head .kicker .sep { margin-inline: .5rem; }
/* a moment page: the moment before and after it, with their dates */
.neighbors { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .4rem 0 1.6rem; }
.neighbors a { --c: var(--era-none); display: grid; gap: .05rem; align-content: start; padding: .7rem .85rem; min-height: 2.75rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--c); text-decoration: none; font-size: .9rem; line-height: 1.6; }
.neighbors a:hover { border-color: var(--c); }
.neighbors a small { color: var(--muted); font-size: .76rem; font-weight: 800; }
.neighbors a b { font-weight: 750; }
.neighbors a span { color: var(--c); font-size: .8rem; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* an era page: its moments as a compact index, each an anchor into the list below */
.moment-index { margin: 1.4rem 0 .4rem; padding: .9rem 1rem .5rem; border-radius: var(--radius); background: color-mix(in srgb, var(--c) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line)); }
.moment-index .kicker { margin: 0 0 .3rem; }
.moment-index ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 1.5rem; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
.moment-index a { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t n" "d n"; column-gap: .6rem; align-items: center; min-height: 2.75rem;
  padding: .35rem .2rem; border-bottom: 1px solid color-mix(in srgb, var(--c) 18%, var(--line)); text-decoration: none; font-size: .92rem; line-height: 1.55; }
.moment-index li:last-child a { border-bottom: none; }
.moment-index .d { grid-area: d; color: var(--c); font-size: .76rem; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.moment-index .t { grid-area: t; font-weight: 650; }
.moment-index .n { grid-area: n; color: var(--muted); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.moment-index a:hover .t { color: var(--c); }
@media print {
  .ribbon, .ribbon-legend, .era-strip, .rail, .neighbors, .pager, .more, .page-head .btn { display: none !important; }
  .era-head { position: static; background: none; backdrop-filter: none; }
  .moment, .card, .moment-index { break-inside: avoid; }
  .card, .neighbors a, .moment-index { box-shadow: none; border-color: #bbb; }
  .moment .node { box-shadow: none; }
}

/* ---------- reading a text ---------- */
.read-head { --c: var(--era-none); padding: clamp(1.4rem, 5vw, 2.6rem) 0 .5rem; }
.read-head .kicker { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .86rem; font-weight: 800; color: var(--c); margin: 0; }
.sep { display: inline-block; inline-size: 1px; block-size: .9em; background: currentColor; opacity: .35; }
.read-head h1 { margin: .35rem 0 .7rem; font-size: clamp(1.55rem, 1.2rem + 1.8vw, 2.35rem); line-height: 1.5; font-weight: 850; }
.occasion { --c: var(--era-none); display: grid; gap: .25rem; margin: .8rem 0 1rem; padding: .9rem 1rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--c) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line)); }
.occasion .row1 { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; font-size: .88rem; font-weight: 700; }
.occasion .row1 a { color: var(--c); }
.occasion p { margin: 0; font-size: .95rem; color: var(--ink-2); line-height: 1.85; }
.radi-line { font-size: .86rem; color: var(--muted); margin: .4rem 0 0; }
.toolbar { position: sticky; top: 3.6rem; z-index: 6; display: flex; gap: .4rem; align-items: center; padding: .45rem 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.toolbar .grow { flex: 1; }
.toolbar button, .toolbar a { min-height: 2.75rem; padding: .35rem .85rem; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem; }
.toolbar button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.text { font-size: 1.12em; }
.text h2 { font-size: 1.05rem; font-weight: 800; color: var(--ink-2); margin: 2.2rem 0 .6rem; line-height: 1.7; display: flex; gap: .55rem; align-items: baseline; }
.text h2::before { content: ""; flex: none; inline-size: .55rem; block-size: .55rem; transform: rotate(45deg); background: var(--gold); border-radius: 2px; translate: 0 -.1rem; }
.blk { position: relative; margin: 0 0 1.25rem; scroll-margin-top: 7.5rem; }
.blk p { margin: 0; line-height: 2.05; }
.blk.narr p { color: var(--ink-2); border-inline-start: 3px solid var(--line-2); padding-inline-start: .85rem; }
.blk .ar-text { display: none; margin: .5rem 0 0; padding: .6rem .9rem; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
body.show-ar .blk .ar-text { display: block; }
.blk .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.blk .tags .chip { font-size: .74rem; padding: .1rem .55rem; }
.blk details { margin-top: .3rem; font-size: .86rem; color: var(--muted); }
.blk details summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 2rem; font-weight: 700; list-style: none; }
.blk details summary::-webkit-details-marker { display: none; }
.blk details summary::before { content: "+"; display: inline-grid; place-items: center; inline-size: 1.2rem; block-size: 1.2rem;
  margin-inline-end: .35rem; border-radius: 50%; border: 1px solid var(--line-2); font-size: .8rem; }
.blk details[open] summary::before { content: "−"; }
.blk details ol { margin: .3rem 0 0; padding-inline-start: 1.3rem; }
.blk details li { margin-bottom: .35rem; line-height: 1.9; }
.blk:target { background: color-mix(in srgb, var(--gold) 14%, transparent); border-radius: 12px; box-shadow: 0 0 0 .6rem color-mix(in srgb, var(--gold) 14%, transparent); }
.blk .act { position: absolute; inset-inline-end: -2.9rem; top: 0; opacity: 0; }
.blk:hover .act, .blk:focus-within .act { opacity: 1; }
@media (max-width: 52rem) { .blk .act { display: none; } }
.end-note { margin-top: 2.5rem; padding: 1rem; border-radius: var(--radius); background: var(--bg-2); color: var(--muted); font-size: .9rem; }
/* reading toolbar: text size pair, one line at 375px */
.reading-bar { flex-wrap: nowrap; white-space: nowrap; }
.reading-bar button, .reading-bar a { padding-inline: .7rem; flex: none; }
.scale-group { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); overflow: hidden; }
.scale-group button { border: none; border-radius: 0; min-inline-size: 2.75rem; padding-inline: .5rem; font-weight: 800; display: inline-grid; place-items: center; font-size: 1.25rem; line-height: 1; }
.scale-group button + button { border-inline-start: 1px solid var(--line); }
.reading-bar [data-share] svg { width: 1.1rem; height: 1.1rem; }
@media (max-width: 30rem) {
  .reading-bar [data-share] span { display: none; }
  .reading-bar [data-share] { inline-size: 2.75rem; padding-inline: 0; justify-content: center; }
  .reading-bar .tl-link { font-size: .82rem; padding-inline: .6rem; }
  .reading-bar .grow { flex: 1 1 0; min-inline-size: 0; }
}
/* per-paragraph Arabic (mobile bar) beside the page-wide switch */
.blk.show-ar .ar-text { display: block; }
/* mobile paragraph bar: one bar, moved into the tapped paragraph */
.pbar { position: absolute; inset-inline-start: 0; top: -3.2rem; z-index: 7; display: inline-flex; gap: .15rem; padding: .2rem;
  border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.pbar[hidden] { display: none; }
.pbar button { min-inline-size: 2.75rem; min-block-size: 2.75rem; padding: 0 .7rem; border: none; border-radius: 999px; background: transparent;
  color: inherit; font: inherit; font-size: .82rem; font-weight: 700; display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.pbar button:hover, .pbar button[aria-pressed="true"] { background: color-mix(in srgb, var(--bg) 18%, transparent); }
.pbar button svg { width: 1rem; height: 1rem; }
.pbar .ar { font-size: 1.05rem; line-height: 1; }
.blk.has-bar { scroll-margin-top: 9rem; }
.blk.has-bar > p:first-of-type { background: color-mix(in srgb, var(--gold) 10%, transparent); border-radius: 10px; box-shadow: 0 0 0 .45rem color-mix(in srgb, var(--gold) 10%, transparent); }
@media (min-width: 52.01rem) { .pbar { display: none !important; } }
/* resume where the reader was: one quiet line, no auto-scroll */
.resume { margin: -.4rem 0 1.2rem; padding: .55rem .9rem; border-radius: 10px; background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); font-size: .88rem; color: var(--ink-2); }
.resume a { font-weight: 800; color: var(--ink); }
.resume[hidden] { display: none; }
/* reading progress without animation-timeline: JS sets the scale */
.progress.js { position: fixed; top: 0; inset-inline: 0; block-size: 3px; z-index: 30; background: var(--accent); transform-origin: right; transform: scaleX(0); }
/* quiet footnotes and chips; headings and toc in both themes */
.blk details summary { color: var(--muted); font-weight: 600; font-size: .82rem; opacity: .8; }
.blk details[open] summary, .blk details summary:hover { opacity: 1; }
.blk .tags .chip { background: transparent; border-color: var(--line); color: var(--muted); font-weight: 600; }
.text h2 { color: var(--ink); scroll-margin-top: 7.5rem; }
.text h2::before { background: var(--gold); }
.toc { margin: 1rem 0 1.4rem; border: 1px solid var(--line); border-radius: .9rem; padding: .7rem 1rem; background: var(--surface); }
.toc summary { cursor: pointer; font-weight: 800; min-block-size: 2.4rem; display: flex; align-items: center; }
.toc ol { margin: .7rem 0 0; padding-inline-start: 1.3rem; columns: 2 16rem; column-gap: 2rem; font-size: .92rem; line-height: 1.9; }
.toc li { break-inside: avoid; }
.toc a { color: var(--ink-2); }
.read-head .full-title { margin: .35rem 0 0; color: var(--muted); font-size: .98rem; line-height: 1.8; }
/* related texts and the pagers at the end */
.related { margin-top: 2.5rem; scroll-margin-top: 8rem; }
.related .section-title { font-size: 1.25rem; }
.related .section-lede { margin-bottom: .9rem; font-size: .92rem; }
.narrow .pager { margin-top: 1.6rem; }
.narrow .pager a { line-height: 1.65; font-size: .95rem; }
@media (max-width: 40rem) { .narrow .pager { flex-direction: column; } .narrow .pager a { flex: 0 0 auto; } .narrow .pager a:last-child { text-align: start; } .narrow .pager span:empty { display: none; } }

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.rows a { display: grid; gap: .1rem; padding: .85rem 1rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; }
.rows a:hover { border-color: var(--line-2); }
.rows .k { font-size: .78rem; font-weight: 800; color: var(--accent); }
.rows .t { font-weight: 750; line-height: 1.6; }
.rows .x { font-size: .9rem; color: var(--muted); line-height: 1.75; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.rows li[hidden] { display: none; }
/* lists: era groups on topic pages, number ranges and the filter box on chapter pages, start-page groups */
.range-head { --c: var(--accent); display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; margin: 2rem 0 .7rem;
  padding-bottom: .4rem; border-bottom: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); font-size: 1.15rem; font-weight: 850; line-height: 1.5; scroll-margin-top: 5.5rem; }
.range-head .yrs { font-size: .8rem; font-weight: 800; color: var(--c); flex-basis: 100%; }
.range-head .n { font-size: .82rem; font-weight: 700; color: var(--muted); }
.era-group { --c: var(--era-none); }
.era-group .rows .k { color: var(--c); }
.era-group:first-of-type .range-head { margin-top: .5rem; }
.range-head[hidden], .jump[hidden] { display: none; }
.jump { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 .5rem; font-size: .88rem; }
.jump span { color: var(--muted); font-weight: 700; }
.jump a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: .3rem .8rem; border-radius: 999px; background: var(--bg-2);
  border: 1px solid var(--line); text-decoration: none; font-weight: 700; color: var(--ink-2); }
.jump a:hover { border-color: var(--line-2); color: var(--ink); }
.list-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin: 0 0 1rem; }
.list-filter[hidden] { display: none; }
.list-filter input { flex: 1 1 14rem; min-height: 3rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); padding: .4rem 1.1rem; font: inherit; }
.list-filter .muted { font-size: .88rem; font-weight: 700; }
.start-group { margin-top: 2.2rem; }
.start-group .section-lede { margin-bottom: .9rem; }

/* ---------- search ---------- */
.results { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .6rem; }
.results a { display: block; padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.results mark { background: color-mix(in srgb, var(--gold) 38%, transparent); color: inherit; border-radius: 3px; padding: 0 .1em; }
.results a:hover { border-color: var(--line-2); }
.results .rt { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; margin-block-end: .2rem; }
.results .k { font-size: .78rem; font-weight: 800; color: var(--accent); }
.results .st { font-weight: 750; line-height: 1.6; }
.results .badge { font-size: .72rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 .5rem; line-height: 1.6; }
.results .sn { display: block; font-size: .95rem; color: var(--ink-2); line-height: 1.85; }
.search-status { min-block-size: 1.6rem; margin: 1rem 0 0; font-size: .92rem; }
.search-h { font-size: 1rem; font-weight: 800; margin: 1.6rem 0 .6rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.search-empty button.chip { min-block-size: 2.75rem; padding-inline: .9rem; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }
.search-empty button.chip:hover, .search-filters .chip:hover { border-color: var(--line-2); color: var(--ink); }
.search-filters { margin-block-start: 1rem; }
.search-filters .chip { min-block-size: 2.75rem; padding-inline: .9rem; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.search-filters .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.search-filters .chip[aria-pressed="true"] .muted { color: inherit; opacity: .85; }
.link-btn { background: none; border: 0; padding: .4rem .2rem; min-block-size: 2.75rem; font: inherit; font-size: .86rem; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: .28em; cursor: pointer; }
.link-btn:hover { color: var(--ink); }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.recent li { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.recent-q { flex: 1; min-block-size: 2.75rem; text-align: start; padding: .5rem .9rem; background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer; }
.recent-q:hover { background: var(--surface-2); }
.recent-x { inline-size: 2.75rem; min-block-size: 2.75rem; background: none; border: 0; border-inline-start: 1px solid var(--line); font: inherit; font-size: 1.25rem; color: var(--muted); cursor: pointer; }
.recent-x:hover { color: var(--accent); background: var(--surface-2); }

/* ---------- prose pages ---------- */
.prose h2 { font-size: 1.3rem; margin: 2.2rem 0 .5rem; }
.prose p, .prose li { line-height: 2; color: var(--ink-2); }
.prose blockquote { margin: 1rem 0; padding: .8rem 1rem; border-inline-start: 4px solid var(--gold); background: var(--surface); border-radius: 10px; }

.toast { position: fixed; bottom: 1.2rem; inset-inline: 0; margin-inline: auto; inline-size: max-content; max-inline-size: 90vw;
  background: var(--ink); color: var(--bg); padding: .6rem 1.1rem; border-radius: 999px; font-weight: 700; z-index: 60;
  opacity: 0; translate: 0 1rem; transition: opacity .2s, translate .2s; pointer-events: none; }
.toast.on { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print {
  .top, .foot, .toolbar, .rail, .act, .to-top, .toast, .progress, .skip, dialog.menu, .crumbs, .pager { display: none !important; }
  body { background: #fff; color: #000; font-size: 11.5pt; }
  a { color: inherit; text-decoration: none; }
  .blk .ar-text { display: block; }
  .end-note a[href^="http"]::after, .end-note a[href^="/"]::after { content: " (" attr(href) ")"; direction: ltr; unicode-bidi: isolate; font-size: .85em; }
  .blk, .card, .today { break-inside: avoid; }
}
.front-ar { border-block-end: 1px solid var(--line); padding: .7rem 0; }
.front-ar summary { cursor: pointer; font-weight: 800; }
.front-ar-text { margin-block-start: .8rem; font-size: 1.12rem; line-height: 2.1; }
.front-ar-text h3 { font-size: 1.15rem; margin: 1.2rem 0 .4rem; }
.front-ar-text p { margin: 0 0 .7rem; }
p.front-ar { margin: 0; }
p.front-ar a { font-weight: 800; }
