/* ==========================================================================
   משפט המעשה | Law in Practice — Design System & Editorial Stylesheet
   ========================================================================== */

:root,
html[data-theme="parchment"] {
  --bg-page: #f7f5f0;
  --bg-header: rgba(247, 245, 240, 0.96);
  --bg-subbar: #f3f0e9;
  --bg-surface: #fcfbf9;
  --bg-card-tint: #f1eee6;
  --bg-callout: #efece4;
  --bg-input: #f5f3ee;
  --bg-disclaimer: #f5efe0;
  --border-disclaimer: #d8c79e;

  --text-primary: #1a1e23;
  --text-secondary: #454a52;
  --text-muted: #757980;
  --text-faint: #8e9299;

  --burgundy: #7b2334;
  --burgundy-hover: #631b29;
  --burgundy-soft: rgba(123, 35, 52, 0.085);
  --burgundy-border: rgba(123, 35, 52, 0.24);

  --gold: #9a7b3e;
  --gold-bright: #c5a059;
  --gold-soft: rgba(154, 123, 62, 0.14);

  --border-subtle: #e2ddd2;
  --border-strong: #d4cec2;

  --shadow-xs: 0 1px 2px rgba(24, 28, 34, 0.04);
  --shadow-sm: 0 4px 14px rgba(24, 28, 34, 0.05);
  --shadow-book:
    0 26px 48px -12px rgba(15, 22, 30, 0.34),
    0 10px 22px -6px rgba(15, 22, 30, 0.2),
    -4px 0 12px rgba(15, 22, 30, 0.12);
}

/* Reader Theme: Crisp Light Studio Paper (בהיר) */
html[data-theme="light"] {
  --bg-page: #fbfbfc;
  --bg-header: rgba(251, 251, 252, 0.96);
  --bg-subbar: #f4f5f7;
  --bg-surface: #ffffff;
  --bg-card-tint: #f4f5f7;
  --bg-callout: #f2f3f5;
  --bg-input: #f7f8fa;
  --border-subtle: #e4e6eb;
  --border-strong: #d3d7df;
}

/* Reader Theme: Aged Archival Folio (ארכיון) */
html[data-theme="archive"] {
  --bg-page: #ede6d6;
  --bg-header: rgba(237, 230, 214, 0.96);
  --bg-subbar: #e5dcc9;
  --bg-surface: #f4efe2;
  --bg-card-tint: #e4dcc8;
  --bg-callout: #e3dbc7;
  --bg-input: #ece5d5;
  --text-primary: #211c15;
  --text-secondary: #463e33;
  --text-muted: #6e6456;
  --border-subtle: #d3c9b4;
  --border-strong: #c2b69e;
}

/* Font-Size Scaling for the Book Reader */
html[data-fontsize="sm"] {
  --reader-font-size: 0.98rem;
  --reader-line-height: 1.82;
}
html[data-fontsize="md"] {
  --reader-font-size: 1.125rem;
  --reader-line-height: 1.9;
}
html[data-fontsize="lg"] {
  --reader-font-size: 1.26rem;
  --reader-line-height: 1.94;
}
html[data-fontsize="xl"] {
  --reader-font-size: 1.42rem;
  --reader-line-height: 1.98;
}

/* Typography Families per Language */
html[lang="he"] {
  --font-serif: "Frank Ruhl Libre", "David Libre", Georgia, "Times New Roman", serif;
  --font-sans: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[lang="en"] {
  --font-serif: "Crimson Pro", "Frank Ruhl Libre", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: style weight;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  transition: background-color 0.22s ease, color 0.22s ease;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text-primary);
}

p {
  margin: 0;
}

.icon-xs { width: 13px; height: 13px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; flex-shrink: 0; }
.icon-md { width: 18px; height: 18px; flex-shrink: 0; }

/* Mirror directional arrows automatically in LTR vs RTL */
html[dir="ltr"] .dir-arrow {
  transform: scaleX(-1);
}

/* ==========================================================================
   Global Sticky Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-header);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1220px;
  height: 66px;
  margin: 0 auto;
  padding-inline: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand / Logo */
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-emblem {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.brand-emblem img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(20, 14, 6, 0.22));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.24rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: color 0.18s ease;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.brand-link:hover .brand-title {
  color: var(--burgundy);
}

.brand-link:hover .brand-emblem {
  transform: translateY(-1px);
}

/* Main Navigation Links */
.main-nav {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 30px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding-inline: 2px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.16s ease;
}

.nav-link:hover {
  color: var(--burgundy);
}

.nav-link.active {
  color: var(--burgundy);
  font-weight: 600;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  inset-inline: -4px;
  bottom: -1px;
  height: 2px;
  background-color: var(--burgundy);
}

/* Header Controls: Search + Lang Switcher */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.search-trigger {
  height: 34px;
  padding-inline: 10px 8px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: border-color 0.16s ease, color 0.16s ease;
}

.search-trigger:hover {
  border-color: var(--burgundy);
  color: var(--text-primary);
}

.search-trigger-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 3px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  direction: ltr;
}

.lang-switcher {
  height: 34px;
  padding-inline: 11px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
}

.lang-btn {
  color: var(--text-muted);
  font-weight: 400;
  padding-block: 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s ease;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  color: var(--burgundy);
  font-weight: 700;
  border-bottom-color: var(--burgundy);
}

.lang-sep {
  color: var(--border-strong);
  font-size: 0.78rem;
  user-select: none;
}

.mobile-menu-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  align-items: center;
  justify-content: center;
}

.mobile-nav-drawer {
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  padding: 10px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav-drawer[hidden] {
  display: none;
}

.mobile-nav-item {
  text-align: start;
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.mobile-nav-item.active {
  background-color: var(--burgundy-soft);
  color: var(--burgundy);
  font-weight: 600;
}

/* Search + language, shown in the hamburger menu on small screens. */
.mobile-nav-tools {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-nav-search {
  height: 42px;
  padding-inline: 12px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.mobile-nav-search:hover {
  border-color: var(--burgundy);
  color: var(--text-primary);
}

.mobile-nav-lang {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  overflow: hidden;
}

.mobile-lang-btn {
  height: 40px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
}

.mobile-lang-btn + .mobile-lang-btn {
  border-inline-start: 1px solid var(--border-strong);
}

.mobile-lang-btn.active {
  background-color: var(--burgundy);
  color: #ffffff;
  font-weight: 600;
}

@media (min-width: 961px) {
  .mobile-nav-drawer {
    display: none;
  }
}

/* ==========================================================================
   Main App Container
   ========================================================================== */
.app-main {
  flex: 1;
}

/* ==========================================================================
   VIEW 1: HOME PAGE (דף הבית)
   ========================================================================== */
.home-hero-band {
  border-bottom: 1px solid var(--border-subtle);
  padding: 58px 28px 66px;
}

.home-hero-grid {
  max-width: 1060px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.28fr 0.92fr;
  align-items: center;
  gap: 58px;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: start;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 999px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.hero-badge svg {
  color: var(--burgundy);
}

.hero-title {
  font-size: 3.45rem;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-bottom: 14px;
}

html[lang="en"] .hero-title {
  font-size: 3.1rem;
}

.hero-subtitle {
  font-family: var(--font-serif);
  font-size: 1.38rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--burgundy);
  margin-bottom: 20px;
}

.hero-byline {
  width: 100%;
  max-width: 440px;
  padding-top: 14px;
  margin-bottom: 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.hero-byline strong {
  color: var(--text-primary);
  font-weight: 700;
  margin-inline-start: 4px;
}

.hero-lead {
  font-size: 0.98rem;
  line-height: 1.78;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Motto (Ecclesiastes 3:16), centred above the hero. */
.hero-epigraph {
  max-width: 640px;
  margin: 0 auto 48px;
  text-align: center;
}

.hero-epigraph-ornament {
  display: block;
  width: 120px;
  height: 9px;
  margin: 0 auto 16px;
  background:
    linear-gradient(var(--gold, #c5a059), var(--gold, #c5a059)) left center / 46px 1px no-repeat,
    linear-gradient(var(--gold, #c5a059), var(--gold, #c5a059)) right center / 46px 1px no-repeat,
    radial-gradient(circle, var(--gold, #c5a059) 0 3px, transparent 3.5px) center / 9px 9px no-repeat;
}

.hero-epigraph blockquote {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.7;
  color: var(--text-primary);
}

html[lang="he"] .hero-epigraph blockquote {
  font-style: normal;
  font-size: 1.45rem;
}

.hero-epigraph figcaption {
  margin-top: 8px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* "All the names in this book are fictitious…" */
.hero-note {
  position: relative;
  width: 100%;
  margin: 0 0 24px;
  padding: 2px 0;
  padding-inline-start: 16px;
  border-inline-start: 3px solid var(--burgundy);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--burgundy);
}

html[lang="he"] .hero-note {
  font-style: normal;
}

/* "All rights reserved to the author ©" — sits directly under the hero note. */
.hero-rights {
  margin: -14px 0 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Second title line on the book cover (smaller, like a subtitle). */
.book-cover-title-sub {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.4;
  color: #d9c79f;
  margin: -4px 0 14px;
}

html[lang="he"] .book-cover-title-sub {
  font-style: normal;
}

.open-access-box {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 18px;
  border-radius: 6px;
  background-color: var(--bg-card-tint);
  border: 1px solid var(--border-subtle);
  margin-bottom: 26px;
}

.open-access-icon {
  color: var(--gold);
  margin-top: 2px;
  flex-shrink: 0;
}

.open-access-title {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.open-access-desc {
  font-size: 0.78rem;
  line-height: 1.58;
  color: var(--text-muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 4px;
  background-color: var(--burgundy);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.16s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background-color: var(--burgundy-hover);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 4px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.btn-secondary svg {
  color: var(--gold);
}

.btn-secondary:hover {
  border-color: var(--gold);
  background-color: var(--bg-surface);
}

.btn-ghost-link {
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.16s ease;
}

.btn-ghost-link:hover {
  color: var(--burgundy);
}

/* Hardcover Book Cover Mockup */
.hero-book-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.book-cover {
  position: relative;
  width: 306px;
  min-height: 422px;
  padding: 14px;
  border-radius: 7px;
  background: linear-gradient(155deg, #1b2632 0%, #131b24 58%, #0f161e 100%);
  box-shadow: var(--shadow-book);
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
  user-select: none;
}

/* Subtle spine groove on binding edge (right in RTL, left in LTR) */
.book-cover::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 9px;
  width: 2px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), rgba(0,0,0,0.35), rgba(255,255,255,0.06));
  pointer-events: none;
}

.book-cover:hover {
  transform: translateY(-4px);
}

/* Silk Crimson Bookmark Ribbon near top-right (inline-start) */
.book-ribbon {
  position: absolute;
  top: 0;
  inset-inline-start: 30px;
  width: 17px;
  height: 46px;
  background: linear-gradient(180deg, #941f35 0%, #761729 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  z-index: 3;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
}

.book-frame-outer {
  height: 100%;
  min-height: 394px;
  border: 1px solid rgba(197, 160, 89, 0.42);
  border-radius: 4px;
  padding: 4px;
  display: flex;
}

.book-frame-inner {
  flex: 1;
  border: 1px solid rgba(197, 160, 89, 0.2);
  border-radius: 2px;
  padding: 30px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: space-between;
}

.book-top-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.book-medallion {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(197, 160, 89, 0.45);
  background: rgba(197, 160, 89, 0.06);
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-medallion svg {
  width: 19px;
  height: 19px;
}

.book-overline {
  font-size: 0.62rem;
  color: var(--gold-bright);
  letter-spacing: 0.26em;
  font-weight: 500;
}

.book-center-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-block: 14px;
}

.book-cover-title {
  font-family: var(--font-serif);
  font-size: 1.52rem;
  font-weight: 700;
  line-height: 1.26;
  color: #f4f1ea;
  margin-bottom: 14px;
}

html[lang="en"] .book-cover-title {
  font-size: 1.38rem;
}

.book-gold-rule {
  width: 52px;
  height: 1px;
  background-color: rgba(197, 160, 89, 0.65);
  margin-bottom: 14px;
}

.book-cover-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.76rem;
  line-height: 1.55;
  color: #a9b4c0;
  max-width: 225px;
}

.book-bottom-group {
  width: 100%;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.book-author {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 700;
  color: #f2efe8;
}

.book-edition {
  font-size: 0.64rem;
  color: #84909e;
  margin-bottom: 7px;
}

.book-pill {
  display: inline-block;
  padding: 3px 13px;
  border-radius: 3px;
  border: 1px solid rgba(197, 160, 89, 0.42);
  background: rgba(197, 160, 89, 0.07);
  color: var(--gold-bright);
  font-size: 0.61rem;
  font-weight: 500;
}

/* Home Stats Section (in the hero text column, below the hero note) */
.home-stats-section {
  margin: 0 0 28px;
}

/* Plain figures sized to their content (no card boxes). */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 28px;
}

.stat-card {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.stat-card + .stat-card {
  padding-inline-start: 28px;
  border-inline-start: 1px solid var(--border-subtle);
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--burgundy);
  direction: ltr;
}

.stat-label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Home Table of Contents Directory Section */
.home-toc-section {
  max-width: 1060px;
  margin: 0 auto;
  padding: 42px 28px 72px;
}

.section-header-centered {
  text-align: center;
  margin-bottom: 32px;
}

.overline-gold {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 8px;
}

.section-subtitle-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--text-muted);
}

.home-chapters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.chapter-preview-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: start;
  padding: 22px 24px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.16s ease;
  cursor: pointer;
}

.chapter-preview-card:hover {
  border-color: var(--burgundy-border);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.chapter-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chapter-preview-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--gold);
}

.chapter-preview-time {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.chapter-preview-title {
  font-family: var(--font-serif);
  font-size: 1.24rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  transition: color 0.16s ease;
}

.chapter-preview-card:hover .chapter-preview-title {
  color: var(--burgundy);
}

.chapter-preview-desc {
  font-size: 0.85rem;
  line-height: 1.62;
  color: var(--text-secondary);
}

/* ==========================================================================
   VIEW 2: BOOK READER PAGE (קריאת הספר — Screenshot 3)
   ========================================================================== */
.reader-subbar {
  position: sticky;
  top: 66px;
  z-index: 90;
  background-color: var(--bg-subbar);
  border-bottom: 1px solid var(--border-subtle);
}

.reader-subbar-inner {
  max-width: 1120px;
  height: 50px;
  margin: 0 auto;
  padding-inline: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toc-toggle-pill {
  height: 32px;
  padding-inline: 12px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}

.toc-toggle-pill:hover {
  border-color: var(--burgundy);
}

.toc-toggle-pill svg {
  color: var(--gold);
}

.toc-current-tag {
  color: var(--burgundy);
  font-weight: 700;
}

.reader-controls-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-icon-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.segmented-box {
  height: 30px;
  display: inline-flex;
  align-items: stretch;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}

.seg-btn {
  padding-inline: 10px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-inline-end: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.seg-btn:last-child {
  border-inline-end: none;
}

.seg-btn:hover:not(.active) {
  background-color: var(--bg-callout);
  color: var(--text-primary);
}

.seg-btn.active {
  background-color: var(--burgundy);
  color: #ffffff;
  font-weight: 700;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background-color: var(--border-strong);
  margin-inline: 2px;
}

.toolbar-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.toolbar-icon-btn:hover {
  background-color: var(--bg-callout);
  color: var(--burgundy);
}

/* Reader Main Layout: TOC Sidebar (inline-start) + Chapter Article (inline-end) */
.reader-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 38px 28px 84px;
  display: grid;
  grid-template-columns: 295px minmax(0, 1fr);
  gap: 52px;
  align-items: start;
}

.reader-layout.toc-collapsed {
  grid-template-columns: minmax(0, 740px);
  justify-content: center;
}

.reader-layout.toc-collapsed .toc-sidebar {
  display: none;
}

.toc-drawer-backdrop,
.toc-drawer-close {
  display: none;
}

.toc-drawer-close {
  margin-inline-start: auto;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-secondary);
}

.toc-drawer-close:hover,
.toc-drawer-close:focus-visible {
  background-color: var(--bg-callout);
  color: var(--burgundy);
}

.toc-toggle-floating {
  display: none;
}

@media (max-width: 960px) {
  .toc-toggle-floating {
    display: inline-flex;
  }
}

/* TOC Sidebar Card */
.toc-sidebar {
  position: sticky;
  top: 136px;
  /* Never taller than the screen, so it stays pinned while the chapter scrolls. */
  max-height: calc(100vh - 136px - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 18px 14px;
  box-shadow: var(--shadow-xs);
}

.toc-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.toc-card-header svg {
  color: var(--gold);
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item-btn {
  width: 100%;
  text-align: start;
  padding: 10px 12px;
  border-radius: 5px;
  border-inline-start: 3px solid transparent;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 2px;
  align-items: baseline;
  transition: background-color 0.15s ease;
}

.toc-item-btn:hover {
  background-color: var(--bg-callout);
}

.toc-item-btn.active {
  background-color: var(--burgundy-soft);
  border-inline-start-color: var(--burgundy);
}

.toc-item-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.toc-item-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.38;
}

.toc-item-btn.active .toc-item-title {
  color: var(--burgundy);
  font-weight: 700;
}

.toc-item-time {
  grid-column: 2;
  font-size: 0.69rem;
  color: var(--text-muted);
}

.toc-card-footer {
  margin-top: 14px;
  padding: 12px 8px 2px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.72rem;
  line-height: 1.52;
  color: var(--text-muted);
  text-align: center;
}

/* Main Chapter Article */
.reader-article {
  min-width: 0;
}

.chapter-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.chapter-meta-label {
  font-weight: 700;
  color: var(--burgundy);
}

.chapter-meta-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.chapter-main-title {
  font-size: 2.55rem;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.chapter-main-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* Epigraph Blockquote with Antique Gold Inline-Start Bar */
.chapter-epigraph {
  margin: 0 0 20px;
  padding: 22px 26px;
  border-radius: 6px;
  background-color: var(--bg-card-tint);
  border-inline-start: 3.5px solid var(--gold);
}

.epigraph-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.epigraph-cite {
  display: block;
  font-size: 0.8rem;
  font-style: normal;
  color: var(--gold);
  font-weight: 500;
}

/* Chapter Abstract Box */
.chapter-abstract-box {
  padding: 15px 22px;
  border-radius: 6px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-subtle);
  margin-bottom: 36px;
}

.abstract-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.abstract-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.96rem;
  line-height: 1.62;
  color: var(--text-secondary);
}

/* Literary Prose Body */
.chapter-prose {
  font-family: var(--font-serif);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
}

.chapter-section-heading {
  font-family: var(--font-serif);
  font-size: 1.46rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 34px 0 16px;
}

.chapter-prose p {
  margin-bottom: 1.35em;
  text-align: justify;
}

/* Literary Drop-Cap on the very first paragraph of each chapter */
.dropcap-letter {
  float: inline-start;
  font-family: var(--font-serif);
  font-size: 3.35em;
  font-weight: 700;
  line-height: 0.84;
  padding-top: 0.04em;
  margin-inline-end: 0.24em;
  color: var(--text-primary);
}

/* Bottom Chapter Pagination */
.chapter-pagination {
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chapter-nav-card {
  padding: 16px 20px;
  border-radius: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  text-align: start;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.chapter-nav-card.next {
  text-align: end;
}

.chapter-nav-card:hover {
  border-color: var(--burgundy);
  background-color: var(--bg-card-tint);
}

.chapter-nav-dir {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.chapter-nav-name {
  font-family: var(--font-serif);
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--burgundy);
}

/* ==========================================================================
   COMBINED LANDING SECTIONS: ABOUT THE AUTHOR (על המחבר) & CONTACT (צור קשר)
   ========================================================================== */
#sectionHome,
#homeTocSection,
#sectionAbout,
#sectionContact {
  scroll-margin-top: 66px;
}

.landing-section-band {
  border-top: 1px solid var(--border-subtle);
}

.landing-section-band.alt-tint {
  background-color: rgba(239, 236, 228, 0.42);
}

.page-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 64px 28px 76px;
}

.page-hero-header {
  text-align: center;
  margin-bottom: 34px;
}

.page-main-title {
  font-size: 2.65rem;
  line-height: 1.16;
  margin-bottom: 10px;
}

.page-subtitle-burgundy {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--burgundy);
}

.about-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}

.author-profile-card {
  background-color: var(--bg-card-tint);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 28px 22px;
  text-align: center;
}

.author-monogram {
  width: 86px;
  height: 86px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(150deg, #1c2733 0%, #121a23 100%);
  border: 2px solid var(--gold-bright);
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.author-card-name {
  font-size: 1.28rem;
  margin-bottom: 4px;
}

.author-card-role {
  font-size: 0.8rem;
  color: var(--burgundy);
  font-weight: 600;
  margin-bottom: 16px;
}

.author-credentials-list {
  list-style: none;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border-subtle);
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.author-credentials-list li strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.78rem;
}

.about-bio-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 32px 34px;
}

.about-bio-card h2 {
  font-size: 1.45rem;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.about-bio-card p {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.about-pillars {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 24px;
}

.about-pillar-box {
  padding: 16px 18px;
  border-radius: 6px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-subtle);
}

.about-pillar-box h3 {
  font-size: 1rem;
  color: var(--burgundy);
  margin-bottom: 5px;
}

.about-pillar-box p {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.58;
  margin-bottom: 0;
}

/* ==========================================================================
   VIEW 4: CONTACT & CORRESPONDENCE PAGE (צור קשר — Screenshot 2)
   ========================================================================== */
.disclaimer-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 24px;
  border-radius: 8px;
  background-color: var(--bg-disclaimer);
  border: 1px solid var(--border-disclaimer);
  margin-bottom: 30px;
}

.disclaimer-icon {
  color: var(--burgundy);
  margin-top: 2px;
  flex-shrink: 0;
}

.disclaimer-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.disclaimer-text {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* Contact Two-Column Grid:
   In RTL: Form (1.62fr) sits on RIGHT (inline-start), Chambers Info (1fr) sits on LEFT (inline-end) — matching Screenshot 2! */
.contact-grid {
  display: grid;
  grid-template-columns: 1.62fr 1fr;
  gap: 28px;
  align-items: start;
}

.contact-form-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 28px 30px;
  box-shadow: var(--shadow-xs);
}

.contact-card-heading {
  font-size: 1.42rem;
  padding-bottom: 14px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 7px;
}

.req-star {
  color: var(--burgundy);
  margin-inline-start: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: 4px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  font-size: 0.86rem;
  color: var(--text-primary);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder {
  color: var(--text-faint);
}

.form-control:hover:not(:focus) {
  border-color: var(--gold);
}

.form-control:focus {
  outline: none;
  border-color: var(--burgundy);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--burgundy-soft);
}

.form-control.has-error {
  border-color: #b42318;
  background-color: #fffbfa;
}

.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  padding: 10px 14px;
  padding-inline-end: 38px;
  border-radius: 4px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  font-size: 0.86rem;
  color: var(--text-primary);
  text-align: start;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-select-trigger:hover {
  border-color: var(--gold);
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  outline: none;
  border-color: var(--burgundy);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--burgundy-soft);
}

.select-chevron {
  position: absolute;
  inset-inline-end: 13px;
  pointer-events: none;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  transition: transform 0.18s ease;
}

.custom-select.open .select-chevron {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 5px);
  inset-inline: 0;
  z-index: 80;
  margin: 0;
  padding: 5px;
  list-style: none;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 14px 32px rgba(18, 22, 28, 0.16);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-option {
  width: 100%;
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-primary);
  text-align: start;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.custom-select-option:hover,
.custom-select-option:focus {
  outline: none;
  background-color: var(--bg-callout);
}

.custom-select-option.selected {
  background-color: var(--burgundy-soft);
  color: var(--burgundy);
  font-weight: 600;
}

textarea.form-control {
  min-height: 118px;
  resize: vertical;
  line-height: 1.6;
}

.field-error-text {
  margin-top: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #b42318;
}

.field-error-text[hidden] {
  display: none;
}

.form-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 6px;
  font-size: 0.79rem;
  line-height: 1.55;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.form-checkbox-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--burgundy);
  cursor: pointer;
}

.contact-submit-row {
  margin-top: 18px;
}

.btn-primary[disabled] {
  opacity: 0.68;
  cursor: wait;
}

.form-confirmation-card {
  padding: 24px 22px;
  border-radius: 8px;
  background-color: var(--bg-card-tint);
  border: 1px solid var(--border-disclaimer);
  text-align: start;
}

.form-confirmation-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--burgundy);
}

.form-confirmation-header h4 {
  font-size: 1.18rem;
  color: var(--burgundy);
}

.form-confirmation-body {
  font-size: 0.88rem;
  line-height: 1.68;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.form-ref-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.form-ref-badge strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-primary);
  margin-inline-start: 4px;
}

/* Chambers Sidebar Card (לשכה והתכתבות אקדמית) */
.chambers-card {
  background-color: var(--bg-card-tint);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 24px 22px;
}

.chambers-heading {
  font-size: 1.12rem;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.chambers-intro {
  font-size: 0.8rem;
  line-height: 1.62;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.chambers-info-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.chambers-info-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.chambers-info-icon {
  color: var(--gold);
  margin-top: 2px;
  flex-shrink: 0;
}

.chambers-info-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.chambers-info-val {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.chambers-email-link {
  color: var(--burgundy);
  font-weight: 600;
  direction: ltr;
  display: inline-block;
}

.chambers-email-link:hover {
  text-decoration: underline;
}

.chambers-footnote {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ==========================================================================
   Site Footer
   ========================================================================== */
.site-footer {
  position: relative;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-subbar);
  padding: 48px 28px 28px;
  margin-top: auto;
}

/* Thin gold rule along the top edge, echoing the book cover. */
.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 96px;
  height: 2px;
  transform: translateX(-50%);
  background-color: var(--gold-bright);
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-top {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  padding-bottom: 32px;
}

.footer-brand-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

.footer-brand-subtitle {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--burgundy);
}

html[lang="he"] .footer-brand-subtitle {
  font-style: normal;
}

.footer-legal-note {
  margin-top: 14px;
  max-width: 38ch;
  line-height: 1.6;
}

.footer-col-heading {
  margin-bottom: 14px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.footer-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links button {
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  text-align: start;
  transition: color 0.15s ease;
}

.footer-links button:hover,
.footer-links button[aria-current="page"] {
  color: var(--burgundy);
}

.footer-bottom {
  padding-top: 22px;
  border-top: 1px solid var(--border-subtle);
}

.footer-rights {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .site-footer {
    padding: 40px 16px 24px;
  }

  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ==========================================================================
   Legal Pages (Terms of Use, Privacy Policy)
   ========================================================================== */
.legal-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 36px 40px;
}

.legal-intro {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.legal-section {
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.legal-section h2 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: var(--burgundy);
}

.legal-section p {
  line-height: 1.75;
  color: var(--text-secondary);
}

.legal-section p + p {
  margin-top: 10px;
}

.legal-actions {
  justify-content: center;
  margin-top: 32px;
}

@media (max-width: 680px) {
  .legal-card {
    padding: 24px 20px;
  }
}

/* ==========================================================================
   Search Modal (Ctrl+K) & Toast Banner
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background-color: rgba(18, 22, 28, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 20px 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.search-dialog {
  width: 100%;
  max-width: 600px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 24px 56px rgba(15, 20, 28, 0.28);
  overflow: hidden;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-modal-icon {
  color: var(--burgundy);
}

.search-modal-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.96rem;
  color: var(--text-primary);
  outline: none;
}

.search-esc-btn {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  padding: 3px 7px;
  border-radius: 4px;
  background-color: var(--bg-callout);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.search-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 10px;
}

.search-result-item {
  width: 100%;
  text-align: start;
  padding: 12px 14px;
  border-radius: 6px;
  display: block;
  transition: background-color 0.14s ease;
}

.search-result-item:hover {
  background-color: var(--burgundy-soft);
}

.search-result-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 2px;
}

.search-result-title {
  font-family: var(--font-serif);
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.search-result-snippet mark {
  background-color: rgba(197, 160, 89, 0.32);
  color: var(--text-primary);
  padding: 0 2px;
  border-radius: 2px;
}

.search-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.toast-banner {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 400;
  padding: 11px 18px;
  border-radius: 6px;
  background-color: #1c2530;
  color: #f6f3ec;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.toast-banner[hidden] {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints & Print Stylesheet
   ========================================================================== */
@media (max-width: 960px) {
  .main-nav {
    display: none;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  /* Search and language move into the hamburger menu. */
  .header-controls .search-trigger,
  .header-controls .lang-switcher {
    display: none;
  }
  .header-inner {
    gap: 12px;
  }
  .brand-link {
    flex-shrink: 1;
    min-width: 0;
  }
  .brand-text {
    min-width: 0;
  }
  .brand-title,
  .brand-subtitle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .home-hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .reader-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  /* Contents list becomes a slide-in panel from the inline-start edge. */
  .toc-sidebar,
  .reader-layout.toc-collapsed .toc-sidebar {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 1200;
    width: min(88vw, 380px);
    max-height: none;
    overflow-y: auto;
    border-radius: 0;
    border-block: 0;
    border-inline-start: 0;
    padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.22);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }
  html[dir="rtl"] .toc-sidebar {
    transform: translateX(100%);
  }
  body.toc-drawer-open .toc-sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
  }
  .toc-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 12, 8, 0.45);
  }
  body.toc-drawer-open .toc-drawer-backdrop {
    display: block;
  }
  body.toc-drawer-open {
    overflow: hidden;
  }
  .toc-drawer-close {
    display: inline-flex;
  }
  .reader-layout,
  .reader-layout.toc-collapsed {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 110px;
  }
  /* Floating contents button, bottom-left of the screen. */
  .toc-toggle-desktop {
    display: none;
  }
  .toc-toggle-floating {
    position: fixed;
    left: 16px;
    right: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 1000;
    height: 46px;
    padding-inline: 16px;
    border-radius: 999px;
    border-color: var(--burgundy-border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  }
  .reader-subbar-inner {
    justify-content: center;
  }
  .about-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .header-inner {
    padding-inline: 16px;
  }
  .brand-subtitle,
  .search-kbd,
  #searchBtnText {
    display: none;
  }
  .search-trigger {
    padding-inline: 9px;
  }
  .hero-title,
  html[lang="en"] .hero-title {
    font-size: 2.3rem;
  }
  .hero-epigraph {
    margin-bottom: 36px;
  }
  .hero-epigraph blockquote {
    font-size: 1.06rem;
  }
  html[lang="he"] .hero-epigraph blockquote {
    font-size: 1.25rem;
  }
  .home-chapters-grid,
  .about-pillars,
  .chapter-pagination {
    grid-template-columns: 1fr;
  }
  /* On a single column, show "Next Chapter" above "Previous Chapter". */
  .chapter-pagination > div:last-child {
    order: -1;
  }
  .reader-subbar-inner {
    height: auto;
    padding-block: 8px;
    padding-inline: 12px;
    flex-wrap: wrap;
  }
  .reader-controls-cluster {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .reader-controls-cluster .toolbar-divider {
    display: none;
  }
  .reader-controls-cluster .segmented-box {
    height: 34px;
  }
  .reader-controls-cluster .seg-btn {
    padding-inline: 9px;
  }
  .reader-controls-cluster .toolbar-icon-btn {
    width: 34px;
    height: 34px;
  }
  .reader-layout {
    padding-inline: 16px;
  }
}

@media print {
  .site-header,
  .reader-subbar,
  .toc-toggle-floating,
  .toc-drawer-backdrop,
  .toc-sidebar,
  .chapter-pagination,
  .site-footer,
  .modal-backdrop,
  .toast-banner {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .reader-layout {
    display: block;
    max-width: 100%;
    padding: 0;
  }
}


/* ==========================================================================
   Gates → Chapters (database-driven book)
   ========================================================================== */
.home-gates-directory {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.home-gate-heading-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  transition: margin-bottom 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.home-gate-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
}

.home-gate-group.is-collapsed .home-gate-heading-row,
.home-gate-group.is-collapsing .home-gate-heading-row {
  margin-bottom: 0;
}

.home-gate-tag {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}

.home-gate-title {
  font-family: var(--font-serif);
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--text-primary);
}

.home-gate-heading:hover .home-gate-title {
  color: var(--burgundy);
}

.toc-gate {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border-subtle);
}

.toc-gate:last-child {
  border-bottom: 0;
}

.toc-gate-heading-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.toc-gate-heading {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 8px 12px 6px;
  border-radius: 5px;
  text-align: start;
}

.toc-gate-heading:hover,
.toc-gate-heading.active {
  background-color: var(--bg-callout);
}

.toc-gate-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
}

.toc-gate-title {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.toc-gate .toc-item-btn {
  padding-inline-start: 18px;
}

/* Rich content written in the admin editor */
.rich-prose h2,
.rich-prose h3,
.rich-prose h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text-primary);
  margin: 34px 0 16px;
}

.rich-prose h2 { font-size: 1.46rem; }
.rich-prose h3 { font-size: 1.22rem; }
.rich-prose h4 { font-size: 1.06rem; }

.rich-prose > p:first-of-type::first-letter {
  float: inline-start;
  font-size: 3.35em;
  font-weight: 700;
  line-height: 0.84;
  padding-top: 0.04em;
  margin-inline-end: 0.24em;
}

.rich-prose blockquote {
  margin: 1.4em 0;
  padding: 4px 18px;
  border-inline-start: 3px solid var(--gold);
  font-style: italic;
  color: var(--text-secondary);
}

.rich-prose ul,
.rich-prose ol {
  margin: 0 0 1.35em;
  padding-inline-start: 1.6em;
}

.rich-prose ul { list-style: disc; }
.rich-prose ol { list-style: decimal; }
.rich-prose li { margin-bottom: 0.4em; }

.rich-prose a {
  color: var(--burgundy);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rich-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1em 0;
}

.rich-prose sup { font-size: 0.7em; }
.rich-prose .ql-align-center { text-align: center; }
.rich-prose .ql-align-right { text-align: right; }
.rich-prose .ql-align-left { text-align: left; }
.rich-prose .ql-direction-rtl { direction: rtl; }

.chapter-figure {
  margin: 0 0 28px;
}

.chapter-figure img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.chapter-video {
  position: relative;
  margin-top: 32px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.chapter-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.gate-chapter-list {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-chapter-link {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 2px;
  align-items: baseline;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-surface);
  text-align: start;
}

.gate-chapter-link:hover {
  border-color: var(--burgundy-border);
  background: var(--burgundy-soft);
}

.gate-chapter-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary);
}

.gate-chapter-sub {
  grid-column: 2;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.reader-empty {
  padding: 80px 16px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

/* Contact-form honeypot: hidden from people, visible to naive bots */
.hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* No-JS fallback for server-rendered chapter pages */
.noscript-reader {
  max-width: 760px;
  margin: 40px auto;
  padding: 0 16px;
}

/* Footnotes (markers numbered server-side by RichContent) */
.rich-prose sup.footnote-ref {
  font-size: 0.68em;
  line-height: 0;
  margin-inline-start: 1px;
  scroll-margin-top: 150px;
}

.rich-prose sup.footnote-ref a {
  display: inline-block;
  min-width: 1.2em;
  padding: 0 0.2em;
  border-radius: 3px;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  color: var(--burgundy);
}

.rich-prose sup.footnote-ref a:hover,
.rich-prose sup.footnote-ref a:focus-visible {
  background: var(--burgundy);
  color: #fff;
}

.rich-prose .footnotes {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.9em;
  color: var(--text-secondary);
}

.rich-prose .footnotes .footnotes-title {
  margin: 0 0 12px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.rich-prose .footnotes ol {
  list-style: decimal;
  margin: 0;
  padding-inline-start: 1.6em;
}

.rich-prose .footnotes li {
  margin-bottom: 0.55em;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.6;
  white-space: pre-line;
  scroll-margin-top: 150px;
  transition: background-color 0.4s ease;
}

.rich-prose .footnotes li.is-target,
.rich-prose sup.footnote-ref.is-target a {
  background: color-mix(in srgb, var(--gold) 22%, transparent);
}

.rich-prose .footnote-back {
  margin-inline-start: 4px;
  text-decoration: none;
  font-family: var(--font-sans, system-ui, sans-serif);
}


/* --------------------------------------------------------------------------
   Landing page reading controls & collapsible gates
   -------------------------------------------------------------------------- */
/* Text size on the landing page scales the whole page (all sizes are in rem);
   the reader keeps its own prose-only scale (--reader-font-size). */
html[data-view="landing"][data-fontsize="sm"] { font-size: 93.75%; }
html[data-view="landing"][data-fontsize="lg"] { font-size: 112.5%; }
html[data-view="landing"][data-fontsize="xl"] { font-size: 125%; }

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

.gate-chapters[hidden],
.is-collapsed > .gate-chapters {
  display: none;
}

.gate-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.gate-toggle:hover,
.gate-toggle:focus-visible,
.gate-toggle-all:hover,
.gate-toggle-all:focus-visible {
  border-color: var(--burgundy-border);
  color: var(--burgundy);
}

.gate-toggle-chevron {
  display: inline-flex;
  transition: transform 0.2s ease;
}

.gate-toggle-chevron svg {
  width: 16px;
  height: 16px;
}

.is-collapsed .gate-toggle-chevron,
.is-collapsing .gate-toggle-chevron,
.gate-toggle-all[aria-pressed="true"] .gate-toggle-chevron {
  transform: rotate(-90deg);
}

html[dir="rtl"] .is-collapsed .gate-toggle-chevron,
html[dir="rtl"] .is-collapsing .gate-toggle-chevron,
html[dir="rtl"] .gate-toggle-all[aria-pressed="true"] .gate-toggle-chevron {
  transform: rotate(90deg);
}

.toc-gate-toggle {
  min-height: 28px;
  margin-top: 6px;
  padding: 2px 6px;
  border-color: transparent;
  background: transparent;
}

.toc-gate-toggle .gate-toggle-count {
  display: none;
}

.toc-gate.is-collapsed {
  padding-bottom: 2px;
}

/* Introduction on the landing page: one row with a read button. */
.home-intro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--border-subtle);
  border-inline-start: 3px solid var(--burgundy);
  border-radius: 6px;
  background-color: var(--bg-surface);
}

.home-intro-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.home-intro-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
}

.home-intro-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.home-intro-read {
  flex-shrink: 0;
}

@media (max-width: 680px) {
  .home-intro-row {
    flex-direction: column;
    align-items: stretch;
  }
  .home-intro-read {
    justify-content: center;
  }
}

/* Introduction in the reader contents: a single link, no chapter list. */
.toc-intro-link.active .toc-gate-title {
  color: var(--burgundy);
}

/* Search matches inside the opened chapter. */
mark.search-hit {
  background-color: rgba(197, 160, 89, 0.38);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
  scroll-margin-top: 140px;
}

mark.search-hit.is-current {
  background-color: var(--burgundy);
  color: #ffffff;
  box-shadow: 0 0 0 2px var(--burgundy);
}

.search-hit-bar {
  position: fixed;
  top: 128px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 32px);
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  font-size: 0.84rem;
  color: var(--text-secondary);
}

html[dir="rtl"] .search-hit-bar {
  padding: 6px 14px 6px 8px;
}

.search-hit-term {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--text-primary);
}

.search-hit-count {
  white-space: nowrap;
  margin-inline-end: 4px;
}

.search-hit-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1;
}

.search-hit-btn:hover,
.search-hit-btn:focus-visible {
  background-color: var(--burgundy-soft);
  color: var(--burgundy);
}

.search-hit-btn svg {
  width: 16px;
  height: 16px;
}

.search-hit-prev svg {
  transform: rotate(180deg);
}

@media (max-width: 680px) {
  .search-hit-bar {
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-toggle-chevron,
  .home-gate-heading-row {
    transition: none;
  }
}

@media print {
  .gate-toggle,
  .search-hit-bar {
    display: none !important;
  }
  mark.search-hit {
    background: none;
    color: inherit;
    box-shadow: none;
  }
  .is-collapsed > .gate-chapters {
    display: grid !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toc-sidebar,
  body.toc-drawer-open .toc-sidebar {
    transition: none;
  }
}

/* ==========================================================================
   Gate 8: readers' forum (public/js/app.js -> renderForumArticle)
   ========================================================================== */
.forum {
  margin-top: 8px;
}

.forum-status {
  padding: 18px 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.forum-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 24px;
}

.forum-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 6px 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--burgundy);
}

.forum-back:hover {
  color: var(--burgundy-hover);
  text-decoration: underline;
}

.forum-section-title {
  margin: 28px 0 12px;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.forum-category-head .forum-section-title {
  margin-top: 4px;
  margin-bottom: 4px;
}

.forum-category-head {
  margin-bottom: 16px;
}

/* Categories */
/* Four categories: a 2 x 2 grid (one column on phones) */
.forum-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 560px) {
  .forum-category-grid {
    grid-template-columns: 1fr;
  }
}

.forum-category-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  border-inline-start: 4px solid var(--burgundy);
  border-radius: 6px;
  background: var(--bg-surface);
  text-align: start;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.forum-category-card:hover {
  border-color: var(--burgundy-border);
  background: var(--burgundy-soft);
}

.forum-category-name {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
}

.forum-category-desc {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.forum-category-count {
  margin-top: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
}

/* Post lists */
.forum-post-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.forum-post-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-surface);
  text-align: start;
}

.forum-post-row:hover {
  border-color: var(--burgundy-border);
  background: var(--burgundy-soft);
}

.forum-post-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary);
}

.forum-post-excerpt {
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.forum-post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.forum-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 600;
}

/* One post */
.forum-post-full {
  padding: 20px 22px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface);
}

.forum-post-heading {
  margin: 10px 0 12px;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
}

/* Readers' formatted text: paragraphs, bold, italic, numbered lists */
.forum-rich {
  font-size: var(--reader-font-size, 1rem);
  line-height: var(--reader-line-height, 1.8);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.forum-rich p {
  margin: 0 0 0.6em;
}

.forum-rich p:last-child,
.forum-rich ol:last-child {
  margin-bottom: 0;
}

.forum-rich ol {
  margin: 0 0 0.6em;
  padding-inline-start: 1.6em;
  list-style: decimal;
}

.forum-rich li {
  margin-bottom: 0.2em;
}

.forum-rich strong {
  font-weight: 700;
}

.forum-rich em {
  font-style: italic;
}

/* Attached images */
.forum-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.forum-images a {
  display: block;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card-tint);
}

.forum-images img {
  display: block;
  width: 168px;
  height: 126px;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.forum-images a:hover img {
  transform: scale(1.03);
}

/* Comment thread: every reply nests under its comment, Reddit style */
.forum-thread {
  margin: 0;
  padding: 0;
  list-style: none;
}

.forum-thread .forum-thread {
  margin-top: 8px;
  margin-inline-start: 14px;
  padding-inline-start: 14px;
  border-inline-start: 2px solid var(--border-subtle);
}

.forum-thread .forum-thread:hover {
  border-inline-start-color: var(--gold-bright);
}

/* Very deep replies keep their thread line but stop moving inwards */
.forum-thread.is-flat .forum-thread {
  margin-inline-start: 0;
}

.forum-node + .forum-node {
  margin-top: 10px;
}

.forum-comment {
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--bg-card-tint);
}

.forum-comment .forum-post-meta {
  margin-bottom: 6px;
}

.forum-comment .forum-post-meta strong {
  color: var(--text-primary);
}

.forum-comment .forum-rich {
  font-size: 0.92rem;
  line-height: 1.7;
}

.forum-comment .forum-images img {
  width: 120px;
  height: 90px;
}

.forum-comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.forum-link-btn {
  padding: 2px 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--burgundy);
}

.forum-link-btn:hover {
  color: var(--burgundy-hover);
  text-decoration: underline;
}

/* Forms */
.forum-form-card {
  margin: 8px 0 28px;
  padding: 20px 22px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface);
}

.forum-node > .forum-form-card {
  margin: 10px 0 4px;
  margin-inline-start: 14px;
  padding: 16px 18px;
}

.forum-form-title {
  margin-bottom: 6px;
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-primary);
}

.forum-hint {
  margin-top: 5px;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.forum-form > .forum-hint {
  margin: 0 0 16px;
}

.forum-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.forum-form textarea.form-control {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.forum-form .form-control:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.forum-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* Quill editor, dressed in the site's form colours */
.forum-form .ql-toolbar.ql-snow {
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: var(--bg-callout);
  font-family: var(--font-sans);
}

.forum-form .ql-container.ql-snow {
  border: 1px solid var(--border-strong);
  border-radius: 0 0 4px 4px;
  background: var(--bg-input);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-primary);
}

.forum-form .ql-container.ql-snow:focus-within {
  border-color: var(--burgundy);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--burgundy-soft);
}

.forum-form .ql-container.has-error {
  border-color: #b42318;
}

.forum-form .ql-editor {
  min-height: 140px;
  line-height: 1.7;
}

.forum-form.is-reply .ql-editor {
  min-height: 90px;
}

.forum-form .ql-editor.ql-blank::before {
  color: var(--text-faint);
  font-style: normal;
  left: 15px;
  right: 15px;
}

.forum-form .ql-snow .ql-stroke {
  stroke: var(--text-secondary);
}

.forum-form .ql-snow .ql-fill {
  fill: var(--text-secondary);
}

.forum-form .ql-snow.ql-toolbar button:hover .ql-stroke,
.forum-form .ql-snow.ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--burgundy);
}

.forum-form .ql-snow.ql-toolbar button:hover .ql-fill,
.forum-form .ql-snow.ql-toolbar button.ql-active .ql-fill {
  fill: var(--burgundy);
}

/* Quill draws list numbers itself; keep them on the reading side in Hebrew */
html[dir="rtl"] .forum-form .ql-editor ol {
  padding-left: 0;
  padding-right: 1.5em;
}

html[dir="rtl"] .forum-form .ql-editor li:not(.ql-direction-rtl)::before {
  margin-left: 0.3em;
  margin-right: -1.5em;
  text-align: left;
}

html[dir="rtl"] .forum-form .ql-editor li:not(.ql-direction-rtl) {
  padding-left: 0;
  padding-right: 1.5em;
}

/* Image drop zone */
.forum-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--bg-input);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.forum-dropzone:hover,
.forum-dropzone:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.forum-dropzone.is-dragging {
  border-color: var(--burgundy);
  background: var(--burgundy-soft);
}

.forum-dropzone-icon {
  font-size: 1.4rem;
  line-height: 1;
  color: var(--gold);
}

.forum-dropzone-text {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.forum-dropzone .forum-hint {
  margin-top: 0;
}

.forum-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.forum-thumbs:not(:empty) {
  margin-top: 10px;
}

.forum-thumb {
  position: relative;
  margin: 0;
}

.forum-thumb img {
  display: block;
  width: 96px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.forum-thumb-remove {
  position: absolute;
  top: -7px;
  inset-inline-end: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 22px;
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.forum-thumb-remove:hover {
  background: var(--burgundy-hover);
}

@media (max-width: 640px) {
  .forum-form-row {
    grid-template-columns: 1fr;
  }

  .forum-post-full,
  .forum-form-card {
    padding: 16px;
  }

  .forum-thread .forum-thread {
    margin-inline-start: 6px;
    padding-inline-start: 10px;
  }

  .forum-node > .forum-form-card {
    margin-inline-start: 0;
  }
}

@media print {
  .forum-toolbar,
  .forum-form,
  .forum-back,
  .forum-comment-actions {
    display: none !important;
  }
}

/* Anonymous: the generated name and the "another name" button */
.forum-anon-name {
  display: flex;
  gap: 8px;
}

.forum-anon-name .form-control[readonly] {
  flex: 1;
  min-width: 0;
  background: var(--gold-soft);
  border-style: dashed;
  font-weight: 600;
  color: var(--text-primary);
  direction: ltr;
  text-align: start;
}

.forum-anon-reroll {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 0.78rem;
}
