:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #d8d2c4;
  --bg: #faf8f3;
  --panel: #ffffff;
  --accent: #0d5c63;
  --accent-soft: #e4efee;
  --sidebar-w: 380px;
  --header-h: 64px;

  /* Reading-area preferences (changed live by the "Aa" panel, saved to
     localStorage). Scoped to .content only, on purpose - the sidebar/tree
     stay compact and legible no matter what a reader picks for body text. */
  --reading-size: 19px;
  --reading-font: "Frank Ruhl Libre", "David Libre", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Frank Ruhl Libre", "David Libre", Georgia, "Times New Roman", serif;
  direction: rtl;
}

/* ---------- Header ---------- */
.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header h1 {
  font-size: 1.3em;
  margin: 0;
  white-space: nowrap;
}
.nav-toggle {
  display: none;
  font-size: 1.4em;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--ink);
}
.search-box {
  position: relative;
  flex: 0 1 380px;
  display: flex;
  align-items: center;
  max-width: 380px;
  margin-inline-start: 18px;
}
.content-search-box {
  position: relative;
  flex: 0 1 300px;
  display: flex;
  align-items: center;
  max-width: 300px;
  margin-inline-start: auto;
}

/* On/off switch used twice: globally in the header ("remember last article")
   and inside each article's header ("remember my place in this article"). */
.remember-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .78em;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.remember-switch:hover { border-color: var(--accent); }
.remember-switch.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: #c9c3b5;
  transition: background .18s;
}
.switch-knob {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: inset-inline-start .18s;
}
.remember-switch.on .switch-track { background: var(--accent); }
.remember-switch.on .switch-knob { inset-inline-start: 16px; }

/* Header copy sits in the gap between the two search boxes - the
   content-search box's own margin-inline-start:auto still pushes it to the
   far side. Two short lines rather than one very long one. */
.remember-global {
  margin-inline-start: 14px;
  max-width: 240px;
}

.article-remember { margin-top: 12px; }

.search-icon {
  position: absolute;
  inset-inline-start: 12px;
  font-size: 1.1em;
  color: var(--muted);
  pointer-events: none;
  transition: color .15s;
}
.search-box:focus-within .search-icon,
.content-search-box:focus-within .search-icon {
  color: var(--accent);
}

.search-box input,
.content-search-box input {
  flex: 1;
  width: 100%;
  /* Logical sides: the icon sits at inline-start (right in RTL), so that's
     where the room for it goes - physical "left" padding put it under the text. */
  padding-block: 10px;
  padding-inline-start: 38px;
  padding-inline-end: 16px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  font-family: inherit;
  font-size: .95em;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search-box input:focus,
.content-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-count {
  position: absolute;
  inset-inline-end: 14px;
  font-size: .78em;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Content (full-text) search ---------- */
.content-search-results {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  min-width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
  z-index: 45;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.content-search-results.hidden { display: none; }

/* The full-text panel opens from the box toward the middle of the screen
   (the box sits at the far end of the header), so it never spills off-screen. */
.csr-panel {
  inset-inline-start: auto;
  inset-inline-end: 0;
  width: min(600px, calc(100vw - 24px));
  min-width: 0;
  max-height: min(76vh, 720px);
}

.csr-controls {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  padding: 12px 12px 8px;
  border-radius: 10px 10px 0 0;
}

/* Segmented control: one track, three equal segments. */
.csr-mode-bar {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.csr-mode-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .8em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s, color .15s, box-shadow .15s;
}
.csr-mode-btn:hover { color: var(--ink); }
.csr-mode-btn.active {
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.csr-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.csr-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  font-size: .8em;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.csr-check:hover { border-color: var(--accent); }
.csr-check input { margin: 0; accent-color: var(--accent); }
.csr-check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.csr-select {
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .8em;
  max-width: 100%;
  cursor: pointer;
}
.csr-select:focus { outline: none; border-color: var(--accent); }
.csr-select.hidden { display: none; }

.csr-hint {
  margin-top: 8px;
  font-size: .72em;
  color: var(--muted);
}

.csr-summary {
  padding: 8px 16px;
  font-size: .8em;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.csr-summary:empty { display: none; }
.csr-summary b { color: var(--ink); }
.csr-summary-mode {
  margin-inline-start: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .92em;
}

/* Per-collection chips under the summary. */
.csr-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.csr-facets.hidden { display: none; }
.csr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .78em;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.csr-chip:hover { border-color: var(--accent); }
.csr-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; cursor: default; }
.csr-chip-n { color: var(--muted); font-size: .9em; }
.csr-chip.active .csr-chip-n { color: var(--accent); }

.csr-item-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.csr-item-head .csr-item-title { flex: 1; min-width: 0; margin: 0; }
.csr-item-occ {
  flex-shrink: 0;
  font-size: .72em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 1px 8px;
  font-weight: 600;
}

.csr-more {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px 12px;
  padding: 9px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: .85em;
  cursor: pointer;
}
.csr-more:hover { background: var(--accent-soft); }
.csr-more.hidden { display: none; }

/* ---------- In-article search hits ---------- */
mark.hit {
  background: #fff3b0;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
mark.hit.current {
  background: #ffb74d;
  box-shadow: 0 0 0 2px #ffb74d;
}

.hit-nav {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .85em;
}
.hit-nav.hidden { display: none; }
.hit-nav-label { padding: 0 8px; white-space: nowrap; }
.hit-nav-btn {
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  font-size: .85em;
}
.hit-nav-btn:hover { background: rgba(255,255,255,.25); }

.csr-status {
  padding: 14px 16px;
  color: var(--muted);
  font-size: .85em;
}

.csr-item {
  display: block;
  padding: 11px 16px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: background .12s;
}
.csr-item:last-child { border-bottom: none; }
.csr-item:hover { background: var(--accent-soft); }
.csr-item-title { font-weight: 600; font-size: .92em; margin-bottom: 3px; }
.csr-item-path { font-size: .75em; color: var(--muted); margin-bottom: 4px; }
.csr-item-snippet { font-size: .82em; color: var(--ink); line-height: 1.6; }
.csr-item-snippet mark {
  background: #fff3b0;
  color: inherit;
  padding: 1px 2px;
  border-radius: 3px;
  font-weight: 600;
}

/* ---------- Text display settings ---------- */
.text-settings { position: relative; }
.text-settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: 20px;
  background: #1d63d8;
  color: #fff;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .88em;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(29, 99, 216, .35);
  transition: background .15s, box-shadow .15s;
}
.text-settings-toggle:hover,
.text-settings-toggle[aria-expanded="true"] { background: #1552b8; box-shadow: 0 2px 10px rgba(29, 99, 216, .5); }
.text-settings-toggle:focus-visible { outline: 3px solid #9cc0f5; outline-offset: 2px; }
.ts-icon { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }

.text-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 14px 16px;
  z-index: 40;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.text-settings-panel.hidden { display: none; }

.ts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.ts-row-col { flex-direction: column; align-items: stretch; gap: 6px; }
.ts-label { font-size: .85em; color: var(--muted); }

.ts-size-controls { display: flex; align-items: center; gap: 8px; }

.ts-align-controls { display: flex; align-items: center; gap: 6px; }
.ts-align-btn {
  width: 34px; height: 30px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-size: 1em;
  color: var(--ink);
  line-height: 1;
}
.ts-align-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.ts-align-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ts-size-controls button {
  width: 32px; height: 32px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-size: .85em;
}
.ts-size-controls button:hover { background: var(--accent-soft); border-color: var(--accent); }
#fontSizeLabel { font-size: .8em; color: var(--muted); min-width: 3.2em; text-align: center; }

#fontSelect {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  font-size: .85em;
  font-family: inherit;
}

.ts-reset {
  width: 100%;
  padding: 7px 10px;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: .8em;
  cursor: pointer;
}
.ts-reset:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-left: 1px solid var(--rule);
  background: var(--panel);
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 10px 40px;
}

/* Drag handle to resize the sidebar (deep trees / long titles need more
   room than any one fixed width gives everyone) - width saved per browser. */
.sidebar-resizer {
  flex-shrink: 0;
  width: 6px;
  margin-inline-start: -3px;
  cursor: col-resize;
  position: relative;
  z-index: 15;
  touch-action: none;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  inset-inline-start: 2px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: background .15s;
}
.sidebar-resizer:hover::after,
.sidebar-resizer.dragging::after { background: var(--accent); }
body.sidebar-dragging { cursor: col-resize; user-select: none; }

.nav-scrim { display: none; }

.content {
  flex: 1;
  min-width: 0;
  padding: 30px 40px 100px;
}

/* ---------- Tree ---------- */
.tree {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.tree-loading { color: var(--muted); font-size: .9em; padding: 10px; }

.tree ul {
  list-style: none;
  margin: 0;
  padding-inline-start: 18px;
  border-inline-start: 1px solid var(--rule);
  margin-inline-start: 11px;
}
.tree > ul { padding-inline-start: 0; border-inline-start: none; margin-inline-start: 0; }

.tree li { margin: 2px 0; }

.branch-row, .leaf-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: .93em;
  line-height: 1.35;
  transition: background-color .12s;
}
.branch-row:hover, .leaf-row:hover { background: var(--accent-soft); }
.leaf-row.active {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 3px 0 0 0 rgba(0,0,0,.15);
  font-weight: 500;
}
.leaf-row.active .count { background: rgba(255,255,255,.22); color: #fff; }

/* Top-level categories read as section headers; deeper levels taper down
   in weight/size so the eye can tell "where am I" at a glance. */
.tree > ul > li > .branch-row,
.tree > ul > li > .leaf-row {
  font-weight: 600;
  font-size: .97em;
}

/* Expand/collapse marker: a small boxed "+" that turns into "−" when open,
   so it's obvious at a glance which rows hold more items. */
.twisty {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  color: var(--accent);
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
}
.branch-row .twisty::before { content: "+"; }
.branch.open > .branch-row .twisty::before { content: "−"; }
.branch-row:hover .twisty { border-color: var(--accent); }
.branch.open > .branch-row .twisty { background: var(--accent); border-color: var(--accent); color: #fff; }
.leaf-row .twisty { visibility: hidden; border: 0; background: none; }

/* Category whose items are standalone articles (Rabash): the "+" is a real
   button that only expands; clicking the name opens the merged page. */
.parts-row .parts-toggle {
  visibility: visible;
  padding: 0;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: var(--panel);
}
.parts-row .parts-toggle::before { content: "+"; }
.has-parts.open > .parts-row .parts-toggle::before { content: "−"; }
.has-parts.open > .parts-row .parts-toggle { background: var(--accent); border-color: var(--accent); color: #fff; }
.parts-row .parts-toggle:hover { border-color: var(--accent); }
.leaf-row.active .parts-toggle { border-color: rgba(255,255,255,.6); }
.part-leaf .leaf-row { font-size: .88em; padding-block: 5px; }
.count-branch { opacity: .8; }

.label { flex: 1; min-width: 0; }

.count {
  margin-inline-start: auto;
  font-size: .74em;
  color: var(--muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 8px;
  flex-shrink: 0;
}

.branch > .tree-children { display: none; }
.branch.open > .tree-children {
  display: block;
  animation: treeExpand .15s ease-out;
}
@keyframes treeExpand {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.tree.filtering .branch,
.tree.filtering .leaf {
  display: none;
}
.tree.filtering .match,
.tree.filtering .match-ancestor {
  display: list-item;
}
.tree.filtering .branch.match-ancestor > .tree-children {
  display: block;
}

/* ---------- PDF viewer (paged presentation) ---------- */
.pdf-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 1000px;
  margin: 0 auto;
  outline: none;
}
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  width: 100%;
}
.pdf-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-size: 1em;
  color: var(--ink);
}
.pdf-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.pdf-btn:disabled { opacity: .4; cursor: default; }
.pdf-btn-wide { width: auto; font-size: .85em; }
.pdf-toolbar-sep { width: 1px; height: 24px; background: var(--rule); margin: 0 4px; }

.pdf-page-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88em;
  color: var(--muted);
  white-space: nowrap;
}
.pdf-page-input {
  width: 3.2em;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  text-align: center;
  font-family: inherit;
}

.pdf-book-title {
  font-weight: 600;
  font-size: .95em;
  margin-inline-end: auto;
}
.pdf-btn[href] {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}

.pdf-native-wrap {
  width: 100%;
  flex: 1;
  min-height: 70vh;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  overflow: hidden;
}
.pdf-native-frame { width: 100%; height: 100%; min-height: 70vh; border: 0; display: block; }

.pdf-view:fullscreen {
  background: #222;
  padding: 16px;
}
.pdf-view:fullscreen .pdf-native-wrap { flex: 1; min-height: 0; }
.pdf-view:fullscreen .pdf-native-frame { min-height: 0; }

@media (max-width: 860px) {
  .pdf-native-wrap, .pdf-native-frame { min-height: 60vh; }
  .pdf-book-title { width: 100%; margin-inline-end: 0; }
}

/* ---------- Welcome ---------- */
.welcome {
  max-width: 640px;
  margin: 60px auto 0;
  text-align: center;
  color: var(--muted);
}
.welcome h2 { color: var(--ink); font-size: 1.6em; }
.welcome-stats { font-size: .85em; margin-top: 24px; }

/* ---------- Article ---------- */
.article-wrap { max-width: 820px; margin: 0 auto; }

.article-header {
  padding-bottom: 18px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 10px;
}
.article-header h2 { font-size: 1.9em; margin: 0 0 8px; }
.article-crumb { color: var(--muted); font-size: .82em; }

.article-toc {
  margin: 22px 0 36px;
  padding: 16px 20px 18px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.article-toc h3 {
  margin: 0 0 12px;
  font-size: .85em;
  color: var(--accent);
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.article-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 22px;
  counter-reset: toc;
}
.article-toc li {
  counter-increment: toc;
  break-inside: avoid;
  margin-bottom: 2px;
}
.article-toc li.toc-extra { display: none; }
.article-toc.toc-expanded li.toc-extra { display: list-item; }

.article-toc a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: .88em;
  padding: 4px 8px;
  border-radius: 5px;
  line-height: 1.4;
}
.article-toc a::before {
  content: counter(toc) ".";
  color: var(--muted);
  font-size: .85em;
  flex-shrink: 0;
  min-width: 1.3em;
}
.article-toc a:hover { background: var(--accent-soft); color: var(--accent); }

.toc-expand-btn {
  border: 1px dashed var(--rule);
  background: none;
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: .82em;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
}
.toc-expand-btn:hover { color: var(--accent); border-color: var(--accent); }

.content, .welcome {
  font-size: var(--reading-size);
  font-family: var(--reading-font);
}

.section {
  line-height: 1.9;
  margin: 0 0 46px;
  padding-top: 14px;
}
.section + .section { border-top: 1px solid var(--rule); }
.section h2.sec { font-size: 1.4em; color: var(--accent); margin: 18px 0 14px; }
.section h3 { font-size: 1em; color: var(--muted); margin: 14px 0 6px; }
/* Justify on the whole section, not just <p>: the Zohar text arrives as
   loose text + <span>s directly inside the section (no paragraphs), so a
   p-only rule justified just the commentary and left the Zohar ragged. */
.section { text-align: justify; }
.section h2.sec, .section h3 { text-align: start; }
.section p { margin: 0 0 1.05em; text-align: justify; }
/* Paragraph gap for texts whose source used <br> between paragraphs
   (build_site.py turns each run of <br> into one of these). */
.section .pgap { display: block; height: .75em; }
/* Articles imported from rabash-writings carry a dated epigraph line and a
   per-article rights line. */
.section .rabash-epigraph { color: var(--muted); font-size: .85em; margin-bottom: 1.2em; }
.section .rabash-copyright { color: var(--muted); font-size: .78em; text-align: center; margin-top: 1.6em; }
.content.no-justify .section,
.content.no-justify .section p { text-align: start; }

.section a.fnref {
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
  font-size: .75em;
  vertical-align: super;
}
.section a.fnref:hover { text-decoration: underline; }
.section .footnotes {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}
.section .footnotes p { font-size: .82em; color: var(--muted); margin-bottom: .6em; }
.section .footnotes a { color: var(--accent); text-decoration: none; font-weight: bold; }

.back-to-top {
  font-size: .75em;
  color: var(--muted);
  text-decoration: none;
}
.back-to-top:hover { color: var(--accent); }

/* Single standalone article (#a{id}s{i}) */
.part-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .8em;
}
.part-pos {
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.part-all { color: var(--accent); text-decoration: none; }
.part-all:hover { text-decoration: underline; }

.part-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.part-pager a {
  flex: 1 1 0;
  max-width: 48%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.part-pager a:hover { border-color: var(--accent); background: var(--accent-soft); }
.part-next { text-align: end; }
.pager-dir { font-size: .75em; color: var(--accent); font-weight: 600; }
.pager-title { font-size: .9em; }

.article-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid var(--accent);
  text-align: center;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .88em;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.share-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.share-btn.share-ok { border-color: #2e7d32; background: #eaf6ea; color: #2e7d32; }
.share-icon { font-size: 1em; line-height: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .site-header {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-h);
    padding: 10px 16px;
    row-gap: 8px;
    transition: transform .2s ease;
  }
  /* Slides away while reading down, returns on scroll up (app.js). */
  .site-header.hdr-away { transform: translateY(-100%); }
  .site-header h1 { font-size: 1.05em; order: 2; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; order: 1; }
  .text-settings { order: 3; margin-inline-start: auto; }
  .remember-global { order: 4; max-width: none; margin-inline-start: 0; }

  .search-box {
    order: 5;
    flex: 1 1 100%;
    max-width: none;
    margin-inline-start: 0;
  }
  .content-search-box {
    order: 6;
    flex: 1 1 100%;
    max-width: none;
    margin-inline-start: 0;
  }
  .content-search-results,
  #sectionSearchResults {
    min-width: 0;
    width: 100%;
  }
  .csr-panel { inset-inline-start: 0; inset-inline-end: 0; width: auto; }
  .csr-hint { font-size: .75em; }
  /* Touch: one swipeable row of chips, bigger tap targets. */
  .csr-facets { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .csr-facets::-webkit-scrollbar { display: none; }
  .csr-chip { padding: 7px 12px; font-size: .85em; }
  .csr-mode-btn { padding: 9px 6px; font-size: .85em; }
  .csr-check, .csr-select { padding: 7px 12px; font-size: .85em; }
  .hit-nav-btn { width: 40px; height: 40px; }

  .sidebar {
    /* phone drawer fit */
    width: min(var(--sidebar-w), 94vw);
    max-width: 100vw;
    overflow-x: hidden;
    position: fixed;
    /* Physical "right", not inset-inline-end: in RTL that resolves to the LEFT
       edge, and translateX(100%) then slid the drawer back onto the screen. */
    right: 0;
    left: auto;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    /* Never wider than the phone: the article counts sit at the far edge. */
    width: min(var(--sidebar-w), 88vw);
    transform: translateX(100%);
    transition: transform .2s ease;
    z-index: 30;
    box-shadow: -4px 0 18px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }

  .nav-scrim.show {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0,0,0,.25);
    z-index: 25;
  }

  .content { padding: 20px 16px 80px; }
  .article-toc ol { columns: 1; }

  .tree ul { padding-inline-start: 12px; margin-inline-start: 7px; }
  .branch-row, .leaf-row { padding: 8px; font-size: .92em; }
  .sidebar-resizer { display: none; }
}

/* Export buttons (export.js) */
.article-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.export-btn[disabled] { opacity: .5; cursor: wait; }
.export-toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: #fff; font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .85em; text-align: center; z-index: 60; transition: opacity .2s, transform .2s;
}
.export-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  @page { margin: 16mm 14mm; }
  html, body { direction: rtl; background: #fff !important; }
  .site-header, .sidebar, .sidebar-resizer, .nav-scrim, .article-toc, .back-to-top, .hit-nav,
  .article-footer, .part-pager, .part-meta, .content-search-results, .export-toast,
  .ohr-login-overlay { display: none !important; }
  .layout, .main, .content { display: block !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; }
  .article-wrap { max-width: none; }
  mark.hit { background: none !important; box-shadow: none !important; color: inherit; }
  h2, h3, .sec { break-after: avoid; }
  p { orphans: 3; widows: 3; }
}

/* ---- WordPress plugin: reader login overlay ---- */
.ohr-login-overlay{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(10,14,24,.82);backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);padding:16px}
.ohr-login-box{background:#fff;color:#1d2433;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.4);padding:28px 26px;width:100%;max-width:360px;direction:rtl;font-family:inherit}
.ohr-login-box h2{margin:0 0 6px;font-size:1.35rem}
.ohr-login-box p{margin:0 0 16px;color:#5b6475;font-size:.95rem}
.ohr-login-box label{display:block;margin:10px 0 4px;font-weight:600;font-size:.9rem}
.ohr-login-box input{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid #c9d0dc;border-radius:8px;font-size:1rem}
.ohr-login-box button{margin-top:18px;width:100%;padding:11px;border:0;border-radius:8px;background:#2563eb;color:#fff;font-size:1rem;font-weight:600;cursor:pointer}
.ohr-login-box button:disabled{opacity:.6;cursor:default}
.ohr-login-err{color:#b91c1c;min-height:1.2em;margin-top:10px;font-size:.9rem}
.ohr-logout{margin-top:8px;width:100%}
body.ohr-embed .site-header{display:none}

/* ---- WordPress plugin: teaser excerpt when locked with indexing enabled ---- */
.ohr-teaser-gate{margin-top:1.2em;padding:12px 16px;background:#f3f4f8;border-inline-start:3px solid #2563eb;border-radius:6px;color:#3b4256;font-size:.95em}

/* ---------- Search log ---------- */
.slog-btn {
  flex: none;
  width: 38px;
  height: 38px;
  margin-inline-start: 6px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.05em;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.slog-btn:hover, .slog-btn:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.slog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 20, 20, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 16px 16px;
}
.slog-overlay.hidden { display: none; }
.slog-dialog {
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}
.slog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; font-size: 1.1em; }
.slog-close { border: none; background: none; font-size: 1.1em; cursor: pointer; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; }
.slog-close:hover { background: var(--accent-soft); color: var(--ink); }
.slog-note { padding: 0 18px 10px; font-size: .8em; color: var(--muted); border-bottom: 1px solid var(--rule); }
.slog-body { overflow-y: auto; padding: 4px 18px 12px; }
.slog-empty { padding: 30px 0; text-align: center; color: var(--muted); }
.slog-day { margin: 14px 0 4px; font-size: .78em; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.slog-entry { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.slog-entry:last-child { border-bottom: none; }
.slog-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.slog-time { font-size: .78em; color: var(--muted); font-variant-numeric: tabular-nums; }
.slog-kind { font-size: .72em; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.slog-q { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.slog-q:hover { color: var(--accent); text-decoration: underline; }
.slog-hits { font-size: .78em; color: var(--muted); }
.slog-del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: .8em; padding: 2px 6px; border-radius: 6px; }
.slog-del:hover { background: #f6e3e3; color: #a00; }
.slog-opened { list-style: none; margin: 6px 0 0; padding: 0 16px 0 0; border-inline-start: 2px solid var(--accent-soft); }
.slog-opened li { display: flex; gap: 10px; align-items: baseline; padding: 2px 10px; }
.slog-opened a { color: var(--accent); text-decoration: none; font-size: .92em; }
.slog-opened a:hover { text-decoration: underline; }
.slog-foot { padding: 10px 18px; border-top: 1px solid var(--rule); text-align: start; }
.slog-clear { border: 1px solid var(--rule); background: var(--bg); border-radius: 16px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: .85em; color: var(--ink); }
.slog-clear:hover { border-color: #a00; color: #a00; }

/* find inside the article */
.hit-nav-input {
  width: 0; padding: 0; border: 0; opacity: 0; pointer-events: none;
  background: #fff; color: var(--ink); border-radius: 16px; font: inherit; height: 32px;
}
.hit-nav.finding .hit-nav-input { width: min(46vw, 220px); padding: 0 12px; opacity: 1; pointer-events: auto; margin-inline-end: 4px; }
.find-btn {
  margin-top: 10px; border: 1px solid rgba(0,0,0,.15); background: rgba(0,0,0,.04); color: inherit;
  padding: 6px 12px; border-radius: 16px; cursor: pointer; font: inherit; font-size: .85em;
}
.find-btn:hover { background: rgba(0,0,0,.08); }

/* recent places */
.recent-toggle { background: #6b7b93; box-shadow: 0 2px 6px rgba(60, 75, 100, .3); }
.recent-toggle:hover, .recent-toggle[aria-expanded="true"] { background: #566579; }
.recent-panel { width: 300px; max-height: 60vh; overflow-y: auto; padding: 6px; }
.recent-item { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: inherit; }
.recent-item:hover { background: rgba(29, 99, 216, .08); }
.recent-title { display: block; font-weight: 600; font-size: .92em; }
.recent-path { display: block; font-size: .78em; opacity: .65; margin-top: 2px; }
.recent-empty { margin: 10px; font-size: .9em; opacity: .7; }
.recent-clear { width: 100%; margin-top: 4px; padding: 8px; border: 0; background: transparent; color: #b3261e; cursor: pointer; font: inherit; font-size: .85em; }


/* ---------- full results page ---------- */
.rp-lock { overflow: hidden; }
.rp-page { position: fixed; inset: 0; z-index: 300; background: var(--bg); color: var(--ink); display: flex; flex-direction: column;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif; }
.rp-page.hidden { display: none; }
.rp-top { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel); border-bottom: 2px solid var(--accent); flex-wrap: wrap; }
.rp-x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0,0,0,.06); cursor: pointer; font-size: 1rem; color: var(--ink); }
.rp-x:hover { background: rgba(0,0,0,.12); }
.rp-qform { flex: 1 1 320px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--rule); border-radius: 26px; padding: 4px 6px 4px 14px; max-width: 640px; }
.rp-qform:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rp-qicon { opacity: .55; font-size: 1.2rem; }
.rp-qform input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 1.05rem; background: transparent; padding: 8px 4px; min-width: 0; }
.rp-go { border: 0; background: var(--accent); color: #fff; border-radius: 20px; padding: 8px 18px; font: inherit; cursor: pointer; }
.rp-tabs { display: flex; gap: 4px; background: rgba(0,0,0,.05); border-radius: 22px; padding: 3px; }
.rp-tab { border: 0; background: transparent; padding: 8px 16px; border-radius: 19px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.rp-tab.on { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(13,92,99,.35); }
.rp-tabn { font-weight: 400; opacity: .85; margin-inline-start: 4px; }

.rp-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; gap: 0; }
.rp-side { overflow-y: auto; padding: 18px 16px 40px; border-inline-end: 1px solid var(--rule); background: #fdfcf8; }
.rp-side-head { font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.rp-clear { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; text-decoration: underline; }
.rp-lab { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.rp-lab input, .rp-lab select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 8px; font: inherit; font-size: .95rem; background: #fff; color: var(--ink); }
.rp-lab input:focus, .rp-lab select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.rp-row { display: flex; gap: 8px; }
.rp-half { flex: 1; }
.rp-facet { margin: 14px 0; }
.rp-facet-t { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; letter-spacing: .03em; }
.rp-chips { display: flex; flex-direction: column; gap: 5px; }
.rp-chip { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: right; border: 1px solid var(--rule); background: #fff; border-radius: 10px; padding: 7px 10px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--ink); }
.rp-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-chip b { font-weight: 600; font-size: .75rem; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; }
.rp-chip:hover { border-color: var(--accent); }
.rp-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.rp-chip.on b { background: rgba(255,255,255,.22); color: #fff; }
.rp-morebooks { margin-top: 6px; border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; text-decoration: underline; }
.rp-morebooks.hidden { display: none; }
.rp-check { display: flex; gap: 8px; align-items: center; font-size: .88rem; margin: 10px 0; cursor: pointer; }
.rp-hint { margin-top: 14px; font-size: .74rem; color: var(--muted); line-height: 1.9; }
.rp-hint kbd { background: #fff; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: inherit; }

.rp-main { overflow-y: auto; padding: 16px 22px 60px; scroll-behavior: smooth; }
.rp-summary { font-size: .95rem; margin-bottom: 8px; }
.rp-summary b { color: var(--accent); }
.rp-active { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rp-achip { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 16px; padding: 4px 12px; font: inherit; font-size: .82rem; cursor: pointer; }
.rp-achip:hover { background: #cfe3e1; }
.rp-progress { height: 3px; background: rgba(0,0,0,.06); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.rp-progress.hidden { display: none; }
.rp-progress span { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 3px; animation: rpslide 1.1s infinite ease-in-out; }
@keyframes rpslide { 0% { transform: translateX(120%); } 100% { transform: translateX(-320%); } }

.rp-list { display: flex; flex-direction: column; gap: 10px; outline: none; }
.rp-card { display: flex; gap: 12px; text-decoration: none; color: inherit; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px; transition: transform .12s, box-shadow .12s, border-color .12s; }
.rp-card:hover, .rp-card.cur { border-color: var(--accent); box-shadow: 0 6px 20px rgba(13,92,99,.13); transform: translateY(-1px); }
.rp-card.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.rp-n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 700; margin-top: 2px; }
.rp-cbody { flex: 1; min-width: 0; }
.rp-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rp-title { font-weight: 700; font-size: 1.05rem; line-height: 1.45; }
.rp-title mark, .rp-snip mark { background: #ffe58a; color: inherit; border-radius: 3px; padding: 0 2px; }
.rp-occ { flex: none; background: var(--accent); color: #fff; border-radius: 12px; padding: 1px 9px; font-size: .78rem; font-weight: 600; }
.rp-path { margin-top: 3px; font-size: .78rem; color: var(--muted); line-height: 1.7; }
.rp-seg { color: var(--muted); text-decoration: none; border-radius: 4px; padding: 0 2px; }
.rp-seg:hover { background: var(--accent-soft); color: var(--accent); }
.rp-sep { margin: 0 3px; opacity: .5; }
.rp-snip { margin-top: 8px; font-size: .92rem; line-height: 1.75; color: #2b2b2b; font-family: "Frank Ruhl Libre", "David Libre", Georgia, serif; }
.rp-list.compact .rp-snip { display: none; }
.rp-list.compact .rp-card { padding: 7px 12px; border-radius: 10px; }
.rp-list.compact { gap: 5px; }
.rp-empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.rp-foot { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.rp-loadmore { border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 22px; padding: 9px 22px; font: inherit; cursor: pointer; }
.rp-loadmore:hover { background: var(--accent-soft); }
.rp-loadmore.hidden { display: none; }
.rp-filter-toggle { display: none; }
.csr-more.rp-open { margin-top: 6px; background: var(--accent); color: #fff; border-color: var(--accent); }
.csr-more.rp-open:hover { background: #0a4a50; }
.csr-more.rp-open.hidden { display: none; }
.rp-open-titles { width: calc(100% - 16px); margin: 8px; display: block; }

.rp-pill { position: fixed; z-index: 250; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 16px; display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 26px; padding: 10px 14px 10px 8px; font: inherit; font-size: .9rem; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.28); font-family: -apple-system, "Segoe UI", Arial, sans-serif; }
.rp-pill-back { background: rgba(255,255,255,.2); border-radius: 50%; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; }
.rp-pill-x { margin-inline-start: 4px; opacity: .75; padding: 0 4px; }
.rp-pill-x:hover { opacity: 1; }

@media (max-width: 800px) {
  .rp-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rp-filter-toggle { display: block; margin: 8px 14px 0; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 20px; padding: 8px 16px; font: inherit; }
  .rp-side { display: none; position: absolute; z-index: 5; top: 48px; right: 0; left: 0; bottom: 0; }
  .rp-side.open { display: block; }
  .rp-body { position: relative; }
  .rp-top { padding: 8px 10px; gap: 8px; }
  .rp-tabs { width: 100%; }
  .rp-tab { flex: 1; }
  .rp-main { padding: 12px 12px 60px; }
  .rp-title { font-size: 1rem; }
}

/* Locked + no public teaser: near-black page, only a quiet login form (no title, no welcome text). */
body.ohr-dark{background:#000}
body.ohr-dark>*:not(#ohrLogin):not(script){display:none!important}
body.ohr-dark .ohr-login-overlay{background:#000;-webkit-backdrop-filter:none;backdrop-filter:none}
body.ohr-dark .ohr-login-box{background:transparent;box-shadow:none;color:#6b7080;max-width:260px}
body.ohr-dark .ohr-login-box label{font-weight:400;font-size:.8rem;color:#555a66}
body.ohr-dark .ohr-login-box input{background:#050505;border:1px solid #1c1c1c;color:#b5b9c4}
body.ohr-dark .ohr-login-box input:focus{outline:none;border-color:#3a3f4d}
body.ohr-dark .ohr-login-box button{background:#0b0b0b;border:1px solid #1c1c1c;color:#777c88}
body.ohr-dark .ohr-login-box button:hover{border-color:#3a3f4d;color:#aab}
body.ohr-dark .ohr-login-err{color:#7a4a4a}


/* ---------- reading tools: remember my place / copy text / hide the contents menu ---------- */
.article-wrap, .article-wrap * { -webkit-user-select: text; user-select: text; }
.read-tools { position: fixed; z-index: 40; display: flex; gap: 8px; font-family: -apple-system, "Segoe UI", Arial, sans-serif; }
.read-tools.hidden { display: none; }
.read-tools button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; }
.read-tools button:hover { border-color: var(--accent); }
.read-tools button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.read-tools .rt-ic { font-size: 1.15rem; line-height: 1; }
.read-tools.rt-float { left: 12px; top: 50%; transform: translateY(-50%); flex-direction: column; opacity: .9; }
.read-tools.rt-float button { width: 44px; height: 44px; border-radius: 50%; padding: 0; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.read-tools.rt-float .rt-lb { display: none; }
.read-tools.rt-bar { top: var(--rt-top, var(--header-h)); left: 0; right: 0; justify-content: center; flex-wrap: nowrap; padding: 4px 8px; gap: 6px; background: var(--panel); border-bottom: 1px solid var(--rule); z-index: 19; }
.read-tools.rt-bar button { border-radius: 18px; padding: 6px 14px; font-size: .9rem; }
body.rt-bar-on #content { padding-top: 46px; }
body.sidebar-hidden .sidebar, body.sidebar-hidden .sidebar-resizer { display: none; }
.rt-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #1f2a30; color: #fff; padding: 9px 18px; border-radius: 22px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }
.rt-toast.hidden { display: none; }
@media (max-width: 860px) {
  .read-tools.rt-float { top: auto; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: none; opacity: .85; }
  .read-tools.rt-float button { width: 40px; height: 40px; }
}
@media print { .read-tools, .rt-toast { display: none !important; } body.rt-bar-on #content { padding-top: 0; } }

/* ---- AI summaries for the Zohar (zsum) ---- */
.zsum{margin:18px 0 10px;border:1px solid #d9c27a;border-radius:14px;background:#fffaf0;color:#2b2416;font-size:.92em;line-height:1.7;overflow:hidden;box-shadow:0 2px 10px rgba(120,90,20,.08)}
.zsum-h{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;padding:10px 14px;background:linear-gradient(135deg,#7a4a12,#b3741d);color:#fff}
.zsum-h b{font-size:1.02em}.zsum-h small{opacity:.88;font-size:.8em;flex:1 1 auto}
.zsum-ic{font-size:1.1em;color:#ffe08a}
.zsum-fold{margin-inline-start:auto;border:1px solid rgba(255,255,255,.5);background:rgba(255,255,255,.15);color:#fff;border-radius:8px;width:30px;height:28px;font-size:18px;line-height:1;cursor:pointer}
.zsum.folded .zsum-body{display:none}
.zsum-body{padding:10px 16px 12px}
.zsum-l{font-weight:700;color:#8a5a17;margin:10px 0 4px;font-size:.92em}
.zsum-s{margin:0}
.zsum-b,.zsum-q{margin:0;padding-inline-start:22px}.zsum-b li,.zsum-q li{margin-bottom:5px}
.zsum-k{margin:0}.zsum-k dt{font-weight:700;margin-top:4px}.zsum-k dd{margin:0 0 4px;padding-inline-start:12px}
.zsum-hw{margin-top:10px;border-top:1px dashed #d9c27a;padding-top:4px}
.zsum-a{display:none;color:#5a4a2a;background:#f6ecd2;border-radius:8px;padding:4px 8px;margin-top:3px}
.zsum-hw.open .zsum-a{display:block}
.zsum-show{margin-top:6px;border:0;border-radius:10px;padding:7px 16px;background:#b3741d;color:#fff;font-weight:700;cursor:pointer}
.zsum-f{margin-top:10px;font-size:.78em;color:#8b7d5e}
.ts-align-btn.zsum-tg{width:auto;padding:0 10px;font-size:.85em}

/* ---- Zohar blocks (ozb) ---- */
.ozb{--c:#e6cf92;--b:#fbf3dc;--h:#f2e2b3;--i:#8a6416;margin:14px 0;border:1px solid var(--c);border-radius:14px;overflow:hidden;background:var(--b);box-shadow:0 1px 6px rgba(60,40,10,.06)}
.ozb-t{--c:#bcd9dc;--b:#eef6f6;--h:#d6eaec;--i:#17636f}
.ozb-p{--c:#dcc6c0;--b:#faf5f0;--h:#f0e0dc;--i:#7a2f3f;border-width:1.5px;border-color:var(--i);box-shadow:0 0 0 3px var(--h),0 1px 6px rgba(60,20,20,.06)}
.ozb-o{--c:var(--rule,#ddd);--b:transparent;--h:rgba(0,0,0,.03);--i:var(--muted,#666)}
.ozb-h{display:flex;align-items:center;gap:10px;padding:7px 14px;background:var(--h);color:var(--i);border-bottom:1px solid var(--c);font-family:"Assistant","Heebo",Arial,sans-serif;font-size:.72em;font-weight:800;letter-spacing:.6px;line-height:1.3}
.ozb-h::after{content:"";flex:1;height:1px;background:linear-gradient(to left,var(--c),transparent);order:5}
.ozb-h .ohr-spk{order:9}
.ozb-bi{flex:none;width:2em;height:2em;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:var(--i);color:var(--b);font-size:1.05em}
.ozb-bi svg{width:1.2em;height:1.2em}
.ozb-s{font-weight:500;opacity:.8;letter-spacing:0}
.ozb-hs{padding:11px 16px;gap:12px;color:#fff;border-bottom:0;position:relative;background:radial-gradient(120% 220% at 0% 0%,rgba(240,205,120,.35),transparent 55%),linear-gradient(110deg,#7a2f3f,#4d1d2b)}
.ozb-hs::after{content:"";position:absolute;inset:auto 0 0 0;height:3px;flex:none;background:linear-gradient(90deg,transparent,#e8cf8b 30%,#e8cf8b 70%,transparent)}
.ozb-ic{flex:none;width:2.6em;height:2.6em;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#f3dc9a;background:rgba(0,0,0,.22);box-shadow:0 0 0 1.5px #e8cf8b inset}
.ozb-ic svg{width:1.45em;height:1.45em;transform:rotate(38deg)}
.ozb-tx{display:flex;flex-direction:column;line-height:1.2}
.ozb-tx b{font-family:"Frank Ruhl Libre","David Libre",Georgia,serif;font-size:1.5em;font-weight:700;color:#fff;text-shadow:0 1px 6px rgba(0,0,0,.35)}
.ozb-tx small{font-size:.92em;font-weight:600;letter-spacing:1.2px;color:#f3dc9a;margin-top:2px}
.ozb-b{padding:10px 16px 12px}
.ozb-b > :first-child{margin-top:0}.ozb-b > :last-child{margin-bottom:0}
@media print{.ozb{box-shadow:none;break-inside:auto}}

/* ---- read aloud (ohr-spk) ---- */
.ohr-spk{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;width:1.9em;height:1.9em;margin-inline-start:.5em;padding:0;border:1.5px solid currentColor;border-radius:50%;background:transparent;color:var(--accent,#1f4e5a);cursor:pointer;font-size:.62em;opacity:.75}
.ohr-spk:hover{opacity:1}
.ohr-spk svg{width:1.15em;height:1.15em;fill:currentColor}
.ohr-spk .ic-stop{display:none}.ohr-spk.on .ic-play{display:none}.ohr-spk.on .ic-stop{display:block}
.ohr-spk.on{background:var(--accent,#1f4e5a);border-color:var(--accent,#1f4e5a);opacity:1}.ohr-spk.on svg{fill:#fff}
.zsum-h .ohr-spk{color:#fff;font-size:15px;margin-inline-start:auto;width:28px;height:28px}
.zsum-h .ohr-spk~.zsum-fold{margin-inline-start:0}
.zsum-h .ohr-spk.on{background:#fff;border-color:#fff}.zsum-h .ohr-spk.on svg{fill:#7a4a12}
section.section.ohr-reading{box-shadow:inset -3px 0 0 var(--accent,#1f4e5a);padding-inline-start:10px;transition:box-shadow .2s}
@media print{.ohr-spk{display:none!important}}

/* ---- mark as read ---- */
.read-tools button[data-rt="read"][hidden] { display: none; }
.read-tools button.is-read { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.read-btn.is-read { border-color: #2e7d32; background: #2e7d32; color: #fff; font-weight: 700; }
.read-btn.is-read:hover { background: #276a2b; color: #fff; }
.leaf-row.is-read .label::after { content: " ✓"; color: #2e7d32; font-weight: 700; }
.leaf-row.is-read.active .label::after { color: #fff; }

/* Android app: the floating reading tools are 15% smaller and sit at the very bottom (plenty of free room there) */
.is-apk .read-tools.rt-float { top: auto; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); transform: none; gap: 5px; }
.is-apk .read-tools.rt-float button { width: 34px; height: 34px; }
.is-apk .read-tools.rt-float .rt-ic { font-size: .98rem; }

/* collapsible reading tools */
.read-tools .rt-fold { width: 26px; height: 26px; min-width: 0; padding: 0; border-radius: 50%; font-size: 1.05rem; line-height: 1; opacity: .75; align-self: center; box-shadow: none; }
.read-tools.rt-collapsed > button:not(.rt-fold) { display: none; }
.is-apk .read-tools.rt-float .rt-fold { width: 26px; height: 26px; }

/* optional app lock */
html.ohr-locked-pre body > *:not(#ohrLock) { visibility: hidden; }
#ohrLock { position: fixed; inset: 0; z-index: 2000; background: var(--bg, #f5f1e8); display: flex; align-items: center; justify-content: center; padding: 16px; }
#ohrLock[hidden] { display: none; }
#ohrLock .lk-box { width: 100%; max-width: 340px; background: var(--panel, #fff); border: 1px solid var(--rule, #d9d2c0); border-radius: 16px; padding: 22px 18px; box-shadow: 0 8px 30px rgba(0,0,0,.18); text-align: center; }
#ohrLock .lk-ic { font-size: 2.2rem; }
#ohrLock .lk-title { margin: 6px 0 4px; font-size: 1.25rem; color: var(--accent, #0d5c63); }
#ohrLock .lk-msg { margin: 0 0 12px; color: var(--muted, #667); font-size: .92rem; line-height: 1.5; }
#ohrLock .lk-in { display: block; width: 100%; box-sizing: border-box; margin: 8px 0; padding: 12px; font: inherit; font-size: 1.15rem; text-align: center; border: 1.5px solid var(--rule, #d9d2c0); border-radius: 10px; background: #fff; color: var(--ink, #222); }
#ohrLock .lk-in[hidden] { display: none; }
#ohrLock .lk-in:focus { outline: 0; border-color: var(--accent, #0d5c63); box-shadow: 0 0 0 3px var(--accent-soft, #e4efee); }
#ohrLock .lk-err { min-height: 1.3em; color: #b3261e; font-size: .9rem; margin: 2px 0 6px; }
#ohrLock .lk-btns { display: flex; gap: 8px; justify-content: center; }
#ohrLock .lk-btns button { flex: 1; padding: 11px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; border: 1.5px solid var(--accent, #0d5c63); background: #fff; color: var(--accent, #0d5c63); }
#ohrLock .lk-btns .lk-ok { background: var(--accent, #0d5c63); color: #fff; }
#ohrLock .lk-btns button[hidden] { display: none; }
#ohrLock.lk-shake .lk-box { animation: lkshake .35s; }
@keyframes lkshake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
html.ohr-lock-open { overflow: hidden; }
.lk-note { display: block; flex-basis: 100%; color: var(--muted, #667); font-size: .78rem; margin-top: 4px; }
@media print { #ohrLock { display: none !important; } }

/* ---- loading screen ---- */
.ohr-loader { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 16px; color: var(--muted, #667); text-align: center; }
.ohr-spin { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--accent-soft, #e4efee); border-top-color: var(--accent, #0d5c63); animation: ohrspin .9s linear infinite; }
.ohr-bar { width: 70%; max-width: 240px; height: 6px; border-radius: 3px; background: var(--accent-soft, #e4efee); overflow: hidden; position: relative; }
.ohr-bar::after { content: ""; position: absolute; inset-block: 0; width: 40%; background: var(--accent, #0d5c63); border-radius: 3px; animation: ohrslide 1.2s ease-in-out infinite; }
.ohr-loader small { opacity: .75; line-height: 1.5; }
.ohr-mini { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--accent-soft, #e4efee); border-top-color: var(--accent, #0d5c63); animation: ohrspin .9s linear infinite; vertical-align: -1px; margin-inline-end: 6px; }
@keyframes ohrspin { to { transform: rotate(360deg); } }
@keyframes ohrslide { 0% { inset-inline-start: -40%; } 100% { inset-inline-start: 100%; } }
