/* Ask Hadith: manuscript-folio look.
   Cool paper, ink, lapis for actions, a thin gold rule around the Arabic text.
   Layout uses logical properties (inline-start/end) so Urdu and Persian mirror. */

:root {
  --paper: #f2f4f0;
  --surface: #fbfcfa;
  --ink: #1d2a2e;
  --ink-soft: #4b5b5f;
  --rule: #cdd5cf;
  --lapis: #22457a;
  --lapis-wash: #e2e8f2;
  --gold: #a8843a;
  --mark: #f1e2b3;

  --g-sahih-bg: #e0eee8;   --g-sahih-fg: #1f5245;
  --g-mid-bg: #e2e8f2;     --g-mid-fg: #22457a;
  --g-weak-bg: #f2e6d8;    --g-weak-fg: #6c431d;
  --g-none-bg: #e6eaec;    --g-none-fg: #4a565c;

  --serif: "Gentium Book Plus", "Gentium Plus", Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  --arabic: "Amiri", "Traditional Arabic", "Arabic Typesetting", "Noto Naskh Arabic", serif;
  --urdu: "Gentium Book Plus", "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  --persian: "Gentium Book Plus", "Vazirmatn", Tahoma, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.3rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131d21;
    --surface: #18252a;
    --ink: #e4e9e4;
    --ink-soft: #a9b6b3;
    --rule: #33454b;
    --lapis: #9bb7e6;
    --lapis-wash: #1f3150;
    --gold: #c9a65a;
    --mark: #5a4a1c;
    --g-sahih-bg: #1d3a33;  --g-sahih-fg: #a7dcc8;
    --g-mid-bg: #1f3150;    --g-mid-fg: #b9cdf0;
    --g-weak-bg: #43301d;   --g-weak-fg: #ecc9a2;
    --g-none-bg: #2b363b;   --g-none-fg: #c3ccd0;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
}

/* Urdu and Persian */
[lang="ur"] { font-family: var(--urdu); line-height: 2.25; }
[lang="fa"] { font-family: var(--persian); line-height: 1.95; }
[lang="en"] { font-family: var(--serif); line-height: 1.6; }
[lang="ar"] { font-family: var(--arabic); }
/* the whole page in the page's own script: Latin letters in Gentium, the rest in our
   Arabic, Urdu or Persian font (the body otherwise keeps the English stack) */
html[lang="ar"] body { font-family: "Gentium Book Plus", var(--arabic); }
html[lang="ur"] body { font-family: var(--urdu); }
html[lang="fa"] body { font-family: var(--persian); }
html[lang="ur"] h1, html[lang="ur"] h2 { line-height: 1.9; }
html[lang="fa"] h1, html[lang="fa"] h2 { line-height: 1.6; }

a { color: var(--lapis); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-1); }
h3 { font-size: var(--step-0); }

mark { background: var(--mark); color: inherit; padding: 0 0.1em; border-radius: 2px; }
code { font-size: 0.92em; background: var(--lapis-wash); padding: 0.05em 0.3em; border-radius: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip { position: absolute; inset-inline-start: -999px; top: 0.5rem; background: var(--surface); padding: 0.5rem 0.75rem; }
.skip:focus { inset-inline-start: 0.5rem; z-index: 10; }

.wrap { max-width: 50rem; margin: 0 auto; padding: 0 1.25rem; }
.wrap--wide { max-width: 68rem; }
.wrap--chat { max-width: 46rem; }

/* Masthead */

.masthead {
  display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap;
  max-width: 68rem; margin: 0 auto; padding: 1rem 1.25rem;
}
.wordmark { display: flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; }
.wordmark-mark {
  width: 1.35rem; height: 1.35rem; flex: none;
  border: 1.5px solid var(--lapis); outline: 1.5px solid var(--gold); outline-offset: 2px;
  background: linear-gradient(var(--ink), var(--ink)) center 40% / 60% 1.5px no-repeat,
              linear-gradient(var(--ink), var(--ink)) center 62% / 60% 1.5px no-repeat;
}
.wordmark-en { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.01em; }
.topnav { display: flex; gap: 1.25rem; font-size: var(--step--1); margin-inline-start: auto; }
.topnav a, .langs a { color: var(--ink-soft); text-decoration: none; }
.topnav a:hover, .langs a:hover { color: var(--lapis); text-decoration: underline; }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.langs { display: flex; gap: 0.75rem; font-size: var(--step--1); padding-inline-start: 1rem; border-inline-start: 1px solid var(--rule); }
.langs a[aria-current="true"] { color: var(--ink); font-weight: 700; }
.langs a[lang="ur"], .langs a[lang="fa"] { line-height: 1.6; }

main { padding-bottom: 3rem; }

/* Buttons */

button, .button-link {
  font: inherit; cursor: pointer; display: inline-block; text-decoration: none;
  padding: 0.6rem 1.1rem;
  color: #fff; background: var(--lapis);
  border: 1px solid var(--lapis); border-radius: 3px;
}
@media (prefers-color-scheme: dark) { button, .button-link { color: #0f1a1e; } }
button:hover, .button-link:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.linkish { background: none; border: 0; padding: 0; color: var(--lapis); text-decoration: underline; text-underline-offset: 0.18em; font-size: var(--step--1); }
@media (prefers-color-scheme: dark) { .linkish { color: var(--lapis); } }

/* Search */

.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { max-width: 16ch; }
.hero--compact { padding-top: 1.25rem; }
.hero--compact h1 { font-size: var(--step-2); max-width: none; }
.hero--compact .lede { display: none; }
.lede { color: var(--ink-soft); max-width: 60ch; margin: 0 0 1.5rem; }

.finder-row { display: flex; gap: 0.5rem; }
.finder input[type="search"] {
  flex: 1; min-width: 0;
  font: inherit; font-size: var(--step-1);
  padding: 0.7rem 0.9rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-bottom: 2px solid var(--lapis);
  border-radius: 3px;
}
.finder input[type="search"]::placeholder { color: var(--ink-soft); opacity: 0.8; font-size: var(--step-0); }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin-top: 0.9rem; font-size: var(--step--1); color: var(--ink-soft); }
.filters label { display: flex; flex-direction: column; gap: 0.25rem; }
select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0.35rem 0.5rem; max-width: 100%;
}
.filters select { max-width: 22rem; }

.browse { margin-top: 1rem; }
.shelf { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.6rem; }
.shelf a {
  display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.75rem; height: 100%;
  padding: 0.75rem 0.9rem; text-decoration: none; color: var(--ink);
  border: 1px solid var(--rule); border-inline-start: 3px solid var(--gold); border-radius: 0;
  background: var(--surface);
}
.shelf a:hover { border-color: var(--lapis); border-inline-start-color: var(--gold); }
.spine-title { grid-column: 1 / -1; font-size: var(--step-0); font-weight: 700; line-height: 1.3; }
.spine-meta, .spine-vols, .spine-count { font-size: var(--step--1); color: var(--ink-soft); }
.spine-count { grid-column: 1 / -1; }

.results-count { color: var(--ink-soft); font-size: var(--step--1); margin: 0.5rem 0 0.75rem; }

.result-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.result {
  display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem;
  padding: 1.1rem 0; border-bottom: 1px solid var(--rule);
}
.result-ref { font-size: var(--step-0); line-height: 1.4; text-decoration: none; font-variant-numeric: tabular-nums; align-self: start; font-weight: 700; }
.result-ref:hover { text-decoration: underline; }
.result-body > * { margin: 0 0 0.45rem; }
.result-chapter { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
.result-book { font-style: normal; }
.result-ar { font-size: 1.3rem; line-height: 2; }
.result-grades { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: var(--step--1); }
.result-grades .who { color: var(--ink-soft); }
.result-ungraded { font-size: var(--step--1); color: var(--ink-soft); margin: 0; }

/* Grade labels */

.grade {
  display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px;
  font-size: var(--step--1); line-height: 1.5;
  background: var(--g-none-bg); color: var(--g-none-fg);
}
.grade--sahih { background: var(--g-sahih-bg); color: var(--g-sahih-fg); }
.grade--hasan, .grade--qawi, .grade--muwaththaq { background: var(--g-mid-bg); color: var(--g-mid-fg); }
.grade--daif, .grade--majhul, .grade--mursal { background: var(--g-weak-bg); color: var(--g-weak-fg); }
.grade--unmapped { border: 1px dashed currentColor; }
.grade [lang="ar"] { font-size: 1rem; }

/* Chat */

.chat { padding-top: 1.5rem; }
.chat-intro h1 { font-size: var(--step-3); }
.examples-label { color: var(--ink-soft); font-size: var(--step--1); margin: 1.5rem 0 0.5rem; }
.examples { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.5rem; }
.example {
  width: 100%; text-align: start; background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); border-inline-start: 3px solid var(--gold); border-radius: 0;
  padding: 0.7rem 0.9rem;
}
.example:hover { border-color: var(--lapis); border-inline-start-color: var(--gold); filter: none; }

.chat-log { list-style: none; padding: 0; margin: 0; }
.msg { margin: 0 0 1.75rem; }
.msg--user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-who { font-size: var(--step--1); color: var(--ink-soft); margin: 0 0 0.2rem; }
.msg--user .msg-body {
  background: var(--lapis-wash); color: var(--ink);
  padding: 0.6rem 0.9rem; border-radius: 12px 12px 2px 12px; max-width: 85%;
  white-space: normal; overflow-wrap: anywhere;
}
[dir="rtl"] .msg--user .msg-body { border-radius: 12px 12px 12px 2px; }
.msg--assistant { border-inline-start: 2px solid var(--gold); padding-inline-start: 1.1rem; }
.answer p, .answer ul, .answer ol { margin: 0 0 0.8rem; }
.answer ul, .answer ol { padding-inline-start: 1.3rem; }
.answer li { margin-bottom: 0.35rem; }
.answer h3 { margin-top: 1rem; }
.cite {
  display: inline-block; font-size: 0.85em; line-height: 1.4; padding: 0 0.35em;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--surface);
  text-decoration: none; white-space: nowrap; font-family: var(--serif); vertical-align: 0.05em;
}
a.cite:hover { border-color: var(--lapis); }
.cite--pending { color: var(--ink-soft); }
.status { color: var(--ink-soft); font-style: italic; margin: 0 0 0.6rem; }
.is-working .status::after { content: ""; display: inline-block; width: 1.2em; text-align: start; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.is-error .status { color: var(--g-weak-fg); font-style: normal; }
.searched { font-size: var(--step--1); color: var(--ink-soft); margin: 0.6rem 0; }
.msg-note { font-size: var(--step--1); color: var(--g-weak-fg); }
.fatwa-note { font-size: var(--step--1); color: var(--ink-soft); margin: 0.9rem 0 0.4rem; padding-top: 0.6rem; border-top: 1px solid var(--rule); }
.msg-actions { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0; }

.refs-title { font-size: var(--step--1); color: var(--ink-soft); font-weight: 400; font-style: italic; margin: 1.2rem 0 0.5rem; }
.ref-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.ref-card { background: var(--surface); border: 1px solid var(--rule); padding: 0.7rem 0.9rem; }
.ref-card > * { margin: 0 0 0.35rem; }
.ref-card > :last-child { margin-bottom: 0; }
.ref-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem; }
.ref-link { font-weight: 700; text-decoration: none; }
.ref-book, .ref-chapter { font-size: var(--step--1); color: var(--ink-soft); }
.ref-chapter { font-style: italic; }
.ref-text { font-size: var(--step--1); }
.others { margin-top: 0.75rem; font-size: var(--step--1); }
.others summary { cursor: pointer; color: var(--lapis); }
.others ul { padding-inline-start: 1.2rem; margin: 0.5rem 0 0; }
.others li { margin-bottom: 0.2rem; }

.composer {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; gap: 0.5rem; align-items: flex-end;
  margin: 0 -1.25rem; padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--rule);
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 220px;
  font: inherit; font-size: var(--step-0); line-height: 1.5;
  padding: 0.65rem 0.8rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-bottom: 2px solid var(--lapis); border-radius: 3px;
}
.composer textarea:disabled { opacity: 0.6; }
.composer button.is-stop { background: var(--surface); color: var(--lapis); }
.chat-tools { text-align: center; margin-top: 0.5rem; }

/* Hadith page */

.crumbs { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; padding-top: 1.5rem; font-size: var(--step--1); color: var(--ink-soft); }
.crumbs > * + *::before { content: "/"; margin-inline-end: 0.6rem; color: var(--rule); }

.hadith-head { padding: 0.6rem 0 1.4rem; }
.hadith-head h1 { font-variant-numeric: tabular-nums; margin-bottom: 0.2rem; text-align: start; }
.hadith-chapter { color: var(--ink-soft); font-style: italic; margin: 0; max-width: 60ch; }
[dir="rtl"] .hadith-head h1, [dir="rtl"] .hadith-chapter { text-align: right; }

.folio-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 2rem; align-items: start; }

.folio { background: var(--surface); padding: 1.25rem; border: 1px solid var(--rule); }
/* The jadwal: the ruled frame around a manuscript's text block. */
.jadwal {
  border: 1px solid var(--lapis);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--gold);
  margin: 5px;
  padding: 1.5rem 1.75rem;
  font-size: 1.65rem;
  line-height: 2.25;
  text-align: right;
}
.jadwal p { margin: 0 0 0.6em; }
.jadwal p:last-child { margin-bottom: 0; }

/* The hāshiya: notes in the margin. */
.hashiya { border-inline-start: 1px solid var(--gold); padding-inline-start: 1.25rem; }
.hashiya h2, .translation h2 { font-size: var(--step-0); color: var(--ink-soft); font-weight: 400; font-style: italic; }
.note { padding: 0.25rem 0 1rem; }
.note + .note { border-top: 1px solid var(--rule); padding-top: 1rem; }
.note p { margin: 0 0 0.3rem; }
.note-who { font-weight: 700; line-height: 1.3; }
.note-who-ar { font-size: 1.15rem; color: var(--ink-soft); line-height: 1.6; }
.note-grade { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.note-raw { font-size: 1.2rem; }
.note-ref { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
.note-none { color: var(--ink-soft); font-size: var(--step--1); }

.ai-translate { margin-top: 1.75rem; max-width: 42rem; }
.ai-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.ai-title { color: var(--ink-soft); }
.ai-btn { background: var(--surface); color: var(--lapis); padding: 0.35rem 0.9rem; }
.ai-btn[aria-pressed="true"] { background: var(--lapis); color: #fff; }
@media (prefers-color-scheme: dark) { .ai-btn[aria-pressed="true"] { color: #0f1a1e; } }
.ai-hint { font-size: var(--step--1); color: var(--ink-soft); }
.ai-status { color: var(--ink-soft); font-style: italic; min-height: 1em; margin: 0.4rem 0; }
.ai-out { border-inline-start: 2px solid var(--gold); padding-inline-start: 1rem; margin-top: 0.5rem; }
.ai-label { font-size: var(--step--1); color: var(--g-weak-fg); margin: 0 0 0.5rem; }
.ai-mark { font-size: 0.7em; font-weight: 600; letter-spacing: 0.04em; border: 1px solid currentColor; border-radius: 3px; padding: 0 0.3em; color: var(--g-weak-fg); vertical-align: middle; cursor: help; }
.ai-text { font-size: 1.15rem; text-align: right; }
.ai-text p { margin: 0 0 0.6em; }

.translation { max-width: 42rem; margin-top: 2rem; }
.translation p { margin: 0 0 0.9rem; }
.sanad { color: var(--ink-soft); font-size: var(--step--1); }
.credit { font-size: var(--step--1); color: var(--ink-soft); }
.missing { color: var(--ink-soft); font-style: italic; font-size: var(--step--1); }

/* "Report a mistake" under a translation or an answer (static/app.js builds the box) */
.report-line { margin: 0.3rem 0 0; }
.ai-out .report-line { text-align: start; }
.report-box { max-width: 36rem; margin: 0.6rem 0 1rem; padding: 0.75rem 0.9rem; border: 1px solid var(--rule, #d9d2c3); border-radius: 6px; background: var(--surface); }
.report-label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.report-box textarea { display: block; width: 100%; box-sizing: border-box; font: inherit; padding: 0.45rem 0.55rem; border: 1px solid var(--rule, #d9d2c3); border-radius: 4px; background: var(--paper, #fff); color: inherit; resize: vertical; }
.report-note { font-size: var(--step--1); color: var(--ink-soft); margin: 0.45rem 0; }
.report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0.4rem 0 0; }
.report-send { background: var(--lapis); color: #fff; padding: 0.35rem 1.1rem; }
@media (prefers-color-scheme: dark) { .report-send { color: #0f1a1e; } }
.report-status { font-size: var(--step--1); color: var(--ink-soft); min-height: 1em; margin: 0.35rem 0 0; }
.report-done { margin: 0; color: var(--ink); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin: 1.5rem 0; }
.copy { background: transparent; color: var(--lapis); }
.copy:hover { background: var(--lapis-wash); filter: none; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

/* Pages, notices, admin */

.page-head { padding: 2rem 0 1rem; }
.status { font-weight: 700; }
.chat .status { font-weight: 400; }
.flash { display: inline-block; padding: 0.3rem 0.7rem; background: var(--g-sahih-bg); color: var(--g-sahih-fg); border-radius: 3px; }
.flash--error { background: var(--g-weak-bg); color: var(--g-weak-fg); }

.notice { margin: 1.5rem 0; padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--rule); border-inline-start: 3px solid var(--gold); }
.notice h1, .notice h2 { font-size: var(--step-1); }
.notice p:last-child { margin-bottom: 0; }

.prose { max-width: 42rem; }
.prose h2 { margin-top: 1.75rem; }
.prose li { margin-bottom: 0.4rem; }
.book-list .code { font-size: var(--step--1); color: var(--ink-soft); }

.settings-form { display: grid; gap: 0.4rem; max-width: 34rem; margin: 1rem 0; }
.settings-form label { font-weight: 700; margin-top: 0.6rem; }
.settings-form input {
  font: inherit; padding: 0.6rem 0.8rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-bottom: 2px solid var(--lapis); border-radius: 3px;
}
.settings-actions { margin-top: 0.8rem; }
.settings-check { margin: 0 0 1.5rem; }
.settings-check .hint { font-size: var(--step--1); color: var(--ink-soft); }

.table-scroll { overflow-x: auto; }
.wordings { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.wordings th { text-align: start; font-weight: 400; color: var(--ink-soft); font-style: italic; padding: 0.5rem; border-bottom: 1px solid var(--ink-soft); }
.wordings td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.wordings tr.is-unmapped td:first-child { border-inline-start: 3px solid var(--gold); }
.wording { display: block; font-size: 1.35rem; line-height: 1.6; }
.see { font-size: var(--step--1); }
.map-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.map-form button { padding: 0.3rem 0.8rem; }
@media (min-width: 761px) {
  .wordings td:first-child { width: 34%; }
  .map-form { flex-wrap: nowrap; }
}
.mine { color: var(--ink-soft); font-style: italic; }

/* Admin: narrator names (src/narrator-review.mjs) */
.nr-search { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0 1rem; }
.nr-search input { font: inherit; padding: 0.4rem 0.7rem; min-width: 14rem; border: 1px solid var(--rule); border-bottom: 2px solid var(--lapis); border-radius: 3px; background: var(--surface); color: var(--ink); }
.nr-filters { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-bottom: 0.75rem; }
.nr-list { list-style: none; padding: 0; margin: 0; }
.nr-row { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.nr-head { display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; align-items: baseline; }
.nr-ar { font-size: 1.3rem; }
.nr-en { color: var(--ink-soft); }
.nr-meta { font-size: var(--step--1); color: var(--ink-soft); }
.nr-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.45rem; }
.nr-actions button, .nr-admin .map-form button { padding: 0.25rem 0.7rem; font-size: var(--step--1); }
.nr-other, .nr-hint { margin: 0.35rem 0 0; }
.nr-other bdi { font-size: 1.05rem; }
.nr-hint { font-style: italic; }
.nr-actions button[disabled] { opacity: 0.45; }
.nr-quiet { background: transparent; color: var(--ink-soft); border: 1px solid var(--rule); }
.nr-more { font-size: var(--step--1); }
.nr-badge { display: inline-block; font-size: var(--step--1); padding: 0.05rem 0.5rem; border-radius: 3px; background: var(--surface); border: 1px solid var(--rule); }
.nr-badge--confirmed { background: var(--g-sahih-bg); color: var(--g-sahih-fg); border-color: transparent; }
.nr-badge--several, .nr-badge--not_name { background: var(--g-weak-bg); color: var(--g-weak-fg); border-color: transparent; }
.nr-how { color: var(--ink-soft); }
.nr-forms .map-form { display: inline-flex; margin: 0.15rem 0.3rem 0.15rem 0; }
.nr-joined li, .nr-examples li { margin-bottom: 0.5rem; }
.nr-inline { display: inline-flex; margin-inline-start: 0.5rem; }
.nr-spellings { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; list-style: none; padding: 0; }
.nr-spellings bdi { font-size: 1.15rem; }
.nr-chain { display: block; font-size: 1.1rem; line-height: 1.9; }
.nr-chain mark { background: var(--g-sahih-bg); color: var(--g-sahih-fg); padding: 0 0.15rem; }
.nr-admin .hint { font-size: var(--step--1); color: var(--ink-soft); }
.nr-near .map-form input, .nr-near select { font: inherit; font-size: var(--step--1); }
.nar-joined { margin-top: 0.6rem; }
.nar-admin { font-size: var(--step--1); }
.notice--checked { border-inline-start-color: var(--g-sahih-fg); }

.colophon { border-top: 1px solid var(--rule); padding: 1.5rem 0 2.5rem; font-size: var(--step--1); color: var(--ink-soft); }
.colophon p { max-width: 62ch; }
.colophon-links { display: flex; gap: 1.25rem; }

/* Phones */

@media (max-width: 760px) {
  h1 { font-size: 1.85rem; }
  .chat-intro h1 { font-size: 1.85rem; }
  .masthead { gap: 0.5rem 1rem; }
  .topnav { margin-inline-start: auto; gap: 1rem; }
  .langs { order: 3; width: 100%; padding-inline-start: 0; border-inline-start: 0; justify-content: flex-end; }
  .hero { padding-top: 1.25rem; }
  .finder-row { flex-direction: column; }
  .finder-row button { width: 100%; }
  .filters { display: grid; grid-template-columns: 1fr; }
  .filters select { max-width: none; }
  .result { grid-template-columns: 1fr; gap: 0.35rem; }
  .folio-wrap { grid-template-columns: 1fr; gap: 1.5rem; }
  .folio { padding: 0.6rem; }
  .jadwal { padding: 1rem 1.1rem; font-size: 1.4rem; line-height: 2.15; }
  .hashiya { border-inline-start: 0; border-top: 1px solid var(--gold); padding: 1rem 0 0; }
  .msg--user .msg-body { max-width: 95%; }
  .msg--assistant { padding-inline-start: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Events */

.period { margin-top: 2rem; }
.timeline { list-style: none; padding: 0; margin: 0; border-inline-start: 2px solid var(--gold); }
.timeline li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.75rem; padding: 0.6rem 0 0.6rem 1rem; border-bottom: 1px solid var(--rule); }
[dir="rtl"] .timeline li { padding: 0.6rem 1rem 0.6rem 0; }
.tl-year { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: var(--step--1); padding-top: 0.2rem; }
.tl-body { display: flex; flex-direction: column; gap: 0.15rem; }
.tl-title { font-weight: 700; text-decoration: none; }
.tl-title:hover { text-decoration: underline; }
.tl-ar { color: var(--ink-soft); font-size: 1.05rem; }
.tl-meta { display: flex; gap: 0.75rem; align-items: center; font-size: var(--step--1); color: var(--ink-soft); }
.score { display: inline-block; padding: 0.05rem 0.55rem; border-radius: 999px; font-size: var(--step--1); border: 1px solid transparent; }
.score--3 { background: var(--g-sahih-bg); color: var(--g-sahih-fg); }
.score--2 { background: var(--g-mid-bg); color: var(--g-mid-fg); }
.score--1 { background: var(--g-none-bg); color: var(--g-none-fg); }
.score--0 { background: var(--g-weak-bg); color: var(--g-weak-fg); }
.ev-alt { color: var(--ink-soft); font-size: 1.15rem; margin: 0 0 0.6rem; }
.ev-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0; font-size: var(--step--1); }
.ev-facts dt { color: var(--ink-soft); }
.ev-facts dd { margin: 0; }
.ev-note { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; max-width: 60ch; }
.ev-score { margin: 1.25rem 0; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-inline-start: 3px solid var(--gold); max-width: 42rem; }
.ev-score h2 { font-size: var(--step-0); margin-bottom: 0.4rem; }
.ev-score-line { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.4rem; }
.ev-points { color: var(--ink-soft); font-size: var(--step--1); }
.ev-why summary { cursor: pointer; color: var(--lapis); font-size: var(--step--1); }
.ev-why ul { margin: 0.5rem 0; padding-inline-start: 1.2rem; font-size: var(--step--1); }
.ev-why p { font-size: var(--step--1); color: var(--ink-soft); margin: 0; }
.ev-text p { max-width: 65ch; }
.ev-sources { margin-top: 2rem; }
.ev-sources h3 { margin-top: 1.5rem; color: var(--ink-soft); font-weight: 400; font-style: italic; }
.count { color: var(--ink-soft); font-weight: 400; font-size: var(--step--1); }
.src-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.src { background: var(--surface); border: 1px solid var(--rule); padding: 0.7rem 0.9rem; }
.src--dep { opacity: 0.85; border-style: dashed; }
.src p { margin: 0 0 0.3rem; }
.src-head { line-height: 1.4; }
.src-died { color: var(--ink-soft); font-size: var(--step--1); }
.src-when, .src-check { font-size: var(--step--1); color: var(--ink-soft); }
.src-cite { font-size: var(--step--1); font-style: italic; }
.ev-hadiths { margin-top: 2rem; max-width: 46rem; }
@media (max-width: 760px) { .timeline li { grid-template-columns: 1fr; gap: 0.1rem; } }

/* ---- chat: who the question is about, events, quoted sentences ---- */
.who-box { border-inline-start: 3px solid var(--gold); padding: 0.45rem 0.8rem; margin: 0 0 0.9rem; background: var(--surface); }
.who-head { margin: 0 0 0.4rem; font-size: var(--step--1); color: var(--ink-soft); }
.who-options { list-style: none; margin: 0 0 0.4rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.who-chip {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.4rem;
  font: inherit; font-size: var(--step--1); text-align: start;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  padding: 0.35rem 0.65rem; border-radius: 999px; min-height: 2.25rem;
}
button.who-chip { cursor: pointer; }
button.who-chip:hover, button.who-chip:focus-visible { border-color: var(--lapis); color: var(--lapis); }
.who-chip.is-on { border-color: var(--lapis); background: var(--lapis-wash); color: var(--lapis); font-weight: 700; }
.who-desc { font-weight: 400; color: var(--ink-soft); }
.who-chip.is-on .who-desc { color: inherit; opacity: 0.85; }
.who-hint { margin: 0; font-size: var(--step--1); color: var(--ink-soft); }
.prep-q { margin: 0 0 0.3rem; font-weight: 600; }
.close-box { margin-top: 0.9rem; }
.ev-box { margin-top: 0.9rem; }
.ev-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.ev-card { background: var(--surface); border: 1px solid var(--rule); border-inline-start: 3px solid var(--lapis); padding: 0.6rem 0.9rem; }
.ev-card > * { margin: 0 0 0.25rem; }
.ev-card-title { font-weight: 700; text-decoration: none; }
.ev-card-ar { display: block; font-family: var(--arabic); color: var(--ink-soft); }
.ev-card-date { font-size: var(--step--1); }
.ev-card-meta { font-size: var(--step--1); color: var(--ink-soft); margin: 0; }
.answer .key-quote { display: block; margin-top: 0.2rem; font-size: var(--step--1); color: var(--ink-soft); font-style: italic; text-align: left; }
a.who-chip { text-decoration: none; }
a.who-chip:hover, a.who-chip:focus-visible { border-color: var(--lapis); color: var(--lapis); }
.results .who-box { margin-bottom: 0.75rem; }
.thread-box { border-inline-start-color: var(--lapis); }
.thread-box .who-chip { max-width: 100%; }
.answer .key-quote--ar { font-family: var(--arabic); font-style: normal; font-size: var(--step-0); line-height: 1.9; text-align: right; color: var(--ink); }
.ref-text--ar { font-family: var(--arabic); font-size: var(--step-0); line-height: 1.9; }

/* Help reading this hadith (no AI) */
.aids { max-width: 42rem; margin-top: 2.25rem; border-top: 1px solid var(--gold); padding-top: 1rem; }
.aids h2 { font-size: var(--step-1); margin: 0 0 0.25rem; }
.aids-note { font-size: var(--step--1); color: var(--ink-soft); margin: 0 0 1rem; }
.aid { margin: 0 0 1.25rem; }
.aid h3 { font-size: var(--step-0); color: var(--ink-soft); font-weight: 400; font-style: italic; margin: 0 0 0.5rem; }
.aid-list { list-style: none; margin: 0; padding: 0; }
.aid-list > li { padding: 0.5rem 0; border-top: 1px solid var(--rule); }
.aid-list > li:first-child { border-top: 0; padding-top: 0; }
.aid-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0 0 0.3rem; }
.aid-head .who { color: var(--ink-soft); font-size: var(--step--1); }
.aid-term { font-family: var(--arabic); font-size: 1.3rem; line-height: 1.6; }
.aid-people { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.aid-people .who-chip { min-height: 0; padding: 0.15rem 0.6rem; }
.aid-note, .aid-parts, .aid-general { margin: 0 0 0.25rem; }
.aid-parts { font-size: var(--step--1); }
.aid-part [lang="ar"] { font-family: var(--arabic); font-size: 1.15rem; }
.aid-general { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.6rem; }
.aid-words { margin: 0; }
.aid-words > div { padding: 0.45rem 0; border-top: 1px solid var(--rule); }
.aid-words > div:first-child { border-top: 0; padding-top: 0; }
.aid-words dt { font-weight: 700; }
.aid-words dt [lang="ar"] { font-family: var(--arabic); font-weight: 400; font-size: 1.2rem; margin-inline-start: 0.35rem; }
.aid-words dd { margin: 0.1rem 0 0; }
.aid-en { font-weight: 400; color: var(--ink-soft); font-size: var(--step--1); margin-inline-start: 0.35rem; }
.aid--chapter summary { cursor: pointer; color: var(--lapis); padding: 0.35rem 0; min-height: 2.25rem; }
.aid--chapter[open] summary { margin-bottom: 0.4rem; }
.mini-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.mini { padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.mini.is-current { background: var(--lapis-wash); padding-inline: 0.5rem; }
.mini-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem; margin: 0 0 0.25rem; font-size: var(--step--1); }
.mini-head .who { color: var(--ink-soft); }
.mini-ref { font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-this { font-style: italic; color: var(--ink-soft); }
.mini-text { margin: 0; font-size: var(--step--1); }
.mini-text--ar { font-family: var(--arabic); font-size: 1.15rem; line-height: 1.9; }
.aid-similar { margin: 0.5rem 0 0; }
.sim-tag { display: inline-block; font-style: normal; font-size: 0.8rem; padding: 0 0.45rem; border-radius: 999px; margin-inline-end: 0.35rem; background: var(--g-none-bg); color: var(--g-none-fg); }
.sim-tag--close { background: var(--g-sahih-bg); color: var(--g-sahih-fg); }
.sim-tag--near { background: var(--g-mid-bg); color: var(--g-mid-fg); }
.sim-phrases { font-size: var(--step--1); color: var(--ink-soft); margin-top: 1.25rem; }
.sim-phrases [lang="ar"] { font-family: var(--arabic); font-size: 1.1rem; }
.ai-explain { max-width: 42rem; margin-top: 1.75rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.ai-explain h2 { font-size: var(--step-1); margin: 0 0 0.25rem; }
.ai-explain .ai-text p { margin: 0 0 0.8rem; }
.ai-removed { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
.ai-explain .ai-text { text-align: start; }
.folio-source { font-size: var(--step--1); color: var(--ink-soft); margin: 0.6rem 0 0; }
.hadith-chapter--ar { font-family: var(--arabic); font-size: 1.35rem; line-height: 1.7; }

/* chain of narrators */
.chain { margin: 1.5rem 0; }
.chain-list { list-style: none; margin: 0.5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 0.2rem; font-size: 1.15rem; line-height: 1.9; }
.chain-list li { padding: 0.1rem 0.7rem; border: 1px solid var(--line, #cfc8b8); border-radius: 0.4rem; background: var(--paper, #fbf8f1); }
.chain-list li:not(:last-child)::after { content: "\2190"; margin-inline-start: 0.6rem; opacity: 0.5; }
.chain-list li.chain-imam { font-weight: 600; }
.chain-list li small { font-size: 0.75rem; font-weight: 400; opacity: 0.75; }

/* narrators */
.narrator-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; columns: 2 16rem; column-gap: 2rem; }
.narrator-list li { padding: 0.25rem 0; break-inside: avoid; font-size: 1.1rem; }
.nar-count { font-size: 0.85rem; opacity: 0.7; margin-inline-start: 0.5rem; }
.chain-list a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.chain-list a:hover { border-bottom-style: solid; }

/* Books of rijāl: entries quoted on the narrator pages */
.rijal h3 { font-size: var(--step-0); margin: 1.25rem 0 0.25rem; }
.rijal-entry { margin: 0.25rem 0 0.75rem; }
.rijal-entry summary { cursor: pointer; font-size: 1.1rem; }
.rijal-text { font-family: var(--arabic); font-size: 1.2rem; line-height: 2; text-align: justify; margin: 0.5rem 0 0; padding-inline-start: 1rem; border-inline-start: 2px solid var(--rule); }
.rijal-text--page { font-size: 1.3rem; padding: 0; border: 0; }

/* Names in English letters (English pages), with the Arabic beside them */
.nm-ar { font-family: var(--arabic); font-size: 0.85em; color: var(--ink-soft); margin-inline-start: 0.35em; }
.nm-ar-big { font-family: var(--arabic); font-size: 1.35rem; color: var(--ink-soft); margin: -0.4rem 0 0.4rem; }
.chain-list--en { font-size: 1.02rem; line-height: 1.6; }
.chain-list--en li:not(:last-child)::after { content: "\2192"; }
.chain-list--en .nm-ar { display: block; margin: 0; font-size: 0.8rem; }

/* About him (narrator pages): read from his name and the chains */
.about-narrator { margin: 1.5rem 0; padding: 0.9rem 1.1rem; border: 1px solid var(--rule); border-inline-start: 3px solid var(--gold); background: var(--surface); }
.about-narrator h2 { margin-top: 0; }
.about-narrator h3 { font-size: var(--step-0); margin: 1rem 0 0.3rem; }
.about-list { margin: 0.3rem 0 0.5rem; padding-inline-start: 1.2rem; }
.about-list li { margin: 0.25rem 0; }
.about-list ul { margin: 0.2rem 0; padding-inline-start: 1.1rem; }
.about-list small, .about-mentions small { color: var(--ink-soft); }
.about-mentions { margin: 0.8rem 0 0; }

/* AI translation of a rijāl entry, before the scholar's own words */
.rijal-ai { margin: 0.6rem 0 0.4rem; padding: 0.5rem 0.8rem; background: var(--lapis-wash); border-radius: 3px; }
.rijal-orig { margin: 0.6rem 0 0; font-size: var(--step--1); color: var(--ink-soft); }
.rijal-none { margin: 0.5rem 0 0; font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
/* in the reader's language: a grade wording word by word, a piece of the Urdu/Persian translation */
.note-gloss { font-size: var(--step--1); color: var(--ink-soft); margin: 0.1rem 0 0.2rem; }
.result-tr { margin: 0.35rem 0 0; }
.result .result-tr { grid-column: 1 / -1; }
.rijal-ai p { margin: 0.3rem 0; }
.rijal-ai .ai-label { margin-bottom: 0.3rem; }
.result-snippet { font-family: var(--arabic); font-size: 1.1rem; line-height: 1.9; margin: 0.35rem 0 0; }
.result .result-snippet { grid-column: 1 / -1; }
.chain-list--en li { display: flex; align-items: center; gap: 0.15rem 0.5rem; flex-wrap: wrap; }
.chain-list--en li:not(:last-child)::after { margin-inline-start: 0.2rem; }
.searchbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch; }
.searchbar input[type="search"] { flex: 1 1 16rem; min-width: 0; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-bottom: 2px solid var(--lapis); padding: 0.5rem 0.7rem; }
.searchbar select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); padding: 0.4rem 0.5rem; max-width: 100%; }

/* short Latin names inside right-to-left text stay on one line */
.nobr { white-space: nowrap; }

/* The chain check by al-Ḥillī's rules (worked out by the app, apart from the scholars' grades) */
.note--check { border-top: 1px dashed var(--gold) !important; margin-top: 0.5rem; }
.grade--undecided { background: transparent; color: var(--ink-soft); border: 1px dashed var(--ink-soft); }
.grade--app { outline: 1px dashed currentColor; outline-offset: 2px; }
.chain-check { margin: 1.5rem 0; max-width: 46rem; }
.cc-result { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.cc-label { font-weight: 700; }
.cc-why { color: var(--ink-soft); }
.cc-route { margin: 0.4rem 0; }
.cc-flags { margin: 0.4rem 0; padding-inline-start: 1.2rem; color: var(--ink-soft); }
.cc-sub { font-size: var(--step-0); margin: 1rem 0 0.25rem; }
.cc-list { list-style: none; margin: 0; padding: 0; counter-reset: cc; }
.cc-link { counter-increment: cc; padding: 0.5rem 0 0.5rem 0; padding-inline-start: 2rem; border-top: 1px solid var(--rule); position: relative; }
.cc-link::before { content: counter(cc); position: absolute; inset-inline-start: 0.25rem; top: 0.55rem; font-size: var(--step--1); color: var(--ink-soft); }
.cc-link p { margin: 0 0 0.15rem; }
.cc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; }
.cc-names { font-size: 1.1rem; }
.cc-names a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.cc-before { color: var(--ink-soft); }
.cc-s { font-size: var(--step--1); padding: 0.05rem 0.5rem; border-radius: 3px; }
.cc-s--T { background: var(--g-sahih-bg); color: var(--g-sahih-fg); }
.cc-s--H, .cc-s--M { background: var(--g-mid-bg); color: var(--g-mid-fg); }
.cc-s--W, .cc-s--X { background: var(--g-weak-bg); color: var(--g-weak-fg); }
.cc-s--U { border: 1px dashed var(--ink-soft); color: var(--ink-soft); }
.cc-how, .cc-entries { font-size: var(--step--1); color: var(--ink-soft); }
.cc-entries a { color: var(--lapis); }
.cc-method { margin-top: 0.75rem; }
.cc-results { list-style: none; padding: 0; }
.cc-results li { margin: 0 0 0.5rem; }
.table-wrap { overflow-x: auto; }
.cc-table { border-collapse: collapse; font-size: var(--step--1); min-width: 32rem; }
.cc-table th, .cc-table td { padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--rule); text-align: end; }
.cc-table th[scope="row"], .cc-table thead th:first-child { text-align: start; }
.cc-link--covered { opacity: 0.75; }

/* The same words in other books (texts without a chain) */
.parallels { margin: 1.5rem 0; max-width: 46rem; }
.par-list { list-style: none; margin: 0.5rem 0; padding: 0; }
.par-list li { padding: 0.5rem 0; border-top: 1px solid var(--rule); }
.par-list p { margin: 0 0 0.15rem; }
.par-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; }
.par-book, .par-share, .par-label, .par-none { color: var(--ink-soft); }
.par-grades { font-size: var(--step--1); }

/* The scholars' explanations (al-Majlisī's Biḥār al-Anwār) and the note on hint words */
.fig-note { margin: 1rem 0; max-width: 46rem; padding: 0.6rem 0.9rem; border-inline-start: 3px solid var(--rule); background: color-mix(in srgb, var(--rule) 18%, transparent); font-size: var(--step--1); }
.fig-note p { margin: 0; }
.scholars { margin: 1.5rem 0; max-width: 46rem; }
.sch-item { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.sch-who { font-weight: 600; margin: 0 0 0.3rem; }
.sch-label, .sch-path { color: var(--ink-soft); font-size: var(--step--1); margin: 0.4rem 0 0.1rem; }
.sch-chapter { margin: 0 0 0.3rem; font-size: 1.1em; }
.sch-text p { margin: 0 0 0.5em; line-height: 1.9; }
.sch-comment { color: var(--ink-soft); }
.sch-intro { margin: 0.4rem 0; }
.sch-intro summary { cursor: pointer; color: var(--ink-soft); font-size: var(--step--1); }
.sch-all, .sch-ours { font-size: var(--step--1); margin: 0.3rem 0 0; }
.bihar-list { max-width: 46rem; padding-inline-start: 2rem; }
.bihar-list li { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
