/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio, geometry.
   Put this @layer first; product CSS outside the layer wins ordinary layout rules.
   Native hidden and closed-dialog states take precedence over component display rules. */
@layer od-layout {
  [hidden]:not([hidden="until-found" i]) { display: none !important; }
  dialog:not([open]) { display: none !important; }

  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* functional inline SVG icons opt into bounded geometry; content SVGs keep their own */
  .od-icon { display: inline-block; inline-size: var(--od-icon-size, 1em); block-size: var(--od-icon-size, 1em); flex: none; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
:root [hidden]:where(:not([hidden="until-found" i])) { display: none; }
/* /OD-LAYOUT-PRIMITIVES v1 */

:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --text: #17202a;
  --muted: #66717e;
  --faint: #8f99a5;
  --border: #d8dee5;
  --border-strong: #b4bec9;
  --grid: #e7ebef;
  --focus: #075fc9;
  --selection: #111820;
  --shadow: 0 12px 30px rgba(22, 32, 43, 0.08);
  --structure: #52718f;
  --structure-soft: rgba(82, 113, 143, 0.2);
  --maps: #bd6c16;
  --maps-soft: rgba(189, 108, 22, 0.2);
  --axes: #34815c;
  --axes-soft: rgba(52, 129, 92, 0.2);
  --diagnostics: #7755a6;
  --diagnostics-soft: rgba(119, 85, 166, 0.2);
  --patches: #c0463e;
  --patches-soft: rgba(192, 70, 62, 0.2);
  --integrity: #9a7a18;
  --integrity-soft: rgba(154, 122, 24, 0.2);
  --candidate: #8d5fb0;
  --overview-rgb: 48, 105, 156;
  --signal: #2b7a8a;
  --register: #a9467a;
  --endpoint-in: #2f6fb0;
  --endpoint-out: #b5552c;
  --sign-positive: #237a41;
  --sign-negative: #b53a33;
  --sign-none: #68737e;
  --sign-mixed: #8a6510;
  --sign-ink: #ffffff;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171d;
    --surface: #182027;
    --surface-raised: #1d2730;
    --text: #edf2f6;
    --muted: #a3afb9;
    --faint: #7e8a94;
    --border: #34414c;
    --border-strong: #53616d;
    --grid: #28343d;
    --focus: #78b4ff;
    --selection: #ffffff;
    --shadow: 0 16px 34px rgba(0, 0, 0, 0.3);
    --structure: #79a6cc;
    --structure-soft: rgba(121, 166, 204, 0.2);
    --maps: #e39a4a;
    --maps-soft: rgba(227, 154, 74, 0.2);
    --axes: #68ba8e;
    --axes-soft: rgba(104, 186, 142, 0.2);
    --diagnostics: #ad8bd6;
    --diagnostics-soft: rgba(173, 139, 214, 0.2);
    --patches: #e17770;
    --patches-soft: rgba(225, 119, 112, 0.2);
    --integrity: #d7b44d;
    --integrity-soft: rgba(215, 180, 77, 0.2);
    --candidate: #c49be0;
    --overview-rgb: 109, 169, 219;
    --signal: #62bccb;
    --register: #e07fae;
    --endpoint-in: #7fb3e6;
    --endpoint-out: #ea9466;
    --sign-positive: #6cc58a;
    --sign-negative: #ef8a83;
    --sign-none: #9aa6b1;
    --sign-mixed: #d7b44d;
    --sign-ink: #10171d;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
input,
select,
canvas,
svg {
  outline-offset: 3px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible,
svg:focus-visible {
  outline: 2px solid var(--focus);
}

button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

button:hover {
  border-color: var(--focus);
}

button:active {
  transform: translateY(1px);
}

.app {
  width: 100%;
  margin: 0 auto;
  padding: 24px clamp(14px, 1.5vw, 28px) 32px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.65rem, 2.8vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.25;
}

.identity {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.79rem;
}

.header-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, auto));
  gap: 9px 18px;
  margin: 0;
  text-align: right;
}

.header-stats div {
  display: grid;
  gap: 2px;
}

.header-stats dt {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 650;
}

.rom-info {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.rom-info summary {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.rom-info summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.rom-info[open] summary {
  border-bottom: 1px solid var(--border);
}

.rom-info-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px 24px;
  padding: 14px;
}

.rom-info-section h2 {
  margin-bottom: 8px;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.rom-info-list {
  display: grid;
  grid-template-columns: minmax(110px, 0.42fr) minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  font-size: 0.75rem;
}

.rom-info-list dt {
  color: var(--muted);
}

.rom-info-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
}

.rom-info-list .rom-info-prose {
  font-family: var(--font-sans);
  line-height: 1.5;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 220px) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg);
}

.field-address input {
  font-family: var(--font-mono);
}

.view-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.view-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.view-tab {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.view-tab[aria-selected="true"] {
  background: var(--text);
  color: var(--surface);
}

.view-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 9px;
}

.field-inline select {
  width: auto;
  min-width: 210px;
  height: 34px;
}

.button-group {
  display: flex;
  gap: 6px;
}

.button-group button:first-child,
.button-group button:nth-child(2) {
  width: 38px;
  padding: 0;
  font-size: 1.1rem;
}

.layer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 2px 10px;
}

.layer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 15px;
}

.layer-filter,
.semantic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.layer-filter input,
.semantic-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--layer-color, var(--focus));
}

.layer-filter strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
}

.overview-section,
.map-panel,
.details,
.warnings,
.arch-banner {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.overview-section {
  margin-top: 5px;
  padding: 13px 14px 14px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.section-heading p,
.section-heading output {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

#overview {
  display: block;
  width: 100%;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  cursor: crosshair;
  touch-action: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.map-heading {
  padding: 13px 14px 0;
}

.gesture-help {
  text-align: right;
}

#viewport-label {
  font-family: var(--font-mono);
}

#address-map {
  display: block;
  width: 100%;
  height: 486px;
  background: var(--surface);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#address-map.is-dragging {
  cursor: grabbing;
}

.axis-line,
.lane-divider,
.tick-line {
  stroke: var(--grid);
  vector-effect: non-scaling-stroke;
}

.axis-line {
  stroke: var(--border-strong);
}

.tick-label,
.lane-label,
.mark-label,
.density-label {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

.lane-label {
  fill: var(--text);
  font-family: var(--font-sans);
  font-weight: 600;
}

.mark-label {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 11px;
}

.mark {
  cursor: pointer;
  opacity: 0.82;
  shape-rendering: crispEdges;
  transition: opacity 100ms ease, filter 100ms ease;
}

.mark[data-layer="structure"] {
  fill: var(--structure);
}

.mark[data-layer="maps"] {
  fill: var(--maps);
}

.mark[data-layer="axes"] {
  fill: var(--axes);
}

.mark[data-layer="diagnostics"] {
  fill: var(--diagnostics);
}

.mark[data-layer="patches"] {
  fill: var(--patches);
}

.mark[data-layer="integrity"] {
  fill: var(--integrity);
}

.mark[data-kind="function-structure"] {
  opacity: 0.27;
}

.mark[data-layer="maps"][data-patch]:not([data-patch=""]) {
  stroke: var(--patches);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.mark[data-kind="patch-claim"],
.mark[data-kind="erased-envelope"],
.mark[data-kind="checksum-domain"] {
  opacity: 0.18;
}

.mark[data-patch-status="candidate"] {
  fill: var(--candidate);
  opacity: 0.72;
  stroke: var(--surface);
  stroke-dasharray: 3 2;
  stroke-width: 1;
}

.mark.is-muted {
  opacity: 0.08;
}

.mark.is-match {
  opacity: 1;
  filter: drop-shadow(0 0 2px currentColor);
}

.mark.is-selected {
  opacity: 1;
  stroke: var(--selection);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.mark[data-layer="maps"][data-patch]:not([data-patch=""]).is-selected {
  stroke: var(--selection);
  stroke-width: 2;
}

.selection-guide {
  stroke: var(--selection);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.details {
  position: sticky;
  top: 12px;
  min-height: 250px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.details-empty {
  color: var(--muted);
}

.details-empty p {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.details-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.details-heading h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.details-heading button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.detail-range {
  margin: 11px 0 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
  font-size: 0.7rem;
}

.detail-meta {
  display: grid;
  grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0 0 13px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

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

.detail-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
}

.detail-copy {
  margin-bottom: 11px;
  font-size: 0.8rem;
  line-height: 1.52;
  white-space: pre-line;
}

.detail-copy.secondary {
  color: var(--muted);
}

.detail-related {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.detail-related button {
  min-height: 30px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.detail-source {
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.warnings {
  margin-top: 14px;
  padding: 13px 15px;
}

.warnings ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.8rem;
}

footer {
  padding: 15px 4px 0;
  color: var(--faint);
  font-size: 0.72rem;
  line-height: 1.45;
}

footer p {
  margin-bottom: 0;
}

/* Architecture view. */

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

.arch-search-field {
  position: relative;
  min-width: 0;
}

.arch-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: min(380px, 60vh);
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.arch-result {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  column-gap: 9px;
  width: 100%;
  min-height: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.arch-result:hover,
.arch-result.is-active {
  background: var(--bg);
}

.arch-result-kind {
  grid-row: 1 / span 2;
  padding-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.arch-result-label,
.arch-result-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arch-result-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.arch-result-detail {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.arch-banner {
  margin: 12px 0 0;
  padding: 10px 13px;
  border-left: 4px solid var(--structure);
  font-size: 0.8rem;
  line-height: 1.45;
}

.arch-banner[data-mode="projected"] {
  border-left-color: var(--integrity);
}

.arch-banner[data-mode="reference"] {
  border-left-color: var(--patches);
}

.arch-chains {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-top: 8px;
}

.arch-active-chain {
  min-width: 0;
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#arch-catalog-toggle {
  flex: none;
  min-height: 32px;
  font-size: 0.82rem;
}

.arch-catalog {
  position: absolute;
  z-index: 6;
  top: 100%;
  right: 0;
  width: min(420px, 100%);
  max-height: min(440px, 52vh);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.arch-catalog-group {
  margin: 12px 0 0;
}

.arch-catalog-group h3,
.arch-catalog summary,
.arch-catalog p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.arch-catalog details {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.arch-catalog summary {
  cursor: pointer;
}

.arch-catalog-chain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 32px;
  padding: 4px 7px;
  border-color: transparent;
  background: transparent;
  font-size: 0.82rem;
  text-align: left;
}

.arch-catalog-chain[aria-current] {
  border-color: var(--border-strong);
  background: var(--structure-soft);
}

.arch-chains-label {
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.arch-notice {
  margin-left: 6px;
  color: var(--patches);
}

.arch-meter-track {
  fill: var(--grid);
}

.arch-meter-fill {
  fill: var(--axes);
}

.arch-legend-mark.meter {
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--axes) 60%, var(--grid) 60%);
}

.arch-box.tint-silicon .arch-box-frame {
  fill: var(--structure-soft);
}

.arch-box.tint-code .arch-box-frame {
  fill: var(--axes-soft);
}

.arch-box.tint-candidate .arch-box-frame {
  fill: var(--diagnostics-soft);
}

.arch-box.tint-pattern .arch-box-frame {
  fill: var(--maps-soft);
}

.arch-box.tint-none .arch-box-frame {
  fill: var(--grid);
}

.arch-legend-mark.tint-silicon {
  background: var(--structure-soft);
}

.arch-legend-mark.tint-code {
  background: var(--axes-soft);
}

.arch-legend-mark.tint-candidate {
  background: var(--diagnostics-soft);
}

.arch-legend-mark.tint-pattern {
  background: var(--maps-soft);
}

.arch-legend-mark.tint-none {
  background: var(--grid);
}

.arch-coverage-table {
  width: 100%;
  margin: 4px 0 10px;
  border-collapse: collapse;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.arch-coverage-table th,
.arch-coverage-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.arch-coverage-table th:first-child,
.arch-coverage-table td:first-child {
  text-align: left;
}

.arch-coverage-table tr.is-current td {
  font-weight: 650;
  background: var(--bg);
}

.arch-coverage-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.76rem;
}

.arch-coverage-list li {
  margin-bottom: 8px;
}

.arch-coverage-meaning {
  display: block;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.arch-coverage-list .arch-actions {
  margin-top: 4px;
}

.arch-chain-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--integrity-soft);
  color: inherit;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.arch-heading {
  align-items: flex-start;
}

.arch-heading-text {
  min-width: 0;
}

.arch-heading p {
  max-width: 88ch;
  line-height: 1.45;
}

.arch-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-bottom: 4px;
  font-size: 0.74rem;
}

.arch-crumb {
  min-height: 24px;
  padding: 0 5px;
  border: 0;
  background: none;
  color: var(--focus);
}

.arch-crumb.is-plain,
.arch-crumb.is-current {
  color: var(--muted);
}

.arch-crumb.is-current {
  color: var(--text);
  font-weight: 600;
}

.arch-crumb-separator {
  color: var(--faint);
}

.arch-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
}

.arch-range {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.arch-range input {
  width: 120px;
  accent-color: var(--focus);
}

.arch-range output {
  min-width: 3ch;
  color: var(--text);
  font-family: var(--font-mono);
}

.arch-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 14px 10px;
}

.arch-filters[hidden] {
  display: none;
}

.arch-filter-chip {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 0.72rem;
}

.arch-filter-chip.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--surface);
}

.arch-filter-chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.arch-canvas-frame {
  position: relative;
}

.arch-block-inventory {
  padding: 14px;
}

.arch-block-inventory .field {
  max-width: 360px;
}

.arch-inventory-table {
  overflow: auto;
  max-height: min(630px, 64vh);
  margin-top: 12px;
}

.arch-inventory-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

.arch-inventory-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.arch-inventory-table th,
.arch-inventory-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.arch-inventory-table td {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.arch-inventory-name {
  min-height: 30px;
  padding: 4px 7px;
  border-color: transparent;
  color: var(--focus);
  font: inherit;
  text-align: left;
}

.arch-inventory-name[aria-pressed="true"] {
  border-color: var(--selection);
  background: var(--structure-soft);
}

.arch-inventory-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.arch-minimap {
  position: absolute;
  right: 10px;
  top: 10px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  cursor: crosshair;
  touch-action: none;
}

.arch-minimap[hidden] {
  display: none;
}

.arch-minimap svg {
  display: block;
}

.arch-minimap-box {
  fill: var(--border-strong);
}

.arch-minimap-box.is-dimmed {
  fill: var(--border);
}

.arch-minimap-box.is-selected {
  fill: var(--focus);
}

.arch-minimap-view {
  fill: var(--focus);
  fill-opacity: 0.12;
  stroke: var(--focus);
  stroke-width: 1.5;
}

.arch-canvas {
  display: block;
  width: 100%;
  height: clamp(460px, 70vh, 860px);
  background: var(--surface);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.arch-canvas.is-dragging {
  cursor: grabbing;
}

.arch-column-label {
  fill: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.arch-column-sub {
  fill: var(--faint);
  font-size: 10px;
}

.arch-row-label {
  fill: var(--text);
  font-size: 11.5px;
  font-weight: 650;
}

.arch-support-band {
  fill: var(--bg);
  stroke: var(--border);
  stroke-dasharray: 4 4;
}

.arch-empty {
  fill: var(--muted);
  font-size: 13px;
}

.arch-box {
  cursor: pointer;
}

.arch-box:focus {
  outline: none;
}

.arch-box-frame {
  fill: var(--surface-raised);
  stroke: var(--border-strong);
  stroke-width: 1;
  transition: stroke 100ms ease;
}

.arch-box-bar {
  fill: var(--structure);
}

.arch-box-title,
.arch-box-sub,
.arch-chip text,
.arch-badge text,
.arch-edge-label text {
  pointer-events: none;
}

.arch-box-title {
  fill: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.arch-box-sub {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.arch-box-tag {
  fill: var(--faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
  pointer-events: none;
}

.arch-box.is-editable .arch-box-tag {
  fill: var(--maps);
  font-weight: 650;
}

.arch-box.is-editable .arch-box-frame {
  stroke: var(--maps);
}

.arch-box.level-candidate .arch-box-frame,
.arch-box.level-pattern .arch-box-frame {
  stroke-dasharray: 5 3;
}

.arch-box.is-support .arch-box-bar {
  fill: var(--faint);
}

.arch-box.is-generic .arch-box-frame {
  stroke-dasharray: 4 3;
}

.arch-box.endpoint-input .arch-box-frame,
.arch-box.endpoint-output .arch-box-frame,
.arch-box.endpoint-bidirectional .arch-box-frame,
.arch-box.external .arch-box-frame {
  fill: var(--bg);
}

.arch-box.endpoint-input .arch-box-bar {
  fill: var(--endpoint-in);
}

.arch-box.endpoint-output .arch-box-bar,
.arch-box.endpoint-bidirectional .arch-box-bar {
  fill: var(--endpoint-out);
}

.arch-box.external .arch-box-frame {
  stroke-dasharray: 4 3;
}

.arch-box.external .arch-box-bar {
  fill: var(--faint);
}

.arch-box.more .arch-box-frame {
  fill: none;
  stroke-dasharray: 2 3;
}

.arch-box.more .arch-box-bar {
  fill: none;
}

.arch-box.kind-map .arch-box-bar,
.arch-chip.kind-map .arch-chip-dot {
  fill: var(--maps);
}

.arch-box.kind-axis .arch-box-bar,
.arch-chip.kind-axis .arch-chip-dot {
  fill: var(--axes);
}

.arch-box.kind-signal .arch-box-bar {
  fill: var(--signal);
}

.arch-box.kind-register .arch-box-bar {
  fill: var(--register);
}

.arch-box.kind-ram .arch-box-bar,
.arch-box.kind-io .arch-box-bar,
.arch-box.kind-rom .arch-box-bar,
.arch-box.kind-other .arch-box-bar,
.arch-chip.kind-more .arch-chip-dot {
  fill: var(--faint);
}

.arch-box.is-center .arch-box-frame {
  stroke: var(--text);
  stroke-width: 2;
}

.arch-box.is-output .arch-box-frame {
  stroke: var(--focus);
  stroke-width: 2;
}

.arch-box.is-related .arch-box-frame,
.arch-box:hover .arch-box-frame {
  stroke: var(--focus);
}

.arch-box.is-selected .arch-box-frame {
  stroke: var(--selection);
  stroke-width: 2.5;
}

.arch-box:focus-visible .arch-box-frame {
  stroke: var(--focus);
  stroke-width: 3;
}

.arch-box.is-dimmed {
  opacity: 0.3;
}

.arch-box.is-empty:not(.is-selected, .is-dimmed) {
  opacity: 0.58;
}

.arch-chip {
  cursor: pointer;
}

.arch-chip text {
  fill: var(--text);
  font-size: 10.5px;
}

.arch-chip:hover text {
  fill: var(--focus);
  text-decoration: underline;
}

.arch-flow {
  fill: none;
  stroke: var(--structure);
  stroke-opacity: 0.4;
  pointer-events: none;
}

.arch-flow.is-support {
  stroke-dasharray: 5 4;
}

.arch-flow.is-incoming {
  stroke: var(--signal);
}

.arch-flow.is-outgoing {
  stroke: var(--endpoint-out);
}

.arch-flow.sign-positive {
  stroke: var(--sign-positive);
  stroke-opacity: 0.85;
}

.arch-flow.sign-negative {
  stroke: var(--sign-negative);
  stroke-opacity: 0.85;
}

.arch-flow.sign-none {
  stroke: var(--sign-none);
  stroke-opacity: 0.75;
}

.arch-flow.is-spec {
  stroke-dasharray: 6 4;
}

.arch-flow.is-hot {
  stroke: var(--focus);
  stroke-opacity: 0.92;
}

.arch-flow.is-selected {
  stroke: var(--selection);
  stroke-opacity: 1;
}

.arch-flow.is-dimmed {
  stroke-opacity: 0.08;
}

.arch-flow-hit {
  fill: none;
  stroke: transparent;
  cursor: pointer;
  pointer-events: stroke;
}

.arch-link {
  fill: none;
  stroke: var(--border-strong);
  stroke-dasharray: 3 3;
  stroke-width: 1.4;
}

.arch-link.is-hot {
  stroke: var(--focus);
  stroke-dasharray: none;
}

.arch-link.is-dimmed {
  opacity: 0.25;
}

.arch-arrow {
  fill: var(--structure);
  fill-opacity: 0.75;
}

.arch-arrow.is-hot {
  fill: var(--focus);
  fill-opacity: 1;
}

.arch-arrow.sign-positive {
  fill: var(--sign-positive);
}

.arch-arrow.sign-negative {
  fill: var(--sign-negative);
}

.arch-arrow.sign-none {
  fill: var(--sign-none);
}

.arch-edge-label {
  cursor: pointer;
}

.arch-edge-label rect {
  fill: var(--surface);
  stroke: var(--sign-none);
}

.arch-edge-label text {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.arch-edge-label.sign-positive rect {
  stroke: var(--sign-positive);
}

.arch-edge-label.sign-negative rect {
  stroke: var(--sign-negative);
}

.arch-edge-label.sign-positive text {
  fill: var(--sign-positive);
}

.arch-edge-label.sign-negative text {
  fill: var(--sign-negative);
}

.arch-badge rect {
  fill: var(--sign-none);
}

.arch-badge text {
  fill: var(--sign-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.arch-badge.sign-positive rect {
  fill: var(--sign-positive);
}

.arch-badge.sign-negative rect {
  fill: var(--sign-negative);
}

.arch-badge.sign-mixed rect {
  fill: var(--sign-mixed);
}

.arch-badge.sign-output rect {
  fill: var(--focus);
}

.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}

.arch-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.arch-legend-mark.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--structure);
}

.arch-legend-mark.swatch.block {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  box-shadow: inset 3px 0 0 var(--structure);
}

.arch-legend-mark.swatch.is-editable {
  border: 1.5px solid var(--maps);
  background: var(--surface-raised);
}

.arch-legend-mark.swatch.external {
  border: 1px dashed var(--border-strong);
  background: var(--bg);
}

.arch-legend-mark.kind-map {
  background: var(--maps);
}

.arch-legend-mark.kind-signal {
  background: var(--signal);
}

.arch-legend-mark.kind-register {
  background: var(--register);
}

.arch-legend-mark.kind-ram {
  background: var(--faint);
}

.arch-legend-mark.endpoint-input {
  border-radius: 6px;
  background: var(--endpoint-in);
}

.arch-legend-mark.endpoint-output {
  border-radius: 6px;
  background: var(--endpoint-out);
}

.arch-legend-mark.line {
  width: 22px;
  border-top: 2.5px solid var(--structure);
}

.arch-legend-mark.line.is-dashed {
  border-top-style: dashed;
}

.arch-legend-mark.sign,
.arch-sign-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--sign-none);
  color: var(--sign-ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.sign-positive.arch-legend-mark,
.sign-positive.arch-sign-pill {
  background: var(--sign-positive);
}

.sign-negative.arch-legend-mark,
.sign-negative.arch-sign-pill {
  background: var(--sign-negative);
}

.sign-mixed.arch-legend-mark,
.sign-mixed.arch-sign-pill {
  background: var(--sign-mixed);
}

.arch-table {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

.arch-table-title {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.arch-trace-list .arch-node-link {
  display: inline-flex;
  width: auto;
  margin: 0 4px 4px 0;
}

.arch-trace-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  font-size: 0.76rem;
}

.arch-trace-arrow {
  color: var(--faint);
}

.arch-details {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.arch-detail-section {
  margin-top: 14px;
}

.arch-detail-section h3,
.arch-detail-section.is-collapsible > summary {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.arch-detail-section.is-collapsible > summary {
  font-weight: 700;
  cursor: pointer;
}

.arch-detail-section.is-collapsible > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.arch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.arch-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.arch-actions button.is-primary {
  border-color: var(--focus);
  background: var(--focus);
  color: var(--surface);
}

.arch-link-list {
  display: grid;
  gap: 4px;
}

.arch-node-link {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 28px;
  padding: 3px 8px;
  border-color: var(--border);
  background: var(--bg);
  font-size: 0.74rem;
  text-align: left;
}

.arch-node-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--structure);
}

.arch-node-link.kind-map .arch-node-dot {
  background: var(--maps);
}

.arch-node-link.kind-axis .arch-node-dot {
  background: var(--axes);
}

.arch-node-link.kind-signal .arch-node-dot {
  background: var(--signal);
}

.arch-node-link.kind-register .arch-node-dot {
  background: var(--register);
}

.arch-node-link.kind-ram .arch-node-dot,
.arch-node-link.kind-io .arch-node-dot,
.arch-node-link.kind-rom .arch-node-dot,
.arch-node-link.kind-other .arch-node-dot {
  background: var(--faint);
}

.arch-node-link.kind-block .arch-node-dot {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  box-shadow: inset 2px 0 0 var(--structure);
}

.arch-node-link.kind-chain .arch-node-dot {
  border-radius: 50%;
  background: var(--focus);
}

.arch-more {
  min-height: 28px;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.72rem;
}

.arch-inline-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--focus);
  font-size: inherit;
  text-align: left;
  text-decoration: underline;
}

.arch-impact-list,
.arch-reach-list,
.arch-spec-list {
  display: grid;
  gap: 5px;
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.4;
}

.arch-impact-list {
  padding: 0;
  list-style: none;
}

.arch-impact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
}

.arch-reach-list,
.arch-spec-list {
  padding-left: 18px;
}

.arch-spec-list {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}

.badge.sign-positive {
  border-color: var(--sign-positive);
  color: var(--sign-positive);
}

.badge.sign-negative {
  border-color: var(--sign-negative);
  color: var(--sign-negative);
}

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: min(340px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  line-height: 1.35;
  pointer-events: none;
}

.tooltip strong,
.tooltip span {
  display: block;
}

.tooltip span {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 290px;
  }

  .arch-heading {
    flex-direction: column;
  }

  .arch-options {
    justify-content: flex-start;
  }

  .header-stats {
    grid-template-columns: repeat(2, auto);
  }
}

@media (max-width: 820px) {
  .app {
    padding-top: 18px;
  }

  .app-header {
    align-items: flex-start;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(145px, 0.5fr);
  }

  .field-search {
    grid-column: 1 / -1;
  }

  .button-group {
    justify-content: flex-end;
  }

  .layer-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .details {
    position: static;
  }

  .arch-details {
    max-height: none;
  }

  #address-map {
    height: 452px;
  }

  .arch-canvas {
    height: clamp(420px, 62vh, 640px);
  }
}

@media (max-width: 560px) {
  .app-header {
    display: grid;
  }

  .header-stats {
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
    text-align: left;
  }

  .toolbar,
  .arch-toolbar {
    grid-template-columns: 1fr;
  }

  .view-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .field-inline select {
    flex: 1;
    min-width: 0;
  }

  .arch-canvas {
    height: 400px;
  }

  .field-search,
  .field-address,
  .field-rom,
  .button-group {
    grid-column: auto;
  }

  .button-group {
    justify-content: flex-start;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .gesture-help {
    display: none;
  }

  .header-stats dt {
    font-size: 0.7rem;
  }

  .header-stats dd {
    font-size: 0.75rem;
  }

  #address-map {
    height: 422px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Theme and component tokens */
:root, .theme-preview[data-palette="light"] {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #fbfcfe;
  --surface-raised: #ffffff;
  --chrome: #ffffff;
  --canvas: #f4f7fb;
  --band: #ecf1f7;
  --text: #162235;
  --muted: #44556b;
  --faint: #4e6179;
  --border: #ced8e4;
  --border-strong: #778ca4;
  --grid: #d6e0eb;
  --dot-grid: #d5dfeb;
  --focus: #175caa;
  --selection: #174f8e;
  --accent-surface: #e3efff;
  --accent-ink: #ffffff;
  --warning-bg: #fff4dc;
  --warning-fg: #684511;
  --shadow: 0 8px 28px rgb(28 49 75 / 14%);
  --structure: #385e85;
  --maps: #865010;
  --axes: #23664f;
  --diagnostics: #69479b;
  --patches: #a33849;
  --integrity: #6b5c1c;
  --signal: #216773;
  --register: #963d76;
  --endpoint-in: #225eaa;
  --endpoint-out: #974728;
  --candidate: #774790;
  --sign-positive: #226744;
  --sign-negative: #a22f3f;
  --sign-none: #4d6178;
  --sign-mixed: #80540e;
  --sign-ink: #ffffff;
  --overview-rgb: 48, 101, 155;
}
:root[data-theme="dark"], .theme-preview[data-palette="dark"] {
  color-scheme: dark;
  --bg: #0d141e;
  --surface: #131d2a;
  --surface-raised: #192536;
  --chrome: #121b28;
  --canvas: #0f1723;
  --band: #162131;
  --text: #e8eff8;
  --muted: #a8b7ca;
  --faint: #93a5bb;
  --border: #2c3b4f;
  --border-strong: #657b96;
  --grid: #26354a;
  --dot-grid: #26364a;
  --focus: #8bc2ff;
  --selection: #a4d0ff;
  --accent-surface: #233d5c;
  --accent-ink: #102338;
  --warning-bg: #302618;
  --warning-fg: #f3ca86;
  --shadow: 0 12px 36px rgb(0 0 0 / 32%);
  --structure: #8fafcf;
  --maps: #e9ac66;
  --axes: #78c7a2;
  --diagnostics: #bc9ee9;
  --patches: #f3929b;
  --integrity: #d5c475;
  --signal: #7bc7d0;
  --register: #e799c8;
  --endpoint-in: #86bbfa;
  --endpoint-out: #f2a582;
  --candidate: #cb9fe5;
  --sign-positive: #8dd3a7;
  --sign-negative: #f6a1a6;
  --sign-none: #a4b5cc;
  --sign-mixed: #efc16d;
  --sign-ink: #101c2a;
  --overview-rgb: 104, 156, 214;
}
:root {
  --u: 4px;
  --s1: calc(var(--u) * 1);
  --s2: calc(var(--u) * 2);
  --s3: calc(var(--u) * 3);
  --s4: calc(var(--u) * 4);
  --s5: calc(var(--u) * 5);
  --s6: calc(var(--u) * 6);
  --s8: calc(var(--u) * 8);
  --s10: calc(var(--u) * 10);
  --r1: 4px;
  --r2: 6px;
  --r3: 8px;
  --shell-height: 48px;
  --toolbar-height: 44px;
  --overview-height: 52px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-ui: 13px;
  --text-body: 16px;
  --text-title: 24px;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --motion: 160ms;
  --ease-out: cubic-bezier(.2,.65,.25,1);
  --structure-soft: color-mix(in srgb, var(--structure) 18%, transparent);
  --maps-soft: color-mix(in srgb, var(--maps) 18%, transparent);
  --axes-soft: color-mix(in srgb, var(--axes) 18%, transparent);
  --diagnostics-soft: color-mix(in srgb, var(--diagnostics) 18%, transparent);
  --patches-soft: color-mix(in srgb, var(--patches) 18%, transparent);
  --integrity-soft: color-mix(in srgb, var(--integrity) 18%, transparent);
}
body { min-width: 0; background: var(--canvas); font-size: var(--text-ui); }
h1, h2, h3, p, dl { margin: 0; }
button, input, select, output { font: inherit; }
input::placeholder { color: var(--faint); opacity: 1; }
input, select { min-width: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); min-height: 28px; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); background: var(--surface); color: var(--text); white-space: nowrap; }
button:hover { border-color: var(--border-strong); background: var(--band); }
button:disabled { opacity: .66; cursor: default; }
button:disabled:hover { border-color: var(--border); background: var(--surface); }
button:active { transform: none; }
summary { cursor: pointer; }
summary:focus-visible { outline: 2px solid var(--focus); }
.icon-library { display: none; }
.od-icon { --od-icon-size: 16px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { width: 28px; min-height: 28px; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono, kbd, .badge.numeric, .header-stats dd, .rom-identity, .arch-chain-count, .arch-range output, #search-status, #arch-zoom-readout, .canvas-footnote, .arch-inventory-table td, .arch-box-sub, .arch-box-tag, .arch-badge text {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.app {
  display: flex; flex-direction: column; height: 100dvh; min-height: 0; margin: 0; padding: 0;
  --address-width: 344px; --arch-width: 360px;
}
.app-header {
  display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center; gap: var(--s2); flex: 0 0 var(--shell-height); min-height: var(--shell-height);
  padding: 0 var(--s4); margin: 0; z-index: 30; background: var(--chrome); border-bottom: 1px solid var(--border);
}
.shell-start, .shell-end, .brand { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.shell-end { justify-content: flex-end; gap: var(--s2); }
.brand { flex: none; gap: var(--s2); }
.brand h1 { font-size: 16px; font-weight: 690; letter-spacing: -.025em; line-height: 1; white-space: nowrap; }
.brand-icon { display: grid; place-items: center; width: 28px; height: 28px; color: var(--focus); background: var(--accent-surface); border: 1px solid color-mix(in srgb, var(--focus) 45%, var(--border)); border-radius: var(--r2); }
.brand-icon .od-icon { --od-icon-size: 18px; }
.rom-switcher { display: inline-flex; align-items: center; gap: var(--s2); position: relative; min-width: 0; min-height: 28px; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); background: var(--bg); cursor: pointer; }
.rom-switcher:hover { border-color: var(--border-strong); }
.rom-switcher:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.rom-switcher select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.rom-switcher .od-icon { --od-icon-size: 12px; color: var(--muted); }
.rom-identity { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-xs); white-space: nowrap; }
.identity-chip { padding: 1px var(--s1); border-radius: var(--r1); background: var(--accent-surface); color: var(--focus); font-weight: 700; }
.identity-secondary { color: var(--muted); }
.view-tabs { flex: none; display: flex; align-items: center; padding: 2px; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r2); }
.view-tab { min-height: 26px; padding: 0 var(--s3); gap: var(--s2); border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 550; }
.view-tab[aria-selected="true"] { border-color: var(--border); border-radius: var(--r1); color: var(--text); background: var(--surface-raised); }
.view-tab[aria-selected="true"] .od-icon { color: var(--focus); }
.view-tab .od-icon { --od-icon-size: 14px; }
.header-stats { display: flex; align-items: center; justify-content: flex-end; gap: 0; margin: 0; }
.header-stats div { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0 var(--s3); border-right: 1px solid var(--border); }
.header-stats dt { font-size: 10px; letter-spacing: .025em; color: var(--muted); line-height: 1.15; }
.header-stats dd { margin: 0; font-size: var(--text-xs); line-height: 1.4; font-weight: 620; color: var(--text); }
.top-popover { flex: none; position: relative; }
.top-popover > summary, .legend-disclosure > summary, .arch-step-drawer > summary { display: flex; align-items: center; gap: var(--s1); min-height: 28px; white-space: nowrap; list-style: none; }
.top-popover > summary::-webkit-details-marker, .legend-disclosure > summary::-webkit-details-marker, .arch-step-drawer > summary::-webkit-details-marker { display: none; }
.top-popover > summary { padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); color: var(--muted); background: var(--surface); font-weight: 580; }
.top-popover > summary:hover { border-color: var(--border-strong); background: var(--band); }
.top-popover[open] > summary { color: var(--focus); border-color: var(--focus); }
.popover-body, .arch-catalog, .arch-results { position: absolute; z-index: 20; top: calc(100% + var(--s2)); right: 0; margin: 0; max-height: min(70vh, 488px); overflow: auto; color: var(--text); background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--r2); box-shadow: var(--shadow); animation: enter var(--motion) var(--ease-out); }
@keyframes enter { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.rom-info-content { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--s4); width: min(448px, 90vw); padding: var(--s4); }
.rom-info-list { display: grid; grid-template-columns: 116px minmax(0,1fr); gap: var(--s1) var(--s3); }
.rom-info-section h2 { margin-bottom: var(--s2); font-size: var(--text-ui); }
.rom-info-list dd { overflow-wrap: anywhere; }
.theme-options { min-width: 112px; padding: var(--s1); }
.theme-options button { width: 100%; justify-content: flex-start; border-color: transparent; background: transparent; }
.theme-options button[aria-pressed="true"] { color: var(--focus); background: var(--accent-surface); }
.warnings {
  position: fixed;
  top: calc(var(--shell-height) + var(--s2));
  right: var(--s4);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  width: min(420px, calc(100vw - 32px));
  margin: 0;
  padding: var(--s2) var(--s3);
  border: 1px solid color-mix(in srgb, var(--warning-fg) 38%, var(--border));
  border-radius: var(--r2);
  background: var(--warning-bg);
  color: var(--warning-fg);
  box-shadow: var(--shadow);
  animation: enter var(--motion) var(--ease-out);
}
.warnings .warnings-icon { --od-icon-size: 15px; flex: none; margin-top: 2px; }
.warnings-body { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.warnings h2 { flex: none; margin: 0; font-size: var(--text-xs); font-weight: 680; letter-spacing: .04em; text-transform: uppercase; line-height: 1.4; }
.warnings ul { display: grid; gap: 2px; margin: 0; padding: 0; color: inherit; font-size: var(--text-xs); line-height: 1.45; list-style: none; }
.warnings-dismiss {
  flex: none;
  width: 22px;
  min-height: 22px;
  padding: 0;
  margin: -2px -4px 0 0;
  border: 1px solid transparent;
  border-radius: var(--r1);
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
}
.warnings-dismiss:hover {
  border-color: color-mix(in srgb, var(--warning-fg) 35%, transparent);
  background: color-mix(in srgb, var(--warning-fg) 12%, transparent);
}
#boot-error { padding: var(--s4); background: var(--warning-bg); color: var(--warning-fg); }
.view { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: var(--s2); min-width: 0; min-height: var(--toolbar-height); margin: 0; padding: var(--s1) var(--s4); border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--chrome); }
.address-toolbar { z-index: 12; }
.command-field { display: flex; align-items: center; gap: var(--s1); min-width: 0; height: 30px; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); color: var(--muted); background: var(--bg); }
.command-field:focus-within { border-color: var(--focus); }
.command-field input { flex: 1 1 auto; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text); outline: none; }
.command-field input:focus-visible { outline: none; }
.command-field input[type="search"]::-webkit-search-decoration { display: none; }
.command-field .od-icon { --od-icon-size: 14px; flex: none; }
.address-search { flex: 1 1 236px; max-width: 328px; min-width: 168px; }
.jump-field { flex: 0 1 148px; min-width: 112px; font-size: var(--text-xs); }
.jump-field > span { white-space: nowrap; }
.jump-field input { font-family: var(--font-mono); }
#search-status { display: inline-block; min-width: 0; color: var(--focus); font-size: 10px; white-space: nowrap; }
#search-status:empty { display: none; }
#search-status:not(:empty) + kbd { display: none; }
kbd { display: inline-flex; align-items: center; gap: var(--s1); padding: 0 var(--s1); border: 1px solid var(--border); border-radius: 3px; color: var(--muted); background: var(--surface); font-size: var(--text-xs); line-height: 1.45; }
.layer-filters { display: flex; flex: 0 0 auto; flex-wrap: nowrap; gap: var(--s1); min-width: 0; padding-left: var(--s1); }
.layer-filter { display: inline-flex; position: relative; align-items: center; gap: var(--s1); min-height: 26px; padding: 0 var(--s1) 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); color: var(--text); background: var(--surface); cursor: pointer; font-size: var(--text-xs); white-space: nowrap; }
.layer-filter strong { font: 600 10px var(--font-mono); color: var(--layer-color); }
.layer-filter input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.layer-filter::before { content: ""; width: 7px; height: 7px; flex: none; border: 1px solid var(--layer-color); border-radius: 50%; background: var(--layer-color); }
.layer-filter:has(input:not(:checked)) { background: transparent; color: var(--muted); }
.layer-filter:has(input:not(:checked))::before { background: transparent; }
.layer-filter:focus-within, .layer-filter:hover { border-color: var(--layer-color); }
.semantic-toggle { display: inline-flex; align-items: center; gap: var(--s2); padding: 0; min-height: 24px; color: var(--text); font-size: var(--text-sm); line-height: 1.25; cursor: pointer; white-space: nowrap; }
.semantic-toggle input { appearance: none; position: relative; display: block; width: 24px; height: 14px; margin: 0; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--band); cursor: pointer; }
.semantic-toggle input::before { content: ""; display: block; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: transform var(--motion) var(--ease-out); }
.semantic-toggle input:checked { background: var(--focus); border-color: var(--focus); }
.semantic-toggle input:checked::before { transform: translateX(10px); background: var(--accent-ink); }
.reviewed-toggle { margin-left: auto; padding-left: var(--s2); }
.overview-section { display: flex; position: relative; align-items: stretch; flex: 0 0 var(--overview-height); min-height: var(--overview-height); margin: 0; padding: 0 var(--s4) 0 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--bg); }
.overview-label { align-self: center; display: grid; flex: 0 0 120px; gap: 2px; padding-left: var(--s4); }
.overview-label h2 { margin: 0; font-size: var(--text-sm); font-weight: 670; }
.overview-label > span { color: var(--muted); font-family: var(--font-mono); font-size: 10px; }
#overview { display: block; flex: 1 1 auto; width: 0; height: 100%; min-width: 0; margin: 0; border: 0; border-radius: 0; background: var(--bg); cursor: grab; }
#overview:active { cursor: grabbing; }
.workspace { display: grid; grid-template-columns: minmax(0,1fr) var(--inspector-width); flex: 1 1 auto; align-items: stretch; gap: 0; min-height: 0; width: 100%; }
.address-workspace { --inspector-width: var(--address-width); }
.arch-workspace { --inspector-width: var(--arch-width); }
.workspace.is-closed { grid-template-columns: minmax(0,1fr); }
.map-panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--canvas); }
.canvas-heading { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex: 0 0 auto; min-height: 64px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); }
.canvas-kicker, .eyebrow { display: block; color: var(--muted); font-size: var(--text-xs); font-weight: 650; line-height: 1.35; letter-spacing: .10em; text-transform: uppercase; overflow-wrap: anywhere; }
.canvas-heading h2, #arch-title { margin: 0; color: var(--text); font-size: var(--text-title); font-weight: 650; letter-spacing: -.028em; line-height: 1.1; }
.canvas-heading-end { display: flex; align-items: center; gap: var(--s2); }
.viewport-readout { padding: var(--s1) var(--s2); color: var(--muted); border: 1px solid var(--border); border-radius: var(--r1); font-size: var(--text-xs); white-space: nowrap; }
.inspector-reopen { display: none; flex: none; }
.workspace.is-closed .inspector-reopen { display: inline-flex; }
#address-map { display: block; flex: 1 1 auto; min-height: 0; width: 100%; height: 0; border: 0; background: var(--canvas); }
#address-map .lane-bg { fill: var(--surface); }
#address-map .lane-bg.is-alt { fill: var(--canvas); }
#address-map .lane-header { fill: var(--bg); }
#address-map .ruler-bg { fill: var(--band); }
#address-map .lane-count { fill: var(--muted); font: 10px var(--font-mono); pointer-events: none; }
#address-map .lane-label { font-size: 12px; }
#address-map .mark:hover { stroke: var(--text); stroke-width: 1.2px; opacity: 1; }
#address-map .mark.is-selected { stroke: var(--selection); stroke-width: 1.5px; }
.selection-guide { stroke: var(--patches); stroke-dasharray: 4 4; opacity: .82; }
.address-callout rect { fill: var(--surface-raised); stroke: var(--patches); }
.address-callout text { fill: var(--text); font: 11px var(--font-mono); }
.address-callout { pointer-events: none; }
.canvas-footnote { display: flex; position: absolute; bottom: var(--s3); left: var(--s4); align-items: center; gap: var(--s2); min-height: 28px; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r1); color: var(--muted); background: var(--bg); font-size: 10px; pointer-events: none; }
.live-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--axes); }
.footnote-separator { height: 12px; border-left: 1px solid var(--border-strong); }
.canvas-hud { position: absolute; z-index: 4; right: var(--s4); bottom: var(--s3); display: flex; align-items: center; gap: 0; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface-raised); box-shadow: var(--shadow); }
.canvas-hud button, .canvas-hud button:first-child, .canvas-hud button:nth-child(2) { min-width: 28px; min-height: 26px; padding: 0 var(--s2); border: 1px solid transparent; background: transparent; font-size: var(--text-xs); }
.canvas-hud button:hover { border-color: var(--border); background: var(--band); }
.canvas-hud button .od-icon { --od-icon-size: 14px; }
.canvas-hud button:is(#full-view,#arch-fit,#arch-zoom-selection) { border-left-color: var(--border); border-radius: 0 var(--r1) var(--r1) 0; }

.inspector { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--border); background: var(--surface); }
.inspector-head { display: flex; flex: 0 0 40px; align-items: center; gap: var(--s2); padding: 0 var(--s4); border-bottom: 1px solid var(--border); background: var(--chrome); color: var(--muted); font-size: var(--text-sm); }
.inspector-head strong { color: var(--text); font-size: var(--text-ui); font-weight: 650; }
.inspector-head > span { margin-left: auto; color: var(--faint); }
.inspector-head button { margin-left: var(--s1); }
.inspector-head .reference-copy { flex: none; gap: var(--s1); min-height: 26px; padding-inline: var(--s2); font-size: var(--text-xs); }
.reference-copy .od-icon { --od-icon-size: 13px; }
.reference-copy.is-copied { color: var(--focus); }
.reference-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: var(--s4); border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.reference-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.reference-dialog h2 { margin: 0 0 var(--s2); font-size: var(--text-ui); }
.reference-dialog p { margin: 0 0 var(--s3); }
.reference-dialog textarea { display: block; width: 100%; padding: var(--s2); border: 1px solid var(--border-strong); border-radius: var(--r1); background: var(--bg); color: var(--text); font: var(--text-sm)/1.5 var(--font-mono); }
.reference-dialog form { margin-top: var(--s3); text-align: right; }
.inspector-resizer { display: block; position: absolute; z-index: 6; top: 0; bottom: 0; left: -4px; width: 8px; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: col-resize; touch-action: none; }
.inspector-resizer:hover, .inspector-resizer.is-resizing, .inspector-resizer:focus-visible { background: color-mix(in srgb, var(--focus) 35%, transparent); }
.details, .arch-details { position: static; flex: 1 1 auto; min-height: 0; max-height: none; margin: 0; padding: var(--s4); overflow: auto; border: 0; border-radius: 0; background: var(--surface); box-shadow: none; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
#details-content { display: flex; flex-direction: column; min-height: 100%; }
.details-heading { align-items: flex-start; margin-bottom: var(--s4); }
.details-heading > div { min-width: 0; }
.details-heading h2 { margin-top: var(--s1); color: var(--text); font-size: 22px; line-height: 1.18; font-weight: 660; letter-spacing: -.024em; overflow-wrap: anywhere; }
.details-heading button { flex: none; min-height: 26px; }
.details-empty { padding: var(--s4) 0; }
.details-empty h2 { margin: var(--s3) 0 var(--s2); color: var(--text); font-size: 19px; }
.details-empty p { line-height: 1.55; }
.empty-mark { display: grid; place-items: center; width: 36px; height: 36px; color: var(--focus); background: var(--accent-surface); border: 1px solid var(--border); border-radius: var(--r2); }
#recent-jumps { display: grid; gap: var(--s2); margin-top: var(--s4); }
#recent-jumps button { justify-content: flex-start; white-space: normal; text-align: left; }
.range-panel { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--s1) var(--s2); align-items: center; margin: 0 0 var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r2); background: var(--bg); }
.range-panel > span:first-child { grid-column: 1/-1; color: var(--muted); font-size: 10px; font-weight: 670; letter-spacing: .1em; }
.range-panel .detail-range { margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; min-height: 20px; padding: 1px var(--s2); color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: var(--r1); font-size: var(--text-xs); line-height: 1.3; }
.badge.size-badge { font-family: var(--font-mono); color: var(--focus); background: var(--accent-surface); border-color: color-mix(in srgb, var(--focus) 45%, var(--border)); }
.detail-badges { margin-bottom: var(--s4); gap: var(--s1); }
.detail-badges .badge:first-child { border-color: color-mix(in srgb, var(--patches) 50%, var(--border)); color: var(--patches); }
.detail-section, .arch-detail-section { margin: 0; padding: var(--s3) 0; border-top: 1px solid var(--border); }
.detail-section h3, .arch-detail-section h3, .arch-detail-section.is-collapsible > summary { margin: 0 0 var(--s2); font-size: var(--text-xs); line-height: 1.35; font-weight: 680; letter-spacing: .085em; color: var(--muted); text-transform: uppercase; }
.detail-meta { grid-template-columns: minmax(82px,.44fr) minmax(0,1fr); margin: 0 0 var(--s2); padding: 0; gap: 0 var(--s3); border: 0; font-size: var(--text-sm); line-height: 1.42; }
.detail-meta > :is(dt,dd) { min-width: 0; padding: var(--s1) 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.detail-meta > :nth-last-child(-n+2) { border-bottom: 0; }
.detail-copy { margin: 0 0 var(--s3); font-size: var(--text-sm); line-height: 1.58; overflow-wrap: anywhere; }
.detail-section .detail-copy:last-child { margin-bottom: 0; }
.detail-related { margin: 0; }
.detail-related button { justify-content: flex-start; min-height: 26px; max-width: 100%; padding: 0 var(--s2); overflow-wrap: anywhere; white-space: normal; text-align: left; }
.detail-provenance { display: flex; align-items: flex-start; gap: var(--s2); margin-top: auto; padding-top: var(--s4); color: var(--muted); }
.detail-provenance .od-icon { --od-icon-size: 14px; }
.detail-source { margin: 0; padding: 0; border: 0; }
.arch-actions { margin: var(--s2) 0 var(--s3); }
.arch-actions button.is-primary { color: var(--accent-ink); }
.arch-coverage-table { table-layout: auto; width: 100%; margin-top: var(--s2); font-family: var(--font-mono); font-size: 10px; }
.arch-coverage-table :is(td,th) { padding: var(--s1) 3px; text-align: right; }
.arch-coverage-table :is(td,th):first-child { text-align: left; }
.arch-coverage-list { overflow-wrap: anywhere; }
.coverage-cell { display: grid; gap: 2px; }
.coverage-cell progress { display: block; width: 100%; height: 3px; accent-color: var(--axes); }
.arch-node-link { display: flex; justify-content: flex-start; white-space: normal; text-align: left; overflow-wrap: anywhere; }
.arch-inline-link { white-space: normal; }

/* Architecture workbench */
.arch-panel { overflow: hidden; }
.arch-toolbar {
  position: absolute; top: 0; left: 0; z-index: 10; width: 100%; flex-wrap: nowrap;
  gap: var(--s2); padding-right: var(--s3);
  background: color-mix(in srgb, var(--chrome) 94%, var(--canvas));
}
.arch-search-field { flex: 0 1 214px; width: 214px; min-width: 132px; }
.arch-search-field input { font-size: var(--text-sm); }
.arch-results { left: 0; right: auto; width: min(392px, 87vw); max-height: min(52vh, 416px); padding: var(--s1); }
.arch-result { display: grid; justify-items: start; align-items: center; grid-template-columns: 68px minmax(0,1fr); column-gap: var(--s2); width: 100%; min-height: 36px; padding: var(--s1) var(--s2); border: 0; border-radius: var(--r1); background: transparent; text-align: left; }
.arch-result.is-active, .arch-result:hover { background: var(--accent-surface); }
.arch-result-kind { color: var(--focus); font: 10px var(--font-mono); text-transform: uppercase; }
.arch-result-label { color: var(--text); font-size: var(--text-sm); }
.arch-result-detail { color: var(--muted); font: 10px var(--font-mono); }
.result-group-label { padding: var(--s2) var(--s2) var(--s1); border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.result-empty { padding: var(--s3); color: var(--muted); white-space: normal; }
.arch-chains { position: relative; min-width: 0; margin: 0; padding: 0; border: 0; background: transparent; }
#arch-catalog-toggle { display: flex; min-height: 28px; max-width: 148px; gap: var(--s1); color: var(--text); font-size: var(--text-sm); }
#arch-catalog-toggle .od-icon { --od-icon-size: 13px; color: var(--focus); }
#arch-catalog-toggle[aria-expanded="true"] { color: var(--focus); border-color: var(--focus); background: var(--accent-surface); }
.arch-catalog { left: 0; right: auto; width: min(320px, 84vw); max-height: min(62vh, 516px); padding: var(--s2); }
.popover-heading { padding: var(--s1) var(--s2) var(--s2); color: var(--text); font-weight: 670; }
.arch-catalog .command-field { margin: 0 0 var(--s2); }
.arch-catalog-group { margin: var(--s1) 0 0; }
.arch-catalog-group h3 { margin: 0; padding: var(--s1) var(--s2); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .10em; }
.arch-catalog-chain { display: flex; width: 100%; justify-content: space-between; gap: var(--s2); min-height: 28px; padding: var(--s1) var(--s2); margin: 0; border: 1px solid transparent; background: transparent; font-size: var(--text-sm); text-align: left; white-space: normal; }
.arch-catalog-chain[aria-current] { border-color: var(--border); color: var(--focus); background: var(--accent-surface); }
.arch-chain-count { flex: none; min-width: 18px; padding: 0 var(--s1); border-radius: var(--r1); color: var(--warning-fg); background: var(--warning-bg); font-size: 10px; text-align: center; }
#arch-unavailable-chains { position: sticky; bottom: 0; margin: var(--s2) calc(-1 * var(--s2)) calc(-1 * var(--s2)); padding: 0 var(--s2) var(--s1); border-top: 1px solid var(--border); background: var(--surface-raised); }
#arch-unavailable-chains summary { padding: var(--s2); color: var(--muted); font-weight: 600; }
#arch-no-chains { padding: var(--s2); }
.arch-filters { display: flex; align-items: center; flex: 1 1 340px; flex-wrap: nowrap; min-width: 0; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 2px var(--s1); gap: var(--s1); }
.arch-filter-chip { flex: none; min-height: 24px; padding: 0 var(--s2); margin: 0; border-color: var(--border); color: var(--muted); font-size: var(--text-xs); }
.arch-filter-chip.is-active { border-color: var(--focus); color: var(--focus); background: var(--accent-surface); font-weight: 650; }
.arch-filter-chip:disabled { border-color: var(--border); color: var(--muted); }
#arch-focus { flex: none; margin-left: auto; }
#arch-focus:empty { display: none; }
.display-menu > summary { font-size: var(--text-sm); }
.arch-options { display: grid; justify-content: stretch; gap: var(--s1); width: min(232px, 86vw); padding: var(--s2); }
.arch-options .semantic-toggle { padding: var(--s1) var(--s2); }
.arch-layout-option { display: grid; gap: var(--s1); padding: var(--s2); border-top: 1px solid var(--border); }
.arch-layout-option > span { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.arch-layout-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s1); }
.arch-layout-buttons button { min-width: 0; min-height: 24px; padding: 0 4px; font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; }
.arch-layout-buttons button[aria-pressed="true"] { border-color: var(--focus); color: var(--focus); background: var(--accent-surface); font-weight: 640; }
.arch-range { display: grid; grid-template-columns: 36px minmax(0,1fr) 28px; align-items: center; gap: var(--s2); margin: var(--s1) 0 0; padding: var(--s2); border-top: 1px solid var(--border); }
.arch-range input { width: 100%; accent-color: var(--focus); }
.arch-range output { margin: 0; color: var(--focus); text-align: right; }
.arch-heading {
  display: grid; position: absolute; z-index: 2; top: var(--toolbar-height); left: 0; right: 0;
  gap: var(--s1); min-height: 0; margin: 0; padding: var(--s2) var(--s4) 0;
  pointer-events: none;
}
.arch-heading :is(button, a, .arch-crumb) { pointer-events: auto; }
.arch-crumbs { display: flex; align-items: center; gap: var(--s1); min-height: 19px; min-width: 0; margin: 0; font-size: var(--text-xs); line-height: 1.2; }
.arch-crumb { flex: none; min-height: 20px; padding: 0 var(--s1); border: none; color: var(--focus); background: transparent; font-size: var(--text-xs); }
.arch-crumb:is(.is-current,.is-plain) { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; padding: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arch-crumb.is-current { display: block; padding-block: 3px; color: var(--text); font-weight: 620; }
.arch-crumb-separator { color: var(--muted); }
.arch-title-row { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
#arch-title { overflow-wrap: anywhere; }
#arch-mode-chip { flex: none; font: 10px var(--font-mono); }
#arch-subtitle, .arch-banner { color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
#arch-subtitle { max-width: 104ch; margin: 0; }
.arch-banner { display: block; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; }
.arch-banner[data-mode] { background: none; }
.arch-banner:empty, .arch-banner[data-compact="true"] { display: none; }
.arch-banner .arch-notice { padding: 1px var(--s1); color: var(--warning-fg); background: var(--warning-bg); }
.arch-canvas-frame { position: relative; flex: 1 1 auto; min-height: 0; }
.arch-canvas { display: block; width: 100%; height: 100%; border: 0; background-color: var(--canvas); background-image: radial-gradient(circle, var(--dot-grid) 1px, transparent 1px); background-size: 16px 16px; }
.arch-canvas:focus-visible, #address-map:focus-visible { outline-offset: -2px; }
.arch-column-label { fill: var(--text); font: 700 13px var(--font-mono); letter-spacing: .015em; }
.arch-column-sub { fill: var(--muted); font-size: 12px; }
.arch-support-band { fill: var(--band); fill-opacity: .62; stroke: var(--border-strong); }
.arch-box-frame { fill: var(--surface-raised); stroke: var(--border-strong); }
.arch-box-bar { fill: var(--node-tone, var(--structure)); }
.arch-box.endpoint-input { --node-tone: var(--endpoint-in); }
.arch-box.endpoint-output, .arch-box.endpoint-bidirectional { --node-tone: var(--endpoint-out); }
.arch-box.kind-map { --node-tone: var(--maps); }
.arch-box.kind-axis { --node-tone: var(--axes); }
.arch-box.kind-signal, .arch-box.kind-ram { --node-tone: var(--signal); }
.arch-box.kind-register { --node-tone: var(--register); }
.arch-box .arch-box-bar { fill: var(--node-tone, var(--structure)); }
.arch-box-title { font-size: 13px; fill: var(--text); }
.arch-box-sub { font-size: 11px; fill: var(--muted); }
.arch-box-tag { font-size: 10px; fill: var(--muted); }
.arch-box.is-empty:not(.is-selected,.is-dimmed) { opacity: .72; }
.arch-box.is-empty .arch-box-frame { stroke-dasharray: 3 2; }
.arch-box.is-selected .arch-box-frame { stroke: var(--focus); stroke-width: 2; fill: color-mix(in srgb, var(--accent-surface) 72%, var(--surface-raised)); }
.arch-box.is-related .arch-box-frame, .arch-box.is-hover-related .arch-box-frame { stroke: var(--focus); stroke-width: 1.5; }
.arch-box.is-hover-related { opacity: 1; }
.arch-meter-track { fill: var(--border); }
.arch-meter-fill { fill: var(--axes); }
.arch-flow { opacity: .66; }
.arch-flow.is-dimmed { opacity: .44; }
.arch-flow.is-spec { stroke-dasharray: 6 4; }
.arch-flow.is-hover-related, .arch-link.is-hover-related { stroke: var(--focus); opacity: 1; }
.arch-link.is-selected, .arch-link.is-selected.is-hover-related { stroke: var(--selection); opacity: 1; }
.arch-flow.is-hover-muted, .arch-link.is-hover-muted { opacity: .20; }
.arch-badge rect { fill: var(--sign-none); }
.arch-badge.sign-positive rect { fill: var(--sign-positive); }
.arch-badge.sign-negative rect { fill: var(--sign-negative); }
.arch-badge.sign-mixed rect { fill: var(--sign-mixed); }
.arch-badge.sign-output rect { fill: var(--focus); }
.arch-badge text { fill: var(--sign-ink); font-size: 14px; font-weight: 800; }
.arch-edge-label rect { fill: var(--surface-raised); }
.arch-edge-label text { fill: var(--text); }
.arch-minimap { top: auto; right: var(--s4); bottom: 52px; z-index: 3; padding: var(--s1); }
#arch-zoom-readout { padding: 0 var(--s2); color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.legend-disclosure, .arch-step-drawer { position: absolute; z-index: 5; bottom: var(--s3); left: var(--s4); border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface-raised); box-shadow: var(--shadow); }
.legend-disclosure > summary, .arch-step-drawer > summary { min-height: 30px; padding: 0 var(--s2); color: var(--muted); font-size: var(--text-xs); }
.legend-disclosure > summary .od-icon { --od-icon-size: 13px; }
.legend-disclosure > summary .od-icon:last-child { --od-icon-size: 11px; }
.legend-disclosure .arch-legend { position: absolute; bottom: calc(100% + 6px); left: 0; display: grid; gap: var(--s2); width: max-content; max-width: min(84vw, 308px); margin: 0; padding: var(--s3); color: var(--text); background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--r2); box-shadow: var(--shadow); }
.arch-legend-item { white-space: normal; line-height: 1.3; }
.arch-step-drawer { left: 104px; }
.arch-step-drawer .arch-table { position: absolute; bottom: calc(100% + 6px); left: 0; width: min(690px, 70vw); margin: 0; padding: var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface-raised); box-shadow: var(--shadow); }
.arch-table-title { margin-bottom: var(--s2); gap: var(--s2); }
.arch-panel[data-scene="inventory"] .arch-toolbar,
.arch-panel[data-scene="inventory"] .arch-heading { position: relative; inset: auto; }
.arch-panel[data-scene="inventory"] .arch-heading { padding-bottom: var(--s3); }
.arch-panel[data-scene="inventory"] .arch-search-field { flex-basis: 276px; width: 276px; }
.arch-panel[data-scene="inventory"] .display-menu { margin-left: auto; }
.arch-panel[data-scene="inventory"] .display-menu:has(.semantic-toggle[hidden]):not(:has(.semantic-toggle:not([hidden]))) { display: none; }
.arch-block-inventory { display: flex; flex: 1; flex-direction: column; gap: var(--s3); min-height: 0; margin: 0; padding: 0 var(--s4) var(--s3); }
.inventory-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 32px; }
.inventory-tools .command-field { flex: 0 1 272px; }
.inventory-count { color: var(--muted); font: var(--text-xs) var(--font-mono); }
.arch-inventory-table { min-height: 0; max-height: none; margin: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface); }
.arch-inventory-table table { width: 100%; min-width: 528px; border-collapse: separate; border-spacing: 0; }
.arch-inventory-table thead { position: sticky; z-index: 1; top: 0; color: var(--muted); background: var(--band); }
.arch-inventory-table thead th { padding: 0 4px; border-bottom: 1px solid var(--border-strong); }
.arch-inventory-table thead button { justify-content: flex-start; min-height: 28px; width: 100%; padding: 0 var(--s2); border-color: transparent; color: var(--text); background: transparent; text-transform: uppercase; font-size: 10px; letter-spacing: .07em; }
.arch-inventory-table th[aria-sort="ascending"] button::after { content: "▲"; color: var(--focus); }
.arch-inventory-table th[aria-sort="descending"] button::after { content: "▼"; color: var(--focus); }
.arch-inventory-table :is(th,td) { text-align: left; }
.arch-inventory-table tbody :is(th,td) { padding: var(--s1) var(--s3); border-bottom: 1px solid var(--border); font-size: var(--text-xs); line-height: 1.25; }
.arch-inventory-table tbody th { width: 37%; padding: 0; }
.arch-inventory-table tbody tr:last-child > * { border-bottom: 0; }
.arch-inventory-table tbody tr:nth-child(even) { background: var(--bg); }
.arch-inventory-table tbody tr:hover, .arch-inventory-table tbody tr:has([aria-pressed="true"]) { background: var(--accent-surface); }
.arch-inventory-name, .arch-inventory-name[aria-pressed="true"] { display: flex; justify-content: flex-start; width: 100%; min-height: 29px; padding: var(--s1) var(--s3); border: 0; border-radius: 0; color: var(--text); background: transparent; font-size: var(--text-sm); line-height: 1.25; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.arch-inventory-name[aria-pressed="true"] { box-shadow: inset 2px 0 var(--focus); color: var(--focus); font-weight: 640; }
.arch-inventory-table .inventory-kind { color: var(--tone, var(--muted)); font-size: 10px; text-transform: uppercase; }

.tooltip { z-index: 70; width: max-content; max-width: min(304px, calc(100vw - 24px)); padding: var(--s2) var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface-raised); box-shadow: var(--shadow); pointer-events: none; }
.tooltip strong { color: var(--text); font-size: var(--text-sm); line-height: 1.35; overflow-wrap: anywhere; }
.tooltip span { margin-top: var(--s1); color: var(--muted); font: var(--text-xs)/1.42 var(--font-mono); overflow-wrap: anywhere; }
@media (max-width: 1320px) {
  .header-stats div { padding: 0 var(--s2); }
  .command-field .search-shortcut { display: none; }
  .optional-caption { display: none; }
  .arch-search-field { flex-basis: 176px; }
  .arch-filter-chip { padding-inline: 5px; }
}
@media (max-width: 1120px) {
  .header-stats div:first-child { display: none; }
  .layer-filter strong { display: none; }
  .app-header { padding-inline: var(--s3); }
  .toolbar { padding-inline: var(--s3); }
  .arch-heading { padding-inline: var(--s3); }
  .identity-secondary { display: none; }
}
@media (max-width: 940px) {
  .header-stats { display: none; }
  #arch-focus .arch-filter-chip { max-width: 108px; }
  .arch-toolbar { gap: var(--s1); }
  .rom-info-label { display: none; }
}
@media (max-width: 760px) {
  .app { height: auto; min-height: 100dvh; }
  .app-header { grid-template-columns: minmax(0,1fr) auto; gap: var(--s1) var(--s2); padding-block: var(--s1); }
  .shell-start { grid-column: 1; grid-row: 1; }
  .shell-end { grid-column: 2; grid-row: 1; }
  .view-tabs { grid-column: 1/-1; grid-row: 2; justify-content: center; }
  .view-tab { flex: 1; min-height: 36px; }
  .theme-menu > summary, #rom-info > summary, .rom-switcher { min-height: 36px; }
  .toolbar { flex-wrap: wrap; padding-block: var(--s2); }
  .address-search, .jump-field { flex: 1 1 128px; min-width: 128px; }
  .layer-filters { flex: 1 1 auto; order: 2; max-width: 100%; overflow-x: auto; scrollbar-width: thin; padding: 2px; }
  .reviewed-toggle { order: 3; margin-left: auto; }
  .overview-label { flex-basis: 90px; padding-left: var(--s3); }
  .workspace { grid-template-columns: minmax(0,1fr); }
  .inspector { min-height: 280px; max-height: 70vh; border-left: 0; border-top: 1px solid var(--border); }
  .inspector-resizer { display: none; }
  .canvas-heading { min-height: 54px; padding-inline: var(--s3); }
  .canvas-heading h2, #arch-title { font-size: 20px; }
  .viewport-readout { padding-inline: var(--s1); font-size: 9px; }
  #address-map { flex: none; height: 500px; }
  .canvas-footnote { display: none; }
  .arch-panel { min-height: 586px; }
  .arch-toolbar { position: relative; inset: auto; z-index: 12; }
  .arch-heading { position: relative; inset: auto; padding-bottom: var(--s2); }
  .arch-filters { order: 2; flex: 1 1 100%; }
  .arch-catalog { left: -56px; }
  .arch-canvas-frame { flex: none; height: 475px; }
  .arch-block-inventory { flex: none; height: 550px; }
  .arch-step-drawer .arch-table { left: -89px; width: min(670px, 92vw); }
}
@media (max-width: 400px) {
  .arch-search-field { flex-basis: 145px; width: 145px; }
  #arch-catalog-toggle { max-width: 108px; }
  .warnings { right: var(--s2); width: calc(100vw - 16px); }
  .canvas-heading { gap: var(--s1); }
  .viewport-readout { max-width: 36vw; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.inventory-pager { justify-content: flex-end; }
.inventory-pager button { min-height: 24px; font-size: var(--text-xs); }
.arch-result-detail { grid-column: 2; }


/* Text and panel sizing */
:root {
  --graph-label-pad: 14px;
  --graph-line-height: 14px;
}
.shell-start .rom-identity { min-width: 0; }
.identity-secondary { overflow: hidden; text-overflow: ellipsis; }
.header-stats dt, .header-stats dd { white-space: nowrap; }
.rom-info-content { width: min(448px, calc(100vw - 64px)); }
.rom-info-list dt, .warnings ul, .details .arch-coverage-list { min-width: 0; overflow-wrap: anywhere; }
.warnings h2 { white-space: nowrap; }
.command-field > input { min-width: 0; }
.semantic-toggle > input { flex: none; }
.inspector-head > strong, .inspector-head > button { flex: none; }
.inspector-head > span { min-width: 0; overflow-wrap: anywhere; }
.details .arch-actions > button, #recent-jumps button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.detail-badges .badge:first-child { color: var(--detail-tone, var(--muted)); border-color: color-mix(in srgb, var(--detail-tone, var(--border-strong)) 50%, var(--border)); }
.details .arch-coverage-table { table-layout: fixed; }
.details .arch-coverage-table th { overflow-wrap: anywhere; }
.details .arch-coverage-table td { white-space: nowrap; }
.details .arch-node-link { max-width: 100%; }
.range-panel .detail-range .mono { white-space: nowrap; }
.viewport-readout { display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: var(--s1); }
.viewport-readout > span { white-space: nowrap; }
#address-map .density-label, #address-map .mark-label {
  paint-order: stroke;
  stroke: var(--canvas);
  stroke-linejoin: round;
  stroke-width: 3px;
}
#address-map .mark-label { font: 10px var(--font-mono); }
#address-map .address-callout { pointer-events: none; }
#address-map [data-full-label], #arch-canvas [data-full-label] { pointer-events: visible; }

.arch-panel { container-type: inline-size; }
.arch-toolbar { min-width: 0; }
.arch-filters { flex: 0 1 auto; overflow: visible; padding: 0; }
.arch-filter-chip { white-space: nowrap; }
.stage-menu > summary { font-size: var(--text-xs); }
.stage-menu .popover-body { left: 0; right: auto; display: grid; gap: var(--s1); width: max-content; max-width: min(248px, calc(100vw - 32px)); padding: var(--s2); }
.stage-menu .arch-filter-chip { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }
.stage-menu .stage-primary { display: none; }
.stage-menu .stage-count { color: var(--focus); font-family: var(--font-mono); }
.arch-result { grid-template-columns: min(27%, 92px) minmax(0,1fr); align-items: start; }
.arch-result-kind { align-self: start; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.arch-result-label, .arch-result-detail { display: block; min-width: 0; max-width: 100%; }
.arch-result-detail { grid-column: 2; }
.arch-catalog-chain { align-items: baseline; }
.arch-catalog-chain .chain-name { min-width: 0; overflow-wrap: anywhere; }
.arch-catalog-chain .arch-chain-count { max-width: 45%; white-space: normal; }
#arch-catalog-toggle { min-width: 0; }
#arch-catalog-toggle > span { min-width: 0; }
.arch-heading { background: var(--canvas); }
.arch-crumbs { flex-wrap: wrap; }
.arch-crumb { max-width: min(30cqi, 252px); }
.arch-crumb :is(span,a) { min-width: 0; }
.arch-crumb.is-plain { display: block; }
.arch-crumb-separator { flex: none; }
.arch-title-row { flex-wrap: wrap; gap: var(--s1) var(--s3); }
#arch-title { min-width: 0; }
#arch-subtitle, .arch-banner { overflow-wrap: anywhere; }
.arch-box-title { font-size: 13px; }
.arch-box-sub, .arch-box-tag { font-variant-numeric: tabular-nums; }
.arch-badge text { font-size: 15px; }
.arch-edge-text { font-size: 10px; font-weight: 650; }
.arch-legend-item { min-width: 0; overflow-wrap: anywhere; }
.arch-legend-mark { flex-shrink: 0; }
.arch-step-drawer { --step-offset: 104px; left: var(--step-offset); }
.arch-step-drawer .arch-table { width: min(690px, calc(100cqi - 112px)); }
.arch-inventory-table table { table-layout: fixed; min-width: 566px; }
.arch-inventory-table :is(th,td):nth-child(1) { width: 34%; }
.arch-inventory-table :is(th,td):nth-child(2) { width: 12%; }
.arch-inventory-table :is(th,td):nth-child(3) { width: 17%; }
.arch-inventory-table :is(th,td):nth-child(4) { width: 12%; }
.arch-inventory-table :is(th,td):nth-child(5) { width: 11%; }
.arch-inventory-table :is(th,td):nth-child(6) { width: 14%; }
.arch-inventory-table tbody td { overflow-wrap: anywhere; }
.arch-inventory-table tbody td:nth-child(3) { white-space: nowrap; }
.arch-inventory-table thead button { white-space: normal; }
.tooltip { max-height: calc(100dvh - 24px); overflow: auto; }
.tooltip :is(strong,span) { min-width: 0; overflow-wrap: anywhere; }
.sheet-specimen, .swatch-item > span, .sheet-type > div > span, .sheet-table :is(th,td) { min-width: 0; overflow-wrap: anywhere; }
.sheet-link.sheet-primary { background: var(--focus); color: var(--accent-ink); }
.sheet-link.sheet-primary:hover { background: var(--focus); color: var(--accent-ink); }

@container (max-width: 1019px) {
  .arch-filters:not([hidden]) { display: none; }
  .stage-menu .stage-primary { display: inline-flex; }
}
@container (max-width: 660px) {
  .arch-search-field, .arch-chains, .arch-toolbar .top-popover { position: static; }
  .arch-search-field { flex: 1 1 130px; }
  .arch-catalog, .arch-results, .stage-menu .popover-body { left: var(--s3); right: var(--s3); width: auto; max-width: 380px; }
  .arch-toolbar .arch-options { right: var(--s3); }
  .arch-step-drawer { --step-offset: 16px; bottom: 52px; }
  .arch-step-drawer .arch-table { left: 0; width: min(690px, calc(100cqi - 32px)); }
}
@container (max-width: 460px) {
  .arch-toolbar { flex-wrap: wrap; }
  .arch-search-field { flex-basis: 100%; width: 100%; }
  #arch-catalog-toggle { max-width: 136px; }
  #arch-focus { margin-left: 0; }
  .arch-toolbar .icon-button { width: 26px; }
  .display-menu > summary { padding-inline: var(--s1); }
  .arch-title-row { align-items: flex-start; }
  .arch-crumb { max-width: min(35cqi, 166px); }
}
@media (max-width: 1080px) {
  .address-toolbar { flex-wrap: wrap; }
  .address-toolbar .layer-filters { order: 2; flex: 1 1 100%; flex-wrap: wrap; overflow: visible; padding-left: 0; }
  .address-toolbar .layer-filter strong { display: block; }
  .address-toolbar .reviewed-toggle { order: 0; }
}
@media (max-width: 760px) {
  .inspector-head { padding-inline: var(--s3); }
  .canvas-heading-end { min-width: 0; }
  .viewport-readout { max-width: min(52vw, 250px); text-align: right; }
  .arch-heading { padding-bottom: var(--s3); }
}
@media (max-width: 420px) {
  .inspector .details { padding-inline: var(--s3); }
  .inventory-tools { flex-wrap: wrap; gap: var(--s1) var(--s2); }
  .sheet-type > div { grid-template-columns: 84px minmax(0,1fr); }
}
.arch-heading { top: var(--arch-toolbar-size, var(--toolbar-height)); }
.lane-count { fill: var(--muted); font: 10px var(--font-mono); }
.lane-label { font-size: 12px; }
.mark-label { font: 10px var(--font-mono); }
.arch-chip-label { font-size: 10.5px; }
.arch-badge-label { font: 800 15px var(--font-mono); }

/* Flash search and cross-ROM bindings */
.address-search { position: relative; }
.address-search > .command-field { width: 100%; }
.address-results-panel {
  position: absolute;
  z-index: 22;
  top: calc(100% + var(--s2));
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(432px, calc(100vw - 32px));
  max-height: min(420px, 56dvh);
  padding: var(--s1);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r2);
  box-shadow: var(--shadow);
}
#address-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#address-results .result-group-label { margin-top: var(--s1); }
.address-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  justify-items: start;
  gap: var(--s1);
  width: 100%;
  padding: var(--s2);
  border-color: transparent;
  background: transparent;
  text-align: left;
  white-space: normal;
}
.address-result[aria-selected="true"], .address-result:hover {
  border-color: var(--border);
  background: var(--accent-surface);
}
.address-result > strong { overflow-wrap: anywhere; }
.address-result-range { color: var(--text); font-size: var(--text-xs); }
.address-result-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); color: var(--muted); font-size: var(--text-xs); }
#address-results-more { flex: none; margin-top: var(--s1); }

.rom-compare { margin-bottom: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--border); }
.rom-compare > summary { min-height: 28px; color: var(--text); font-weight: 620; }
.rom-compare > summary .badge { margin-left: var(--s2); vertical-align: middle; }
.rom-compare-scroll { max-height: 204px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: var(--r1); }
.rom-compare table { width: 100%; border-spacing: 0; font-size: var(--text-xs); }
.rom-compare thead { position: sticky; top: 0; z-index: 1; background: var(--band); }
.rom-compare :is(th, td) { padding: var(--s1); border-bottom: 1px solid var(--border); text-align: left; }
.rom-compare thead th { color: var(--muted); font-weight: 620; }
.rom-compare tbody th { font-weight: 620; }
.rom-compare tbody tr[aria-current="true"] { background: var(--accent-surface); }
.rom-compare tbody td:last-child { color: var(--muted); }
.rom-compare tbody td[data-state="Bound"] { color: var(--axes); }
.rom-compare tbody td[data-state="Unresolved"] { color: var(--warning-fg); }
.rom-compare-address { white-space: nowrap; }
.rom-compare-link {
  min-height: 20px;
  padding: 0;
  border: 0;
  color: var(--focus);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rom-compare-link:hover { background: transparent; text-decoration-thickness: 2px; }
.rom-compare-empty { padding: var(--s2) 0; border-top: 1px solid var(--border); }

/* Navigation and chain traversal */
.arch-crumbs { display: block; min-height: 24px; }
.arch-crumb-list {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.arch-crumb-item { display: flex; align-items: baseline; gap: var(--s2); min-width: 0; }
.arch-crumb-item:first-child:not(:only-child) { flex: none; }
.arch-crumb-item:last-child { flex: 0 1 auto; }
.arch-crumb-list .arch-crumb {
  display: block;
  min-width: 0;
  min-height: 0;
  max-width: none;
  padding: 0;
  border: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 24px;
}
.arch-crumb-list .arch-crumb-separator { color: var(--faint); line-height: 24px; }
.arch-crumb-list button.arch-crumb:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.chain-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin-top: var(--s1); }
.chain-navigation > button { min-height: 26px; font-size: var(--text-xs); }
.chain-route-modes { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.chain-route-modes button { min-height: 24px; padding: 0 var(--s2); font-size: var(--text-xs); }
.chain-route-modes button[aria-pressed="true"] { border-color: var(--focus); color: var(--focus); background: var(--accent-surface); }
.chain-route-status { color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.arch-panel[data-scene="chain"] .arch-flow.is-dimmed { opacity: .45; stroke-opacity: .46; }
.arch-panel[data-scene="chain"] .arch-flow.is-chain-path { opacity: 1; stroke-opacity: .94; stroke-width: 3px; }
.arch-panel[data-scene="chain"] .arch-flow.is-selected { opacity: 1; stroke-width: 3.6px; }
.arch-panel[data-scene="chain"] .arch-box.is-dimmed { opacity: .52; }
.arch-panel[data-scene="chain"] .arch-box.is-chain-path:not(.is-selected) .arch-box-frame {
  stroke: color-mix(in srgb, var(--focus) 70%, var(--border-strong));
}
.arch-panel[data-scene="chain"] .arch-edge-label.is-off-path { opacity: .42; }
.chain-step-adjacency { display: grid; gap: var(--s1); }
.chain-adjacent-step {
  display: grid;
  grid-template-columns: 27px minmax(0,1fr);
  gap: var(--s2);
  justify-content: stretch;
  justify-items: stretch;
  align-items: center;
  min-height: 40px;
  width: 100%;
  padding: var(--s1) var(--s2);
  white-space: normal;
  text-align: left;
}
.chain-adjacent-step .arch-sign-pill { border-radius: var(--r1); }
.chain-step-copy { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.chain-step-copy > strong { color: var(--text); font-size: var(--text-sm); font-weight: 630; }
.chain-step-copy > small { color: var(--muted); font-size: var(--text-xs); line-height: 1.3; }
@container (max-width: 560px) {
  .arch-crumb-list, .arch-crumb-item { gap: var(--s1); }
  .arch-crumb-list .arch-crumb { font-size: var(--text-xs); }
}
.arch-crumb-list .arch-crumb { flex: 0 1 auto; }
.detail-view-link { margin-bottom: var(--s3); }
.detail-view-link button {
  min-height: 28px;
  border-color: var(--focus);
  color: var(--focus);
  background: var(--accent-surface);
}
.detail-view-link button:hover { border-color: var(--selection); background: var(--band); }
.detail-view-link p { margin: 0; }
/* Patch provenance */
.arch-patch-tag { fill: var(--patches); }
.arch-box[data-patch-provenance="hook"]:not(.is-selected, .is-related, .is-hover-related, .is-chain-path, :hover, :focus-visible) .arch-box-frame {
  stroke: var(--patches);
  stroke-width: 1.5;
}
.arch-chip[data-patch-provenance] .arch-chip-dot { stroke: var(--patches); stroke-width: 1.6; }
.arch-chip.is-editable .arch-chip-dot { stroke: var(--focus); stroke-width: 1.4; }
.arch-chip-badge { fill: var(--focus); font-family: var(--font-mono); font-size: 8.5px; font-weight: 650; }
.arch-inventory-name { align-items: center; gap: 6px; flex-wrap: wrap; }
.arch-inventory-pill { display: inline-flex; align-items: center; padding: 1px 5px; border-radius: 999px; font-family: var(--font-mono); font-size: 9.5px; font-weight: 650; letter-spacing: .03em; border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-raised); white-space: nowrap; }
.arch-inventory-pill.is-editor { border-color: color-mix(in srgb, var(--focus) 55%, var(--border)); color: var(--focus); background: color-mix(in srgb, var(--focus) 12%, transparent); }
.arch-inventory-pill[data-patch-provenance="hook"] { border-color: color-mix(in srgb, var(--warn) 65%, var(--border)); color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.arch-inventory-pill[data-patch-provenance="injected"] { border-color: color-mix(in srgb, var(--patches) 65%, var(--border)); color: var(--patches); background: color-mix(in srgb, var(--patches) 14%, transparent); }
.arch-inventory-pill[data-patch-provenance="reference"] { border-color: color-mix(in srgb, var(--diagnostics) 60%, var(--border)); color: var(--diagnostics); background: color-mix(in srgb, var(--diagnostics) 12%, transparent); }
.arch-inventory-table tbody tr.tint-silicon { box-shadow: inset 3px 0 var(--ok); }
.arch-inventory-table tbody tr.tint-code { box-shadow: inset 3px 0 var(--focus); }
.arch-inventory-table tbody tr.tint-candidate { box-shadow: inset 3px 0 var(--warn); }
.arch-inventory-table tbody tr.tint-pattern { box-shadow: inset 3px 0 var(--patches); }
.arch-inventory-table tbody tr.tint-none { box-shadow: inset 3px 0 var(--border-strong); }
.arch-legend-mark.patch-provenance {
  min-width: 26px;
  color: var(--patches);
  font: 10px var(--font-mono);
}
.badge.patch-provenance, .detail-badges .badge.patch-provenance {
  color: var(--patches);
  background: var(--surface);
  border-color: color-mix(in srgb, var(--patches) 60%, var(--border));
}
.arch-result-kind .patch-result-label {
  display: block;
  margin-top: 2px;
  color: var(--patches);
  letter-spacing: 0;
}

/* Chain inspector */
.chain-inspector-tabs {
  display: flex;
  flex: none;
  align-items: stretch;
  gap: var(--s3);
  padding: 0 var(--s4);
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
}
.chain-inspector-tabs > button {
  min-height: 34px;
  padding: 0 var(--s1);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
}
.chain-inspector-tabs > button[aria-selected="true"] { color: var(--focus); border-bottom-color: var(--focus); }
.chain-inspector-tabs > button:focus-visible { outline-offset: -3px; }
.chain-steps-panel { padding: var(--s2) var(--s3) var(--s3); }
.chain-steps-summary { padding: var(--s1) var(--s1) var(--s2); color: var(--muted); font-size: var(--text-xs); }
.chain-inspector-steps {
  display: grid;
  gap: var(--s1);
  padding: 0;
  margin: 0;
  list-style: none;
}
.chain-inspector-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  justify-items: start;
  align-items: start;
  gap: var(--s2);
  width: 100%;
  min-height: 52px;
  padding: var(--s2);
  color: var(--text);
  background: var(--bg);
  text-align: left;
  white-space: normal;
}
.chain-inspector-step.is-path-step { border-inline-start: 2px solid var(--focus); padding-inline-start: calc(var(--s2) - 1px); }
.chain-inspector-step[aria-pressed="true"] { border-color: var(--focus); background: var(--accent-surface); }
.chain-inspector-step:focus-visible { outline-offset: -2px; }
.chain-step-index { color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.chain-inspector-step-main { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.chain-inspector-step-main strong { font-size: var(--text-sm); font-weight: 620; }
.chain-step-target { color: var(--text); font-size: var(--text-sm); }
.chain-inspector-step-main small { color: var(--muted); font-size: var(--text-xs); }
.chain-inspector-step .arch-sign-pill { border-radius: var(--r1); }

/* Preloader and lazy-loading indicator */
.atlas-preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  transition: opacity 200ms var(--ease-out);
}
.atlas-preloader.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.preloader-card {
  display: grid;
  gap: var(--s3);
  width: min(360px, 100%);
  padding: var(--s5);
  border: 1px solid var(--border-strong);
  border-radius: var(--r3);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}
.preloader-brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.preloader-brand strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 670;
}
.preloader-brand span#preloader-detail {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
}
.preloader-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}
.preloader-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--focus);
  transition: width 180ms var(--ease-out);
}
.atlas-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 95;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--focus), transparent);
  background-size: 40% 100%;
  animation: atlas-indeterminate 1.1s linear infinite;
}
@keyframes atlas-indeterminate {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}
.atlas-loading-status {
  position: fixed;
  right: var(--s4);
  top: calc(var(--shell-height) + var(--s2));
  z-index: 95;
  padding: var(--s1) var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r1);
  background: var(--surface-raised);
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
  box-shadow: var(--shadow);
}

/* Profile switcher and Architecture Patches controls */
.profile-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  flex: none;
  position: relative;
  min-height: 28px;
  padding: 0 var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-xs);
}
.profile-switcher:hover {
  border-color: var(--border-strong);
  background: var(--band);
}
.profile-switcher:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.profile-switcher-label {
  color: var(--muted);
  font-weight: 560;
}
.profile-switcher select {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 640;
  padding-right: 14px;
  cursor: pointer;
}
.profile-switcher select:focus-visible {
  outline: none;
}
.profile-switcher .od-icon {
  position: absolute;
  right: 6px;
  --od-icon-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.patches-menu > summary {
  font-size: var(--text-sm);
}
.patches-menu > summary .od-icon {
  --od-icon-size: 14px;
  color: var(--patches);
}
.patches-menu[data-active="true"] > summary {
  border-color: color-mix(in srgb, var(--patches) 60%, var(--border));
  color: var(--text);
  background: var(--patches-soft);
}
.patches-menu[data-available="false"] > summary {
  opacity: .72;
}
.patch-count-badge {
  min-width: 28px;
  text-align: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--patches-soft);
  color: var(--patches);
  font: 700 10px/16px var(--font-mono);
}
.patches-menu[data-active="false"] .patch-count-badge {
  background: var(--band);
  color: var(--muted);
}
.patches-menu-body {
  left: 0;
  right: auto;
  display: grid;
  gap: var(--s2);
  width: min(264px, 86vw);
  padding: var(--s2);
}
.patches-menu-note {
  margin: 0;
  padding: 0 var(--s2);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}
.arch-patch-filters {
  display: grid;
  gap: var(--s1);
  padding-top: var(--s1);
  border-top: 1px solid var(--border);
}
.arch-patch-filters:empty {
  display: none;
}
.arch-patch-filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s1) var(--s2);
  border-radius: var(--r1);
  font-size: var(--text-xs);
  cursor: pointer;
}
.arch-patch-filter-item:hover {
  background: var(--band);
}
.arch-patch-filter-item input {
  accent-color: var(--patches);
}
.arch-patch-filter-item > span {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}
.arch-patch-filter-item > code {
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
}

/* Architecture Patch Layer visual differentiation */
.arch-patches-band {
  fill: var(--patches-soft);
  fill-opacity: .42;
  stroke: color-mix(in srgb, var(--patches) 55%, var(--border));
  stroke-dasharray: 5 3;
}
.arch-box.is-patch-block {
  --node-tone: var(--patches);
}
.arch-box.is-patch-block:not(.is-selected, .is-related, .is-hover-related, :hover, :focus-visible) .arch-box-frame {
  stroke: color-mix(in srgb, var(--patches) 70%, var(--border-strong));
  stroke-width: 1.4;
}
.arch-box.kind-patch-hook,
.arch-box.kind-patch-code,
.arch-box.kind-patch-flash-data,
.arch-box.kind-patch-ram-data,
.arch-box.kind-patch-map-copy,
.arch-box.kind-patch-axis,
.arch-box.kind-patch-parameter,
.arch-box.kind-patch-did {
  --node-tone: var(--patches);
}
.arch-box[data-patch-provenance="injected"]:not(.is-selected, .is-related, .is-hover-related, .is-chain-path, :hover, :focus-visible) .arch-box-frame {
  stroke: color-mix(in srgb, var(--patches) 72%, var(--border-strong));
  stroke-width: 1.4;
  stroke-dasharray: 5 3;
}
.arch-box[data-patch-provenance="reference"]:not(.is-selected, .is-related, .is-hover-related, .is-chain-path, :hover, :focus-visible) .arch-box-frame {
  stroke: color-mix(in srgb, var(--patches) 48%, var(--border-strong));
}
.arch-flow.is-patch-flow:not(.is-selected, .is-hover-related),
.arch-link.is-patch-edge:not(.is-selected, .is-hover-related) {
  stroke: var(--patches);
}
.arch-link.is-patch-edge {
  stroke-dasharray: 5 3;
}
.arch-legend-mark.patch-hook {
  min-width: 30px;
  color: var(--patches);
  font: 700 9px var(--font-mono);
}
.arch-legend-mark.patch-injected {
  min-width: 30px;
  color: var(--patches);
  border: 1px dashed var(--patches);
  border-radius: 3px;
  padding: 0 3px;
  font: 700 9px var(--font-mono);
}
.arch-legend-mark.patch-reference {
  min-width: 30px;
  color: var(--patches);
  font: 600 9px var(--font-mono);
}
.badge.patch-hook {
  color: var(--accent-ink);
  background: var(--patches);
  border-color: var(--patches);
}
.badge.patch-injected {
  color: var(--patches);
  background: var(--patches-soft);
  border-color: color-mix(in srgb, var(--patches) 60%, var(--border));
}
.badge.patch-reference {
  color: var(--patches);
  background: var(--surface);
  border-color: color-mix(in srgb, var(--patches) 50%, var(--border));
}
