/* BachataLibrary custom styles. */
:root {
  /* Default theme accent is blue (matches format-row palette). Per-row pill
     accents (style=red, format=blue, type=orange, source=green, status=purple)
     are unaffected — they each declare their own --row-accent. The clearing
     buttons (.bl-toolbar-clear, .bl-sidebar-clear, modal-close) stay red on
     purpose. */
  --bl-accent: #1d4ed8;
  --bl-accent-bg: #dbeafe;
  /* Per-row palettes — solid enough to read at a glance. Each row sets a stronger
     `--row-accent` (used for pill hover/active border + active bg) and
     `--row-bg` (the row background tint). */
  --bl-row-style: #ffd6df;       --bl-row-style-accent:  #be123c;
  --bl-row-format: #b9deff;      --bl-row-format-accent: #1d4ed8;
  --bl-row-type: #ffd9b5;        --bl-row-type-accent:   #c2410c;
  --bl-row-source: #b8edd5;      --bl-row-source-accent: #047857;
  --bl-row-status: #d8d1f5;      --bl-row-status-accent: #6d28d9;
  --bl-row-transcript: #fde68a;  --bl-row-transcript-accent: #b45309;
  --bl-thumb-size: 220px;
}

/* ---- Filter pills (ColdFluMedsDashboard pattern) ---- */
.bl-pill {
  font-size: 12px; padding: 3px 10px;
  border: 1px solid #c7c7c7; border-radius: 999px;
  background: #fff; color: #111;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
  text-decoration: none;
  /* `--row-accent` is set on the row container (.bl-row-style etc.) and
     inherited here. The var() fallback covers pills outside any colored row. */
}
.bl-pill:hover { border-color: var(--row-accent, var(--bl-accent)); background: var(--row-accent-bg, var(--bl-accent-bg)); }
.bl-pill.bl-active {
  background: var(--row-accent, var(--bl-accent)); color: #fff;
  border-color: var(--row-accent, var(--bl-accent));
}
.bl-pill.bl-active:hover { filter: brightness(.85); }
.bl-pill .bl-pill-check { display: inline-block; width: 1em; text-align: center; font-weight: 700; }
.bl-pill.bl-pill-checkable .bl-pill-check { color: var(--row-accent, var(--bl-accent)); }
.bl-pill.bl-active .bl-pill-check { color: #fff; }
.bl-pill .bl-pill-count {
  font-size: 10px; opacity: .7;
  background: rgba(0, 0, 0, .05);
  padding: 0 5px; border-radius: 999px;
  margin-left: 2px;
}
.bl-pill.bl-active .bl-pill-count { opacity: 1; color: #fff; background: rgba(255, 255, 255, .2); }
/* Empty pills: dimmed but still clickable */
.bl-pill.bl-pill-empty { color: #94a3b8; border-color: #e5e7eb; }
.bl-pill.bl-pill-empty .bl-pill-count { opacity: .4; }
.bl-pill.bl-pill-empty:hover { color: #475569; border-color: var(--row-accent, var(--bl-accent)); background: var(--row-accent-bg, var(--bl-accent-bg)); }
.bl-pill-removable .bl-pill-x { margin-left: 4px; opacity: .7; }
.bl-pill-removable:hover .bl-pill-x { opacity: 1; }

/* ---- Sidebar nav rows (Teachers / Concepts / Categories) ---- */
.bl-nav-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 6px; align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none !important;  /* Kill the default link underline */
  color: #1e293b;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.bl-nav-row:hover {
  background: rgba(29, 78, 216, .08);
  color: var(--bl-accent);
}
.bl-nav-row.bl-nav-active {
  background: linear-gradient(90deg, var(--bl-accent-bg), rgba(219, 234, 254, .35));
  color: var(--bl-accent);
  font-weight: 600;
}
.bl-nav-row.bl-nav-active:hover {
  background: linear-gradient(90deg, rgba(29, 78, 216, .18), var(--bl-accent-bg));
}
.bl-nav-check {
  font-weight: 700; color: var(--bl-accent);
  text-align: center; line-height: 1;
}
.bl-nav-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* Force a leading capital on every sidebar entry — child suffixes like
     "interrupted" / "scurry" / "alt exits" come straight from concept
     canonical names which are mixed-case. We use ::first-letter (not
     `text-transform: capitalize`) so we DON'T uppercase the Spanish "y"
     in teacher names like "Alan y Pati". inline-block is required for
     ::first-letter to take effect on inline-context elements. */
  display: inline-block;
}
.bl-nav-label::first-letter {
  text-transform: uppercase;
}
.bl-nav-count {
  font-size: 11px; color: #94a3b8;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, .05);
  padding: 0 6px; border-radius: 999px;
  min-width: 24px; text-align: center;
}
.bl-nav-row.bl-nav-active .bl-nav-count {
  background: rgba(255, 255, 255, .35);
  color: var(--bl-accent);
}

/* ---- Categories tree (sidebar) — ChatGPT-recommended SAFE pattern (2nd
   consult, 2026-05-03). All rows share the same grid so column geometry
   stays identical; indentation is ONLY done via padding-left. Child check
   placeholder uses visibility:hidden so the column width is still occupied. */
.bl-cat-tree {
  --row-pad-x: 8px;
  --level-0-indent: 24px;       /* parent rows — reduced ~1/3 from 36 (per user 2026-05-03) */
  --level-1-indent: 40px;       /* children — reduced ~1/3 from 60 */
  /* Dashed-guide x in viewport pixels from .bl-cat-children left edge.
     Triangle SVG center sits at: row.padding-left + button.padding-left + svg.width/2
                                 = 24 + 4 + 6 = 34 px from the row's left edge.
     .bl-cat-children left edge equals row left edge, so guide-x = 34 lines up. */
  --guide-x: 34px;
  list-style: none; padding: 0; margin-top: 4px; margin-left: 4px;
}
/* Leaf top-level rows (no children → no triangle): render a CSS dot in the
   check column. Absolute-positioned at exactly x=10 (matching the triangle
   SVG center, since triangle = col-x + button-pad-left:4 + svg-half:6 = 10).
   Same color as triangles, slightly bigger than the 12px triangle for
   visibility (per user 2026-05-03). */
.bl-cat-tree .bl-top-row:not(.bl-cat-group-parent) .bl-nav-check {
  position: relative;
}
.bl-cat-tree .bl-top-row:not(.bl-cat-group-parent) .bl-nav-check:empty::before {
  content: '';
  position: absolute;
  left: 10px;                   /* triangle SVG center x, in col-1's local frame */
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;      /* slightly bigger than 6px would be — visible at sidebar size */
  border-radius: 50%;
  background: #334155;          /* same slate-700 as triangles */
}
.bl-cat-children { list-style: none; padding: 0; margin: 0; position: relative; }

/* Same grid for all rows: check | label | (optional triangle) | count */
.bl-cat-tree .bl-nav-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 6px; align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  box-sizing: border-box;
}
/* Group parents reuse the 3-col grid: triangle takes the FIRST column slot
   (same column the check ✓ uses on leaf rows) so all top-level labels still
   land at the same x. */
/* Indentation per level — the ONLY way we differentiate parents vs children */
.bl-cat-tree .bl-top-row     { padding-left: var(--level-0-indent); }
.bl-cat-tree .bl-cat-children .bl-nav-row { padding-left: var(--level-1-indent); }

/* Top-level labels: bold + slate-900 */
.bl-cat-tree .bl-top-row .bl-nav-label { color: #0f172a; font-weight: 700; }
.bl-cat-tree .bl-cat-children .bl-nav-label { color: #475569; font-weight: 400; }
/* Top-level (BachaZouk-level) count badges: bold + black to match the parent
   label styling. Children counts stay in the lighter slate-400. */
.bl-cat-tree .bl-top-row .bl-nav-count { color: #0f172a; font-weight: 700; }

/* Children: keep the check column for geometric consistency, just hide it */
.bl-cat-tree .bl-cat-children .bl-nav-check { visibility: hidden; }

/* Group <details> + summary plumbing */
.bl-cat-group { margin: 0; }
.bl-cat-group > summary {
  list-style: none;
  cursor: pointer;
  display: block;
}
.bl-cat-group > summary::-webkit-details-marker { display: none; }
.bl-cat-group > summary::marker { content: ''; }
.bl-cat-group-parent:hover {
  background: rgba(29, 78, 216, .08);
  color: var(--bl-accent);
}

/* Triangle button (inline between label and count) */
.bl-cat-group-tri {
  background: transparent; border: 0; padding: 2px 4px;
  cursor: pointer;
  color: #334155;
  display: inline-grid; place-items: center;
  border-radius: 4px;
  line-height: 0;
}
.bl-cat-group-tri:hover { background: rgba(15, 23, 42, .08); color: #0f172a; }
.bl-cat-group-tri svg {
  display: block;
  width: 12px; height: 12px;
  fill: currentColor;
  transition: transform .16s ease;
}
.bl-cat-group[open] > summary .bl-cat-group-tri svg {
  transform: rotate(90deg);
}

/* Vertical dashed guide for children */
.bl-cat-children::before {
  content: '';
  position: absolute;
  left: var(--guide-x);
  top: 2px; bottom: 2px;
  border-left: 1px dashed #94a3b8;
}

/* ---- Header nav dropdown (Partners menu) ---- */
.bl-nav-dropdown { position: relative; display: inline-block; }
.bl-nav-trigger { cursor: pointer; }
.bl-nav-menu {
  position: absolute;
  /* No vertical gap between trigger and menu so the cursor can travel from
     trigger into menu without losing :hover. (Earlier ::before bridge caused
     a ghost-stuck-open glitch — eliminated by removing the gap entirely.) */
  top: 100%;
  left: 0;
  min-width: 220px; max-height: 70vh; overflow-y: auto;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .14), 0 4px 8px rgba(15, 23, 42, .06);
  padding: 4px 0;
  opacity: 0; transform: translateY(-4px);
  pointer-events: none;
  /* `visibility: hidden` makes the menu items invisible to Safari/Chrome
     Find-on-page (⌘F). Without this, Find matches text inside closed
     dropdowns (e.g. "Songs needing ID", "Song conflicts") and renders
     yellow highlight rectangles at the wrong position because the menu
     is off-screen via opacity (per user 2026-05-03). The visibility
     transition is delayed by .12s on close so the opacity fade still
     completes before the menu disappears from layout. */
  visibility: hidden;
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
  z-index: 50;
}
.bl-nav-dropdown:hover .bl-nav-menu,
.bl-nav-dropdown:focus-within .bl-nav-menu {
  opacity: 1; transform: translateY(0); pointer-events: auto;
  visibility: visible;
  /* On open, visibility flips immediately (no delay) so menu becomes
     interactive at the same instant the fade-in starts. */
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear 0s;
}
.bl-nav-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 12px;
  font-size: 13px; color: #334155; text-decoration: none;
}
.bl-nav-menu-item:hover { background: rgba(29, 78, 216, .08); color: #1d4ed8; }
.bl-nav-menu-all {
  border-bottom: 1px solid #e2e8f0; margin-bottom: 4px;
  font-weight: 600; color: #1d4ed8;
}
.bl-nav-menu-count {
  font-variant-numeric: tabular-nums;
  background: #e2e8f0; color: #475569;
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  min-width: 26px; text-align: center;
}

/* ---- Partner concept-status collapsible groups ---- */
.bl-status-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0;
}
.bl-status-group > summary::-webkit-details-marker { display: none; }
.bl-status-tri {
  display: inline-block;
  width: 10px; height: 10px; line-height: 10px;
  font-size: 8px; color: #64748b; text-align: center;
  transition: transform .15s ease-out;
  flex: 0 0 auto;
}
.bl-status-group[open] > summary > .bl-status-tri {
  transform: rotate(90deg);
}
/* Partner-concept badges */
.bl-pc-vidcount {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  background: rgba(15, 23, 42, .08); color: #475569;
  padding: 1px 7px; margin-left: 6px;
  border-radius: 999px; text-decoration: none;
  vertical-align: middle;
}
.bl-pc-vidcount:hover { background: rgba(29, 78, 216, .15); color: #1d4ed8; }
.bl-pc-tags {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.bl-pc-tag {
  font-size: 10px; padding: 1px 6px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: 999px;
  color: #475569; text-transform: lowercase;
}
/* "Assign to other partner" mini-dropdown next to each concept row */
.bl-pc-assign { position: relative; }
.bl-pc-assign-trigger {
  list-style: none;
  cursor: pointer;
  font-size: 11px; line-height: 1;
  color: #1d4ed8;
  background: rgba(29, 78, 216, .08);
  border: 1px solid rgba(29, 78, 216, .25);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.bl-pc-assign-trigger::-webkit-details-marker { display: none; }
.bl-pc-assign-trigger::marker { display: none; content: ''; }
.bl-pc-assign-trigger:hover { background: rgba(29, 78, 216, .18); }
.bl-pc-assign[open] > .bl-pc-assign-trigger {
  background: #1d4ed8; color: #fff; border-color: #1d4ed8;
}
.bl-pc-assign-menu {
  position: absolute;
  top: calc(100% + 4px); right: 0;
  min-width: 160px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .14);
  padding: 4px 0;
  z-index: 60;
}
.bl-pc-assign-header {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: #94a3b8; padding: 4px 10px 2px;
}
.bl-pc-assign-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px;
  font-size: 12px;
}
.bl-pc-assign-item button {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; cursor: pointer; color: #1d4ed8;
  text-align: left; width: 100%;
}
.bl-pc-assign-item button:hover { color: #0f172a; }
.bl-pc-assign-item.is-checked { color: #94a3b8; cursor: not-allowed; }

/* Two-column grid layout: label in column 1 (fixed width), pills in column 2.
   Pills that wrap stay in column 2 (hanging indent), not under the label.
   Compact sizing is now ALWAYS-ON (per user 2026-05-03) — float toggle now
   only controls whether the dashboard sticks/scrolls, not its size. */
.bl-control-row {
  display: grid;
  grid-template-columns: 80px 1fr;        /* widened from 60 so 'TRANSCRIPT' fits without overlap */
  gap: 4px 8px; align-items: center;
  padding: 3px 10px; border: 1px solid #e5e7eb; border-bottom: none;
}
.bl-control-label { font-size: 9px; letter-spacing: .3px; }
.bl-pills { gap: 4px; }
.bl-pill { font-size: 10px; padding: 1px 7px; gap: 2px; line-height: 1.2; }
.bl-pill .bl-pill-count { font-size: 9px; padding: 0 4px; }
.bl-pill .bl-pill-check { font-size: 9px; }
.bl-toolbar-pills { gap: 6px; }
.bl-toolbar-clear, .bl-toolbar-btn { font-size: 10px; padding: 1px 7px; }
.bl-toolbar-btn > span[aria-hidden] { font-size: 11px; }
/* The .bl-pill-more-item <span> wrappers exist so JS can hide individual
   pills via [hidden]. Make them transparent to layout so they don't add
   weird vertical spacing on flex-wrap (per user 2026-05-03). */
.bl-pill-more-item { display: contents; }
.bl-pill-more-item[hidden] { display: none; }
.bl-control-row:first-child { border-radius: 8px 8px 0 0; }
.bl-control-row:last-child { border-bottom: 1px solid #e5e7eb; border-radius: 0 0 8px 8px; }
.bl-row-style  { background: var(--bl-row-style);  --row-accent: var(--bl-row-style-accent);  --row-accent-bg: #ffe4e9; }
.bl-row-format { background: var(--bl-row-format); --row-accent: var(--bl-row-format-accent); --row-accent-bg: #dbe9fb; }
.bl-row-type   { background: var(--bl-row-type);   --row-accent: var(--bl-row-type-accent);   --row-accent-bg: #ffe6cf; }
.bl-row-source { background: var(--bl-row-source); --row-accent: var(--bl-row-source-accent); --row-accent-bg: #c6f0db; }
.bl-row-status { background: var(--bl-row-status); --row-accent: var(--bl-row-status-accent); --row-accent-bg: #e6dffa; }
.bl-row-transcript { background: var(--bl-row-transcript); --row-accent: var(--bl-row-transcript-accent); --row-accent-bg: #fef3c7; }
/* "Show N more" pseudo-pill in the Transcript row. Click to expand all
   .bl-pill-more-item siblings; click again to collapse back to top-10. */
.bl-pill-more {
  font-style: italic;
  cursor: pointer;
  background: transparent;
  border-color: var(--row-accent, var(--bl-accent));
  color: var(--row-accent, var(--bl-accent));
}
.bl-pill-more:hover { background: var(--row-accent-bg, var(--bl-accent-bg)); }
/* When expanded, keep `display: contents` (set above on .bl-pill-more-item) so
   the wrapper <span> is transparent to the parent flex layout. An earlier
   `display: inline-block` here made the wrapper a real flex item that carried
   the body's 24px line-height as a strut, padding each wrapped pill row to
   ~26px and making transcript pills LOOK taller than other rows' pills (per
   user 2026-05-03 — pills themselves are still 16px in both rows, only the
   row spacing looked off). [hidden] still wins via the rule above. */
.bl-row-search { background: #fafafa; }
.bl-row-toolbar { background: #f8fafc; }

/* Toolbar pills (Clear all, Show staging, Float toggle) */
.bl-toolbar-pills { gap: 10px; }
.bl-toolbar-clear {
  background: #fff; border: 1px solid #fca5a5; color: #b91c1c;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.bl-toolbar-clear:hover { background: #fee2e2; border-color: #ef4444; }
.bl-toolbar-clear.is-disabled {
  color: #cbd5e1; border-color: #e5e7eb;
  pointer-events: none; cursor: default;
}

/* Sidebar's own Clear all — same pill style as dashboard Clear all for consistency */
.bl-sidebar-clear {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid #fca5a5; color: #b91c1c;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  cursor: pointer; text-decoration: none;
}
.bl-sidebar-clear:hover { background: #fee2e2; border-color: #ef4444; }
.bl-sidebar-clear.is-disabled {
  color: #cbd5e1; border-color: #e5e7eb;
  pointer-events: none; cursor: default;
}
/* Toolbar buttons (Show staging, Float) — uniform pill-like style. */
.bl-toolbar-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: #475569;
  cursor: pointer;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff;
  text-decoration: none;
  font-family: inherit;
}
.bl-toolbar-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.bl-toolbar-btn.is-active {
  background: var(--bl-accent); color: #fff; border-color: var(--bl-accent);
}
.bl-toolbar-btn.is-active:hover { filter: brightness(.9); }
.bl-toolbar-btn > span[aria-hidden] { font-size: 13px; line-height: 1; }

/* ---- Dashboard layout ----
   Always renders at the top of <main> abutting the header (zeroed top padding).
   Float toggle only changes scroll behavior — when `.is-floating`, position:sticky
   keeps it stuck during scroll; when off, it scrolls away with content. Either
   way the INITIAL position is identical, so toggling never causes vertical jump
   (per user 2026-05-03). Default state: float ON, set by JS init.
   Backgrounds get 90% opacity so content scrolls visibly behind when floating. */
body main { padding-top: 0; }
.bl-dashboard.is-floating {
  position: sticky;
  top: var(--bl-header-h, 60px);
  z-index: 5;                              /* below header (z-10) so we slide under, not over */
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
}
.bl-dashboard {
  margin-top: -1px;                        /* hide hairline subpixel gap regardless of float state */
}
.bl-dashboard .bl-row-toolbar    { background: rgba(248, 250, 252, .9); }
.bl-dashboard .bl-row-style      { background: rgba(255, 214, 223, .9); }
.bl-dashboard .bl-row-format     { background: rgba(185, 222, 255, .9); }
.bl-dashboard .bl-row-type       { background: rgba(255, 217, 181, .9); }
.bl-dashboard .bl-row-source     { background: rgba(184, 237, 213, .9); }
.bl-dashboard .bl-row-status     { background: rgba(216, 209, 245, .9); }
.bl-dashboard .bl-row-transcript { background: rgba(253, 230, 138, .9); }

/* The pills container — second grid column. Lets pills wrap with consistent
   hanging indent at the column-2 left edge (not under the label). */
.bl-control-row > .bl-pills {
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center;
  align-content: flex-start;       /* prevent extra vertical space between wrapped lines (default stretch was distributing 9px extra per line) */
  min-width: 0;
}

/* Now that compact sizing is unconditional (per user 2026-05-03), the label
   keeps its uppercase + weight but at the smaller font set above. */
.bl-control-label {
  font-weight: 600; text-transform: uppercase; color: #4a4a4a;
  align-self: center;
}

/* ---- Resizable sidebar layout ---- */
.bl-page {
  display: grid;
  /* sidebar width persisted in --bl-sidebar-w (default 220px); handle is 6px; results take the rest */
  grid-template-columns: var(--bl-sidebar-w, 220px) 6px 1fr;
  gap: 0;
  align-items: start;
}
.bl-sidebar {
  /* Scrollable pane that stays put while the grid scrolls. Sticky-positioned
     just below the floating dashboard (which itself sits below the header).
     `--bl-dashboard-h` is JS-synced via ResizeObserver in grid.js, so the
     sidebar's top auto-adjusts as filters wrap or the dashboard collapses on
     mobile. The user can scroll deep into a long category list and click an
     item without losing their place — `initScrollPersist()` in sidebar.js
     saves & restores scrollTop across the page reload that the click triggers. */
  position: sticky;
  top: calc(var(--bl-header-h, 60px) + var(--bl-dashboard-h, 0px) + 8px);
  max-height: calc(100vh - var(--bl-header-h, 60px) - var(--bl-dashboard-h, 0px) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  min-width: 120px;
}
/* Slimmer scrollbar for the sidebar (WebKit + Firefox). */
.bl-sidebar::-webkit-scrollbar { width: 6px; }
.bl-sidebar::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .35); border-radius: 3px; }
.bl-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .6); }
.bl-sidebar { scrollbar-width: thin; scrollbar-color: rgba(100, 116, 139, .35) transparent; }
.bl-sidebar.collapsed { display: none; }
.bl-sidebar-handle {
  cursor: col-resize;
  background: transparent;
  border-left: 1px solid #e5e7eb;
  height: 100%; min-height: 60vh;
  position: relative;
  user-select: none;
  touch-action: none;
}
.bl-sidebar-handle:hover, .bl-sidebar-handle.dragging {
  border-left-color: var(--bl-accent);
  background: rgba(190, 18, 60, 0.08);
}
.bl-results-wrap { padding-left: 16px; min-width: 0; }

/* Narrow / mobile: stack sidebar above results, hide the resize handle (a column-
   resize cursor in a single-column flow makes no sense). Filter pill rows already
   wrap naturally because they're inline-flex. */
@media (max-width: 720px) {
  .bl-page {
    grid-template-columns: 1fr;
  }
  .bl-sidebar {
    padding-right: 0;
    /* Override the desktop sticky/scrollable-pane behavior on mobile —
       the sidebar is opened from a tap-toggle drawer, not a sticky pane. */
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .bl-sidebar-handle { display: none; }
  .bl-results-wrap { padding-left: 0; padding-top: 12px; }
  .bl-control-row { flex-wrap: wrap; }
  .bl-view-controls { flex-wrap: wrap; gap: 8px; }
}

/* ---- Grid + List view ---- */
.bl-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(var(--bl-thumb-size), 1fr));
}
.bl-card {
  background: white; border: 1px solid #e2e8f0; border-radius: 8px;
  overflow: hidden; transition: box-shadow .15s, border-color .15s;
  display: block; cursor: pointer;
}
.bl-card:hover { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: #93c5fd; }
.bl-card .vid-thumb {
  aspect-ratio: var(--card-aspect, 16/9); object-fit: contain; background: #000;
  width: 100%; display: block;
}

.bl-results.bl-list { grid-template-columns: 1fr !important; gap: 6px; }
.bl-results.bl-list .bl-card {
  display: grid; grid-template-columns: var(--bl-thumb-size) 1fr;
  gap: 12px; padding: 0; align-items: center;
}
.bl-results.bl-list .bl-card .vid-thumb {
  aspect-ratio: var(--card-aspect, 16/9); height: auto; max-width: var(--bl-thumb-size);
}
.bl-results.bl-list .bl-card .bl-card-body { padding: 8px 12px; }
.bl-results.bl-list .bl-card .bl-card-title { font-size: 14px; -webkit-line-clamp: 1; }

/* The card body fills remaining card height and stacks BOTTOM-aligned — the
   whole content stack (title + meta + tags) sits flush at the bottom of the
   body, leaving any extra height as whitespace AT THE TOP. This way short
   titles in a row of taller neighbors visually align on a baseline (rather
   than floating in the middle with title at top + meta at bottom). */
.bl-card { display: flex; flex-direction: column; }
.bl-card-body {
  padding: 8px;
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  justify-content: flex-end;
}

/* Spinner shown while hover preview is buffering */
/* Carousel-post badge in card grid */
.bl-carousel-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0, 0, 0, .65); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  pointer-events: none; user-select: none;
  z-index: 2;
}

/* Carousel arrows + dots in player */
.bl-player { position: relative; }
.bl-carousel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 5;
  width: 36px; height: 56px;
  background: rgba(0, 0, 0, .55); color: #fff;
  border: none; border-radius: 6px;
  font-size: 28px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, opacity .15s;
}
.bl-carousel-arrow:hover { background: rgba(0, 0, 0, .8); }
.bl-carousel-arrow:disabled { opacity: .3; cursor: default; }
.bl-carousel-prev { left: 8px; }
.bl-carousel-next { right: 8px; }
.bl-carousel-dots {
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 0 4px 0;
  flex-wrap: wrap;
}
.bl-carousel-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  padding: 7px; /* 22px outer, 8px visible — touch target ≥22px */
  background: transparent; cursor: pointer;
  position: relative;
  transition: transform .15s;
}
.bl-carousel-dot::before {
  content: ''; position: absolute;
  top: 7px; left: 7px; width: 8px; height: 8px;
  border-radius: 50%; background: #cbd5e1;
  transition: background .15s;
}
.bl-carousel-dot:hover::before { background: #94a3b8; }
.bl-carousel-dot:hover { transform: scale(1.15); }
.bl-carousel-dot.is-active::before { background: var(--bl-accent); }
.bl-carousel-dot.is-active { transform: scale(1.2); }

.bl-card.bl-hover-loading::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%;
  animation: bl-spin .9s linear infinite;
  z-index: 2; pointer-events: none;
}
.bl-card { position: relative; }
@keyframes bl-spin { to { transform: rotate(360deg); } }
/* Card text scales with --bl-text-scale (set by grid.js applySize from the
   thumb-size slider). Default 1.0 keeps the baseline 13/11/10 sizes. */
.bl-card-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: calc(13px * var(--bl-text-scale, 1));
  font-weight: 500; line-height: 1.25;
}
.bl-card-meta {
  display: flex; justify-content: space-between;
  font-size: calc(11px * var(--bl-text-scale, 1));
  color: #64748b; margin-top: 4px;
}
.bl-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bl-tag {
  padding: 2px 6px; border-radius: 4px;
  font-size: calc(10px * var(--bl-text-scale, 1));
}
.bl-tag-teacher { background: #f1f5f9; }
.bl-tag-event { background: #dbeafe; color: #1e40af; }
.bl-tag-variant { background: #ede9fe; color: #6d28d9; }
.bl-tag-staging { background: #fef3c7; color: #92400e; }
.bl-tag-fav { background: #ffe4e6; color: #be123c; }

.bl-card .vid-preview {
  /* Hover-autoplay preview matches the same aspect as the still thumbnail
     so transition is seamless and the video isn't cropped. */
  width: 100%; aspect-ratio: var(--card-aspect, 16/9);
  object-fit: contain; background: #000;
  display: none;
}
.bl-card.bl-hover-playing .vid-thumb { display: none; }
.bl-card.bl-hover-playing .vid-preview { display: block; }

/* ---- Custom video player ---- */
.bl-player { position: relative; width: 100%; }
.bl-player video {
  width: 100%; background: #000; border-radius: 8px; display: block;
  aspect-ratio: var(--video-aspect, 16/9);
  object-fit: contain;
  max-height: 80vh;
}
/* ---- Player control banner: pure-black strip below the video. 4 groups
   distributed evenly via space-between; tight intra-group spacing. ---- */
.bl-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; margin: 0 auto;
  background: #000;
  border-radius: 0 0 8px 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  color: #e2e8f0;
  flex-wrap: nowrap;
  overflow: visible;
  position: relative; z-index: 7;
}
.bl-ctrl-group {
  display: inline-flex; align-items: center; gap: 0;   /* tight intra-group */
}
.bl-btn {
  background: transparent; border: none; border-radius: 4px;
  padding: 2px 4px; font-size: 12px; cursor: pointer;  /* less padding */
  display: inline-flex; align-items: center; justify-content: center;
  gap: 3px; color: inherit;
  height: 28px; min-width: 28px;
  line-height: 1;
}
.bl-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.bl-btn.bl-active { color: var(--bl-accent); background: transparent; }
.bl-btn.bl-active:hover { background: rgba(59, 130, 246, .18); }
/* Speed popup (icon trigger + small flyout menu) */
.bl-speed-pop { position: relative; }
.bl-speed-trigger { list-style: none; }
.bl-speed-trigger::-webkit-details-marker { display: none; }
.bl-speed-trigger::marker { display: none; content: ''; }
.bl-speed-label {
  font-size: 11px; font-variant-numeric: tabular-nums;
  margin-left: 2px;
}
.bl-speed-menu {
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  background: #1e293b; border: 1px solid #334155;
  border-radius: 6px; padding: 4px 0;
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  z-index: 200;                       /* above video + dim layer */
}
.bl-speed-opt {
  background: transparent; border: 0; color: #e2e8f0;
  font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 4px 16px; text-align: center; cursor: pointer;
  white-space: nowrap;
}
.bl-speed-opt:hover { background: rgba(255,255,255,.1); }
.bl-speed-opt.is-current { color: var(--bl-accent); font-weight: 600; }
.bl-ab-status {
  font-variant-numeric: tabular-nums; font-size: 11px;
  color: #93c5fd;
}

/* ---- Dim mode (lights-out backdrop) ----
   When body.bl-dim-on, EVERYTHING outside the .bl-player is darkened so the
   video stands out. On the detail page the page background/layout fades; on
   the quickview modal the body backdrop stays dark. Default on.

   We use a fixed-position vignette overlay that is placed BEHIND the player
   wrapper but in front of the rest of the page. The .bl-player is given a
   higher z-index so it punches through the dim layer. */
body.bl-dim-on::after {
  content: '';
  position: fixed; inset: 0;
  background: rgba(8, 12, 18, .72);
  pointer-events: none;
  z-index: 5;
  transition: opacity .15s ease-out;
}
body.bl-dim-on .bl-player { position: relative; z-index: 6; }
body.bl-dim-on .bl-controls { position: relative; z-index: 6; }
body.bl-dim-on .bl-modal { z-index: 100; }
body.bl-dim-on .bl-modal-card { z-index: 101; }
/* The video-meta line (e.g. "720×1280 (portrait) · 0:57 · 30 fps · h264") sits
   inside .bl-player at z-index 6, but the area below the video is transparent —
   so the dark dim-overlay (rgba(8,12,18,.72)) shows through and the default
   text-slate-500 (#64748b) on that blue-tinted dark bg looks "weird". Switch
   to a neutral mid-gray that reads consistently against either background. */
body.bl-dim-on .bl-player .text-slate-500 { color: #94a3b8; }

/* ---- Plyr overlay readability ----
   The default Plyr controls overlay is translucent; over light video frames
   the progress track + thumb become invisible (only the white scrubber dot
   is visible — looks like a stray "dim" button). Force a darker bottom
   gradient AND increase progress-track opacity so the bar is always visible. */
.plyr--video .plyr__controls {
  background: linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,.55) 65%, rgba(0,0,0,.85) 100%);
  padding: 24px 10px 8px;
}
.plyr--video .plyr__progress__container { min-width: 80px; }
.plyr--video .plyr__progress input[type=range] { color: #ffffff; }
.plyr__progress__buffer { background: rgba(255,255,255,.35) !important; }
/* Plyr's progress track itself ("seekTime" base) — make it visible */
.plyr--full-ui input[type=range].plyr__progress {
  --plyr-range-track-background: rgba(255,255,255,.30);
  --plyr-range-fill-background: #3b82f6; /* blue-500 to match theme */
}
.bl-saved-flash {
  color: #059669; font-size: 11px;
  animation: bl-saved-fade 2s ease-out forwards;
}
@keyframes bl-saved-fade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}
.bl-time { font-variant-numeric: tabular-nums; font-size: 12px; color: #475569; margin-left: auto; }

.bl-hud {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0, 0, 0, .7); color: white;
  padding: 6px 12px; border-radius: 6px;
  font-family: -apple-system, monospace; font-size: 14px; font-weight: 600;
  pointer-events: none; opacity: 0; transition: opacity .15s;
  letter-spacing: .5px; z-index: 5;
}

/* A↔B loop markers — overlay on Plyr progress bar */
.bl-ab-marker {
  position: absolute; top: 0; bottom: 0;
  width: 2px; pointer-events: none;
  z-index: 4;
}
.bl-ab-marker.a { background: #10b981; box-shadow: 0 0 4px #10b981; }
.bl-ab-marker.b { background: #ef4444; box-shadow: 0 0 4px #ef4444; }
.bl-ab-marker::after {
  content: attr(data-label);
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  background: inherit; color: white; padding: 1px 6px;
  font-size: 10px; font-weight: 600; border-radius: 3px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.bl-ab-band {
  position: absolute; top: 0; bottom: 0;
  background: rgba(16, 185, 129, .15);
  pointer-events: none; z-index: 3;
}
.bl-ab-status {
  font-variant-numeric: tabular-nums; font-size: 11px;
  color: #059669; margin-left: 4px;
}

/* ---- Cheatsheet overlay ---- */
#bl-cheatsheet {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#bl-cheatsheet.hidden { display: none; }
#bl-cheatsheet .panel {
  background: white; border-radius: 12px; padding: 24px;
  max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
}
#bl-cheatsheet h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 12px; }
#bl-cheatsheet h3 { font-size: 0.875rem; font-weight: 600; margin: 16px 0 6px; color: #475569; text-transform: uppercase; letter-spacing: .5px; }
#bl-cheatsheet kbd {
  display: inline-block; padding: 2px 8px;
  font-family: ui-monospace, monospace; font-size: 12px;
  background: #f1f5f9; border: 1px solid #cbd5e1; border-bottom-width: 2px;
  border-radius: 4px; color: #1e293b;
}
#bl-cheatsheet .row {
  display: grid; grid-template-columns: 200px 1fr; gap: 8px;
  padding: 4px 0; font-size: 13px;
}

/* Hide WebKit/Chromium's built-in clear button on type="search" inputs —
   we render our own .bl-search-clear ✕. Otherwise users see TWO ✕ icons. */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none; appearance: none;
}

/* ---- Search dropdown (ShowCaseAnalysis pattern, blur + portal-to-body) ---- */
.bl-search-dropdown {
  position: fixed;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, .25);
  max-height: min(60vh, 520px);
  overflow-y: auto;
  font-size: 13px;
  padding: 4px 0;
  opacity: 0; transform: translateY(-4px);
  transition: opacity 140ms ease-out, transform 140ms ease-out;
  pointer-events: none;
}
.bl-search-dropdown:not(.hidden) {
  opacity: 1; transform: translateY(0); pointer-events: auto;
}
.bl-search-dropdown.hidden { display: none; }
.bl-search-dropdown .sd-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: #64748b;
  padding: 8px 12px 4px;
  border-bottom: 1px solid rgba(226, 232, 240, .5);
  margin-top: 2px;
}
.bl-search-dropdown .sd-group-label:first-child { margin-top: 0; }
.bl-search-dropdown .sd-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 7px 12px;
  color: #1e293b;
  text-decoration: none !important;     /* Kill any link underline */
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.bl-search-dropdown .sd-row:hover {
  background: rgba(29, 78, 216, .08);
  color: var(--bl-accent);
}
.bl-search-dropdown .sd-icon {
  display: inline-block; font-size: 13px; opacity: .65;
  margin-right: 6px; vertical-align: middle;
}
.bl-search-dropdown .sd-label {
  /* No truncation — let labels wrap so titles aren't cut to single letters. */
  white-space: normal; overflow-wrap: anywhere; line-height: 1.3;
}
.bl-search-dropdown .sd-label mark { background: #fef3c7; padding: 0 2px; }
.bl-search-dropdown .sd-meta { font-size: 11px; color: #64748b; font-variant-numeric: tabular-nums; }
.bl-search-dropdown .sd-empty { padding: 16px; text-align: center; color: #64748b; }
.bl-search-dropdown .sd-footer {
  padding: 6px 12px; font-size: 11px; color: #64748b;
  border-top: 1px solid rgba(226, 232, 240, .6); margin-top: 4px;
}
.bl-search-dropdown .sd-footer kbd {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 3px;
  padding: 0 4px; font-family: ui-monospace, monospace; font-size: 10px;
}

/* Keyboard-shortcuts hint button next to the search bar.
   Sized like a real button — used to be 18px in an inline style and felt
   like a typo. Now matches the search field's vertical rhythm. */
.bl-kbd-hint {
  font-size: 22px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  /* Square hit target — cursor target should comfortably fit a fingertip
     even on desktop where touch screens exist. */
  min-width: 40px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Clear button inside the search bar */
header form { position: relative; }
.bl-search-clear {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: #e2e8f0; border: none; border-radius: 50%;
  width: 18px; height: 18px; line-height: 18px;
  cursor: pointer; font-size: 11px; color: #475569;
  display: flex; align-items: center; justify-content: center;
}
.bl-search-clear:hover { background: var(--bl-accent); color: white; }
header input[name="q"] { padding-right: 32px; }

/* ---- View controls bar ---- */
.bl-view-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 12px; flex-wrap: wrap;
}
.bl-view-controls label { display: inline-flex; align-items: center; gap: 6px; }
.bl-view-controls input[type=range] { width: 140px; }
.bl-view-toggle { display: flex; gap: 0; border: 1px solid #cbd5e1; border-radius: 6px; overflow: hidden; }
.bl-view-toggle button {
  background: white; padding: 4px 10px; cursor: pointer; border: none;
  font-size: 12px;
}
.bl-view-toggle button.bl-active { background: var(--bl-accent); color: white; }

/* ---- Quick-view modal (ShowCase pattern) ---- */
#bl-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#bl-modal.hidden { display: none; }
.bl-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.bl-modal-shell {
  position: relative;
  background: white;
  border-radius: 12px;
  width: min(900px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .35);
  z-index: 1;
}
/* Modal toolbar — inline strip at the top of the shell that holds the close
   ✕ button (mac standard: close on the LEFT). Replaces the prior absolute-
   positioned button which overlapped the title area. */
.bl-modal-toolbar {
  display: flex; align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px 12px 0 0;
}
.bl-modal-close {
  background: transparent; border: 1px solid transparent;
  border-radius: 999px; width: 24px; height: 24px;
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #475569;
  padding: 0; line-height: 1;
}
.bl-modal-close:hover { background: #fef2f2; color: #be123c; }
.bl-modal-content { padding: 16px 20px 20px; }
body.bl-modal-open { overflow: hidden; }

/* ---- Quick-view layout (vertical: video on top, everything else stacked) ----
   The video element itself is height-capped so the title + video + Plyr
   controls (with progress bar) + bl-controls + carousel dots all fit inside
   the modal viewport without scroll. We cap ONLY the <video> tag, NOT the
   .plyr wrapper — capping .plyr clips the controls overlay (the progress
   bar in particular). Reserve ~260px for header + Plyr controls bar +
   bl-controls + carousel dots. */
.bl-quickview { display: flex; flex-direction: column; }
.bl-quickview .bl-qv-header { flex: 0 0 auto; }
/* Quickview header banner — gradient strip so the header has visual weight
   instead of looking like loose text floating above the video. */
.bl-qv-banner {
  background: linear-gradient(90deg, rgba(59, 130, 246, .08), rgba(15, 23, 42, .04));
  border-left: 3px solid var(--bl-accent);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  color: #0f172a;
  display: flex; flex-direction: column; gap: 6px;
}
.bl-qv-title { font-size: 16px; font-weight: 700; color: #0f172a; line-height: 1.2; }
.bl-qv-title-prefix { color: var(--bl-accent); }
.bl-qv-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bl-qv-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1;
  padding: 4px 8px; border-radius: 999px;
  background: #fff; border: 1px solid #e2e8f0;
  color: #334155; text-decoration: none;
  white-space: nowrap;
}
.bl-qv-pill svg { display: block; }
.bl-qv-pill-date    { background: #fef3c7; border-color: #fde68a; color: #854d0e; }
.bl-qv-pill-teacher { background: #dbeafe; border-color: #bfdbfe; color: #1e40af; }
.bl-qv-pill-event   { background: #fce7f3; border-color: #fbcfe8; color: #9d174d; text-transform: capitalize; }
.bl-qv-pill-variant { background: #f3e8ff; border-color: #e9d5ff; color: #7e22ce; font-weight: 600; }
.bl-qv-pill-action  { background: var(--bl-accent); border-color: var(--bl-accent); color: #fff; }
.bl-qv-pill-action:hover { background: #1e40af; border-color: #1e40af; }
.bl-quickview .bl-player { margin-bottom: 8px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
}
.bl-quickview .bl-player .plyr,
.bl-quickview .bl-player .plyr__video-wrapper {
  max-height: calc(92vh - 260px);
}
.bl-quickview .bl-player video {
  max-height: calc(92vh - 260px);
}
.bl-quickview .qv-section {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid #e2e8f0;
}
.bl-quickview .qv-section:first-of-type { border-top: none; padding-top: 0; }
.bl-quickview h2 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; color: #334155; }
.bl-quickview h1 { font-size: 1.25rem; font-weight: 600; margin-bottom: 4px; }

/* Unified card-section heading used in detail.html sidebar (Concepts, Song,
   Source, Transcript, Sidecars) and quickview sections. Plain `font-semibold`
   black text was visually flat — too much same-weight content per user
   2026-05-03. This makes headings scannable: uppercase + letter-spacing for
   typographic distinction, slate-600 muted color, slate-200 underline strip,
   small emoji icon kept at normal case sized slightly larger than the label. */
/* Selector includes h2/h3 tags so it beats `.bl-quickview h2` specificity
   (0,1,1) without needing !important. */
h2.bl-card-heading,
h3.bl-card-heading,
.bl-card-heading {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: #475569; text-transform: uppercase;
  padding-bottom: 6px; margin-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.bl-card-heading .bl-card-icon {
  font-size: 14px; letter-spacing: 0; text-transform: none;
  font-weight: normal;
  /* Emojis don't get inherited letter-spacing; reset for clean rendering. */
}

/* ---- Vertical popup volume slider (attaches to Plyr's mute button) ---- */
.bl-vol-popup {
  position: absolute;
  bottom: 100%; left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(15, 23, 42, .92);
  border-radius: 6px;
  padding: 10px 6px 6px;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 100;
}
.bl-vol-popup.is-open {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(-4px);
}
.bl-vol-popup input[type="range"][orient="vertical"] {
  -webkit-appearance: slider-vertical;
  writing-mode: bt-lr;
  width: 8px; height: 90px;
  cursor: pointer;
}
.bl-vol-popup .bl-vol-pct {
  color: #fff; font-size: 10px; font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  min-width: 32px; text-align: center;
}

/* ============================================================================
   MOBILE PASS (added 2026-05-03 from iPhone 13/14 viewport audit)

   Universal safety net + targeted overrides for screens ≤640px.
   Goal: every page usable in portrait iPhone without horizontal scrolling
   or content being shoved off-screen by hover-dropdowns and wide tables.
   ============================================================================ */

/* 1. Kill the universal 54px X-overflow caused by .bl-nav-menu being
   position:absolute with min-width:220px — even when visibility:hidden it
   still contributes to documentElement.scrollWidth. `overflow-x: clip` is
   the modern equivalent of `hidden` that does NOT create a scrolling
   context, so sticky positioning on the header keeps working. */
html, body { overflow-x: clip; }

/* 2. Mobile-first nav-menu: on narrow screens, drop the 220px min-width
   and let the menu align to the viewport edges via fixed positioning so
   it can never escape. */
@media (max-width: 640px) {
  .bl-nav-menu {
    position: fixed;
    top: var(--bl-header-h, 60px);
    left: 8px; right: 8px;
    min-width: 0; max-width: none; width: auto;
    max-height: 70vh;
  }
}

/* 3. Mobile header tightening: shorter brand, no emojis (they're
   decorative), tighter gaps, single-row when it fits. The stats line is
   already hidden via Tailwind's `md:inline`. */
@media (max-width: 640px) {
  header .max-w-screen-2xl { gap: 6px !important; padding: 8px 10px !important; }
  /* Hide the dancer emoji prefix on mobile to free up width — they're
     decorative and the brand text is enough. */
  header a.font-bold {
    font-size: 0;             /* hide text nodes (incl. emojis) */
  }
  header a.font-bold::after {
    content: "BachataLibrary";
    font-size: 15px;
  }
  /* Tighter nav-trigger labels so Partners + Boot camp + Loose ends all fit
     on row 1 next to the brand. */
  header .bl-nav-trigger { font-size: 12px; padding: 0 2px; }
  /* Hide the keyboard-shortcuts button on touch devices — there's no keyboard
     to consult shortcuts for. (User asked 2026-05-03.) */
  header .bl-kbd-hint { display: none; }
  /* Make the search field own row 2 */
  header form { flex-basis: 100%; order: 99; }
}

/* 4. Mobile sidebar: hide the giant filter-pill dashboard by default,
   collapsed under a tap-toggle. The user's primary mobile action is to
   browse the video grid, not configure filters. The aside sidebar
   (Teachers/Categories tree) also collapses behind a toggle. */
@media (max-width: 720px) {
  /* Dashboard pill panel: hide rows by default; show a "Filters ▾" toggle */
  .bl-dashboard:not(.bl-mobile-open) > .bl-control-row:not(.bl-row-toolbar) {
    display: none;
  }
  /* In the toolbar row, suppress the "Float" button (irrelevant on mobile
     since sticky positioning + tiny viewport is awkward) */
  #bl-dashboard-float-toggle { display: none; }
  /* Show a mobile-only filters toggle button injected by JS, OR re-purpose
     the toolbar Filters label as the toggle */
  .bl-dashboard .bl-control-label.bl-mobile-toggle {
    cursor: pointer;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
  }
  .bl-dashboard .bl-control-label.bl-mobile-toggle::after {
    content: " ▾";
    color: #64748b;
  }
  .bl-dashboard.bl-mobile-open .bl-control-label.bl-mobile-toggle::after {
    content: " ▴";
  }

  /* Sidebar (Teachers/Categories) — collapse under a toggle too */
  #bl-sidebar:not(.bl-mobile-open) {
    display: none;
  }
  .bl-mobile-sidebar-toggle {
    display: inline-block;
    margin: 4px 0 8px;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
  }
}
@media (min-width: 721px) {
  /* Hide the mobile toggle button on desktop */
  .bl-mobile-sidebar-toggle { display: none; }
}

/* 5. Admin tables (admin_invites, admin_visitors): convert to card layout
   below 640px. The trick: thead is hidden, each <tr> becomes a block, each
   <td> is a label-value row using `data-label` attribute. */
@media (max-width: 640px) {
  table.bl-mobile-cards { display: block; width: 100%; }
  table.bl-mobile-cards thead { display: none; }
  table.bl-mobile-cards tbody { display: block; }
  table.bl-mobile-cards tr {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    padding: 8px 12px;
    margin-bottom: 10px;
  }
  table.bl-mobile-cards td {
    display: block;
    padding: 4px 0;
    border: none;
    text-align: left;
  }
  table.bl-mobile-cards td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 88px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: #64748b;
    margin-right: 8px;
  }
  /* When a cell is just a label-only spacer (action buttons), drop the label */
  table.bl-mobile-cards td[data-label=""]::before { content: none; }
  /* Long URL fields wrap nicely */
  table.bl-mobile-cards td code {
    display: inline-block;
    word-break: break-all;
    max-width: 100%;
  }
}

/* 6. Generic table fallback: any table not opted into card-mode gets a
   horizontal scroll wrapper instead of breaking layout. */
@media (max-width: 640px) {
  /* If a table is wrapped in .bl-table-scroll, scroll it horizontally */
  .bl-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 7. Detail page (form grid for Edit metadata): single column on mobile */
@media (max-width: 640px) {
  .bl-edit-grid, form.bl-edit-form .grid { grid-template-columns: 1fr !important; }
}

/* 8. Fix the cheatsheet modal so it doesn't overflow on mobile */
@media (max-width: 640px) {
  #bl-cheatsheet > div { max-width: 92vw; max-height: 80vh; overflow: auto; }
}

/* 9. Tighten the player control bar on mobile so all 8 buttons fit comfortably
   inside narrow portrait-video widths. The controls bar inherits the video's
   width (which for portrait is ~290px on iPhone), so default desktop padding
   would push the rightmost button (dim/moon) off the edge. */
@media (max-width: 640px) {
  .bl-controls { padding: 4px 4px; }
  .bl-controls .bl-btn { min-width: 24px; height: 26px; padding: 1px 2px; }
  .bl-controls .bl-seek-svg { width: 19px; height: 19px; }
  .bl-controls .bl-speed-trigger { padding: 1px 4px; }
  .bl-controls .bl-speed-label { font-size: 11px; }
  /* Make the player container span the full quickview modal width on mobile,
     so even when the video itself is portrait/aspect-constrained, the BLACK
     control banner gets the extra horizontal real estate. */
  .bl-quickview .bl-player { width: 100%; align-items: stretch; }
  /* Re-center the video element itself with auto margins (since align-items
     is now stretch, the video would otherwise stretch to full width and
     break aspect ratio — explicit margin auto preserves centering for the
     aspect-constrained video element). */
  .bl-quickview .bl-player video,
  .bl-quickview .bl-player .plyr,
  .bl-quickview .bl-player .plyr__video-wrapper {
    max-width: 100%;
    margin-left: auto; margin-right: auto;
  }
  /* The controls bar now spans full player width (looks like black letterbox
     bars extending past the video frame, which is fine — gives the buttons
     room to breathe). */
  .bl-controls { width: 100%; max-width: 100%; }
  /* Reclaim ~30px of width on mobile by trimming the quickview modal padding
     (was 16px outer + 20px inner = 36px each side; now 4px + 8px = 12px). */
  #bl-modal { padding: 4px; }
  .bl-modal-content { padding: 8px 8px 12px; }
}

