/* ============================================================
   مكتبة السيرة — نظام التصميم المشترك
   Seerah Library · shared design system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Aref+Ruqaa:wght@400;700&family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-ui: 'Cairo', 'Geeza Pro', 'Al Bayan', Tahoma, sans-serif;
  --font-display: 'Aref Ruqaa', 'Amiri', 'Traditional Arabic', 'Geeza Pro', serif;
  --font-naskh: 'Amiri', 'Geeza Pro', 'Traditional Arabic', serif;

  /* Light — off-white blended with warm yellow */
  --bg: #F7F2E3;
  --bg2: #FCF9EF;
  --surface: #FFFCF4;
  --surface2: #F1E9D5;
  --ink: #2B2A23;
  --ink2: #615B4B;
  --muted: #8C846C;
  --line: rgba(122, 94, 40, .20);
  --line2: rgba(122, 94, 40, .11);
  --gold: #A8802F;
  --gold2: #DDB866;
  --gold-soft: rgba(168, 128, 47, .11);
  --wine: #6F2A2A;
  --emerald: #2E5C4B;
  --shadow: 0 22px 55px rgba(89, 68, 26, .16);
  --shadow-sm: 0 7px 20px rgba(89, 68, 26, .10);
  --glass: rgba(255, 252, 244, .80);
  --reader-bg: #3A3730;
  --pattern-op: .105;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'%3E%3Cg fill='none' stroke='%23A8802F' stroke-width='1'%3E%3Cpath d='M45 6 L54 22 L72 14 L64 32 L84 45 L64 58 L72 76 L54 68 L45 84 L36 68 L18 76 L26 58 L6 45 L26 32 L18 14 L36 22 Z'/%3E%3Ccircle cx='45' cy='45' r='13'/%3E%3Crect x='0' y='0' width='90' height='90'/%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="dark"] {
  /* Night — deep gray */
  --bg: #1B1D20;
  --bg2: #222427;
  --surface: #282B2F;
  --surface2: #303338;
  --ink: #F4EEDD;
  --ink2: #C6C0B0;
  --muted: #948D7C;
  --line: rgba(216, 180, 106, .22);
  --line2: rgba(216, 180, 106, .11);
  --gold: #D8B46A;
  --gold2: #F1D695;
  --gold-soft: rgba(216, 180, 106, .11);
  --wine: #C07979;
  --emerald: #7FBCA6;
  --shadow: 0 22px 60px rgba(0, 0, 0, .48);
  --shadow-sm: 0 7px 22px rgba(0, 0, 0, .32);
  --glass: rgba(40, 43, 47, .82);
  --reader-bg: #15171A;
  --pattern-op: .085;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'%3E%3Cg fill='none' stroke='%23D8B46A' stroke-width='1'%3E%3Cpath d='M45 6 L54 22 L72 14 L64 32 L84 45 L64 58 L72 76 L54 68 L45 84 L36 68 L18 76 L26 58 L6 45 L26 32 L18 14 L36 22 Z'/%3E%3Ccircle cx='45' cy='45' r='13'/%3E%3Crect x='0' y='0' width='90' height='90'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.8;
  overflow-x: hidden;
  transition: background .45s ease, color .45s ease;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--pattern);
  background-size: 90px 90px;
  opacity: var(--pattern-op);
  transition: opacity .45s ease;
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 88% -5%, var(--gold-soft), transparent 70%),
    radial-gradient(700px 520px at 2% 95%, rgba(111, 42, 42, .07), transparent 72%);
}
.topbar, main, .modal, .site-footer { position: relative; z-index: 1; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: var(--gold); color: #fff; }
:focus-visible { outline: 3px solid var(--gold2); outline-offset: 3px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 99px; border: 3px solid var(--bg2); }

.wrap { width: min(1220px, 92vw); margin-inline: auto; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.center { text-align: center; }
.hide { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 0; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; color: #241C0C;
  background: linear-gradient(145deg, var(--gold2), var(--gold));
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text strong { display: block; font-family: var(--font-display); font-size: 20px; line-height: 1.35; }
.brand-text small { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; }
.top-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex: 1; }
.search-wrap { position: relative; display: flex; align-items: center; width: min(360px, 44vw); }
.search-wrap > svg { position: absolute; right: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-wrap input {
  width: 100%; padding: 10px 42px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  outline: none; font-size: 13.5px; transition: .25s;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.search-wrap kbd {
  position: absolute; left: 12px; font-family: var(--font-ui); font-size: 11px;
  color: var(--muted); background: var(--surface2); border: 1px solid var(--line);
  border-radius: 6px; padding: 0 6px; line-height: 19px;
}
.theme-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 12.5px; font-weight: 700; white-space: nowrap; transition: .25s;
}
.theme-btn:hover { border-color: var(--gold); color: var(--gold); }
.theme-btn svg { width: 17px; height: 17px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: .25s; flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold); transform: rotate(-8deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 21px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: 13.5px; transition: .28s; white-space: nowrap;
  background: transparent; color: var(--ink);
}
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  color: #241C0C; box-shadow: 0 10px 26px rgba(168, 128, 47, .28);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 16px 32px rgba(168, 128, 47, .40); }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-2px); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-outline { border-color: var(--gold); color: var(--gold); }
.btn-outline:hover { background: var(--gold-soft); }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1.12fr .88fr; gap: 46px; align-items: center; padding: 62px 0 48px; }
.eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-naskh); font-size: 20px; color: var(--gold); margin: 0;
}
.eyebrow::before, .eyebrow::after { content: ""; height: 1px; width: 42px; background: linear-gradient(90deg, transparent, var(--gold)); }
.eyebrow::after { background: linear-gradient(90deg, var(--gold), transparent); }
.hero h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(40px, 5.6vw, 76px); line-height: 1.3; margin: 12px 0 10px;
  letter-spacing: -1px;
}
.gold-text {
  color: var(--gold);
  background: linear-gradient(115deg, var(--gold), var(--gold2) 40%, var(--wine) 95%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero .sallallah { font-size: .52em; vertical-align: middle; -webkit-text-fill-color: var(--gold); }
.hero-sub { font-size: 16px; color: var(--ink2); max-width: 54ch; margin: 0 0 4px; line-height: 2.05; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 28px; }
.stat {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 15px; box-shadow: var(--shadow-sm);
}
.stat svg { width: 20px; height: 20px; color: var(--gold); }
.stat b { font-size: 18px; color: var(--ink); line-height: 1.2; }
.stat span { font-size: 11px; color: var(--muted); display: block; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 11px; }

.hero-art { position: relative; display: grid; place-items: center; min-height: 430px; }
.hero-art::before {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), transparent 68%); filter: blur(8px);
}
.ring {
  position: absolute; inset: 0; margin: auto;
  width: 392px; height: 392px; border-radius: 50%;
  border: 1px dashed var(--line); animation: spin 80s linear infinite;
}
.ring::before, .ring::after {
  content: ""; position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); top: -5px; left: calc(50% - 4px);
}
.ring::after { top: auto; bottom: -5px; background: var(--wine); }
.ring.small { width: 330px; height: 330px; border-style: solid; border-color: var(--line2); animation-direction: reverse; }
.book-frame {
  position: relative; width: min(292px, 76%); padding: 9px; border-radius: 5px;
  background: linear-gradient(145deg, var(--gold2), #8A6A24 45%, var(--gold2));
  box-shadow: 0 28px 60px rgba(60, 40, 10, .38); transform: rotate(-3deg);
  transition: transform .55s cubic-bezier(.2, .8, .2, 1);
  animation: floaty 7s ease-in-out infinite;
}
.book-frame:hover { transform: rotate(0deg) translateY(-10px); }
.book-frame img { width: 100%; aspect-ratio: 451 / 698; object-fit: cover; border: 2px solid rgba(255, 255, 255, .45); }
.book-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .30), transparent 38%);
}
.seal {
  position: absolute; bottom: 2%; left: 1%; width: 98px; height: 98px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--gold);
  display: grid; place-items: center; text-align: center; box-shadow: var(--shadow);
  transform: rotate(9deg); z-index: 3;
}
.seal b { display: block; font-size: 24px; color: var(--gold); line-height: 1.1; font-family: var(--font-display); }
.seal span { display: block; font-size: 10px; color: var(--muted); }

/* ---------- Progress band ---------- */
.band {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px 28px;
  display: flex; align-items: center; gap: 24px; box-shadow: var(--shadow-sm);
}
.band::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: linear-gradient(var(--gold2), var(--wine)); }
.ring-box { width: 84px; height: 84px; flex: 0 0 84px; position: relative; }
.ring-box svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-box circle { fill: none; stroke-width: 8; }
.ring-box .track { stroke: var(--surface2); }
.ring-box .fill { stroke: var(--gold); stroke-linecap: round; transition: stroke-dasharray .7s ease; }
.ring-box span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: var(--gold); white-space: nowrap; }
.band-body { flex: 1; min-width: 0; }
.band-body h3 { margin: 0 0 2px; font-family: var(--font-display); font-size: 21px; font-weight: 400; }
.band-body p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.progress-track { height: 9px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold2)); transition: width .7s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Sections ---------- */
.section { padding: 62px 0 8px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.kicker { font-size: 11px; letter-spacing: 2px; color: var(--gold); font-weight: 800; }
.section-head h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 3.4vw, 42px); margin: 4px 0 0; }
.section-head p { margin: 4px 0 0; color: var(--ink2); font-size: 13.5px; }
.note-line { font-size: 12px; color: var(--muted); }

/* ---------- Roadmap ---------- */
.roadmap-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 26px; box-shadow: var(--shadow-sm); }
.phases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.phase {
  position: relative; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: 18px; padding: 17px 15px 19px;
  transition: .3s;
}
.phase:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: var(--shadow-sm); }
.phase::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 3px; background: linear-gradient(90deg, var(--gold2), var(--wine)); }
.phase-num { font-size: 10px; font-weight: 800; color: var(--gold); letter-spacing: 1px; }
.phase h3 { font-family: var(--font-display); font-weight: 400; font-size: 23px; margin: 2px 0 0; }
.phase .rng { font-size: 11.5px; color: var(--muted); }
.nodes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; position: relative; }
.nodes::before { content: ""; position: absolute; top: 21px; right: 18px; left: 18px; height: 2px; background: var(--line); }
.node {
  position: relative; z-index: 1; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink2);
  transition: .28s;
}
.node:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-4px) scale(1.06); box-shadow: var(--shadow-sm); }
.node.done { background: linear-gradient(145deg, var(--gold2), var(--gold)); color: #241C0C; border-color: transparent; }
.node.done:hover { color: #241C0C; }
.phase-foot { margin-top: 14px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* ---------- Cards ---------- */
.search-status { font-size: 13px; color: var(--muted); margin: -12px 0 18px; }
.search-status b { color: var(--gold); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s, border-color .35s;
  animation: rise .55s both;
}
.card:hover { transform: translateY(-9px); box-shadow: var(--shadow); border-color: var(--gold); }
.card-thumb { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--surface2); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .6s ease; }
.card:hover .card-thumb img { transform: scale(1.07); }
.card-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 64%, rgba(24, 18, 6, .56)); }
.badge {
  position: absolute; top: 11px; right: 11px; z-index: 2;
  background: linear-gradient(135deg, var(--gold2), var(--gold)); color: #241C0C;
  font-weight: 800; font-size: 11px; padding: 4px 11px; border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .22);
}
.read-ribbon {
  position: absolute; top: 11px; left: 11px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--emerald); color: #fff; border: 2px solid rgba(255, 255, 255, .7);
}
.read-ribbon svg { width: 14px; height: 14px; }
.thumb-label { position: absolute; bottom: 10px; right: 13px; z-index: 2; color: #FFF6DF; font-size: 11.5px; font-weight: 700; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.card-body { padding: 15px 17px 17px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card-body h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 21px; line-height: 1.5; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 10.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--ink2); border: 1px solid var(--line2); }
.card-foot { margin-top: auto; padding-top: 11px; display: flex; gap: 7px; }
.card-foot .btn { flex: 1; padding: 9px 10px; font-size: 12px; }
.card-foot .icon-btn { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; }
.empty {
  grid-column: 1 / -1; text-align: center; padding: 62px 20px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 22px;
}
.empty svg { width: 54px; height: 54px; color: var(--gold); margin: 0 auto 12px; opacity: .7; }
.empty h3 { font-family: var(--font-display); font-weight: 400; margin: 0 0 4px; font-size: 24px; }
.empty p { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 70px; border-top: 1px solid var(--line); padding: 30px 0 42px; }
.orn-divider { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--gold); margin-bottom: 16px; }
.orn-divider::before, .orn-divider::after { content: ""; width: min(180px, 22vw); height: 1px; background: linear-gradient(90deg, transparent, var(--line)); }
.orn-divider::after { background: linear-gradient(90deg, var(--line), transparent); }
.orn-divider svg { width: 22px; height: 22px; }
.site-footer p { margin: 4px 0; color: var(--muted); font-size: 12.5px; }
.json-link { color: var(--gold); font-weight: 700; border-bottom: 1px dashed var(--gold); }
.json-link:hover { color: var(--wine); border-color: var(--wine); }
.site-footer .bism { font-family: var(--font-naskh); font-size: 19px; color: var(--gold); }

/* ---------- Modal (embedded sub-path) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(18, 16, 11, .66); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  padding: 16px;
}
[data-theme="dark"] .modal { background: rgba(0, 0, 0, .74); }
.modal.open { display: flex; flex-direction: column; animation: fade .25s both; }
.modal-sheet {
  width: min(1300px, 100%); height: 100%; margin: auto;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border: 1px solid var(--gold); border-radius: 20px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, .55);
  animation: pop .32s cubic-bezier(.2, .8, .2, 1) both;
}
.modal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 15px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.modal-bar .mb-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-bar .mb-title b { font-family: var(--font-display); font-weight: 400; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-bar .mb-title small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.modal-bar .mb-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.modal-sheet > iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* ---------- Part page ---------- */
.part-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--surface), var(--bg2));
  border-bottom: 1px solid var(--line); padding: 34px 0 0;
}
.part-hero::before {
  content: ""; position: absolute; inset-inline-end: -60px; top: -110px;
  width: 340px; height: 340px; border-radius: 50%; border: 1px dashed var(--line);
}
.part-hero-inner { display: grid; grid-template-columns: auto 1fr auto; gap: 28px; align-items: center; padding-bottom: 26px; }
.part-num {
  font-family: var(--font-display); font-size: clamp(74px, 10vw, 138px); line-height: 1;
  color: transparent; -webkit-text-stroke: 2px var(--gold); opacity: .5;
}
.part-hero h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 4vw, 50px); margin: 2px 0 4px; line-height: 1.4; }
.part-hero .sub { color: var(--ink2); font-size: 14px; margin: 0 0 12px; }
.part-hero-thumb { width: 106px; border-radius: 4px; border: 3px solid var(--gold); box-shadow: var(--shadow); transform: rotate(4deg); }
.journey { display: flex; align-items: center; gap: 14px; padding-bottom: 22px; }
.journey .jt { flex: 1; }
.journey-label { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; display: flex; justify-content: space-between; }

.reader { padding: 30px 0 14px; }
.reader-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; padding: 12px 16px;
}
.reader-title { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 14px; }
.reader-title svg { width: 19px; height: 19px; color: var(--gold); }
.reader-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.page-jump { display: flex; align-items: center; gap: 6px; }
.page-jump span { font-size: 12px; color: var(--muted); }
.page-jump input {
  width: 88px; padding: 7px 9px; border-radius: 10px; text-align: center;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); outline: none; font-size: 13px;
}
.page-jump input:focus { border-color: var(--gold); }
.shake { animation: shake .35s; }
.paper {
  position: relative; padding: 13px;
  border: 1px solid var(--line); border-radius: 0 0 18px 18px;
  background: var(--reader-bg); box-shadow: var(--shadow);
}
.paper iframe { display: block; width: 100%; height: min(76vh, 900px); min-height: 520px; border: 0; border-radius: 7px; background: #fff; }
.reader-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 12px 2px 0; font-size: 12px; color: var(--muted);
}
.reader-hint .btn { font-size: 11.5px; padding: 6px 12px; }

.part-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.part-actions .side { display: flex; gap: 9px; flex-wrap: wrap; }
.chip-section { margin-top: 34px; }
.chip-section h3 { font-family: var(--font-display); font-weight: 400; font-size: 22px; margin: 0 0 14px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  width: 42px; height: 42px; border-radius: 12px; font-weight: 800; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink2); transition: .25s;
}
.chip:hover { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); transform: translateY(-3px); }
.chip.active { background: linear-gradient(145deg, var(--gold2), var(--gold)); color: #241C0C; border-color: transparent; }
.chip.done:not(.active) { border-color: var(--emerald); color: var(--emerald); }

/* Embedded mode inside home modal */
.is-embedded .site-header { display: none; }
.is-embedded .part-hero { padding-top: 16px; }
.is-embedded .part-hero::before { display: none; }
.is-embedded .part-hero-inner { grid-template-columns: 1fr; gap: 4px; padding-bottom: 12px; }
.is-embedded .part-num, .is-embedded .part-hero-thumb { display: none; }
.is-embedded .part-hero h1 { font-size: 25px; margin: 0; }
.is-embedded .part-hero .sub { margin: 0 0 6px; font-size: 12.5px; }
.is-embedded .part-hero .card-meta { display: none; }
.is-embedded .journey { padding-bottom: 12px; }
.is-embedded .reader { padding-top: 14px; }
.is-embedded .paper iframe { height: min(62vh, 720px); min-height: 380px; }
.is-embedded .site-footer, .is-embedded .chip-section { display: none; }
.is-embedded .reader-toolbar { padding: 9px 13px; }

/* ---------- HTML-native reader (PDF -> page image + OCR text) ----- */
.mode-switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); }
.mode-switch button {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink2);
  font-size: 12px; font-weight: 700; white-space: nowrap; transition: .25s;
}
.mode-switch button svg { width: 15px; height: 15px; }
.mode-switch button.active { background: var(--surface); color: var(--gold); box-shadow: var(--shadow-sm); }
.page-nav { display: flex; align-items: center; gap: 7px; }
.page-nav input {
  width: 66px; padding: 7px 6px; border-radius: 9px; text-align: center;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink);
  font-size: 13px; outline: none;
}
.page-nav input:focus { border-color: var(--gold); }
.page-counter { font-size: 12px; color: var(--muted); white-space: nowrap; }
.reader-tools { gap: 5px; }
.zoom-label { font-size: 11.5px; color: var(--muted); min-width: 38px; text-align: center; }
.paper { padding: 0; overflow: hidden; }
.ocr-note {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  border-inline-start: 4px solid var(--gold);
  font-size: 11.5px; color: var(--ink2); line-height: 1.7;
}
.ocr-note svg { width: 17px; height: 17px; color: var(--gold); flex-shrink: 0; }
.page-stage {
  height: min(70vh, 860px); min-height: 440px; overflow: auto;
  background: #E9E5DB; display: flex; align-items: flex-start; padding: 14px;
  justify-content: center; justify-content: safe center;
}
[data-theme="dark"] .page-stage { background: #17191C; }
.page-stage img {
  width: 100%; max-width: none; height: auto; flex-shrink: 0;
  background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.text-stage {
  height: min(70vh, 860px); min-height: 440px; overflow: auto;
  background: var(--surface); padding: 26px clamp(18px, 5vw, 70px);
}
.text-page-head { font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 20px; }
.ocr-text {
  font-family: var(--font-naskh); font-size: 21px; line-height: 2;
  color: var(--ink); direction: rtl; text-align: right; max-width: 760px; margin-inline: auto;
}
.ocr-text p { margin: 0 0 1.1em; }
.ocr-text .no-text { text-align: center; color: var(--muted); font-family: var(--font-ui); font-size: 14px; padding: 40px 0; }
.text-tools { display: flex; justify-content: center; margin-top: 26px; }
.page-strip { display: flex; gap: 6px; overflow-x: auto; padding: 12px 2px 4px; scrollbar-width: thin; }
.page-chip {
  flex: 0 0 38px; height: 34px; border-radius: 9px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink2); transition: .2s;
}
.page-chip:hover { border-color: var(--gold); color: var(--gold); }
.page-chip.active { background: linear-gradient(145deg, var(--gold2), var(--gold)); color: #241C0C; border-color: transparent; }
.text-search { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.text-search label { display: flex; align-items: center; gap: 10px; }
.text-search label svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }
.text-search input {
  flex: 1; padding: 9px 13px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); outline: none;
}
.text-search input:focus { border-color: var(--gold); }
.part-results, .tr-list { display: grid; gap: 8px; margin-top: 12px; }
.tresult {
  display: block; width: 100%; text-align: right; padding: 11px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--ink); transition: .2s;
}
.tresult:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tr-head { display: block; font-size: 12.5px; font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.tr-head small { color: var(--muted); font-weight: 400; }
.tr-snip { display: block; font-family: var(--font-naskh); font-size: 15px; line-height: 1.9; color: var(--ink2); }
.tr-snip mark { background: var(--gold2); color: #241C0C; border-radius: 3px; padding: 0 3px; }
.tr-none, .tr-count { margin: 4px 0; font-size: 12.5px; color: var(--muted); }
#textResults { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; margin: 0 0 22px; box-shadow: var(--shadow-sm); }
.tr-title { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 19px; margin-bottom: 6px; }
.tr-title svg { width: 19px; height: 19px; color: var(--gold); }
.is-embedded .page-stage, .is-embedded .text-stage { height: min(58vh, 640px); min-height: 340px; }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floaty { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-9px); } }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.reveal { animation: rise .7s both; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  .phases { grid-template-columns: repeat(2, 1fr); }
  .hero { gap: 26px; }
  .ring { width: 330px; height: 330px; }
  .ring.small { width: 280px; height: 280px; }
}
@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .hero-art { min-height: 350px; order: -1; overflow: clip; }
  .book-frame { width: min(230px, 62%); }
  .ring { width: 310px; height: 310px; }
  .ring.small { width: 260px; height: 260px; }
  .seal { width: 78px; height: 78px; }
  .seal b { font-size: 19px; }
  .topbar-in { flex-wrap: wrap; }
  .search-wrap { width: 100%; order: 3; }
  .top-actions { flex: 0; }
  .brand-text strong { font-size: 17px; }
  .theme-btn .tb-label { display: none; }
  .theme-btn { padding: 9px 12px; }
  .band { flex-direction: column; text-align: center; gap: 14px; }
  .part-hero-inner { grid-template-columns: auto 1fr; }
  .part-hero-thumb { display: none; }
  .part-num { font-size: 76px; }
  .paper { padding: 7px; }
  .paper iframe { min-height: 460px; }
}
@media (max-width: 520px) {
  .phases { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 12px; }
  .card-body h3 { font-size: 17px; }
  .card-foot { flex-direction: column; }
  .hero h1 { font-size: 40px; }
  .modal { padding: 0; }
  .modal-sheet { border-radius: 0; border: 0; }
  .modal-bar .mb-title small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   Static HTML text pages (text/*.html)
   ============================================================ */
.text-link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.text-link-card {
  display: flex; align-items: center; gap: 15px; padding: 20px 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-sm); transition: .3s;
}
.text-link-card:hover { transform: translateY(-5px); border-color: var(--gold); box-shadow: var(--shadow); }
.tlc-icon {
  width: 50px; height: 50px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; color: #241C0C;
  background: linear-gradient(145deg, var(--gold2), var(--gold));
}
.tlc-icon svg { width: 26px; height: 26px; }
.tlc-copy { flex: 1; min-width: 0; }
.tlc-copy b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 21px; line-height: 1.5; }
.tlc-copy small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.tlc-arrow { color: var(--gold); font-size: 22px; font-weight: 800; }
.text-main { padding: 46px 0 10px; }
.text-hero { padding: 0 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.text-hero .kicker { font-size: 11px; letter-spacing: 2px; color: var(--gold); font-weight: 800; }
.text-hero h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 4.6vw, 58px); line-height: 1.4; margin: 6px 0 4px; }
.text-hero .sub { color: var(--ink2); font-size: 15px; margin: 0 0 14px; max-width: 74ch; line-height: 2; }
.text-main > .ocr-note { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 16px; padding: 12px 16px; }
.text-filter {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 15px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.text-filter label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; }
.text-filter label svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }
.text-filter input {
  flex: 1; padding: 9px 13px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); outline: none;
}
.text-filter input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.filter-count { font-size: 12px; color: var(--gold); font-weight: 700; white-space: nowrap; }
.text-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 24px; align-items: start; }
.text-toc {
  position: sticky; top: 78px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 16px 14px;
  box-shadow: var(--shadow-sm); max-height: calc(100vh - 100px); overflow: auto;
}
.text-toc h3 { font-family: var(--font-display); font-weight: 400; font-size: 18px; margin: 0 0 12px; }
.toc-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.toc-list a {
  display: grid; place-items: center; height: 31px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--line2);
  color: var(--ink2); font-size: 11.5px; font-weight: 700; transition: .2s;
}
.toc-list a:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.toc-note { font-size: 10.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; }
.text-body { min-width: 0; }
.page-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px clamp(16px, 3vw, 30px) 22px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm); scroll-margin-top: 88px;
}
.pb-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line2); padding-bottom: 10px; margin-bottom: 16px;
}
.pb-num { font-weight: 800; font-size: 13px; color: var(--gold); }
.pb-abs { font-size: 11.5px; color: var(--muted); }
.pb-links { display: flex; gap: 8px; margin-inline-start: auto; }
.pb-links a { font-size: 11px; font-weight: 700; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; transition: .2s; }
.pb-links a:hover { color: var(--gold); border-color: var(--gold); }
.pb-text { font-family: var(--font-naskh); font-size: 20px; line-height: 2.05; color: var(--ink); text-align: right; }
.pb-text p { margin: 0 0 .85em; }
.pb-text .no-text { font-family: var(--font-ui); font-size: 13px; color: var(--muted); text-align: center; padding: 18px 0; }
.text-partnav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; flex-wrap: wrap; }
.text-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 8px; }
.text-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow-sm); transition: .3s;
}
.text-card:hover { transform: translateY(-5px); border-color: var(--gold); box-shadow: var(--shadow); }
.tc-head { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.tc-num {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold2), var(--gold)); color: #241C0C;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.text-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 21px; margin: 0; }
.text-card h2 a:hover { color: var(--gold); }
.tc-range { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.tc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tc-actions .btn { flex: 1; padding: 8px 9px; font-size: 11.5px; }
.all-toc { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.all-toc h3 { font-family: var(--font-display); font-weight: 400; font-size: 19px; margin: 0 0 10px; }
.all-toc-list { display: flex; flex-wrap: wrap; gap: 7px; }
.all-toc-list a { font-size: 11.5px; font-weight: 700; color: var(--ink2); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; transition: .2s; }
.all-toc-list a:hover { color: var(--gold); border-color: var(--gold); }
.all-part-title {
  font-family: var(--font-display); font-weight: 400; font-size: 30px;
  color: var(--gold); border-bottom: 2px solid var(--line); padding-bottom: 10px;
  margin: 34px 0 18px; scroll-margin-top: 88px;
}
.all-part-title small { font-family: var(--font-ui); font-size: 12px; color: var(--muted); font-weight: 400; }
@media (max-width: 820px) {
  .text-layout { grid-template-columns: 1fr; }
  .text-toc { position: static; max-height: 170px; }
  .toc-list { grid-template-columns: repeat(8, 1fr); }
  .pb-text { font-size: 18px; }
}
@media (max-width: 520px) {
  .toc-list { grid-template-columns: repeat(6, 1fr); }
  .pb-links { margin-inline-start: 0; width: 100%; }
}
