@font-face {
  font-family: 'Droid Arabic Naskh';
  src: url('/fonts/DroidNaskh-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Droid Arabic Naskh';
  src: url('/fonts/DroidNaskh-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Kufi Arabic';
  src: url('/fonts/noto-kufi-arabic-arabic-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Kufi Arabic';
  src: url('/fonts/noto-kufi-arabic-arabic-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Aref Ruqaa';
  src: url('/fonts/aref-ruqaa-arabic-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* Classic Arabic scholarly palette matching al-albani.pages.dev */
:root {
  color-scheme: light;
  --navy: #1f4d40;
  --blue: #2c6e58;
  --link: #246854;
  --green: #8cc63f;
  --green-dark: #6fa831;
  --ok: #2e7031;
  --weak: #b03a26;
  --mawdu: #841c1c;
  --other: #8a5a14;
  --bg: #f4f4f4;
  --card: #ffffff;
  --soft: #f8f8f8;
  --ink: #2b2b2b;
  --muted: #6c6c6c;
  --line: #e2e2e2;
  --ui: 'Noto Kufi Arabic', 'Droid Arabic Naskh', sans-serif;
  --serif: 'Droid Arabic Naskh', 'Noto Naskh Arabic', serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #0c1a16;
  --blue: #7cc4aa;
  --link: #8fd1b8;
  --green: #6f9e32;
  --green-dark: #5d8a28;
  --ok: #98ce62;
  --weak: #e68673;
  --mawdu: #f08282;
  --other: #e2b45d;
  --bg: #111a17;
  --card: #17241f;
  --soft: #1c2b25;
  --ink: #dde8e3;
  --muted: #98aaa2;
  --line: #2a3b34;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.95;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--navy); text-decoration: underline; }
:root[data-theme="dark"] a:hover { color: #fff; }
[hidden] { display: none !important; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; width: 100%; }

/* Top header bar */
.top { background: var(--navy); color: #fff; border-bottom: 3px solid var(--green); }
:root[data-theme="dark"] .top { border-bottom-color: var(--green-dark); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1.2rem; flex-wrap: wrap; padding-block: .55rem .65rem; }
.brand { display: flex; flex-direction: column; color: #fff; line-height: 1.2; }
.brand:hover { text-decoration: none; color: #fff; }
.brand small { font-family: var(--ui); font-weight: 700; font-size: .76rem; opacity: .9; }
.brand-title { font-family: 'Aref Ruqaa', serif; font-size: 2.25rem; font-weight: 700; line-height: 1.3; }

.top-tools { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--ui);
  font-size: .82rem;
  font-weight: 700;
  padding: .36rem .75rem;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.45);
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  line-height: 1.4;
}
.tool-btn:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.75); }
.tool-btn .ico { display: inline-block; flex: none; }
.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: inline-block; }

/* Secondary navigation strip */
.subnav { background: var(--card); border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.04); font-family: var(--ui); font-size: .88rem; }
.subnav-in { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; }
.subnav-links { display: flex; align-items: stretch; gap: .2rem; flex-wrap: wrap; }
.subnav-links a {
  padding: .68rem .85rem .58rem;
  color: var(--ink);
  font-weight: 700;
  border-bottom: 3px solid transparent;
}
.subnav-links a:hover { color: var(--blue); text-decoration: none; }
.subnav-links a.on { color: var(--blue); border-bottom-color: var(--green-dark); }
.sister-link { font-size: .82rem; font-weight: 700; color: var(--blue); padding: .45rem 0; }

/* Patterned page background (same classic tile as al-albani.pages.dev) */
.page {
  flex: 1;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23e2e2e2' stroke-width='1'%3E%3Crect x='20' y='20' width='32' height='32'/%3E%3Crect x='20' y='20' width='32' height='32' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 0l14 14M72 0L58 14M0 72l14-14M72 72L58 58'/%3E%3C/g%3E%3C/svg%3E");
  padding: 1.4rem 0 2.4rem;
}
:root[data-theme="dark"] .page {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23192821' stroke-width='1'%3E%3Crect x='20' y='20' width='32' height='32'/%3E%3Crect x='20' y='20' width='32' height='32' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 0l14 14M72 0L58 14M0 72l14-14M72 72L58 58'/%3E%3C/g%3E%3C/svg%3E");
}

/* Classic green tab section heading */
.sec { display: flex; align-items: flex-end; justify-content: space-between; gap: .6rem; border-bottom: 2px solid #dce8e2; margin: 0 0 .9rem; font-family: var(--ui); }
:root[data-theme="dark"] .sec { border-color: var(--line); }
.sec h1, .sec h2 {
  margin: 0;
  background: var(--green-dark);
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.5;
  padding: .38rem 1.05rem;
  border-radius: 3px 3px 0 0;
}
.sec-meta { font-size: .8rem; color: var(--muted); padding-bottom: .3rem; }

/* White ruled panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
:root[data-theme="dark"] .panel { box-shadow: 0 1px 5px rgba(0,0,0,.4); }
.panel-head { padding: .65rem 1.2rem; background: var(--soft); border-bottom: 1px solid var(--line); font-family: var(--ui); font-size: .86rem; color: var(--muted); }

/* Search panel */
.search-panel { margin-bottom: 1.5rem; }
.search-form { padding: 1rem 1.2rem; }
.search-row { display: flex; gap: .5rem; }
.search-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: .48rem .85rem;
  border: 1px solid #cfcfcf;
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
  outline: 0;
}
:root[data-theme="dark"] .search-row input { border-color: #33493f; background: var(--bg); }
.search-row input:focus { border-color: var(--blue); }
.btn-primary {
  font-family: var(--ui);
  font-size: .9rem;
  font-weight: 700;
  padding: .48rem 1.6rem;
  border: 0;
  border-radius: 3px;
  background: var(--green-dark);
  color: #fff;
  cursor: pointer;
}
.btn-primary:hover { background: var(--blue); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.filters select {
  font-family: var(--ui);
  font-size: .84rem;
  padding: .38rem .7rem;
  border: 1px solid #cfcfcf;
  border-radius: 3px;
  background: var(--soft);
  color: var(--ink);
  max-width: 100%;
}
:root[data-theme="dark"] .filters select { border-color: #33493f; background: var(--bg); }

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .55rem;
  padding: .6rem 1.2rem;
  background: var(--soft);
  border-top: 1px solid var(--line);
  font-family: var(--ui);
  font-size: .82rem;
  color: var(--muted);
}
.examples a { color: var(--link); }
.ex-sep { color: var(--muted); opacity: .55; }

/* Classic ruled book lists */
.book-sec { margin-top: 1.5rem; }
.book-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.book-list li { border-bottom: 1px solid var(--line); }
.book-list li:nth-child(odd) { border-inline-end: 1px solid var(--line); }
.book-list a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .72rem 1.15rem;
  color: var(--ink);
  transition: background .12s;
}
.book-list a::before {
  content: '';
  flex: none;
  width: .42rem;
  height: .42rem;
  border-top: 2px solid var(--green-dark);
  border-left: 2px solid var(--green-dark);
  transform: rotate(-45deg);
}
.book-list a:hover { background: var(--soft); color: var(--navy); text-decoration: none; }
:root[data-theme="dark"] .book-list a:hover { color: #fff; }
.book-name { font-family: var(--ui); font-size: .92rem; font-weight: 700; color: var(--link); }
.book-count { margin-inline-start: auto; font-family: var(--ui); font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* Hadith list inside unified panel */
.h-list { padding: 0 1.4rem; }
.h-item { padding: 1.15rem 0; border-top: 1px solid var(--line); }
.h-item:first-child { border-top: 0; }
.h-item.h-single { padding: 1.35rem 1.5rem; border-top: 0; }
.h-text { font-size: 1.14rem; line-height: 2.15; margin-bottom: .65rem; }
.h-text.clip { max-height: 13rem; overflow: hidden; -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
.h-text mark { background: #fbf3c4; color: inherit; border-radius: 2px; padding: 0 .1rem; }
:root[data-theme="dark"] .h-text mark { background: #5a4c12; }
.h-expand { margin: -.25rem 0 .65rem; padding: 0; border: 0; background: none; color: var(--blue); font-family: var(--ui); font-size: .84rem; font-weight: 700; cursor: pointer; }
.h-expand:hover { text-decoration: underline; }
.h-ref { margin: -.2rem 0 .6rem; font-size: .88rem; color: var(--muted); }
.h-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; font-family: var(--ui); font-size: .82rem; color: var(--muted); }
.meta-book a { font-weight: 700; color: var(--blue); }
.meta-chap { color: var(--green-dark); }
.meta-in { color: var(--blue); }
.h-grade b { font-weight: 700; }
.h-grade.ok b { color: var(--ok); }
.h-grade.weak b { color: var(--weak); }
.h-grade.mawdu b { color: var(--mawdu); }
.h-grade.other b { color: var(--other); }

.h-actions { margin-inline-start: auto; display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.act-btn {
  font-family: var(--ui);
  font-size: .76rem;
  padding: .16rem .6rem;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--link);
  cursor: pointer;
}
.act-btn:hover { border-color: var(--blue); text-decoration: none; }
.act-btn.copied { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

.comm { margin-top: .75rem; }
.comm summary { cursor: pointer; font-family: var(--ui); font-size: .85rem; font-weight: 700; color: var(--blue); }
.comm-body { margin-top: .5rem; padding: .5rem 1rem; border-inline-start: 3px solid var(--green-dark); background: var(--soft); font-size: .98rem; line-height: 2; }
.comm-body p { margin: .45rem 0; }

/* Breadcrumbs, Chapters & Book controls */
.crumbs {
  margin: 0 0 1.1rem;
  padding: .45rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  font-family: var(--ui);
  font-size: .82rem;
  color: var(--muted);
}
.crumbs a { color: var(--blue); }

.book-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; font-family: var(--ui); }
.btn-outline {
  display: inline-block;
  font-family: var(--ui);
  font-size: .84rem;
  font-weight: 700;
  padding: .4rem .9rem;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--blue);
}
.btn-outline:hover { border-color: var(--blue); text-decoration: none; }

.grade-tabs { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem 1.2rem; background: var(--soft); border-bottom: 1px solid var(--line); font-family: var(--ui); font-size: .8rem; }
.grade-tabs a { padding: .24rem .7rem; border-radius: 3px; border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.grade-tabs a.on, .grade-tabs a:hover { background: var(--blue); border-color: var(--blue); color: #fff; text-decoration: none; }

.ch-list { padding: .4rem 1.2rem; }
.ch-grp { font-family: var(--ui); font-size: .92rem; color: var(--blue); margin: 1rem 0 .3rem; }
.ch-item { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.ch-item:last-child { border-bottom: 0; }
.ch-item:hover { color: var(--blue); text-decoration: none; }
.ch-item small { font-family: var(--ui); font-size: .78rem; color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .85rem 1.2rem;
  border-top: 1px solid var(--line);
  background: var(--soft);
  font-family: var(--ui);
  font-size: .84rem;
}
.pager.standalone { margin-top: 1rem; border: 1px solid var(--line); border-radius: 3px; background: var(--card); }
.page-info { color: var(--muted); }

/* Prose & Note */
.prose { padding: 1.4rem 1.7rem; }
.prose h1 { font-family: var(--ui); font-size: 1.3rem; color: var(--blue); margin: 0 0 1rem; }
.prose h2 { font-family: var(--ui); font-size: 1.05rem; color: var(--blue); margin: 1.5rem 0 .5rem; }
.prose h2::before {
  content: '';
  display: inline-block;
  width: .42rem;
  height: .42rem;
  border-top: 2px solid var(--green-dark);
  border-left: 2px solid var(--green-dark);
  transform: rotate(-45deg);
  margin-inline-end: .55rem;
  vertical-align: .12em;
}
.prose p { margin: 0 0 .9rem; text-align: justify; }
.prose ul { padding-inline-start: 1.4rem; }
.prose li { margin-bottom: .5rem; }
.prose code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: .84em; background: var(--soft); padding: .08rem .35rem; border-radius: 2px; border: 1px solid var(--line); }
.source-line { margin-top: 1.4rem; padding-top: .9rem; border-top: 1px solid var(--line); font-family: var(--ui); font-size: .82rem; color: var(--muted); }
.note-panel { margin-top: 1.6rem; padding: .9rem 1.25rem; font-size: .85rem; line-height: 1.85; color: var(--muted); }
.note-panel code { font-size: .85em; }
.empty { padding: 1.6rem; text-align: center; color: var(--muted); }

/* Footer */
.foot { background: var(--navy); color: #cde1d9; border-top: 3px solid var(--green); padding: 1rem 0; font-family: var(--ui); font-size: .82rem; }
:root[data-theme="dark"] .foot { border-top-color: var(--green-dark); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .4rem .7rem; }
.foot a { color: #e2f1eb; }
.sep { opacity: .45; }

@media (max-width: 720px) {
  .book-list { grid-template-columns: minmax(0, 1fr); }
  .book-list li:nth-child(odd) { border-inline-end: 0; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .brand-title { font-size: 1.8rem; }
  .h-list { padding: 0 1rem; }
  .h-item.h-single, .prose { padding: 1.1rem; }
  .search-form, .examples { padding-inline: .9rem; }
  .search-row { flex-direction: column; }
  .btn-primary { width: 100%; }
}
