/* 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) ----
   Grid columns: ✓ check (16px) · emoji badge (1.4em) · label (1fr) ·
   count (auto). Categories tree overrides this further down because those
   rows don't have a badge column. Adding/removing a column here MUST be
   matched in browse.html (#sidebar) AND visually validated via the
   Playwright snippet at scripts/_visual_check_sidebar.py. */
.bl-nav-row {
  display: grid;
  /* Default: 3 columns (check / label / count) — for concept rows and the
     category tree. The 4-column variant below kicks in only when the row
     also contains a `.bl-nav-badge` child (teacher / partner emoji rows),
     so the label doesn't get squeezed into the badge slot when it's missing.
     Regression source: 2026-05-04 sidebar emoji-badge change set this to
     4 cols globally; concept rows fell into the wrong columns and rendered
     as "B…" with a wide bar where the count belongs. Fixed 2026-05-05. */
  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:has(.bl-nav-badge) {
  grid-template-columns: 16px 1.4em 1fr auto;
}
.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;
}
/* Emoji badge before each teacher/partner name — flex layout already handles
   spacing; explicit width keeps row alignment when the badge is missing. */
.bl-nav-badge {
  display: inline-block; min-width: 1.3em; line-height: 1;
  text-align: center; flex-shrink: 0;
}
.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;
  /* Disable native link-drag so mousedown+drag inside the anchor selects
     text instead of starting a link-ghost drag. Without this, every card
     title is unselectable because the <a> wrapper hijacks the gesture. */
  -webkit-user-drag: none;
  user-drag: none;
}
/* Inner text inside the anchor must be explicitly selectable (overrides any
   inherited / parent rule, and tells the browser to prefer text-selection
   over link-drag). Combined with draggable="false" on the <a> via JS, this
   makes every visible label inside a card copy-able. */
.bl-card,
.bl-card * {
  -webkit-user-select: text;
  user-select: text;
}
.bl-card:hover { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: #93c5fd; }
/* Stable thumb-wrap container (introduced 2026-05-09 so JS can bind hover
   ONLY to the thumb area). When present, the inner img/video fill 100% of
   it; when absent (older templates not yet wrapped), the legacy .vid-thumb
   rule below sizes the image directly. overflow MUST stay visible — the
   list-mode hover preview uses transform: scale() to grow OUTSIDE the
   wrap's 100×56 box and would be invisibly clipped by overflow: hidden. */
.bl-card .bl-card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: var(--card-aspect, 16/9);
  background: #000;
  position: relative;
  overflow: visible;
}
.bl-card .bl-card-thumb .vid-thumb,
.bl-card .bl-card-thumb .vid-preview {
  /* Both children are absolutely positioned so they OVERLAP within the wrap
     instead of stacking. Without position:absolute the two block-level
     elements would each take height:100% of the wrap (sequential block
     flow), the second sticking out below — caused list-view "video doesn't
     play" reports because the preview rendered below the thumb. */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}
/* Legacy rule for templates not yet wrapped (loose_ends_recent, bootcamp,
   partner, audit). Keeps their thumbs sized correctly. */
.bl-card > .vid-thumb {
  aspect-ratio: var(--card-aspect, 16/9); object-fit: contain; background: #000;
  width: 100%; display: block;
}

/* ─── List view as a real sortable table ───────────────────────────────
   Header + body share the same grid-template-columns so columns align.
   Header is `position: sticky`; default sits just under the page navbar
   (top: var(--bl-header-h)) so column labels stay visible. When the user
   has the dashboard floating (default ON), :has() bumps the offset down by
   --bl-dashboard-h so the table header floats RIGHT BELOW the dashboard,
   not under it. The list-only per-column `<span class="bl-cell">` elements
   live inside each card and replace the grid-mode body in list mode. */
:root {
  /* --bl-list-thumb-w + --bl-list-row-h are set live by grid.js applySize so
     the slider scales list rows and the thumb cell. Defaults match the legacy
     hardcoded baseline (slider=220 → thumb 100px / row 56px). */
  --bl-list-thumb-w: 100px;
  --bl-list-row-h: 56px;
  /* Per-column widths. Defaults are the legacy template; once the user
     drags a resize handle, grid.js sets the dragged column to a px value
     and persists it. fr-based columns continue to flex over the remaining
     space. The thumb column derives from --bl-list-thumb-w (slider-driven).
     Don't change these names without updating data-col in the header
     template + grid.js's COL_NAMES list. */
  --bl-col-thumb: var(--bl-list-thumb-w);
  --bl-col-title: minmax(0, 2fr);
  --bl-col-date: 96px;
  --bl-col-indexed: 96px;
  --bl-col-teacher: minmax(0, 1.1fr);
  --bl-col-account: minmax(0, 1.1fr);
  --bl-col-concept: minmax(0, 1.1fr);
  --bl-col-category: minmax(0, 1.1fr);
  --bl-col-dur: 88px;
  --bl-list-cols: var(--bl-col-thumb) var(--bl-col-title) var(--bl-col-date) var(--bl-col-indexed) var(--bl-col-teacher) var(--bl-col-account) var(--bl-col-concept) var(--bl-col-category) var(--bl-col-dur);
}
.bl-list-header {
  display: none;
  grid-template-columns: var(--bl-list-cols);
  gap: 8px;
  align-items: stretch;
  position: sticky;
  top: var(--bl-header-h, 60px);
  z-index: 5;
  background: white;
  border: 1px solid #e2e8f0; border-radius: 8px 8px 0 0; border-bottom: none;
  padding: 0;
  font-size: 12px; font-weight: 600; color: #475569;
  margin-bottom: 0;
}
/* When dashboard is floating, the table header should float right below it
   (not slide under it). :has() lets us condition the offset on the dashboard
   state without JS poking at a class on body. */
body:has(.bl-dashboard.is-floating) .bl-list-header {
  top: calc(var(--bl-header-h, 60px) + var(--bl-dashboard-h, 0px));
}
.bl-list-header .bl-list-h-thumb { /* spacer for thumbnail column */
  position: relative;
}
.bl-list-header .bl-list-h-col {
  background: transparent; border: none; padding: 8px 6px;
  text-align: left; font-weight: 600; color: inherit; cursor: pointer;
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 0;
  position: relative;
}
.bl-list-header .bl-list-h-col:hover { background: #f1f5f9; color: #0f172a; }
.bl-list-header .bl-list-h-col.is-sorted { color: #1d4ed8; }
.bl-list-header .bl-list-h-col .dir { font-weight: 700; margin-left: 2px; }
.bl-list-header .bl-list-h-dur { padding: 8px 6px; text-align: right; white-space: nowrap; overflow: visible; position: relative; }

/* Column resize handles. Sit on the right edge of each header cell, 8 px
   wide hit area centered on the gutter. Visible only on hover/drag so the
   header stays uncluttered. Cursor flips to col-resize. The handle itself
   is a sibling absolute element so its mousedown doesn't trigger the
   button's sort click — JS calls stopPropagation(). */
.bl-list-h-resize {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  /* Hit area sits ENTIRELY inside the parent header cell so the parent's
     overflow: hidden doesn't clip the right half. 12 px is wide enough to
     grab without precision pointing. The painted indicator at right edge
     gives the user a visible affordance. */
  width: 12px;
  cursor: col-resize;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
}
/* Always-visible vertical line indicating where the column can be resized.
   Faint default colour so it doesn't compete with the column labels; bold
   pink on hover or active drag. */
.bl-list-h-resize::before {
  content: "";
  position: absolute;
  top: 4px; bottom: 4px;
  right: 1px;
  width: 1px;
  background: #cbd5e1;
  border-radius: 1px;
  transition: background 0.12s, width 0.12s;
}
.bl-list-h-resize:hover::before,
.bl-list-h-resize.is-dragging::before {
  background: var(--bl-accent, #be123c);
  width: 2px;
}
/* During an active drag, freeze cursor + suppress text selection across
   the whole document so the user can drag freely. */
body.bl-col-resizing,
body.bl-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* Show header only when in list view */
.bl-results-wrap.is-list-view .bl-list-header { display: grid; }

/* List mode card layout — same column template as the header. */
.bl-results.bl-list { grid-template-columns: 1fr !important; gap: 0; }
.bl-results.bl-list .bl-card {
  display: grid;
  grid-template-columns: var(--bl-list-cols);
  gap: 8px; padding: 0;
  align-items: center;
  border-radius: 0;
  border-top: none;
  min-height: var(--bl-list-row-h, 56px);
}
.bl-results.bl-list .bl-card:first-of-type { border-top: 1px solid #e2e8f0; }
.bl-results.bl-list .bl-card:last-of-type { border-radius: 0 0 8px 8px; }
/* Light-blue row hover so the user can see which row their cursor is on,
   even when the title body / cells (not the thumb) is being hovered. */
.bl-results.bl-list .bl-card:hover {
  background: #eff6ff;
  box-shadow: none;
  border-color: #93c5fd;
}
/* List-mode rows must allow overflow so the 1.5x-scaled hover preview isn't
   clipped at the row bounding box. The grid-mode .bl-card uses overflow:hidden
   to round image corners; in list mode the row is borderless and the still
   thumb is grid-cell-pinned to 100×56, so removing the clip is safe. */
.bl-results.bl-list .bl-card { overflow: visible; }
/* In list mode pin BOTH the still thumb AND the hover-autoplay video preview
   to the SAME grid cell (column 1, row 1) at the fixed 100×56 size — without
   this the .vid-preview that grid.js appends as a sibling becomes the 10th
   child of a 9-col grid and lands in a phantom row spanning the whole card
   width (~1100 px) → autoplay was rendering huge. */
/* List mode + .bl-card-thumb wrap: the wrap is the grid-pinned element. The
   inner img/video fill it. */
.bl-results.bl-list .bl-card .bl-card-thumb {
  height: var(--bl-list-row-h, 56px);
  width: auto;
  max-width: var(--bl-list-thumb-w, 100px);
  aspect-ratio: var(--card-aspect, 16/9);
  margin: 0 auto;
  grid-column: 1 / 2; grid-row: 1 / 2;
  align-self: center; justify-self: center;
}
/* Fallback for older templates without the wrap — pin the thumb/preview
   directly into the grid cell (legacy 2026-05-08 rule). */
.bl-results.bl-list .bl-card > .vid-thumb,
.bl-results.bl-list .bl-card > .vid-preview {
  aspect-ratio: var(--card-aspect, 16/9);
  height: var(--bl-list-row-h, 56px);
  width: auto;
  max-width: var(--bl-list-thumb-w, 100px);
  margin: 0 auto;
  grid-column: 1 / 2; grid-row: 1 / 2;
  align-self: center; justify-self: center;
}
/* When playing in list mode, scale the preview up 2x so it's easier to read.
   transform scale doesn't disturb layout — other rows stay in place; the
   scaled preview just overflows above and below the row. The z-index lifts
   it above adjacent cards so the overflow paints over neighbours. */
.bl-results.bl-list .bl-card.bl-hover-playing {
  position: relative;
  z-index: 20;
}
.bl-results.bl-list .bl-card.bl-hover-playing .vid-preview {
  /* Adaptive scale: 3x at smallest slider value, 1.5x at largest. The var
     is set live by grid.js applySize via computePreviewScale(px). */
  transform: scale(var(--bl-list-preview-scale, 2));
  transform-origin: center center;
  border-radius: 4px;
  box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.45);
}
/* In list mode, the grid-mode body is hidden; per-column cells take over. */
.bl-results.bl-list .bl-card-body { display: none; }
.bl-cell { display: none; font-size: 13px; color: #334155; padding: 0 6px;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-results.bl-list .bl-cell { display: block; }
.bl-results.bl-list .bl-cell-title { font-weight: 500; color: #0f172a; }
.bl-results.bl-list .bl-cell-date,
.bl-results.bl-list .bl-cell-indexed,
.bl-results.bl-list .bl-cell-dur { font-variant-numeric: tabular-nums; color: #64748b; font-size: 12px; }
.bl-results.bl-list .bl-cell-dur { text-align: right; }
.bl-results.bl-list .bl-card-tags,
.bl-results.bl-list .bl-card-meta,
.bl-results.bl-list .bl-card-title {
  /* These belong to the grid-mode body which is hidden in list mode; defensive
     in case stray markup leaks through. */
  display: none;
}

/* In grid mode, the list-only cells must stay hidden (already handled by
   .bl-cell { display: none } default — kept for clarity / future-proofing). */
.bl-results.bl-grid-mode .bl-cell { display: none; }

/* Hide the Indexed column on narrower viewports — it's the least useful. */
@media (max-width: 1280px) {
  :root {
    /* Drop the indexed column on narrow screens; keep per-col vars so any
       persisted resize widths still apply to the remaining columns. */
    --bl-list-cols: var(--bl-col-thumb) var(--bl-col-title) var(--bl-col-date) var(--bl-col-teacher) var(--bl-col-account) var(--bl-col-concept) var(--bl-col-category) var(--bl-col-dur);
  }
  .bl-list-h-indexed { display: none !important; }
}

/* Phones: drop list view's tabular layout — a 9-col grid doesn't fit. The
   view-toggle is hidden on mobile by mobile.css, so list mode shouldn't be
   reachable, but guard anyway. */
@media (max-width: 640px) {
  .bl-list-header { display: none !important; }
  .bl-results.bl-list .bl-card { grid-template-columns: 1fr; }
  .bl-results.bl-list .bl-card .vid-thumb { max-width: 100%; height: auto; }
  .bl-results.bl-list .bl-cell { display: none !important; }
  .bl-results.bl-list .bl-card-body { display: flex !important; padding: 8px; }
  .bl-results.bl-list .bl-card-title,
  .bl-results.bl-list .bl-card-meta,
  .bl-results.bl-list .bl-card-tags { display: flex; }
}

/* 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%; display: flex; flex-direction: column; align-items: center; }
.bl-player video {
  /* Let aspect-ratio + max-width + max-height drive sizing so the video
     element shrinks to its intrinsic CONTENT size — no letterbox padding
     around the video. Without `width: 100%`, portrait videos shrink in
     width (matching the aspect), and Plyr's controls + progress bar align
     exactly with the visible video frame. Per user spec 2026-05-06.
     Landscape videos still fill the column because max-height kicks in
     and the implied width hits max-width. */
  max-width: 100%;
  max-height: 80vh;
  aspect-ratio: var(--video-aspect, 16/9);
  background: #000; border-radius: 8px; display: block;
  object-fit: contain;
}
/* Mirror the same constraints on .plyr (Plyr's wrapper around the video) so
   the controls overlay positioned absolute inside .plyr matches the video
   frame, not a wider letterbox. .bl-controls (our custom dark banner) is a
   sibling of .plyr, not inside it; it gets sized via JS in player.js to
   match the video's offsetWidth, keeping it visually attached. */
.bl-player .plyr {
  max-width: 100%;
  max-height: 80vh;
  aspect-ratio: var(--video-aspect, 16/9);
  /* WebKit-safety: clip any internal overflow at the video frame boundary.
     When .plyr is narrow (portrait videos on smaller viewports), Plyr's
     flex-laid-out controls bar contains children whose total natural width
     exceeds the parent. Chromium shrinks them; WebKit overflows them LEFT.
     Clipping at .plyr keeps the visible footprint bounded to the video. */
  overflow: hidden;
}
/* Allow Plyr's flex children to shrink below their min-content width — fixes
   the WebKit-specific bug where the .plyr__progress__container (which holds
   the seek bar input) refuses to compress and ends up positioned LEFT of
   its parent .plyr__controls. */
.bl-player .plyr__controls > * {
  min-width: 0;
}
/* ---- 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 6px; margin: 0 auto;          /* tighter outer L/R padding */
  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 */
}
/* Thin vertical separator between every non-first group, so the eye can
   distinguish seek vs. loop vs. trim vs. speed vs. dim at a glance.
   Per user spec 2026-05-06. */
.bl-ctrl-group:not(:first-child)::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,0.22);
  margin: 0 6px 0 4px;
  flex: 0 0 auto;
}
.bl-btn {
  background: transparent; border: none; border-radius: 4px;
  padding: 2px 3px; font-size: 12px; cursor: pointer;  /* tighter intra-button */
  display: inline-flex; align-items: center; justify-content: center;
  gap: 3px; color: inherit;
  height: 26px; min-width: 24px;             /* a touch smaller per user 2026-05-06 */
  line-height: 1;
}
/* Seek buttons get even tighter spacing — they're the densest cluster. */
.bl-controls .bl-back15,
.bl-controls .bl-back5,
.bl-controls .bl-fwd5,
.bl-controls .bl-fwd15 {
  padding: 1px 1px;
  min-width: 22px;
}
.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: flex; gap: 8px; 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 {
  flex: 0 0 auto;
  width: 18px; text-align: center;
  font-size: 13px; opacity: .65;
}
.bl-search-dropdown .sd-icon-spacer {
  /* Invisible spacer used in "X more results..." rows so their label
     left-aligns with rows that have a real icon. */
  visibility: hidden;
}
.bl-search-dropdown .sd-label {
  flex: 1 1 auto;
  text-align: left;
  /* 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 { flex: 0 0 auto; margin-left: auto; 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-more { font-size: 11px; color: #64748b; font-style: italic; padding-top: 2px; padding-bottom: 4px; }
.bl-search-dropdown .sd-more .sd-more-label { color: #64748b; }
.bl-search-dropdown .sd-more:hover { color: var(--bl-accent); }
.bl-search-dropdown .sd-more:hover .sd-more-label { color: var(--bl-accent); }
.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 {
  /* Now houses an inline SVG (.bl-kbd-icon) instead of the ⌨ Unicode char.
     The SVG sizes itself, so the button's own font-size is moot; padding +
     min-width define the hit target. Bumped 2026-05-09 after repeated
     reports of the keyboard glyph reading as too small. */
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 8px;
  min-width: 48px;
  display: inline-flex; align-items: center; justify-content: center;
}
.bl-kbd-icon { width: 26px; height: 26px; display: block; }

/* 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; cursor: pointer; border: none;
  /* Compact button: padding + 18 px icon → ~26 px content height, aligning
     with the sort control (height: 26 px) and native checkbox/slider rows.
     Reduced 2026-05-09 after the previous bump made the bar too tall. */
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; font-size: 13px; line-height: 1;
}
.bl-view-toggle .bl-view-icon { width: 18px; height: 18px; flex: 0 0 18px; }
.bl-view-toggle .bl-view-label { font-weight: 500; }
.bl-view-toggle button.bl-active { background: var(--bl-accent); color: white; }
.bl-view-toggle button.bl-active .bl-view-icon { color: white; }

/* Sort control — select + direction button. Set explicit equal heights so the
   native select chrome on macOS doesn't make the button look stunted. */
.bl-sort-control select,
.bl-sort-control button {
  /* Match .bl-view-toggle's content height (≈26 px). 2026-05-09 — was 30 px
     and felt taller than the row it sits in. */
  height: 26px; line-height: 24px; box-sizing: border-box;
  font-size: 12px; padding: 0 6px;
}
.bl-sort-control button { cursor: pointer; }

/* ---- 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; }
}


/* ── Trim/extract panel ───────────────────────────────────────────────────
   Slides in below .bl-controls when the scissors button is clicked. Layout
   is two rows: (1) Set start | times | Set end, (2) optional title + Save.
   Lives inside .bl-player so the carousel-dots/text-meta below shift down
   naturally. */
.bl-trim-panel {
  margin-top: 4px;
  padding: 8px 10px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  color: #1e293b;
}
.bl-trim-panel[hidden] { display: none; }
.bl-trim-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.bl-trim-row:last-child { margin-bottom: 0; }
.bl-trim-panel .bl-btn {
  /* Re-style the dark .bl-btn appearance for this lighter context */
  background: #fff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  min-width: auto;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  height: auto;
}
.bl-trim-panel .bl-btn:hover { background: #e2e8f0; }
.bl-trim-panel .bl-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.bl-trim-panel .bl-trim-save {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  margin-left: auto;
}
.bl-trim-panel .bl-trim-save:not(:disabled):hover { background: #1d4ed8; }
.bl-trim-times {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 3px 8px;
  border-radius: 4px;
  flex: 1;
  justify-content: center;
}
.bl-trim-time { font-weight: 600; }
.bl-trim-sep { color: #64748b; }
.bl-trim-len { color: #047857; font-size: 11px; }
.bl-trim-title {
  flex: 1;
  min-width: 160px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
}
.bl-trim-hint { font-size: 11px; color: #64748b; margin-top: 4px; }
.bl-trim-toggle.bl-active {
  background: #fbbf24 !important;
  color: #78350f !important;
}

/* ── Trim confirm modal + shared video-metadata form ─────────────────────
   Modal opens on "Review & save" click in the trim panel. The form fields
   inside come from _video_metadata_form.html so the same UI will be used
   for inbox-review in phase 2. */
.bl-trim-modal {
  border: none;
  padding: 0;
  border-radius: 10px;
  max-width: 480px;
  width: 90%;
  background: transparent;     /* the inner content provides bg */
}
.bl-trim-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.bl-trim-modal-content {
  background: #fff;
  padding: 20px 24px 18px;
  border-radius: 10px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.3);
  font-size: 14px;
  color: #1e293b;
}
.bl-trim-modal-content h3 {
  font-size: 16px; font-weight: 600;
  margin: 0 0 8px; color: #0f172a;
}
.bl-trim-modal-range {
  font-size: 13px;
  color: #475569;
  margin: 0 0 16px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bl-trim-modal-range strong { color: #0f172a; font-weight: 600; }
.bl-trim-modal-len { color: #047857; margin-left: 6px; }
.bl-meta-field {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}
.bl-meta-field > span {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: #334155;
}
.bl-meta-field > span > em { font-style: normal; color: #94a3b8; font-weight: 400; }
.bl-meta-field input[type="text"],
.bl-meta-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.bl-meta-field input[type="text"]:focus,
.bl-meta-field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.bl-trim-modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}
.bl-trim-modal-buttons .bl-btn {
  background: #fff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  height: auto;
  padding: 6px 14px;
  font-size: 13px;
}
.bl-trim-modal-buttons .bl-trim-modal-confirm {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  font-weight: 500;
}
.bl-trim-modal-buttons .bl-trim-modal-confirm:hover { background: #1d4ed8; }
.bl-trim-modal-buttons .bl-trim-modal-confirm:disabled { opacity: 0.5; cursor: not-allowed; }
.bl-trim-modal-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 5px;
  font-size: 12px;
  color: #b91c1c;
}
