.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  z-index: 1000;
  background: #111;
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 6px 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.skip-link:visited {
  color: #fff;
}
/* The site chrome top bar. Scoped to classless <nav> so this never leaks into
   in-content <nav> landmarks (e.g. .book-subnav, .faq-toc), which carry a class
   and style themselves — an unscoped `nav {}` turned those into 108px flex bars
   and overlapped their contents. Chrome navs (HOME_NAV / AUTH_NAV /
   confirm-email-change) are classless, so they still match. */
nav:not([class]) {
  background: #111;
  padding: 0 32px;
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.nav-brand { text-decoration: none; line-height: 0; }
.nav-brand img { height: 108px; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { color: #9ca3af; text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:visited { color: #9ca3af; }
.nav-links a:hover { color: #fff; }
/* Active-page indicator (set by nav.js on both navs). Underline via
   text-decoration — not a border — so there's no layout shift on inactive
   links and no clash with the mobile menu's per-row bottom border. */
.nav-links a.active,
.nav-links a.active:visited { color: #fff; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.nav-links a:focus-visible { outline: 2px solid rgba(255,255,255,0.7); outline-offset: 3px; border-radius: 2px; }
/* Nav auth-flash guard (paired with the inline guard in lib/head.js +
   homenav.js). HOME_NAV's link cluster carries .nav-links--auth-guard and
   stays invisible while <html> has `nav-pending` — i.e. until the async
   session check resolves and homenav.js sets the correct logged-in/out
   links. Stops a logged-in user from flashing the logged-out nav (Log In /
   Sign Up) on first paint. visibility (not display) keeps the bar's layout
   stable, so there's no shift on reveal. AUTH_NAV's .nav-links has no guard
   class, so authed pages are unaffected; the brand logo + hamburger stay
   visible throughout. */
.nav-pending .nav-links--auth-guard { visibility: hidden; }
.btn-nav {
  padding: 9px 20px;
  background: white;
  color: #111 !important;
  border-radius: 8px;
  font-weight: 700 !important;
  font-size: 14px;
  text-decoration: none;
}
.btn-nav:hover { background: #e5e7eb; color: #111 !important; }
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 14px 10px;
  flex-direction: column;
  gap: 5px;
  width: auto;
  color: inherit;
}
.nav-hamburger:hover { background: none; }
.nav-hamburger:focus-visible { outline: 2px solid rgba(255,255,255,0.7); outline-offset: 2px; border-radius: 4px; }
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}
footer {
  border-top: 1px solid #e5e7eb;
  padding: 40px 24px;
  text-align: center;
  font-size: 14px;
  color: #9ca3af;
}
footer a { color: #9ca3af; text-decoration: none; margin: 0 12px; }
footer a:visited { color: #9ca3af; }
footer a:hover { color: #111; }

/* ── Group switcher ─────────────────────────────────────────────────────────── */
.nav-list-switcher { position: relative; }
.list-switcher-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  max-width: 180px;
  min-height: 44px;
  font-family: inherit;
}
.list-switcher-btn:hover { background: rgba(255,255,255,0.18); }
.list-switcher-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.7); outline-offset: 2px; }
#groupSwitcherName { overflow: hidden; text-overflow: ellipsis; }
.list-switcher-chevron { display: inline-block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: 0.7; flex-shrink: 0; margin-top: 1px; }
.list-switcher-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}
.list-switcher-dropdown.open { display: block; }
.list-switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 14px;
  color: #111;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  gap: 12px;
}
.list-switcher-item:last-child { border-bottom: none; }
.list-switcher-item:hover { background: #f9fafb; }
.list-switcher-item:focus-visible { outline: 2px solid #111; outline-offset: -2px; }
.list-switcher-item-name { font-weight: 500; flex: 1; }
.list-switcher-item.active .list-switcher-item-name { font-weight: 700; }
.list-switcher-check { color: #111; font-size: 14px; }
.list-switcher-dropdown .list-switcher-manage {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}
.list-switcher-dropdown .list-switcher-manage:visited { color: #6b7280; }
.list-switcher-dropdown .list-switcher-manage:hover { color: #111; background: #f9fafb; }
.list-switcher-dropdown .list-switcher-manage:focus-visible { outline: 2px solid #111; outline-offset: -2px; }

@media (max-width: 900px) {
  nav:not([class]) { height: 80px; }
  .nav-brand img { height: 80px; }
}

/* Collapse to the hamburger at the tablet threshold (768px), not 640px: the
   authenticated nav carries 8 links + logo, which needs ~765px of content
   width, so 641–767px overflowed the bar instead of wrapping. */
@media (max-width: 768px) {
  nav:not([class]) { padding: 0 20px; height: 64px; }
  .nav-brand img { height: 64px !important; }
  .nav-hamburger { display: flex; margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: #111;
    flex-direction: column;
    padding: 8px 20px 16px;
    gap: 0;
    z-index: 100;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 14px 0; border-bottom: 1px solid #374151; font-size: 15px; }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links .btn-nav { background: none; color: #9ca3af !important; font-weight: 500 !important; }
  .nav-list-switcher { width: 100%; padding: 12px 0; border-bottom: 1px solid #374151; }
  .list-switcher-btn {
    background: none;
    border: none;
    padding: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    max-width: 100%;
  }
  .list-switcher-btn:hover { background: none; }
  .list-switcher-dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: transparent;
    margin-top: 8px;
    min-width: 0;
    max-height: 60vh;
    overflow-y: auto;
  }
  .list-switcher-item { color: #9ca3af; padding: 12px 0; border-bottom: none; background: transparent; }
  .list-switcher-item:hover { background: transparent; color: #fff; }
  .list-switcher-item:focus-visible { outline-color: rgba(255,255,255,0.7); }
  .list-switcher-item.active .list-switcher-item-name { color: #fff; }
  .list-switcher-check { color: #fff; }
  .list-switcher-manage { background: transparent; color: #888; border-top: none; padding: 8px 0 0; }
  .list-switcher-manage:hover { background: transparent; color: #9ca3af; }
}

/* ── Utility message classes ─────────────────────────────────────────────── */
.text-error { color: #dc2626; }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.msg-box { padding: 12px 16px; border-radius: 8px; font-size: 14px; line-height: 1.5; text-align: left; display: none; }
.msg-box.error { display: block; background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626; }
.msg-box.success { display: block; background: #f0fdf4; border: 1px solid #86efac; color: #16a34a; }
