/* workbench.css — chrome for the SNES and N-Gage workbenches
   (cartridge_cartography, symbian_sextant).

   Ported 2026-08-08 from hexenwerkzeug.com's ide.css as part of the
   workbench migration (docs/hexenwerkzeug-workbench-migration.md). Three
   sections, in load order:

     1. a token shim mapping the hexenwerkzeug token names the kit consumes
        onto this site's design tokens, so the pages follow bbt's theme
        (accent choice, light/dark) instead of shipping a second palette;
     2. integration rules for tool_base.html — the page body is the IDE
        grid, the bbt nav occupies the grid's nav row, and <main> is
        display:contents so the page's header/sections/footer become grid
        items (note: child combinators below are written `> main >` because
        display:contents flattens boxes, not the DOM);
     3. the ide.css body, unchanged except for that selector rewrite.

   Scrollbars stay global (design/base.css owns them; this file declares
   none). Tokens are overridden on :root, never html. */

:root {
  /* hexenwerkzeug token name → bbt design token. Tokens whose names bbt
     already defines (--accent, --accent-dim, --blue, --purple, --cyan,
     --radius-sm) are deliberately NOT redefined here — the kit inherits
     the site's values directly. */
  --bg: var(--bg-base);
  --surface: var(--bg-elevated);
  --surface-2: var(--bg-hover);
  --elevated: var(--bg-surface);
  --border: var(--border-default);
  --border-strong: var(--border-default);
  --text: var(--text-primary);
  --dim: var(--text-secondary);
  --faint: var(--text-muted);
  --accent-d: var(--accent-hover);
  --amber: var(--warning);
  --rose: var(--error);
  --sans: var(--font-sans);
  --mono: var(--font-mono);
  --radius: var(--radius-md);

  /* IDE layout defaults — lived on hexenwerkzeug's base.css :root. */
  --ide-header: 36px;
  --ide-status: 24px;
  --ide-left: 220px;
  --ide-right: 300px;
  --ide-bottom: 200px;

  /* Type scale — the whole workbench draws from these five discrete steps
     rather than the ad-hoc 0.62-1.05rem values the ported kit shipped with.
     Root font-size is 16px, so the rem steps land on whole pixels. bbt's
     design/base.css has no canonical --text-* scale yet; when it grows one
     these should alias onto it. */
  --wb-text-2xs: 0.6875rem; /* 11px - micro labels: meta, refs, chips, legend */
  --wb-text-xs:  0.75rem;   /* 12px - small labels: badges, eyebrows, status bar */
  --wb-text-sm:  0.8125rem; /* 13px - default control/body text: hex, kv, tabs, code */
  --wb-text-md:  0.875rem;  /* 14px - titles / emphasis: h1, editor, results */
  --wb-text-lg:  1rem;      /* 16px - prominent: dropzone prompt, palette input */
}

/* ── tool_base.html integration ── */
body[data-layout="ide"] > .bbt-nav { grid-area: nav; }
body[data-layout="ide"] > main { display: contents; }

/* ── carried from hexenwerkzeug base.css (only what the pages use and
      neither ide.css nor bbt's design CSS provides) ── */
:where(.icon) {
  --icon-size: 16px;
  inline-size: var(--icon-size);
  block-size: var(--icon-size);
  flex-shrink: 0;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  inset-inline-start: 0.5rem;
  inset-block-start: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
  z-index: 20;
}
.skip-link:focus { transform: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: var(--wb-text-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 120ms, color 120ms, background 120ms;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn[data-primary] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}
.btn[data-primary]:hover { background: var(--accent-d); border-color: var(--accent-d); color: var(--bg); }

/* ── ide.css (ported; `body[data-layout="ide"] >` rewritten `> main >`) ── */
/* ide.css — IDE-style page chrome.
   Layout is CSS Grid driven by --ide-* tokens (overridable per-page).
   No required classes on inner panels — every selector keys off
   semantic elements or data-attributes. */

/* Resizable columns use minmax(min, ideal) so the JS-tracked
   --ide-left / --ide-right never collapse below their min, even
   if the splitter drag math drifts. */
body[data-layout="ide"] {
  --ide-min-left:   200px;
  --ide-min-center: 280px;
  --ide-min-right:  220px;
  --ide-min-bottom: 120px;

  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template:
    "nav    nav    nav"    40px
    "header header header" var(--ide-header)
    "left   center right"  1fr
    "status status status" var(--ide-status)
    / minmax(var(--ide-min-left),  var(--ide-left))
      minmax(var(--ide-min-center), 1fr)
      minmax(var(--ide-min-right), var(--ide-right));
  background: var(--bg);
}
body[data-layout="ide"] > main > .hw-nav { grid-area: nav; }

body[data-layout="ide"] > main > header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-inline: 0.85rem;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  block-size: var(--ide-header);
  overflow: hidden;
  min-block-size: 0;
}
/* All direct children stay vertically centred and never blow up the
   bar's height. Anything taller scales down via line-height tricks
   rather than scrolling. */
body[data-layout="ide"] > main > header > * { flex-shrink: 0; align-self: center; }
body[data-layout="ide"] > main > header > .file-tabs--inline { flex-shrink: 1; }
body[data-layout="ide"] > main > header h1 {
  font-size: var(--wb-text-md);
  font-weight: 500;
  letter-spacing: -0.01em;
}
body[data-layout="ide"] > main > header h1 em { color: var(--accent); font-style: normal; }
/* Toolbar keyboard-hint chip (Cmd-K). Was an inline style on the <kbd>. */
.kbd-hint { font-family: var(--mono); font-size: var(--wb-text-xs); color: var(--faint); }
body[data-layout="ide"] > main > header .badge {
  font-size: var(--wb-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  padding: 0.15rem 0.55rem;
  background: var(--elevated);
  border-radius: 999px;
}

body[data-layout="ide"] > main > footer {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-inline: 0.85rem;
  background: var(--surface);
  border-block-start: 1px solid var(--border);
  font-size: var(--wb-text-xs);
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* Dynamic values inside the status bar stay SANS (Inter) but flip
   tabular-nums so digits align; this matches the user's font policy:
   sans for chrome, mono only for hex / code / value fields proper. */
body[data-layout="ide"] > main > footer .accent,
body[data-layout="ide"] > main > footer .mono {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
body[data-layout="ide"] > main > footer .mono { color: var(--text); font-weight: 400; }
body[data-layout="ide"] > main > footer .mono.dim,
body[data-layout="ide"] > main > footer .dim    { color: var(--dim); }
body[data-layout="ide"] > main > footer .sep    { inline-size: 1px; block-size: 10px; background: var(--border); }
body[data-layout="ide"] > main > footer .spacer { flex: 1; }

/* Panels live in the four named areas. Each is <section data-area=…>. */
[data-area="left"]   { grid-area: left;   border-inline-end: 1px solid var(--border); background: var(--surface); }
[data-area="center"] { grid-area: center; background: var(--bg);     overflow: hidden; }
[data-area="right"]  { grid-area: right;  border-inline-start: 1px solid var(--border); background: var(--surface); }
[data-area="bottom"] { grid-area: bottom; border-block-start: 1px solid var(--border); background: var(--surface); }

[data-area] {
  display: grid;
  grid-template-rows: auto 1fr;
  min-block-size: 0;
  min-inline-size: 0;
}

/* Panel header — small caps title + optional badge/actions. */
[data-area] > header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  block-size: 32px;
  padding-inline: 0.65rem;
  background: var(--surface-2);
  border-block-end: 1px solid var(--border);
}
[data-area] > header h2 {
  flex: 1;
  font-size: var(--wb-text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0;
}
[data-area] > header .badge {
  font-size: var(--wb-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  background: var(--elevated);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}
[data-area] > header .action {
  display: inline-flex; align-items: center; justify-content: center;
  inline-size: 22px; block-size: 22px;
  border-radius: var(--radius-sm);
  color: var(--faint);
}
[data-area] > header .action:hover { background: var(--elevated); color: var(--text); }

[data-area] > .body { overflow: auto; padding: 0.5rem 0; }
[data-area][data-role="raw"] > .body { padding: 0; }

/* ── File tree (used by Tree + Explorer blocks) ── */
[role="tree"] { display: block; outline: none; }
[role="tree"]:focus-visible { box-shadow: inset 2px 0 0 var(--accent); }

.tree { display: grid; }
.tree-item {
  display: grid;
  grid-template-columns: 14px 16px 1fr auto auto auto;
  align-items: center;
  gap: 0.4rem;
  block-size: 26px;
  padding-inline: 0.6rem;
  border-inline-start: 2px solid transparent;
  cursor: pointer;
  font-size: var(--wb-text-sm);
  color: var(--dim);
  user-select: none;
}
.tree-item:hover { background: var(--elevated); color: var(--text); }
.tree-item[aria-selected="true"] {
  background: var(--accent-dim);
  color: var(--accent);
  border-inline-start-color: var(--accent);
}
.tree-item.focused {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.tree-item .chev { color: var(--faint); display: inline-grid; place-items: center; }
.tree-item[data-type="file"] .chev { visibility: hidden; }
.tree-item .label { color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .meta  { font-family: var(--mono); font-size: var(--wb-text-2xs); color: var(--faint); }
.tree-item .kind  {
  font-family: var(--mono);
  font-size: var(--wb-text-2xs);
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  background: var(--elevated);
  border-radius: 3px;
}
/* Per-row action chips — invisible until the row is hovered or
   focused. Each is a real <button> so keyboard focus exposes them. */
.tree-item .tree-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  opacity: 0;
  transition: opacity 120ms ease;
}
.tree-item:hover .tree-actions,
.tree-item:focus-within .tree-actions { opacity: 1; }
.tree-action {
  display: inline-grid;
  place-items: center;
  inline-size: 22px;
  block-size: 22px;
  color: var(--faint);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 120ms, background 120ms;
}
.tree-action:hover { color: var(--accent); background: var(--surface); }
.tree-action .icon { --icon-size: 14px; }

/* ── <hw-badge> — small inline status / count pill.
   Variants flip a single accent token; the layout chrome is shared
   so future variants only need one selector. Also styles the legacy
   .badge class so both forms render identically during the
   migration. ── */
hw-badge[hidden],
.badge[hidden] { display: none; }
hw-badge,
.badge {
  --hw-badge-fg: var(--dim);
  --hw-badge-bg: var(--elevated);
  --hw-badge-bd: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  font-family: var(--mono);
  font-size: var(--wb-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--hw-badge-fg);
  background: var(--hw-badge-bg);
  border: 1px solid var(--hw-badge-bd);
  border-radius: 999px;
  white-space: nowrap;
}
hw-badge[variant="accent"],
.badge.badge--accent {
  --hw-badge-fg: var(--accent);
  --hw-badge-bg: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-dim);
}
hw-badge[variant="warn"] {
  --hw-badge-fg: var(--amber);
  --hw-badge-bg: rgba(245, 158, 11, 0.10);
}
hw-badge[variant="surface"] {
  --hw-badge-bg: var(--surface-2);
}
/* Leading dot indicator (status-light style). */
hw-badge[dot]::before {
  content: '';
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── <hw-button> — declarative icon + label button. Wraps a real
   <button> so keyboard / disabled / focus semantics come for free.
   Variants: default / primary / ghost. ── */
hw-button {
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
}
hw-button .hw-button-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: var(--wb-text-sm);
  cursor: pointer;
  transition: border-color 120ms, background 120ms, color 120ms;
}
hw-button .hw-button-inner:hover {
  border-color: var(--accent);
  color: var(--accent);
}
hw-button[variant="primary"] .hw-button-inner {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}
hw-button[variant="primary"] .hw-button-inner:hover {
  background: var(--accent-d);
  border-color: var(--accent-d);
  color: var(--bg);
}
hw-button[variant="ghost"] .hw-button-inner {
  background: transparent;
  border-color: transparent;
  color: var(--faint);
  padding: 0.3rem;
}
hw-button[variant="ghost"] .hw-button-inner:hover {
  background: var(--elevated);
  color: var(--text);
}
hw-button[disabled] .hw-button-inner,
hw-button .hw-button-inner[disabled] {
  opacity: 0.5;
  pointer-events: none;
}
.hw-button-icon {
  inline-size: 14px;
  block-size: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.hw-button-label[hidden] { display: none; }

/* ── <hw-select> — custom dropdown Web Component. Light-DOM
   render, so these selectors style children of the host element.
   Rotating chevron on [open], accent focus ring, faded options. */
hw-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  font: inherit;
  cursor: pointer;
  user-select: none;
}
hw-option { display: none; }

.hw-select-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.4rem 0.2rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.hw-select-trigger:hover {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border));
  background: var(--elevated);
}
hw-select[aria-expanded="true"] .hw-select-trigger,
hw-select:focus-visible .hw-select-trigger {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
hw-select[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }

.hw-select-chev {
  inline-size: 12px;
  block-size: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms cubic-bezier(0.34, 1.4, 0.6, 1);
}
hw-select[aria-expanded="true"] .hw-select-chev { transform: rotate(180deg); }

.hw-select-menu {
  display: none;
  position: absolute;
  inset-block-start: calc(100% + 4px);
  inset-inline-start: 0;
  margin: 0;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  list-style: none;
  min-inline-size: 100%;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  z-index: 100;
  /* Subtle pop-in. */
  animation: hw-select-pop 140ms cubic-bezier(0.34, 1.3, 0.6, 1);
  transform-origin: top left;
}
@keyframes hw-select-pop {
  from { opacity: 0; transform: scaleY(0.95) translateY(-2px); }
  to   { opacity: 1; transform: scaleY(1)    translateY(0);   }
}
hw-select[aria-expanded="true"] .hw-select-menu { display: block; }

.hw-select-option {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--dim);
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}
.hw-select-option:hover,
.hw-select-option:focus {
  background: var(--surface-2);
  color: var(--text);
}
.hw-select-option[aria-selected="true"] {
  color: var(--accent);
}
.hw-select-option[aria-disabled="true"] {
  opacity: 0.5;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .hw-select-chev,
  .hw-select-menu { animation: none; transition: none; }
}

/* ── Tabs strip — both [role="tablist"] (panel internals) and the
   new <hw-tabs> Web Component share the same chrome. ── */
[role="tablist"],
hw-tabs {
  display: flex;
  align-items: stretch;
}
/* File-tabs — multi-file slot. Two variants:
   • default: standalone bar (its own bg + border)
   • .file-tabs--inline: rides inside an existing chrome bar (header /
     sub-navbar); transparent so it inherits the parent's surface. */
.file-tabs {
  display: flex;
  align-items: stretch;
  min-block-size: 0;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}
.file-tabs:empty { display: none; }
.file-tabs > [role="tablist"],
.file-tabs > hw-tabs { flex: 1; min-inline-size: 0; overflow-x: auto; }
.file-tabs [role="tab"],
.file-tabs hw-tab {
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  block-size: 32px;
  padding-inline: 0.9rem;
}

.file-tabs--inline {
  align-self: stretch;
  flex: 1;
  min-inline-size: 0;
  block-size: 100%;
  background: transparent;
  border-block-end: 0;
}
.file-tabs--inline [role="tablist"],
.file-tabs--inline hw-tabs { block-size: 100%; }
.file-tabs--inline [role="tab"],
.file-tabs--inline hw-tab {
  block-size: 100%;
  padding-inline: 0.75rem;
  font-family: var(--sans);
  font-size: var(--wb-text-sm);
  letter-spacing: -0.005em;
  color: var(--dim);
  gap: 0.4rem;
}
.file-tabs--inline [role="tab"][aria-selected="true"],
.file-tabs--inline hw-tab[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
}
.file-tabs--inline [role="tab"][aria-selected="true"]::after,
.file-tabs--inline hw-tab[aria-selected="true"]::after {
  background: var(--accent);
}
[role="tab"],
hw-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-inline: 0.85rem;
  border-inline-end: 1px solid var(--border);
  font-size: var(--wb-text-sm);
  color: var(--dim);
  white-space: nowrap;
  position: relative;
  cursor: pointer;
  outline: none;
}
/* aria-selected is the screen-reader-visible truth; the component
   mirrors the `selected` attribute into it so we can style off ARIA. */
[role="tab"][aria-selected="true"],
hw-tab[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
}
[role="tab"][aria-selected="true"]::after,
hw-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  block-size: 1px;
  background: var(--accent);
}
[role="tab"] .x,
.hw-tab-close {
  display: inline-flex; align-items: center; justify-content: center;
  inline-size: 20px; block-size: 20px;
  border-radius: var(--radius-sm);
  color: var(--faint);
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
[role="tab"] .x:hover,
.hw-tab-close:hover { background: var(--border-strong); color: var(--text); }
[role="tab"] .x svg,
.hw-tab-close svg {
  inline-size: 14px;
  block-size: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Code pane with gutter ── */
.editor {
  display: grid;
  grid-template-columns: 48px 1fr;
  block-size: 100%;
  overflow: auto;
  background: var(--bg);
}
.gutter {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.55rem 0.85rem 0;
  text-align: end;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  color: var(--faint);
  line-height: 1.6;
  user-select: none;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
}
.code {
  margin: 0;
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  line-height: 1.6;
  white-space: pre;
  color: var(--text);
  background: var(--bg);
  border: 0;
}

/* ── Hex viewer ──
   The hex view is the consolidated renderer (design/hexview.js -> createHexView),
   styled by the design system in design/components.css (.hex-view / .hex-row /
   .hex-byte / .hex-ascii ...). Only the per-field colour overlay below is
   workbench-specific; it is scoped under .hex-view so it composes with — and
   out-specifies — the base .hex-region highlight. The old blocks/hex.js
   structural rules were removed together with that renderer: they set
   .hex-row{position:absolute}, which piled the keeper's flow-laid rows on top
   of one another. */
.hex-view .hex-byte[data-field]                       { font-weight: 500; }
.hex-view .hex-byte[data-field="title"]               { background: var(--accent-dim);      color: var(--accent); }
.hex-view .hex-byte[data-field="mapper"]              { background: rgba(96,165,250,0.14);  color: var(--blue);   }
.hex-view .hex-byte[data-field="checksum"]            { background: rgba(192,132,252,0.14); color: var(--purple); }
.hex-view .hex-byte[data-field="checksum-complement"] { background: rgba(192,132,252,0.08); color: var(--purple); }
.hex-view .hex-byte[data-field="region"]              { background: rgba(245,158,11,0.12);  color: var(--amber);  }
.hex-view .hex-byte[data-field="vectors"]             { background: rgba(34,211,238,0.12);  color: var(--cyan);   }

/* ── Key/value inspector ── */
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  row-gap: 0.2rem;
  padding: 0.5rem 0.85rem;
  font-size: var(--wb-text-sm);
}
/* dt = constant label (sans); dd = dynamic value (mono). */
.kv dt { color: var(--faint); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); font-family: var(--mono); }
.kv dd.accent { color: var(--accent); }
/* Clickable vector address — surfaces a pointer cursor + hover
   ring so the affordance is discoverable without explanation. */
.kv dd.vec-link {
  cursor: pointer;
  border-radius: 3px;
  padding-inline: 0.3rem;
  margin-inline-start: -0.3rem;
  transition: background 100ms, color 100ms;
}
.kv dd.vec-link:hover,
.kv dd.vec-link:focus-visible {
  background: var(--elevated);
  color: var(--accent);
  outline: none;
}

/* ── Terminal-look panel ── */
[data-role="terminal"] > .body {
  background: #050506;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  color: var(--text);
  padding: 0.75rem 1rem;
}
[data-role="terminal"] .prompt { color: var(--accent); margin-inline-end: 0.5rem; }

/* ── Stacked collapsible sections (used in left + right panels) ── */
.right-stack,
.left-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rstack-section {
  border-block-end: 1px solid var(--border);
}
.rstack-section[open] { padding-block-end: 0.4rem; }
.rstack-section > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  user-select: none;
  min-inline-size: 0;
}
.rstack-section > summary::-webkit-details-marker { display: none; }
/* Chevron icon — pulled from the shared #lucide-chevron-down sprite symbol.
   Render via <svg class="rstack-chev"><use href="#lucide-chevron-down"/></svg>
   inside the <summary>; CSS only handles rotation + colour. */
.rstack-chev {
  inline-size: 12px;
  block-size: 12px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--faint);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms cubic-bezier(0.34, 1.4, 0.6, 1), stroke 120ms;
}
.rstack-section:not([open]) .rstack-chev { transform: rotate(-90deg); }
.rstack-section > summary:hover .rstack-chev { stroke: var(--text); }
.rstack-title {
  font-size: var(--wb-text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.rstack-summary-fill { flex: 1; }

/* ── Entropy heat strip ── */
.entropy-body { padding: 0.4rem 0.85rem; }
#snes-entropy-canvas {
  display: block;
  inline-size: 100%;
  block-size: 32px;
  image-rendering: pixelated;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: crosshair;
}
.entropy-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-block-start: 0.4rem;
  font-size: var(--wb-text-2xs);
  color: var(--faint);
  align-items: center;
}
.legend-swatch {
  display: inline-block;
  inline-size: 10px;
  block-size: 10px;
  border-radius: 2px;
  margin-inline-end: 0.2rem;
}
.legend-swatch.lg-pad  { background: #364FC7; }
.legend-swatch.lg-text { background: #3C8A60; }
.legend-swatch.lg-code { background: #D9A535; }
.legend-swatch.lg-high { background: #DC5050; }

/* ── Tile viewer (right-panel bottom section) ── */
.tile-ctl {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--wb-text-xs); color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tile-ctl select, .tile-ctl input {
  font: var(--wb-text-sm) var(--mono);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 0.15rem 0.35rem;
}
.tile-body {
  padding: 0.6rem;
  overflow: auto;
}
#snes-tile-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--bg);
  border: 1px solid var(--border);
}
.dd-sha1 { word-break: break-all; font-size: var(--wb-text-2xs); line-height: 1.4; }

/* ── Disassembly listing (right panel of the SNES workbench) ── */
.panel-eyebrow {
  font-size: var(--wb-text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 1rem 0.85rem 0.4rem;
  margin: 0;
}
.da-row {
  display: grid;
  grid-template-columns: 64px 92px 56px 1fr auto;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.15rem 0.85rem;
  font: var(--wb-text-sm)/1.5 var(--mono);
  cursor: pointer;
  white-space: nowrap;
}
.da-row:hover { background: var(--elevated); }
.da-pc    { color: var(--faint);  font-variant-numeric: tabular-nums; }
.da-bytes { color: var(--dim);    font-variant-numeric: tabular-nums; }
.da-mnem  { color: var(--cyan);   font-weight: 500; }
.da-op    { color: var(--text); }
.da-cmt   { color: var(--faint); font-style: italic; grid-column: 1 / -1; padding-inline-start: 220px; }

/* ── BinForge DSL editor (textarea + highlight overlay) ── */
.dsl-editor-shell {
  position: relative;
  block-size: 100%;
  overflow: hidden;
}
.dsl-editor, .dsl-hi {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.75rem 1rem;
  font: var(--wb-text-md)/1.55 var(--mono);
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  border: 0;
}
.dsl-editor {
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  outline: none;
  resize: none;
  z-index: 2;
}
.dsl-hi {
  background: var(--bg);
  color: var(--text);
  pointer-events: none;
  z-index: 1;
}
.dsl-hi .t-kw    { color: var(--purple); font-weight: 500; }
.dsl-hi .t-type  { color: var(--amber);  }
.dsl-hi .t-dir   { color: var(--blue);   }
.dsl-hi .t-str   { color: var(--accent); }
.dsl-hi .t-num   { color: var(--cyan);   }
.dsl-hi .t-field { color: var(--text);   font-weight: 500; }
.dsl-hi .t-op    { color: var(--dim);    }
.dsl-hi .t-punc  { color: var(--faint);  }
.dsl-hi .t-cmt   { color: var(--faint);  font-style: italic; }

.dsl-errors {
  background: rgba(251,113,133,0.08);
  border: 1px solid var(--rose);
  border-radius: var(--radius-sm);
  color: var(--rose);
  padding: 0.5rem 0.75rem;
  margin-block-end: 0.75rem;
  font: var(--wb-text-sm)/1.5 var(--mono);
  white-space: pre-wrap;
}
.dsl-js {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin: 0.4rem 0.75rem 0;
  font: var(--wb-text-xs)/1.5 var(--mono);
  color: var(--dim);
  max-block-size: 360px;
  overflow: auto;
}

/* ── Drop zone ── */
[id$="-dropzone"] {
  position: relative;
  inset: 0;
  block-size: 100%;
  display: grid;
}
[id$="-dropzone"][data-active="true"]::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-dim);
  z-index: 5;
  pointer-events: none;
}
[id$="-dropzone"] .dz-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6rem;
  pointer-events: none;        /* container ignores clicks (it overlays the hex) */
  text-align: center;
  color: var(--dim);
}
[id$="-dropzone"] .dz-hint strong { color: var(--text); font-weight: 500; font-size: var(--wb-text-lg); }
[id$="-dropzone"] .dz-hint code   { font-family: var(--mono); color: var(--accent); }
[id$="-dropzone"] .dz-hint kbd    {
  font-family: var(--mono); font-size: var(--wb-text-xs); color: var(--dim);
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: 3px; padding: 0.1em 0.4em;
}
[id$="-dropzone"] .dz-hint .dz-or {
  font-size: var(--wb-text-xs); color: var(--faint);
  letter-spacing: 0.08em; text-transform: uppercase;
}
[id$="-dropzone"] .dz-hint .dz-kb { font-size: var(--wb-text-sm); }
[id$="-dropzone"] .dz-hint .dz-btn {
  pointer-events: auto;        /* but the button can be clicked */
  font-size: var(--wb-text-md);
  padding: 0.55rem 1rem;
}
/* Legacy <button class="btn topbar-open"> — kept for any tool that
   still uses it. The new <hw-button class="topbar-open"> below
   targets the inner button only, so we don't pay padding twice
   (host element + inner button = button blowing past the 36-px bar). */
.topbar-open:not(hw-button) {
  font-size: var(--wb-text-sm);
  padding: 0.35rem 0.7rem;
  gap: 0.4rem;
}
.topbar-open:not(hw-button) .icon { --icon-size: 14px; }

/* <hw-button class="topbar-open"> — the host carries no padding;
   we just trim the inner button so it slots into the sub-nav bar. */
hw-button.topbar-open .hw-button-inner {
  padding-block: 0.25rem;
  font-size: var(--wb-text-sm);
}
hw-button.topbar-open .hw-button-icon { inline-size: 14px; block-size: 14px; }
.dz-btn .icon      { --icon-size: 16px; }
/* Once any hex cell exists inside the dropzone, hide the hint —
   the hex view has taken over. Uses :has() on the dropzone wrapper
   so it works regardless of how deep the rendered byte sits. */
[id$="-dropzone"]:has(.hex-byte) .dz-hint { display: none; }

/* OK / mismatch badge for checksum cell. */
[id$="-valid"][data-ok="true"]  { color: var(--accent); }
[id$="-valid"][data-ok="false"] { color: var(--rose);   }

/* ── Variant layouts (set data-variant on body[data-layout="ide"]) ── */
body[data-layout="ide"][data-variant="dual"] {
  grid-template:
    "header header" var(--ide-header)
    "left   center" 1fr
    "status status" var(--ide-status)
    / var(--ide-left) 1fr;
}
body[data-layout="ide"][data-variant="dual"] [data-area="right"],
body[data-layout="ide"][data-variant="dual"] [data-area="bottom"] { display: none; }

body[data-layout="ide"][data-variant="solo"] {
  grid-template:
    "header" var(--ide-header)
    "center" 1fr
    "status" var(--ide-status)
    / 1fr;
}
body[data-layout="ide"][data-variant="solo"] [data-area="left"],
body[data-layout="ide"][data-variant="solo"] [data-area="right"],
body[data-layout="ide"][data-variant="solo"] [data-area="bottom"] { display: none; }

body[data-layout="ide"][data-variant="with-bottom"] {
  grid-template:
    "header header header" var(--ide-header)
    "left   center right"  1fr
    "bottom bottom bottom" var(--ide-bottom)
    "status status status" var(--ide-status)
    / var(--ide-left) 1fr var(--ide-right);
}

/* ─── Splitter handles ─────────────────────────────────────────
   Constrained to the panel row only — they sit between the IDE
   header bar and the status bar, NEVER underneath the top nav.
   Visual: invisible by default, just a wider grab strip. On hover
   the edge of the panel grows a faded accent glow (no solid 4 px
   bar, no chrome that pretends to be a divider all the time).    */
:root { --ide-row-top: calc(40px + var(--ide-header)); --ide-row-bottom: var(--ide-status); }
[role="separator"][data-split] {
  position: absolute;
  background: transparent;
  z-index: 5;
  transition: background 160ms ease;
}
[role="separator"][data-split="left"] {
  inset-block-start: var(--ide-row-top);
  inset-block-end:   var(--ide-row-bottom);
  inset-inline-start: var(--ide-left);
  inline-size: 8px;
  cursor: col-resize;
  transform: translateX(-4px);
}
[role="separator"][data-split="right"] {
  inset-block-start: var(--ide-row-top);
  inset-block-end:   var(--ide-row-bottom);
  inset-inline-end:  var(--ide-right);
  inline-size: 8px;
  cursor: col-resize;
  transform: translateX(4px);
}
[role="separator"][data-split="bottom"] {
  inset-inline: 0;
  inset-block-end: var(--ide-bottom);
  block-size: 8px;
  cursor: row-resize;
  transform: translateY(-4px);
}
/* The visible glow is an inner ::after pseudo, 2 px wide,
   horizontally centred. Faded on hover / drag. */
[role="separator"][data-split]::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  background: var(--accent);
  opacity: 0;
  transition: opacity 160ms ease, box-shadow 160ms ease;
}
[role="separator"][data-split="left"]::after,
[role="separator"][data-split="right"]::after  { inline-size: 2px; }
[role="separator"][data-split="bottom"]::after { block-size: 2px;  }
[role="separator"][data-split]:hover::after {
  opacity: 0.55;
  box-shadow: 0 0 8px 1px color-mix(in oklab, var(--accent) 60%, transparent);
}
[role="separator"][data-split].active::after {
  opacity: 1;
  box-shadow: 0 0 14px 2px color-mix(in oklab, var(--accent) 70%, transparent);
}
[role="separator"][data-split="left"].active::after,
[role="separator"][data-split="right"].active::after { inline-size: 3px; }
[role="separator"][data-split="bottom"].active::after { block-size: 3px;  }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing * { pointer-events: none; }

/* ─── Editor block (read-only viewer) ─── */
.editor {
  position: relative;
  block-size: 100%;
  background: var(--bg);
}
.editor-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
}
.editor-content {
  position: relative;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  line-height: 20px;
}
.editor-row {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  block-size: 20px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  white-space: pre;
}
.editor-row:hover { background: rgba(255,255,255,0.025); }
.editor-row--clickable { cursor: pointer; }
.editor-row--clickable:hover { background: var(--elevated); }

/* SNES disasm uses the editor with PC addresses in the gutter, which
   are wider than line numbers — bump the gutter column accordingly. */
.disasm-editor .editor-row { grid-template-columns: 80px 1fr; }
.disasm-editor .editor-row .gutter-num { color: var(--dim); }

/* Rows that are themselves a branch target — visual cue that "an
   arrow lands here". The colour matches the arrow stroke: accent
   for plain branches, purple for calls (JSR / JSL). When a line is
   both, calls win — it's a subroutine entry the eye should pick up. */
.editor-row--jump-target {
  --jump-color: var(--accent);
  box-shadow: inset 2px 0 0 var(--jump-color);
}
.editor-row--jump-target .gutter-num {
  color: var(--jump-color);
  font-weight: 500;
}
.editor-row--call-target   { --jump-color: var(--purple); }
.editor-row--branch-target { --jump-color: var(--accent); }
/* While an arrow is keyboard-focused / hovered, brighten its target
   row so the eye can connect "where I'm focused" to "where it goes". */
.editor-row--jump-focus {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  box-shadow: inset 2px 0 0 var(--accent),
              inset -2px 0 0 var(--accent);
}

/* The disasm pane fills its rstack section, so it needs a concrete
   block-size for the editor's internal scroll to engage. Without
   this, `block-size: 100%` on the editor collapses to 0 (its parent
   `<details>` content is auto-sized). */
#snes-disasm {
  display: block;
  block-size: clamp(220px, 28vh, 480px);
  position: relative;
}
#snes-disasm hw-editor { display: block; block-size: 100%; }

/* Control-flow arrows live INSIDE the editor's scrollable content
   so they scroll with the source. Overlay the leftmost 48px; the
   rows shift right by the same amount so they don't sit on top. */
.disasm-editor .editor-content { padding-inline-start: 48px; }
.disasm-editor .editor-row     { inset-inline-start: 48px; }
.disasm-arrows {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 48px;
  pointer-events: none;     /* lines pass clicks through to the row */
}
.disasm-arrows .hw-jump-arrow { pointer-events: stroke; }

/* ── <hw-jump-arrows> — SVG control-flow arrows for disasm views.
   Kind class drives stroke colour; backward edges (loops) get the
   accent, forward edges (fall-through branches) get a cool cyan. */
hw-jump-arrows {
  display: block;
  pointer-events: none;          /* arrows decorate, editor handles input */
}
hw-jump-arrows .hw-jump-arrow {
  pointer-events: stroke;        /* clickable when the user does hit a line */
  cursor: pointer;
}
hw-jump-arrows .hw-jump-arrow line,
hw-jump-arrows .hw-jump-arrow polygon {
  stroke: var(--cyan);
  fill: var(--cyan);
  stroke-width: 1;
  opacity: 0.4;
  transition: opacity 120ms, stroke 120ms;
}
hw-jump-arrows .hw-jump-arrow--back line,
hw-jump-arrows .hw-jump-arrow--back polygon {
  stroke: var(--accent);
  fill: var(--accent);
  opacity: 0.55;
}
hw-jump-arrows .hw-jump-arrow--call line,
hw-jump-arrows .hw-jump-arrow--call polygon {
  stroke: var(--purple);
  fill: var(--purple);
  opacity: 0.5;
}
hw-jump-arrows .hw-jump-arrow:hover line,
hw-jump-arrows .hw-jump-arrow:hover polygon,
hw-jump-arrows .hw-jump-arrow:focus-visible line,
hw-jump-arrows .hw-jump-arrow:focus-visible polygon { opacity: 0.95; }
hw-jump-arrows .hw-jump-arrow:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
/* Cross-component correlation: when a label-list row or the arrow
   itself is hovered/focused, every arrow landing on the same target
   line gets boosted opacity + a faint accent glow so the eye can
   follow the link across panels. */
hw-jump-arrows .hw-jump-arrow.is-correlated line,
hw-jump-arrows .hw-jump-arrow.is-correlated polygon {
  opacity: 1;
  stroke: var(--accent);
  fill: var(--accent);
}
hw-jump-arrows .hw-jump-arrow--call.is-correlated line,
hw-jump-arrows .hw-jump-arrow--call.is-correlated polygon {
  stroke: var(--purple);
  fill: var(--purple);
}

/* ── N-Gage decoded-string editor pane. Only visible while a
   SISString field is selected; sits below the kv detail rows. ── */
.field-text-editor {
  display: block;
  block-size: clamp(120px, 24vh, 320px);
  margin: 0 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}
.field-text-editor[hidden] { display: none; }

/* N-Gage files manifest — sits between the parts header and the SIS
   structure tree, listing decoded install paths so the user reads
   "what does this package install?" at a glance. */
.ngage-files {
  border-block-end: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 60%, transparent);
}
.ngage-files[hidden] { display: none; }
.ngage-files > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font: 600 var(--wb-text-sm) var(--sans);
}
.ngage-files > summary::-webkit-details-marker { display: none; }
.ngage-files > summary:hover,
.ngage-files > summary:focus-visible {
  background: var(--elevated);
  outline: none;
}
.ngage-files > summary .rstack-chev {
  inline-size: 14px;
  block-size: 14px;
  flex: 0 0 auto;
  transition: transform 160ms;
  transform: rotate(-90deg);
  color: var(--dim);
}
.ngage-files[open] > summary .rstack-chev { transform: none; }
.ngage-files .rstack-summary-fill { flex: 1; }
.ngage-file-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}
.ngage-file-list-item {
  margin: 0;
  padding: 0;
}
.ngage-file-list-btn {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  inline-size: 100%;
  padding: 0.3rem 0.85rem;
  background: transparent;
  border: 0;
  text-align: start;
  cursor: pointer;
  transition: background 120ms;
}
.ngage-file-list-btn:hover,
.ngage-file-list-btn:focus-visible {
  background: var(--elevated);
  outline: none;
}
.ngage-file-list-btn[data-copied="true"] {
  background: color-mix(in oklab, var(--accent) 25%, transparent);
  transition: background 800ms;
}
.ngage-file-list-path {
  flex: 1;
  font: var(--wb-text-xs) var(--mono);
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0;
}
.ngage-file-list-size {
  font: var(--wb-text-2xs) var(--mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* Detail-panel actions — a row of small buttons that follow the kv
   list. Used for things like "Download decompressed payload" on
   SISCompressed fields. */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem 1rem;
}
.detail-actions:empty { display: none; }
.detail-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: 500 var(--wb-text-sm) var(--sans);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.detail-action-btn:hover:not(:disabled),
.detail-action-btn:focus-visible {
  border-color: var(--accent);
  background: var(--elevated);
  outline: none;
}
.detail-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── SNES branch-targets list. Each row is a real button (free
   keyboard + focus); clicking jumps the editor + hex view. ── */
.label-list-filter {
  padding: 0.35rem 0.85rem 0.1rem;
}
.label-list-filter input {
  inline-size: 100%;
  font: var(--wb-text-sm) var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.3rem 0.5rem;
}
.label-list-filter input::placeholder { color: var(--faint); }
.label-list-filter input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.label-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  display: grid;
}
.label-list-item[hidden] { display: none; }
.label-list-item { margin: 0; padding: 0; }
.label-list-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: baseline;
  inline-size: 100%;
  padding: 0.3rem 0.85rem;
  background: transparent;
  border: 0;
  text-align: start;
  color: var(--dim);
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.label-list-button:hover,
.label-list-button:focus-visible {
  background: var(--elevated);
  color: var(--text);
  outline: none;
}
/* Mirrored correlation styling — when the label row reflects a
   focused arrow elsewhere in the panel, paint the same background as
   :hover so the user can see which list entry the arrow points at. */
.label-list-item.is-correlated > .label-list-button {
  background: var(--elevated);
  color: var(--text);
}
.label-list-pc { color: var(--label-color, var(--accent)); }
.label-list-name { color: var(--text); }
/* Same colour language as the arrow strokes + row rails: purple
   for subroutine calls (JSR/JSL targets), accent for plain
   branches. Keeps the SNES tool visually consistent. */
.label-list-item--call   { --label-color: var(--purple); }
.label-list-item--branch { --label-color: var(--accent); }
.label-list-refs {
  color: var(--faint);
  font-size: var(--wb-text-2xs);
  font-variant-numeric: tabular-nums;
}

/* SNES tile canvas — keep within the analysis panel so a narrow
   pane doesn't cause horizontal scrolling. Canvas backing pixels
   stay at their original res; CSS scales the display. */
#snes-tile-canvas {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
  image-rendering: pixelated;
}
.editor-row .gutter-num {
  color: var(--faint);
  text-align: end;
  user-select: none;
}
.editor-row .text {
  color: var(--text);
  padding-inline-end: 16px;
  min-inline-size: 0;
  overflow: hidden;       /* keep long lines from blowing past row width;
                             editor-scroll handles horizontal scroll when
                             content needs it */
  text-overflow: ellipsis;
}

/* Token colors. */
.tok-comment   { color: var(--faint); font-style: italic; }
.tok-directive { color: var(--amber); }
.tok-mnemonic  { color: var(--cyan); font-weight: 500; }
.tok-register  { color: var(--amber); }
.tok-string    { color: var(--accent); }
.tok-number    { color: var(--purple); }
.tok-label     { color: var(--blue); font-weight: 600; }
.tok-labelref  { color: var(--blue); cursor: pointer; }
.tok-labelref:hover { text-decoration: underline; }
.tok-symbol    { color: var(--text); }
.tok-punct     { color: var(--dim); }

/* Editor hover preview. */
.editor-hover {
  position: absolute;
  z-index: 30;
  min-inline-size: 280px;
  max-inline-size: 480px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
}
.editor-hover > header {
  padding: 0.4rem 0.65rem;
  background: var(--surface-2);
  border-block-end: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  color: var(--accent);
}
.editor-hover > pre {
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border: 0;
  border-radius: 0;
  font-family: var(--mono);
  font-size: var(--wb-text-sm);
  line-height: 1.55;
  color: var(--text);
  max-block-size: 220px;
}
.editor-hover .lno { color: var(--faint); margin-inline-end: 0.5rem; }
.editor-hover mark { background: var(--accent-dim); color: inherit; }

/* ─── Command palette ─── */
#cmd-palette {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: grid;
  place-items: start center;
  padding-block-start: 12vh;
}
.cmd-box {
  inline-size: min(560px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  overflow: hidden;
}
.cmd-input {
  inline-size: 100%;
  padding: 0.85rem 1rem;
  font: var(--wb-text-lg) var(--sans);
  background: transparent;
  border: 0;
  color: var(--text);
  border-block-end: 1px solid var(--border);
}
.cmd-input:focus { outline: 0; }
.cmd-results {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  max-block-size: 50vh;
  overflow: auto;
}
.cmd-results li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: var(--wb-text-md);
  cursor: pointer;
}
.cmd-results li[aria-selected="true"] { background: var(--accent-dim); color: var(--accent); }
.cmd-results .cmd-hint { color: var(--faint); font-size: var(--wb-text-sm); }
.cmd-results kbd {
  font: var(--wb-text-2xs) var(--mono);
  color: var(--dim);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05em 0.4em;
}

/* -- Narrow viewports: collapse the IDE to a single scrolling column --
   The desktop grid needs >=700px (200+280+220 track minimums); below that
   its columns overflow sideways. At <=860px the layout becomes one column
   -- nav, toolbar, then each panel stacked, status bar last -- and scrolls
   vertically. overflow-x is clipped on the body, so horizontal scrolling is
   impossible at any width. The hex/ROM pane keeps an explicit height (its
   view is absolutely positioned inside); the other panels grow to content. */
@media (max-width: 860px) {
  body[data-layout="ide"] {
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    grid-template:
      "nav"    40px
      "header" auto
      "left"   auto
      "center" clamp(340px, 60vh, 620px)
      "right"  auto
      "status" auto
      / 1fr;
  }
  /* Column splitters have nothing to drag when the columns are stacked. */
  body[data-layout="ide"] [role="separator"][data-split] { display: none; }
  /* Column side-borders become row separators. */
  body[data-layout="ide"] [data-area] {
    border-inline: 0;
    border-block-end: 1px solid var(--border);
  }
  /* Toolbar + status bar wrap rather than clip their contents. */
  body[data-layout="ide"] > main > header,
  body[data-layout="ide"] > main > footer {
    block-size: auto;
    flex-wrap: wrap;
    row-gap: 0.25rem;
    padding-block: 0.3rem;
  }
  body[data-layout="ide"] > main > header { min-block-size: var(--ide-header); }
  body[data-layout="ide"] > main > footer { min-block-size: var(--ide-status); }
  /* Cmd-K is a desktop keyboard affordance - hide it on touch widths. */
  body[data-layout="ide"] > main > header .kbd-hint { display: none; }
}
