:root {
  --bg-space: #040d1a;
  --bg-panel: #1e1e22;
  --bg-panel-2: #25252a;
  --bg-elevated: #2a2a30;
  --text: #e8e8ea;
  --text-muted: #9a9aa3;
  --accent: #e9f2a9;
  --nano-gold: #a88b5e;
  --btn: #464966;
  --btn-hover: #575b7f;
  --btn-disabled: #30313c;
  --good: #31843e;
  --caution: #a5762f;
  --danger: #bb3232;
  --border: rgba(233, 242, 169, 0.12);
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --radius: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  /* Shared layout rhythm: sticky Contents uses the same gap under the header */
  --site-header-height: 4rem;
  --page-gap: 1.5rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--site-header-height) + var(--page-gap));
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-space);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(70, 73, 102, 0.35), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(168, 139, 94, 0.12), transparent 45%);
  background-attachment: fixed;
}

.site-main {
  flex: 1 0 auto;
  width: 100%;
}

.site-main-bleed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
}

/* Lock viewport for full-bleed tools (maps / paperwork) so only inner panes scroll */
body:has(.site-main-bleed) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body:has(.site-main-bleed) .site-main-bleed {
  height: calc(100dvh - var(--site-header-height));
  max-height: calc(100dvh - var(--site-header-height));
  overflow: hidden;
}

/*
 * Map viewer: fill remaining viewport under the site header.
 * OpenLayers' .ol-viewport uses height:100% with overflow:hidden. If #map only
 * has min-height (height percentage indefinite), the viewport collapses to 0px
 * and clips the canvas + controls — blank map.
 */
.map-viewer-shell {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100dvh - var(--site-header-height));
  min-height: calc(100dvh - var(--site-header-height));
  background: #060913;
}

.map-viewer-shell .map {
  height: 100%;
  width: 100%;
  background-color: #060913;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: #fff;
}

img {
  max-width: 100%;
  height: auto;
}

/* Content images must never render smaller than 64×64 */
.site-main img,
.prose img,
.wiki-prose img,
.wiki-table img,
.panel img {
  min-width: 64px;
  min-height: 64px;
  object-fit: contain;
}

.site-header img,
.section-title img,
.news-article-mark,
.map-viewer-shell img,
.doc-editor-shell .badge-container img,
.doc-editor-shell .embedded-logo {
  min-width: 0;
  min-height: 0;
}

/*
 * OpenLayers ImageStatic uses positioned <img> elements. The global
 * `img { max-width:100%; height:auto }` rule collapses those and blanks the map.
 */
.map-viewer-shell img,
.map-viewer-shell .ol-viewport img,
.map-viewer-shell .ol-layer img {
  /* Do not set width/height — OpenLayers positions these inline. */
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: unset !important;
}

/* Map selector: readable on SolDocs dark chrome (OL defaults are light-on-light) */
.map-viewer-shell #map-selector {
  /* Right of OL zoom (+/−); leave left column for zoom + recenter */
  top: 0.5rem;
  left: 3rem;
  background: rgba(30, 30, 34, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  min-width: 13.2rem;
  max-width: min(24.2rem, calc(100vw - 1rem));
  padding: 0.35rem 0.45rem;
  z-index: 1;
}

/* Recenter under zoom controls (same slot as OL's zoom-extent) */
.map-viewer-shell .map-tool-recenter {
  position: absolute;
  top: 4.643em;
  left: 0.5em;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 1.375em;
  height: 1.375em;
  margin: 1px;
  padding: 0;
  color: #fff;
  font-size: 1.14em;
  font-weight: 700;
  line-height: 1;
  background-color: rgba(0, 60, 136, 0.5);
  border: none;
  border-radius: 2px;
  cursor: pointer;
}

.map-viewer-shell .map-tool-recenter svg {
  display: block;
  width: 0.85em;
  height: 0.85em;
  fill: currentColor;
}

.map-viewer-shell .map-tool-recenter:hover,
.map-viewer-shell .map-tool-recenter:focus {
  background-color: rgba(0, 60, 136, 0.7);
  outline: none;
}

/* Optional station orientation (map.json rotation); off by default */
.map-viewer-shell .map-tool-orient {
  position: absolute;
  top: 6.55em;
  left: 0.5em;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 1.375em;
  height: 1.375em;
  margin: 1px;
  padding: 0;
  color: #fff;
  font-size: 1.14em;
  font-weight: 700;
  line-height: 1;
  background-color: rgba(0, 60, 136, 0.5);
  border: none;
  border-radius: 2px;
  cursor: pointer;
}

.map-viewer-shell .map-tool-orient:hover,
.map-viewer-shell .map-tool-orient:focus {
  background-color: rgba(0, 60, 136, 0.7);
  outline: none;
}

.map-viewer-shell .map-tool-orient.is-active {
  background-color: rgba(0, 60, 136, 0.85);
  box-shadow: inset 0 0 0 1px rgba(233, 242, 169, 0.55);
}

/* Per-grid visibility toggles — bottom-right so map selector dropdown is clear */
.map-viewer-shell .map-grid-toggles {
  position: absolute;
  top: auto;
  left: auto;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 2;
  min-width: 10rem;
  max-width: min(18rem, calc(100vw - 1.5rem));
  padding: 0.45rem 0.55rem;
  background: rgba(30, 30, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
}

.map-viewer-shell .map-grid-toggles.hidden {
  display: none;
}

.map-viewer-shell .map-grid-toggles-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.map-viewer-shell .map-grid-toggles-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.map-viewer-shell .map-grid-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: space-between;
}

.map-viewer-shell .map-grid-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  min-width: 0;
  flex: 1;
}

.map-viewer-shell .map-grid-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-viewer-shell .map-grid-toggle input {
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.map-viewer-shell .map-grid-goto {
  flex-shrink: 0;
  margin: 0;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  line-height: 1.3;
}

.map-viewer-shell .map-grid-goto:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.map-viewer-shell .map-grid-goto:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.map-viewer-shell #map-selector .selected-label {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.map-viewer-shell #map-selector-button {
  width: 1.75rem;
  height: 1.75rem;
  line-height: 1.75rem;
  flex-shrink: 0;
}

.map-viewer-shell #map-selector-maps {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: min(60vh, 28rem);
  overflow-y: auto;
  margin-top: 0.35rem;
}

.map-viewer-shell #map-selector-maps.hidden {
  display: none;
}

.map-viewer-shell #map-selector-maps > button {
  width: 100%;
  height: auto;
  min-height: 2rem;
  line-height: 1.3;
  padding: 0.35rem 0.5rem;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  border-radius: 4px;
}

.map-viewer-shell #map-selector-maps > button:hover:not([disabled]) {
  background: var(--btn-hover);
}

.map-viewer-shell #map-selector-maps > button[disabled] {
  color: var(--text-muted);
  background: rgba(0, 30, 68, 0.55);
}

/* LOD processing wait overlay */
.map-viewer-shell.is-lod-waiting .map,
.map-viewer-shell.is-lod-waiting .ol-viewport {
  visibility: hidden;
}

.map-viewer-shell .map-lod-wait {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 19, 0.92);
  backdrop-filter: blur(4px);
}

.map-viewer-shell .map-lod-wait[hidden] {
  display: none !important;
}

.map-viewer-shell .map-lod-wait-card {
  text-align: center;
  max-width: 22rem;
  padding: 1.5rem 1.25rem;
}

.map-viewer-shell .map-lod-wait-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 3px solid rgba(233, 242, 169, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-lod-spin 0.8s linear infinite;
}

.map-viewer-shell .map-lod-wait-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.map-viewer-shell .map-lod-wait-msg {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

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

.site-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  min-height: var(--site-header-height);
  height: auto;
  padding: 0 1.5rem;
  background: rgba(30, 30, 34, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header .banner-link {
  display: flex;
  align-items: center;
  height: var(--site-header-height);
}

.site-header img.logo-mark {
  height: 40px;
  width: auto;
}

.site-header img.logo-banner {
  height: 36px;
  width: auto;
}

.site-header .site-nav-toggle {
  display: none;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
}

.site-header .site-nav-toggle:hover {
  border-color: rgba(233, 242, 169, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.site-header nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
}

.site-header nav a:hover,
.site-header nav a.active {
  color: var(--accent);
}

.site-header .site-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0 0.35rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.2;
  cursor: pointer;
}

.site-header .site-search-trigger:hover {
  color: var(--text);
  border-color: rgba(233, 242, 169, 0.28);
}

.site-header .site-search-trigger kbd {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .site-header {
    padding: 0 0.85rem;
    row-gap: 0;
  }

  .site-header .site-nav-toggle {
    display: inline-flex;
  }

  .site-header nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex-basis: 100%;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0 0.85rem;
    gap: 0.15rem;
    border-top: 1px solid var(--border);
  }

  .site-header.is-nav-open nav {
    display: flex;
  }

  .site-header nav a {
    padding: 0.55rem 0.35rem;
    font-size: 1rem;
  }

  .site-header .site-search-trigger {
    margin: 0.35rem 0 0;
    justify-content: center;
    width: 100%;
  }

  .site-header .site-search-trigger-label {
    display: none;
  }
}

/* —— Site search popup —— */
body.site-search-open {
  overflow: hidden;
}

.site-search-root[hidden] {
  display: none !important;
}

.site-search-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(15vh, 6rem) 1rem 1rem;
}

.site-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 13, 26, 0.72);
  backdrop-filter: blur(4px);
}

.site-search-modal {
  position: relative;
  width: min(36rem, 100%);
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.site-search-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.site-search-icon {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.site-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
}

.site-search-input::placeholder {
  color: var(--text-muted);
}

.site-search-kbd {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-muted);
}

.site-search-status {
  padding: 0.4rem 1rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.site-search-results {
  overflow-y: auto;
  padding: 0.5rem;
  flex: 1;
}

.site-search-empty {
  margin: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.site-search-group-title {
  padding: 0.45rem 0.55rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-search-hit {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.site-search-hit:hover,
.site-search-hit.is-active {
  background: var(--bg-elevated);
}

.site-search-hit-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.site-search-snippet {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.site-search-hit mark {
  background: rgba(233, 242, 169, 0.28);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.1em;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--page-gap);
}

.layout-docs {
  --docs-sidebar-width: 313px;
  --docs-article-max: 86.9rem;
  --docs-actions-width: 3.25rem;
  display: grid;
  /* Shared layout: fixed Contents width + article takes the rest (no crush) */
  grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr);
  column-gap: var(--page-gap);
  row-gap: var(--page-gap);
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: var(--page-gap);
  align-items: start;
}

.layout-docs:has(> .page-actions) {
  grid-template-columns:
    var(--docs-sidebar-width)
    minmax(0, 1fr)
    var(--docs-actions-width);
}

.layout-docs > .sidebar {
  grid-column: 1;
  justify-self: stretch;
  width: var(--docs-sidebar-width);
  max-width: 100%;
}

.layout-docs > .panel,
.layout-docs > article {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  /* Cap reading width, but never force the actions column off-screen */
  max-width: min(var(--docs-article-max), 100%);
}

.layout-docs > .page-actions {
  grid-column: 3;
  justify-self: stretch;
  min-width: var(--docs-actions-width);
  flex-shrink: 0;
}

.wiki-page-header {
  margin-bottom: 1.25rem;
  text-align: center;
}

/* Page action rail (download / GitHub source) */
.page-actions {
  --sidebar-sticky-top: calc(var(--site-header-height) + var(--page-gap));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.45rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: var(--sidebar-sticky-top);
  width: 100%;
  box-sizing: border-box;
}

.page-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.35rem;
  padding: 0.45rem;
  border-radius: 6px;
  background: var(--btn);
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.page-action:hover {
  background: var(--btn-hover);
  color: #fff;
}

.page-action i {
  font-size: 1.05rem;
  width: 1.15rem;
  text-align: center;
}

/* Shared / mid width: icon-only rail to save horizontal space */
.page-action-label {
  display: none;
}

/* Desktop Contents header (shared + wide) */
.sidebar .sidebar-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 1rem 1rem 0.75rem;
  border: none;
  background: var(--bg-panel);
  color: var(--nano-gold);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: default;
  pointer-events: none;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
}

.sidebar .sidebar-toggle-chevron {
  display: none;
}

/*
 * Wide: article centered with Contents in the left gutter and actions in the
 * right. Middle track may shrink below --docs-article-max so the actions
 * column keeps a real min width and never clips off-screen.
 */
@media (min-width: 110rem) {
  .layout-docs,
  .layout-docs:has(> .page-actions) {
    --docs-actions-width: 9.5rem;
    grid-template-columns:
      minmax(var(--docs-sidebar-width), 1fr)
      minmax(0, var(--docs-article-max))
      minmax(var(--docs-actions-width), 1fr);
  }

  .layout-docs > .sidebar {
    justify-self: end;
    width: var(--docs-sidebar-width);
  }

  .layout-docs > .panel,
  .layout-docs > article {
    max-width: none;
  }

  .layout-docs > .page-actions {
    justify-self: start;
    width: var(--docs-actions-width);
    min-width: var(--docs-actions-width);
  }

  /* Wide: show labels beside icons */
  .page-action {
    justify-content: flex-start;
    padding: 0.55rem 0.75rem;
  }

  .page-action-label {
    display: inline;
  }
}

/*
 * Narrow: Contents becomes a collapsible bar above the article.
 * Must override .layout-docs:has(> .page-actions) (higher specificity than
 * .layout-docs alone) or the 3-column grid stays and everything piles into
 * the 313px sidebar column — leaving a large empty void on the right.
 */
@media (max-width: 64rem) {
  .layout-docs,
  .layout-docs:has(> .page-actions) {
    grid-template-columns: 1fr;
  }

  .layout-docs > .sidebar,
  .layout-docs > .panel,
  .layout-docs > article,
  .layout-docs > .page-actions {
    grid-column: 1;
    justify-self: stretch;
    max-width: none;
    width: 100%;
    margin-inline: 0;
  }

  .layout-docs > .sidebar {
    grid-row: 1;
    width: 100%;
    position: relative;
    top: auto;
    max-height: none;
    margin-bottom: 0;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .layout-docs > .page-actions {
    grid-row: 2;
    flex-direction: row;
    position: static;
    width: 100%;
    padding: 0.55rem;
    gap: 0.55rem;
  }

  .layout-docs > .panel,
  .layout-docs > article {
    grid-row: 3;
  }

  .page-action {
    flex: 1;
    justify-content: center;
    padding: 0.6rem 0.75rem;
  }

  .page-action-label {
    display: inline;
  }

  .sidebar .sidebar-toggle {
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    position: static;
  }

  .sidebar .sidebar-toggle:hover {
    color: var(--accent);
  }

  .sidebar .sidebar-toggle-chevron {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.15s ease;
  }

  .sidebar.sidebar-open .sidebar-toggle-chevron {
    transform: rotate(180deg);
  }

  .sidebar:not(.sidebar-open) .nav-tree {
    display: none;
  }

  .sidebar.sidebar-open {
    max-height: min(60dvh, 28rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar .nav-tree {
    padding: 0 0.75rem 0.75rem;
  }

  .sidebar .nav-link,
  .sidebar .nav-group-label {
    padding: 0.28rem 0.45rem;
    font-size: 0.88rem;
  }

  .sidebar .nav-children {
    padding-left: 0.5rem;
  }
}


.sidebar {
  --sidebar-sticky-top: calc(var(--site-header-height) + var(--page-gap));
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  height: fit-content;
  position: sticky;
  /* Same offset as layout-docs padding under the header — stays constant while scrolling */
  top: var(--sidebar-sticky-top);
  max-height: calc(100dvh - var(--site-header-height) - (2 * var(--page-gap)));
  margin-bottom: var(--page-gap);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar .nav-tree,
.sidebar .nav-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar .nav-tree {
  padding: 0 1rem 1rem;
}

.sidebar .nav-children {
  /* Vertical guide sits under the parent chevron center (toggle is 1.25rem wide) */
  margin-left: calc(1.25rem / 2 - 0.5px);
  padding-left: 0.65rem;
  border-left: 1px solid var(--border);
}

/* Root branches: chevron is nudged into the margin (−0.4rem) */
.sidebar .nav-tree > .nav-item > .nav-children {
  margin-left: calc(-0.4rem + 1.25rem / 2 - 0.5px);
}

.sidebar .nav-item {
  margin: 0;
}

.sidebar .nav-row {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Root rows: nudge chevron/spacer into the tree’s left padding */
.sidebar .nav-tree > .nav-item > .nav-row > .nav-toggle,
.sidebar .nav-tree > .nav-item > .nav-row > .nav-toggle-spacer {
  margin-left: -0.4rem;
}

.sidebar .nav-toggle,
.sidebar .nav-toggle-spacer {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.4rem;
}

.sidebar .nav-toggle {
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.sidebar .nav-toggle:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.sidebar .nav-branch.expanded > .nav-row > .nav-toggle {
  transform: rotate(90deg);
}

.sidebar .nav-branch.collapsed > .nav-children {
  display: none;
}

.sidebar .nav-active-dot {
  display: none;
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  border-radius: 50%;
  background: #4da3ff;
  box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.25);
}

/* Collapsed parent of the current page (page is not this header) */
.sidebar .nav-branch.collapsed[data-nav-active-child="true"] > .nav-row .nav-active-dot {
  display: block;
}

.sidebar .nav-link,
.sidebar .nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem 0.35rem 0.25rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.3;
}

.sidebar .nav-group-label {
  font-weight: 600;
  color: var(--text);
  cursor: default;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: var(--bg-elevated);
  color: var(--accent);
}

.sidebar .nav-icon {
  width: 1.1em;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.9em;
  opacity: 0.95;
}

.sidebar a {
  color: inherit;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.hero {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
}

.hero img.hero-logo {
  width: min(220px, 55vw);
  margin-bottom: 1rem;
}

.hero h1 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0.25rem 0 0.75rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.hero p {
  color: var(--text-muted);
  max-width: 36rem;
  margin: 0 auto 1.25rem;
}

.btn-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  border-radius: 6px;
  background: var(--btn);
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
  color: #fff;
}

.btn-accent {
  background: transparent;
  border-color: rgba(233, 242, 169, 0.35);
  color: var(--accent);
}

.btn-accent:hover {
  border-color: var(--accent);
  background: rgba(233, 242, 169, 0.08);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.status-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.status-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.status-card .name {
  font-weight: 700;
  color: var(--accent);
  line-height: 1.3;
}

.status-pill {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  margin: 0;
}

.status-pill.online {
  background: rgba(49, 132, 62, 0.25);
  color: #7dcf8a;
}

.status-pill.offline {
  background: rgba(187, 50, 50, 0.25);
  color: #ef8a8a;
}

.status-connect {
  margin: 0.75rem 0 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}

.section-title img {
  height: 48px;
  width: auto;
}

.section-title h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.35rem;
}

/* Sol's News Network — in-game articles (site theme, not Discord embeds) */
.news-article {
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
}

.news-article-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.news-article-mark {
  flex-shrink: 0;
  border-radius: 6px;
}

.news-article-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nano-gold);
  margin-bottom: 0.2rem;
}

.news-article-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent);
  line-height: 1.3;
}

.news-article-body {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
}

.news-article-meta {
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}


/* UFS changelog entries */
.cl-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cl-tabs a {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.cl-tabs a.active {
  background: var(--btn);
  color: var(--accent);
}

.cl-entry {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 0;
}

.cl-entry:last-child {
  border-bottom: none;
}

.cl-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.cl-meta a {
  color: var(--nano-gold);
}

.cl-change {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: start;
  gap: 0.5rem;
  margin: 0.2rem 0;
  font-size: 0.95rem;
}

.cl-change > span:not(.cl-type) {
  min-width: 0;
}

.cl-type {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  height: fit-content;
  margin-top: 0.15rem;
}

.cl-type.Fix { background: rgba(187, 50, 50, 0.25); color: #ef8a8a; }
.cl-type.Add, .cl-type.Feature { background: rgba(49, 132, 62, 0.25); color: #7dcf8a; }
.cl-type.Tweak, .cl-type.Remove { background: rgba(165, 118, 47, 0.25); color: #e0b56a; }

.prose h1, .prose h2, .prose h3,
.prose h4, .wiki-prose h2, .wiki-prose h3, .wiki-prose h4 {
  font-family: var(--font-display);
  color: var(--accent);
  scroll-margin-top: calc(var(--site-header-height) + var(--page-gap));
}

.prose hr,
.wiki-prose hr {
  border: 0;
  border-top: 1px solid var(--border, #3a3a45);
  margin: 1.25rem 0;
}

.prose code {
  background: var(--bg-elevated);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.prose pre {
  background: #121218;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid var(--border);
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose blockquote {
  border-left: 3px solid var(--nano-gold);
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Wiki feature set (Starlight-compatible)
   ═══════════════════════════════════════════════════════════════════════════ */

.wiki-prose {
  max-width: none;
}

/* 1 — Contents block */
.wiki-toc {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1.5rem;
  max-width: 36rem;
}

.wiki-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 0.45rem;
  margin-bottom: 0.6rem;
}

.wiki-toc-label {
  font-weight: 600;
  color: var(--text);
}

.wiki-toc-hide {
  background: none;
  border: none;
  color: #5eb8ff;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  text-decoration: underline;
}

.wiki-toc-hide:hover {
  color: #9dd4ff;
}

.wiki-toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wiki-toc-list a {
  color: #5eb8ff;
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  font-size: 0.92rem;
}

.wiki-toc-list a:hover {
  text-decoration: underline;
}

.wiki-toc-num {
  color: var(--text-muted);
  margin-right: 0.35rem;
}

.wiki-toc-l2 { margin-left: 0; }
.wiki-toc-l3 { margin-left: 1.25rem; }
.wiki-toc-l4 { margin-left: 2.25rem; }

.wiki-toc-hidden .wiki-toc-list {
  display: none;
}

/* 3 — Collapsible sections */
.wiki-collapse {
  margin: 1.25rem 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
}

.wiki-collapse-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #0a0a0c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.55rem 1rem;
  position: relative;
}

.wiki-collapse-title {
  font-weight: 600;
  color: var(--text);
}

.wiki-collapse-toggle {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: #5eb8ff;
  cursor: pointer;
  font-size: 0.88rem;
  text-decoration: none;
}

.wiki-collapse-toggle:hover {
  text-decoration: underline;
}

.wiki-collapse-toggle::before {
  content: "[";
}

.wiki-collapse-toggle::after {
  content: "]";
}

.wiki-collapse-body {
  padding: 0.75rem;
  background: var(--bg-panel);
}

.wiki-collapse-closed .wiki-collapse-body {
  display: none;
}

/* 4 & 5 — Fancy warning / notice blocks */
.wiki-notice {
  margin: 1.25rem 0;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid;
}

.wiki-notice-title {
  text-align: center;
  font-weight: 700;
  padding: 0.65rem 1rem;
  color: #fff;
}

.wiki-notice-body {
  padding: 0.85rem 1.1rem;
  text-align: center;
  color: var(--text);
  background: var(--bg-panel);
}

.wiki-notice-body p {
  margin: 0.35rem 0;
}

.wiki-notice-plain {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-panel-2);
  padding: 0.85rem 1.1rem;
  border-radius: 8px;
}

.wiki-notice-plain p {
  margin: 0;
}

.wiki-notice-orange { border-color: #e8940a; }
.wiki-notice-orange .wiki-notice-title { background: #e8940a; }

.wiki-notice-ooc { border-color: #e8940a; }
.wiki-notice-ooc .wiki-notice-title { background: #e8940a; }

.wiki-notice-red { border-color: #c0392b; }
.wiki-notice-red .wiki-notice-title { background: #c0392b; }

.wiki-notice-green { border-color: #31843e; }
.wiki-notice-green .wiki-notice-title { background: #31843e; }

.wiki-notice-blue { border-color: #3a6ea5; }
.wiki-notice-blue .wiki-notice-title { background: #3a6ea5; }

.wiki-notice-purple { border-color: #7b4397; }
.wiki-notice-purple .wiki-notice-title { background: #7b4397; }

.wiki-notice-neutral { border-color: rgba(255, 255, 255, 0.2); }
.wiki-notice-neutral .wiki-notice-title { background: #3a3a42; }

.wiki-notice-amber { border-color: #d4a017; }
.wiki-notice-amber .wiki-notice-title { background: #d4a017; color: #1a1a1a; }

.wiki-notice-teal { border-color: #1a8a7a; }
.wiki-notice-teal .wiki-notice-title { background: #1a8a7a; }

.wiki-notice-maroon { border-color: #8b2252; }
.wiki-notice-maroon .wiki-notice-title { background: #8b2252; }

.wiki-notice-lime { border-color: #7cfc00; }
.wiki-notice-lime .wiki-notice-title { background: #7cfc00; color: #1a1a1a; }

.wiki-notice-yellow { border-color: #e6c619; }
.wiki-notice-yellow .wiki-notice-title { background: #e6c619; color: #1a1a1a; }

.wiki-notice-pink { border-color: #d65db1; }
.wiki-notice-pink .wiki-notice-title { background: #d65db1; }

.wiki-notice-brown { border-color: #8b6914; }
.wiki-notice-brown .wiki-notice-title { background: #8b6914; }

/* 7 — Callout / quote blocks (colored left border) */
.wiki-callout {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--bg-panel-2);
  border-left: 4px solid;
  border-radius: 0 6px 6px 0;
}

.wiki-callout-body p:first-child {
  margin-top: 0;
}

.wiki-callout-body p:last-child {
  margin-bottom: 0;
}

.wiki-callout-green { border-left-color: #3d9a4a; }
.wiki-callout-orange { border-left-color: #d4842a; }
.wiki-callout-red { border-left-color: #c0392b; }
.wiki-callout-blue { border-left-color: #4a7eb8; }
.wiki-callout-purple { border-left-color: #9b59b6; }
.wiki-callout-neutral { border-left-color: #666; }
.wiki-callout-amber { border-left-color: #d4a017; }
.wiki-callout-teal { border-left-color: #1a8a7a; }
.wiki-callout-maroon { border-left-color: #8b2252; }
.wiki-callout-lime { border-left-color: #7cfc00; }
.wiki-callout-yellow { border-left-color: #e6c619; }
.wiki-callout-pink { border-left-color: #d65db1; }
.wiki-callout-brown { border-left-color: #8b6914; }
.wiki-callout-ooc { border-left-color: #e8940a; }

/* 2 & 6 — Fancy tables + colored cells */
.wiki-table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.wiki-prose .wiki-table,
.wiki-prose table.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-panel-2);
  table-layout: auto;
}

.wiki-table th,
.wiki-table td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.65rem 0.75rem;
  vertical-align: middle;
  text-align: left;
}

.wiki-table th {
  background: #1a1a22;
  color: #5eb8ff;
  font-weight: 600;
  text-align: center;
}

.wiki-table td img {
  display: block;
  margin: 0 auto 0.35rem;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  image-rendering: pixelated;
}

/* Full-body job / character portraits — same size everywhere (roles page = 96×96) */
.wiki-char-sprite,
.wiki-table-roles td img,
.wiki-table-role-header td:first-child img {
  width: 96px !important;
  height: 96px !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Roles / job list tables: uniform rows, centered cells, full-size sprites */
.wiki-table.wiki-table-roles td {
  height: 8.5rem;
  vertical-align: middle;
}

.wiki-table.wiki-table-roles td:first-child {
  text-align: center;
  width: 8rem;
  min-width: 8rem;
}

.wiki-table.wiki-table-roles td:nth-child(3),
.wiki-table.wiki-table-roles td:nth-child(4) {
  text-align: center;
  white-space: nowrap;
}

.wiki-table.wiki-table-roles td:last-child {
  min-width: 12rem;
}

.wiki-table-role-header td:first-child {
  text-align: center;
  vertical-align: middle;
}

.wiki-table td:has(> div),
.wiki-table td:has(> a img),
.wiki-table td:has(> img) {
  text-align: center;
}

.wiki-table .wiki-table-job {
  text-align: center;
  min-width: 7.5rem;
  width: 7.5rem;
}

.wiki-table .wiki-table-job a {
  display: block;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Colored cell presets (crime guide, etc.) */
.wiki-table .cell-purple,
.wiki-table td.cell-purple,
.wiki-table th.cell-purple { background: #4a2d6e !important; color: #e8e0f0; }

.wiki-table .cell-teal,
.wiki-table td.cell-teal,
.wiki-table th.cell-teal { background: #1a5c52 !important; color: #d0f0ea; }

.wiki-table .cell-green,
.wiki-table td.cell-green,
.wiki-table th.cell-green { background: #2d5a32 !important; color: #d8eeda; }

.wiki-table .cell-brown,
.wiki-table td.cell-brown,
.wiki-table th.cell-brown { background: #5a4a28 !important; color: #f0e8d0; }

.wiki-table .cell-red,
.wiki-table td.cell-red,
.wiki-table th.cell-red { background: #6b2020 !important; color: #f5d0d0; }

.wiki-table .cell-maroon,
.wiki-table td.cell-maroon,
.wiki-table th.cell-maroon { background: #4a1528 !important; color: #f0d0dc; }

.wiki-table .cell-blue,
.wiki-table td.cell-blue,
.wiki-table th.cell-blue { background: #1e3a5f !important; color: #d0e4f8; }

.wiki-table .cell-orange,
.wiki-table td.cell-orange,
.wiki-table th.cell-orange { background: #6b4518 !important; color: #f8ecd8; }

.wiki-table .cell-yellow,
.wiki-table td.cell-yellow,
.wiki-table th.cell-yellow { background: #5a5220 !important; color: #f8f4d0; }

.wiki-table .cell-neutral,
.wiki-table td.cell-neutral,
.wiki-table th.cell-neutral { background: #2a2a30 !important; }

.wiki-table .wiki-cell-colored {
  /* preserve inline background from imports */
}

.wiki-prose h2 {
  border-bottom: 1px solid rgba(168, 139, 94, 0.35);
  padding-bottom: 0.35rem;
  margin-top: 2rem;
}

/* SOP / section heading job icons — uniform size (avoids Warden.png portrait vs WARDEN.png icon) */
.wiki-prose :is(h2, h3, h4) img {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.wiki-prose h3 {
  margin-top: 1.5rem;
}

.muted {
  color: var(--text-muted);
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
  flex-shrink: 0;
}
