/* ==========================================================
   Prismatic Studios Documentation — styles
   ========================================================== */

:root {
  --bg:            #111111;
  --surface:       #181A1B;
  --surface-2:     #1E1F21;
  --surface-3:     #25272A;
  --border:        #232527;
  --border-strong: #2F3134;
  --border-input:  #2A2C2E;   /* search field outline */
  --text:          #ECECEE;
  --text-soft:     #C9CACF;
  --text-muted:    #9A9CA4;
  --text-faint:    #63666E;
  --accent:        #9050DA;
  --accent-ink:    #FFFFFF;
  --accent-text:   #BE94F5;
  --accent-soft:   rgba(144, 80, 218, 0.12);

  --topbar-h: 62px;
  --sidebar-w: 300px;
  --toc-w: 260px;         /* minimum width of "On this page" */
  --main-w: calc(var(--content-max) + 360px); /* docs column + side margins; the panel fills the rest */
  --content-max: 1120px;  /* docs column, incl. side padding */
  --content-pad: 20px;    /* side padding; grows at larger widths */

  color-scheme: dark;
}

/* ---------- Base ---------- */
html {
  /* The scrollbar only appears on pages long enough to scroll (no empty strip on short pages) */
  overflow-y: auto;
  /* Shown in the scrollbar's spot while search is open: top bar colour behind the top bar, page colour below */
  background: linear-gradient(var(--surface) 0 var(--topbar-h), var(--bg) var(--topbar-h)) fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
}
body {
  font-family: Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

::selection { background: rgba(144, 80, 218, 0.3); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
main:focus { outline: none; }

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 100;
  padding: 6px 12px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-size: 13px; transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- Shared bits ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 6px;
  color: var(--text-muted);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.badge {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid rgba(144, 80, 218, 0.45);
  border-radius: 4px;
  background: var(--accent-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  line-height: 17px;
  color: var(--accent-text);
}

/* ==========================================================
   TOP BAR
   ========================================================== */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--bg);  /* barely-there break above the sidebar */
}
.topbar-brand {
  display: flex; align-items: center; gap: 4px;
  flex: 0 0 auto; min-width: 0;
  padding-left: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 6px; }
.brand-logo { width: 33px; height: 33px; object-fit: contain; }
.brand-text {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.menu-btn { margin-left: -6px; }

.topbar-main { flex: 1 1 auto; min-width: 0; padding: 0 56px 0 16px; }
/* Same max-width + horizontal padding as .content, so the left edges match */
.topbar-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 20px;
}
.topbar-inner .search { max-width: 360px; }
.search {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 38px;
  padding: 0 7px 0 12px;
  border: 1px solid var(--border-input);
  border-radius: 7px;
  background: var(--bg);
  font-size: 14px; color: var(--text-muted);
  transition: border-color .15s, color .15s;
}
.search:hover { border-color: var(--border-strong); color: var(--text); }
.search svg { width: 16px; height: 16px; }
.search-label { flex: 1; text-align: left; }
.search kbd, .prose-docs kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--text-muted);
}

.topbar-actions {
  position: absolute; right: 12px; top: 0; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */
.sidebar {
  position: fixed; z-index: 40;
  top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--surface);
  transform: translateX(-100%);
  transition: transform .2s ease-out;
}

/* Navigation tree */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px 40px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sb-list { list-style: none; margin: 0; padding: 0; }
/* Nested levels: indented with a vertical guide line, like a tree */
.sb-list[data-depth="1"],
.sb-list[data-depth="2"],
.sb-list[data-depth="3"] {
  margin-left: 11px;
  padding-left: 6px;
  border-left: 1px solid var(--border-strong);
}
.sb-list[data-depth="1"] { margin-top: 2px; margin-bottom: 4px; }

.sb-group[data-depth="0"] + .sb-group[data-depth="0"] { margin-top: 18px; }

.sb-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
  padding: 4px 8px;
  border-radius: 5px;
  text-align: left;
  color: var(--text);
  transition: background-color .15s;
}
.sb-toggle:hover { background: var(--surface-2); }
.sb-group[data-depth="0"] > .sb-toggle { font-size: 16.5px; font-weight: 600; padding-top: 5px; padding-bottom: 5px; }
.sb-group[data-depth="1"] > .sb-toggle { font-size: 15.5px; font-weight: 600; }
.sb-group[data-depth="2"] > .sb-toggle,
.sb-group[data-depth="3"] > .sb-toggle { font-size: 15px; font-weight: 500; }

.sb-chevron {
  width: 17px; height: 17px; flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .18s ease;
}
.sb-group.is-collapsed > .sb-toggle .sb-chevron { transform: rotate(-90deg); }

/* Smooth collapse */
.sb-children {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .2s ease;
}
.sb-group.is-collapsed > .sb-children { grid-template-rows: 0fr; }
.sb-children-inner { overflow: hidden; min-height: 0; }
.sb-group.is-collapsed > .sb-children .sb-children-inner { visibility: hidden; transition: visibility 0s .2s; }

.sb-link {
  display: block;
  margin: 2px 0;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-soft);
  transition: background-color .12s, color .12s;
}
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link .badge { display: table; margin: 2px 0 1px; }

/* ---------- Beta label ---------- */
.sb-link:has(.beta-tag) { display: flex; align-items: center; gap: 8px; }
.sb-link-label { min-width: 0; }
.beta-tag {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0;
  height: 19px;
  padding: 0 7px 0 6px;
  border: 1px solid rgba(144, 80, 218, .38);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(144, 80, 218, .16), rgba(144, 80, 218, .07));
  font-family: Poppins, system-ui, sans-serif;
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent-text);
  white-space: nowrap;
  vertical-align: middle;
}
/* small pulsing dot: "still evolving" */
.beta-tag::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(144, 80, 218, .55);
  animation: beta-pulse 2.4s ease-out infinite;
}
@keyframes beta-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(144, 80, 218, .55); }
  70%  { box-shadow: 0 0 0 5px rgba(144, 80, 218, 0); }
  100% { box-shadow: 0 0 0 0 rgba(144, 80, 218, 0); }
}
.sb-link.is-active .beta-tag {
  border-color: rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .14);
  color: var(--accent-ink);
}
.sb-link.is-active .beta-tag::before { background: var(--accent-ink); animation: none; }

/* Larger version next to the page title */
.beta-tag-lg {
  height: 24px;
  margin-left: 12px;
  padding: 0 10px 0 9px;
  gap: 6px;
  font-size: 11.5px;
  position: relative; top: -4px;
  transition: border-color .15s, background-color .15s;
}
.beta-tag-lg::before { width: 6px; height: 6px; }
.beta-tag-lg:hover { border-color: rgba(144, 80, 218, .65); }
.prose-docs td .beta-tag { margin: 0; }
.sb-link.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.sb-link.is-active .badge { border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .12); color: var(--accent-ink); }

.sb-empty { padding: 4px 8px; font-size: 13px; color: var(--text-faint); }

/* Sidebar scrollbar (WebKit) */
.sidebar-nav::-webkit-scrollbar { width: 10px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid var(--surface);
}

/* Mobile overlay */
.overlay {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35;
  background: rgba(0, 0, 0, .6);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
body.sidebar-open .sidebar { transform: none; }
body.sidebar-open .overlay { opacity: 1; pointer-events: auto; }

/* ==========================================================
   PAGE
   ========================================================== */
.page {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.main-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
/* Full-width title band: the line spans sidebar → "On this page" */
.page-header { border-bottom: 1px solid var(--surface); }
.page-header-inner,
.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-left: var(--content-pad);
  padding-right: var(--content-pad);
}
.page-header-inner { padding-top: 34px; padding-bottom: 28px; }
.content {
  flex: 1;
  display: flex; flex-direction: column;
  padding-top: 8px;
  padding-bottom: 40px;
}

.title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.title-row h1 {
  margin: 0;
  font-size: 42px; font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.02em;
}
.copy-btn { flex-shrink: 0; border: 1px solid var(--border); }

/* ---------- Article typography ---------- */
.prose-docs { padding-top: 8px; color: var(--text-soft); }
.prose-docs > * + * { margin-top: 18px; }
.prose-docs .lead { margin-top: 28px; font-size: 17.5px; color: var(--text-muted); }
.prose-docs h2 {
  margin-top: 52px;
  font-size: 34px; font-weight: 600;
  line-height: 1.25; letter-spacing: -0.015em;
  color: var(--text);
}
.prose-docs h3 {
  margin-top: 36px;
  font-size: 24px; font-weight: 600;
  line-height: 1.3; letter-spacing: -0.01em;
  color: var(--text);
}
.prose-docs h2 + *, .prose-docs h3 + * { margin-top: 12px; }
.prose-docs strong { color: var(--text); font-weight: 600; }
.prose-docs a:not(.doc-card) {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(190, 148, 245, .4);
}
.prose-docs a:not(.doc-card):hover { text-decoration-color: currentColor; }
.prose-docs code {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--text);
}
.prose-docs ul:not(.plain), .prose-docs ol { padding-left: 22px; }
.prose-docs ul:not(.plain) { list-style: disc; }
.prose-docs ol { list-style: decimal; }
.prose-docs li + li { margin-top: 4px; }

/* Code block (use <pre class="code"><code>…</code></pre>) */
.prose-docs pre.code {
  position: relative;
  padding: 36px 16px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow-x: auto;
}
.prose-docs pre.code::before {
  content: "";
  position: absolute; top: 14px; left: 14px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border-strong);
  box-shadow: 12px 0 0 var(--border-strong), 24px 0 0 var(--border-strong);
}
.prose-docs pre.code code { padding: 0; border: 0; background: none; font-size: 13.5px; line-height: 1.7; color: var(--accent-text); }
.prose-docs pre.code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Callout */
.callout {
  margin-top: 24px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
  background: var(--accent-soft);
  color: var(--text);
}
.callout p { margin: 0; }
.callout p + p { margin-top: 4px; }
.callout-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--accent-text);
}
.callout-title svg { width: 18px; height: 18px; }
.callout-muted { border-left-color: var(--text-faint); background: var(--surface-2); }
.callout-muted .callout-title { color: var(--text); }

/* Tables (wrap in <div class="table-wrap">) */
.prose-docs .table-wrap { margin-top: 20px; overflow-x: auto; }
.prose-docs table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.prose-docs th {
  padding: 10px 20px 10px 0;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.prose-docs td {
  padding: 11px 20px 11px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prose-docs th:last-child, .prose-docs td:last-child { padding-right: 0; }
.prose-docs td strong { font-weight: 500; }
.prose-docs td code { white-space: nowrap; }

/* Punishment ladders: identical columns so stacked tables line up */
.prose-docs table.ladder { table-layout: fixed; min-width: 640px; }
.prose-docs table.ladder th:first-child { width: 40%; }

/* Lists */
.prose-docs li::marker { color: var(--text-faint); }
.prose-docs ol > li { padding-left: 4px; }
.prose-docs li strong { font-weight: 600; }

/* Callout variants */
.callout-note    { border-left-color: #5B8DEF; background: rgba(91, 141, 239, .10); }
.callout-note    .callout-title { color: #8FB1F5; }
.callout-warning { border-left-color: #E2B33C; background: rgba(226, 179, 60, .09); }
.callout-warning .callout-title { color: #EFC960; }
.callout-danger  { border-left-color: #E5484D; background: rgba(229, 72, 77, .10); }
.callout-danger  .callout-title { color: #F27B7F; }
.callout code { background: rgba(255, 255, 255, .06); }

/* Figures (use <figure class="doc-figure"><img …><figcaption>…</figcaption></figure>) */
.prose-docs .doc-figure { margin: 24px 0 0; }
.prose-docs .doc-figure img {
  display: block;
  width: 100%; max-width: 420px; height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  image-rendering: pixelated;
}
.prose-docs .doc-figure figcaption { margin-top: 10px; font-size: 14px; color: var(--text-muted); }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 20px;
}
@media (min-width: 640px) { .card-grid { grid-template-columns: 1fr 1fr; } }
.doc-card {
  display: flex; flex-direction: column;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.doc-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.doc-card svg { width: 20px; height: 20px; color: var(--text-muted); transition: color .15s; }
.doc-card:hover svg { color: var(--accent); }
.doc-card-title { margin-top: 16px; font-size: 17px; font-weight: 600; color: var(--text); }
.doc-card-desc { margin-top: 3px; font-size: 14.5px; line-height: 1.55; color: var(--text-muted); }

.page-footer {
  margin-top: auto;
  padding-top: 64px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Previous / Next ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.pager[hidden] { display: none; }
@media (min-width: 640px) { .pager { grid-template-columns: 1fr 1fr; gap: 16px; } }
.pager.is-single { grid-template-columns: 1fr; }

.pager-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color .18s ease, background-color .18s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.pager-next { justify-content: flex-end; text-align: right; }
.pager-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.pager-link:active { transform: scale(.985); }
.pager-link:focus-visible { outline-offset: 3px; border-radius: 8px; }

.pager-text { display: flex; flex-direction: column; min-width: 0; }
.pager-label {
  font-size: 13.5px;
  color: var(--text-muted);
  transition: color .18s ease;
}
.pager-where { color: var(--text-faint); }
.pager-title {
  margin-top: 2px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager-link:hover .pager-label { color: var(--accent-text); }

.pager-arrow {
  width: 18px; height: 18px;
  color: var(--text-muted);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), color .18s ease;
}
.pager-link:hover .pager-arrow { color: var(--accent); }
.pager-prev:hover .pager-arrow { transform: translateX(-3px); }
.pager-next:hover .pager-arrow { transform: translateX(3px); }

.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 24px;
  padding-top: 40px;
}
.page-footer strong { font-weight: 500; color: var(--text-muted); }

/* ==========================================================
   ON THIS PAGE
   ========================================================== */
.toc {
  display: none;
  flex: 0 0 var(--toc-w);
  border-left: 1px solid var(--surface);
}
.toc-inner {
  position: sticky;
  top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 20px;
}
.toc-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.toc-title { display: flex; align-items: center; gap: 8px; }
.toc-title svg { width: 17px; height: 17px; color: var(--text-muted); }
.toc ul { list-style: none; margin: 0; padding: 0; }

/* Tree guide lines, matching the left sidebar */
#toc-list,
.toc-sub {
  margin-left: 4px;
  padding-left: 6px;
  border-left: 1px solid var(--border-strong);
}
.toc-sub { margin: 1px 0 3px 10px; }

.toc li a {
  position: relative;
  display: block;
  padding: 3px 0 3px 6px;
  font-size: 13.5px; line-height: 1.5;
  color: var(--text-muted);
  transition: color .12s;
}
.toc li a:hover { color: var(--text); }
.toc li a.is-active { color: var(--accent-text); }
/* Active marker sits on top of the guide line */
.toc li a::before {
  content: "";
  position: absolute;
  left: -7.5px; top: 5px; bottom: 5px;
  width: 2px; border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}
.toc li a.is-active::before { opacity: 1; }

/* ==========================================================
   SEARCH MODAL
   ========================================================== */
/* Page stays put while search is open: the removed scrollbar's width is added back (set in search.js) */
html.search-open { overflow: hidden; padding-right: var(--scrollbar-w, 0px); }
html.search-open .topbar { right: var(--scrollbar-w, 0px); }

.search-modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 56px 16px 24px;
}
.search-modal[hidden] { display: none; }

.search-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 8, 9, .55);
  backdrop-filter: blur(10px) saturate(110%);
  -webkit-backdrop-filter: blur(10px) saturate(110%);
  opacity: 0;
  transition: opacity .16s ease;
}

.search-panel {
  position: relative;
  display: flex; flex-direction: column;
  width: min(680px, 100%);
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  opacity: 0;
  transform: translateY(-8px) scale(.985);
  transition: opacity .16s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}
.search-modal.is-open .search-backdrop { opacity: 1; }
.search-modal.is-open .search-panel { opacity: 1; transform: none; }

/* Input */
.search-field {
  position: relative;
  margin: 18px 18px 0;
  flex-shrink: 0;
}
.search-field-icon {
  position: absolute; left: 15px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
#search-input {
  width: 100%; height: 50px;
  padding: 0 48px 0 44px;
  border: 1px solid var(--border-input);
  border-radius: 9px;
  background: var(--bg);
  font: inherit; font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: rgba(144, 80, 218, .7);
  box-shadow: 0 0 0 3px rgba(144, 80, 218, .14);
}
.search-clear {
  position: absolute; right: 8px; top: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 7px;
  color: var(--accent);
  transform: translateY(-50%);
  transition: background-color .15s, color .15s;
}
.search-clear:hover { background: var(--surface-2); color: var(--accent-text); }
.search-clear[hidden] { display: none; }
.search-clear svg { width: 20px; height: 20px; }

/* Results */
.search-results {
  flex: 1; min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.search-results::-webkit-scrollbar { width: 10px; }
.search-results::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid var(--surface);
}
.search-count,
.search-empty {
  margin: 16px 2px 14px;
  font-size: 13.5px; font-weight: 500;
  color: var(--text-muted);
}
.search-count strong { color: var(--text); font-weight: 600; }
.search-empty { font-weight: 400; color: var(--text-faint); }

.sr-group {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  overflow: hidden;
}
.sr-group + .sr-group { margin-top: 14px; }

.sr-item {
  display: flex;
  color: var(--text-soft);
  transition: background-color .1s;
}
.sr-item.is-active { background: var(--surface-3); }
.sr-item.is-active .sr-page-title,
.sr-item.is-active .sr-sec-title { color: var(--accent-text); }

/* Page row */
.sr-page {
  align-items: flex-start; gap: 13px;
  padding: 15px 16px;
}
.sr-page-icon {
  width: 22px; height: 22px;
  margin-top: 1px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sr-item.is-active .sr-page-icon { color: var(--accent); }
.sr-page-text { display: flex; flex-direction: column; min-width: 0; }
.sr-page-title {
  font-size: 17px; font-weight: 500; line-height: 1.35;
  color: var(--text);
  transition: color .1s;
}
.sr-page-text .sr-snippet { margin-top: 3px; }

/* Section rows, joined by a tree line */
.sr-sections { border-top: 1px solid var(--border); }
.sr-sec {
  position: relative;
  flex-direction: column;
  padding: 11px 16px 12px 50px;
}
.sr-sec + .sr-sec {
  background-image: linear-gradient(var(--border), var(--border));
  background-repeat: no-repeat;
  background-size: calc(100% - 42px) 1px;
  background-position: 42px 0;
}
.sr-sec.is-active { background-color: var(--surface-3); }
.sr-sec::before {               /* vertical line */
  content: "";
  position: absolute; left: 26px; top: 0; bottom: 0;
  border-left: 1px solid var(--border-strong);
}
.sr-sec:last-child::before { bottom: auto; height: 23px; }
.sr-sec::after {                /* branch into the title */
  content: "";
  position: absolute; left: 26px; top: 23px;
  width: 10px;
  border-top: 1px solid var(--border-strong);
}
.sr-sec-title {
  font-size: 15.5px; font-weight: 600; line-height: 1.5;
  color: var(--text);
  transition: color .1s;
}
.sr-snippet {
  margin-top: 2px;
  font-size: 14px; line-height: 1.6;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sr-snippet mark {
  background: none;
  color: var(--text);
  font-weight: 600;
}

/* Footer hints */
.search-footer {
  display: flex; gap: 18px;
  flex-shrink: 0;
  padding: 11px 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-faint);
}
.search-footer kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  margin-right: 4px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .search-modal { padding: 10px; }
  .search-panel { max-height: calc(100dvh - 20px); }
  .search-field { margin: 12px 12px 0; }
  .search-results { padding: 4px 12px 12px; }
  .search-footer { display: none; }
}

/* Heading reached from a search result: brief highlight */
.prose-docs .is-target { animation: target-flash 1.6s ease-out; border-radius: 4px; }
@keyframes target-flash {
  0%, 25% { background: rgba(144, 80, 218, .16); box-shadow: 0 0 0 6px rgba(144, 80, 218, .16); }
  100%    { background: transparent; box-shadow: 0 0 0 6px transparent; }
}

/* ==========================================================
   TOAST
   ========================================================== */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity .18s, transform .18s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 1023px) {
  .topbar-main { padding: 0 56px 0 12px; }
  .topbar-inner { padding: 0; margin: 0 0 0 auto; }
}

@media (max-width: 640px) {
  .brand-text { display: none; }
  .search kbd { display: none; }
  .title-row h1 { font-size: 30px; }
  .prose-docs h2 { font-size: 27px; }
}

@media (min-width: 768px) {
  :root { --content-pad: 40px; }
}
@media (min-width: 1024px) {
  .topbar-inner { padding: 0 var(--content-pad); }
}

@media (min-width: 1024px) {
  .menu-btn { display: none; }
  .topbar-brand { flex: 0 0 var(--sidebar-w); }
  .topbar-main { padding: 0; }
  .sidebar { transform: none; }
  .overlay { display: none; }
  .page { padding-left: var(--sidebar-w); }
}

@media (min-width: 1280px) {
  :root {
    --content-pad: 56px;
    --content-pad-left: clamp(72px, 5vw, 96px); /* extra breathing room from the sidebar */
  }
  /* Docs column has a set max width; "On this page" stretches to fill the rest (like PaperMC) */
  .main-col { flex: 0 1 var(--main-w); }
  .toc { display: block; flex: 1 0 var(--toc-w); }
  /* Content sits toward the "On this page" panel, leaving a wide gap from the sidebar */
  .page-header-inner,
  .content,
  .topbar-inner {
    margin-left: auto;
    margin-right: 0;
    padding-left: var(--content-pad-left);
  }
  /* Top bar mirrors the same split so the search stays aligned with the content */
  .topbar-main { flex: 0 1 var(--main-w); }
  .topbar::after { content: ""; flex: 1 0 var(--toc-w); }
}

/* ---------- Motion ---------- */
.page-enter { animation: page-in .2s ease-out both; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Icons (Phosphor + Simple Icons, see assets/js/icons.js) ---------- */
svg.icon { flex-shrink: 0; }
.doc-card svg.icon { width: 24px; height: 24px; }
.topbar .icon-btn { width: 38px; height: 38px; }
.topbar-actions svg.icon { width: 21px; height: 21px; }
.topbar .menu-btn svg.icon { width: 20px; height: 20px; }
