/* ============================================================
   Pi-Search · style.css
   Minimalist tabbed interface · matches the ELS tool palette.
   ============================================================ */
:root {
  --bg:        #0b1020;
  --bg-soft:   #131a32;
  --panel:     #1a2448;
  --panel-2:   #202a52;
  --line:      rgba(246, 196, 83, 0.10);
  --line-2:    rgba(255, 255, 255, 0.06);

  --gold:      #f6c453;
  --gold-soft: rgba(246, 196, 83, 0.18);
  --gold-dim:  #c79a37;

  --text:      #ecedf2;          /* ~16.7:1 on --bg — primary text */
  --text-2:    #d6dbec;          /* ~13.2:1 on --bg — bumped from #c9cee0 for body values on panel */
  --muted:     #95a1ba;          /* ~7.4:1 on --bg — bumped from #7d8aa3, now passes AA on --panel */
  --muted-2:   #7e88a3;          /* ~5.5:1 on --bg — bumped from #59617a (was failing at ~2.9:1) */

  --success:   #7fce9f;

  --serif:     "Frank Ruhl Libre", Georgia, "Times New Roman", serif;
  --sans:      "Heebo", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:      "JetBrains Mono", "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius:    14px;
  --radius-sm: 8px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* =========================================================
   Lang-conditional visibility — for cases where EN vs HE need
   structurally different markup (not just swapped text).
   ========================================================= */
html[dir="ltr"] .lang-he { display: none; }
html[dir="rtl"] .lang-en { display: none; }

/* In RTL, body-prose paragraphs should justify cleanly to both edges */
html[dir="rtl"] .about-section p,
html[dir="rtl"] .archive-deck,
html[dir="rtl"] .archive-collection p,
html[dir="rtl"] .archive-promise-text p,
html[dir="rtl"] .gloss-defn,
html[dir="rtl"] details.faq .faq-body p,
html[dir="rtl"] .prob-caveat-body,
html[dir="rtl"] .finding-note,
html[dir="rtl"] .about-tagline {
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
}

/* =========================================================
   Info-button + popover system — used anywhere the tool needs
   to explain itself (next to form titles, etc.)
   ========================================================= */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  background: rgba(246,196,83,0.12);
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 12px; font-weight: 500; line-height: 1;
  cursor: pointer;
  margin: 0 2px;
  padding: 0;
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
              border-color 0.15s var(--ease), transform 0.1s var(--ease),
              box-shadow 0.2s var(--ease);
  vertical-align: middle;
  flex-shrink: 0;
}
.info-btn:hover {
  background: var(--gold); color: var(--bg);
  border-color: var(--gold);
  transform: scale(1.10);
  box-shadow: 0 4px 12px -4px rgba(246,196,83,0.45);
}
.info-btn:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.info-pop {
  position: absolute;
  background: var(--panel-2);
  border: 1px solid var(--gold-soft);
  border-radius: 10px;
  padding: 14px 16px;
  max-width: 320px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(246,196,83,0.05);
  z-index: 100;
  animation: info-pop-in 0.18s var(--ease);
}
@keyframes info-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.info-pop::before {
  content: "";
  position: absolute;
  top: -7px; left: 50%;
  width: 12px; height: 12px;
  background: var(--panel-2);
  border-left: 1px solid var(--gold-soft);
  border-top: 1px solid var(--gold-soft);
  transform: translateX(-50%) rotate(45deg);
}
.info-pop-text {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0.005em;
}
html[dir="rtl"] .info-pop-text { letter-spacing: 0; font-size: 13.5px; line-height: 1.75; }
/* RTL: the arrow indicator stays centered (works for either dir) */

/* Inline form-validation: empty required field + form-level hint message */
.qform-input.is-error,
.qform-input.is-error:focus {
  border-color: #e57777;
  background: rgba(229,119,119,0.06);
  animation: shake 0.32s var(--ease);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.qform-hint {
  display: none;
  margin-top: 4px;
  padding: 9px 12px;
  background: rgba(229,119,119,0.08);
  border-left: 2px solid #e57777;
  border-radius: 4px;
  font-family: var(--sans); font-size: 12px;
  color: var(--text); line-height: 1.55;
  letter-spacing: 0.01em;
  animation: hint-in 0.18s var(--ease);
}
html[dir="rtl"] .qform-hint {
  border-left: none; border-right: 2px solid #e57777;
  font-size: 12.5px;
}
.qform-hint.is-visible { display: block; }
@keyframes hint-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Make qform titles inline-flex so the title text + info button align nicely */
.qform-title {
  display: inline-flex; align-items: center; gap: 4px;
}

/* =========================================================
   RTL (Hebrew) overrides — applied when html[dir="rtl"]
   ========================================================= */
html[dir="rtl"] body {
  /* Heebo is excellent for Hebrew; serif (Frank Ruhl Libre) also supports Hebrew. */
  font-family: var(--sans);
}
html[dir="rtl"] .brand-text-link { align-items: flex-end; }
html[dir="rtl"] .brand-tfv { letter-spacing: 0.04em; }      /* tight letter-spacing on uppercase doesn't apply to Hebrew */
html[dir="rtl"] .tab,
html[dir="rtl"] .qform-label,
html[dir="rtl"] .a-label,
html[dir="rtl"] .qform-note,
html[dir="rtl"] .array-row-label,
html[dir="rtl"] .array-grid-head { letter-spacing: 0; }
html[dir="rtl"] .a-label { text-align: left; }
html[dir="rtl"] .tab-link::after { content: "↖"; }           /* outbound arrow mirrors */
html[dir="rtl"] .back-btn { direction: rtl; }
html[dir="rtl"] .search-input { text-align: right; }
html[dir="rtl"] .search-input::placeholder { text-align: right; }
html[dir="rtl"] .qform-input { text-align: right; }
/* Digits and monospace stay LTR even in RTL pages — numbers read the same direction. */
html[dir="rtl"] .digit-row,
html[dir="rtl"] .pos-pill,
html[dir="rtl"] .array-row-digits,
html[dir="rtl"] .a-val,
html[dir="rtl"] .array-sum-value,
html[dir="rtl"] .code-block { direction: ltr; text-align: left; unicode-bidi: isolate; }
html[dir="rtl"] .array-row { direction: ltr; }
html[dir="rtl"] .array-row .array-row-label { direction: ltr; }

body {
  background: radial-gradient(ellipse at 50% -10%, #182246 0%, var(--bg) 65%) fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100svh;
  display: flex; flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* RTL Hebrew weight discipline — Hebrew letterforms render heavier; using
   bold on Hebrew muddies the type. Lean on size and color for emphasis. */
html[dir="rtl"] strong, html[dir="rtl"] b { font-weight: 500; }
html[dir="rtl"] .lede { font-weight: 300; }
html[dir="rtl"] .qform-title { font-weight: 500; }

a { color: var(--gold); text-decoration: underline; text-decoration-color: var(--gold-soft); text-underline-offset: 3px; }
a:hover { color: var(--gold-dim); }

/* Selection */
::selection { background: rgba(246,196,83,0.25); color: var(--text); }

/* Global scrollbar — subtle, on-brand */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(246,196,83,0.20); background-clip: padding-box; }

/* Focus visible — accessibility on all interactive elements */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, input:focus-visible { outline-offset: 3px; }

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.topbar-divider {
  display: inline-block;
  width: 1px; height: 20px;
  background: var(--line-2);
  margin: 0 4px;
}
.brand-logo-link {
  display: inline-flex; align-items: center;
  text-decoration: none; color: inherit;
  border-radius: 8px;
  transition: opacity 0.15s var(--ease), transform 0.1s var(--ease);
}
.brand-text-link {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  text-decoration: none; color: inherit;
  border-radius: 8px;
  line-height: 1.15;
  transition: opacity 0.15s var(--ease), transform 0.1s var(--ease);
}
.brand-logo-link:hover, .brand-text-link:hover { opacity: 0.92; }
.brand-logo-link:active, .brand-text-link:active { transform: scale(0.98); }
.brand-logo {
  height: 44px; width: auto; display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(246,196,83,0.18));
}
.brand-tool {
  font-family: var(--serif); font-size: 19px; font-weight: 500;
  color: var(--text); letter-spacing: -0.005em;
  line-height: 1.15;
}
html[dir="rtl"] .brand-tool {
  font-size: 20px; font-weight: 500;
  letter-spacing: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-tfv  {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 3px;
}
html[dir="rtl"] .brand-tfv {
  font-size: 11.5px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-top: 4px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.topbar-link  { color: var(--muted); text-decoration: none; padding: 6px 10px; font-size: 13px; border-radius: 999px; border: 1px solid transparent; transition: color 0.2s var(--ease), border-color 0.2s var(--ease); }
.topbar-link:hover { color: var(--gold); border-color: var(--gold-soft); }
.status {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--muted); padding: 4px 10px 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.03); margin-right: 6px;
}
.status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--success); box-shadow: 0 0 8px rgba(127,206,159,0.5); }
.status[data-state="searching"] .status-dot { background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="error"]    .status-dot { background: #e57777; }
@keyframes pulse { 50% { opacity: 0.35; } }
.lang-toggle, .icon-btn {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; padding: 6px 10px;
  border-radius: 999px; cursor: pointer;
  font-family: var(--sans); font-size: 13px; letter-spacing: 0.04em;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.icon-btn { padding: 6px; display: inline-flex; align-items: center; justify-content: center; }
.lang-toggle:hover, .icon-btn:hover {
  color: var(--gold); background: rgba(246,196,83,0.06); border-color: var(--gold-soft);
}

/* כניסה / Sign-in button — primary CTA for unauthenticated visitors. */
.login-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(246, 196, 83, 0.10);
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.1s var(--ease);
}
.login-btn:hover {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  box-shadow: 0 6px 20px -8px rgba(246,196,83,0.5);
}
.login-btn:active { transform: scale(0.97); }
.login-btn[hidden] { display: none !important; }
/* Flip the "enter" arrow in RTL so it points toward the reading direction */
html[dir="rtl"] .login-btn svg { transform: scaleX(-1); }

/* User avatar — visible when authenticated; replaces the login button. */
.user-avatar {
  width: 38px; height: 38px; border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 16px; font-weight: 500;
  border: 1px solid var(--gold);
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.18);
}
.user-avatar[hidden] { display: none !important; }

/* =========================================================
   TABS
   ========================================================= */
.tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,16,32,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 65px; z-index: 20;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent; border: 1px solid transparent;
  color: var(--muted); padding: 7px 16px; border-radius: 999px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer; white-space: nowrap;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
html[dir="rtl"] .tab { letter-spacing: 0.01em; font-size: 13.5px; }
.tab:hover:not(:disabled) { color: var(--gold); background: rgba(246,196,83,0.05); }
.tab[aria-selected="true"] {
  background: var(--gold); color: var(--bg); font-weight: 600; border-color: var(--gold);
  box-shadow: 0 4px 14px -6px rgba(246,196,83,0.55);
}
html[dir="rtl"] .tab[aria-selected="true"] { font-weight: 500; }
.tab:disabled { opacity: 0.32; cursor: not-allowed; }
/* Tab-styled outbound link (About page navigates away). */
.tab-link { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.tab-link::after { content: "↗"; font-size: 11px; opacity: 0.7; }
/* Tab-link in selected state (about.html active "About" tab) — match .tab[aria-selected] */
.tab-link[aria-selected="true"],
.tab-link[aria-current="page"] {
  background: var(--gold) !important;
  color: var(--bg) !important;
  font-weight: 600;
  border-color: var(--gold) !important;
  box-shadow: 0 4px 14px -6px rgba(246,196,83,0.55);
}
.tab-link[aria-selected="true"]::after,
.tab-link[aria-current="page"]::after { opacity: 1; color: var(--bg); }
html[dir="rtl"] .tab-link[aria-selected="true"],
html[dir="rtl"] .tab-link[aria-current="page"] { font-weight: 500; }
.tab-spacer { flex: 1; }
.tab-context {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  padding: 4px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
  letter-spacing: 0.02em;
  opacity: 0.88;
  transition: opacity 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.tab-context:hover { opacity: 1; border-color: var(--gold-soft); color: var(--muted); }
.tab-context:empty { display: none; }

/* =========================================================
   TAB PANELS
   ========================================================= */
.tab-panel {
  flex: 1;
  padding: 0 28px 60px;
  animation: tab-in 0.24s var(--ease);
}
@keyframes tab-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   HERO + SEARCH (Search tab)
   ========================================================= */
.hero {
  width: 100%; max-width: 800px; margin: 0 auto;
  padding-top: 8vh;
  display: flex; flex-direction: column; gap: 28px;
}
.lede {
  margin: 0; text-align: center;
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1.05; letter-spacing: -0.015em; color: var(--text);
}
.lede em {
  font-style: italic; color: var(--gold); font-weight: 400;
  /* slight visual lift on the π so it reads as the symbol it is */
  text-shadow: 0 0 28px rgba(246,196,83,0.25);
  padding: 0 0.04em;
}
.lede-sub {
  display: block; margin-top: 22px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 400;
  letter-spacing: 0.16em; color: var(--muted);
  text-transform: uppercase;
}
html[dir="rtl"] .lede-sub {
  text-transform: none; letter-spacing: 0.04em; font-size: 14.5px;
}

.search {
  display: flex; align-items: stretch;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 5px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.3s var(--ease);
}
.search:hover { border-color: rgba(246,196,83,0.18); }
.search:focus-within {
  border-color: var(--gold-soft); background: var(--panel);
  box-shadow: 0 18px 60px -30px rgba(246,196,83,0.3), 0 0 0 4px rgba(246,196,83,0.06);
}
.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); padding: 18px 22px;
  font-family: var(--mono); font-size: 17px; letter-spacing: 0.01em;
  min-width: 0;
}
.search-input::placeholder { color: var(--muted-2); font-family: var(--sans); font-weight: 300; font-size: 15.5px; }
.search-go {
  background: var(--gold); color: var(--bg); border: none;
  border-radius: calc(var(--radius) - 5px); width: 58px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s var(--ease), transform 0.1s var(--ease);
  flex-shrink: 0;
}
.search-go:hover { background: var(--gold-dim); }
.search-go:active { transform: scale(0.96); }
/* Flip the arrow in RTL — it should point in the reading direction */
html[dir="rtl"] .search-go svg { transform: scaleX(-1); }

.hints {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 12px; font-size: 12.5px; color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: -8px;
}
.hint     { color: var(--muted); }
.hint-sep { color: var(--muted-2); }

.row-toggles {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin-top: 4px;
}
.seg {
  display: inline-flex;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.seg-opt {
  appearance: none; background: transparent; border: none;
  color: var(--text-2); padding: 8px 14px;
  border-radius: calc(var(--radius-sm) - 3px);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer; line-height: 1.2; letter-spacing: 0.02em;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.seg-opt:hover:not([aria-checked="true"]) { color: var(--gold); }
.seg-opt small {
  font-weight: 400; font-size: 10.5px; color: var(--muted-2);
  letter-spacing: 0.06em; margin-top: 3px; text-transform: uppercase;
}
html[dir="rtl"] .seg-opt small { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.seg-opt[aria-checked="true"] {
  background: var(--gold); color: var(--bg);
  box-shadow: 0 2px 8px -2px rgba(246,196,83,0.4);
}
.seg-opt[aria-checked="true"] small { color: rgba(11,16,32,0.7); }
.seg-compact .seg-opt { padding: 6px 12px; flex-direction: row; }

.cta-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding-top: 24px; margin-top: 6px;
  border-top: 1px dashed var(--line-2);
}

/* =========================================================
   QUICK STRUCTURED FORMS — so users don't have to guess syntax.
   Three cards, equal height, each with: title · field group · note · CTA.
   ========================================================= */
.quick-forms {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.qform {
  background: linear-gradient(180deg, var(--bg-soft), rgba(19,26,50,0.55));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  display: flex; flex-direction: column; gap: 16px;
  transition: border-color 0.22s var(--ease), background 0.22s var(--ease), box-shadow 0.3s var(--ease), transform 0.18s var(--ease);
  min-height: 310px;
  position: relative;
}
.qform:hover {
  border-color: rgba(246,196,83,0.22);
  transform: translateY(-1px);
  box-shadow: 0 10px 28px -22px rgba(246,196,83,0.20);
}
.qform:focus-within {
  border-color: var(--gold-soft);
  background: linear-gradient(180deg, var(--panel), rgba(26,36,72,0.72));
  box-shadow: 0 18px 48px -26px rgba(246,196,83,0.4), 0 0 0 1px rgba(246,196,83,0.06);
  transform: translateY(-1px);
}
.qform-title {
  margin: 0;
  font-family: var(--serif); font-size: 17.5px;
  color: var(--gold); font-weight: 500;
  letter-spacing: 0.005em; line-height: 1.25;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  gap: 6px;
}
.qform-title > span:first-child { flex: 0 1 auto; }
html[dir="rtl"] .qform-title { font-size: 18.5px; }

/* The field group (rows of label+input). Pushes note + CTA to the bottom. */
.qform-fields {
  display: flex; flex-direction: column; gap: 12px;
}

.qform-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* qform-row-stack: a label-above-input pair.  Stacking vertically lets
   labels of different widths (e.g. "חלון של" vs "ספרות מסתכמות ל-")
   coexist without alignment issues.  Each pair occupies its own row. */
.qform-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-wrap: nowrap;
}
.qform-row-stack .qform-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
  line-height: 1;
}
html[dir="rtl"] .qform-row-stack .qform-label {
  text-transform: none;             /* Hebrew has no concept of uppercase */
  letter-spacing: 0;
  font-size: 12.5px;
  font-weight: 400;
}
.qform-row-stack .qform-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}
.qform-label {
  font-size: 12px; color: var(--muted); letter-spacing: 0.04em;
  font-family: var(--sans);
}
.qform-input {
  background: rgba(0,0,0,0.22); border: 1px solid var(--line-2);
  border-radius: 8px; color: var(--text);
  padding: 11px 14px; font-family: var(--mono); font-size: 15px;
  flex: 1; min-width: 70px;
  letter-spacing: 0.01em;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.qform-input-small { max-width: 90px; flex: 0 0 90px; }
.qform-input:hover { border-color: rgba(246,196,83,0.22); }
.qform-input:focus {
  outline: none; border-color: var(--gold-soft);
  background: rgba(0,0,0,0.32);
  box-shadow: 0 0 0 3px rgba(246,196,83,0.08);
}
.qform-input::placeholder { color: var(--muted-2); font-weight: 300; }
/* Remove number-input spinners — they don't add value here and disrupt rhythm */
.qform-input[type="number"]::-webkit-outer-spin-button,
.qform-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.qform-input[type="number"] { -moz-appearance: textfield; }

/* Note + CTA live together at the bottom of the card, pinned via margin-top: auto */
.qform-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding-top: 6px;
}
.qform-note {
  font-size: 11.5px; color: var(--muted);
  letter-spacing: 0.01em; line-height: 1.6;
  margin: 0;
  padding-top: 2px;
  border-top: 1px dashed rgba(246,196,83,0.08);
  padding-top: 12px;
}
html[dir="rtl"] .qform-note { font-size: 12.5px; line-height: 1.75; }

.qform-go {
  background: rgba(246,196,83,0.10);
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer; align-self: stretch;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
              border-color 0.2s var(--ease), transform 0.1s var(--ease),
              box-shadow 0.25s var(--ease);
}
html[dir="rtl"] .qform-go { letter-spacing: 0.01em; font-size: 14.5px; font-weight: 500; }
.qform-go:hover {
  background: var(--gold); color: var(--bg);
  border-color: var(--gold);
  box-shadow: 0 8px 22px -10px rgba(246,196,83,0.55);
}
.qform-go:active { transform: scale(0.98); }
.qform-go:focus-visible { outline-offset: 3px; }
/* When the form is focused, the CTA pre-lights to suggest "press me next" */
.qform:focus-within .qform-go {
  background: rgba(246,196,83,0.16);
  border-color: rgba(246,196,83,0.40);
}

@media (max-width: 920px) { .quick-forms { grid-template-columns: 1fr; } .qform { min-height: 0; } }
.ghost-btn {
  background: transparent; border: 1px solid var(--line);
  color: var(--text); padding: 16px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 14px;
  cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}
html[dir="rtl"] .ghost-btn { text-align: right; }
.ghost-btn strong { font-weight: 500; }
.ghost-btn small {
  color: var(--muted); font-size: 12px; font-weight: 400;
  letter-spacing: 0.01em;
}
.ghost-btn:hover { border-color: var(--gold-soft); background: rgba(246,196,83,0.05); }
.ghost-btn:active { transform: scale(0.99); }
.ghost-btn.small { padding: 8px 14px; font-size: 13px; gap: 2px; }
.ghost-prominent {
  background: rgba(246,196,83,0.05);
  border-color: var(--gold-soft);
}
.ghost-prominent strong { color: var(--gold); font-weight: 500; }
.ghost-prominent:hover { background: rgba(246,196,83,0.10); border-color: var(--gold); }

.footnotes {
  max-width: 800px; margin: 72px auto 0;
  padding-top: 28px; border-top: 1px solid var(--line-2);
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted); text-align: center;
  letter-spacing: 0.01em; line-height: 1.7;
}
html[dir="rtl"] .footnotes { font-size: 12.5px; }
.footnotes a { color: var(--muted); text-decoration-color: var(--line); }
.footnotes a:hover { color: var(--gold); text-decoration-color: var(--gold-soft); }

/* =========================================================
   RESULTS TAB
   ========================================================= */
.results-wrap {
  max-width: 980px; margin: 0 auto; padding-top: 34px;
}
.results-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding-bottom: 20px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line-2);
}
.results-query {
  font-family: var(--serif); font-size: 32px; font-weight: 400;
  color: var(--text); margin: 0; letter-spacing: -0.015em;
  line-height: 1.15;
}
.results-note {
  font-family: var(--sans); font-size: 12.5px;
  color: var(--text-2); line-height: 1.65;
  background: linear-gradient(180deg, rgba(246, 196, 83, 0.06), rgba(246, 196, 83, 0.03));
  border-left: 2px solid var(--gold);
  padding: 12px 16px;
  border-radius: 4px;
  margin: 0 0 22px 0;
  letter-spacing: 0.01em;
}
html[dir="rtl"] .results-note {
  border-left: none; border-right: 2px solid var(--gold);
  font-size: 13px; line-height: 1.75;
}
.results-note em {
  color: var(--gold); font-style: normal; font-weight: 500;
  font-family: var(--serif);
}
.results-meta {
  font-family: var(--sans); font-size: 13px; color: var(--muted);
  margin: 8px 0 0 0; letter-spacing: 0.03em;
}
.results-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.results-body { display: flex; flex-direction: column; gap: 14px; }

.result-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
}
.result-table thead th {
  font-family: var(--sans); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); text-align: left; padding: 10px 12px;
  border-bottom: 1px dashed var(--line-2);
}
html[dir="rtl"] .result-table thead th {
  text-transform: none; letter-spacing: 0.02em; font-size: 12.5px; font-weight: 500;
  text-align: right;
}
.result-row { transition: background 0.15s var(--ease); cursor: pointer; }
.result-row:hover { background: rgba(246,196,83,0.05); }
.result-row:hover .pos-pill {
  background: rgba(246,196,83,0.14); border-color: var(--gold);
}
.result-table td { padding: 17px 12px; vertical-align: middle; border-bottom: 1px solid var(--line-2); }
.t-rank { width: 36px; color: var(--muted-2); font-family: var(--mono); font-size: 13px; }
.t-pos  { width: 130px; }
.pos-pill {
  display: inline-block; padding: 5px 13px;
  background: rgba(246,196,83,0.08); border: 1px solid var(--gold-soft);
  border-radius: 999px; font-family: var(--mono); font-size: 14px;
  color: var(--gold); letter-spacing: 0.02em;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
  font-weight: 500;
}
.t-context { font-family: var(--mono); font-size: 14px; color: var(--text-2); max-width: 1px; }
.digit-row { display: inline-block; max-width: 100%; white-space: nowrap; overflow-x: auto; padding-bottom: 2px; }
.digit-row::-webkit-scrollbar { height: 4px; }
.digit-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.ctx-before, .ctx-after { color: var(--muted); }
.ell { color: var(--muted-2); padding: 0 4px; }
.hit-mark {
  color: var(--gold);
  background: rgba(246,196,83,0.16);
  padding: 2px 7px; border-radius: 4px; font-weight: 600;
  border: 1px solid var(--gold-soft);
  text-shadow: 0 0 12px rgba(246,196,83,0.30);
}
.t-action { width: 160px; text-align: right; color: var(--muted-2); font-size: 12px; }
.t-action-btns { display: inline-flex; gap: 6px; justify-content: flex-end; }
.row-mini-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px;
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.04em;
  cursor: pointer; white-space: nowrap;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.row-mini-btn:hover { color: var(--gold); border-color: var(--gold-soft); background: rgba(246,196,83,0.04); }

.empty {
  text-align: center; padding: 36px 16px;
  color: var(--muted); font-family: var(--serif);
  font-size: 18px; font-style: italic;
}
.error-query {
  text-align: center; padding: 18px 16px 8px;
  color: var(--text-2); font-family: var(--serif);
  font-size: 17px; letter-spacing: 0.01em;
}
.error-query strong { color: var(--gold); font-weight: 500; }
.error {
  text-align: center; padding: 24px 16px;
  color: #e57777; font-family: var(--sans);
  font-size: 14px;
}

/* gematria result card (Hebrew lookup) */
.gematria-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.gem-block { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--bg-soft); border-radius: var(--radius-sm); border: 1px solid var(--line-2); }
.gem-label { font-size: 11px; color: var(--muted); letter-spacing: 0.10em; text-transform: uppercase; }
.gem-value { font-family: var(--serif); font-size: 42px; color: var(--gold); line-height: 1; font-weight: 400; }
.gem-action { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--sans); font-size: 13px; align-self: flex-start; }
.gem-action:hover { border-color: var(--gold-soft); color: var(--gold); }

/* =========================================================
   RANGE SUM CARD — three-column scannable layout
   ========================================================= */
.sumcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px;
  display: flex; flex-direction: column;
}
.sumcard-head {
  font-family: var(--serif); font-size: 22px; color: var(--text);
  margin-bottom: 12px; padding-bottom: 14px;
  border-bottom: 1px dashed var(--line-2);
  letter-spacing: -0.005em; line-height: 1.2;
}
.sumcard-row {
  display: grid; grid-template-columns: 170px 130px 1fr;
  gap: 22px; align-items: start;
  padding: 18px 0; border-bottom: 1px solid var(--line-2);
}
.sumcard-row:last-child { border-bottom: none; }
.sumcard-label {
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--text-2); letter-spacing: 0.02em;
  line-height: 1.4; padding-top: 4px;
}
.sumcard-sublabel { font-size: 11px; color: var(--muted-2); font-weight: 400; letter-spacing: 0.04em; }
.sumcard-value {
  font-family: var(--mono); font-size: 28px;
  color: var(--gold); font-weight: 500;
  line-height: 1; padding-top: 2px;
}
.sumcard-meaning {}  /* container; inline component carries its own style */

@media (max-width: 720px) {
  .sumcard-row { grid-template-columns: 1fr; gap: 8px; padding: 14px 0; }
  .sumcard-value { font-size: 24px; }
}

/* =========================================================
   TFV CANONICAL INLINE ANNOTATION
   Sits beside a value in a row. Tag + Hebrew + English on one
   line; optional verse block underneath. Bold + gold for the
   meaningful bits, never sprawling.
   ========================================================= */
.tfv-inline {
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(246,196,83,0.05);
  border-left: 2px solid var(--gold);
  border-radius: 4px;
  padding: 10px 14px;
}
.tfv-inline-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 10px;
}
.tfv-tag {
  display: inline-block;
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--bg); background: var(--gold);
  padding: 3px 8px; border-radius: 4px;
  flex-shrink: 0; line-height: 1.4;
}
html[dir="rtl"] .tfv-tag { letter-spacing: 0.04em; }
.tfv-tag-sgv { background: rgba(246,196,83,0.18); color: var(--gold); border: 1px solid var(--gold-soft); }
.tfv-tag-ordinal { background: var(--panel-2); color: var(--muted-2); border: 1px solid var(--line); }
.tfv-tag-computed { background: var(--panel-2); color: var(--muted-2); border: 1px solid var(--line); }
.tfv-hebrew {
  font-family: var(--serif); font-size: 22px;
  color: var(--gold); font-weight: 500;
  line-height: 1.2;
}
.tfv-translit {
  font-family: var(--serif); font-size: 15.5px;
  color: var(--text); font-style: italic;
  line-height: 1.45;
}
.tfv-meaning {
  font-family: var(--serif); font-size: 16px;
  color: var(--text); font-weight: 400; line-height: 1.5;
}

.tfv-verse {
  display: flex; flex-direction: column; gap: 5px;
  margin-top: 4px; padding: 10px 14px;
  background: rgba(0,0,0,0.22);
  border-left: 2px solid var(--gold-soft);
  border-radius: 4px;
}
.tfv-verse-he {
  font-family: var(--serif); font-size: 19px;
  color: var(--gold); font-weight: 400;
  direction: rtl; line-height: 1.7;
}
.tfv-verse-en {
  font-family: var(--serif); font-size: 14.5px;
  color: var(--text-2); font-style: italic;
  line-height: 1.55;
}
.tfv-verse-role {
  font-family: var(--sans); font-size: 11.5px;
  color: var(--muted); letter-spacing: 0.04em;
  margin-top: 4px; line-height: 1.6;
}

/* Analyzer panel — show the canonical inline annotation at the top */
.analysis .tfv-inline { margin-bottom: 14px; }

/* Sum card actions row — no longer used for range sum (auto-opens array)
   but retained for potential reuse by sum-window result actions. */
.sumcard-actions {
  display: flex; justify-content: flex-end;
  padding-top: 14px; margin-top: 4px;
  border-top: 1px dashed var(--line-2);
}

/* =========================================================
   OPEN ARRAY VIEW · the digit-grid view in Detail tab
   ========================================================= */
.array-head {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 18px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line-2);
}
.array-title {
  font-family: var(--serif); font-size: clamp(28px, 4vw, 36px);
  color: var(--gold); font-weight: 400; line-height: 1.1;
  letter-spacing: -0.005em;
}
.array-subtitle { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }

.array-sums {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 22px;
}
.array-sum {
  padding: 20px 22px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 8px;
}
.array-sum-titlewrap { display: flex; flex-direction: column; gap: 2px; }
.array-sum-label {
  font-family: var(--serif); font-size: 18px;
  color: var(--text); font-weight: 500; letter-spacing: -0.005em;
}
.array-sum-explanation {
  font-family: var(--sans); font-size: 12.5px;
  color: var(--muted); letter-spacing: 0.02em;
  font-style: italic; line-height: 1.4;
}
.array-sum-formula {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted-2); letter-spacing: 0.04em;
  margin-top: -4px;
}
.array-sum-value {
  font-family: var(--mono); font-size: 30px; color: var(--gold);
  font-weight: 500; line-height: 1; margin: 6px 0 0;
}
.array-sum-meta .array-sum-value { color: var(--text); }
.array-sum .tfv-inline { margin: 4px 0; padding: 8px 10px; }
.array-sum .tfv-hebrew { font-size: 17px; }
.array-sum .tfv-translit, .array-sum .tfv-meaning { font-size: 13px; }
.array-sum .tfv-tag { font-size: 9px; padding: 2px 7px; }

/* Sum of Thousands shown nested inside its parent sum card */
.array-sum-derived {
  margin-top: 8px; padding: 10px 12px;
  background: rgba(0,0,0,0.18);
  border-left: 2px solid var(--gold-soft);
  border-radius: 4px;
  display: flex; flex-direction: column; gap: 6px;
}
.array-sum-derived-label {
  font-family: var(--sans); font-size: 11px;
  color: var(--muted); letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 500;
}
.array-sum-derived-value {
  font-family: var(--mono); font-size: 18px;
  color: var(--gold); font-weight: 500; line-height: 1;
}
.array-sum-derived .tfv-inline { margin: 4px 0 0; padding: 6px 10px; }

@media (max-width: 900px) { .array-sums { grid-template-columns: 1fr; } }

.array-grid-wrap {
  background: var(--bg-soft); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 22px 24px;
}
.array-grid-head {
  font-family: var(--sans); font-size: 12px; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 14px; font-weight: 500;
}
.array-grid {
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--mono);
}
.array-row {
  display: grid; grid-template-columns: 72px 1fr;
  gap: 16px; align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}
.array-row:hover { background: rgba(246,196,83,0.03); }
.array-row-label {
  font-size: 12px; color: var(--muted);
  text-align: right; letter-spacing: 0.04em;
  font-family: var(--mono);
}
.array-row-digits {
  display: flex; gap: 3px; flex-wrap: wrap;
}
.array-digit {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  font-size: 14.5px; color: var(--text);
  font-family: var(--mono); font-weight: 400;
  border-radius: 3px;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.array-digit:hover { background: rgba(246,196,83,0.15); color: var(--gold); cursor: pointer; }
.array-digit.selected {
  background: var(--gold); color: var(--bg);
  font-weight: 500;
  box-shadow: 0 0 0 2px rgba(246,196,83,0.4);
}
.array-pos-display {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-2); letter-spacing: 0.04em;
  text-transform: none;
}
.array-pos-display strong { color: var(--gold); font-weight: 500; }

/* Hit highlight (used when Detail tab shows a substring hit in the grid) */
.array-digit-hit {
  background: rgba(246, 196, 83, 0.30);
  color: var(--gold);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--gold-soft);
}

/* Show more / show less controls inside the array grid */
.array-expand-controls {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px dashed var(--line-2);
}

/* Per-position analyses below the digit grid */
.array-analyses { margin-top: 30px; }
.array-analyses-head {
  margin: 0 0 14px 0;
  font-family: var(--serif); font-weight: 500; font-size: 22px;
  color: var(--gold);
}
.array-analyses-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
}
.array-analysis-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.array-analysis-card-head {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 14px; border-bottom: 1px dashed var(--line);
}
.array-analysis-card-eyebrow {
  font-family: var(--sans); font-size: 11px;
  color: var(--gold-dim); letter-spacing: 0.14em;
  text-transform: uppercase; font-weight: 600;
}
html[dir="rtl"] .array-analysis-card-eyebrow { text-transform: none; letter-spacing: 0.02em; font-size: 13px; font-weight: 500; }
.array-analysis-card-num {
  font-family: var(--serif); font-size: 38px;
  color: var(--gold); font-weight: 400; line-height: 1;
  letter-spacing: -0.015em;
}

@media (max-width: 800px) {
  .array-analyses-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .array-sums { grid-template-columns: 1fr; }
  .array-row { grid-template-columns: 56px 1fr; gap: 10px; }
  .array-digit { width: 20px; height: 20px; font-size: 13px; }
  .array-analysis-card { padding: 18px 18px; }
  .array-analysis-card-num { font-size: 30px; }
  .a-label { min-width: 90px; font-size: 11.5px; }
  .a-val { font-size: 13.5px; }
}

/* =========================================================
   DETAIL TAB
   ========================================================= */
.detail-wrap {
  max-width: 980px; margin: 0 auto; padding-top: 28px;
  display: flex; flex-direction: column; gap: 24px;
}
.back-btn { align-self: flex-start; }
.detail-head {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 22px; border-bottom: 1px solid var(--line-2);
}
.detail-position {
  font-family: var(--serif); font-size: clamp(44px, 6vw, 56px); color: var(--gold);
  font-weight: 300; line-height: 1; letter-spacing: -0.025em;
  text-shadow: 0 0 36px rgba(246,196,83,0.18);
  /* digits stay LTR even on RTL pages */
  direction: ltr; unicode-bidi: isolate;
}
html[dir="rtl"] .detail-position { text-align: right; }
.detail-subtitle {
  font-family: var(--sans); font-size: 11.5px; color: var(--gold-dim);
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600;
  margin-bottom: 2px;
}
html[dir="rtl"] .detail-subtitle {
  text-transform: none; letter-spacing: 0.03em; font-size: 13px; font-weight: 500;
}
.detail-digits {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  font-family: var(--mono); font-size: 15.5px; line-height: 1.7;
  color: var(--text-2); word-break: break-all;
}
.detail-digits .hit-mark { font-size: inherit; }
.detail-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.analysis {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
}
.analysis-head {
  font-family: var(--serif); font-size: 20px; color: var(--text);
  margin: 0 0 14px 0; padding-bottom: 10px; border-bottom: 1px dashed var(--line-2);
}
.analysis-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 32px; }
.a-line {
  display: grid; grid-template-columns: 110px 1fr;
  align-items: baseline; gap: 12px; padding: 4px 0;
  min-width: 0;
}
.a-line-wide { grid-column: 1 / -1; align-items: flex-start; padding-top: 8px; }
.a-line-wide .a-val { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.a-label {
  font-size: 11.5px; letter-spacing: 0.06em; color: var(--muted);
  text-transform: lowercase; font-weight: 500;
  text-align: right; line-height: 1.4;
  white-space: nowrap;
}
html[dir="rtl"] .a-label { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 400; }
.a-val {
  font-family: var(--mono); font-size: 14.5px; color: var(--text);
  line-height: 1.4; min-width: 0;
  word-break: break-word;
}
.a-val strong { color: var(--gold); font-weight: 500; font-family: var(--serif); }
.a-val em     { color: var(--gold); font-style: normal; font-family: var(--serif); }
.a-tfv .a-val { font-size: 15px; }
.a-chip {
  display: inline-block;
  padding: 4px 11px;
  font-family: var(--mono); font-size: 13px;
  background: rgba(246,196,83,0.10);
  border: 1px solid var(--gold-soft);
  border-radius: 6px;
  color: var(--text);
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.a-chip:hover {
  background: rgba(246,196,83,0.16);
  border-color: var(--gold);
  color: var(--gold);
}
.a-aside {
  color: var(--muted); font-family: var(--sans);
  font-size: 11px; letter-spacing: 0.04em;
  margin-left: 6px;
}

/* =========================================================
   PROBABILITY TAB
   ========================================================= */
.probability-wrap {
  max-width: 980px; margin: 0 auto; padding-top: 24px;
  display: flex; flex-direction: column; gap: 22px;
}
.prob-head {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line-2);
}
.prob-title {
  font-family: var(--serif); font-size: clamp(28px, 4vw, 38px);
  color: var(--text); font-weight: 400; letter-spacing: -0.01em;
}
.prob-title em { color: var(--gold); font-style: normal; }
.prob-subtitle {
  font-family: var(--sans); font-size: 14px; color: var(--muted);
  letter-spacing: 0.03em;
}

.prob-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.prob-card h3 {
  margin: 0; font-family: var(--serif); font-size: 19px;
  color: var(--gold); font-weight: 500;
}
.prob-card p { margin: 0; color: var(--text-2); line-height: 1.7; font-size: 14.5px; }
.prob-card p.muted { color: var(--muted); font-size: 13px; }

.prob-stat { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: baseline; padding: 6px 0; }
.prob-stat-label { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); text-transform: lowercase; }
.prob-stat-value { font-family: var(--mono); font-size: 16px; color: var(--text); }
.prob-stat-value strong { color: var(--gold); font-weight: 500; }

/* live Monte Carlo card */
.mc-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.mc-trials-select {
  background: var(--bg-soft); border: 1px solid var(--line-2);
  color: var(--text); padding: 8px 10px; border-radius: 6px;
  font-family: var(--mono); font-size: 13px;
}
.mc-trials-select:focus { outline: none; border-color: var(--gold-soft); }
.mc-run-btn {
  background: var(--gold); color: var(--bg); border: none;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; letter-spacing: 0.03em;
  transition: background 0.2s var(--ease), transform 0.1s var(--ease);
}
.mc-run-btn:hover { background: var(--gold-dim); }
.mc-run-btn:active { transform: scale(0.97); }
.mc-run-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.mc-stop-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--sans); font-size: 13px;
}
.mc-stop-btn:hover { color: var(--gold); border-color: var(--gold-soft); }
.mc-stop-btn[hidden] { display: none !important; }

.mc-progress {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; background: var(--bg-soft);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
}
.mc-progress-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 14px; font-family: var(--mono);
}
.mc-counter { display: flex; flex-direction: column; gap: 4px; }
.mc-counter-label { font-size: 11px; letter-spacing: 0.08em; color: var(--muted-2); text-transform: uppercase; font-family: var(--sans); }
.mc-counter-value { font-size: 22px; color: var(--gold); font-weight: 500; }
.mc-bar {
  width: 100%; height: 6px; background: rgba(255,255,255,0.05);
  border-radius: 999px; overflow: hidden;
}
.mc-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  width: 0%; transition: width 0.25s var(--ease);
  box-shadow: 0 0 12px rgba(246,196,83,0.4);
}
.mc-logo {
  width: 32px; height: 32px;
  animation: load-rotate 8s linear infinite;
}
.mc-logo[hidden] { display: none !important; }
.mc-status-line { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }

/* caveats / notes */
.prob-caveats { display: flex; flex-direction: column; gap: 10px; }
.prob-caveat {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border-left: 2px solid var(--gold-soft);
  border-radius: var(--radius-sm);
}
.prob-caveat-icon {
  width: 28px; height: 28px; border-radius: 999px;
  background: rgba(246,196,83,0.10);
  color: var(--gold); font-family: var(--serif);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; font-weight: 500;
}
.prob-caveat-body { font-size: 13.5px; color: var(--text-2); line-height: 1.65; }
.prob-caveat-body strong { color: var(--gold); }

.prob-learn-more {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--gold); text-decoration: none;
  font-size: 14px;
  border: 1px solid var(--gold-soft); padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  align-self: flex-start;
}
.prob-learn-more:hover { background: var(--gold); color: var(--bg); }

/* =========================================================
   ARCHIVE TAB
   ========================================================= */
.archive-wrap {
  max-width: 920px; margin: 0 auto; padding: 48px 0 80px;
  display: flex; flex-direction: column; gap: 36px;
}
.archive-eyebrow {
  font-family: var(--sans); font-size: 12px;
  color: var(--gold-dim); letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 600;
}
html[dir="rtl"] .archive-eyebrow {
  text-transform: none; letter-spacing: 0.04em; font-size: 13.5px; font-weight: 500;
}
.archive-title {
  margin: 0; font-family: var(--serif); font-weight: 300;
  font-size: clamp(34px, 5vw, 50px); line-height: 1.05;
  letter-spacing: -0.02em; color: var(--text);
}
.archive-title em { font-style: italic; color: var(--gold); font-weight: 400; }
.archive-deck {
  margin: 0; font-family: var(--serif); font-size: clamp(17px, 2.2vw, 21px);
  color: var(--text-2); line-height: 1.6; max-width: 720px;
}

.archive-collections {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  margin-top: 12px;
}
.archive-collection {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px 28px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
}
.archive-collection-mark {
  position: absolute; top: 20px; right: 22px;
  font-family: var(--serif); font-size: 26px;
  color: var(--gold); opacity: 0.5; line-height: 1;
}
.archive-collection h2 {
  margin: 0; font-family: var(--serif); font-weight: 500;
  font-size: 24px; color: var(--gold); letter-spacing: -0.005em;
}
.archive-collection p {
  margin: 0; color: var(--text-2); line-height: 1.65; font-size: 15px;
}
.archive-collection p.muted { color: var(--muted); font-size: 14px; font-style: italic; }
.archive-collection p strong { color: var(--text); font-weight: 500; }
.archive-criteria {
  margin: 4px 0 4px 0; padding-inline-start: 22px;
  color: var(--text-2); line-height: 1.65; font-size: 14.5px;
  display: flex; flex-direction: column; gap: 8px;
}
html[dir="rtl"] .archive-criteria { padding-inline-start: 0; padding-inline-end: 22px; }
.archive-criteria li strong { color: var(--gold); font-weight: 500; }

.archive-promise {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  background: linear-gradient(135deg, rgba(246,196,83,0.08), rgba(246,196,83,0.02));
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
}
.archive-promise-text h3 {
  margin: 0 0 6px 0; font-family: var(--serif); font-size: 18px;
  color: var(--gold); font-weight: 500;
}
.archive-promise-text p {
  margin: 0; color: var(--text-2); line-height: 1.6; font-size: 14.5px; max-width: 560px;
}
.archive-stay-tuned {
  font-family: var(--serif); font-size: clamp(22px, 3vw, 30px);
  color: var(--gold); font-style: italic; font-weight: 400;
  white-space: nowrap; letter-spacing: 0.01em;
  text-shadow: 0 0 24px rgba(246,196,83,0.2);
}

@media (max-width: 800px) {
  .archive-collections { grid-template-columns: 1fr; }
  .archive-promise { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   LOADING SCREEN
   ========================================================= */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7, 11, 24, 0.85);
  backdrop-filter: blur(8px);
  z-index: 60;
  animation: fade-in 0.18s var(--ease);
}
.loading-screen[hidden] { display: none !important; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.loading-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.loading-logo {
  width: 140px; height: 140px;
  animation: load-rotate 12s linear infinite;
}
.loading-logo .loading-glow { animation: load-pulse 2.4s ease-in-out infinite; transform-origin: center; }
.loading-logo .loading-ring { animation: load-ring 6s linear infinite; transform-origin: center; }
.loading-logo .loading-pi   { animation: load-glow 2.4s ease-in-out infinite; }
@keyframes load-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes load-pulse  { 0%,100% { opacity: 0.45; transform: scale(0.92); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes load-ring   { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
@keyframes load-glow   { 0%,100% { fill: #f6c453; filter: drop-shadow(0 0 8px rgba(246,196,83,0.4)); } 50% { fill: #ffd574; filter: drop-shadow(0 0 18px rgba(246,196,83,0.8)); } }

.loading-brand {
  font-family: var(--serif); font-size: 22px;
  color: var(--gold); letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(246,196,83,0.2);
}
.loading-text {
  font-family: var(--sans); font-size: 13px;
  color: var(--muted); letter-spacing: 0.10em; text-transform: lowercase;
}

/* =========================================================
   COMPOSITE DRAWER
   ========================================================= */
.drawer {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.drawer[hidden] { display: none !important; }
.drawer-veil {
  position: absolute; inset: 0;
  background: rgba(7,11,24,0.82); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.drawer-card {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  padding: 30px 30px 26px; width: min(700px, 100%);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 90px -30px rgba(0,0,0,0.85), 0 0 60px -20px rgba(246,196,83,0.18);
  display: flex; flex-direction: column; gap: 18px;
  animation: tab-in 0.25s var(--ease);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
  gap: 16px;
}
.drawer-head h2 {
  font-family: var(--serif); font-weight: 400; font-size: 26px;
  margin: 0; color: var(--gold); letter-spacing: -0.005em;
  line-height: 1.1;
}
html[dir="rtl"] .drawer-head h2 { font-size: 28px; }
.drawer-intro {
  font-size: 13px; color: var(--muted); margin: 0; line-height: 1.65;
  letter-spacing: 0.01em;
  padding: 12px 14px;
  background: rgba(246,196,83,0.04);
  border-left: 2px solid var(--gold-soft);
  border-radius: 4px;
}
html[dir="rtl"] .drawer-intro {
  font-size: 13.5px; line-height: 1.75;
  border-left: none; border-right: 2px solid var(--gold-soft);
}

.cond-list { display: flex; flex-direction: column; gap: 10px; }
.cond-list:empty { display: none; }
.cond {
  display: grid;
  grid-template-columns: 28px 120px 1fr 1fr;
  gap: 12px; align-items: center;
  padding: 13px 16px;
  background: rgba(0,0,0,0.24);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.cond:hover { border-color: rgba(246,196,83,0.20); }
.cond:focus-within {
  border-color: var(--gold-soft);
  background: rgba(0,0,0,0.32);
  box-shadow: 0 0 0 3px rgba(246,196,83,0.05);
}
/* Re-order cells so remove (X) appears LAST visually after the inputs, label first */
.cond .cond-type { order: 1; }
.cond input:nth-of-type(1) { order: 2; }
.cond input:nth-of-type(2) { order: 3; }
.cond .cond-remove { order: 4; }
.cond-type {
  font-size: 10.5px; letter-spacing: 0.12em; color: var(--gold);
  text-transform: uppercase; font-weight: 700;
  line-height: 1.25;
}
html[dir="rtl"] .cond-type {
  text-transform: none; letter-spacing: 0; font-size: 13.5px;
  font-weight: 500; color: var(--gold);
}
.cond input[type="text"] {
  background: rgba(0,0,0,0.25); border: 1px solid var(--line-2);
  border-radius: 6px; color: var(--text);
  padding: 9px 12px; font-family: var(--mono); font-size: 13.5px; width: 100%;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.cond input[type="text"]::placeholder { color: var(--muted-2); }
.cond input[type="text"]:focus {
  outline: none; border-color: var(--gold-soft); background: rgba(0,0,0,0.35);
}
.cond-remove {
  background: transparent; border: none; color: var(--muted-2);
  cursor: pointer; font-size: 16px;
  width: 28px; height: 28px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.cond-remove:hover { color: var(--gold); background: rgba(246,196,83,0.08); }

.cond-add {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 16px 0 6px;
  border-top: 1px dashed var(--line-2);
}
.cond-add .ghost-btn {
  padding: 10px 16px; font-size: 12.5px;
  flex-direction: row; gap: 4px; text-align: center;
  background: rgba(246,196,83,0.06);
  color: var(--gold);
  border-color: var(--gold-soft);
  font-weight: 500;
  letter-spacing: 0.02em;
  border-width: 1px;
}
html[dir="rtl"] .cond-add .ghost-btn { font-size: 13.5px; }
.cond-add .ghost-btn:hover {
  background: rgba(246,196,83,0.14);
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -10px rgba(246,196,83,0.45);
}
.cond-add .ghost-btn small { color: var(--muted); }

.drawer-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--line-2);
}
.primary-btn {
  background: var(--gold); color: var(--bg);
  border: none; padding: 12px 26px; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  cursor: pointer; letter-spacing: 0.04em;
  transition: background 0.2s var(--ease), transform 0.1s var(--ease);
}
html[dir="rtl"] .primary-btn { font-weight: 500; letter-spacing: 0.01em; font-size: 15px; }
.primary-btn:hover { background: var(--gold-dim); }
.primary-btn:active { transform: scale(0.97); }
.drawer-status {
  font-size: 12.5px; color: var(--muted); flex: 1;
  font-family: var(--mono); letter-spacing: 0.01em;
}
.drawer-status:empty { display: none; }

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .brand-tfv { display: none; }
  .topbar-divider { display: none; }
  .login-btn { font-size: 14px; padding: 6px 14px; }
  .tabs { padding: 8px 16px; top: 60px; }
  .tab { padding: 6px 13px; font-size: 12.5px; }
  .tab-panel { padding: 0 16px 60px; }
  .hero { padding-top: 6vh; gap: 22px; }
  .lede { font-size: 38px; }
  .lede-sub { font-size: 11.5px; letter-spacing: 0.10em; }
  .cta-row { grid-template-columns: 1fr; padding-top: 16px; }
  .row-toggles { gap: 8px; }
  .result-table thead { display: none; }
  .result-table td { display: block; border: none; padding: 4px 0; }
  .result-row { border-bottom: 1px solid var(--line-2); padding: 12px 0; }
  .t-pos, .t-context { max-width: none; width: auto; }
  .analysis-body { grid-template-columns: 1fr; }
  .a-line { grid-template-columns: 110px 1fr; }
  .gematria-card { grid-template-columns: 1fr; }
  .results-head { flex-direction: column; align-items: stretch; }
  .results-controls { justify-content: flex-end; }
  .cond { grid-template-columns: 28px 1fr 1fr; row-gap: 8px; }
  .cond-type { grid-column: 1 / -1; order: 0; }
  .cond .cond-remove { order: 1; }
  .cond input:nth-of-type(1) { order: 2; }
  .cond input:nth-of-type(2) { order: 3; }
  .drawer { padding: 12px; }
  .drawer-card { padding: 22px 20px; }
  .drawer-head h2 { font-size: 22px; }
  .footnotes { margin-top: 48px; }
}


/* =========================================================
   Language switch — side-by-side EN | HE pattern matching
   TheFirstVerse.com's main header.  Active = bright gold,
   inactive = dim gold (#9e8556 passes WCAG AA on dark bg).
   ========================================================= */
.lang-switch {
  display: inline-flex; align-items: center;
  font-family: var(--serif); font-size: 13px;
  letter-spacing: 0.04em;
}
.lang-switch-btn {
  background: none; border: none;
  padding: 4px 8px;
  font-family: inherit; font-size: inherit; letter-spacing: inherit;
  color: #9e8556;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.lang-switch-btn:hover { color: var(--gold); }
.lang-switch-btn[aria-pressed="true"] {
  color: var(--gold);
}
.lang-switch-sep {
  color: #9e8556; padding: 0 2px;
}
