/* ===================================================
   ספר הבדיחה והחידוד — stylesheet
   RTL-first, mobile-first, no frameworks
   =================================================== */

/* Self-hosted Heebo — no third-party font CDN (privacy / offline). */
@font-face {
  font-family: 'Heebo'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/hebrew-400-normal.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+FB1D-FB4F, U+200C-2010, U+20AA, U+25CC;
}
@font-face {
  font-family: 'Heebo'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Heebo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/hebrew-700-normal.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+FB1D-FB4F, U+200C-2010, U+20AA, U+25CC;
}
@font-face {
  font-family: 'Heebo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Ensure the [hidden] attribute always wins over display rules below */
[hidden] {
  display: none !important;
}

/* Skip-to-content link — visible only when focused (keyboard users) */
.skip-link {
  position: absolute;
  right: 0.5rem;
  top: -3rem;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* Clear keyboard-focus ring (without forcing it on mouse clicks) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- CSS Variables --- */
:root {
  --bg:          #faf8f3;
  --bg-card:     #ffffff;
  --bg-annot:    #f5f0e8;
  --ink:         #2c1810;
  --ink-muted:   #6b5744;
  --accent:      #b8860b;
  --accent-dark: #8b6508;
  --accent-darker:#6b4e06;
  --accent-light:#f0e0a0;
  --border:      #d9cfc0;
  --star-empty:  #a08454;
  --star-filled: #b8860b;
  --radius:      6px;
  --shadow:      0 2px 8px rgba(44, 24, 16, 0.08);
  --font:        'Heebo', 'Arial Hebrew', Arial, sans-serif;
}

/* --- Reset & base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  text-align: right;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}
a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* --- Site Header --- */
.site-header {
  background: var(--ink);
  color: var(--bg);
  padding: 1.25rem 1rem;
  border-bottom: 3px solid var(--accent);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

/* App-mode share button: shown only in the installed PWA (see base.html),
   pinned to the header's inline-end corner (physical left in this RTL app). */
.app-share-btn {
  position: absolute;
  inset-inline-end: 0;
  top: 0;
  font-family: var(--font);
  font-size: 0.85rem;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent-light);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.app-share-btn:hover { background: var(--accent); color: #fff; }
/* When the button is actually shown (standalone mode), inset the title so its
   text can't run under the absolutely-positioned button. Scoped to the revealed
   state, so a normal browser tab (button hidden) keeps the full-width title. */
.app-share-btn:not([hidden]) ~ .header-title-link { padding-inline-end: 5.25rem; }

.header-title-link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}
.header-title-link:hover {
  color: var(--accent-light);
  text-decoration: none;
}

.site-title {
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.site-subtitle {
  font-size: 0.9rem;
  color: var(--accent-light);
  margin-top: 0.2rem;
  font-weight: 400;
  letter-spacing: 0.05em;
}

/* --- Main content --- */
.main-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}

/* --- Footer --- */
.site-footer {
  background: var(--ink);
  color: var(--ink-muted);
  text-align: center;
  font-size: 0.8rem;
  padding: 0.9rem 1rem;
  border-top: 2px solid var(--accent);
  color: #9e8870;
}
.logout-link {
  color: #9e8870;
  text-decoration: underline;
  white-space: nowrap;  /* keep multi-word links (e.g. "איך נבנה האתר") on one line */
}
.logout-link:hover { color: var(--accent); }

.footer-donate {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--accent-light);
}
.footer-donate .donate-link {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-donate .donate-link:hover { color: var(--accent-light); }
.footer-donate .donate-soon { cursor: help; }

.footer-dedication {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(184, 134, 11, 0.25);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--accent-light);
}

/* Login page */
.login-page {
  display: flex;
  justify-content: center;
  padding: 3rem 1rem;
}
.login-form {
  width: 100%;
  max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
}
.login-title {
  font-size: 1.3rem;
  color: var(--ink);
  margin: 0 0 0.3rem;
}
.login-hint {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0 0 1.25rem;
}
.login-input {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.85rem;
  box-sizing: border-box;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-error {
  color: #b00020;
  font-size: 0.85rem;
  margin: 0 0 0.85rem;
}
.login-btn {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.login-btn:hover { background: var(--accent-dark); }

/* ===================================================
   INDEX PAGE
   =================================================== */

.search-section {
  margin-bottom: 1.75rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.search-input {
  flex: 1;
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  direction: rtl;
  transition: border-color 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}

.search-btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  background: var(--accent-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.search-btn:hover {
  background: var(--accent-darker);
}

/* Filter pills */

/* Results header */
.results-header {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}
.reshuffle-btn {
  font: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.4rem;      /* ≥24px tap target */
  margin: -0.35rem 0.15rem -0.35rem -0.2rem;  /* keep the row height as before */
  border-radius: var(--radius);
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.12s, transform 0.2s;
}
.reshuffle-btn:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* Table of contents */
.toc {
  margin: 0 0 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toc-summary {
  cursor: pointer;
  padding: 0.85rem 1.1rem;
  font-weight: 700;
  color: var(--accent-dark);
  list-style: none;
}
.toc-summary::-webkit-details-marker { display: none; }
.toc-summary::before {
  content: "▸";
  margin-inline-end: 0.5rem;
  font-size: 0.8em;
}
.toc[open] .toc-summary::before { content: "▾"; }

/* Druyanov's preface on a list page (מפתח האישים) — same collapsible look as the ToC. */
.list-preamble {
  margin: 0 0 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.list-preamble > summary {
  cursor: pointer;
  padding: 0.75rem 1.1rem;
  font-weight: 700;
  color: var(--accent-dark);
  list-style: none;
}
.list-preamble > summary::-webkit-details-marker { display: none; }
.list-preamble > summary::before { content: "▸"; margin-inline-end: 0.5rem; font-size: 0.8em; }
.list-preamble[open] > summary::before { content: "▾"; }
.list-preamble-body {
  padding: 0 1.1rem 1rem;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ink-muted);
}
.list-preamble-body p { margin: 0 0 0.7rem; }
.toc-body {
  padding: 0 1.1rem 1rem;
  border-top: 1px solid var(--accent-light);
}
.toc-volume-title {
  font-size: 1rem;
  color: var(--ink);
  margin: 1rem 0 0.5rem;
}
.toc-chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem;
}
@media (min-width: 640px) {
  .toc-chapters { grid-template-columns: 1fr 1fr; }
}
.toc-chapter {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s;
}
.toc-chapter:hover { background: var(--accent-light); }
.toc-chapter-count {
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.toc-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin: 0.6rem 0 0;
}

/* Jokes grid */
.jokes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 540px) {
  .jokes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 780px) {
  .jokes-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Joke card */
.joke-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  cursor: pointer;
}
.joke-card:hover {
  box-shadow: 0 4px 16px rgba(44, 24, 16, 0.13);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--ink);
}

.joke-number-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.joke-preview {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 0.6rem;
  /* clamp to ~4 lines */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Preview affordance: the text thins out toward the bottom so the card reads
   as "there's more — tap through" (to the full joke, rating, comprehension).
   Applied to ALL card previews, even jokes that fit whole — the destination
   page is always richer than the card. Mask (not color) so it follows any
   theme/ink automatically. */
.preview-fade {
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, rgba(0, 0, 0, 0.15) 100%);
          mask-image: linear-gradient(to bottom, #000 35%, rgba(0, 0, 0, 0.15) 100%);
}

.joke-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
  display: block;
}

/* Placeholders */
.loading-placeholder,
.empty-msg,
.error-msg {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-muted);
  padding: 2rem;
  font-size: 0.95rem;
}

/* ===================================================
   JOKE PAGE
   =================================================== */

.joke-page {
  max-width: 680px;
  margin: 0 auto;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.breadcrumb a {
  color: var(--accent-dark);
}
.breadcrumb a:hover {
  color: var(--accent-darker);
}
.breadcrumb-sep {
  color: var(--border);
}
/* The repeated back link at the foot of a joke page: space it from the content
   above and drop the top margin's bottom gap. */
.breadcrumb-bottom {
  margin-top: 1.75rem;
  margin-bottom: 0;
}

/* Joke article */
.joke-article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  margin-bottom: 1.75rem;
  position: relative;
}

/* Hero number — typewriter / old-press style */
.joke-number-hero {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  border-bottom: 2px solid var(--accent-light);
  padding-bottom: 0.75rem;
  /* subtle typewriter feel */
  font-feature-settings: "tnum";
  text-shadow: 1px 1px 0 var(--accent-light);
}

.joke-body {
  font-size: 1.15rem;
  line-height: 1.9;
  color: var(--ink);
  word-break: break-word;
}

.joke-body p {
  margin: 0 0 0.75em;
}

.joke-body p:last-child {
  margin-bottom: 0;
}

/* Inline footnote superscript */
.fn-ref {
  font-size: 0.65em;
  vertical-align: super;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
  margin-inline-start: 0.05em;
  /* enlarge the tap target without moving the layout (inline vertical
     padding doesn't grow the line box, and there's no background to show) */
  padding: 0.5em 0.25em;
}

.fn-ref:hover {
  text-decoration: underline;
}

/* Inline links from the joke body to a mapped concept (term/place/profession/defect). */
.concept-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px dotted var(--accent-dark);
}
.concept-link:hover {
  color: var(--accent-dark);
  border-bottom-style: solid;
}

/* Popover shown on hover/tap of an inline concept link (concept_tip.js). A term
   shows its gloss; an entity shows its name + an "appears in N jokes" link. A
   single shared element, positioned + viewport-clamped by the script. */
.concept-link { cursor: pointer; }
.concept-pop {
  position: fixed;
  top: 0; left: 0; right: auto;  /* JS sets physical top/left; keep right unset */
  z-index: 1000;
  max-width: min(280px, 78vw);
  background: var(--ink, #2b2b2b);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: right;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  pointer-events: auto;  /* interactive: entity link / term report button */
}
.concept-pop.is-visible { opacity: 1; visibility: visible; }
.concept-pop-name {
  display: block;
  font-weight: 600;
}
.concept-pop-go {
  display: block;
  margin-top: 0.25rem;
  color: var(--accent-light, #e6c07a);
  text-decoration: none;
  font-size: 0.82rem;
}
.concept-pop-go:hover { text-decoration: underline; }
/* Term popover: the gloss, plus a subtle one-tap "report a bad gloss" button. */
.concept-pop-report {
  display: block;
  margin: 0.4rem -0.7rem -0.5rem;  /* bleed to the popover edges */
  padding: 0.3rem 0.7rem;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0 0 8px 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font: inherit;
  font-size: 0.75rem;
  text-align: right;
  cursor: pointer;
}
.concept-pop-report:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, 0.08); }
.concept-pop-report:disabled { cursor: default; color: var(--accent-light, #e6c07a); }

/* Footnotes section at bottom of joke card */
.joke-footnotes {
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Druyanov's original back-matter notes */
.druyanov-section {
  margin: 1.5rem 0;
  background: var(--bg-annot);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.druyanov-note {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ink);
}
/* plaintext: a note paragraph opening with a Cyrillic/Latin bibliographic run
   resolves LTR on its own instead of reordering inside the RTL page (same fix
   as .biblio-item below) */
.druyanov-note p { margin: 0 0 0.7em; unicode-bidi: plaintext; text-align: start; }
.druyanov-note p:last-child { margin-bottom: 0; }
.druyanov-source {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.fn-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fn-item {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-muted);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.fn-num {
  font-size: 0.75em;
  color: var(--accent-dark);
  font-weight: 600;
  flex-shrink: 0;
}

.fn-source-link {
  color: var(--accent);
  text-decoration: none;
}

.fn-source-link:hover {
  text-decoration: underline;
}

/* Inline citation links (footnotes + Druyanov notes), e.g. "ברכות ס, ב". */
.src-link {
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

.src-link:hover {
  border-bottom-style: solid;
}

/* A citation with a verse preview is not a link — it shows the verse in a
   popover, so cue a tooltip rather than navigation. */
.src-verse {
  cursor: help;
}

/* Verse popover for single-verse Tanakh citations (verse-popover.js). */
.verse-popover {
  position: absolute;
  z-index: 50;
  max-width: min(22rem, calc(100vw - 1rem));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem;
  text-align: right;
  direction: rtl;
}
.verse-popover-text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink);
}
.verse-popover-link {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-dark);
}

/* --- Rating section --- */
.rating-section,
.annotation-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

/* Star widget */
.star-widget {
  display: flex;
  flex-direction: row-reverse;  /* RTL: star 5 on right visually */
  gap: 0.15rem;
  margin-bottom: 0.6rem;
}

/* Reverse trick: hover on a star highlights it + all stars to its right (higher values) */
.star-widget {
  direction: ltr;              /* stars laid out LTR so CSS sibling trick works */
  display: inline-flex;
}

.star-btn {
  font-size: 1.9rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--star-empty);
  padding: 0 0.1rem;
  line-height: 1;
  transition: color 0.1s, transform 0.1s;
}
.star-btn:hover,
.star-btn.filled {
  color: var(--star-filled);
}
.star-btn:hover {
  transform: scale(1.15);
}

.rating-summary {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin-top: 0.4rem;
}

/* --- Annotation section --- */
.annotate-btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.3rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.annotate-btn:hover {
  background: #4a2e1f;
}
.annotate-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.annotation-box {
  margin-top: 1rem;
  background: var(--bg-annot);
  border: 1px solid var(--accent-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.annotation-spinner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* CSS spinner */
.spinner {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.annotation-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ink);
}
.annotation-meta {
  margin-top: 0.75em;
  font-size: 0.78rem;
  color: var(--muted, #888);
  opacity: 0.85;
}
.effort-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-inline-end: 0.6em;
  font-size: 0.85rem;
  color: var(--muted, #888);
}
.effort-picker select {
  font: inherit;
  padding: 0.2em 0.4em;
}
.annotation-text p {
  margin: 0 0 0.85em;
}
.annotation-text p:last-child {
  margin-bottom: 0;
}
.annotation-text strong {
  color: var(--accent-dark);
  font-weight: 700;
}
.annotation-text em {
  font-style: italic;
}
.annotation-text h2,
.annotation-text h3 {
  font-size: 1.05rem;
  margin: 1em 0 0.4em;
  color: var(--ink);
}
.annotation-text ul,
.annotation-text ol {
  margin: 0 0 0.85em;
  padding-inline-start: 1.4em;
}
.annotation-text li {
  margin-bottom: 0.25em;
}

/* --- Related jokes (precomputed embedding neighbours) --- */
.related-jokes {
  margin-top: 1.75rem;
}
.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.related-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.15s, background 0.15s;
}
.related-link:hover {
  border-color: var(--accent-dark);
  text-decoration: none;
}
.related-label {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-darker);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
.related-body {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.related-number {
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.related-snippet {
  color: var(--ink-muted);
  font-size: 0.92rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Joke navigation --- */
.joke-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 0.5rem;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent-dark);
  background: var(--bg-card);
  transition: all 0.15s;
  text-align: center;
  min-width: 7rem;
}
.nav-link:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
  color: var(--accent-dark);
}
.nav-link.nav-home {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
  min-width: 5rem;
}
.nav-link.nav-home:hover {
  background: var(--accent-darker);
  border-color: var(--accent-darker);
  color: #fff;
}
.nav-link.disabled {
  opacity: 0;
  pointer-events: none;
}

/* --- Comprehension section --- */
.comprehension-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
}

.comp-ask {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.7rem;
}

.comp-prompt {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.comp-buttons {
  display: inline-flex;
  gap: 0.5rem;
}

.comp-btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.comp-btn.comp-yes:hover {
  border-color: #2d8a4e;
  background: #eaf7ef;
  color: #1a5c33;
}
.comp-btn.comp-no:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
}

.comp-voted {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.comp-stats {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* "Actually I didn't get it on my own" — post-annotation correction */
.comp-recant {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}
.comp-recant-prompt {
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.comp-recant-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-annot);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.comp-recant-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
}
.comp-recant-done {
  font-size: 0.85rem;
  color: #1a5c33;
  font-weight: 700;
}

/* --- Reveal button --- */
.reveal-btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.3rem;
  background: var(--accent-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.reveal-btn:hover {
  background: var(--accent-darker);
}

/* --- Annotation feedback --- */
.annotation-feedback {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--accent-light);
}

.ann-feedback-label {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.ann-rate-btn {
  font-size: 1.1rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.4;
}
.ann-rate-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.ann-report-toggle {
  margin-right: auto;
  font-family: var(--font);
  font-size: 0.78rem;
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.4rem 0.45rem;      /* ≥24px tap target */
  opacity: 0.7;
  transition: opacity 0.12s;
}
.ann-report-toggle:hover { opacity: 1; }

.ann-approve-btn {
  font-family: var(--font);
  font-size: 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: background 0.12s;
}
.ann-approve-btn:hover { background: var(--accent-dark); }
.ann-approve-btn:disabled { opacity: 0.5; cursor: default; }

.ann-approved-label {
  font-size: 0.8rem;
  color: var(--accent-dark);
  font-weight: 700;
}

/* --- Report form --- */
.report-form {
  margin-top: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.report-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.65rem;
}

.report-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  color: var(--ink);
}
.report-reasons label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.report-details {
  width: 100%;
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  resize: vertical;
  direction: rtl;
  margin-bottom: 0.65rem;
}
.report-details:focus {
  outline: none;
  border-color: var(--accent);
}

.report-actions {
  display: flex;
  gap: 0.5rem;
}

.report-submit-btn {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.report-submit-btn:hover { background: #4a2e1f; }

.report-cancel-btn {
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.12s;
}
.report-cancel-btn:hover { border-color: var(--ink-muted); }

.report-sent {
  font-size: 0.88rem;
  color: #2d8a4e;
  font-weight: 700;
  margin-top: 0.5rem;
}

/* Generic "report an error" widget (jokes & entity descriptions) */
.content-report {
  margin-top: 0.75rem;
}
.content-report-toggle {
  font-family: var(--font);
  font-size: 0.8rem;
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.4rem 0.45rem;      /* ≥24px tap target */
  margin-inline-start: -0.15rem;  /* keep the label's visual start edge */
  opacity: 0.75;
  transition: opacity 0.12s;
}
.content-report-toggle:hover { opacity: 1; color: var(--accent-dark); }

/* ── Share joke ─────────────────────────────────────────── */
.joke-share {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0 0.2rem;
}
.share-btn {
  font-family: var(--font);
  font-size: 0.9rem;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.share-btn:hover { background: var(--accent); color: #fff; }
.share-feedback { font-size: 0.85rem; color: var(--ink-muted); }

.content-report-form {
  margin-top: 0.6rem;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.content-report-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.content-report-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  margin-bottom: 0.7rem;
  font-size: 0.88rem;
  color: var(--ink);
}
.content-report-reasons label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.content-report-details {
  width: 100%;
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  resize: vertical;
  direction: rtl;
  margin-bottom: 0.6rem;
}
.content-report-details:focus { outline: none; border-color: var(--accent); }
.content-report-actions { display: flex; gap: 0.5rem; }
.content-report-submit {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.content-report-submit:hover { background: #4a2e1f; }
.content-report-cancel {
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-muted);
  cursor: pointer;
}
.content-report-cancel:hover { border-color: var(--ink-muted); }
.content-report-sent { font-size: 0.88rem; color: #2d8a4e; font-weight: 700; }
.content-report-error { font-size: 0.88rem; color: #b00020; font-weight: 700; }

/* ===================================================
   UTILITY / RESPONSIVE TWEAKS
   =================================================== */

@media (max-width: 480px) {
  .joke-article {
    padding: 1.25rem 1rem;
  }
  .joke-number-hero {
    font-size: 2.5rem;
  }
  .joke-body {
    font-size: 1.05rem;
  }
  .nav-link {
    min-width: auto;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }
  .search-form {
    flex-direction: column;
  }
  .search-btn {
    width: 100%;
  }
}

/* ===================================================
   Admin dashboard
   =================================================== */

.admin-page {
  max-width: 920px;
  margin: 0 auto;
}

.admin-topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* Banner shown when the last Claude API call failed (e.g. budget exhausted). */
.admin-alert {
  background: #fbeaea;
  border: 1px solid #e0a0a0;
  border-inline-start: 4px solid #b00020;
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: #5a1414;
  line-height: 1.6;
}
.admin-alert-time { color: var(--ink-muted); font-size: 0.82rem; }
.admin-alert-note { display: block; color: var(--ink-muted); font-size: 0.8rem; }

/* One-tap deploy button + status readout (admin page). */
.admin-deploy { margin-bottom: 1.5rem; }
.admin-deploy-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.admin-deploy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.admin-deploy-btn:hover { background: var(--accent-dark); }
.admin-deploy-btn:disabled { opacity: 0.55; cursor: progress; }
.admin-deploy-status { font-size: 0.9rem; line-height: 1.5; }
.admin-version {
  font-size: 0.82rem; color: var(--ink-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.admin-deploy-working { color: var(--ink-muted); }
.admin-deploy-ok { color: #1c7c2e; font-weight: 600; }
.admin-deploy-fail { color: #b00020; font-weight: 600; }
.admin-deploy-warn { color: var(--accent-dark); font-weight: 600; }
.admin-deploy-log {
  margin-top: 0.6rem;
  max-height: 16rem;
  overflow: auto;
  background: #1e1e1e;
  color: #e6e6e6;
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 0.78rem;
  line-height: 1.45;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}
.health-report {
  margin-top: 1rem;
  background: #1e1e1e;
  color: #e6e6e6;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.admin-heading {
  font-size: 1.6rem;
  color: var(--ink);
}
.admin-logout {
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* --- Stats cards --- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 0.75rem;
  text-align: center;
}
.stat-card.stat-warn  { border-color: var(--accent); background: #fdf8ec; }
.stat-card.stat-alert { border-color: #c0392b; background: #fdeceb; }
.stat-num {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1.2;
}
.stat-card.stat-alert .stat-num { color: #c0392b; }
.stat-trend { font-size: 0.9rem; font-weight: 700; vertical-align: 0.15em; }
.stat-trend-up   { color: #2e7d32; }
.stat-trend-down { color: #c0392b; }
.stat-trend-flat { color: var(--ink-muted); }
.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

/* --- Sections --- */
.admin-section { margin-bottom: 2rem; }
.admin-subtitle {
  font-size: 1rem;
  color: var(--ink);
  margin: 1.2rem 0 0.6rem;
}
.admin-section-title {
  font-size: 1.15rem;
  color: var(--ink);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.count-pill {
  background: var(--accent-dark);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  min-width: 1.4rem;
  text-align: center;
}
.admin-empty {
  color: var(--ink-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

/* --- Cards (pending annotations + reports) --- */
.admin-list { display: flex; flex-direction: column; gap: 1rem; }
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.admin-card-done { opacity: 0; transform: translateY(-6px); }
.admin-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.admin-joke-link { font-weight: 700; }
.admin-card-meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-inline-start: auto;
}
.admin-snippet {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}
.admin-annotation {
  background: var(--bg-annot);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.7;
}
.admin-annotation :last-child { margin-bottom: 0; }

.admin-card-actions { display: flex; gap: 0.5rem; }
.admin-btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
}
.admin-btn:hover { background: var(--bg-annot); }
.admin-approve { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.admin-approve:hover { background: var(--accent-dark); }
.admin-reject:hover { background: #fdeceb; border-color: #c0392b; color: #c0392b; }
.admin-resolve { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.admin-resolve:hover { background: var(--accent-dark); }

/* --- Reports --- */
.report-reason-tag {
  background: #fdeceb;
  color: #c0392b;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 0.1rem 0.5rem;
}
.admin-report-details {
  background: var(--bg-annot);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
}

/* --- Tables --- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: right;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--bg-annot);
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg-annot); }

.admin-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  .admin-two-col { grid-template-columns: 1fr; }
}

/* Admin: AI generation settings */
.admin-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.settings-field select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  min-width: 12rem;
}
.settings-saved {
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

/* Per-feature AI model settings: stack one row per feature. */
.ai-settings {
  flex-direction: column;
  align-items: stretch;
}
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}
.settings-feature {
  min-width: 9rem;
  align-self: center;
  font-weight: 700;
  color: var(--ink);
}

/* Visitor geography map (admin dashboard; moved from /admin/health). */
.geo-total { font-size: .8rem; font-weight: 400; color: var(--ink-muted); margin-inline-start: .4rem; }
.geo-toggle { display: flex; gap: .4rem; margin-bottom: .7rem; }
.geo-toggle button { font: inherit; font-size: .82rem; padding: .3rem .8rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--ink); }
.geo-toggle button.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
#geo-map { position: relative; background: #f6f1e6; border-radius: var(--radius);
  padding: .5rem; overflow: hidden; }
.geo-svg { display: block; width: 100%; height: auto; }
.geo-country { stroke: #d9cdb4; stroke-width: .3; transition: fill .15s; }
.geo-country:hover { stroke: var(--accent-dark); stroke-width: .8; }
.geo-tip { position: absolute; pointer-events: none; background: #2c1810; color: #f0e6d6;
  font-size: .78rem; padding: .2rem .5rem; border-radius: 6px; white-space: nowrap; z-index: 5; }
.geo-list { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0;
  margin: .8rem 0 0; }
.geo-list li { display: flex; align-items: center; gap: .35rem; background: #fff;
  border: 1px solid var(--border); border-radius: 999px; padding: .2rem .6rem; font-size: .85rem; }
.geo-flag { font-size: 1.05rem; line-height: 1; }
.geo-cc { color: var(--ink-muted); font-size: .78rem; }
.geo-n { font-weight: 700; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.geo-empty { color: var(--ink-muted); }
.geo-us-title { margin: 1.1rem 0 0; font-size: .95rem; color: var(--ink-muted);
  border-top: 1px dashed var(--border); padding-top: .9rem; }
/* Per-IP drill-down under the 24h geo chips (admin only) */
.geo-detail { margin-top: .8rem; font-size: .85rem; }
.geo-detail summary { cursor: pointer; color: var(--accent-dark); font-weight: 600; }
.geo-detail-country { margin: .6rem 0 0; }
.geo-detail-list { list-style: none; padding: 0; margin: .25rem 0 0; }
.geo-detail-list li { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .35rem .6rem; margin-top: .35rem; overflow-x: auto; text-align: left; }
.geo-detail-list mark { background: #f6dfa8; padding: 0 .25em; border-radius: 3px; }
.geo-detail-ua { color: var(--ink-muted); }

/* Chapter listing pages (/chapters → /chapter/…) */
.chapter-joke-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.chapter-joke-link { display: flex; align-items: baseline; gap: .6rem; padding: .5rem .65rem;
  margin-top: .4rem; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit; }
.chapter-joke-link:hover { border-color: var(--accent); }
.chapter-joke-number { font-weight: 700; color: var(--accent-dark);
  font-variant-numeric: tabular-nums; flex-shrink: 0; }
.chapter-joke-snippet { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chapter-nav { margin-top: 1.4rem; }

/* "לאן ממשיכים?" experiment table (admin). */
.slate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.slate-table th,
.slate-table td {
  padding: 0.45rem 0.7rem;
  text-align: start;
  border-bottom: 1px solid var(--border);
}
.slate-table th {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 700;
}
.slate-table tbody tr:first-child .slate-ctr {
  color: var(--accent-dark);
  font-weight: 700;
}

/* Usage meter (Claude API calls + CPU budget). */
.meter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}
.meter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.meter-big {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-dark);
}
.meter-features {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.meter-feature {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  border-top: 1px solid var(--accent-light);
  padding-top: 0.25rem;
}
.meter-muted { color: var(--ink-muted); justify-content: flex-start; }
.meter-note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.5;
}
.meter-bar {
  margin-top: 0.7rem;
  height: 0.7rem;
  background: var(--accent-light);
  border-radius: 999px;
  overflow: hidden;
}
.meter-bar-fill {
  height: 100%;
  background: #1c7c2e;
  transition: width 0.4s ease;
}
.meter-bar-fill.meter-warn { background: var(--accent); }
.meter-bar-fill.meter-danger { background: #b00020; }
.meter-refresh {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-muted);
  user-select: none;
}
.meter-refresh:hover { color: var(--accent); }

/* Annotation generating-state note */
.spinner-line {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-weight: 700;
  color: var(--ink-muted);
}
.spinner-note {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-muted);
  opacity: 0.85;
}

/* ===================================================
   Character / place index
   =================================================== */

/* --- Entity chips (shared: joke page, entity index) --- */
.entity-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.entity-chip:hover { background: var(--bg-annot); border-color: var(--accent); text-decoration: none; }
.entity-chip-place { border-color: #b0c4d8; }
.entity-chip-place:hover { border-color: #6b94bf; }
.entity-chip-animal { border-color: #cdbf9a; }
.entity-chip-animal:hover { border-color: #a98c4f; }
.entity-chip-food { border-color: #d8b79a; }
.entity-chip-food:hover { border-color: #bf8a5f; }
.entity-chip-holiday { border-color: #c3b0d8; }
.entity-chip-holiday:hover { border-color: #9370bf; }
.humor-chip { border-color: var(--accent-light); background: var(--bg-annot); }

/* Glossary of terms */
/* Quick-jump index — all terms as chips at the top */
/* Single-place locator map on the entity page */
.place-map-section { margin: 1.25rem 0 0.5rem; }
.place-map {
  height: 240px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-card);
}
.place-map-caption {
  margin: 0.5rem 0 0; text-align: center;
  font-size: 0.9rem; color: var(--ink-muted);
}
.place-pin { font-size: 1.6rem; line-height: 1; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }

.glossary-count {
  font-size: 0.85rem; color: var(--ink-muted);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.05rem 0.6rem; margin-inline-start: 0.4rem;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* Sticky search + letter nav */
.glossary-controls {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 0.75rem 0 0.6rem;
  margin: 0 0 0.5rem; border-bottom: 1px solid var(--border);
}
.glossary-search {
  width: 100%; box-sizing: border-box;
  font-size: 1rem; font-family: inherit;
  padding: 0.5rem 0.85rem; margin-bottom: 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--ink);
}
.glossary-search:focus { outline: none; border-color: var(--accent); }
.glossary-letters {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.glossary-letter-chip {
  min-width: 1.6rem; text-align: center;
  font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.1rem 0.35rem;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.glossary-letter-chip:hover { background: var(--accent-light); border-color: var(--accent); }

.glossary-section { scroll-margin-top: 7rem; }
.glossary-section-head {
  font-size: 1.5rem; font-weight: 800; color: var(--accent);
  margin: 1.25rem 0 0.25rem; padding-bottom: 0.2rem;
  border-bottom: 2px solid var(--accent-light);
}
.glossary-no-results { color: var(--ink-muted); font-style: italic; margin: 1.5rem 0; }

/* Compact dictionary entries */
.glossary-list { margin: 0; }
.glossary-term {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) 1fr;
  gap: 0.5rem 1.25rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 7rem;
}
.glossary-term[hidden] { display: none; }
.glossary-term:target { background: var(--accent-light); border-radius: var(--radius); padding-inline: 0.75rem; }
.glossary-term-name {
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent-dark); margin: 0;
}
.people-entity-link {
  color: inherit;
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
.people-entity-link:hover { text-decoration: underline solid var(--accent-dark); }
.people-entity-arrow { color: var(--accent); font-size: 0.8em; font-weight: 400; }
.people-wiki-link {
  font-size: 0.72rem; font-weight: 600; color: var(--ink-muted);
  text-decoration: none; margin-inline-start: 0.4rem;
  vertical-align: 0.08em; white-space: nowrap;
}
.people-wiki-link:hover { color: var(--accent-dark); text-decoration: underline; }
.glossary-term-body { margin: 0; }
.glossary-term-explanation { line-height: 1.7; }
.glossary-examples { display: inline; }
.glossary-examples-label {
  font-size: 0.85rem; font-weight: 700; color: var(--ink-muted);
  margin-inline-start: 0.35rem;
}
.glossary-ex-chip {
  display: inline-block;
  font-size: 0.82rem; font-variant-numeric: tabular-nums;
  color: var(--accent-dark); background: var(--bg-annot);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.05rem 0.55rem; margin: 0 0.15rem;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.glossary-ex-chip:hover { background: var(--accent-light); border-color: var(--accent); }
.glossary-usage { font-size: 0.95rem; color: var(--ink-muted); font-style: italic; }

@media (max-width: 560px) {
  .glossary-term { grid-template-columns: 1fr; gap: 0.25rem; }
}
.entity-chip-count {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.02rem 0.45rem;
}

/* --- Inline entities row on the joke page --- */
.entities-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}
.entities-inline-label {
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-weight: 700;
}

/* --- Entity index page --- */
.entities-index-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.entities-index-intro { color: var(--ink-muted); margin-bottom: 1.5rem; }
.entities-group { margin-bottom: 2rem; }
.entities-group-title {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}
.entity-chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Entity detail page --- */
.entity-header {
  text-align: center;
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.entity-type-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  margin-bottom: 0.6rem;
}
.entity-type-place { color: #4a6d8c; background: #e2ecf5; }
.entity-type-food { color: #8a5a2b; background: #f5ead9; }
.entity-type-holiday { color: #6a4a8c; background: #ece2f5; }
.entity-name { font-size: 2rem; line-height: 1.2; }
.entity-aliases { color: var(--ink-muted); font-size: 0.95rem; margin-top: 0.4rem; }
.entity-count { color: var(--ink-muted); font-size: 0.9rem; margin-top: 0.3rem; }

.entity-description {
  background: var(--bg-annot);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

/* Druyanov's own רשימה-ראשונה entry, shown on the figure's entity page */
.druyanov-list-entry {
  background: var(--bg-annot);
  border-right: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}
.druyanov-list-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
}
.druyanov-list-text { margin: 0; }
.druyanov-list-note {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}
.druyanov-list-src { margin: 0.6rem 0 0; font-size: 0.85rem; }
.druyanov-list-src a { color: var(--accent-dark); text-decoration: none; font-weight: 600; }
.druyanov-list-src a:hover { text-decoration: underline; }

/* Druyanov's footnote under a מפתח-האישים entry */
.people-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.65;
}

.entity-wiki { margin: 0.5rem 0 0; font-size: 0.9rem; }
.entity-wiki a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.entity-wiki a:hover { text-decoration: underline; }
.draft-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9a6a00;
  background: #fdf0d0;
  border: 1px dashed #d9a93a;
  border-radius: var(--radius);
  padding: 0.05rem 0.5rem;
  margin-bottom: 0.5rem;
}
.entity-jokes-title { font-size: 1.2rem; margin-bottom: 1rem; }

.index-links { text-align: center; margin: 1rem 0 0.5rem; }
.index-link {
  display: inline-block;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
}
.index-link:hover { background: var(--bg-annot); text-decoration: none; }

/* Surprise / random joke button (חידוד בהפתעה) */
.surprise-btn {
  display: inline-block;
  margin-top: 0.85rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.surprise-btn:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.surprise-again {
  text-align: center;
  margin-top: 1.25rem;
}

/* ===================================================
   Admin — entity description studio
   =================================================== */

.ent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
/* Report-driven studio: manual-pick highlight, picker row, inline reports. */
.ent-card-manual { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dark); }
.studio-picker {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0 0 1.5rem; padding: 0.75rem 0.9rem;
  background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius);
}
.studio-picker .ent-label { margin: 0; }
.studio-pick-input {
  flex: 1 1 12rem; min-width: 8rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--bg);
}
.studio-empty { color: var(--muted); padding: 0.75rem 0; }
.studio-reports {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin: 0.5rem 0 0.75rem; padding: 0.6rem 0.75rem;
  background: rgba(180, 30, 30, 0.06); border-radius: 8px;
}
.studio-report { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.studio-report .admin-report-details { margin: 0; }
.ent-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.ent-name { font-size: 1.1rem; font-weight: 700; }
.ent-count { font-size: 0.85rem; color: var(--ink-muted); }
.ent-status {
  margin-inline-start: auto;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
.ent-status.pending  { background: #fdf0d0; color: #9a6a00; }
.ent-status.approved { background: #e2f0dd; color: #3f7a35; }

.ent-jokes { margin-bottom: 0.8rem; }
.ent-jokes summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-weight: 700;
}
.ent-jokes-list { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; }
.ent-joke {
  font-size: 0.85rem;
  color: var(--ink-muted);
  padding: 0.3rem 0.5rem;
  background: var(--bg-annot);
  border-radius: var(--radius);
}
.ent-joke:hover { color: var(--ink); text-decoration: none; }
.ent-joke-num { font-weight: 700; color: var(--accent-dark); }

.ent-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin: 0.7rem 0 0.25rem;
}
.ent-draft, .ent-instr {
  width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  resize: vertical;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.ent-draft { background: var(--bg-annot); }
.ent-instr:focus, .ent-draft:focus { outline: 2px solid var(--accent-light); border-color: var(--accent); }
.ent-meta { font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.3rem; }
.ent-flags {
  margin: 0.4rem 0 0;
  padding-inline-start: 0;
  list-style: none;
  font-size: 0.83rem;
  color: #9a6a00;
}
.ent-flags li {
  background: #fdf6e6;
  border: 1px dashed #d9a93a;
  border-radius: var(--radius);
  padding: 0.2rem 0.5rem;
  margin-top: 0.25rem;
}
.ent-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.ent-regen { background: var(--accent-light); }
.ent-spinner { font-size: 0.85rem; color: var(--ink-muted); }

/* Header portrait of Druyanov (public-domain photo, Odessa 1909) */
.header-title-flex {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.header-portrait {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
  background: #fff;
}

.admin-topbar-links { display: inline-flex; gap: 0.9rem; align-items: center; margin-inline-start: auto; }

/* Druyanov sticks his tongue out on hover — כיאה לליצן */
.header-portrait-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  line-height: 0;
  cursor: pointer;
}
.portrait-tongue {
  position: absolute;
  left: 42%;
  top: 55%;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transform: translateX(-50%) translateY(-2px) scale(0.2) rotate(-4deg);
  transform-origin: top center;
  transition: opacity 0.12s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
/* Gags are JS-driven (random pick on hover/tap), so a class — not :hover —
   triggers them; :focus-within keeps the tongue reachable by keyboard. */
.header-portrait-wrap:focus-within .portrait-tongue,
.header-portrait-wrap.gag-tongue .portrait-tongue {
  opacity: 1;
  transform: translateX(-50%) translateY(4px) scale(1) rotate(-4deg);
}

/* ─── ARCHIVED gags — NOT shipped (only the tongue is live). The bird and
   Groucho markup is guarded by {% if false %} in base.html and dropped from
   the JS GAGS rotation; this CSS is kept so they can be re-enabled later.
   See docs/portrait-gags.md. ───────────────────────────────────────────── */

/* Gag: a bird flies over Druyanov's head and poops on him. */
.gag-bird-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  pointer-events: none;
}
.gag-bird-layer .bird,
.gag-bird-layer .poop,
.gag-bird-layer .splat {
  position: absolute;
  opacity: 0;
}
.gag-bird-layer .bird  { width: 40px; height: 26px; top: -18px; left: 0; }
.gag-bird-layer .poop  { width: 6px;  height: 8px;  top: -8px;  left: 24px; }
.gag-bird-layer .splat { width: 20px; height: 15px; top: -2px;  left: 19px; }
.gag-bird-layer .wing  { transform-origin: 16px 11px; }

.header-portrait-wrap.gag-bird .bird  { animation: bird-fly 2.9s ease-in-out both; }
.header-portrait-wrap.gag-bird .wing  { animation: bird-flap 0.16s linear infinite; }
.header-portrait-wrap.gag-bird .poop  { animation: bird-poop 2.9s ease-in both; }
.header-portrait-wrap.gag-bird .splat { animation: bird-splat 2.9s ease-out both; }

/* Bird: in from the left, settles over his head, then flaps off to the right. */
@keyframes bird-fly {
  0%   { opacity: 0; transform: translate(-52px, 2px) scaleX(0.9); }
  8%   { opacity: 1; }
  38%  { opacity: 1; transform: translate(16px, -6px) scaleX(1); }
  48%  { transform: translate(21px, -3px); }
  60%  { transform: translate(21px, -3px); }
  92%  { opacity: 1; transform: translate(86px, -10px); }
  100% { opacity: 0; transform: translate(96px, -14px); }
}
@keyframes bird-flap {
  0%, 100% { transform: rotate(-20deg); }
  50%      { transform: rotate(32deg); }
}
/* Poop: held under the bird while it hovers, then drops onto his forehead. */
@keyframes bird-poop {
  0%, 49%  { opacity: 0; transform: translateY(0); }
  50%      { opacity: 1; transform: translateY(0); }
  61%      { opacity: 1; transform: translateY(10px) scaleY(1.25); }
  64%, 100% { opacity: 0; transform: translateY(10px); }
}
/* Splat: blooms on his forehead where the poop lands, then fades. */
@keyframes bird-splat {
  0%, 61%   { opacity: 0; transform: scale(0); }
  66%       { opacity: 1; transform: scale(1.15); }
  72%       { transform: scale(1); }
  88%       { opacity: 1; }
  100%      { opacity: 0; transform: scale(1.1); }
}
/* Respect reduced-motion: keep the gag but skip the wing's rapid flutter. */
@media (prefers-reduced-motion: reduce) {
  .header-portrait-wrap.gag-bird .wing { animation: none; }
}

/* Gag: a Groucho-Marx disguise drops from above onto his face, then falls off. */
.gag-groucho-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  pointer-events: none;
}
.gag-groucho-layer .disguise {
  position: absolute;
  top: 16px;
  left: 12px;
  width: 30px;
  height: auto;
  opacity: 0;
  transform: translateY(-64px);
}
.header-portrait-wrap.gag-groucho .disguise {
  animation: groucho-drop 2.4s cubic-bezier(0.5, 1.3, 0.6, 1) both;
}
@keyframes groucho-drop {
  0%   { opacity: 0; transform: translateY(-64px) rotate(-6deg); }
  8%   { opacity: 1; }
  26%  { transform: translateY(4px)  rotate(2deg); }   /* lands, overshoots */
  34%  { transform: translateY(-3px) rotate(-1deg); }  /* small bounce up */
  42%  { transform: translateY(0)    rotate(0); }      /* settles on his face */
  74%  { opacity: 1; transform: translateY(0) rotate(0); } /* holds */
  100% { opacity: 0; transform: translateY(72px) rotate(14deg); } /* slides off */
}

/* Sort bar on the index page */
.sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.sort-label {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-inline-end: 0.2rem;
}
.sort-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-card);
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sort-btn:hover { border-color: var(--accent); color: var(--ink); }
.sort-btn.active {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent-dark);
}

/* Per-card stats (rating + comprehension) */
.joke-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.joke-stat {
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
.joke-stat-rating { color: var(--accent-dark); font-weight: 700; }

/* Release-version badge in the header */
.version-badge {
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.12em 0.5em;
  border-radius: 999px;
  background: rgba(240, 224, 160, 0.18);
  color: var(--accent-light);
  border: 1px solid var(--accent-dark);
  white-space: nowrap;
}

/* studio: filter toolbar + extra status bands */
.ent-filter { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.ent-filter-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}
.ent-filter-btn.active { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.ent-status.drafted { background: #fdf0d0; color: #9a6a00; }
.ent-status.empty   { background: #ece7df; color: var(--ink-muted); }

.admin-joke-text {
  background: var(--bg-annot);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-top: 0.5rem;
  line-height: 1.7;
  white-space: pre-wrap;
  font-size: 0.95rem;
}
.ann-saved { font-size: 0.85rem; font-weight: 700; color: #3f7a35; }

.entities-rare { margin-top: 1rem; }
.entities-rare summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 0.3rem 0;
}
.entities-rare summary:hover { color: var(--accent-dark); }
.entities-rare .entity-chip-cloud { margin-top: 0.6rem; }
.entity-chip-rare { opacity: 0.7; font-size: 0.82rem; }

.entity-chip-biblical { border-color: #c9b896; background: #f7f1e3; }
.entity-chip-biblical:hover { border-color: var(--accent); }

/* ===== Entity index: lists + world map ===== */
.entity-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem;
}
@media (min-width: 560px) { .entity-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) { .entity-list { grid-template-columns: 1fr 1fr 1fr; } }
.entity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.32rem 0.55rem;
  border-radius: var(--radius);
  transition: background 0.12s;
}
.entity-row:hover { background: var(--bg-annot); }
.entity-row a { color: var(--ink); font-weight: 500; }
.entity-row a:hover { color: var(--accent-dark); text-decoration: none; }
.entity-row-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg-annot);
  border-radius: 999px;
  padding: 0.02rem 0.5rem;
  flex-shrink: 0;
}

.places-map-section {
  margin: 0.5rem 0 1.5rem;
}
.places-map-title {
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.places-map {
  height: 460px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  z-index: 0;
}

/* Map place search / autocomplete */
.map-search-wrap { position: relative; max-width: 26rem; margin-bottom: 0.6rem; }
.map-search-input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
}
.map-search-input:focus { outline: none; border-color: var(--accent); }
.map-search-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 500;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  max-height: 18rem;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.map-search-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.map-search-item.active,
.map-search-item:hover { background: var(--accent-light); }
.map-search-name { font-weight: 700; color: var(--ink); }
.map-search-sub { font-size: 0.78rem; color: var(--ink-muted); flex: 1; }
.map-search-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  margin-inline-start: auto;
}

/* Body-map of defects (מומים) */
.body-map-wrap {
  margin: 0.5rem 0 1.25rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.body-map-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}
.body-maps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem 2rem;
  margin-bottom: 0.5rem;
}
.body-map {
  position: relative;
}
.body-map-head { width: 150px; aspect-ratio: 100 / 110; }
.body-map-body { width: 170px; aspect-ratio: 100 / 115; }
.body-figure {
  width: 100%;
  height: 100%;
  display: block;
}
.body-figure circle, .body-figure rect, .body-figure ellipse {
  fill: var(--accent-light);
  stroke: var(--accent);
  stroke-width: 1.2;
}
.body-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0.35rem;
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s, background 0.12s;
  white-space: nowrap;
}
.body-marker:hover { background: var(--accent-light); }
.body-marker.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
  transform: translate(-50%, -50%) scale(1.1);
}
.body-marker-count {
  font-weight: 700;
  color: var(--accent-dark);
}
.body-marker.active .body-marker-count { color: #fff; }
.body-map-panels {
  min-height: 2.4rem;
  text-align: center;
}
.body-map-hint { font-size: 0.82rem; color: var(--ink-muted); }
.body-region-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.body-region-label {
  font-weight: 700;
  color: var(--ink);
  margin-inline-end: 0.3rem;
}
.body-defect-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.12s, background 0.12s;
}
.body-defect-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
  color: var(--ink);
}
.body-defect-count { font-size: 0.75rem; color: var(--ink-muted); }
.map-dot span {
  display: block;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  opacity: 0.85;
}
.map-joke span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.map-popup { text-align: right; direction: rtl; font-family: var(--font); }
.map-popup-sub { font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.15rem; }
.map-popup-quip {
  font-size: 0.82rem;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
  color: var(--accent-dark);
}

.map-flag span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  width: 30px;
  height: 30px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* About / disclaimers page */
.about-page { max-width: 720px; margin: 0 auto; }
.about-title { font-size: 1.6rem; margin-bottom: 1rem; }
.about-section { margin-bottom: 1.5rem; }
.about-section h3 {
  font-size: 1.1rem;
  color: var(--accent-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
  margin-bottom: 0.6rem;
}
.about-section p, .about-section li { line-height: 1.8; }
.about-section ul { padding-inline-start: 1.2rem; }
.about-asis { font-size: 0.85rem; color: var(--ink-muted); font-style: italic; }

/* Front-matter prose pages (author preface). */
.prose-page { max-width: 720px; margin: 0 auto; }
.prose-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.prose-part-indicator {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 1.25rem;
}
.prose-body {
  font-size: 1.02rem;
  line-height: 1.9;
  color: var(--ink);
}
.prose-body p { margin: 0 0 1em; text-align: justify; }
.prose-body p:last-child { margin-bottom: 0; }

/* Closing essay (לסיום) — the author's signed colophon, set apart from the body. */
.prose-signature {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: start;           /* RTL: hugs the right margin like a signature */
  color: var(--ink-muted);
  font-style: italic;
  line-height: 1.6;
}
.prose-signature-line { margin: 0.15rem 0; }
.prose-signature-line:first-child {   /* the signed name */
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  font-size: 1.05rem;
}
.prose-signature-line:last-child {    /* „על ערש דוי‟ — his parting words */
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Preface link at the head of the table of contents. */
.toc-chapter-intro .toc-chapter-name { font-weight: 700; color: var(--accent-dark); }

.ai-note {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.5rem;
  opacity: 0.85;
}
.footer-links { margin-top: 0.3rem; }
.footer-sep { margin: 0 0.4rem; opacity: 0.5; }

/* Search autocomplete dropdown */
.ac-wrap { position: relative; }
.ac-box {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 50;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 340px;
  overflow-y: auto;
}
.ac-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--accent-light);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover,
.ac-item.ac-active { background: var(--accent-light); }
.ac-ic { font-size: 1.05rem; line-height: 1; }
.ac-label { flex: 1; color: var(--ink); }
.ac-group {
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05em 0.55em;
  white-space: nowrap;
}

/* Entity index: collapsible category sections + capped scrolling lists so all
   categories are visible on landing instead of one endless list. */
details.entities-group { margin-bottom: 1.25rem; }
summary.entities-group-title {
  cursor: pointer;
  list-style: none;
}
summary.entities-group-title::-webkit-details-marker { display: none; }
summary.entities-group-title::after {
  content: "▾";
  margin-inline-start: auto;
  font-size: 0.72em;
  color: var(--ink-muted);
}
details.entities-group:not([open]) > summary.entities-group-title::after { content: "◂"; }
/* rolling window — a long category scrolls inside a bounded box */
.entities-group .entity-list {
  max-height: 300px;
  overflow-y: auto;
  padding-inline-end: 0.3rem;
}
.entities-group .entity-list::-webkit-scrollbar { width: 8px; }
.entities-group .entity-list::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px;
}

/* ===================================================
   "Find me a joke" (RAG) page
   =================================================== */
.ask-page { max-width: 720px; margin: 0 auto; }
.ask-kind { font-weight: 700; color: var(--accent-dark); margin: 0 0 .5rem; font-size: .95rem; }
.ask-mode { display: inline-flex; gap: 0.3rem; background: var(--bg-annot);
  border-radius: 999px; padding: 0.25rem; margin-bottom: 1rem; }
.ask-mode-btn { font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: none; background: transparent; color: var(--ink-muted);
  padding: 0.4rem 0.9rem; border-radius: 999px; transition: background .15s, color .15s; }
.ask-mode-btn.active { background: var(--accent-dark); color: #fff; }
.ask-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.ask-intro { color: var(--ink-muted); margin-bottom: 1.25rem; }
.ask-ai-note { color: var(--ink-muted); font-size: 0.82rem; margin: -0.75rem 0 1.25rem; }
.ask-ai-note a { color: inherit; text-decoration: underline; }
.ask-form { display: flex; flex-direction: column; gap: 0.6rem; }
.ask-input {
  width: 100%;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.6;
  padding: 0.8rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  resize: vertical;
}
.ask-input:focus { outline: none; border-color: var(--accent); }
.ask-btn {
  align-self: flex-start;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  background: var(--accent-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.ask-btn:hover { background: var(--accent-darker); }
.ask-btn:disabled { opacity: 0.6; cursor: default; }

.ask-examples {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
  margin: 1rem 0 0.5rem; font-size: 0.85rem; color: var(--ink-muted);
}
.ask-chip {
  font-family: var(--font); font-size: 0.82rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; color: var(--ink);
}
.ask-chip:hover { background: var(--bg-annot); border-color: var(--accent); }

.ask-status { margin: 1.25rem 0; color: var(--ink-muted); font-size: 0.95rem; }
.ask-results { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.ask-match {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.ask-match-top { border-color: var(--accent); border-width: 2px; }
.ask-match-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.ask-badge {
  font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 0.1rem 0.6rem;
}
.ask-match-num { font-weight: 700; margin-inline-start: auto; }
.ask-match-reason {
  background: var(--bg-annot); border-radius: var(--radius);
  padding: 0.5rem 0.75rem; margin-bottom: 0.6rem; font-size: 0.95rem;
}
.ask-match-text { line-height: 1.75; white-space: pre-wrap; }
.ask-match-chapter { display: block; margin-top: 0.5rem; font-size: 0.8rem; color: var(--ink-muted); }

/* ===================================================
   Druyanov-bot chat
   =================================================== */
.chat-page { max-width: 720px; margin: 0 auto; }
.chat-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.chat-intro { color: var(--ink-muted); margin-bottom: 1rem; }
.chat-log {
  display: flex; flex-direction: column; gap: 0.7rem;
  min-height: 260px; max-height: 60vh; overflow-y: auto;
  padding: 1rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.8rem;
}
.chat-msg { max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 14px; line-height: 1.7; }
.chat-user {
  align-self: flex-start; background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-user a { color: #fff; text-decoration: underline; }
.chat-bot {
  align-self: flex-end; background: var(--bg-annot); color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.chat-chip {
  font-family: var(--font); font-size: 0.8rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; color: var(--ink);
}
.chat-chip:hover { background: #fff; border-color: var(--accent); }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-input {
  flex: 1; font-family: var(--font); font-size: 1rem; line-height: 1.5;
  padding: 0.6rem 0.85rem; border: 2px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card); color: var(--ink);
  resize: none; max-height: 140px;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send {
  font-family: var(--font); font-weight: 700; padding: 0.6rem 1.1rem;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
}
.chat-send:hover { background: var(--accent-dark); }
.chat-send:disabled { opacity: 0.6; cursor: default; }
/* typing dots */
.chat-typing span {
  display: inline-block; width: 7px; height: 7px; margin: 0 1px;
  background: var(--ink-muted); border-radius: 50%; opacity: 0.4;
  animation: chatblink 1.2s infinite both;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatblink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
.chat-quote {
  display: block;
  border-inline-start: 3px solid var(--accent);
  padding: 0.15rem 0.6rem; margin: 0.3rem 0;
  color: var(--ink-muted); font-style: italic;
}

/* ===================================================
   Joke generator
   =================================================== */
.gen-page { max-width: 720px; margin: 0 auto; }
.gen-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.gen-intro { color: var(--ink-muted); margin-bottom: 0.4rem; }
.gen-disclaimer {
  font-size: 0.82rem; color: #9a6a00; background: #fdf6e6;
  border: 1px dashed #d9a93a; border-radius: var(--radius);
  padding: 0.4rem 0.7rem; margin-bottom: 1.1rem;
}
.gen-form { display: flex; gap: 0.5rem; }
.gen-input {
  flex: 1; font-family: var(--font); font-size: 1.05rem; padding: 0.7rem 1rem;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--ink);
}
.gen-input:focus { outline: none; border-color: var(--accent); }
.gen-btn {
  font-family: var(--font); font-weight: 700; padding: 0.7rem 1.3rem; white-space: nowrap;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
}
.gen-btn:hover { background: var(--accent-dark); }
.gen-btn:disabled { opacity: 0.6; cursor: default; }
.gen-examples {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
  margin: 0.8rem 0; font-size: 0.85rem; color: var(--ink-muted);
}
.gen-chip {
  font-family: var(--font); font-size: 0.82rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.7rem;
  cursor: pointer; color: var(--ink);
}
.gen-chip:hover { background: var(--bg-annot); border-color: var(--accent); }
.gen-status { margin: 1.25rem 0; color: var(--ink-muted); }
.gen-result { margin-top: 1.25rem; }
.gen-card {
  background: var(--bg-card); border: 2px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.3rem;
}
.gen-joke { font-size: 1.15rem; line-height: 1.9; white-space: pre-wrap; }
.gen-card-note { font-size: 0.78rem; color: var(--ink-muted); margin-top: 0.9rem; }
.gen-inspired { font-size: 0.85rem; color: var(--ink-muted); margin-top: 0.3rem; }
.gen-again {
  margin-top: 1rem; font-family: var(--font); font-weight: 700; font-size: 0.9rem;
  background: var(--bg-annot); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.45rem 1rem; cursor: pointer;
}
.gen-again:hover { background: var(--accent-light); }

/* ===================================================
   Quiz — real or AI?
   =================================================== */
.quiz-page { max-width: 640px; margin: 0 auto; }
.quiz-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
.quiz-intro { color: var(--ink-muted); margin-bottom: 1rem; }
.quiz-score {
  display: inline-block; font-weight: 700; font-size: 0.9rem;
  background: var(--bg-annot); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.3rem 0.9rem; margin-bottom: 1rem;
}
.quiz-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.5rem;
}
.quiz-joke { font-size: 1.2rem; line-height: 1.95; min-height: 5rem; white-space: pre-wrap; }
.quiz-actions { display: flex; gap: 0.7rem; margin-top: 1.4rem; }
.quiz-guess {
  flex: 1; font-family: var(--font); font-weight: 700; font-size: 1rem;
  padding: 0.8rem 0.6rem; border-radius: var(--radius); cursor: pointer;
  border: 2px solid var(--border); background: var(--bg-card); color: var(--ink);
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.quiz-guess:hover { transform: translateY(-1px); border-color: var(--accent); background: var(--bg-annot); }
.quiz-result {
  margin-top: 1.3rem; padding: 0.8rem 1rem; border-radius: var(--radius);
  font-size: 1.02rem; line-height: 1.7;
}
.quiz-correct { background: #e7f6ec; border: 1px solid #57b87a; }
.quiz-wrong   { background: #fdecec; border: 1px solid #d9736f; }
.quiz-next {
  margin-top: 1.1rem; font-family: var(--font); font-weight: 700; font-size: 0.95rem;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 0.6rem 1.3rem; cursor: pointer;
}
.quiz-next:hover { background: var(--accent-dark); }

.quiz-report-row { margin-top: 0.9rem; }
.quiz-report {
  font-family: var(--font); font-size: 0.8rem;
  background: none; border: none; color: var(--ink-muted);
  cursor: pointer; padding: 0.2rem 0.3rem; opacity: 0.8;
}
.quiz-report:hover { opacity: 1; color: var(--accent-dark); }
.quiz-report-sent { font-size: 0.82rem; color: #2d8a4e; font-weight: 700; }

/* ===================================================
   Home onboarding guide — "איך מתחילים?" hero
   =================================================== */
.start-guide { margin: 0.25rem 0 1.75rem; }
.start-title { font-size: 1.7rem; margin: 0 0 0.35rem; }
.start-sub { color: var(--ink-muted); line-height: 1.6; margin: 0 0 1.4rem; max-width: 60ch; }
.start-paths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
.start-path {
  position: relative;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1.35rem 1.1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.start-path-num {
  position: absolute; top: -0.75rem; inset-inline-start: 1.1rem;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
}
.start-path-icon { font-size: 1.7rem; line-height: 1; }
.start-path-title { font-size: 1.08rem; font-weight: 700; margin: 0; }
.start-path-text { font-size: 0.9rem; color: var(--ink-muted); line-height: 1.6; margin: 0; flex: 1; }
.start-path-btn {
  align-self: flex-start; margin-top: 0.35rem;
  font-family: var(--font); font-size: 0.92rem; font-weight: 700;
  padding: 0.55rem 1.1rem;
  background: var(--accent-dark); color: #fff;
  border: none; border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, transform 0.08s;
}
.start-path-btn:hover { background: var(--accent-darker); transform: translateY(-1px); }
.start-jump {
  margin-top: 0.85rem; padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
}
.start-jump-label { display: block; font-size: 0.8rem; color: var(--ink-muted); margin-bottom: 0.4rem; }
.start-jump-row { display: flex; gap: 0.4rem; }
.start-jump-input {
  flex: 1; min-width: 0;
  font-family: var(--font); font-size: 0.92rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--ink);
}
.start-jump-input:focus { outline: none; border-color: var(--accent); }
.start-jump-btn {
  font-family: var(--font); font-size: 0.9rem; font-weight: 700;
  padding: 0.45rem 0.9rem;
  background: var(--bg-annot); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.start-jump-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.index-page.searching .start-guide { display: none; }

@media (max-width: 640px) {
  .start-paths { grid-template-columns: 1fr; }
  .start-title { font-size: 1.45rem; }
}

/* ===================================================
   Home top section — categorized nav (גלו / צרו)
   =================================================== */
.home-nav { display: flex; flex-direction: column; gap: 1.1rem; margin: 1.25rem 0; }
.home-nav-label {
  font-size: 0.82rem; font-weight: 700; color: var(--ink-muted);
  margin: 0 0 0.5rem; letter-spacing: 0.01em;
}
.home-nav-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.home-card {
  display: flex; flex-direction: column; gap: 0.12rem;
  padding: 0.7rem 0.85rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
  transition: border-color 0.15s, transform 0.08s, background 0.15s;
}
.home-card:hover { border-color: var(--accent); background: var(--bg-annot); transform: translateY(-1px); }
.home-card-icon { font-size: 1.2rem; line-height: 1.2; }
.home-card-title { font-weight: 700; font-size: 0.92rem; }
.home-card-sub { font-size: 0.76rem; color: var(--ink-muted); }

/* Search mode: collapse browse chrome so results sit right under the box. */
.index-page.searching .home-nav,
.index-page.searching .surprise-btn,
.index-page.searching .toc,
.index-page.searching .sort-bar { display: none; }

.clear-search-btn {
  font-family: var(--font); font-size: 0.8rem; cursor: pointer;
  background: var(--bg-annot); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.12rem 0.7rem; margin-inline-start: 0.5rem; color: var(--ink);
}
.clear-search-btn:hover { border-color: var(--accent); }

@media (max-width: 560px) {
  .home-nav-cards { grid-template-columns: 1fr 1fr; }
}

/* ===================================================
   Home — category cover-flow carousel (גלו לפי קטגוריה)
   Surfaces every entity group on the home page so readers discover
   מומים / בעלי-מקצוע without opening the index first.
   =================================================== */
.cat-carousel-section { margin: 1.5rem 0; text-align: center; }
.cat-carousel-title {
  font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 0 0 0.15rem;
}
.cat-carousel-sub { font-size: 0.82rem; color: var(--ink-muted); margin: 0 0 0.8rem; }

.cat-carousel-viewport { position: relative; }

/* Rebuilt as a plain native-snap shelf after repeated iPhone flicker: no
   clones, no JS-driven classes, no transforms/transitions on the scroll
   path — nothing left that CAN flicker. The browser owns the scrolling. */
.cat-carousel-track {
  display: flex; gap: 0.6rem;
  overflow-x: auto; scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* room so the first/last card can sit dead-centre */
  padding: 0.5rem calc(50% - 100px) 1rem;
}
.cat-carousel-track::-webkit-scrollbar { display: none; }

.cat-card {
  flex: 0 0 200px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 1.1rem 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
  /* the card is one big link — iOS flashes its grey tap-highlight over the
     whole card on every touch (reads as the card flickering); disable it */
  -webkit-tap-highlight-color: transparent;
}
.cat-nav { -webkit-tap-highlight-color: transparent; }
.cat-card-emoji { font-size: 2.1rem; line-height: 1.1; }
.cat-card-label { font-weight: 700; font-size: 1.05rem; }
.cat-card-count {
  font-size: 0.78rem; color: var(--accent-dark); font-weight: 600;
  background: var(--accent-light); border-radius: 999px; padding: 0.05rem 0.6rem;
}
.cat-card-sub {
  font-size: 0.8rem; color: var(--ink-muted); line-height: 1.35;
  min-height: 2.1em;
}
.cat-card-cta {
  font-size: 0.82rem; font-weight: 700; color: var(--accent-dark);
  margin-top: 0.15rem;
}

.cat-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 2; width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-card); color: var(--accent-dark);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cat-nav:hover { border-color: var(--accent); background: var(--accent-light); }
.cat-nav-prev { left: 2px; }
.cat-nav-next { right: 2px; }

.index-page.searching .cat-carousel-section { display: none; }

/* On touch devices you swipe the shelf, so the ‹ › arrows are redundant. */
@media (pointer: coarse) {
  .cat-nav { display: none; }
}
/* From tablet/desktop up, drop the scroller: lay every category out as a
   centered wrapping grid (fills the 900px content instead of leaving the
   snap-centering padding as white space) — nothing to scroll, no arrows. */
@media (min-width: 640px) {
  .cat-carousel-track {
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
    scroll-snap-type: none;
    padding-inline: 0;
  }
  .cat-nav { display: none; }
}


/* Always-visible free-text search, sitting just under the carousel. */
.home-search { margin: 0 0 1.4rem; }

@media (max-width: 560px) {
  .cat-card { flex-basis: 170px; }
  .cat-carousel-track { padding-inline: calc(50% - 85px); }
}

/* ── הורדת משלב — modern-Hebrew rewrite, side-by-side ───── */
.register-bar { margin: 0 0 0.75rem; }
.register-toggle {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--bg-annot);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.register-toggle:hover { background: var(--accent-light); border-color: var(--accent); }

.register-col-label {
  display: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.joke-cols.cols-split { display: flex; gap: 1.5rem; align-items: flex-start; }
.joke-cols.cols-split .joke-col { flex: 1 1 0; min-width: 0; }
.joke-cols.cols-split .register-col-label { display: block; }

.joke-col-modern { border-inline-start: 3px solid var(--accent-light); padding-inline-start: 1rem; }

@media (max-width: 640px) {
  .joke-cols.cols-split { flex-direction: column; gap: 1rem; }
  .joke-cols.cols-split .joke-col-modern {
    border-inline-start: none;
    border-top: 1px solid var(--border);
    padding-inline-start: 0;
    padding-top: 1rem;
  }
}

/* ── Homepage: situational search as the default; literal search secondary ── */
.search-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 1rem;
  margin-top: 1rem;
}
.link-btn {
  font: inherit;
  font-size: 0.9rem;
  background: none;
  border: none;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem;
}
.link-btn:hover { color: var(--accent); }
/* On the homepage the ask box is the hero — give it a little breathing room. */
.index-page .search-section { margin-bottom: 1.5rem; }
.index-page .ask-results:not(:empty) { margin-top: 1.25rem; }

/* ── Situational-search results: shorter text + clear "read more" ────────── */
.ask-more-btn {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  background: var(--accent-dark);
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  text-decoration: none;
}
.ask-more-btn:hover { background: var(--accent-darker); text-decoration: none; }
.ask-new { display: inline-block; margin-bottom: 0.75rem; }
/* fun fact rotating in the loading state */
.ask-fact {
  display: block;
  margin-top: 0.6rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
}
.ask-how {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent-dark);
  font-size: 0.82rem;
  text-decoration: none;
}
.ask-how:hover { text-decoration: underline; }

/* ── Joke page: small number at the top, right (RTL), like the print book ── */
.joke-number-book {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink-muted);
  text-align: start;
  letter-spacing: 0.03em;
  margin-bottom: 0.6rem;
}

/* ── Footer general "report an error" ───────────────────────────────────── */
.content-report-general {
  margin: 0.9rem auto 0;
  max-width: 420px;
}
.footer-report-toggle {
  background: none;
  border: none;
  color: #9e8870;
  text-decoration: underline;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem;
}
.footer-report-toggle:hover { color: var(--accent); }
.content-report-general .content-report-form {
  text-align: start;
  margin-top: 0.6rem;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
}

/* persons-index dates */
.people-dates { color: var(--muted, #8a7a66); font-weight: 400; font-size: 0.88em; }

/* Visually hidden, still read by screen readers (e.g. the joke page's
   orientation heading) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── 404 / 500 error pages ─────────────────────────────── */
.not-found {
  max-width: 480px;
  margin: 3rem auto 4rem;
  padding: 0 1rem;
  text-align: center;
}
.not-found-number {
  font-size: 5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 1px 0 var(--accent-light);
  border-bottom: 2px solid var(--accent-light);
  display: inline-block;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}
.not-found-msg {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.not-found-sub {
  font-size: 0.95rem;
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
}
.btn-back {
  display: inline-block;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  background: var(--accent-dark);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s;
}
.btn-back:hover {
  background: var(--accent-darker);
  color: #fff;
  text-decoration: none;
}

/* bibliography / sources page */
.biblio-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.biblio-item { padding: 0.35rem 0.2rem; border-bottom: 1px solid rgba(120,90,50,0.10); line-height: 1.55; unicode-bidi: plaintext; text-align: start; }
.biblio-contributors { line-height: 2.1; unicode-bidi: plaintext; }
