:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #d8d2c4;
  --bg: #faf8f3;
  --panel: #ffffff;
  --accent: #0d5c63;
  --accent-soft: #e4efee;
  --sidebar-w: 440px;
  --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;
}

.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, .article-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
}
.part-pager a, .article-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, .article-pager a:hover { border-color: var(--accent); background: var(--accent-soft); }
.part-next, .pager-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;
  }
  .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 { display: none; }

  .sidebar {
    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));
    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; }
}

@media print {
  .site-header, .sidebar, .nav-scrim, .article-toc, .back-to-top { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* ---- WordPress plugin: reader login overlay ---- */
.brs-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}
.brs-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}
.brs-login-box h2{margin:0 0 6px;font-size:1.35rem}
.brs-login-box p{margin:0 0 16px;color:#5b6475;font-size:.95rem}
.brs-login-box label{display:block;margin:10px 0 4px;font-weight:600;font-size:.9rem}
.brs-login-box input{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid #c9d0dc;border-radius:8px;font-size:1rem}
.brs-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}
.brs-login-box button:disabled{opacity:.6;cursor:default}
.brs-login-err{color:#b91c1c;min-height:1.2em;margin-top:10px;font-size:.9rem}
.brs-logout{margin-top:8px;width:100%}
body.brs-embed .site-header{display:none}
