:root {
  --bg: #0b0f16;
  --bg-soft: #111825;
  --surface: #151d2b;
  --surface-2: #1b2536;
  --border: #26324a;
  --text: #e7edf6;
  --text-dim: #98a6bd;
  --accent: #4dd4ac;
  --accent-2: #58a6ff;
  --danger: #ff6b6b;
  --warn: #f0b429;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  /* Fill behind the copyable value in a result header (a deep green chip). */
  --accent-deep: #166534;
  --on-accent-deep: #dcfce7;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #dde3ec;
  --text: #17202e;
  --text-dim: #5b6a80;
  --accent: #0f9d76;
  --accent-2: #1f6feb;
  --danger: #d64545;
  --warn: #b7791f;
  --shadow: 0 8px 24px rgba(20, 30, 60, .10);
  --accent-deep: #166534;
  --on-accent-deep: #dcfce7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(77, 212, 172, .12), transparent 60%),
    radial-gradient(900px 460px at 92% 0%, rgba(88, 166, 255, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  /* Prose stays a system sans; every piece of *data* — values, command
   * names, tables, buttons — is set in --mono (see below), which is what
   * gives the site its datasheet-instrument look.  No web fonts: the site
   * ships zero external requests. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  color: #07110e;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- buttons ---------- */
.primary-btn, .ghost-btn, .chip, .copy-btn {
  font: inherit;
  /* Controls read as instrument labels: same mono as the data they carry. */
  font-family: var(--mono);
  cursor: pointer;
  border-radius: 10px;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}

.primary-btn {
  padding: 12px 24px;
  border: 0;
  font-weight: 600;
  color: #06120e;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}

.primary-btn:hover { transform: translateY(-1px); }

.ghost-btn {
  padding: 11px 16px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
}

.ghost-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- search card ---------- */
.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-row select,
.search-row input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
}

.search-row input {
  flex: 1 1 360px;
  min-width: 220px;
  font-family: var(--mono);
  font-size: 14px;
}

.search-row input:focus,
.search-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 212, 172, .16);
}

.hint {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.hint b { color: var(--text); }

code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  /* Every chip is one line tall now, so centring is safe; flex-start keeps
     the row honest if a future chip ever wraps. */
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
}

.chips-label {
  color: var(--text-dim);
  font-size: 12px;
  /* Match the chips' 6px padding + border so the label sits on the first
     line instead of floating above it. */
  padding-top: 7px;
}

.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 11px;
  font-size: 12.5px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, transform .15s ease;
}

/* name + query on the first line, the device's encoding underneath */
.chip-head {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.chip-name { color: var(--text-dim); white-space: nowrap; }

.chip code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  white-space: nowrap;
}

/* The bus word this chip encodes — inline after the query (``REF → 0x08
   0x30``), one step smaller and dimmer than the query itself. */
.chip-hex {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-dim);
  white-space: nowrap;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.chip:hover .chip-name { color: var(--text); }

/* ---------- recent searches ---------- */
/* Client-side history, filtered by the selected device: the row is filled
 * by app.js and unhidden only when the current device has saved searches.
 * All entries live on one line; whatever does not fit is simply clipped —
 * no horizontal scrolling, a scrollbar here visually breaks the page. */
.history {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.history[hidden] { display: none; }

.history-label {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 12px;
}

.history-items {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

/* Long stored queries stop with an ellipsis; the full text is in title. */
.history-item {
  font-family: var(--mono);
  flex-shrink: 0;
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-clear {
  flex-shrink: 0;
  padding: 6px 11px;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------- results ---------- */
.results { margin-top: 24px; }

/* A search is in flight (app.js toggles the class): dim the previous answer
   just enough to say "these are stale" without flickering the page. */
.results.is-loading {
  opacity: .55;
  transition: opacity .12s ease;
  pointer-events: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* The header carries the answer itself — the command, its badges and the bus
   value the copy button sits next to.  Only the copyable value is worth a
   highlight, so it alone wears the deep-green chip; the header itself stays
   transparent.  The chip is pinned to the card's top-right corner and never
   wraps — the badges give way around it instead. */
.result-head {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px 12px;
  align-items: flex-start;
  justify-content: space-between;
}

/* The title and its badges give way first: they wrap inside their own row
   (`min-width: 0` lets the flex item shrink below its content width) while
   the value chip keeps its corner. */
.result-head .title-row {
  flex: 1 1 auto;
  min-width: 0;
}

/* Pinned right and kept on one line: `flex: 0 0 auto` stops it from being
   squeezed, `margin-left: auto` pushes it to the far edge, and `nowrap`
   keeps "ma=0x2d op=0x5b" from splitting across two lines. */
.result-head .raw-row {
  flex: 0 0 auto;
  margin-left: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Phones: a nowrap header would squeeze the title to a column of single
   characters, so the chip is allowed to drop onto its own line there — it
   still sits at the right edge and still never wraps internally. */
@media (max-width: 720px) {
  .result-head { flex-wrap: wrap; }
  /* The value chip never wraps internally, so on a narrow phone a long
     capture ("ma=0x2d op=0x5b …") used to push the card wider than the
     screen.  Give it its own scrollable line instead. */
  .result-head .raw-row {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .result-head .raw-row::-webkit-scrollbar { display: none; }
}

/* The value itself (the typed command, or the raw bus words when the query
   *is* the word).  Overrides the generic `code` chip: solid deep green,
   inverted text, so it reads as the answer rather than as a code sample. */
.result-head .raw-row .cmd,
.result-head .raw-row .raw {
  padding: 3px 10px;
  border: 1px solid var(--accent-deep);
  border-radius: 8px;
  background: var(--accent-deep);
  color: var(--on-accent-deep);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

/* Hover lifts the chip one step (not all the way to the bright accent) so the
   affordance reads without flashing a neon block. */
.result-head .raw-row .cmd:hover {
  background: #1f8047;
  border-color: #1f8047;
  color: var(--on-accent-deep);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.title-row h2 {
  margin: 0;
  /* The card's headline is the command *name* — data, not prose. */
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: -.3px;
}

.badge {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .3px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #06120e;
  background: var(--accent);
  font-weight: 600;
}

.badge.alt {
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 500;
}

.raw-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.raw {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-2);
}

.copy-btn {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.copy-btn:hover { color: var(--text); border-color: var(--accent); }

.raw-arrow {
  color: var(--text-dim);
  font-size: 12px;
}

/* The decoded command in typed form, printed next to the bus values.
   Clicking it copies, like the button beside it. */
.cmd {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

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

.desc {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

.desc.strong { color: var(--text); }

.field-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.field {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}

.field .fname { color: var(--text-dim); }
.field .fval { color: var(--accent); font-weight: 600; }
.field .fdec { color: var(--text-dim); font-size: 12px; }
.field.flag .fval { color: var(--accent-2); }
.field.bad { border-color: var(--danger); }
.field.bad .fval { color: var(--danger); }

/* ---------- truth table ---------- */
.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.tt {
  font-family: var(--mono);
  min-width: 940px;
}

.tt th, .tt td {
  border: 1px solid var(--border);
  padding: 7px 9px;
  text-align: center;
  white-space: nowrap;
}

.tt thead th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.tt .cmd-cell {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  min-width: 120px;
}

.tt .cmd-cell small,
.tt .cyc-cell small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
}

.tt .cyc-cell {
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  min-width: 92px;
}

.tt .kind {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-soft);
}

.tt .cell { color: var(--text-dim); }
.tt .cell.val { color: var(--text); font-weight: 600; }
.tt .cell.bad {
  background: rgba(255, 107, 107, .16);
  color: var(--danger);
  font-weight: 700;
}

.note {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--warn);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
  font-size: 13px;
}

.alert {
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--danger);
  background: rgba(255, 107, 107, .10);
  color: var(--danger);
}

.error-card h2 { margin-top: 0; font-size: 18px; }
.error-card { border-color: var(--danger); }
.error-card p { color: var(--text-dim); margin-bottom: 0; }
.err-title { color: var(--danger); }

/* A notice card: the query parsed, but it is not answerable as typed
   (e.g. a paged control word with no page=).  Amber, not red — nothing failed. */
.warn-card { border-color: var(--warn); }
.warn-card h2 { font-size: 18px; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-dim);
}

.empty h2 { margin: 0 0 8px; font-size: 18px; color: var(--text); }

/* ---------- panels ---------- */
.panel {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 4px; font-size: 17px; }

.panel-note {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 13px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px 18px;
  margin: 12px 0 0;
}

.legend-item {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.legend dt {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
  min-width: 62px;
}

.legend dd { margin: 0; color: var(--text-dim); font-size: 13px; }

.ref-table { min-width: 720px; }

.ref-table th, .ref-table td {
  border: 1px solid var(--border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}

.ref-table thead th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ref-table tbody tr:hover { background: var(--surface-2); }
.ref-table .clickable { cursor: pointer; }
.ref-table .center { text-align: center; }
.ref-table .desc-cell { color: var(--text-dim); font-size: 13px; }
.ref-table code { color: var(--accent-2); }
/* A register number in a frame table (HBM3's MR overview) links to that
   register's card — same look as the register listing's names. */
.ref-table td a { color: var(--accent-2); text-decoration: none; }
.ref-table td a:hover { text-decoration: underline; }
/* The value column is short by construction (an MA address, a few CA
   samples); letting it wrap broke "MA[4:0] = 00000（0）" across two lines. */
.ref-table td.frame-val { white-space: nowrap; }

.ref-table tr.group-row th {
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .3px;
}

.ref-table tr.group-row:hover { background: var(--bg-soft); }
.muted { color: var(--text-dim); font-weight: 400; }

/* ---------- feedback ---------- */
.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions .ghost-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.feedback-panel[hidden] { display: none; }

.feedback-panel .fb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.feedback-panel select,
.feedback-panel textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.feedback-panel textarea {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 13.5px;
  resize: vertical;
}

.feedback-panel select:focus,
.feedback-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 212, 172, .16);
}

.fb-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.fb-req { color: var(--danger); margin-left: 4px; }

.fb-context-hint {
  color: var(--text-dim);
  font-size: 12.5px;
}

.fb-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.fb-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.fb-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fb-actions .primary-btn { padding: 10px 20px; }

.fb-actions .primary-btn[disabled] { opacity: .6; cursor: progress; }

.fb-status { font-size: 13px; color: var(--text-dim); }
.fb-status.good { color: var(--accent); }
.fb-status.bad { color: var(--danger); }

.fb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.fb-filters .chip { text-decoration: none; }
.fb-filters .chip.on { color: #06120e; background: var(--accent); border-color: var(--accent); }

.fb-id { font-family: var(--mono); font-size: 15px; }
.fb-time { color: var(--text-dim); font-size: 12.5px; }

/* A bug report keeps the user's line breaks; .desc alone would collapse them. */
.fb-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 32px;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

.site-footer p { margin: 4px 0; }

@media (max-width: 640px) {
  .page { padding: 20px 14px 48px; }
  .site-header { align-items: flex-start; }
  .header-actions .ghost-btn { padding: 8px 10px; }
  .brand-text h1 { font-size: 20px; }
  .primary-btn { width: 100%; }
  .search-row { flex-direction: column; }
  .search-row input { flex: 0 0 auto; width: 100%; min-width: 0; }
  .fb-two { grid-template-columns: 1fr; }
}

/* ==========================================================================
   mode-register detail (kind="mrfull") — bit strip + field decode + encoding
   tables.  Colours come from the theme variables so both themes stay legible.
   ========================================================================== */

.mr-detail { margin-top: 14px; }

.mr-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 6px;
}

.mr-head .mr-name { font-size: 15px; font-weight: 700; }
.mr-head .mr-title { color: var(--text-dim); font-size: 13px; }
.mr-head .mr-src {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
}

.mr-purpose { margin: 0 0 12px; color: var(--text-dim); font-size: 13px; }

/* ---- bit strip ---- */
.mr-bitstrip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 10px 0 4px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.mr-bit {
  min-width: 42px;
  padding: 4px 6px;
  border-radius: 7px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  border: 1px solid var(--border);
  background: var(--surface);
}

.mr-bit .bl { display: block; color: var(--text-dim); font-size: 10px; }
.mr-bit .bv { display: block; font-size: 14px; font-weight: 700; }

.mr-bit.f0 { background: rgba(77, 212, 172, .16); border-color: rgba(77, 212, 172, .45); }
.mr-bit.f1 { background: rgba(88, 166, 255, .16); border-color: rgba(88, 166, 255, .45); }
.mr-bit.f2 { background: rgba(240, 180, 41, .16); border-color: rgba(240, 180, 41, .45); }
.mr-bit.f3 { background: rgba(188, 140, 255, .16); border-color: rgba(188, 140, 255, .45); }
.mr-bit.f4 { background: rgba(255, 123, 114, .16); border-color: rgba(255, 123, 114, .45); }
.mr-bit.f5 { background: rgba(110, 231, 183, .14); border-color: rgba(110, 231, 183, .40); }

.mr-bit.undef { background: transparent; border-style: dashed; opacity: .65; }
.mr-bit.undef .bv { color: var(--text-dim); }

.mr-bitlegend {
  margin: 0 0 12px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---- field decode table ---- */
.mr-fields { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mr-fields th, .mr-fields td {
  border: 1px solid var(--border);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}
.mr-fields thead th {
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.mr-fields td.bits { font-family: var(--mono); white-space: nowrap; color: var(--text-dim); }
.mr-fields td.val { font-family: var(--mono); white-space: nowrap; }
.mr-fields td.meaning { min-width: 180px; }
.mr-fields tr:hover td { background: var(--surface-2); }
.mr-fields .rw-tag {
  font-size: 10.5px;
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  color: var(--text-dim);
}
.mr-fields .field-note {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: normal;
}

/* ---- encoding tables ---- */
.mr-enc-wrap { margin-top: 5px; }
.mr-enc-wrap > summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--accent);
  list-style: none;
}
.mr-enc-wrap > summary::-webkit-details-marker { display: none; }
.mr-enc-wrap > summary::before { content: "▸ "; }
.mr-enc-wrap[open] > summary::before { content: "▾ "; }

.mr-enc {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 2px;
  font-size: 12px;
}
.mr-enc th, .mr-enc td {
  border: 1px solid var(--border);
  padding: 3px 8px;
  text-align: left;
}
.mr-enc thead th {
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-dim);
}
.mr-enc td.code { font-family: var(--mono); white-space: nowrap; color: var(--text-dim); }
.mr-enc tr.current td { background: rgba(77, 212, 172, .18); font-weight: 700; }
.mr-enc tr.current td.code::after { content: " ◀"; color: var(--accent); }
.mr-enc .grp {
  margin: 8px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
}

/* ---- notes ---- */
.mr-notes {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.mr-notes ol { margin: 0; padding-left: 18px; }
.mr-notes li { margin: 3px 0; }

/* ---- register listing (kind="mrlist") ---- */
.mr-list { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mr-list th, .mr-list td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
}
.mr-list thead th { background: var(--surface-2); font-size: 11.5px; color: var(--text-dim); }
.mr-list td.name { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.mr-list td.cov { font-family: var(--mono); white-space: nowrap; color: var(--text-dim); }
.mr-list td.cov.full { color: var(--accent); }
.mr-list tr:hover td { background: var(--surface-2); }
.mr-list a { color: var(--accent-2); text-decoration: none; }
.mr-list a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .mr-bit { min-width: 36px; }
  .mr-head .mr-src { margin-left: 0; }
}

/* Visually hidden but announced by screen readers (result-count live region). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Accessibility: visible keyboard focus and reduced motion.
   ========================================================================== */

/* Every interactive element — including ones that never had a focus style
   (result-table rows, filter links, buttons) — shows the same accent ring,
   but only for keyboard focus (:focus-visible); mouse clicks stay quiet.
   Outlines follow the element's own border-radius in current browsers. */
:where(a, button, select, input, textarea, [tabindex], tr.clickable):focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* The hover lifts and chip transitions (transform translateY, fades) are
   decoration; the OS "reduce motion" setting turns them off wholesale. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
