/* ============================================================================
 * kb.css — Knowledge-base shared design system
 * ----------------------------------------------------------------------------
 * Single source of truth for the chrome shared across every public `notes`
 * view (box/group, links, tree, summary, descriptions, term, domain).
 *
 * Extracted verbatim from group_terms.php's inline <style> so migrated views render
 * pixel-identically, then extended with the canonical view-switcher tokens.
 *
 * Emitted via kb_head() in util_gui.php. Do NOT duplicate these tokens inside
 * individual view files — import this instead.
 * ========================================================================== */

/* ── Reset & Variables ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --panel-left-w:   260px;
    --topbar-h:        52px;
    --sidebar-bg:     #1c2333;
    --sidebar-text:   #c9d1d9;
    --sidebar-hover:  #2d3748;
    --accent:         #2f80ed;
    --accent-light:   #ebf3fd;
    --body-bg:        #f4f6f9;
    --card-bg:        #ffffff;
    --border:         #e2e8f0;
    --text-main:      #1a202c;
    --text-muted:     #718096;
    --badge-bg:       #e2e8f0;
    --badge-text:     #4a5568;
    --font:           'DM Sans', Arial, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text-main);
    margin: 0;
}

/* ── Top Bar ──────────────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    z-index: 200;
    border-bottom: 1px solid #2d3748;
}

.topbar-hamburger {
    /* Always visible: on desktop it collapses the sidebar drawer; on mobile it
       opens the off-canvas drawer. (Driven by the shared kb_sidebar.js.) */
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.topbar-brand {
    flex-shrink: 0;
    font-size: 17px; font-weight: 700; letter-spacing: -.01em;
    color: #fff; text-decoration: none; line-height: 1;
}
.topbar-brand:hover { opacity: .85; }

.topbar-search {
    display: flex;
    align-items: center;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 6px;
    padding: 0 10px;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-search input {
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font-family: var(--font);
    font-size: 13px;
    width: 180px;
    padding: 6px 0;
}

.topbar-search input::placeholder { color: #718096; }
.topbar-search .search-icon { color: #718096; font-size: 14px; }

.clear-btn {
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    display: none;
    touch-action: manipulation;
}

.topbar-admin { display: flex; gap: 4px; flex-shrink: 0; }

.topbar-admin a {
    font-size: 11px;
    padding: 3px 7px;
    border: 1px solid #4a5568;
    border-radius: 4px;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
}

.topbar-admin a:hover { background: #2d3748; color: #fff; }

.topbar-home {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1; color: #fff; text-decoration: none;
    padding: 4px 8px; border-radius: 5px; flex-shrink: 0;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.topbar-home:hover { background: #2d3748; color: #fff; }

/* ── App Shell ────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    margin-top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;   /* clip the sidebar as it slides off-canvas when collapsed */
}

/* ── Left Panel — Tree ────────────────────────────────────────────────── */
.left-panel {
    width: var(--panel-left-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    overflow-y: auto;
    height: 100%;
    z-index: 100;
    transition: transform 0.25s ease, margin-left 0.25s ease;
}

/* Desktop drawer collapse: pull the sidebar off-canvas with a negative margin so
   the flex content (.right-panel) reflows to fill the freed width. Scoped to
   desktop — on mobile the sidebar is a fixed overlay drawer (see media query),
   so this rule stays inert there. Toggled by kb_sidebar.js. */
@media (min-width: 769px) {
    .app-shell.sidebar-collapsed .left-panel {
        margin-left: calc(-1 * var(--panel-left-w));
    }
}

.tree-root-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #718096;
}

/* Sticky sidebar header: the root name (dropdown or static label) + the
   hover-revealed "collapse all" control. Stays pinned so both remain reachable
   while the tree scrolls. */
.tree-header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 8px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.tree-header .tree-root-switcher,
.tree-header .tree-root-name { flex: 1; min-width: 0; padding: 0; border-bottom: none; }

/* Collapse/expand-all toggle — invisible at rest, revealed on sidebar hover
   (or keyboard focus). One click folds every branch; click again expands. */
.tree-collapse-all {
    flex-shrink: 0;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    color: #94a3b8;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0; pointer-events: none;
    transition: opacity .15s, background .15s, color .15s;
}
.left-panel:hover .tree-collapse-all,
.tree-collapse-all:focus-visible { opacity: 1; pointer-events: auto; }
.tree-collapse-all:hover { background: rgba(255,255,255,.14); color: #fff; }
.tree-collapse-all.all-collapsed { color: var(--accent); border-color: var(--accent); }

/* Static root name — shown instead of the switcher dropdown when a domain has a
   single root (the tree starts at the root's children, so the root is named here). */
.tree-root-name {
    font-size: 15px;
    font-weight: 700;
    color: #e2e8f0;
}

/* Root-group switcher: compact <select> at the top of the sidebar that jumps
   between the domain's top-level hierarchies. Shared across box/links/tree. */
.tree-root-switcher {
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.tree-root-switcher select {
    width: 100%;
    font-family: 'DM Sans', Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px;
    padding: 7px 28px 7px 10px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%2394a3b8'><path d='M4 6l4 4 4-4z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: background .15s, border-color .15s;
}
.tree-root-switcher select:hover  { background-color: rgba(255,255,255,.10); border-color: rgba(255,255,255,.22); }
.tree-root-switcher select:focus  { outline: none; border-color: var(--accent); }
/* The native option list renders on a light popup on most platforms */
.tree-root-switcher option { color: #1a202c; background: #fff; }

/* Tree depth bar: subtle by default, full controls revealed on hover/focus */
.tree-depth-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 6px;
    font-family: 'DM Sans', Arial, sans-serif;
    font-size: 11px;
    color: #b6c1cf;
    border-bottom: 1px solid transparent;
    transition: color .15s, border-color .15s;
}
.left-panel:hover .tree-depth-bar,
.tree-depth-bar:focus-within {
    color: var(--text-muted);
    border-bottom-color: var(--border);
}
.tree-depth-btn {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    width: 22px; height: 22px;
    line-height: 1; padding: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s, background .12s, border-color .12s, color .12s;
}
.left-panel:hover .tree-depth-btn,
.tree-depth-bar:focus-within .tree-depth-btn {
    opacity: 1;
    pointer-events: auto;
    border-color: var(--border);
}
.tree-depth-btn:hover  { background: #f0f4f8; color: #1a202c; }
.tree-depth-btn:active { transform: translateY(1px); }
.tree-depth-label      { user-select: none; }
/* Touch devices have no hover — keep controls visible when the panel is in use */
@media (hover: none) {
    .tree-depth-bar { color: var(--text-muted); border-bottom-color: var(--border); }
    .tree-depth-btn { opacity: 1; pointer-events: auto; border-color: var(--border); }
}

.tree-node { }

.tree-row {
    display: flex;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: 0;
    align-items: center;
    gap: 4px;
    padding: 5px 8px 5px 12px;
    cursor: pointer;
    color: var(--sidebar-text);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 400;
    transition: background 0.12s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Depth-based font size and weight */
.tree-row[data-depth='0'] { font-size: 14px; font-weight: 600; padding: 6px 8px 6px 12px; }
.tree-row[data-depth='1'] { font-size: 13px; font-weight: 500; padding: 5px 8px 5px 14px; }
.tree-row[data-depth='2'] { font-size: 12px; font-weight: 400; padding: 4px 8px 4px 16px; }

.tree-row:hover  { background: var(--sidebar-hover); color: #fff; }
.tree-row.active { background: var(--accent); color: #fff; }

/* .scope = the URL-selected group whose subtree a view is currently showing
 * (opt-in via render_group_tree_sidebar's scope_active). Persistent regardless
 * of scroll position; a yellow rail marks it as the boundary of what's loaded. */
.tree-row.scope {
    background: #2c3e64;
    color: #fff;
    border-left: 3px solid #f6c453;
    padding-left: 9px;
}
.tree-row.scope.active { background: var(--accent); }
.tree-row.scope:hover  { background: #364c75; color: #fff; }

.tree-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 9px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    opacity: 0.7;
    -webkit-user-select: none;
    user-select: none;
}

.tree-toggle:hover { opacity: 1; }
.tree-toggle-spacer { width: 18px; flex-shrink: 0; }

.tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Count bubble — varies by depth */
.tree-count {
    flex-shrink: 0;
    font-size: 10px;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 22px;
    text-align: center;
    background: rgba(255,255,255,.12);
    color: rgba(255,255,255,.55);
}

/* Depth-0 (root): solid accent pill, more visible */
.tree-row[data-depth='0'] .tree-count {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 11px;
    padding: 2px 7px;
}

/* Depth-1: slightly lighter pill */
.tree-row[data-depth='1'] .tree-count {
    background: rgba(47,128,237,.35);
    color: #c8dcf8;
    font-weight: 500;
}

/* Active state overrides */
.tree-row.active .tree-count {
    background: rgba(255,255,255,.3);
    color: #fff;
}

.tree-children { padding-left: 14px; }

.tree-node.collapsed > .tree-children { display: none; }

/* ── Right Panel ──────────────────────────────────────────────────────── */
.right-panel {
    flex: 1;
    overflow-y: auto;
    height: 100%;
    padding: 0 24px 24px 24px;
}

/* Breadcrumb — top of right panel, updates on every AJAX navigation */
/* Breadcrumb: flush bar spanning the full width of the right panel */
.rp-breadcrumb-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 4px;
    column-gap: 0;
    margin: 0 -24px 0 -24px;
    padding: 5px 16px 5px 10px;
    background: #f0f4f8;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
    min-height: 36px;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Shared rectangle base for all breadcrumb items */
.bc-domain, .bc-section, .bc-root, .bc-middle, .bc-current {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 5px 11px;
    white-space: nowrap;
    line-height: 1.4;
    border-radius: 0;
}

/* Section — soft amber chip with folder icon, between Domain and Root */
.bc-section {
    background: #f5e6c4;
    color: #6e4a10;
    font-weight: 500;
    font-style: italic;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.bc-section::before {
    content: "📚";
    margin-right: 4px;
    font-size: 11px;
    font-style: normal;
}
.bc-section:hover { background: #ecd49a; color: #4d3308; }

/* Domain — rich teal, clearly the top-level anchor */
.bc-domain {
    background: #0e6b8a;
    color: #e0f4fb;
    font-weight: 600;
    letter-spacing: .03em;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.bc-domain:hover { background: #0a5570; color: #fff; }

/* Root group — dark slate, subordinate but still prominent */
.bc-root {
    background: #344870;
    color: #c8d8f0;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.bc-root:hover { background: #2a3b5c; color: #fff; }

/* Intermediate groups — subtle box, link color text */
.bc-middle {
    background: #dde4ef;
    color: var(--accent);
    font-weight: 400;
    text-decoration: none;
    transition: background .15s;
}
.bc-middle:hover { background: #ccd5e8; text-decoration: none; }

/* Current page — same subtle box, dark text, no link */
.bc-current {
    background: #dde4ef;
    color: var(--text-main);
    font-weight: 500;
}

/* Separator — visible > sign */
.bc-sep {
    display: inline-flex;
    align-items: center;
    color: #4a5568;
    font-size: 15px;
    font-weight: 500;
    flex-shrink: 0;
    user-select: none;
    padding: 0 4px;
}

/* ── Canonical View Switcher ──────────────────────────────────────────── */
/* The unifying chrome element: lists every available view for the current
 * group and highlights the active one. Adding a new view = one new entry in
 * render_view_switcher() — the styling here is shared by all of them. */
.kb-view-switcher {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    /* Stick just below the (already sticky) breadcrumb so view-switching stays
       reachable while scrolling. Spans the right-panel padding like the
       breadcrumb, with a solid backdrop so content doesn't show through. */
    position: sticky;
    top: 36px;                 /* breadcrumb min-height */
    z-index: 49;               /* one below the breadcrumb's 50 */
    margin: 0 -24px;
    padding: 10px 24px;
    background: var(--body-bg);
    border-bottom: 1px solid var(--border);
    /* Soft elevation so the sticky header (breadcrumb + this switcher) reads as
       floating above the scrolling content instead of blending into the body. */
    box-shadow: 0 5px 8px -5px rgba(16, 24, 40, .18);
}

.kb-vsw-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.kb-vsw-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent-light);
}
.kb-vsw-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    cursor: default;
}
.kb-vsw-btn .bi { font-size: 13px; }

/* "Zoom continuum" grouping: the four structural lenses (Map·Tree·Terms·Read)
   read as one magnification band, flanked by ◀ ▶ cues; vertical rules fence off
   the prose Overview (left) and external Resources (right). */
.kb-vsw-band {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.kb-vsw-sep {
    width: 1px;
    align-self: stretch;
    min-height: 18px;
    background: var(--border);
    margin: 0 3px;
}
.kb-vsw-zoom {
    color: var(--text-muted);
    font-size: 9px;
    opacity: .55;
    user-select: none;
    line-height: 1;
}

/* Group page header */
.rp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--text-main);
}

.rp-header-left  { display: flex; flex-direction: column; gap: 6px; }
.rp-group-title  { font-size: 22px; font-weight: 600; margin: 0; line-height: 1.2; }
.rp-meta-links   { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-btn        { font-size: 12px; padding: 2px 8px; display: inline-flex; align-items: center; gap: 4px; }

.rp-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.rp-total-count { font-size: 28px; font-weight: 600; color: var(--accent); line-height: 1; }
.rp-total-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* Root terms pill block */
.rp-root-terms {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.rp-root-terms h6 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin: 0 0 10px 0;
}

.rp-root-terms ul {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Modal trigger links inside pill block */
.rp-root-terms ul li a,
.rp-root-terms ul li span[onclick],
.rp-root-terms ul li [data-term] {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    padding: 3px 12px;
    border-radius: 20px;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}

.rp-root-terms ul li a:hover { background: #d0e8fc; }

/* Cards grid */
.cards-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

@media (min-width: 600px)  { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } }

/* Individual card */
.group-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-header-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.card-title-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    display: block;
    word-break: break-word;
}

.card-title-link:hover { color: var(--accent); }
/* Leaf group (no sub-groups): not a drill link */
.card-title-leaf { cursor: default; }
.card-title-leaf:hover { color: var(--text-main); }
.card-meta-links { display: flex; gap: 6px; flex-wrap: wrap; }

.card-count-badge {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 8px;
    padding: 4px 10px;
    min-width: 44px;
}

.card-count-badge .num { font-size: 16px; font-weight: 600; line-height: 1; }
.card-count-badge .lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }

/* Term list inside card */
.card-term-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.card-term-list li a,
.card-term-list li span[onclick],
.card-term-list li [data-term] {
    font-size: 13px;
    color: var(--text-main);
    text-decoration: none;
    display: block;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.card-term-list li a:hover { background: var(--accent-light); color: var(--accent); }

/* Collapsible sub-nodes inside cards */
.sub-node { margin-top: 4px; }

.sub-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}

.sub-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 9px;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.sub-toggle:hover { background: var(--border); color: var(--text-main); }

.sub-node-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.sub-node-name:hover { color: var(--accent); }
/* Leaf sub-node (no sub-groups): not a drill link */
.sub-node-leaf { cursor: default; }
.sub-node-leaf:hover { color: var(--text-muted); }

.sub-node-count {
    font-size: 10px;
    background: var(--badge-bg);
    color: var(--badge-text);
    border-radius: 10px;
    padding: 1px 6px;
    flex-shrink: 0;
}

.sub-node.collapsed > .sub-node-content { display: none; }
.sub-node-content { padding-left: 20px; }

/* Search results */
.search-overlay { display: none; }
.search-overlay.active { display: block; }

.search-results-header {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    font-weight: 500;
}

.search-result-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
}

/* Grouped search results: section per group */
.search-group-block { margin-bottom: 18px; }
.search-group-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    font-family: 'DM Sans', Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
    background: #f0f4f8;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.search-group-heading:hover {
    background: #e2e8f0;
    color: #1a202c;
    text-decoration: none;
}
.search-group-name  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-group-count {
    background: #fff;
    color: var(--text-muted);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.search-group-items { padding-left: 6px; }

.search-result-group {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    text-align: right;
    flex-shrink: 0;
    text-decoration: none;
}
.search-result-group:hover {
    color: var(--accent);
    text-decoration: underline;
}

.search-no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 14px;
}

/* Spinner */
.rp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    gap: 10px;
    font-size: 14px;
}

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile drawer overlay (button reset so it fills the screen) */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
    border: none;
    padding: 0;
    cursor: default;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .topbar-hamburger { display: flex; align-items: center; }
    .topbar-search input { width: 110px; }
    .topbar-admin { display: none; }
    .topbar-brand { font-size: 15px; }   /* keep the wordmark from crowding the bar */

    .left-panel {
        position: fixed;
        top: var(--topbar-h);
        left: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 150;
    }

    .left-panel.open { transform: translateX(0); }
    .drawer-overlay.open { display: block; }

    .right-panel { padding: 0 14px 14px 14px; }
    .rp-breadcrumb-nav { margin: 0 -14px 0 -14px; padding-left: 8px; }
    .kb-view-switcher { margin: 0 -14px; padding: 8px 14px; }
    /* Collapse the zoom-band scaffolding on phones: the row already wraps, so the
       dividers/arrows just add clutter and eat vertical space. display:contents
       lets the four band pills wrap together with Overview/Resources. */
    .kb-vsw-sep, .kb-vsw-zoom { display: none; }
    .kb-vsw-band { display: contents; }
    /* Icon-only pills on mobile so the whole switcher stays on one line. Labels
       are still announced via each pill's title/aria; the active pill keeps its
       label for orientation. */
    .kb-view-switcher { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .kb-vsw-btn { padding: 7px 9px; gap: 0; }
    .kb-vsw-btn .kb-vsw-lbl { display: none; }
    .kb-vsw-btn.active .kb-vsw-lbl { display: inline; margin-left: 5px; }
    /* …except the leaf (term) pill — its name is already in the heading/breadcrumb. */
    .kb-vsw-btn.kb-vsw-leaf .kb-vsw-lbl { display: none; }
    .rp-group-title { font-size: 18px; }
    .rp-total-count { font-size: 22px; }
}

/* ── Print ────────────────────────────────────────────────────────────── */
@media print {
    .topbar, .left-panel { display: none; }
    .right-panel { padding: 0; }
    .group-card { page-break-inside: avoid; }
}


pre {
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

code {
  font-family: 'Fira Code', 'Courier New', monospace;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Shared scope-aware search overlay (kb_search.js + search.php fragment)
   ═══════════════════════════════════════════════════════════════════════════ */
.kb-search-results {
    position: fixed;
    top: var(--topbar-h); left: 0; right: 0; bottom: 0;
    background: var(--body-bg);
    overflow-y: auto;
    z-index: 150;
    padding: 26px 24px 48px;
}
.kb-search-results[hidden] { display: none; }
.kb-sr-inner { max-width: 980px; margin: 0 auto; }

.kb-search-loading { text-align: center; color: var(--text-muted); padding: 48px 16px; font-size: 14px; }

.kb-search-results .results-summary { font-size: 14px; color: var(--text-muted); margin-bottom: 22px; }
.kb-search-results .results-summary strong { color: var(--text-main); }

/* Masonry grid of result groups: pack variable-height blocks into columns. */
.kb-search-results .search-grid { column-width: 300px; column-gap: 24px; }
.kb-search-results .search-grid .domain-block { break-inside: avoid; -webkit-column-break-inside: avoid; }
.kb-search-results .domain-block {
    margin-bottom: 20px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;            /* clip the full-bleed path strip to the rounded card */
    padding: 11px 14px 13px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}
.kb-search-results .domain-heading {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); padding-bottom: 8px; margin-bottom: 12px;
    border-bottom: 2px solid var(--border); text-decoration: none;
}
.kb-search-results .domain-heading:hover { color: var(--accent); }
.kb-search-results .domain-heading .count {
    font-size: 11px; font-weight: 600; background: var(--badge-bg); color: var(--badge-text);
    border-radius: 999px; padding: 1px 9px; letter-spacing: 0;
}

/* Breadcrumb heading for each result group (domain › … › group, all linked). */
/* Subtle full-bleed top strip — the hierarchy recedes; the terms are the focus. */
.kb-search-results .search-path {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 5px;
    font-size: 11px; color: var(--text-muted);
    margin: -11px -14px 11px; padding: 6px 14px;
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.kb-search-results .search-path a { color: var(--text-muted); text-decoration: none; }
.kb-search-results .search-path a:hover { color: var(--accent); text-decoration: underline; }
.kb-search-results .search-path .sp-leaf { font-weight: 600; }
.kb-search-results .search-path .sp-sep { color: #cbd5e0; }
.kb-search-results .search-path .count {
    margin-left: auto; font-size: 10px; font-weight: 600;
    background: var(--badge-bg); color: var(--badge-text); border-radius: 999px; padding: 1px 8px;
}

.kb-search-results .term-list { display: flex; flex-wrap: wrap; gap: 8px; }
/* render_term_withOnClickModal() emits a bare <span onclick=…>; style it as a pill */
.kb-search-results .term-list > span {
    background: var(--accent-light); color: var(--accent);
    font-size: 14px; padding: 6px 14px; border-radius: 20px; line-height: 1.3;
    cursor: pointer; transition: background .15s;
}
.kb-search-results .term-list > span:hover { background: #d0e8fc; }

.kb-search-results .empty-state,
.kb-search-results .prompt-state {
    text-align: center; color: var(--text-muted); padding: 54px 16px; font-size: 15px;
}
.kb-search-results .empty-state strong { color: var(--text-main); }
.kb-search-widen {
    margin-top: 14px; font-size: 13px; font-weight: 600;
    padding: 7px 16px; border-radius: 999px;
    border: 1px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer;
    transition: background .14s, color .14s;
}
.kb-search-widen:hover { background: var(--accent); color: #fff; }

/* Inline variant: results fill the content region (sidebar + breadcrumb +
   switcher stay visible). The view places kb_search_region() after its switcher
   and wraps its body in .kb-search-hideable. */
.kb-search-results--inline {
    position: static;
    top: auto; left: auto; right: auto; bottom: auto;
    z-index: auto;
    background: transparent;
    overflow: visible;
    padding: 18px 0 40px;
}
.kb-search-results--inline .kb-sr-inner { max-width: none; }
