/*
 * SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>
 * SPDX-License-Identifier: MIT
 */

/* A reference manual on warm paper: serif prose, a mono for anything that
 * is bytes, and the terminal itself as the one dark object on the page. */

:root {
  --paper: #f5f1e8;
  --paper-2: #ece6d8;
  --ink: #1e222b;
  --muted: #676a72;
  --rule: #d6cdb9;
  --accent: #b5442a;
  --link: #24577f;
  --ok: #2c7a4b;
  --ok-wash: #dcecdf;
  --bad: #b1261d;
  --bad-wash: #f4d9d4;
  --no: #8b1a1a;
  --warn: #93600a;
  --warn-wash: #f3e5c4;
  --term-bg: #15181e;
  --term-fg: #e8e2d4;
  --term-dim: #545a66;
  --term-cursor: #f0a64a;

  --serif: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "Adwaita Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #181a1f;
    --paper-2: #21242b;
    --ink: #e4dfd3;
    --muted: #9a9ca3;
    --rule: #353943;
    --accent: #ec8a64;
    --link: #8ec1ea;
    --ok: #7cc996;
    --ok-wash: #1d3326;
    --bad: #f08a80;
    --bad-wash: #3d2220;
    --no: #c94a40;
    --warn: #e6b45c;
    --warn-wash: #3a2f19;
    --term-bg: #0d0f12;
    --term-fg: #e8e2d4;
    --term-dim: #4a505c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #181a1f;
  --paper-2: #21242b;
  --ink: #e4dfd3;
  --muted: #9a9ca3;
  --rule: #353943;
  --accent: #ec8a64;
  --link: #8ec1ea;
  --ok: #7cc996;
  --ok-wash: #1d3326;
  --bad: #f08a80;
  --bad-wash: #3d2220;
  --no: #c94a40;
  --warn: #e6b45c;
  --warn-wash: #3a2f19;
  --term-bg: #0d0f12;
  --term-fg: #e8e2d4;
  --term-dim: #4a505c;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--serif);
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

code,
kbd,
pre {
  font-family: var(--mono);
  font-size: 0.86em;
}

:not(pre) > code {
  background: var(--paper-2);
  border-radius: 3px;
  padding: 0.05em 0.3em;
}

/* ---- frame ---------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font: 600 1.05rem/1 var(--mono);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.wordmark .esc {
  color: var(--accent);
  margin-right: 0.35em;
}

.masthead-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--muted);
  font: 0.8rem/1 var(--mono);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.search-trigger:hover,
.search-trigger:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
  outline: none;
}

.search-trigger-label {
  padding-right: 0.25rem;
}

.search-trigger kbd {
  font-size: 0.72rem;
  padding: 0.12rem 0.32rem;
  border-radius: 3px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--muted);
}

.engine {
  font: 0.8rem/1 var(--mono);
  color: var(--muted);
}

@media (max-width: 600px) {
  .search-trigger-label,
  .masthead .engine {
    display: none;
  }
}

/* Three columns under the masthead, each scrolling by itself: the index of
   pages, the page, and the page's contents. On narrower screens the
   contents go first, and then the index joins the page in one column that
   scrolls as a whole. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.masthead {
  flex: none;
}

.frame {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr) 14rem;
  width: 100%;
  max-width: 96rem;
  margin: 0 auto;
}

.index,
.page,
.toc {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.index {
  padding: 1.5rem 1.25rem 3rem 1.5rem;
  border-right: 1px solid var(--rule);
  font-size: 0.92rem;
}

.page {
  display: flex;
  flex-direction: column;
}

.page main {
  flex: 1;
}

.toc {
  padding: 1.5rem 1.25rem 3rem;
  border-left: 1px solid var(--rule);
  font-size: 0.84rem;
}

.toc h2 {
  font: 600 0.72rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.toc.empty > * {
  display: none;
}

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

.toc li.level-1 {
  margin-top: 0.6rem;
}

.toc li.level-1:first-child {
  margin-top: 0;
}

.toc li.level-1 a {
  font-weight: 600;
}

.toc li.level-2 a {
  padding-left: 0.9rem;
}

.toc a {
  display: block;
  position: relative;
  padding: 0.12rem 0.4rem;
  margin-left: -0.4rem;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.35;
}

.toc a:hover {
  background: var(--paper-2);
}

.toc a.current {
  background: var(--paper-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* A case's verdict, as a dot in front of its entry. */
.toc a[data-verdict]::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.62em;
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 50%;
  background: var(--muted);
}

.toc a[data-verdict="pass"]::before,
.toc a[data-verdict="fixed"]::before {
  background: var(--ok);
}

.toc a[data-verdict="fail"]::before {
  background: var(--bad);
}

.toc a[data-verdict="differs"]::before {
  background: var(--warn);
}

.index section + section {
  margin-top: 1.4rem;
}

.index h2 {
  font: 600 0.72rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.4rem;
}

.index h2 a {
  color: var(--muted);
  text-decoration: none;
}

.index ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.index li a {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0.4rem;
  padding: 0.15rem 0.4rem;
  margin-left: -0.4rem;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.35;
}

.index li a:hover {
  background: var(--paper-2);
}

.index li a.current {
  background: var(--ink);
  color: var(--paper);
}

.index .mnemonic {
  font: 600 0.82rem/1.35 var(--mono);
  white-space: nowrap;
}

/* A DEC private mode's mnemonic, in front of its name when the mode is
   listed by number. */
.dec {
  font-family: var(--mono);
  font-size: 0.92em;
  margin-right: 0.4em;
}

.index .name {
  color: inherit;
  opacity: 0.8;
  font-size: 0.85rem;
}

main {
  padding: 2rem 2.5rem 4rem;
  min-width: 0;
}

@media (max-width: 1100px) {
  .frame {
    grid-template-columns: 17rem minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

.colophon {
  border-top: 1px solid var(--rule);
  padding: 1.2rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 820px) {
  body {
    display: block;
    height: auto;
    overflow: visible;
  }

  .frame {
    grid-template-columns: minmax(0, 1fr);
  }

  .index,
  .page {
    overflow: visible;
  }

  .index {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--rule);
    padding: 1.25rem 1rem 2rem;
  }

  main {
    padding: 1.25rem 1rem 2.5rem;
  }

  .masthead {
    padding: 0.8rem 1rem;
  }
}

/* ---- prose ---------------------------------------------------------- */

.prose {
  max-width: 46rem;
}

.prose h1 {
  font-size: 2rem;
  line-height: 1.15;
  margin: 0.2rem 0 0.6rem;
  letter-spacing: -0.01em;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin: 0.6rem 0 0.75rem;
  font: 0.82rem/1.3 var(--mono);
  color: var(--muted);
}

.page-actions button,
.page-actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.page-actions button:hover,
.page-actions a:hover {
  color: var(--ink);
}

.page-actions .copy-markdown .icon-check {
  display: none;
}

.page-actions .copy-markdown[data-state="copied"] {
  color: var(--ok);
}

.page-actions .copy-markdown[data-state="copied"] .icon-copy {
  display: none;
}

.page-actions .copy-markdown[data-state="copied"] .icon-check {
  display: inline;
}

.page-actions .copy-markdown[data-state="error"] {
  color: var(--bad);
}

.page-actions .sep {
  color: var(--rule);
  user-select: none;
}

.prose > hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0 0 1.25rem;
}

.prose h2 {
  font-size: 1.3rem;
  margin: 2.4rem 0 0.6rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--rule);
}

.prose h3 {
  font-size: 1.05rem;
  margin: 2rem 0 0.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.6rem 0.35rem 0;
  border-bottom: 1px solid var(--rule);
}

.prose pre {
  background: var(--paper-2);
  padding: 0.8rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

.kicker {
  margin: 0;
  font: 0.75rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kicker a {
  color: var(--muted);
  text-decoration: none;
}

.sequence h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.8rem;
}

.sequence h1 .mnemonic {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.9em;
}

.sequence h1 .name {
  font-weight: 400;
}

.sequence h1 .or {
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
}

/* Another sequence the page covers, under its own name. */
.also-name {
  margin: 0 0 0.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}

.also-name .mnemonic {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
}

.also-name .name {
  color: var(--muted);
}

.lede {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 1.2rem;
  font-size: 0.92rem;
  margin: 0 0 1.5rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.86rem;
}

/* ---- syntax diagram ------------------------------------------------- */

.syntax {
  margin: 0 0 1.25rem;
  overflow-x: auto;
}

.wire {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
  width: max-content;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.2rem;
  border: 1.5px solid var(--ink);
  margin-left: -1.5px;
  font-family: var(--mono);
}

.tile:first-child {
  border-radius: 6px 0 0 6px;
  margin-left: 0;
}

.tile:last-child {
  border-radius: 0 6px 6px 0;
}

.tile .label {
  padding: 0.45rem 0.7rem 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.tile .hex {
  align-self: stretch;
  text-align: center;
  padding: 0.2rem 0.5rem 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  min-height: 1.5rem;
}

.tile.intro .label,
.tile.control .label {
  color: var(--accent);
}

.tile.param {
  border-style: dashed;
  background: var(--paper-2);
}

.tile.param .label {
  font-style: italic;
  font-weight: 400;
}

/* ---- tables of sequences -------------------------------------------- */

.catalog section h2 {
  border-top: 0;
  margin-top: 2rem;
}

.catalog section > p {
  color: var(--muted);
  margin-top: 0;
}

.sequences th {
  width: 6rem;
  font-family: var(--mono);
}

.sequences th a {
  font-weight: 600;
  text-decoration: none;
}

.sequences .syntax-inline code {
  background: none;
  padding: 0;
  white-space: nowrap;
}

.sequences .tally {
  text-align: right;
  white-space: nowrap;
  color: var(--muted);
}

@media (max-width: 600px) {
  .sequences .syntax-inline {
    display: none;
  }
}

/* ---- the Support page ---------------------------------------------- */

/* Fifteen terminals may still not fit, so each table scrolls sideways on
   its own, with the sequence column held in place. */
/* The tables take the whole width the page column has; the prose keeps its
   reading width. */
.prose:has(.support-matrix) {
  max-width: none;
}

.prose:has(.support-matrix) p,
.prose:has(.support-matrix) .page-actions,
.prose:has(.support-matrix) > hr {
  max-width: 46rem;
}

.support-matrix,
.support-terminals {
  overflow-x: auto;
  margin: 1rem 0;
}

.support-matrix table,
.support-terminals table {
  width: auto;
  margin: 0;
  font-size: 0.85rem;
}

.support-matrix th,
.support-matrix td,
.support-terminals th,
.support-terminals td {
  white-space: nowrap;
  padding: 0.3rem 0.5rem;
}

/* A cell's plain text is always No: Yes and Partly are marked up, and a
   terminal not examined leaves the cell empty. */
.support-matrix td {
  color: var(--no);
}

.support-matrix th {
  color: var(--ink);
  vertical-align: bottom;
}

.support-matrix th:first-child,
.support-matrix td:first-child {
  position: sticky;
  left: 0;
  background: var(--paper);
  font-family: var(--mono);
}

.support-matrix strong {
  color: var(--ok);
}

.support-matrix em {
  color: var(--warn);
  font-style: normal;
}

/* ---- verdicts ------------------------------------------------------- */

.pill {
  display: inline-block;
  font: 600 0.7rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3em 0.55em;
  border-radius: 999px;
  white-space: nowrap;
}

.pill.pass,
.pill.fixed {
  color: var(--ok);
  background: var(--ok-wash);
}

.pill.fail {
  color: var(--bad);
  background: var(--bad-wash);
}

.pill.differs {
  color: var(--warn);
  background: var(--warn-wash);
}

/* ---- a diagram ------------------------------------------------------ */

/* Mermaid source until diagram.js draws it, then the drawing, scaled down
   to fit a narrow screen. */
.diagram {
  margin: 1rem 0 1.5rem;
  padding: 0;
  border: 0;
  overflow-x: auto;
}

.diagram.drawn {
  text-align: center;
}

.diagram.drawn svg {
  max-width: 100%;
  height: auto;
}

/* ---- a validation case ---------------------------------------------- */

.vt-case > pre {
  margin: 0.4rem 0;
}

.load-error {
  color: var(--bad);
  font-size: 0.9rem;
}

.case {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ok);
  border-radius: 6px;
  margin: 0.6rem 0 1.5rem;
  background: color-mix(in srgb, var(--paper) 70%, var(--paper-2));
}

.case.fail {
  border-left-color: var(--bad);
}

.case.differs {
  border-left-color: var(--warn);
}

.case-body {
  display: grid;
  /* The input takes what the screens leave, but never less than enough to
     read a step; the screens give way and wrap rather than push it over. */
  grid-template-columns: minmax(14rem, 1fr) minmax(0, max-content);
  gap: 1rem 1.5rem;
  padding: 1rem 1rem 0.6rem;
}

@media (max-width: 760px) {
  .case-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

.case-body > * {
  min-width: 0;
}

.case h4 {
  margin: 0 0 0.4rem;
  font: 600 0.7rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  grid-template-areas: "n head" "n bytes";
  column-gap: 0.6rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.5;
}

.step::before {
  content: counter(step);
  grid-area: n;
  color: var(--muted);
  text-align: right;
}

.step.done {
  opacity: 1;
}

.step.current {
  background: var(--paper-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* The source and its note share a line while they fit, and the note drops
   below a source too long to leave room beside it. */
.step .head {
  grid-area: head;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6rem;
  min-width: 0;
}

.step .src {
  min-width: 0;
  background: none;
  padding: 0;
  font-size: 1em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.step .note {
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95em;
}

.step .bytes {
  grid-area: bytes;
  color: var(--muted);
  font-size: 0.85em;
  overflow-wrap: anywhere;
}

.screens {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.screen {
  margin: 0;
}

.screen figcaption {
  font: 600 0.7rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  display: flex;
  gap: 0.5rem;
}

/* Room for the longest of "before any input", "after step N" and "after all
 * input", so that stepping does not resize the figure and shift the
 * expected screen beside it. */
.screen .when {
  display: inline-block;
  min-width: 16ch;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.grid {
  --cell-w: 1.5ch;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-w));
  grid-auto-rows: 1.45em;
  width: max-content;
  padding: 0.5rem 0.6rem;
  background: var(--term-bg);
  color: var(--term-fg);
  font: 1.05rem/1.45 var(--mono);
  border-radius: 5px;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.15);
}

.grid.expected {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--rule);
}

.cell {
  text-align: center;
  white-space: pre;
  position: relative;
  /* Faint column guides, so blank cells can still be counted. */
  background-image: linear-gradient(to right, transparent calc(100% - 1px), rgb(127 127 127 / 0.12) 0);
}

.grid.expected .cell.blank::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px;
  border-radius: 50%;
  background: var(--rule);
}

.cell.bold {
  font-weight: 700;
}

.cell.italic {
  font-style: italic;
}

.cell.faint {
  opacity: 0.55;
}

.cell.invisible {
  color: transparent !important;
}

.cell.cursor {
  box-shadow: inset 0 0 0 2px var(--term-cursor);
}

.grid.expected .cell.cursor {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* A wrap is pending: the next character goes on the next line, so the
 * cursor is drawn leaning off the right edge of its cell. */
.cell.cursor.pending-wrap {
  box-shadow: inset -3px 0 0 var(--term-cursor);
}

.cell.miss {
  background-color: color-mix(in srgb, var(--bad) 45%, transparent);
  outline: 1px solid var(--bad);
  outline-offset: -1px;
}

.sent {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.8rem;
  margin: 0;
  font: 0.8rem/1.4 var(--mono);
}

.sent dt {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  padding-top: 0.15rem;
}

.sent dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
  overflow-wrap: anywhere;
}

.sent .bytes,
.sent .none {
  color: var(--muted);
}

.case-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.6rem 1rem 0.8rem;
  border-top: 1px dashed var(--rule);
}

.verdict {
  font: 600 0.75rem/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ok);
}

.case.fail .verdict {
  color: var(--bad);
}

.case.differs .verdict {
  color: var(--warn);
}

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  font: 0.78rem/1.3 var(--mono);
}

.checks li::before {
  content: "✓ ";
  color: var(--ok);
}

.checks li.bad::before {
  content: "✗ ";
  color: var(--bad);
}

.checks .what {
  color: var(--muted);
  margin-right: 0.35em;
}

.checks .got {
  color: var(--bad);
  margin-left: 0.5em;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}

.stepper button {
  font: 0.8rem/1 var(--mono);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  min-width: 2rem;
  height: 1.9rem;
  cursor: pointer;
}

.stepper button:hover {
  border-color: var(--ink);
}

.stepper input[type="range"] {
  width: 7rem;
  accent-color: var(--accent);
}

.stepper .position {
  font: 0.78rem/1 var(--mono);
  color: var(--muted);
  min-width: 3.2rem;
  text-align: right;
}

/* ---- search overlay (⌘K) -------------------------------------------- */

.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgb(15 18 23 / 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 1rem 2rem;
}

.search-backdrop[hidden] {
  display: none;
}

.search-modal {
  width: 100%;
  max-width: 42rem;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 22px 54px rgb(0 0 0 / 0.38);
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--term-bg);
  color: var(--term-fg);
  border-bottom: 1px solid var(--rule);
}

.search-prompt {
  font: 700 0.92rem/1 var(--mono);
  color: var(--term-cursor);
  user-select: none;
  flex: none;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--term-fg);
  font: 0.96rem/1.4 var(--mono);
  caret-color: var(--term-cursor);
  outline: none;
}

.search-input::placeholder {
  color: var(--term-dim);
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-esc {
  flex: none;
  padding: 0.22rem 0.45rem;
  background: transparent;
  border: 1px solid var(--term-dim);
  border-radius: 4px;
  color: var(--term-fg);
  font: 0.7rem/1 var(--mono);
  cursor: pointer;
  opacity: 0.75;
}

.search-esc:hover {
  opacity: 1;
  border-color: var(--term-fg);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

.search-item + .search-item {
  margin-top: 0.15rem;
}

.search-item a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
}

.search-item.active a,
.search-item a:hover {
  background: var(--paper-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.search-item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
}

.search-mnemonic {
  font: 700 0.9rem/1.3 var(--mono);
  color: var(--accent);
}

.search-name {
  font-weight: 600;
  font-size: 0.96rem;
}

.search-heading {
  font-size: 0.86rem;
  color: var(--muted);
}

.search-syntax,
.search-category {
  margin-left: auto;
  font: 0.78rem/1.3 var(--mono);
  color: var(--muted);
  background: var(--paper-2);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.search-item.active .search-syntax,
.search-item.active .search-category {
  background: var(--paper);
}

.search-snippet {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

.search-snippet mark {
  background: var(--warn-wash);
  color: var(--ink);
  font-weight: 600;
  padding: 0.02em 0.22em;
  border-radius: 3px;
}

.search-empty,
.search-no-results {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  font: 0.88rem/1.5 var(--mono);
}

.search-empty-error {
  color: var(--bad);
}

.search-empty-suggestions {
  padding: 0.65rem 0.75rem 0.8rem;
  text-align: left;
  font-family: var(--serif);
}

.search-empty-title,
.search-suggestions-title {
  margin: 0 0 0.65rem;
  font: 600 0.74rem/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.search-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--ink);
  font: 0.82rem/1.2 var(--serif);
  cursor: pointer;
}

.search-chip:hover {
  border-color: var(--ink);
}

.search-chip code {
  background: none;
  padding: 0;
  font-weight: 600;
  color: var(--accent);
}

.search-chip span {
  color: var(--muted);
}

.search-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0.85rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font: 0.74rem/1.2 var(--mono);
  color: var(--muted);
}

.search-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.search-footer kbd {
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  background: var(--paper);
  border: 1px solid var(--rule);
  font-size: 0.7rem;
  margin-right: 0.2rem;
}

.search-status,
.search-engine-badge {
  opacity: 0.8;
}
