/* Pip-Boy Terminal (dark, amber) is the default. Vault-Tec Blue is the optional light theme. */
:root[data-bs-theme='dark'] {
  color-scheme: dark;
  --main-bg: #151719; --sidebar-bg: #1d2023; --card-bg: #22262a;
  --card-header-bg: #282c30; --card-hover-bg: #2d3032;
  --main-border-color: #3d4245; --sidebar-border-color: #3d4245;
  --text-color: #d4d1c9; --heading-color: #f4f1ea; --site-title-color: #f4f1ea;
  --site-subtitle-color: #b9b8b0; --text-muted-color: #b9b8b0; --sidebar-muted-color: #b9b8b0;
  --sidebar-active-color: #efbb65; --sidebar-hover-bg: #3a3020;
  --sidebar-btn-bg: #292d30; --sidebar-btn-color: #efbb65;
  --link-color: #efbb65; --link-underline-color: #917441; --toc-highlight: #efbb65;
  --topbar-bg: #151719ed; --search-border-color: #545a5d;
  --tag-border: #3d4245; --tag-hover: #3a3020; --categories-border: #3d4245;
  --categories-hover-bg: #3a3020; --card-shadow: 0 0 0 1px #3d4245;
  --lab-accent: #efbb65; --lab-selected: #3a3020; --lab-visual: #2c2924;
  --lab-terminal-bg: #1d2023; --lab-terminal-text: #d4d1c9; --lab-terminal-accent: #efbb65;
  --lab-toolbar-bg: #1d2023; --lab-toolbar-text: #b9b8b0; --lab-fade: #151719ed;
}
:root[data-bs-theme='light'] {
  color-scheme: light;
  --main-bg: #f1ebd8; --sidebar-bg: #21496b; --card-bg: #fffbed;
  --card-header-bg: #eee4c9; --card-hover-bg: #f5edd5;
  --main-border-color: #c9bea0; --sidebar-border-color: #e9c44c;
  --text-color: #344551; --heading-color: #21496b; --site-title-color: #ffe087;
  --site-subtitle-color: #e2e8e6; --text-muted-color: #5e6a70; --sidebar-muted-color: #e2e8e6;
  --sidebar-active-color: #21496b; --sidebar-hover-bg: #efd067;
  --sidebar-btn-bg: #efd067; --sidebar-btn-color: #21496b;
  --link-color: #84500d; --link-underline-color: #b79558; --toc-highlight: #84500d;
  --topbar-bg: #f1ebd8ed; --search-border-color: #b5a989;
  --tag-border: #c9bea0; --tag-hover: #eee0ad; --categories-border: #c9bea0;
  --categories-hover-bg: #eee0ad; --card-shadow: 0 0 0 1px #c9bea0;
  --lab-accent: #84500d; --lab-selected: #eee0ad; --lab-visual: #e7dabb;
  --lab-terminal-bg: #21496b; --lab-terminal-text: #e2e8e6; --lab-terminal-accent: #ffe087;
  --lab-toolbar-bg: #21496b; --lab-toolbar-text: #fff5d6; --lab-fade: #f1ebd8ed;
}
#sidebar #avatar { border:1px solid var(--sidebar-border-color); box-shadow:0 0 25px #00000018; }
/* The sidebar <img> carries the Pip-Boy Terminal avatar (brand-avatar-graphite.svg); Vault-Tec swaps in its own animated colourway. */
:root[data-bs-theme='light'] #sidebar #avatar { background:url('/assets/img/brand-avatar-vault.svg?v=2') center / 100% no-repeat; transition:background-size .5s; }
:root[data-bs-theme='light'] #sidebar #avatar:hover { background-size:120%; }
:root[data-bs-theme='light'] #sidebar #avatar img { opacity:0; }
.product-category-icon { width:24px; height:24px; object-fit:contain; margin-right:8px; vertical-align:middle; }
.product-category-icon[src$='.png'] { transform:scale(1.8); }
a:focus-visible,button:focus-visible { outline:2px solid var(--lab-accent); outline-offset:4px; }
:root[data-bs-theme='light'] #sidebar { border-right:5px solid #e9c44c; background-image:radial-gradient(circle at 40% 86%,transparent 0 62px,#ffffff06 63px 76px,transparent 77px 86px,#ffffff06 87px 89px,transparent 90px); }
:root[data-bs-theme='light'] #sidebar .site-title { font-family:Georgia,serif; color:#ffe087; }
:root[data-bs-theme='light'] #sidebar .nav-link:hover { color:#21496b; }
:root[data-bs-theme='light'] #sidebar .sidebar-bottom .btn,:root[data-bs-theme='light'] #sidebar .sidebar-bottom > a { color:#21496b; }
:root[data-bs-theme='light'] #main-wrapper { background-image:radial-gradient(circle at 100% 82%,transparent 0 160px,#21496b05 161px 182px,transparent 183px 204px,#21496b05 205px 208px,transparent 209px); }
/* Author card at the bottom of the sidebar (see _includes/sidebar.html). */
#sidebar .sidebar-author { display:flex; align-items:center; gap:12px; width:calc(100% - 3rem); margin:0 1.5rem 1rem; padding:10px 12px; border:1px solid var(--sidebar-border-color); border-radius:10px; color:var(--site-title-color); text-decoration:none; opacity:1; transition:background-color .2s; }
#sidebar .sidebar-author:hover { background:var(--sidebar-hover-bg); }
#sidebar .sidebar-author img { flex:0 0 48px; width:48px; height:48px; border-radius:50%; object-fit:cover; object-position:50% 20%; box-shadow:0 0 0 2px var(--sidebar-bg),0 0 0 4px var(--sidebar-active-color); }
#sidebar .sidebar-author-text { display:flex; flex:1 1 0; flex-direction:column; min-width:0; line-height:1.3; }
#sidebar .sidebar-author-name { font-weight:600; font-size:.95rem; }
#sidebar .sidebar-author-role { color:var(--sidebar-muted-color); font-size:.75rem; }
#sidebar .sidebar-author-badge { display:none; }
/* Vault-Tec Blue: the author card becomes a Vault-Tec Dweller ID badge. */
:root[data-bs-theme='light'] #sidebar .sidebar-author { flex-wrap:wrap; gap:10px; padding:0 12px 12px; overflow:hidden; background:#fff5d6; color:#21496b; border:2px solid #e9c44c; border-radius:6px; box-shadow:4px 4px 0 #0b274099; transform:rotate(-2deg); transition:transform .25s; }
:root[data-bs-theme='light'] #sidebar .sidebar-author:hover { background:#fff5d6; transform:rotate(0) scale(1.03); }
:root[data-bs-theme='light'] #sidebar .sidebar-author-badge { display:block; flex:0 0 calc(100% + 24px); margin:0 -12px; padding:4px 12px; background:#e9c44c; color:#21496b; font:700 9px/1.5 ui-monospace,Consolas,monospace; letter-spacing:1.2px; text-transform:uppercase; }
:root[data-bs-theme='light'] #sidebar .sidebar-author img { flex-basis:44px; width:44px; height:52px; border-radius:3px; border:2px solid #21496b; box-shadow:none; }
:root[data-bs-theme='light'] #sidebar .sidebar-author-name { font:700 12px/1.4 ui-monospace,Consolas,monospace; letter-spacing:1px; text-transform:uppercase; color:#21496b; }
:root[data-bs-theme='light'] #sidebar .sidebar-author-role { font:10px/1.4 ui-monospace,Consolas,monospace; color:#5e6a70; text-transform:uppercase; }
/* Both themes: centred logo and a one-line title spanning the sidebar. */
#sidebar .profile-wrapper { display:flex; flex-direction:column; align-items:center; padding-left:1.25rem; padding-right:1.25rem; text-align:center; }
#sidebar .site-title { white-space:nowrap; }
:root[data-bs-theme='light'] #sidebar .site-title { font-size:1.6rem; letter-spacing:0; }
@media (min-width:1650px) { :root[data-bs-theme='light'] #sidebar .site-title { font-size:1.85rem; } }
#sidebar .sidebar-vault-emblem { display:none; }
/* The nav stops stretching so the emblem's auto margins centre it between the categories and the badge. */
:root[data-bs-theme='light'] #sidebar nav { flex-grow:0 !important; }
:root[data-bs-theme='light'] #sidebar .sidebar-vault-emblem { display:block; flex:none; align-self:center; color:#e9c44c; opacity:.35; margin:auto 0; }
:root[data-bs-theme='light'] #sidebar .sidebar-author { flex-shrink:0; } /* never squash the badge on short screens */
/* Footer buttons: one even gap, no separator dot, centred under the author badge. */
#sidebar .sidebar-bottom { justify-content:center; gap:.8rem; padding-left:1rem; padding-right:1rem; }
#sidebar .sidebar-bottom > * { margin-left:0 !important; margin-right:0 !important; }
#sidebar .sidebar-bottom .icon-border { display:none; }
/* Vault-Tec Blue: post headings match the Georgia titles used on the home cards. */
:root[data-bs-theme='light'] main h1, :root[data-bs-theme='light'] .content h2, :root[data-bs-theme='light'] .content h3 { font-family:Georgia,serif; }
.vault-banner { display:none; }
:root[data-bs-theme='light'] .vault-banner { display:grid; grid-template-columns:210px minmax(0,1fr); background:#21496b; border-bottom:7px solid #e9c44c; margin-bottom:26px; min-height:205px; overflow:hidden; position:relative; }
.vault-boy-art { background:#185b86 url('/assets/img/fallout/vault-boy-banner.jpg') center / cover no-repeat; border-right:3px solid #e9c44c; }
.vault-banner-copy { position:relative; display:flex; align-items:center; padding:28px 32px; background-image:radial-gradient(circle at 110% 120%,transparent 0 78px,#ffe08715 79px 88px,transparent 89px 100px,#ffe08715 101px 104px,transparent 105px); }
.vault-banner h2 { color:#fff5d6; font:italic 700 clamp(30px,4.2vw,48px)/1.08 Georgia,serif; margin:0; text-shadow:3px 3px 0 #0b2740; }
/* Clip card contents to the rounded corners in both themes, so the square preview strip and its toolbar never poke out. */
#post-list .card-wrapper .post-preview { position:relative; overflow:hidden; }
/* Vault-Tec gold bar drawn inside the card frame, clipped to its rounded corners. */
:root[data-bs-theme='light'] #post-list .card-wrapper .post-preview::after { content:''; position:absolute; z-index:2; inset:0 0 auto; height:4px; background:#e9c44c; pointer-events:none; } /* ::before is Chirpy's hover overlay */
/* Vault-Tec Blue theme menu: the sidebar's light muted text is unreadable on the white dropdown. */
:root[data-bs-theme='light'] #sidebar #mode-toggle + .dropdown-menu .dropdown-item { color:#344551; }
:root[data-bs-theme='light'] #sidebar #mode-toggle + .dropdown-menu .dropdown-item.active { color:#21496b; }
:root[data-bs-theme='light'] #sidebar #mode-toggle + .dropdown-menu .dropdown-item > i { color:#21496b; }
/* Equal-width menu icons so the three labels start on one line. */
#sidebar #mode-toggle + .dropdown-menu .dropdown-item > i { flex:0 0 1.25rem; width:1.25rem; text-align:center; }
:root[data-bs-theme='light'] #post-list .card-title { font-family:Georgia,serif; font-weight:700; }
@media(max-width:767px) {
 :root[data-bs-theme='light'] .vault-banner { grid-template-columns:125px minmax(0,1fr); min-height:190px; }
 .vault-boy-art { background-size:contain; }
 .vault-banner-copy { padding:18px 16px; }
 .vault-banner h2 { font-size:28px; }
}
@media(max-width:380px) {
 :root[data-bs-theme='light'] .vault-banner { grid-template-columns:100px minmax(0,1fr); }
 .vault-banner h2 { font-size:24px; }
}
@media(prefers-reduced-motion:reduce) { html { scroll-behavior:auto; } }
/* Sidebar navigation with Fallout names per theme (_data/lab_nav.yml, _includes/lab-nav-item.html).
   Both sets are in the markup; the inactive theme's label and icon are hidden. */
:root[data-bs-theme='light'] #sidebar .lab-nav-pipboy,
:root:not([data-bs-theme='light']) #sidebar .lab-nav-vault { display:none; }
#sidebar a.lab-nav-link .lab-nav-text { display:flex; flex-direction:column; min-width:0; line-height:1.15; }
#sidebar li.nav-item a.lab-nav-link span.lab-nav-text { font-size:100%; } /* the page name keeps Chirpy's 90% */
#sidebar a.lab-nav-link .lab-nav-name { white-space:nowrap; }
#sidebar a.lab-nav-link .lab-nav-fx { margin-top:2px; font-size:.64rem; font-weight:600; letter-spacing:.9px; text-transform:uppercase; opacity:.72; white-space:nowrap; }
#sidebar li.nav-item a.lab-nav-link { padding-top:.42rem; padding-bottom:.42rem; }
:root:not([data-bs-theme='light']) #sidebar a.lab-nav-link .lab-nav-fx { font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-weight:500; letter-spacing:1.6px; }
/* Custom SVG nav icons (_includes/icons/), sized and spaced like Chirpy's Font Awesome nav icons. */
#sidebar a.lab-nav-link .lab-nav-svg { flex:none; width:1.25em; height:1.25em; opacity:.85; }
/* Larger icons and page names than Chirpy's defaults; Font Awesome and SVG icons share size and text start. */
#sidebar a.lab-nav-link > i, #sidebar a.lab-nav-link > .lab-nav-svg { font-size:118%; margin-right:1.2rem; }
#sidebar li.nav-item a.lab-nav-link span.lab-nav-name { font-size:100%; }
/* Low screens: tighter items so the badge and footer buttons stay in view; below 760px no tagline, below 690px only the page name. */
@media (max-height:820px) {
  #sidebar ul.nav { margin-bottom:1rem; }
  #sidebar li.nav-item:not(:first-child) { margin-top:.1rem; }
  #sidebar li.nav-item a.lab-nav-link { padding-top:.26rem; padding-bottom:.26rem; }
  #sidebar a.lab-nav-link .lab-nav-fx { margin-top:0; font-size:.6rem; }
  #sidebar #avatar { width:5rem; height:5rem; }
  #sidebar .profile-wrapper { margin-top:1.5rem; }
  :root[data-bs-theme='light'] #sidebar .sidebar-vault-emblem { display:none; }
  :root[data-bs-theme='light'] #sidebar .sidebar-author { margin-top:auto; } /* the hidden emblem no longer pushes it down */
}
@media (max-height:760px) {
  #sidebar li.nav-item a.lab-nav-link { padding-top:.16rem; padding-bottom:.16rem; }
  #sidebar a.lab-nav-link > i, #sidebar a.lab-nav-link > .lab-nav-svg { font-size:108%; }
  #sidebar .site-subtitle { display:none; } /* the tagline makes room for the Fallout subtitles */
}
@media (max-height:690px) {
  #sidebar a.lab-nav-link .lab-nav-fx { display:none; }
  #sidebar li.nav-item a.lab-nav-link { padding-top:.3rem; padding-bottom:.3rem; }
}
/* Wider custom icons (the rolled-aside vault door): same text start as the 1.25em Font Awesome icons. */
#sidebar a.lab-nav-link .lab-nav-svg-wide { width:1.5em; margin-right:calc(1.2rem - .25em); }
/* Pip-Boy Terminal home banner (_layouts/home.html): amber phosphor screen, typed headline, real blog stats.
   The typing, cursor and flicker are CSS animations, so the animations switch ends them in their final state. */
.pipboy-banner { display:none; }
:root:not([data-bs-theme='light']) .pipboy-banner { --pb:#efbb65; --pb-dim:#5a4520; position:relative; display:grid; grid-template-columns:210px minmax(0,1fr); min-height:205px; margin-bottom:26px; overflow:hidden; background:radial-gradient(ellipse at 30% 40%,#1f1a0f,#0d0b07 70%); border:1px solid var(--pb-dim); border-bottom:4px solid var(--pb); border-radius:6px; color:var(--pb); font-family:ui-monospace,SFMono-Regular,Consolas,monospace; text-shadow:0 0 6px #efbb6566; }
.pipboy-banner::after { content:''; position:absolute; inset:0; pointer-events:none; background:repeating-linear-gradient(0deg,#00000052 0 1px,transparent 1px 3px); animation:pb-flicker 5s steps(1) infinite; }
.pipboy-art { display:flex; align-items:center; justify-content:center; border-right:1px solid var(--pb-dim); padding:10px; }
/* A CSS background, not an <img>: Chirpy wraps content images in a grey lazy-load frame. */
.pipboy-vault-boy { width:100%; max-width:190px; aspect-ratio:1; background:center / contain no-repeat; mix-blend-mode:screen; filter:drop-shadow(0 0 8px #efbb6540); -webkit-mask:radial-gradient(circle,#000 60%,transparent 71%); mask:radial-gradient(circle,#000 60%,transparent 71%); }
.pipboy-copy { display:flex; flex-direction:column; gap:8px; min-width:0; padding:16px 24px 14px; }
.pipboy-tabs { display:flex; gap:18px; padding-bottom:7px; border-bottom:1px solid var(--pb-dim); font-size:12px; letter-spacing:.16em; }
.pipboy-tabs span { opacity:.5; }
.pipboy-tabs .on { opacity:1; margin:-1px -7px; padding:0 6px; border:1px solid var(--pb); }
.pipboy-boot { margin:0; font-size:11px; letter-spacing:.08em; opacity:.7; }
.pipboy-banner h2 { margin:2px 0 0; color:var(--pb); font:500 clamp(19px,2.6vw,30px)/1.2 ui-monospace,SFMono-Regular,Consolas,monospace; letter-spacing:.01em; }
.pipboy-line { display:inline-block; overflow:hidden; white-space:nowrap; vertical-align:bottom; width:0; --n:20; animation:pb-type .8s steps(20) .25s forwards; } /* --n = characters in the line */
.pipboy-line + br + .pipboy-line { --n:19; animation:pb-type .75s steps(19) 1.15s forwards; }
.pipboy-cursor { display:inline-block; width:.55em; height:.95em; margin-left:.25em; vertical-align:-.1em; background:var(--pb); animation:pb-blink 1.05s steps(1) 2s infinite; }
.pipboy-stats { display:flex; flex-wrap:wrap; gap:6px 18px; margin:auto 0 0; padding-top:8px; border-top:1px solid var(--pb-dim); font-size:11px; letter-spacing:.12em; }
.pipboy-signal i { display:inline-block; width:46px; height:8px; margin-left:4px; vertical-align:-1px; border:1px solid var(--pb); background:linear-gradient(90deg,var(--pb) 0 78%,transparent 78%) content-box; padding:1px; }
@keyframes pb-type { to { width:calc(var(--n) * 1ch); } }
@keyframes pb-blink { 50% { opacity:0; } }
@keyframes pb-flicker { 0%,100% { opacity:1; } 47% { opacity:.86; } 48% { opacity:1; } }
@media (max-width:767px) {
  :root:not([data-bs-theme='light']) .pipboy-banner { grid-template-columns:120px minmax(0,1fr); min-height:180px; }
  .pipboy-copy { padding:12px 14px; gap:6px; }
  .pipboy-tabs { gap:10px; font-size:10px; letter-spacing:.08em; }
  .pipboy-boot { font-size:9px; }
}
@media (max-width:420px) {
  :root:not([data-bs-theme='light']) .pipboy-banner { grid-template-columns:92px minmax(0,1fr); }
  .pipboy-tabs span:nth-child(n+4) { display:none; }
  .pipboy-banner h2 { font-size:17px; }
}
/* Post preview banner: never wider than the 1200px card, and the image fills its frame instead of being cropped (wide flowchart layout). */
article header .preview-img { max-width:1200px; }
article header .preview-img img { width:100%; height:100%; }
/* Below 850px (where the menu button shows) the top bar stays in view while scrolling,
   so the menu and search are always one tap away. The translucent --topbar-bg plus a blur keeps text readable. */
@media (max-width: 849.98px) {
  #topbar-wrapper {
    position: sticky;
    top: 0;
    z-index: 1;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
}
/* Opening the menu slides the page 260px to the right. Since pinch-zoom is allowed, phones zoomed the layout
   out to fit that overflow (e.g. when the theme menu opened), which stretched the fixed sidebar so its bottom
   buttons dropped below the screen. The overflow has to be clipped by body itself: html only sets the viewport
   (which still zooms out), and a non-visible html stops body's value moving to the viewport. Clip, unlike hidden,
   does not make body a scroll container, so the sticky bars keep working. */
@media (max-width: 849.98px) {
  html { overflow-x: hidden; }
  body { overflow-x: clip; }
}
/* Phones and small tablets: a Vault-Tec top bar instead of the plain cream strip. Blue with a gold rule in Vault-Tec
   Blue, graphite with amber in Pip-Boy Terminal. On articles the rule fills up as reading progress (--lab-read,
   set by tenant-lab-post-nav.js); elsewhere it is full. */
@media (max-width: 849.98px) {
  :root[data-bs-theme='light'] { --lab-bar-text: #fff5d6; --lab-bar-title: #ffe087; --lab-bar-rule: #e9c44c; --lab-bar-track: #e9c44c40; }
  :root[data-bs-theme='dark'] { --lab-bar-text: #d4d1c9; --lab-bar-title: #f4f1ea; --lab-bar-rule: #efbb65; --lab-bar-track: #efbb6533; }
  #topbar-wrapper {
    background:
      radial-gradient(120% 140% at 50% -40%, #ffffff1f, transparent 60%),
      var(--sidebar-bg);
    transition: box-shadow 0.2s;
  }
  #topbar-wrapper::before,
  #topbar-wrapper::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    pointer-events: none;
  }
  #topbar-wrapper::before { background: var(--lab-bar-track); }
  #topbar-wrapper::after {
    background: var(--lab-bar-rule);
    transform: scaleX(var(--lab-read, 1));
    transform-origin: left;
  }
  #topbar-wrapper.is-scrolled { box-shadow: 0 6px 18px #00000033; }
  #topbar #sidebar-trigger,
  #topbar #search-trigger,
  #topbar #lab-toc-trigger,
  #topbar #search-cancel {
    min-width: 44px;
    min-height: 44px;
    color: var(--lab-bar-text);
  }
  #topbar #search-cancel { min-width: 0; }
  #topbar #search { background: #ffffff14; border-color: #ffffff33; }
  #topbar #search,
  #topbar #search > i,
  #topbar #search-input,
  #topbar #search-input::placeholder { color: var(--lab-bar-text); }
  #topbar-title {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    color: var(--lab-bar-title);
  }
  .lab-topbar-label,
  .lab-topbar-page-title {
    transition: opacity 0.25s, transform 0.25s;
  }
  .lab-topbar-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: Georgia, serif;
    font-size: 1.08rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
  }
  .lab-topbar-logo {
    flex: 0 0 26px;
    height: 26px;
    border-radius: 50%;
    background: url('/assets/img/brand-avatar-graphite.svg?v=2') center / 100% no-repeat;
    box-shadow: 0 0 0 1.5px var(--lab-bar-rule);
  }
  :root[data-bs-theme='light'] .lab-topbar-logo { background-image: url('/assets/img/brand-avatar-vault.svg?v=2'); }
  .lab-topbar-page-title {
    position: absolute;
    inset: 0;
    padding: 0 4px;
    overflow: hidden;
    color: var(--lab-bar-title);
    font-family: Georgia, serif;
    font-size: 0.98rem;
    line-height: 3rem;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(60%);
    pointer-events: none;
  }
  #topbar-wrapper.is-past-title .lab-topbar-label { opacity: 0; transform: translateY(-60%); }
  #topbar-wrapper.is-past-title .lab-topbar-page-title { opacity: 1; transform: none; }
  /* The top bar carries the contents button now, so Chirpy's own sticky contents bar would only cover it. */
  #toc-bar { display: none !important; }
}
@media (max-width: 849.98px) and (prefers-reduced-motion: reduce) {
  .lab-topbar-label,
  .lab-topbar-page-title { transition: none; }
}
#lab-toc-trigger { display: none; }
@media (max-width: 849.98px) {
  #lab-toc-trigger { display: block; }
}
/* Search in this post (tenant-lab-post-nav.js): a field at the top of the contents popup, and a bar under the
   top bar to step through the matches. */
#toc-popup .lab-find {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 1rem 0.25rem;
  padding: 0 12px;
  min-height: 44px;
  border: 1px solid var(--main-border-color);
  border-radius: 8px;
  color: var(--text-muted-color);
}
#toc-popup .lab-find:focus-within { border-color: var(--lab-accent); }
#toc-popup .lab-find input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--heading-color);
  font-size: 16px; /* below 16px iOS zooms in on focus */
  outline: none;
}
#toc-popup .lab-find-count { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.lab-find-bar {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid var(--main-border-color);
  background: var(--card-bg);
  color: var(--text-color);
  box-shadow: 0 6px 18px #0000002a;
  font-size: 0.9rem;
}
.lab-find-bar[hidden] { display: none; }
.lab-find-term {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-find-position { color: var(--text-muted-color); font-variant-numeric: tabular-nums; }
.lab-find-bar button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--heading-color);
}
::highlight(lab-find) { background-color: #e9c44c66; }
::highlight(lab-find-current) { background-color: #e9c44c; color: #21496b; }
/* Chirpy's search mode hides the menu, title and search buttons with .d-none; hide the contents button with them. */
#topbar:has(#search-trigger.d-none) #lab-toc-trigger { display: none; }
/* Chirpy's Older/Newer buttons (and other outline-primary buttons) fell back to Bootstrap's bright #0d6efd on
   hover, tap and focus. Use the theme's own selection colours instead; Chirpy's own tag hover still wins. */
.btn-outline-primary {
  --bs-btn-hover-color: var(--heading-color);
  --bs-btn-hover-bg: var(--lab-selected);
  --bs-btn-hover-border-color: var(--lab-accent);
  --bs-btn-active-color: var(--heading-color);
  --bs-btn-active-bg: var(--lab-selected);
  --bs-btn-active-border-color: var(--lab-accent);
  --bs-btn-focus-shadow-rgb: 233, 196, 76;
}
/* Chirpy turns the "Older"/"Newer" label whitesmoke on hover, made for its blue fill; keep it readable. */
.post-navigation .btn:hover:not(.disabled)::before { color: var(--lab-accent); }
/* Chirpy forces a #007bff border on every outline-primary hover (with !important). */
.btn.btn-outline-primary:not(.disabled):hover { border-color: var(--lab-accent) !important; }
/* Chirpy's "New content available" toast: themed, and kept steadily on top while scrolling. It had no z-index
   (so anything later in the page with one could paint over it) and a backdrop blur on a fixed, transformed
   element, which phone browsers drop for a moment while scrolling. Now: an explicit layer above the sticky bars
   (below the cookie banner, 1100), a solid themed background instead of the blur, and its own compositing layer. */
:root[data-bs-theme='light'] #notification {
  --lab-toast-bg: #21496b; --lab-toast-text: #fff5d6; --lab-toast-rule: #e9c44c;
  --lab-toast-btn-bg: #efd067; --lab-toast-btn-text: #21496b;
}
:root[data-bs-theme='dark'] #notification {
  --lab-toast-bg: #1d2023; --lab-toast-text: #d4d1c9; --lab-toast-rule: #efbb65;
  --lab-toast-btn-bg: #efbb65; --lab-toast-btn-text: #151719;
}
#notification.toast {
  z-index: 1090;
  border: 1px solid var(--lab-toast-rule);
  background: var(--lab-toast-bg);
  color: var(--lab-toast-text);
  box-shadow: 0 10px 28px #00000040;
}
#notification.toast.show {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: translate3d(-50%, 0, 0);
  will-change: transform;
}
#notification .toast-body { color: inherit; font-weight: 600; }
#notification .btn-primary {
  --bs-btn-bg: var(--lab-toast-btn-bg);
  --bs-btn-border-color: var(--lab-toast-btn-bg);
  --bs-btn-color: var(--lab-toast-btn-text);
  --bs-btn-hover-bg: var(--lab-toast-rule);
  --bs-btn-hover-border-color: var(--lab-toast-rule);
  --bs-btn-hover-color: var(--lab-toast-btn-text);
  --bs-btn-active-bg: var(--lab-toast-rule);
  --bs-btn-active-border-color: var(--lab-toast-rule);
  --bs-btn-active-color: var(--lab-toast-btn-text);
  --bs-btn-focus-shadow-rgb: 233, 196, 76;
  min-height: 32px;
  font-weight: 700;
}
/* The close cross is a dark SVG; lighten it for the blue / graphite background. */
#notification .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: 0.8; }
#notification .btn-close:hover { opacity: 1; }
/* Phones and small tablets: the menu button is a round gold handle with a double chevron, styled like the sidebar's
   footer buttons. Closed it sits top left in the sticky bar ("»", open the menu). Chirpy slides the page 260px to the
   right when the menu opens, which puts the button exactly at the menu's edge; it then sits flush against it as the
   menu's handle and turns to "«" (close). Keyed on Chirpy's own body[sidebar-display], so it needs no script.
   The glyph is swapped here because the markup's fa-bars icon is Chirpy's (Font Awesome 6 and 7 both honour it). */
@media (max-width: 849.98px) {
  #topbar #sidebar-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    padding: 0;
    transition: transform 0.3s ease;
  }
  #topbar #sidebar-trigger i {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sidebar-btn-bg);
    color: var(--sidebar-btn-color);
    box-shadow: 0 0 0 1px var(--sidebar-border-color), 0 2px 6px #00000033;
    font-size: 0.85rem;
    transition: transform 0.3s ease;
  }
  #topbar #sidebar-trigger .fa-bars::before { content: '\f101'; } /* angles-right */
  /* Open: the round handle sits flush against the menu edge (the menu paints above the shifted page, so it cannot overlap it). */
  body[sidebar-display] #topbar #sidebar-trigger { transform: translateX(-7px); }
  body[sidebar-display] #topbar #sidebar-trigger i { transform: rotate(180deg); }
}
