/* Automizi Admin Tools — minimal styling on top of Bootstrap (stock theme).
   Served from /static (CSP style-src 'self'); no inline styles anywhere.
   --brand/--danger/--muted alias Bootstrap's own tokens so the bespoke bits
   below (sidebar, docs viewer, audit rows) stay one shade with every
   Bootstrap-styled button/badge — one source of truth, no color drift. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: var(--bs-secondary-color);
  --line: #e5e7eb;
  --brand: var(--bs-primary);
  --danger: var(--bs-danger);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* htmx indicator styles — shipped here (CSP-clean) instead of htmx's injected
   <style> tag, which the strict style-src blocks (see htmx-config meta). */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }
/* App shell — MOBILE-FIRST (Rule #2). Base: a stacked column with a horizontal
   top nav bar. At >=800px it becomes a fixed-width left sidebar. */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding: 0.6rem 1rem;
}
.sidebar .brand {
  display: block;
  padding: 0.3rem 0.6rem;
}
.sidebar .brand img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
}
.sidebar .brand-title {
  margin: 0.85rem 0 0;
  color: #fff;
  font-weight: 600;
  font-size: 1.32rem;
  text-align: center;
}
.sidebar .brand-rule {
  width: 100%;
  border: 0;
  border-top: 1px solid #1e293b;
  margin: 0.75rem 0;
}
.side-nav { display: flex; flex-flow: row wrap; gap: 0.15rem; }
.side-nav .section { display: none; } /* section labels only show in the sidebar */
.nav-link {
  color: #cbd5e1;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  display: block;
}
.nav-link:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.sidebar-foot .who { display: flex; align-items: center; gap: 0.4rem; }
.sidebar-foot .email { font-size: 0.85rem; color: #94a3b8; word-break: break-all; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn { width: auto; }

.content { flex: 1; min-width: 0; }
.content > main { padding: 1rem; }
.spacer { flex: 1; }

/* Logged-out pages (login): no sidebar. */
.layout--plain { display: block; }

/* Public docs site (docs.<host>) — standalone shell, no admin sidebar/nav.
   Mobile-first: a white top bar, a centred content column, and a footer. */
body.public-docs { background: var(--bg); }
.public-top { background: var(--panel); border-bottom: 1px solid var(--line); }
.public-top-inner { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem; }
.public-title { margin: 0; font-size: 1.5rem; font-weight: 700; }
.public-subtitle { margin: 0.15rem 0 0; color: var(--muted); }
.public-main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; }
.public-foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.75rem 1rem 2.5rem; }

@media (min-width: 800px) {
  .layout { flex-direction: row; align-items: flex-start; }
  .sidebar {
    width: 240px;
    flex-shrink: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 1rem 0.75rem;
    /* Pinned full-height rail: brand stays at top, foot at bottom, nav scrolls
       between them (scrollbar hidden). */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
  }
  .sidebar .brand,
  .sidebar .brand-rule { flex: 0 0 auto; }
  .sidebar .brand { padding: 0.25rem 0.5rem 0; }
  .sidebar .brand img {
    width: 100%;
    height: auto;
    padding: 10px 12px;
  }
  .side-nav {
    flex: 1 1 auto;
    flex-direction: column;
    flex-wrap: nowrap; /* bounded height + inherited wrap would spill into a 2nd column */
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox: hide scrollbar */
  }
  .side-nav::-webkit-scrollbar { display: none; } /* Webkit: hide scrollbar */
  .side-nav .section {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.9rem 0.65rem 0.3rem;
  }
  .sidebar-foot {
    margin-top: auto;
    margin-left: 0;
    flex: 0 0 auto;
    display: block;
    padding-top: 1rem;
    border-top: 1px solid #1e293b;
  }
  .sidebar-foot .who {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.4rem 0.65rem;
  }
  .sidebar-foot form { margin-top: 0.5rem; padding: 0 0.65rem; }
  .sidebar-foot .btn { width: 100%; }
  .content > main { padding: 1.5rem 2rem; }
}
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
td { overflow-wrap: anywhere; } /* long emails/ids wrap instead of forcing scroll (Bootstrap's .table doesn't do this) */
.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; }
.card-narrow { max-width: 420px; margin: 2rem auto; }

/* Full-width white page header (title + optional CTA buttons). Spans the whole
   content column, sticks to the top on scroll. Rendered by partials/header.ejs
   so every page shares it. */
.page-header {
  /* display/flex/gap now come from utility classes in the markup (page-header.ejs) */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem;
}
.page-header h1 { margin: 0; font-size: 1.2rem; }
.page-heading-block { min-width: 0; }
.page-subheading { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }
/* .page-actions layout now comes from utility classes in the markup */
@media (min-width: 800px) {
  .page-header { padding: 0.9rem 2rem; }
  .page-header h1 { font-size: 1.3rem; }
}

/* Filter form (audit log) — layout comes from utility classes in the markup;
   .field sizes each filter column. */
.filters .field { flex: 1 1 150px; }
.filters .field label { margin-top: 0; }
.filters .field--actions { display: flex; gap: 0.5rem; align-items: end; flex: 0 0 auto; }

/* Audit log: collapsible disclosure rows (no wide table / horizontal scroll).
   Each row's summary shows the key fields; expanding reveals full detail. */
.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 0.5rem;
}
.audit-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
}
.audit-item > summary::-webkit-details-marker {
  display: none;
}
.audit-item > summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 0.8rem;
}
.audit-item[open] > summary::before {
  content: '▾';
}
.audit-item .ai-when {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.audit-item .ai-action {
  font-weight: 600;
}
.audit-item .ai-resource {
  color: var(--muted);
}
.audit-item .ai-end {
  margin-left: auto;
}
.audit-item .ai-detail {
  padding: 0.25rem 0.85rem 0.85rem;
  border-top: 1px solid var(--line);
}
.audit-item .ai-detail dl {
  display: grid;
  grid-template-columns: 1fr; /* mobile-first: stacked label/value */
  gap: 0.15rem 1rem;
  margin: 0.85rem 0 0;
}
.audit-item .ai-detail dt {
  color: var(--muted);
  margin-top: 0.5rem;
}
.audit-item .ai-detail dd {
  margin: 0;
  word-break: break-word;
}
@media (min-width: 560px) {
  .audit-item .ai-detail dl {
    grid-template-columns: 150px 1fr;
    gap: 0.3rem 1rem;
  }
  .audit-item .ai-detail dt {
    margin-top: 0;
  }
}

/* ── Docs viewer (MOBILE-FIRST) ─────────────────────────────────────────────── */
.docs-search input { flex: 1; }

/* Live search-suggestion dropdown (source: SearchBar's live results panel).
   #search-dropdown:empty collapses automatically — same pattern as
   #modal-errors:empty — so no query / no results-yet leaves nothing visible. */
#search-dropdown:empty { display: none; }
.search-dropdown-panel {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 0.25rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  max-height: 28rem; overflow-y: auto;
}
.search-dropdown-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.search-dropdown-more {
  display: block; padding: 0.6rem 0.9rem; font-size: 0.8rem;
  border-top: 1px solid var(--line);
}

/* Search result row — shared by the dropdown and the full results page.
   SRT/subtitle hits get the distinct amber treatment (source: SearchResultRow). */
.search-result {
  display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.65rem 0.9rem;
  text-decoration: none; color: inherit; border-bottom: 1px solid var(--line);
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--bg); text-decoration: none; }
.search-result--standalone {
  border: 1px solid var(--line); border-radius: 10px; border-bottom: 1px solid var(--line);
}
.search-result-icon {
  flex: 0 0 auto; width: 1.5rem; height: 1.5rem; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.75rem;
}
/* SRT/subtitle hits get a light-yellow row background (source: the amber
   subtitle-match rows) so they read distinctly from plain article hits. */
.search-result--srt { background: #fffaeb; }
.search-result--srt:hover { background: var(--bs-warning-bg-subtle); }
.search-result--srt .search-result-icon { color: var(--bs-warning-text-emphasis); }
.search-result--srt .search-result-title {
  color: var(--bs-warning-text-emphasis); font-size: 0.75rem; font-weight: 600;
}
.search-result-body { flex: 1; min-width: 0; }
.search-result-title { display: block; font-weight: 500; }
.search-result-snippet { display: block; font-size: 0.85rem; color: var(--muted); }
.search-result-time {
  flex: 0 0 auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem;
  color: var(--bs-emphasis-color); background: var(--bs-warning-bg-subtle);
  border: 1px solid var(--bs-warning-border-subtle); border-radius: 4px; padding: 0.1rem 0.35rem;
}
.docs-crumbs { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; font-size: 0.9rem; margin: 0 0 0.75rem; }
/* Article mode: line the breadcrumb up with the centred article card's column. */
.docs-crumbs--boxed { max-width: 760px; margin-left: auto; margin-right: auto; }
.docs-crumbs .sep { color: var(--muted); }
.docs-crumbs span:last-child { color: var(--ink); }

.docs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent, var(--brand));
  border-radius: 10px;
}
.doc-card:hover { text-decoration: none; box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.doc-card-name { font-weight: 600; color: var(--ink); }
.doc-card-count { font-size: 0.85rem; color: var(--muted); }

/* Landing hero ("Learning Center") — centred title + subtitle + search. */
.doc-hero .card-body { padding: 2rem 1.25rem; }
.doc-hero-title { text-align: center; font-size: 1.6rem; font-weight: 700; margin: 0 0 0.35rem; }
.doc-hero-sub { text-align: center; color: var(--muted); margin: 0 0 1.25rem; }
.doc-hero .docs-search { max-width: 640px; margin: 0 auto; }
@media (min-width: 800px) { .doc-hero .card-body { padding: 2.5rem 2rem; } .doc-hero-title { font-size: 1.85rem; } }

/* Uppercase section label above card groups (source: RECENTLY UPDATED etc). */
.doc-section-label {
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem;
  font-weight: 600; color: var(--muted); margin: 0 0 0.6rem;
}

/* Recently-updated article cards: play glyph (video only) + title + category badge. */
.doc-article-cards { display: flex; flex-direction: column; gap: 0.6rem; }
.doc-article-card {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: inherit;
}
.doc-article-card:hover { text-decoration: none; box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.doc-article-card-play { flex: 0 0 auto; color: var(--muted); font-size: 0.7rem; }
.doc-article-card-main { min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.doc-article-card-title { font-weight: 600; color: var(--ink); }
/* Small outline category chip (source: the blue-outline "General" pill). */
.doc-badge-cat {
  align-self: flex-start; font-size: 0.72rem; font-weight: 500; line-height: 1;
  padding: 0.2rem 0.45rem; border-radius: 0.3rem;
  color: var(--bs-primary); background: var(--bs-primary-bg-subtle);
  border: 1px solid var(--bs-primary-border-subtle);
}

/* Article view: no AI column, so centre the card at a comfortable reading width. */
.doc-article { max-width: 760px; margin: 0 auto; }
.doc-article-media { padding: 1rem 1rem 0.75rem; }
/* Split layout (desktop): the video + transcript stay fixed at the top of the
   card and only the article body scrolls. Mobile flows normally (Rule #2). */
@media (min-width: 800px) {
  .doc-article--split { display: flex; flex-direction: column; max-height: calc(100vh - 8rem); }
  .doc-article--split .card-header,
  .doc-article--split .doc-article-media { flex: 0 0 auto; }
  .doc-article--split .doc-article-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }

.doc-video { width: 100%; border-radius: 10px; background: #000; }
.doc-embed { position: relative; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; }
.doc-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.doc-embed.pdf { padding-top: 0; height: 70vh; }
.doc-embed.pdf iframe { position: static; height: 100%; }

/* Article card header — small icon box + title + close-to-root (source:
   ArticleViewer's articleCardHeader). */
.doc-article-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; flex: 0 0 auto;
  background: var(--bs-primary-bg-subtle); color: var(--bs-primary);
  border-radius: 0.4rem; font-size: 0.7rem;
}

/* Amber transcript panel (source: the sticky bg-amber-50 panel) — always
   visible whenever SRT exists, not a collapsible disclosure. */
.doc-transcript-panel { margin-top: 0.75rem; padding: 0.25rem 4rem 0.25rem 0.25rem; }
.doc-sync-toggle { position: absolute; bottom: 0.35rem; right: 0.4rem; }
/* Fixed ~96px — about 3 lines visible before scrolling (matches the source's
   compact transcript box exactly; it isn't meant to show the whole transcript
   at once). */
.cues { list-style: none; margin: 0; padding: 0; height: 96px; overflow-y: auto; }
/* Thin, unobtrusive scrollbar (match the reference transcript box, not the
   chunky default OS bar). */
.cues { scrollbar-width: thin; scrollbar-color: rgba(146, 64, 14, 0.35) transparent; }
.cues::-webkit-scrollbar { width: 6px; }
.cues::-webkit-scrollbar-track { background: transparent; }
.cues::-webkit-scrollbar-thumb { background: rgba(146, 64, 14, 0.3); border-radius: 3px; }
.cues li { margin: 0; }
.cue, .cue-static {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.cue-time {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--bs-emphasis-color);
  opacity: 0.7;
}
.cue-text { line-height: 1.3; }
.cue:hover { background: var(--bs-warning-border-subtle); }
.cue-active { background: var(--bs-warning-border-subtle); color: var(--bs-emphasis-color); font-weight: 700; }
.cue-static { cursor: default; color: var(--muted); }
.doc-pdf, .doc-pdf-trigger { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.doc-md { margin-top: 1.25rem; line-height: 1.6; }
.doc-md h2, .doc-md h3, .doc-md h4 { margin: 1rem 0 0.5rem; }
.doc-md p { margin: 0.6rem 0; }
.doc-md code { background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }

@media (min-width: 700px) {
  .docs-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .docs-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Pretty-printed JSON blocks. */
.code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre;
}

/* Permission matrix (user form) — MOBILE-FIRST: each page is a block whose CRUD
   checkboxes wrap; at >=560px the page label sits beside the checkbox group. */
.perm-note { margin: 0.15rem 0 0.5rem; }
.perm-matrix {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.perm-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.perm-row:last-child { border-bottom: 0; }
.perm-page { font-weight: 600; }
.perm-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
/* .perm-check now just sizes-to-content inside the .perm-actions flex row;
   checkbox/label layout itself comes from Bootstrap's .form-check. */
.perm-check { margin: 0; font-weight: 400; }
@media (min-width: 560px) {
  .perm-row { flex-direction: row; align-items: center; }
  .perm-page { flex: 0 0 9rem; }
}

/* Help admin — Articles/Categories tab strip (underline tabs). */
.help-tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.25rem; }
.help-tab { padding: 0.6rem 0.15rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.help-tab:hover { color: var(--ink); text-decoration: none; }
.help-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.help-tab-count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.help-tab.active .help-tab-count { color: var(--brand); }

/* Filter toolbar (Articles list) — wraps mobile-first, single row from ~992px. */
.art-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 1.25rem; }
.art-filter-search { flex: 1 1 9rem; min-width: 7rem; max-width: 18rem; min-height: 44px; }
.art-filter-cat { flex: 0 0 11rem; min-width: 9rem; }
/* Segmented filter groups — btn-check radios; active segment takes the group's
   theme colour (blue default / orange PDF / purple Subs). Uniform 44px height
   (Rule #2 touch target) so the whole toolbar lines up. */
.seg .btn { --seg: var(--bs-primary); border-color: var(--line); color: var(--ink); background: #fff; font-size: 0.8rem; padding: 0.3rem 0.55rem; min-height: 44px; display: inline-flex; align-items: center; }
.seg.seg--pdf .btn { --seg: #f97316; }
.seg.seg--subs .btn { --seg: #8b5cf6; }
.seg .btn-check:checked + .btn { background: var(--seg); border-color: var(--seg); color: #fff; }
.seg .btn:hover { background: color-mix(in srgb, var(--seg) 10%, #fff); }
.seg .btn-check:focus-visible + .btn { outline: 2px solid var(--seg); outline-offset: 1px; }

/* Article rows (cards). */
.art-list { display: flex; flex-direction: column; gap: 0.6rem; }
.art-row { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.85rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.art-check { margin-top: 0.2rem; flex: 0 0 auto; }
.art-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; margin-top: 0.45rem; }
.art-dot--on { background: var(--bs-success); }
.art-dot--off { background: var(--bs-secondary-color); }
.art-main { flex: 1; min-width: 0; }
.art-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; }
.art-title { font-weight: 600; }
.art-snippet { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; overflow-wrap: anywhere; }
.art-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

/* Category chip — colour tracks the category (data-accent → --accent via CSSOM). */
.cat-chip { font-size: 0.72rem; font-weight: 500; line-height: 1; padding: 0.2rem 0.45rem; border-radius: 0.3rem; border: 1px solid var(--accent, var(--line)); color: var(--accent, var(--muted)); background: #fff; white-space: nowrap; }

/* Small status tags. */
.tag { font-size: 0.7rem; font-weight: 500; line-height: 1; padding: 0.2rem 0.45rem; border-radius: 0.3rem; border: 1px solid transparent; }
.tag--subs { color: #7c3aed; background: #f3e8ff; border-color: #e9d5ff; }
.tag--pdf { color: #c2410c; background: #ffedd5; border-color: #fed7aa; }
.tag--video { color: var(--bs-secondary-color); background: var(--bg); border-color: var(--line); }

/* Kebab "…" row menu — native <details> (CSP-clean, no Popper). */
.kebab { position: relative; flex: 0 0 auto; }
.kebab-btn { list-style: none; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--muted); font-size: 1.15rem; line-height: 1; }
.kebab-btn::-webkit-details-marker { display: none; }
.kebab-btn:hover { background: var(--bg); color: var(--ink); }
.kebab-menu { position: absolute; right: 0; top: 100%; margin-top: 0.25rem; z-index: 30; min-width: 8rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 30px rgba(0,0,0,0.15); padding: 0.25rem; display: flex; flex-direction: column; }
.kebab-item { text-align: left; background: none; border: 0; padding: 0.45rem 0.6rem; border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.kebab-item:hover { background: var(--bg); }
.kebab-item--danger { color: var(--danger); }
.art-empty { padding: 1.5rem; text-align: center; }

/* Bulk selection toolbar (help-bulk.js) — shown when ≥1 row is checked. */
.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  background: var(--bs-primary-bg-subtle); border: 1px solid var(--bs-primary-border-subtle);
  border-radius: 10px; padding: 0.55rem 1rem; margin-bottom: 1rem;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar-left { display: flex; align-items: center; gap: 0.6rem; }
.bulk-count { color: var(--bs-primary); font-weight: 600; }
.bulk-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
/* Categories action = purple (matches the Subs filter accent family). */
.bulk-btn-cat { color: #fff; background: #8b5cf6; border-color: #8b5cf6; }
.bulk-btn-cat:hover { color: #fff; background: #7c3aed; border-color: #7c3aed; }
.bulk-clear { text-decoration: none; }

/* Bulk Edit-Categories modal rows. */
.bulk-cat-list { display: flex; flex-direction: column; }
.bulk-cat-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.bulk-cat-row:last-child { border-bottom: 0; }
.bulk-cat-name { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow-wrap: anywhere; }
.bulk-cat-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }

/* Help admin editors. */
.help-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.grow { flex: 1; min-width: 12rem; }
.inline-label { display: inline; margin: 0; font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.cat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.cat-row .help-actions { margin-left: auto; }
.cat-sub { padding-left: 1.25rem; color: var(--muted); }
.cat-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* Category cards (admin Categories tab). */
.cat-cards { display: flex; flex-direction: column; gap: 0.6rem; }
.cat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cat-card-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; }
.cat-card-main { flex: 1; min-width: 0; }
.cat-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.55rem; }
.cat-card-name { font-weight: 600; }
.cat-card-count { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }
.cat-card-count--inline { margin-top: 0; }
.cat-source {
  font-size: 0.72rem; font-weight: 500; line-height: 1; padding: 0.2rem 0.45rem; border-radius: 0.3rem;
  color: var(--bs-primary); background: var(--bs-primary-bg-subtle); border: 1px solid var(--bs-primary-border-subtle);
}
.cat-actions { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; }
.cat-sub-btn { --bs-btn-padding-y: 0.2rem; --bs-btn-padding-x: 0.55rem; --bs-btn-font-size: 0.8rem; white-space: nowrap; }
.cat-subs { background: var(--bg); }
.cat-sub-row { padding: 0.6rem 1rem 0.6rem 1.5rem; border-top: 1px solid var(--line); }
.cat-sub-name { color: var(--muted); }
/* Square icon action buttons (edit/delete/reorder). */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn--danger { color: var(--danger); border-color: var(--bs-danger-border-subtle); }
.icon-btn--danger:hover:not(:disabled) { background: var(--bs-danger-bg-subtle); color: var(--danger); }

.cat-edit { margin: 0.25rem 0 0.5rem; }
.cat-edit summary { cursor: pointer; color: var(--brand); font-size: 0.9rem; }
.cat-edit.inline { display: inline-block; }

/* Category color picker (category-form.ejs) — a .btn-check radio per swatch;
   the fill color comes from data-swatch via ui-colors.js's CSSOM pattern
   (CSP-safe, no inline style=""), not from this stylesheet. */
.swatch-radio {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  display: inline-block;
  position: relative;
  border: 2px solid transparent;
}
.btn-check:checked + .swatch-radio { border-color: var(--ink); }
.btn-check:checked + .swatch-radio::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}
.btn-check:focus-visible + .swatch-radio { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

/* Colour picker layout (category-form): header + preview pill, swatch grid,
   custom-hex row. Swatch fills come from data-swatch (ui-colors.js / color-picker.js). */
.color-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.color-preview {
  font-size: 0.72rem; font-weight: 600; color: #fff; padding: 0.15rem 0.6rem; border-radius: 0.35rem;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25); border: 1px solid rgba(0,0,0,0.08);
}
.swatch-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; max-width: 22rem; }
.custom-color { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.custom-color-swatch { border: 1px solid var(--bs-border-color); }
.custom-hex { max-width: 12rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Left Menu reference cards. */
.page-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.6rem;
}
.page-card-title { font-weight: 600; font-size: 1.05rem; }
.page-card-path { color: var(--muted); }
.page-actions-table code { overflow-wrap: anywhere; }

/* ── Modal (Rule #3: all CRUD happens in a modal) ─────────────────────────────
   Native <dialog>: free backdrop/focus-trap/Esc, CSP-clean. `.app-dialog` sizes
   and positions the native <dialog> box itself (renamed from a plain `.modal`
   to avoid colliding with Bootstrap's own JS-driven `.modal` class, which this
   app doesn't use); the content inside uses Bootstrap's `.modal-dialog` /
   `.modal-content` / `.modal-header` / `.modal-body` / `.modal-footer` classes
   for visual styling. Mobile-first — a bottom sheet on small screens, a
   centred card once there's room.

   IMPORTANT: Bootstrap scopes its `--bs-modal-*` custom properties to the
   `.modal` class itself (confirmed via computed-style inspection — they are
   NOT defined at `:root`). Renaming our wrapper away from `.modal` silently
   dropped those variable definitions, so `.modal-content`'s
   `background-color: var(--bs-modal-bg)` (and its border/shadow/padding
   vars) resolved to nothing — an invisible, transparent modal card with no
   border. Re-declaring the ones that affect appearance here restores them. */
.app-dialog {
  --bs-modal-color: var(--bs-body-color);
  --bs-modal-bg: var(--bs-body-bg);
  --bs-modal-border-color: var(--bs-border-color-translucent);
  --bs-modal-border-width: var(--bs-border-width);
  --bs-modal-border-radius: var(--bs-border-radius-lg);
  --bs-modal-box-shadow: var(--bs-box-shadow-sm);
  --bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - var(--bs-border-width));
  /* Body/footer padding: Bootstrap scopes --bs-modal-padding to `.modal`, so
     renaming our wrapper to `.app-dialog` dropped it and `.modal-body` rendered
     with NO inner padding. Re-declare it (roomier 1.5rem to match the refs). */
  --bs-modal-padding: 1.5rem;
  --bs-modal-header-padding-x: 1.5rem;
  --bs-modal-header-padding-y: 1.25rem;
  --bs-modal-header-padding: 1.25rem 1.5rem;
  --bs-modal-header-border-color: var(--bs-border-color);
  --bs-modal-header-border-width: var(--bs-border-width);
  --bs-modal-title-line-height: 1.5;
  --bs-modal-footer-gap: 0.5rem;
  --bs-modal-footer-border-color: var(--bs-border-color);
  --bs-modal-footer-border-width: var(--bs-border-width);
  border: none;
  padding: 0;
  width: 100%;
  max-width: min(640px, 100%);
  background: transparent;
}
.app-dialog--sm { max-width: min(400px, 100%); }
.app-dialog::backdrop { background: rgba(15, 23, 42, 0.5); }
.app-dialog .modal-content { max-height: 90vh; overflow-y: auto; }
.app-dialog .btn-close { min-width: 44px; min-height: 44px; } /* Rule #2 touch target */
/* Bottom-sheet on phones. */
@media (max-width: 599px) {
  .app-dialog { margin: auto auto 0; max-width: 100%; }
  .app-dialog .modal-content { border-radius: 14px 14px 0 0; max-height: 92vh; }
}

/* Shared validation-error slot inside a modal (styling now comes from
   Bootstrap's `.alert.alert-danger`, applied alongside this class in markup). */
#modal-errors:empty { display: none; }

/* Shared file drop zone (file-drop.js) — loads a text file into a textarea. */
.file-drop {
  border: 1px dashed var(--bs-border-color); border-radius: 8px;
  padding: 0.6rem 0.75rem; text-align: center; cursor: pointer;
  color: var(--muted); font-size: 0.85rem; background: var(--bs-body-bg);
  margin-bottom: 0.4rem;
}
.file-drop:hover { border-color: var(--bs-primary); color: var(--ink); }
.file-drop.drag-over { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); color: var(--ink); }
.file-drop.has-file { color: var(--bs-primary); font-weight: 500; }
.file-drop code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── Searchable dropdown (Tom Select) — matches Bootstrap's .form-control via
   its own --bs-* variables, so it tracks the stock theme automatically. 44px
   min-height kept for Rule #2 touch targets (bigger than Bootstrap's ~38px). */
.ts-wrapper { width: 100%; }
.ts-control {
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  background-color: var(--bs-body-bg);
}
/* Tom Select's default theme paints single-select controls with a grey gradient,
   an inset bevel shadow and a #b8b8b8 border (specificity 0,3,0) — override at
   equal specificity to Bootstrap's flat white .form-control look. Also keep the
   single value on one line so a narrow control doesn't wrap to double height. */
.ts-wrapper.single .ts-control {
  background-color: var(--bs-body-bg);
  background-image: none;
  border: var(--bs-border-width) solid var(--bs-border-color);
  box-shadow: none;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
/* Focus ring — needs to out-specify the single-control rule above to win. */
.ts-wrapper.focus .ts-control,
.ts-wrapper.single.focus .ts-control {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.ts-dropdown { border: var(--bs-border-width) solid var(--bs-border-color); border-radius: var(--bs-border-radius); }
.ts-dropdown .active { background: var(--bs-primary); color: #fff; }
/* Tom Select copies the original <select>'s classes onto its wrapper, so a
   `.form-select` select drags Bootstrap's caret background AND its padding onto
   `.ts-wrapper` (double caret + a too-tall control). Strip both — one source of
   truth for every searchable select (articles filter, user form, audit filters). */
.ts-wrapper.form-select { background-image: none; padding: 0; }

/* ── Reorder (Rule #3: arrows + drag-and-drop) ────────────────────────────── */
[data-drag-handle] {
  cursor: grab;
  touch-action: none;
  user-select: none;
  color: var(--bs-secondary-color, var(--muted));
  padding: 0 0.35rem;
  min-width: 32px;
  text-align: center;
}
[data-drag-handle]:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { background: #eff6ff; }
