/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-surface);
  margin-bottom: 0;
  overflow: hidden;
}

a { color: var(--color-accent); }
a:hover { text-decoration: none; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }

/* ─── Navbar ─────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--navbar-height);
  background: var(--color-navbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  box-shadow: 0 1px 3px var(--color-shadow);
}

.navbar-hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--color-navbar-text); font-size: 18px;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background .15s;
}
.navbar-hamburger:hover { background: rgba(255,255,255,.1); }
.navbar-hamburger.desktop-visible { display: flex; }

@media (max-width: 767px) {
  .navbar-hamburger {
    display: flex;
    width: 48px; height: 48px;
    font-size: 24px;
  }
  .navbar-hamburger i { font-size: 24px; }
}

.navbar-brand {
  font-size: 14px; font-weight: 600;
  color: var(--color-navbar-text);
  white-space: nowrap; flex-shrink: 0;
  letter-spacing: -.01em;
  text-decoration: none;
  padding-left: 8px;
}
.navbar-brand:hover { color: var(--color-navbar-text); text-decoration: none; }
.navbar-brand .brand-accent { color: #818CF8; }

.has-search {
  flex: 1; max-width: 440px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px;
}
.has-search-field { position: relative; flex: 1; min-width: 0; }
.has-search .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,.4); font-size: 12px; pointer-events: none;
  z-index: 1;
}

/* Select2 inside navbar */
.has-search span.select2-container--default .select2-selection--single {
  background-color: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  height: 32px;
}
.has-search .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: rgba(255,255,255,.9);
  line-height: 30px;
  padding-left: 30px;
  font-size: 13px;
}
.has-search .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: rgba(255,255,255,.4);
}
.has-search .select2-container--default .select2-selection--single .select2-selection__arrow {
  display: none;
}
span.select2.select2-container.select2-container--default {
  width: 100% !important;
}

.navbar-icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--color-navbar-text);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 14px;
  flex-shrink: 0;
  transition: background .15s;
}
.navbar-icon-btn:hover { background: rgba(255,255,255,.1); }

/* Mobile-only search toggle + back button (hidden on desktop, where the
   search field is always in the navbar) */
.navbar-search-btn { display: none; }
.navbar-search-back {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--color-navbar-text);
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 16px;
  flex-shrink: 0;
  transition: background .15s;
}
.navbar-search-back:hover { background: rgba(255,255,255,.1); }

/* ─── App Layout ─────────────────────────────────────────────── */
.page-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--navbar-height) - var(--footer-height));
  margin-top: var(--navbar-height);
}

.panel-container {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.panel-left {
  width: var(--sidebar-width);
  min-width: var(--sidebar-min-width);
  max-width: var(--sidebar-max-width);
  flex-shrink: 0;
  background: var(--color-surface-2) !important;
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .2s ease, min-width .2s ease;
}

.panel-left.collapsedMenu {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none;
}

.sidebar-header {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-filter-wrap { position: relative; }
.sidebar-filter-icon {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted); font-size: 11px; pointer-events: none;
}

#searchMenuInput,
#searchMenuInputDrawer {
  width: 100%; height: 30px;
  background: var(--color-surface-3) !important;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 10px 0 28px !important;
  font-size: 12px; font-family: var(--font-body);
  color: var(--color-text) !important; outline: none;
  transition: border-color .15s;
}
#searchMenuInput::placeholder,
#searchMenuInputDrawer::placeholder { color: var(--color-text-muted) !important; }
#searchMenuInput:focus,
#searchMenuInputDrawer:focus { border-color: var(--color-accent); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 6px; }

.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

#expandMenu {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 2px;
  transition: color .15s;
  text-decoration: none;
}
#expandMenu:hover { color: var(--color-text); text-decoration: none; }

/* ─── Floating expand tab (when sidebar is collapsed) ────────── */
.sidebar-expand-tab {
  position: fixed;
  left: 0;
  bottom: calc(var(--footer-height, 64px) + 24px);
  width: 22px;
  height: 56px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: 2px 2px 8px var(--color-shadow);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  z-index: 900;
  transition: background .15s, color .15s, width .15s;
}
.sidebar-expand-tab:hover {
  width: 26px;
  background: var(--color-surface-3);
  color: var(--color-text);
}
.sidebar-expand-tab.show { display: flex; }
@media (max-width: 767px) {
  .sidebar-expand-tab.show { display: none; }
}

/* ─── Splitter ───────────────────────────────────────────────── */
.splitter {
  flex: 0 0 var(--splitter-width);
  background: var(--color-border);
  cursor: col-resize;
  transition: background .15s, flex-basis .15s;
}
.splitter:hover, .splitter.dragging {
  background: var(--color-accent);
  flex-basis: 6px;
}

@media (max-width: 767px) {
  :root { --footer-height: 64px; }
  .panel-left, .splitter { display: none; }
  .navbar { gap: 6px; }
  .navbar-brand {
    flex: 1; min-width: 0; padding-left: 4px;
    overflow: hidden; text-overflow: ellipsis;
  }
  .navbar-icon-btn { width: 40px; height: 40px; font-size: 16px; }
  .navbar-search-btn { display: flex; }

  /* Search mode: the field takes over the whole bar, everything else hides */
  .has-search { display: none; max-width: none; margin: 0; }
  .navbar.search-open .has-search {
    display: flex; flex: 1;
    padding-right: 10px; /* theme zeroes navbar padding; keep field off the edge */
    animation: searchBarIn .18s ease-out;
  }
  .navbar.search-open .navbar-hamburger,
  .navbar.search-open .navbar-brand,
  .navbar.search-open .navbar-search-btn,
  .navbar.search-open #themeNavBtn { display: none; }
  .navbar-search-back { display: flex; }

  /* Taller field so it's an easy tap target */
  .has-search span.select2-container--default .select2-selection--single { height: 40px; }
  .has-search .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px; font-size: 15px; padding-left: 34px;
  }
  .has-search .search-icon { left: 12px; font-size: 14px; }
}

@keyframes searchBarIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Content Panel ──────────────────────────────────────────── */
.panel-right {
  flex: 1;
  background: var(--color-surface);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#mainPanel {
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden;
}

.content-header {
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .content-header { padding: 12px 14px 10px; }
}

#markdownTitle {
  font-size: 1.35rem; font-weight: 600;
  color: var(--color-text); line-height: 1.3;
  margin: 0;
}

/* Wraps the scroll container so the back-to-top button can be anchored to the
   article area (the window itself never scrolls — html/body are overflow:hidden). */
.content-scroll-wrap {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
}

#markdownContent {
  flex: 1;
  overflow-y: auto;
  /* Extra bottom padding lets the end of a long article scroll clear of the
     floating back-to-top button. */
  padding: 22px 22px 72px;
  font-size: .9375rem;
  line-height: 1.7;
  height: auto;
}

@media (max-width: 767px) {
  #markdownContent { padding: 14px 14px 64px; }
}

/* ─── Back to top ────────────────────────────────────────────── */
.back-to-top {
  position: absolute;
  right: 22px;
  bottom: 18px;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,.16);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s,
              background .15s, color .15s, box-shadow .15s;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top.show:hover {
  background: var(--color-surface-3);
  color: var(--color-accent-text);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.back-to-top:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .back-to-top { right: 14px; bottom: 14px; }
}

#nextPreviousBtns {
  padding: 12px 22px;
  border-top: 1px solid var(--color-border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  #nextPreviousBtns { padding: 10px 14px; }
}

/* ─── Pill Nav Buttons ───────────────────────────────────────── */
.buttonLink {
  display: inline-flex !important; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--color-accent-light) !important;
  color: var(--color-accent-text) !important;
  border-radius: 99px !important;
  font-size: 13px; font-weight: 500;
  text-decoration: none !important;
  transition: background .15s;
  border: none;
}
.buttonLink:hover { background: #dde6ff !important; color: var(--color-accent-text) !important; }
[data-theme="dark"] .buttonLink:hover { background: #2e27a0 !important; }

/* ─── ··· Overflow Menu ──────────────────────────────────────── */
.menu-btn-wrap { position: relative; }

.buttonDrop {
  background: var(--color-surface-3) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-sm) !important;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text-muted) !important;
  font-size: 16px; letter-spacing: 1px;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
  padding: 0;
}
.buttonDrop:hover {
  background: var(--color-surface-3) !important;
  border-color: var(--color-accent) !important;
  color: var(--color-text) !important;
}

.dots-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--color-shadow);
  min-width: 220px; z-index: 200;
  overflow: visible;
  display: none;
}
.dots-menu.open { display: block; }

.dots-menu-section { padding: 4px 0; }

.dots-menu-label {
  padding: 6px 14px 2px;
  font-size: 10px; font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}

.dots-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-size: 13px; color: var(--color-text);
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  transition: background .1s;
  text-decoration: none;
}
.dots-menu-item:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.dots-menu-item:disabled,
.dots-menu-item.disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}
.dots-menu-item .item-icon { width: 16px; color: var(--color-text-muted); font-size: 13px; text-align: center; flex-shrink: 0; }
.dots-menu-item .item-arrow { margin-left: auto; color: var(--color-text-muted); font-size: 11px; }

.dots-menu-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

.theme-toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-size: 13px; color: var(--color-text);
}
.theme-toggle-row .item-icon { width: 16px; color: var(--color-text-muted); font-size: 13px; text-align: center; flex-shrink: 0; }
.theme-toggle-row span { flex: 1; }

.toggle-switch {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--color-border);
  position: relative; cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
  border: none; padding: 0;
}
.toggle-switch.on { background: var(--color-accent); }
.toggle-switch::after {
  content: ''; position: absolute;
  left: 3px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; transition: left .2s;
}
.toggle-switch.on::after { left: 19px; }

/* Language / TOC submenu */
.dots-submenu {
  position: absolute; right: calc(100% + 4px); top: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--color-shadow);
  min-width: 180px; z-index: 201;
  overflow: hidden;
  display: none;
}
.dots-submenu.open { display: block; }
.dots-submenu-section { padding: 4px 0; max-height: 280px; overflow-y: auto; }

@media (max-width: 767px) {
  .dots-menu { max-width: calc(100vw - 16px); }
  .dots-submenu {
    position: static;
    width: 100%;
    min-width: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }
  .dots-submenu .dots-menu-item,
  .dots-submenu .tocUl a { padding-left: 36px; }
  .dots-submenu-section { max-height: 50vh; }
  .dots-menu-section .item-arrow { transition: transform .15s; }
  .dots-menu-section:has(.dots-submenu.open) .item-arrow { transform: rotate(90deg); }
}

/* TOC list */
.tocUl { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.tocUl a {
  display: block; padding: 7px 14px;
  color: var(--color-text); font-size: 13px;
  transition: background .1s; text-decoration: none;
}
.tocUl a:hover { background: var(--color-surface-3); }
.tocUl .tocUl { padding-left: 12px; }

/* ─── Sidebar Nav (MetisMenu compatible) ─────────────────────── */
.sidebar-nav ul,
.sidebar-nav .metismenu { padding: 0; margin: 0; list-style: none; }

.sidebar-nav .metismenu { display: flex; flex-direction: column; }

a.menuLink, button.menuLink {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--color-text);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .1s;
  text-decoration: none !important;
  position: relative;
}
a.menuLink:hover, button.menuLink:hover {
  background: var(--color-surface-3);
  color: var(--color-text);
  text-decoration: none;
}

a.menuLink.selectedMenuItem {
  background: var(--color-accent-light);
  color: var(--color-accent-text);
  font-weight: 500;
}
a.menuLink.selectedMenuItem::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 2px; background: var(--color-accent);
  border-radius: 2px;
}

.nav-icon { font-size: 11px; width: 14px; flex-shrink: 0; color: var(--color-text-muted); }
a.menuLink.selectedMenuItem .nav-icon { color: var(--color-accent-text); }

.nav-chevron {
  font-size: 10px; margin-left: auto; flex-shrink: 0;
  color: var(--color-text-muted); transition: transform .2s;
}
a.menuLink.has-arrow[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }

/* Suppress MetisMenu's built-in ::after arrow — we use nav-chevron instead */
.metismenu .has-arrow::after { display: none !important; }

/* MetisMenu sub-ul indentation — compounds 14px per nesting level so the
   tree indents correctly at any depth (no hardcoded level cap). */
.sidebar-nav .metismenu ul { padding-left: 14px; overflow: hidden; }
.sidebar-nav .metismenu ul a.menuLink { font-size: 12.5px; }

/* ─── Footer ─────────────────────────────────────────────────── */
.footer {
  height: var(--footer-height);
  background: var(--color-navbar) !important;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  width: 100%;
  line-height: normal;
  margin: 0;
  bottom: auto;
}
.footer a { color: rgba(255,255,255,.65); }
.footer a:hover { color: white; }

@media (max-width: 767px) {
  .footer {
    height: auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    padding: 12px 16px;
  }
}

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-backdrop-custom {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: var(--color-overlay);
  align-items: center; justify-content: center;
}
.modal-backdrop-custom.open { display: flex; }

.modal-content {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: 14px 18px;
}
.modal-header h5 { font-size: 15px; font-weight: 600; color: var(--color-text); }
.modal-footer { border-top: 1px solid var(--color-border); padding: 12px 18px; }
.modal-body { padding: 18px; }

.modal-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 16px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  margin-left: auto;
}
.modal-close-btn:hover { background: var(--color-surface-3); color: var(--color-text); }

.btn-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; font-family: var(--font-body);
}
.btn-action-primary { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.btn-action-primary:hover { background: var(--color-accent-hover); }
.btn-action-ghost { background: none; color: var(--color-text); border-color: var(--color-border); }
.btn-action-ghost:hover { background: var(--color-surface-3); }

.share-socials { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.share-social-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; border: none; transition: opacity .15s;
}
.share-social-btn:hover { opacity: .8; }
.s-fb { background: #1877F2; color: white; }
.s-li { background: #0A66C2; color: white; }
.s-tw { background: #000; color: white; }
.s-em { background: #EA4335; color: white; }

.url-copy { display: flex; }
.url-copy input {
  flex: 1; height: 34px;
  border: 1px solid var(--color-border); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 0 10px; font-size: 12px;
  background: var(--color-surface-2); color: var(--color-text);
  outline: none; font-family: var(--font-body);
}

.buttonCopy {
  background-color: var(--color-accent) !important;
  color: white !important;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--color-accent);
  font-family: var(--font-body);
}
.buttonCopy:hover { background-color: var(--color-accent-hover) !important; }

/* ─── Cookie Banner ──────────────────────────────────────────── */
.cookie-consent-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--color-navbar);
  color: var(--color-navbar-text);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  font-size: 13px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.15);
}
.cookie-consent-banner__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; width: 100%;
}
.cookie-consent-banner__copy { flex: 1; }
.cookie-consent-banner__header { font-weight: 600; margin-bottom: 2px; font-size: 12px; }
.cookie-consent-banner__description { font-size: 12px; color: rgba(255,255,255,.7); }
.cookie-consent-banner__cta {
  background: var(--color-accent); color: white !important;
  border: none; border-radius: var(--radius-sm);
  padding: 6px 14px; font-size: 12px; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
  font-family: var(--font-body); display: inline-block;
}
.cookie-consent-banner__cta:hover { background: var(--color-accent-hover); }

/* ─── Mobile Drawer ──────────────────────────────────────────── */
.drawer-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: var(--color-overlay);
  opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; display: block; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 310;
  width: min(300px, 80vw);
  background: var(--color-surface-2);
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,.15);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  height: var(--navbar-height);
  padding: 0 12px;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.drawer-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 16px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.drawer-close:hover { background: var(--color-surface-3); color: var(--color-text); }

.drawer-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.drawer-nav { flex: 1; overflow-y: auto; padding: 8px 6px; }
.drawer-nav ul,
.drawer-nav .metismenu { padding: 0; margin: 0; list-style: none; }
.drawer-nav .metismenu ul { padding-left: 14px; }
.drawer-nav .metismenu ul a.menuLink { font-size: 12.5px; }

/* ─── Markdown Content ───────────────────────────────────────── */
#markdownContent h1 { font-size: 1.3rem; font-weight: 600; margin: 0 0 16px; }
#markdownContent h2 {
  font-size: 1.1rem; font-weight: 600;
  margin: 28px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}
#markdownContent h3 { font-size: .95rem; font-weight: 600; margin: 20px 0 8px; }
#markdownContent h4 { font-size: .9rem; font-weight: 600; margin: 16px 0 6px; }
#markdownContent p { margin: 0 0 14px; }
#markdownContent ul, #markdownContent ol { margin: 0 0 14px; padding-left: 24px; }
#markdownContent li { margin-bottom: 4px; }
#markdownContent code {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 4px; padding: 1px 5px;
  font-size: 85%;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
#markdownContent pre {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 16px; overflow-x: auto;
}
#markdownContent pre code { background: none; border: none; padding: 0; font-size: 13px; }
#markdownContent blockquote {
  border-left: 3px solid var(--color-accent);
  margin: 0 0 14px; padding: 8px 14px;
  background: var(--color-accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
#markdownContent table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: .9rem; }
#markdownContent th {
  background: var(--color-surface-2); padding: 8px 12px;
  text-align: left; font-weight: 600; border: 1px solid var(--color-border);
}
#markdownContent td { padding: 8px 12px; border: 1px solid var(--color-border); }
#markdownContent tr:nth-child(even) td { background: var(--color-surface-2); }
#markdownContent img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* ─── Select2 overrides ──────────────────────────────────────── */
.select2-container--default .select2-results > .select2-results__options {
  background: var(--color-surface) !important;
  max-height: 70vh !important;
}
@media (min-width: 992px) {
  .select2-container--default .select2-results > .select2-results__options { max-height: 75vh !important; }
}
.select2-container--default .select2-results__option {
  padding: 0;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
  background: transparent !important;
  color: inherit !important;
}
.select2-search__field { background: var(--color-surface-2) !important; color: var(--color-text) !important; }
.select2-search--dropdown { background: var(--color-surface-2) !important; }
.select2-results { background: var(--color-surface-2) !important; color: var(--color-text) !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--color-text); }

/* Mobile: results become a full-bleed panel pinned under the navbar.
   Select2 positions the dropdown container with inline top/left/width, so
   these need !important to win. `body >` targets the detached dropdown
   container only, not the selection container inside the navbar. */
@media (max-width: 767px) {
  body > .select2-container--open {
    left: 0 !important;
    top: var(--navbar-height) !important;
    width: 100vw !important;
  }
  .select2-container--open .select2-dropdown {
    width: 100% !important;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: 0 8px 24px var(--color-shadow);
  }
  /* select2.min.css loads after site.css, so equal-specificity rules lose;
     bump specificity / use !important like the other Select2 overrides here */
  .select2-container--default .select2-search--dropdown { padding: 10px 12px; }
  .select2-container--default .select2-search--dropdown .select2-search__field {
    height: 44px;
    padding: 0 12px;
    font-size: 16px; /* ≥16px stops iOS Safari auto-zooming into the field */
    font-family: var(--font-body);
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-sm);
    outline: none;
  }
  .select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--color-accent) !important;
  }
  .select2-container--default .select2-results > .select2-results__options {
    /* navbar + search field row; dvh tracks the on-screen keyboard */
    max-height: calc(100vh - var(--navbar-height) - 64px) !important;
    max-height: calc(100dvh - var(--navbar-height) - 64px) !important;
  }
  .search-result { padding: 12px 16px; }
  .select2-results__option.select2-results__message,
  .select2-results__option.loading-results { padding: 12px 16px; font-size: 14px; }
}

.search-result {
  color: var(--color-text);
  text-decoration: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border) !important;
  transition: background .12s ease;
}
.search-result:last-child { border-bottom: 0 !important; }
.search-result:hover,
.select2-container--default .select2-results__option--highlighted .search-result {
  background: var(--color-surface-3) !important;
  text-decoration: none;
}
a.searchLink { color: var(--color-text); text-decoration: none; display: block; }
a.searchLink h5 { color: var(--color-accent); text-decoration: none; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
a.searchLink h6 { color: var(--color-text-muted); font-size: 12px; margin-bottom: 4px; }
a.searchLink span { display: block; color: var(--color-text-muted); line-height: 1.4; }
a.searchLink:hover { text-decoration: none; }

/* ─── Star rating in modal ───────────────────────────────────── */
.rating-container { margin-top: 8px; }

/* ─── Social icon button compat ─────────────────────────────── */
.btn-social-icon { display: inline-flex; align-items: center; justify-content: center; }

/* ─── Copy toast ─────────────────────────────────────────────── */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  transition: opacity .2s ease, transform .2s ease;
}
.copy-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.copy-toast i { color: #16a34a; font-size: 16px; }
