/* Biblissima Textes — base styles & component classes (.bt-*).
   Uses logical properties (inline/block) so RTL locales work without changes. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bt-bg); color: var(--bt-ink);
  font-family: var(--bt-font-ui); font-size: var(--bt-fs-md); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
p { margin: 0; }
a { color: var(--bt-blue); text-underline-offset: 3px; }
a:hover { color: var(--bt-navy); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--bt-focus); outline-offset: 2px; border-radius: 2px; }
[v-cloak] { display: none; }
.bt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bt-skip { position: absolute; inset-inline-start: 8px; inset-block-start: -60px; background: var(--bt-navy); color: var(--bt-on-navy); padding: 8px 14px; z-index: 100; }
.bt-skip:focus { inset-block-start: 8px; }

/* ---------- Layout ---------- */
.bt-container { max-width: var(--bt-page); margin-inline: auto; padding-inline: var(--bt-s5); }
.bt-section { padding-block: var(--bt-s6); }
.bt-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--bt-s6); }
.bt-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--bt-s5); }
.bt-grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--bt-s4); }
.bt-row { display: flex; align-items: center; gap: var(--bt-s3); flex-wrap: wrap; }
.bt-stack { display: flex; flex-direction: column; gap: var(--bt-s3); }
.bt-grow { flex: 1; }
@media (max-width: 860px) { .bt-grid-3, .bt-grid-2 { grid-template-columns: 1fr; } }

/* ---------- Typography ---------- */
.bt-eyebrow { font-size: var(--bt-fs-xs); font-weight: 500; color: var(--bt-ink-faint); }
.bt-h1 { font-size: clamp(1.625rem, 4vw, var(--bt-fs-2xl)); font-weight: 600; color: var(--bt-ink); letter-spacing: -.01em; }
.bt-h2 { font-size: var(--bt-fs-lg); font-weight: 600; color: var(--bt-ink); }
.bt-h3 { font-size: var(--bt-fs-md); font-weight: 600; color: var(--bt-ink); }
.bt-lead { font-size: var(--bt-fs-lg); color: var(--bt-ink-soft); }
.bt-muted { color: var(--bt-ink-faint); }
.bt-small { font-size: var(--bt-fs-sm); }
.bt-xs { font-size: var(--bt-fs-xs); }
.bt-mono { font-family: var(--bt-font-mono); font-size: .85em; }
.bt-sectionhead {
  font-size: var(--bt-fs-sm); font-weight: 600;
  color: var(--bt-ink); border-block-end: 1px solid var(--bt-ink); padding-block-end: 6px; margin-block-end: var(--bt-s3);
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--bt-s3);
}
.bt-sectionhead--accent { color: var(--bt-accent); border-color: var(--bt-accent); }
.bt-sectionhead a { font-weight: 400; font-size: var(--bt-fs-sm); color: var(--bt-accent); }
[lang="grc"] { font-family: var(--bt-font-greek); }
[lang="ar"] { font-family: var(--bt-font-arabic); }
/* EB Garamond's Latin locl swaps u→v; keep the edition's spelling */
:lang(la), :lang(lat) { font-feature-settings: "locl" 0; }
[lang="he"] { font-family: var(--bt-font-hebrew); }

/* ---------- Header / footer ---------- */
.bt-header { position: sticky; inset-block-start: 0; z-index: 40; background: var(--bt-bg); border-block-end: 1px solid var(--bt-border); }
.bt-header__in { display: flex; align-items: center; gap: var(--bt-s5); min-height: var(--bt-header-h); }
.bt-logo { font-weight: 600; font-size: 1.0625rem; letter-spacing: -.01em; color: var(--bt-ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.bt-logo svg { color: var(--bt-accent); }
.bt-logo__img { block-size: 1.9rem; inline-size: auto; display: block; }
.bt-logo__sub { color: var(--bt-accent); font-family: 'Source Serif 4', 'Source Serif Pro', Georgia, serif; font-weight: 600; font-size: 1.6rem; letter-spacing: 0; line-height: 1; }
.bt-nav { display: flex; gap: var(--bt-s5); flex: 1; }
.bt-nav a { font-size: var(--bt-fs-sm); color: var(--bt-ink-soft); text-decoration: none; padding-block: 16px; border-block-end: 2px solid transparent; }
.bt-nav a:hover { color: var(--bt-navy); }
.bt-nav a[aria-current="page"] { color: var(--bt-navy); border-color: var(--bt-accent); }
.bt-langswitch { display: inline-flex; border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius); overflow: hidden; }
.bt-langswitch button { background: transparent; border: 0; padding: 3px 10px; font-size: var(--bt-fs-xs); color: var(--bt-ink-soft); }
.bt-langswitch button[aria-pressed="true"] { background: var(--bt-navy); color: var(--bt-on-navy); }
.bt-footer { border-block-start: 1px solid var(--bt-border-strong); margin-block-start: var(--bt-s7); padding-block: var(--bt-s5); color: var(--bt-ink-faint); font-size: var(--bt-fs-sm); }
.bt-footer__in { display: flex; gap: var(--bt-s5); flex-wrap: wrap; justify-content: space-between; }
.bt-navtoggle { display: none; background: none; border: 0; padding: 8px; margin-inline-start: -8px; color: var(--bt-ink); order: 2; }
.bt-header__in > .bt-account { margin-inline-start: auto; }
@media (max-width: 720px) {
  .bt-header__in { gap: var(--bt-s3); }
  .bt-navtoggle { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
  .bt-nav { display: none; position: absolute; inset-inline: 0; inset-block-start: 100%; flex-direction: column; gap: 0; background: var(--bt-bg); border-block-end: 1px solid var(--bt-border-strong); box-shadow: var(--bt-shadow-pop); padding: 4px var(--bt-s4) 8px; max-height: calc(100vh - var(--bt-header-h)); overflow-y: auto; }
  .bt-nav.is-open { display: flex; }
  .bt-nav a { padding: 13px 0; border-block-end: 1px solid var(--bt-border); font-size: var(--bt-fs-md); }
  .bt-nav a[aria-current="page"] { border-block-end-color: var(--bt-border); font-weight: 600; box-shadow: inset 3px 0 0 var(--bt-accent); padding-inline-start: 12px; }
}

/* ---------- Buttons ---------- */
.bt-btn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--bt-navy); background: var(--bt-navy); color: var(--bt-on-navy);
  padding: 7px 16px; border-radius: var(--bt-radius); font-size: var(--bt-fs-sm); text-decoration: none; line-height: 1.3; }
.bt-btn:hover { background: var(--bt-navy-2); color: var(--bt-on-navy); }
.bt-btn--ghost { background: transparent; color: var(--bt-navy); border-color: var(--bt-border-strong); }
.bt-btn--ghost:hover { background: var(--bt-bg-sunken); color: var(--bt-navy); border-color: var(--bt-navy); }
.bt-btn--accent { background: var(--bt-accent); border-color: var(--bt-accent); }
.bt-btn--accent:hover { background: #7d1c21; }
.bt-btn--sm { padding: 3px 10px; font-size: var(--bt-fs-xs); }
.bt-btn--icon { padding: 6px; min-width: 34px; justify-content: center; }
.bt-btn[aria-pressed="true"] { background: var(--bt-navy); color: var(--bt-on-navy); border-color: var(--bt-navy); }
.bt-btn:disabled { opacity: .45; cursor: not-allowed; }
.bt-link-arrow { color: var(--bt-accent); text-decoration: none; font-size: var(--bt-fs-sm); }
.bt-link-arrow:hover { text-decoration: underline; color: var(--bt-accent); }

/* ---------- Tags ---------- */
.bt-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border: 1px solid var(--bt-border-strong); border-radius: 2px;
  font-size: var(--bt-fs-xs); background: var(--bt-surface); color: var(--bt-ink-soft); white-space: nowrap; }
.bt-tag--lang { background: var(--c, var(--bt-lang-other)); border-color: var(--c, var(--bt-lang-other)); color: #fff; }
.bt-tag--accent { background: var(--bt-blue-soft); border-color: var(--bt-border); color: var(--bt-navy); }
.bt-tag--active { background: var(--bt-navy); color: var(--bt-on-navy); border-color: var(--bt-navy); }
.bt-tag button { background: none; border: 0; color: inherit; padding: 0 0 0 2px; }
.bt-lang-greek { --c: var(--bt-lang-greek); } .bt-lang-latin { --c: var(--bt-lang-latin); } .bt-lang-oldfr { --c: var(--bt-lang-oldfr); }
.bt-lang-arabic { --c: var(--bt-lang-arabic); } .bt-lang-hebrew { --c: var(--bt-lang-hebrew); } .bt-lang-other { --c: var(--bt-lang-other); }

/* ---------- Search band (direction A's blue) ---------- */
.bt-band { background: var(--bt-search-bg); color: var(--bt-search-ink); padding-block: var(--bt-s7) var(--bt-s6); }
.bt-band { position: relative; isolation: isolate; overflow: hidden; }
.bt-band::before { content: ''; position: absolute; inset: 0; z-index: -1; background: url(img/bge-lat0016_012v_header.jpg) center / cover no-repeat; opacity: .09; pointer-events: none; }   /* a manuscript page under the colour, barely there */
.bt-band .bt-h1 { color: #fff; max-width: 22ch; margin-block: var(--bt-s2) var(--bt-s2); }
.bt-band__sub { color: var(--bt-search-ink-soft); margin-block-end: var(--bt-s5); }
.bt-searchbox { display: flex; align-items: center; gap: 10px; background: var(--bt-surface); color: var(--bt-ink); border: 2px solid transparent;
  border-radius: var(--bt-radius-lg); padding: 6px 8px 6px 16px; max-width: 760px;  }
.bt-searchbox:focus-within { border-color: var(--bt-focus); }
.bt-searchbox input { flex: 1; border: 0; outline: 0; background: transparent; font-size: var(--bt-fs-md); padding-block: 8px; min-width: 0; }
.bt-searchbox svg { color: var(--bt-ink-faint); flex: none; }
.bt-searchbox kbd { font: inherit; font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); border: 1px solid var(--bt-border); border-radius: 3px; padding: 0 6px; }
.bt-quick { margin-block-start: var(--bt-s4); display: flex; gap: var(--bt-s3); flex-wrap: wrap; font-size: var(--bt-fs-sm); color: var(--bt-search-ink-soft); }
.bt-quick a { color: #fff; text-decoration-style: solid; }
/* light variant for in-page filters */
.bt-searchbox--light { box-shadow: none; border: 1.5px solid var(--bt-border-strong); max-width: none; border-radius: var(--bt-radius); padding-block: 2px; }
.bt-input { width: 100%; border: 1.5px solid var(--bt-border-strong); border-radius: var(--bt-radius); background: var(--bt-surface); padding: 6px 10px; font-size: var(--bt-fs-sm); }

/* ---------- Stats ---------- */
.bt-stats { background: var(--bt-bg-sunken); border-block: 1px solid var(--bt-border-strong); }
.bt-stats__in { display: flex; }
.bt-stat { flex: 1; text-align: center; padding: var(--bt-s3) var(--bt-s2); border-inline-end: 1px solid var(--bt-border-strong); }
.bt-stat:last-child { border-inline-end: 0; }
.bt-stat b { display: block; font-weight: 600; font-size: var(--bt-fs-lg); color: var(--bt-navy); }
.bt-stat span { font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); }
@media (max-width: 720px) { .bt-stats__in { flex-wrap: wrap; } .bt-stat { flex: 1 1 33%; } }

/* ---------- Lists ---------- */
.bt-index li { display: flex; justify-content: space-between; gap: var(--bt-s3); padding: 5px 0; border-block-end: 1px solid var(--bt-border); font-size: var(--bt-fs-sm); }
.bt-index a { text-decoration: none; color: var(--bt-ink); }
.bt-index a:hover { color: var(--bt-blue); text-decoration: underline; }
.bt-index small { color: var(--bt-ink-faint); }
.bt-news li { display: flex; gap: var(--bt-s4); padding: 8px 0; border-block-end: 1px solid var(--bt-border); }
.bt-news time { flex: none; width: 7.5em; font-size: var(--bt-fs-sm); color: var(--bt-accent); }

/* ---------- Cards ---------- */
.bt-card { background: var(--bt-surface); border: 1px solid var(--bt-border); border-radius: var(--bt-radius-lg); padding: var(--bt-s4); }
.bt-card h3 { margin-block-end: 4px; }
.bt-work { background: var(--bt-surface); border: 1px solid var(--bt-border); border-radius: var(--bt-radius); padding: var(--bt-s3) var(--bt-s4); }
.bt-work__head { display: flex; justify-content: space-between; gap: var(--bt-s3); align-items: baseline; }

/* ---------- Breadcrumb ---------- */
.bt-crumbbar { background: var(--bt-bg); border-block-end: 1px solid var(--bt-border); }
.bt-crumbs { font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); height: var(--bt-crumb-h); display: flex; align-items: center; overflow-x: auto; white-space: nowrap; }
.bt-crumbs ol { display: flex; flex-wrap: nowrap; gap: 2px 0; margin: 0; padding: 0; list-style: none; min-width: 0; }
.bt-crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.bt-crumbs li > a, .bt-crumbs li > span { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; }
.bt-crumbs li:last-child > span { max-width: 48ch; }
.bt-crumbs li + li::before { content: '›'; margin-inline: 8px; color: var(--bt-border-strong); }
[dir="rtl"] .bt-crumbs li + li::before { content: '‹'; }
.bt-crumbs a { color: var(--bt-ink-soft); text-decoration: none; }
.bt-crumbs a:hover { color: var(--bt-blue); text-decoration: underline; }
.bt-crumbs [aria-current] { color: var(--bt-navy); font-weight: 600; }

/* ---------- Tabs ---------- */
.bt-tabs { display: flex; border-block-end: 1px solid var(--bt-border); }
.bt-tabs button { flex: 1; background: none; border: 0; border-block-end: 2px solid transparent; padding: 9px 6px; font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); margin-block-end: -1px; }
.bt-tabs button[aria-selected="true"] { color: var(--bt-navy); border-color: var(--bt-accent); font-weight: 600; }

/* ---------- Tree / TOC ---------- */
.bt-tree { font-size: var(--bt-fs-sm); }
.bt-tree ul ul { margin-inline-start: 14px; border-inline-start: 1px solid var(--bt-border); }
.bt-tree__row { display: flex; align-items: center; gap: 4px; }
.bt-tree__toggle { background: none; border: 0; width: 22px; height: 26px; padding: 0; color: var(--bt-ink-faint); flex: none; }
.bt-tree__toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
[dir="rtl"] .bt-tree__toggle svg { transform: scaleX(-1); }
.bt-tree__spacer { width: 22px; flex: none; }
.bt-tree__link { flex: 1; text-align: start; background: none; border: 0; border-inline-start: 3px solid transparent; padding: 4px 8px; color: var(--bt-ink-soft); border-radius: 2px; display: flex; gap: 8px; justify-content: space-between; }
.bt-tree__link:hover { background: var(--bt-bg-sunken); }
.bt-tree__link[aria-current="true"] { background: var(--bt-navy); color: var(--bt-on-navy); }
.bt-tree__link--lang { border-inline-start-color: var(--c); font-weight: 600; }
.bt-tree__ref { font-size: var(--bt-fs-xs); opacity: .7; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Catalogue: master-detail (direction C) ---------- */
.bt-master { display: grid; grid-template-columns: 240px 300px 1fr; height: calc(100vh - var(--bt-header-h) - var(--bt-crumb-h) - 2px); min-height: 420px; background: var(--bt-surface); }
.bt-master > * { min-width: 0; }
.bt-pane { overflow-y: auto; height: 100%; }
.bt-pane--tree { background: var(--bt-surface); border-inline-end: 1px solid var(--bt-border); padding: var(--bt-s3) 0; }
.bt-pane--list { background: var(--bt-surface); border-inline-end: 1px solid var(--bt-border); }
.bt-pane--detail { padding: var(--bt-s5); }
.bt-az { display: flex; flex-wrap: wrap; gap: 3px; margin-block-start: 8px; }
.bt-az button { border: 1px solid var(--bt-border-strong); background: var(--bt-surface); border-radius: 2px; padding: 0 5px; font-size: var(--bt-fs-xs); }
.bt-az button[aria-pressed="true"] { background: var(--bt-navy); color: var(--bt-on-navy); border-color: var(--bt-navy); }
.bt-listitem { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: start; background: none; border: 0; border-block-end: 1px solid var(--bt-border); padding: 9px var(--bt-s3); font-size: var(--bt-fs-sm); }
.bt-listitem:hover { background: var(--bt-bg-sunken); }
.bt-listitem[aria-current="true"]:hover { background: var(--bt-navy); }
.bt-listitem[aria-current="true"] { background: var(--bt-navy); color: var(--bt-on-navy); }
.bt-listitem small { opacity: .7; white-space: nowrap; flex: none; }
@media (max-width: 980px) {
  .bt-master { grid-template-columns: 1fr; height: auto; }
  .bt-pane { height: auto; max-height: 320px; }
}

/* ---------- Metadata list ---------- */
.bt-meta { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px var(--bt-s4); font-size: var(--bt-fs-sm); }
.bt-meta dt { color: var(--bt-ink-faint); }
.bt-meta dd { margin: 0; color: var(--bt-ink); overflow-wrap: anywhere; }

/* ---------- Reader ---------- */
.bt-titlebar { padding-block-start: var(--bt-s5); display: flex; justify-content: space-between; align-items: flex-end; gap: var(--bt-s4); flex-wrap: wrap; padding-block-end: var(--bt-s4); border-block-end: 1px solid var(--bt-border); }
.bt-titlebar h1 { font-size: var(--bt-fs-xl); font-weight: 600; color: var(--bt-ink); }
.bt-reader { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--bt-s6); align-items: start; padding-block: var(--bt-s5); }
.bt-side { position: sticky; inset-block-start: calc(var(--bt-header-h) + 12px); max-height: calc(100vh - var(--bt-header-h) - 24px); overflow-y: auto; }
.bt-side--left { background: var(--bt-surface); border: 1px solid var(--bt-border); border-radius: var(--bt-radius-lg); }
.bt-side__body { padding: var(--bt-s3); }
.bt-toolbar { position: sticky; inset-block-start: var(--bt-header-h); z-index: 20; background: var(--bt-bg); border-block-end: 1px solid var(--bt-border); padding-block: var(--bt-s2); display: flex; gap: var(--bt-s2); align-items: center; flex-wrap: wrap; }
.bt-toolbar__sep { width: 1px; align-self: stretch; background: var(--bt-border); margin-inline: 4px; }
.bt-findbox { display: flex; align-items: center; gap: 4px; background: var(--bt-surface); border: 1.5px solid var(--bt-border-strong); border-radius: var(--bt-radius); padding: 2px 4px 2px 8px; flex: 1; min-width: 180px; max-width: 360px; }
.bt-findbox:focus-within { border-color: var(--bt-focus); }
.bt-findbox input { border: 0; outline: 0; flex: 1; min-width: 0; font-size: var(--bt-fs-sm); background: transparent; }
.bt-findbox output { font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bt-text { padding-block: var(--bt-s5); max-width: 100%; font-family: var(--bt-font-text); font-size: calc(1.25rem * var(--bt-zoom, 1)); }
.bt-section-title { font-family: var(--bt-font-ui); font-size: var(--bt-fs-sm); font-weight: 600; color: var(--bt-accent); margin-block: var(--bt-s5) var(--bt-s2); scroll-margin-block-start: calc(var(--bt-header-h) + 64px); }
.bt-line { display: grid; grid-template-columns: 3.5em minmax(0, 1fr); gap: var(--bt-s3); padding-block: 3px; border-radius: 3px; line-height: 1.8; }
.bt-line--parallel { grid-template-columns: 3.5em minmax(0, 1fr) minmax(0, 1fr); }
.bt-line.is-selected { background: var(--bt-blue-soft); }
.bt-line__ref { align-self: start; font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); text-align: end; padding-block-start: 6px; font-variant-numeric: tabular-nums; user-select: none; border: 0; background: none; }
.bt-line__ref:hover { color: var(--bt-blue); text-decoration: underline; }
.bt-line__text { max-width: 72ch; }
.bt-line__tr { font-family: var(--bt-font-text); }
.bt-line__tr { color: var(--bt-ink-soft); font-style: italic; }
.bt-text.no-refs .bt-line__ref { visibility: hidden; }
mark.bt-hit { background: var(--bt-hit); color: inherit; border-radius: 2px; padding-inline: 1px; }
mark.bt-hit.is-active { background: var(--bt-hit-active); outline: 2px solid var(--bt-focus); }
.bt-cite-float { position: fixed; inset-inline-end: 24px; inset-block-end: 24px; z-index: 30; box-shadow: var(--bt-shadow-pop); }
@media (max-width: 1100px) {
  .bt-reader { grid-template-columns: 1fr; }
  .bt-side { position: static; max-height: none; }
}

/* ---------- Modal / toast ---------- */
.bt-modal-back { position: fixed; inset: 0; background: rgba(20,28,40,.55); z-index: 90; display: grid; place-items: center; padding: var(--bt-s4); }
.bt-modal { background: var(--bt-surface); border-radius: var(--bt-radius-lg); box-shadow: var(--bt-shadow-pop); width: min(640px, 100%); max-height: 90vh; overflow: auto; }
.bt-modal__head { display: flex; justify-content: space-between; align-items: center; padding: var(--bt-s4) var(--bt-s5); border-block-end: 1px solid var(--bt-border); }
.bt-modal__body { padding: var(--bt-s5); display: flex; flex-direction: column; gap: var(--bt-s4); }
.bt-code { font-family: var(--bt-font-mono); font-size: var(--bt-fs-xs); background: var(--bt-bg-sunken); border: 1px solid var(--bt-border); border-radius: var(--bt-radius); padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--bt-ink); }
.bt-field label { display: block; font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); letter-spacing: .06em; text-transform: uppercase; margin-block-end: 4px; }
.bt-toast { position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--bt-navy); color: var(--bt-on-navy); padding: 8px 18px; border-radius: 2px; z-index: 100; font-size: var(--bt-fs-sm); }

/* ---------- External links ---------- */
.bt-ext li + li { border-block-start: 1px solid var(--bt-border); }
.bt-ext a { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; text-decoration: none; font-size: var(--bt-fs-sm); }
.bt-ext a:hover span:first-child { text-decoration: underline; }

/* ---------- Results ---------- */
.bt-result { padding: var(--bt-s4) 0; border-block-end: 1px solid var(--bt-border); }
.bt-result__ref { font-size: var(--bt-fs-xs); color: var(--bt-accent); letter-spacing: .06em; }
.bt-facet label { display: flex; gap: 8px; align-items: center; font-size: var(--bt-fs-sm); padding: 2px 0; }
.bt-pager { display: flex; gap: 4px; }
.bt-pager button { border: 1px solid var(--bt-border-strong); background: var(--bt-surface); border-radius: 2px; padding: 2px 10px; }
.bt-pager button[aria-current="page"] { background: var(--bt-navy); color: var(--bt-on-navy); border-color: var(--bt-navy); }
.bt-empty { text-align: center; padding: var(--bt-s7) var(--bt-s4); color: var(--bt-ink-faint); border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius-lg); }

/* ---------- Style-guide helpers ---------- */
.bt-swatch { border: 1px solid var(--bt-border); border-radius: var(--bt-radius); overflow: hidden; background: var(--bt-surface); }
.bt-swatch i { display: block; height: 64px; }
.bt-swatch div { padding: 8px 10px; font-size: var(--bt-fs-xs); line-height: 1.4; }
.bt-swatch b { display: block; font-size: var(--bt-fs-sm); }
.bt-demo { border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius-lg); padding: var(--bt-s5); background: var(--bt-surface); }
.bt-guide { display: grid; grid-template-columns: 200px 1fr; gap: var(--bt-s6); padding-block: var(--bt-s6); }
.bt-guide nav { position: sticky; inset-block-start: calc(var(--bt-header-h) + 16px); align-self: start; display: flex; flex-direction: column; gap: 6px; font-size: var(--bt-fs-sm); }
.bt-guide nav a { text-decoration: none; color: var(--bt-ink-soft); }
.bt-guide section { margin-block-end: var(--bt-s7); scroll-margin-block-start: calc(var(--bt-header-h) + 16px); }
.bt-guide section > .bt-h2 { margin-block-end: var(--bt-s2); }
.bt-guide section > p { margin-block-end: var(--bt-s4); max-width: 70ch; color: var(--bt-ink-soft); }
.bt-dodont { display: grid; grid-template-columns: 1fr 1fr; gap: var(--bt-s4); }
.bt-do, .bt-dont { padding: var(--bt-s3) var(--bt-s4); border-radius: var(--bt-radius); font-size: var(--bt-fs-sm); }
.bt-do { background: var(--bt-ok-soft); border-inline-start: 3px solid var(--bt-success); }
.bt-dont { background: var(--bt-err-soft); border-inline-start: 3px solid #a23b3b; }
@media (max-width: 860px) { .bt-guide { grid-template-columns: 1fr; } .bt-guide nav { position: static; flex-direction: row; flex-wrap: wrap; } .bt-dodont { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Filter chips (toggle buttons) */
.bt-chip { border: 1px solid var(--bt-border-strong); background: var(--bt-surface); border-radius: var(--bt-radius); padding: 2px 10px; font-size: var(--bt-fs-sm); color: var(--bt-ink-soft); }
.bt-chip:hover { border-color: var(--bt-ink); }
.bt-chip[aria-pressed="true"] { background: var(--bt-navy); border-color: var(--bt-navy); color: var(--bt-on-navy); }

/* News */
.bt-article { max-width: 70ch; }
.bt-article p { margin-block: 0 var(--bt-s4); font-family: var(--bt-font-text); font-size: 1.25rem; line-height: 1.6; }
.bt-newsitem { display: grid; grid-template-columns: 9em 1fr; gap: var(--bt-s4); padding-block: var(--bt-s4); border-block-end: 1px solid var(--bt-border); }
.bt-newsitem a { color: var(--bt-ink); text-decoration: none; }
.bt-newsitem a:hover { color: var(--bt-blue); text-decoration: underline; }
@media (max-width: 640px) { .bt-newsitem { grid-template-columns: 1fr; gap: 4px; } }

/* Collections (rubric red marks curated / editorial groupings) */
.bt-colllabel { color: var(--bt-accent); font-size: var(--bt-fs-xs); font-weight: 600; }
.bt-colltag { display: inline-block; border: 1px solid var(--bt-accent-bright); background: var(--bt-accent-soft); color: var(--bt-accent); border-radius: var(--bt-radius); padding: 0 8px; font-size: var(--bt-fs-xs); text-decoration: none; }
.bt-colltag:hover { border-color: var(--bt-accent); color: var(--bt-accent); }
.bt-partof { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); margin-block-end: 10px; }
.bt-featured { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--bt-s5); align-items: end; border: 1px solid var(--bt-border); border-block-start: 3px solid var(--bt-accent); background: var(--bt-surface); padding: var(--bt-s5); }
.bt-featured h2 { font-size: var(--bt-fs-xl); font-weight: 600; margin-block: 4px 8px; }
.bt-featured h2 a { color: var(--bt-ink); text-decoration: none; }
.bt-featured h2 a:hover { text-decoration: underline; }
@media (max-width: 720px) { .bt-featured { grid-template-columns: 1fr; } }
.bt-segment { display: flex; margin: 0 var(--bt-s3) var(--bt-s3); border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius); }
.bt-segment button { flex: 1; border: 0; background: var(--bt-surface); padding: 6px 4px; font-size: var(--bt-fs-sm); color: var(--bt-ink-soft); }
.bt-segment button + button { border-inline-start: 1px solid var(--bt-border-strong); }
.bt-segment button[aria-pressed="true"] { background: var(--bt-navy); color: var(--bt-on-navy); }
.bt-segment button.is-coll[aria-pressed="true"] { background: var(--bt-accent); }
.bt-group { font-size: var(--bt-fs-xs); font-weight: 600; color: var(--bt-ink-faint); padding: 12px var(--bt-s3) 4px; }
.bt-group--coll { color: var(--bt-accent); }
.bt-listitem--sub { padding-inline-start: 24px; }
/* Prose */
.bt-line--prose { line-height: 1.75; padding-block: 6px; }
.bt-line--prose .bt-line__text { max-width: 68ch; text-align: justify; hyphens: auto; }
.bt-line--prose.bt-line--parallel .bt-line__text, .bt-line--prose .bt-line__tr { text-align: start; }
.bt-line--prose .bt-line__tr { font-style: normal; font-size: .9em; }
.bt-featured-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--bt-s4); }
.bt-featured--card { grid-template-columns: 1fr; align-content: space-between; gap: var(--bt-s4); }
.bt-featured--card h3 { font-size: var(--bt-fs-lg); font-weight: 600; margin-block: 4px 8px; }
.bt-featured--card h3 a { color: var(--bt-ink); text-decoration: none; }
.bt-featured--card h3 a:hover { text-decoration: underline; }

/* Selection toolbar & similar passages (future feature) */
.bt-selpop { position: fixed; z-index: 60; transform: translate(-50%, calc(-100% - 10px)); display: flex; background: var(--bt-navy); border-radius: var(--bt-radius); box-shadow: var(--bt-shadow-pop); overflow: hidden; }
.bt-selpop button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: #fff; padding: 7px 12px; font-size: var(--bt-fs-sm); white-space: nowrap; }
.bt-selpop button + button { border-inline-start: 1px solid rgba(255,255,255,.2); }
.bt-selpop button:hover { background: var(--bt-navy-2); }
.bt-soon { display: inline-block; font-size: 0.6875rem; font-weight: 600; line-height: 1.4; padding: 0 6px; border: 1px dashed var(--bt-border-strong); border-radius: var(--bt-radius); color: var(--bt-ink-soft); background: var(--bt-bg); vertical-align: middle; }
.bt-soon--dark { border-color: rgba(255,255,255,.5); color: #fff; background: transparent; }
.bt-quote { margin: 0; padding: 8px 12px; border-inline-start: 3px solid var(--bt-navy); background: var(--bt-bg-sunken); font-family: var(--bt-font-text); font-size: 1.1rem; max-height: 9em; overflow: auto; }
.bt-preview { font-size: var(--bt-fs-sm); padding: 10px 12px; border: 1px dashed var(--bt-border-strong); background: var(--bt-bg); color: var(--bt-ink-soft); }
.bt-fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); }
.bt-similar { margin: 0; padding: 0; list-style: none; }
.bt-similar li { padding-block: 12px; border-block-end: 1px solid var(--bt-border); }
.bt-similar__text { font-family: var(--bt-font-text); font-size: 1.1rem; margin-block: 6px 4px; }
.bt-score { display: inline-block; width: 64px; height: 6px; background: var(--bt-bg-sunken); border: 1px solid var(--bt-border); flex: none; }
.bt-score i { display: block; height: 100%; background: var(--bt-blue); }
.bt-cite-float { display: flex; box-shadow: none; }
.bt-cite-float .bt-btn { box-shadow: var(--bt-shadow-pop); }

/* Lexical statistics */
.bt-lex { display: flex; flex-direction: column; gap: var(--bt-s4); }
.bt-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); border: 1px solid var(--bt-border); background: var(--bt-surface); }
.bt-tiles > div { padding: 10px 12px; border-inline-end: 1px solid var(--bt-border); }
.bt-tiles > div:last-child { border-inline-end: 0; }
.bt-tiles b { display: block; font-size: var(--bt-fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.bt-tiles span { font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); }
.bt-lexsearch { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.bt-lexsearch .bt-segment { flex: none; }
.bt-lexsearch .bt-findbox { flex: 1; min-width: 200px; }
.bt-lexres { border: 1px solid var(--bt-border); border-block-start: 3px solid var(--bt-blue); background: var(--bt-surface); padding: var(--bt-s4); }
.bt-freq { width: 100%; border-collapse: collapse; font-size: var(--bt-fs-sm); font-variant-numeric: tabular-nums; }
.bt-freq th { font-size: var(--bt-fs-xs); font-weight: 600; color: var(--bt-ink-faint); text-align: start; padding: 6px 6px; border-block-end: 1px solid var(--bt-ink); }
.bt-freq td { padding: 3px 6px; border-block-end: 1px solid var(--bt-border); }
.bt-freq .num { text-align: end; white-space: nowrap; }
.bt-freq tr.is-active td { background: var(--bt-blue-soft); }
.bt-freq__bar { width: 40%; }
.bt-freq__bar span { display: block; height: 10px; background: var(--bt-blue); border-radius: 0 4px 4px 0; min-width: 2px; }
[dir="rtl"] .bt-freq__bar span { border-radius: 4px 0 0 4px; }
.bt-freq__item { background: none; border: 0; padding: 2px 0; color: var(--bt-blue); text-decoration: underline; text-underline-offset: 3px; font-family: var(--bt-font-text); font-size: 1.05rem; }
.bt-cols { margin: 0; }
.bt-cols__plot { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-block-end: 1px solid var(--bt-ink-faint); margin-block-start: 6px; }
.bt-cols__hit { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bt-cols__hit:hover .bt-cols__bar { background: var(--bt-navy); }
.bt-cols__bar { display: block; width: 100%; background: var(--bt-blue); border-radius: 4px 4px 0 0; }
.bt-cols__axis { display: flex; justify-content: space-between; font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); padding-block-start: 4px; }
.bt-tip { position: absolute; inset-block-end: calc(100% + 6px); z-index: 5; background: var(--bt-ink); color: #fff; font-size: var(--bt-fs-xs); padding: 5px 8px; border-radius: var(--bt-radius); white-space: nowrap; pointer-events: none; }
.bt-compare { width: 100%; border-collapse: collapse; font-size: var(--bt-fs-sm); }
.bt-compare th, .bt-compare td { padding: 6px 8px; border-block-end: 1px solid var(--bt-border); text-align: start; vertical-align: middle; }
.bt-compare .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Account */
.bt-account { position: relative; }
.bt-avatarbtn { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 2px; color: var(--bt-ink-soft); }
.bt-avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--bt-navy); color: var(--bt-on-navy); font-size: var(--bt-fs-xs); font-weight: 600; }
.bt-avatar--lg { width: 56px; height: 56px; font-size: var(--bt-fs-lg); }
.bt-menu { position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 8px); min-width: 240px; background: var(--bt-surface); border: 1px solid var(--bt-border); box-shadow: var(--bt-shadow-pop); z-index: 50; display: flex; flex-direction: column; padding-block: 6px; }
.bt-menu__who { padding: 8px 14px 10px; border-block-end: 1px solid var(--bt-border); margin-block-end: 4px; display: flex; flex-direction: column; font-size: var(--bt-fs-sm); }
.bt-menu__who span { color: var(--bt-ink-faint); font-size: var(--bt-fs-xs); }
.bt-menu a, .bt-menu button { display: block; text-align: start; padding: 7px 14px; font-size: var(--bt-fs-sm); color: var(--bt-ink); text-decoration: none; background: none; border: 0; }
.bt-menu a:hover, .bt-menu button:hover { background: var(--bt-bg-sunken); }
.bt-menu button { border-block-start: 1px solid var(--bt-border); margin-block-start: 4px; color: var(--bt-ink-soft); }
.bt-signin { max-width: 440px; margin: var(--bt-s6) auto; }
.bt-signin .bt-btn { width: 100%; justify-content: center; }
.bt-or { display: flex; align-items: center; gap: 12px; color: var(--bt-ink-faint); font-size: var(--bt-fs-xs); margin-block: var(--bt-s4); }
.bt-or::before, .bt-or::after { content: ''; flex: 1; border-block-start: 1px solid var(--bt-border); }
.bt-form label { display: block; font-size: var(--bt-fs-sm); margin-block: 10px 4px; }
.bt-savebtn[aria-pressed="true"] { background: var(--bt-blue-soft); border-color: var(--bt-blue); color: var(--bt-navy); }
.bt-switch { display: flex; align-items: center; gap: 10px; font-size: var(--bt-fs-sm); padding-block: 6px; }

/* Catalogue by collection: one column per opened level (Miller columns), scrolls horizontally */
.bt-master--miller { display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-behavior: smooth; }
.bt-master--miller > .bt-pane { flex: 0 0 240px; }
.bt-master--miller > .bt-pane--tree { flex-basis: 240px; }
.bt-master--miller > .bt-pane--detail { flex: 1 0 420px; }
.bt-pane--col { border-inline-end: 1px solid var(--bt-border); }
.bt-colhead { position: sticky; inset-block-start: 0; z-index: 1; background: var(--bt-bg-sunken); padding: 10px var(--bt-s3) 8px; border-block-end: 1px solid var(--bt-border); }
.bt-colhead__title { font-weight: 600; font-size: var(--bt-fs-sm); line-height: 1.3; }
.bt-haskids { color: var(--bt-accent); font-weight: 600; margin-inline-end: 2px; }
.bt-listitem[aria-current="true"] .bt-haskids { color: #fff; }
@media (max-width: 980px) {
  .bt-master--miller { flex-direction: column; overflow-x: visible; }
  .bt-master--miller > .bt-pane { flex: none; }
}
.bt-subcoll { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--bt-ink); border-block-start: 3px solid var(--bt-accent); }
.bt-subcoll:hover { border-color: var(--bt-accent); background: var(--bt-bg); }
.bt-subcoll:hover b { text-decoration: underline; }
.bt-colltree a[aria-current="page"] { font-weight: 600; color: var(--bt-ink); }

/* Concordance (KWIC): keyword column centred, contexts clipped on their outer side */
.bt-conc { display: flex; flex-direction: column; gap: 6px; }
.bt-concform { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bt-querybox { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.bt-querybox .bt-segment { flex: none; margin: 0; }
.bt-querybox .bt-findbox { flex: 1; min-width: 200px; max-width: none; }
.bt-querybox.is-off { opacity: .55; }
.bt-more { display: flex; justify-content: center; padding: var(--bt-s3); min-block-size: 1px; }
.bt-spin { display: inline-block; inline-size: 1em; block-size: 1em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: bt-spin .8s linear infinite; vertical-align: -.15em; }
@keyframes bt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bt-spin { animation-duration: 2.4s; } }
.bt-concform .bt-findbox { flex: 1; min-width: 220px; }
.bt-kwic { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: var(--bt-font-text); font-size: 1.1rem; }
.bt-kwic th { font-family: var(--bt-font-ui); font-size: var(--bt-fs-xs); font-weight: 600; color: var(--bt-ink-faint); text-align: start; padding: 6px; border-block-end: 1px solid var(--bt-ink); }
.bt-kwic td { padding: 4px 6px; border-block-end: 1px solid var(--bt-border); white-space: nowrap; overflow: hidden; vertical-align: baseline; }
.bt-kwic tbody tr:hover td { background: var(--bt-bg-sunken); }
.bt-kwic th:first-child { width: 9.5em; }
.bt-kwic th.bt-kwic__k { text-align: center; }
.bt-kwic th.bt-kwic__l { text-align: end; }
.bt-kwic__ref { font-family: var(--bt-font-ui); font-size: var(--bt-fs-xs); }
.bt-kwic__ref a, .bt-kwic__ref button { color: var(--bt-blue); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.bt-kwic__l { text-align: end; }
.bt-clipl { display: flex; justify-content: flex-end; overflow: hidden; }   /* long left context is clipped on its far (left) side */
.bt-clipl span { flex: none; }
.bt-kwic__r span { display: inline-block; }
td.bt-kwic__k { text-align: center; overflow: visible; }
.bt-kwic__k mark { background: var(--bt-hit); color: var(--bt-ink); font-weight: 600; padding-inline: 3px; border-radius: 2px; }
.bt-kwic__tr td { white-space: normal; font-style: italic; color: var(--bt-ink-soft); font-size: .9em; padding-block-end: 8px; }
.bt-kwic--compact { font-size: 1rem; }
.bt-kwic--compact th:first-child { width: 3.5em; }
.bt-line.is-flash { animation: bt-flash 1.6s ease-out; }
@keyframes bt-flash { from { background: var(--bt-hit-active); } to { background: transparent; } }
.bt-subtabs { display: flex; gap: var(--bt-s5); border-block-end: 1px solid var(--bt-border); margin-block: var(--bt-s4) var(--bt-s5); }
.bt-subtabs a { padding-block: 8px; text-decoration: none; color: var(--bt-ink-soft); border-block-end: 2px solid transparent; margin-block-end: -1px; }
.bt-subtabs a[aria-current="page"] { color: var(--bt-ink); border-color: var(--bt-accent); font-weight: 600; }

/* Reader tools: text on the left (with its header), tool on the right; everything else hidden */
html.bt-locked, html.bt-locked body { overflow: hidden; }
.bt-tool { position: fixed; inset-block: 0; inset-inline: 0; z-index: 95; background: var(--bt-bg); display: flex; flex-direction: column; }
html.bt-toolmode .bt-tool { inset-block-start: var(--bt-chrome-h); inset-inline-start: var(--bt-textpane); border-inline-start: 1px solid var(--bt-border); box-shadow: -8px 0 24px rgba(0,0,0,.06); }
.bt-tool__bar { background: var(--bt-surface); border-block-end: 1px solid var(--bt-border); flex: none; }
.bt-tool__barin { display: flex; align-items: center; gap: var(--bt-s3); min-height: 48px; padding-inline: var(--bt-s5); }
.bt-tool__barin .bt-btn { padding-block: 4px; }
.bt-tool__title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bt-tool__title h2 { font-size: var(--bt-fs-md); font-weight: 600; }
.bt-tool__title > span { color: var(--bt-ink-faint); font-size: var(--bt-fs-sm); }
.bt-tool__hint { font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); white-space: nowrap; }
.bt-tool__hint kbd { font: inherit; border: 1px solid var(--bt-border-strong); border-block-end-width: 2px; border-radius: 3px; padding: 0 5px; background: var(--bt-bg); color: var(--bt-ink-soft); }
.bt-tool__body { flex: 1; overflow-y: auto; padding: var(--bt-s5) var(--bt-s5) var(--bt-s7); }
/* tool mode uses the whole window: no page-width cap anywhere inside the tool */
.bt-tool .bt-container { max-width: none; margin-inline: 0; }
.bt-tool__body > .bt-container { padding-inline: 0; }
.bt-tool__barin.bt-container { padding-inline: var(--bt-s5); }

:root { --bt-textpane: 42%; --bt-chrome-h: calc(var(--bt-header-h) + var(--bt-crumb-h) + 2px); }
.bt-readpane__head { position: sticky; inset-block-start: 0; z-index: 2; background: var(--bt-surface); border-block-end: 1px solid var(--bt-border); padding: 10px 0 8px; }
.bt-readpane__head h2 { font-size: var(--bt-fs-lg); font-weight: 600; line-height: 1.2; }
.bt-readpane__head p { font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); }
/* site header + breadcrumb stay, pinned above both panes */
html.bt-toolmode .bt-header { position: fixed; inset-inline: 0; inset-block-start: 0; z-index: 97; }
html.bt-toolmode .bt-header .bt-container, html.bt-toolmode .bt-crumbbar .bt-container { max-width: none; padding-inline: var(--bt-s5); }
html.bt-toolmode .bt-crumbbar { position: fixed; inset-inline: 0; inset-block-start: calc(var(--bt-header-h) + 1px); z-index: 97; }
html.bt-toolmode .bt-titlebar, html.bt-toolmode .bt-side,
html.bt-toolmode .bt-toolbar, html.bt-toolmode .bt-footer, html.bt-toolmode .bt-cite-float { display: none; }
html.bt-toolmode .bt-readpane { position: fixed; inset-block: var(--bt-chrome-h) 0; inset-inline-start: 0; width: var(--bt-textpane); overflow-y: auto; z-index: 94;
  background: var(--bt-surface); padding-inline: var(--bt-s5); --bt-zoom: .9 !important; }
html.bt-toolmode .bt-readpane .bt-text { padding-block-start: var(--bt-s3); }
html.bt-toolmode .bt-section-title { scroll-margin-block-start: 80px; }
@media (max-width: 860px) {
  html.bt-toolmode .bt-tool { inset-inline-start: 0; }
  html.bt-toolmode .bt-readpane { display: none; }
}
.bt-simlayout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--bt-s6); align-items: start; }
@media (max-width: 860px) { .bt-simlayout { grid-template-columns: 1fr; } .bt-tool__hint { display: none; } }


/* ---------- Phones & small screens ---------- */
.bt-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  :root { --bt-fs-sm: .9375rem; }
  .bt-container { padding-inline: var(--bt-s4); }
  .bt-section { padding-block: var(--bt-s5); }
  /* 16px inputs stop iOS from zooming on focus */
  input, select, textarea, .bt-input, .bt-searchbox input, .bt-findbox input { font-size: 1rem; }
  .bt-btn { min-height: 40px; }
  .bt-btn--sm { min-height: 34px; padding-inline: 12px; }
  .bt-chip, .bt-az button, .bt-pager button { min-height: 34px; padding-inline: 10px; }
  .bt-az button { min-width: 30px; }
  .bt-tree__toggle { width: 34px; height: 36px; }
  .bt-tree__link, .bt-listitem { padding-block: 10px; }
  .bt-band { padding-block: var(--bt-s5) var(--bt-s5); }
  .bt-searchbox kbd { display: none; }
  .bt-stat { flex: 1 1 50%; border-block-end: 1px solid var(--bt-border-strong); }
  .bt-stat:nth-child(2n) { border-inline-end: 0; }
  .bt-featured-grid { grid-template-columns: 1fr; }
  .bt-news li { flex-wrap: wrap; gap: 4px var(--bt-s3); }
  .bt-news time { width: auto; }
  .bt-newsitem[style] { grid-template-columns: 1fr !important; }
  .bt-sectionhead { flex-wrap: wrap; }
  .bt-titlebar h1 { font-size: var(--bt-fs-lg); }
  .bt-master--miller > .bt-pane { max-height: 60vh; }
  .bt-pane--detail { padding: var(--bt-s4); }
  .bt-meta { grid-template-columns: 1fr; gap: 0 var(--bt-s4); }
  .bt-meta dd { margin-block-end: 8px; }
  .bt-subtabs { gap: var(--bt-s4); overflow-x: auto; white-space: nowrap; }
  /* reader */
  .bt-toolbar { position: static; }
  .bt-findbox { min-width: 0; max-width: none; flex-basis: 100%; }
  .bt-toolbar__sep { display: none; }
  .bt-text { font-size: calc(1.125rem * var(--bt-zoom, 1)); }
  .bt-line { grid-template-columns: 2.5em minmax(0, 1fr); gap: var(--bt-s2); }
  .bt-line--parallel { grid-template-columns: 2.5em minmax(0, 1fr); }
  .bt-line--parallel .bt-line__tr { grid-column: 2; }
  .bt-line--prose .bt-line__text { text-align: start; }
  .bt-cite-float { inset-inline-end: 12px; inset-block-end: 12px; }
  .bt-toast { max-width: calc(100vw - 24px); inset-block-end: 12px; text-align: center; }
  .bt-modal__head, .bt-modal__body { padding: var(--bt-s4); }
  .bt-selpop { max-width: calc(100vw - 16px); }
  /* tools (concordance, similar passages, stats) */
  .bt-tool__barin, .bt-tool__barin.bt-container { padding-inline: var(--bt-s3); gap: var(--bt-s2); }
  .bt-tool__body { padding: var(--bt-s4) var(--bt-s4) var(--bt-s7); }
  .bt-tool__title > span { display: none; }
  html.bt-toolmode .bt-header .bt-container, html.bt-toolmode .bt-crumbbar .bt-container { padding-inline: var(--bt-s4); }
  .bt-lexsearch .bt-findbox, .bt-concform .bt-findbox { min-width: 0; flex-basis: 100%; }
  .bt-lexsearch .bt-segment { margin: 0; }
  .bt-lexres { padding: var(--bt-s3); }
  .bt-kwic { table-layout: auto; font-size: 1rem; }
  .bt-kwic th:first-child { width: 5em; }
  .bt-freq .bt-freq__bar { display: none; }
  .bt-compare { display: block; overflow-x: auto; }
  .bt-tiles { grid-template-columns: repeat(2, 1fr); }
  .bt-tiles > div { border-block-end: 1px solid var(--bt-border); }
  .bt-menu { min-width: 0; width: min(280px, calc(100vw - 24px)); }
  .bt-dodont { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .bt-footer__in { flex-direction: column; gap: var(--bt-s3); }
  .bt-grid-auto { grid-template-columns: 1fr !important; }
  .bt-header__in .bt-langswitch button { padding-inline: 8px; }
}

/* Reader outline: collapsible once the layout stacks (tablet & phone) */
.bt-sidetoggle { display: none; }
@media (max-width: 1100px) {
  .bt-sidetoggle { display: flex; align-items: center; justify-content: space-between; gap: var(--bt-s3); width: 100%; min-height: 44px; padding: 8px var(--bt-s3); background: none; border: 0; text-align: start; font-size: var(--bt-fs-sm); color: var(--bt-ink); }
  .bt-sidetoggle__t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bt-sidetoggle__t > span { color: var(--bt-ink-faint); }
  .bt-sidetoggle svg { flex: none; transition: transform .15s; }
  .bt-sidetoggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .bt-side--left.is-collapsed .bt-tabs, .bt-side--left.is-collapsed .bt-side__body { display: none; }
  .bt-side--left .bt-tabs { border-block-start: 1px solid var(--bt-border); }
  .bt-side--left .bt-side__body { max-height: 50vh; overflow-y: auto; }
}
@media (max-width: 720px) {
  .bt-zoom { display: none; }
  .bt-crumbs ol { flex-wrap: nowrap; }
  .bt-crumbs li { flex: none; }
}

/* Catalogue drill-down: on phones & tablets show one level at a time */
.bt-drillbar { display: none; }
@media (max-width: 980px) {
  .bt-master.is-drill > .bt-pane:not(.is-current) { display: none; }
  .bt-master.is-drill > .bt-pane { max-height: none; }
  .bt-master { min-height: 0; }
  .bt-drillbar { display: flex; position: sticky; inset-block-start: var(--bt-header-h); z-index: 6; background: var(--bt-surface); border-block-end: 1px solid var(--bt-border); }
  .bt-drillbar__back { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 48px; padding: 8px var(--bt-s4); background: none; border: 0; text-align: start; color: var(--bt-blue); font-size: var(--bt-fs-sm); font-weight: 600; }
  .bt-drillbar__back svg { transform: rotate(90deg); flex: none; }
  [dir="rtl"] .bt-drillbar__back svg { transform: rotate(-90deg); }
  .bt-drillbar__back span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Catalogue theming: one palette for every block (tree, lists, detail).
   Surfaces are white, sub-headers are sunken, the selection is navy, red only labels collections.
   Languages carry no colour here. */
.bt-master .bt-tag--lang { background: var(--bt-bg-sunken); border-color: var(--bt-border-strong); color: var(--bt-ink-soft); }
.bt-master .bt-tree__link--lang { border-inline-start-color: transparent; }
.bt-master .bt-segment button.is-coll[aria-pressed="true"] { background: var(--bt-navy); }
.bt-master .bt-pane--detail { background: var(--bt-surface); }
.bt-master .bt-colhead, .bt-master .bt-searchhead { background: var(--bt-bg-sunken); border-block-end: 1px solid var(--bt-border); }
.bt-master .bt-searchhead { padding: 12px; }
.bt-master .bt-group { background: transparent; }
.bt-master .bt-pane--list .bt-xs.bt-muted[role="status"] { border-block-end: 1px solid var(--bt-border); }
.bt-master .bt-az button { background: var(--bt-surface); }
.bt-master .bt-work, .bt-master .bt-empty { background: var(--bt-surface); border-color: var(--bt-border); }
.bt-master .bt-searchhead--tree { margin-block-end: var(--bt-s2); }
.bt-master .bt-searchhead--tree .bt-segment { margin: 0; }
.bt-master .bt-pane--tree { padding-block-start: 0; }

.bt-titlebar__ed { margin-block-start: 2px; font-style: italic; }
@media (max-width: 720px) {
  .bt-titlebar { gap: var(--bt-s3); padding-block-end: var(--bt-s3); }
  .bt-titlebar__actions { gap: 6px; }
  .bt-titlebar__actions .bt-btn { min-height: 30px; padding: 2px 9px; gap: 5px; font-size: var(--bt-fs-xs); }
  .bt-titlebar__actions .bt-btn svg { width: 14px; height: 14px; }
}

/* Concordance on phones: each hit becomes a card — reference, then the context flowing as one line of text */
@media (max-width: 720px) {
  .bt-conc { min-width: 0; }
  .conc-examples { flex-wrap: nowrap; overflow-x: auto; padding-block-end: 4px; }
  .conc-examples > * { flex: none; }
  .bt-concform { gap: var(--bt-s2); }
  .bt-concform .bt-segment { width: 100%; }
  .bt-concform .bt-segment button { padding-block: 9px; }
  .bt-concform label.bt-row { flex: 1 1 100%; flex-wrap: nowrap; justify-content: space-between; }
  .bt-concform label.bt-row { min-width: 0; }
  .bt-concform label.bt-row .bt-input { flex: 1; min-width: 0; max-width: 60% !important; width: auto; }
  .bt-kwic, .bt-kwic tbody, .bt-kwic tr, .bt-kwic td { display: block; width: auto; }
  .bt-kwic thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .bt-kwic tr { padding-block: 10px; }
  .bt-kwic td { border: 0; padding: 0; overflow: visible; white-space: normal; }
  .bt-kwic tbody tr:hover td { background: none; }
  .bt-kwic tr:not(.bt-kwic__tr):not(:has(+ .bt-kwic__tr)), .bt-kwic tr.bt-kwic__tr { border-block-end: 1px solid var(--bt-border); }
  .bt-kwic tr:has(+ .bt-kwic__tr) { padding-block-end: 4px; }
  .bt-kwic tr.bt-kwic__tr { padding-block-start: 0; }
  .bt-kwic td.bt-kwic__ref { margin-block-end: 4px; }
  .bt-kwic td.bt-kwic__l, .bt-kwic td.bt-kwic__k, .bt-kwic td.bt-kwic__r { display: inline; text-align: start; line-height: 1.7; font-size: 1.15rem; }
  .bt-kwic .bt-clipl, .bt-kwic .bt-clipl span, .bt-kwic__r span { display: inline; }
  .bt-kwic td.bt-kwic__l::after { content: ' '; }
  .bt-kwic td.bt-kwic__k::after { content: ' '; }
  .bt-kwic__tr td:first-child { display: none; }
  .bt-kwic__tr td { padding: 0; font-size: var(--bt-fs-sm); }
}

/* ---------- Scope picker (assets/scope-picker.js) ---------- */
.bt-scope { position: relative; flex: 1; min-width: 0; max-width: 520px; }
.bt-scope__box { display: flex; align-items: center; gap: 8px; background: var(--bt-surface); border: 1.5px solid var(--bt-border-strong); border-radius: var(--bt-radius); padding: 2px 6px 2px 10px; min-height: 36px; }
.bt-scope__box:focus-within, .bt-scope.is-open .bt-scope__box { border-color: var(--bt-focus); }
.bt-scope__box > svg { color: var(--bt-ink-faint); flex: none; }
.bt-scope__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: var(--bt-fs-sm); padding-block: 5px; text-overflow: ellipsis; color: var(--bt-ink); }
.bt-scope__clear { flex: none; display: grid; place-items: center; width: 28px; height: 28px; background: none; border: 0; border-radius: 50%; color: var(--bt-ink-faint); }
.bt-scope__clear:hover { background: var(--bt-bg-sunken); color: var(--bt-ink); }
.bt-scope__list { position: absolute; z-index: 60; inset-inline: 0; inset-block-start: calc(100% + 4px); max-height: min(420px, 60vh); overflow-y: auto; background: var(--bt-surface); border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius-lg); box-shadow: var(--bt-shadow-pop); min-width: min(360px, 100vw - 32px); }
.bt-scope__head { position: sticky; inset-block-start: 0; background: var(--bt-bg-sunken); border-block: 1px solid var(--bt-border); padding: 4px 12px; font-size: var(--bt-fs-xs); font-weight: 600; color: var(--bt-ink-faint); letter-spacing: .04em; text-transform: uppercase; }
.bt-scope__group:first-child .bt-scope__head { border-block-start: 0; }
.bt-scope__opt { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: var(--bt-fs-sm); border-block-end: 1px solid var(--bt-border); }
.bt-scope__opt:last-child { border-block-end: 0; }
.bt-scope__opt.is-active { background: var(--bt-blue-soft); }
.bt-scope__opt[aria-selected="true"] .bt-scope__label { font-weight: 600; }
.bt-scope__opt.is-all { font-weight: 600; }
.bt-scope__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bt-scope__label { overflow-wrap: anywhere; }
.bt-scope__path { font-size: var(--bt-fs-xs); color: var(--bt-ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-scope__count { flex: none; color: var(--bt-ink-faint); white-space: nowrap; }
/* the two kinds read differently at a glance: collections in rubric red (as everywhere on the site), editions neutral */
.bt-scope__badge { flex: none; font-size: var(--bt-fs-xs); font-weight: 600; line-height: 1.5; padding: 0 7px; border-radius: 2px; white-space: nowrap; border: 1px solid; }
.bt-scope__badge[data-type="collection"] { color: var(--bt-accent); background: var(--bt-accent-soft); border-color: var(--bt-accent-bright); }
.bt-scope__badge[data-type="edition"] { color: var(--bt-ink-soft); background: var(--bt-bg-sunken); border-color: var(--bt-border-strong); }
.bt-scope__msg { padding: 12px; font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); }
.bt-scope__retry { background: none; border: 0; padding: 0; color: var(--bt-blue); text-decoration: underline; }
.bt-scopefield { flex: 1 1 280px; flex-wrap: nowrap; }
@media (max-width: 720px) {
  .bt-scope { max-width: none; }
  .bt-scope__input { font-size: 1rem; }
  .bt-scope__opt { padding-block: 11px; }
  .bt-scope__list { min-width: 0; max-height: 55vh; }
  .bt-scope__badge { display: none; }
  .bt-scope__opt .bt-scope__badge { display: inline-block; }
  .bt-scopefield { flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 4px; }
  .bt-scopefield .bt-scope { max-width: none; width: 100%; }
}

/* facet mode (multiple): chips live inside the field, the list stays open while toggling */

.bt-scope__chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 1px 2px 1px 8px; font-size: var(--bt-fs-xs); border: 1px solid; border-radius: 2px; }
.bt-scope__chip[data-type="collection"] { color: var(--bt-accent); background: var(--bt-accent-soft); border-color: var(--bt-accent-bright); }
.bt-scope__chip[data-type="edition"] { color: var(--bt-ink-soft); background: var(--bt-bg-sunken); border-color: var(--bt-border-strong); }
.bt-scope__chiplabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.bt-scope__chipx { display: grid; place-items: center; width: 22px; height: 22px; background: none; border: 0; border-radius: 2px; color: inherit; padding: 0; }
.bt-scope__chipx:hover { background: rgba(0,0,0,.08); }
.bt-scope.is-multiple .bt-scope__input { flex: 1 1 8ch; min-width: 8ch; }
.bt-scope__check { flex: none; width: 1.1em; color: var(--bt-navy); font-weight: 700; }
.bt-scope__opt.is-on { background: var(--bt-bg); }
.bt-scope__opt.is-on.is-active { background: var(--bt-blue-soft); }
.bt-scope__done { display: none; position: sticky; inset-block-end: 0; width: 100%; padding: 12px; border: 0; border-block-start: 1px solid var(--bt-border-strong); background: var(--bt-navy); color: var(--bt-on-navy); font-size: var(--bt-fs-sm); }
@media (max-width: 720px) { .bt-scope__done { display: block; } .bt-scope__chipx { width: 28px; height: 28px; } .bt-scope__chip { font-size: var(--bt-fs-sm); } }

/* facet mode — selected values. Placement is chosen by the page (see docs/scope-picker.md):
   above = stacked, one per row (default) · below / target = wrapped row · inline = inside the field */
.bt-scope__field { position: relative; }
.bt-scope__chips { display: flex; flex-direction: column; gap: 4px; list-style: none; margin: 0 0 8px; padding: 0; min-width: 0; }
.bt-scope__chips:not(.is-flow) .bt-scope__chip { width: 100%; justify-content: space-between; padding-block: 3px; }
.bt-scope__chips.is-flow { flex-direction: row; flex-wrap: wrap; margin: 8px 0 0; }
.bt-scope__chiplabel { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.bt-scope__chips.is-flow .bt-scope__chiplabel { flex: 0 1 auto; max-width: 28ch; }
.bt-scope__chipx { margin-inline-start: auto; flex: none; }
.bt-scope--inline .bt-scope__box { flex-wrap: wrap; row-gap: 4px; padding-block: 4px; cursor: text; }
.bt-scope--inline .bt-scope__chips.is-flow { display: contents; }
.bt-scope--inline .bt-scope__chips.is-flow .bt-scope__chip { max-width: 100%; }

/* details on hover / keyboard focus of a selected value */
.bt-scope__chip { position: relative; }
.bt-scope__tip { display: none; position: absolute; z-index: 70; inset-inline-start: 0; inset-block-start: calc(100% + 4px); min-width: 180px; max-width: min(320px, 90vw); padding: 8px 10px; background: var(--bt-ink); color: #fff; border-radius: var(--bt-radius); font-size: var(--bt-fs-xs); line-height: 1.4; box-shadow: var(--bt-shadow-pop); pointer-events: none; flex-direction: column; gap: 2px; white-space: normal; }
.bt-scope__tip b { font-weight: 600; opacity: .7; margin-inline-end: 4px; }
.bt-scope__tip.is-on { display: flex; }

.bt-conc__scopeout:empty { display: none; }
.bt-conc__scopeout .bt-scope__chips.is-flow { margin: 0; }

/* header theme button + logo swap in dark */
.bt-themebtn { display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border: 1px solid var(--bt-border); border-radius: 50%; background: transparent; color: var(--bt-ink-soft); cursor: pointer; }
.bt-themebtn:hover { background: var(--bt-bg-sunken); color: var(--bt-ink); }
:root[data-theme="dark"] .bt-logo__img { content: url(img/biblissima-sans-baseline-blanc.png); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bt-logo__img { content: url(img/biblissima-sans-baseline-blanc.png); } }
:root[data-theme="dark"] .bt-band::before { opacity: .12; }

.bt-toplist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; counter-reset: t; }
.bt-toplist li { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; padding: 6px 0; border-block-end: 1px solid var(--bt-border); counter-increment: t; font-size: var(--bt-fs-sm); }
.bt-toplist li::before { content: counter(t); inline-size: 1.4em; color: var(--bt-ink-faint); font-variant-numeric: tabular-nums; }
.bt-toplist li a { flex: 1; min-width: 0; }
.bt-top .bt-sectionhead small { font-weight: 400; font-size: var(--bt-fs-xs); }

/* Ingestion admin */
.bt-staging { background: var(--bt-hit); border-block-end: 1px solid var(--bt-hit-active); color: var(--bt-ink); font-size: var(--bt-fs-sm); padding: 6px 12px; text-align: center; }
.bt-ingest-row { display: grid; grid-template-columns: 1fr auto; gap: var(--bt-s3); padding-block: var(--bt-s3); border-block-end: 1px solid var(--bt-border); }
.bt-ingest-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 var(--bt-s4); }
.bt-messages { margin: 4px 0 0; padding-inline-start: 18px; font-size: var(--bt-fs-sm); color: var(--bt-ink-soft); }
.bt-sample { white-space: pre-wrap; font-family: var(--bt-font-text); border-inline-start: 3px solid var(--bt-border-strong); padding-inline-start: 12px; max-height: 14em; overflow: auto; }
@media (max-width: 640px) { .bt-ingest-row { grid-template-columns: 1fr; } }
.bt-ingest-filter { gap: 8px; margin-block-end: 8px; }
.bt-ingest-filter .bt-input { width: auto; flex: 0 1 260px; }
.bt-ingest-actions { align-self: center; justify-content: flex-end; max-width: 330px; gap: var(--bt-s2); }
.bt-live { border: 1px solid var(--bt-border-strong); border-radius: var(--bt-radius-lg); background: var(--bt-surface); padding: var(--bt-s4); }
.bt-live__line { margin-block: var(--bt-s2) 2px; font-size: var(--bt-fs-sm); }
.bt-live__line b { font-size: var(--bt-fs-lg); font-variant-numeric: tabular-nums; }
.bt-progress { height: 10px; margin-block-start: var(--bt-s3); background: var(--bt-bg-sunken); border: 1px solid var(--bt-border); border-radius: var(--bt-radius); overflow: hidden; }
.bt-progress > span { display: block; height: 100%; background: var(--bt-navy); transition: width .8s linear; }
.bt-steps { list-style: none; margin: var(--bt-s3) 0 0; padding: 0; display: grid; gap: 4px; font-size: var(--bt-fs-sm); color: var(--bt-ink-faint); }
.bt-steps li { display: flex; align-items: baseline; gap: var(--bt-s2); }
.bt-steps li::before { content: '○'; width: 1em; text-align: center; }
.bt-steps li small { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.bt-steps li.is-done { color: var(--bt-ink-soft); }
.bt-steps li.is-done::before { content: '✓'; color: var(--bt-success); }
.bt-steps li.is-current { color: var(--bt-ink); font-weight: 600; }
.bt-steps li.is-current::before { content: '▸'; color: var(--bt-navy); }
.bt-steps li.is-failed { color: var(--bt-accent); }
.bt-steps li.is-failed::before { content: '×'; }
.bt-steps li.is-waiting::before { content: '…'; }
.bt-state::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-inline-end: 6px; border-radius: 50%; background: var(--bt-border-strong); }
.bt-state.is-ok::before { background: var(--bt-success); }
.bt-state.is-behind::before { background: var(--bt-hit-active); }
.bt-state.is-busy::before { background: var(--bt-blue); }
.bt-linkbtn { background: none; border: 0; padding: 0; color: var(--bt-blue); text-decoration: underline; font: inherit; cursor: pointer; }
@media (max-width: 640px) { .bt-ingest-actions { justify-content: flex-start; max-width: none; } }
@media (prefers-reduced-motion: reduce) { .bt-progress > span { transition: none; } }
