/* Datapath Studio — tonal AMOLED/multi-theme IDE UI inspired by franticplant/mars-ide. */
:root {
  --bg: #000;
  --surface: #000;
  --panel: #0a0a0a;
  --raised: #141414;
  --text: #e8e8e8;
  --muted: #7d8590;
  --primary: #3d8bff;
  --accent: #ffb02e;
  --success: #2ee67a;
  --warning: #ffd24d;
  --error: #ff3b5c;

  --s-keyword: #5fb3ff;
  --s-type: #5ee8c0;
  --s-directive: #d68bff;
  --s-systask: #ff5c8a;
  --s-number: #ff9b4d;
  --s-string: #a8ff60;
  --s-comment: #5c6370;
  --s-operator: #9aa5b1;
  --s-port: #4dffc3;
  --s-errbg: #2a0010;
  --s-warnbg: #241c00;
  --s-control: #ffe066;
  --s-sim: #ff5c8a;

  --hair: color-mix(in srgb, var(--text) 9%, transparent);
  --hover: color-mix(in srgb, var(--text) 7%, transparent);
  --sel: color-mix(in srgb, var(--primary) 26%, transparent);
  --chip: color-mix(in srgb, var(--text) 7%, transparent);

  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --radius: 8px;
  --explorer-width: 210px;
  --inspector-width: 245px;
  --dock-height: 360px;
  --dock-width: 580px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.45 var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-columns: minmax(0, 100%);
}
.topbar, .layout, .statusbar, .keybar, .mobile-nav { min-width: 0; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; transition: background .12s ease, color .12s ease, border-color .12s ease, opacity .12s ease; }
button:disabled { opacity: .35; cursor: default; }
input, select, textarea { font: inherit; color: inherit; }
:where(button, input, select, textarea):focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
::selection { background: var(--sel); }
.hidden, [hidden] { display: none !important; }

.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text) 18%, transparent) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 16%, transparent); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

svg.i { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  min-height: 40px;
  background: var(--panel);
  border-bottom: 1px solid var(--hair);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background .25s ease;
  pointer-events: none;
}
body.st-running .topbar::after { background: color-mix(in srgb, var(--success) 35%, transparent); }
body.st-error .topbar::after { background: color-mix(in srgb, var(--error) 45%, transparent); }
body.st-done .topbar::after { background: color-mix(in srgb, var(--primary) 35%, transparent); }
body.st-ready .topbar::after { background: color-mix(in srgb, var(--primary) 16%, transparent); }

.topbar .sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--hair); flex: none; }
.brand { display: flex; align-items: baseline; gap: 4px; padding: 0 6px 0 2px; white-space: nowrap; user-select: none; font-size: 14px; line-height: inherit; border-radius: 8px; }
button.brand:hover .mark, button.brand:focus-visible .mark { text-shadow: 0 0 10px color-mix(in srgb, var(--primary) 70%, transparent); }
button.brand:hover b, button.brand:focus-visible b { color: var(--primary); }
button.brand:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.brand .mark { color: var(--primary); font-size: 16px; }
.brand b { font-weight: 800; letter-spacing: -.01em; }
.brand span:not(.mark) { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; }
.mobile-title { display: none; flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  min-height: 30px;
  border-radius: var(--radius);
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 85%, #fff); }
.btn.run { color: var(--success); font-weight: 600; }
.btn.stop { color: var(--error); }
.btn .ic { display: inline-flex; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--muted);
  flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--chip);
}
.mode-switch button {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}
.mode-switch button:hover { color: var(--text); }
.mode-switch button[aria-pressed="true"] { background: var(--raised); color: var(--text); font-weight: 600; }

.runbar { display: flex; align-items: center; gap: 2px; }

.pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--chip);
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
body.st-ready .pill { color: var(--primary); }
body.st-running .pill { color: var(--success); }
body.st-running .pill::before { animation: pulse 1s infinite; }
body.st-done .pill { color: var(--primary); }
body.st-error .pill { color: var(--error); }
@keyframes pulse { 50% { opacity: .25; } }

/* ------------------------------------------------------------------ layout grid */
.layout { display: flex; min-height: 0; width: 100%; }
.sidebar, .inspector {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar { width: var(--explorer-width); flex: 0 0 var(--explorer-width); }
.inspector { width: var(--inspector-width); flex: 0 0 var(--inspector-width); }
.workspace { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.workspace-split { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.splitter { flex: 0 0 4px; background: var(--panel); touch-action: none; transition: background .12s ease; }
.splitter.vertical { cursor: col-resize; }
.splitter.horizontal { cursor: row-resize; }
.splitter:hover, .splitter:focus-visible, .splitter.dragging { background: color-mix(in srgb, var(--primary) 42%, var(--panel)); outline: none; }

@media (min-width: 901px) {
  .explorer-hidden .sidebar, .explorer-hidden #explorer-splitter,
  .inspector-hidden .inspector, .inspector-hidden #inspector-splitter,
  .dock-hidden .bottom, .dock-hidden #dock-splitter { display: none; }
  body.dock-right .workspace-split { flex-direction: row; }
  body.dock-right .bottom { height: auto; width: var(--dock-width); border-left: 1px solid var(--hair); }
  body.dock-right.dock-maximized .bottom { border-left: 0; }
  .mode-wave .editor-groups, .mode-wave #dock-splitter,
  body.dock-maximized .editor-groups, body.dock-maximized #dock-splitter { display: none !important; }
  .mode-wave .bottom, body.dock-maximized .bottom { flex: 1 !important; height: auto !important; width: auto !important; border-left: 0; }
}

/* ------------------------------------------------------------------ sidebar / explorer */
.side-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 6px 5px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.side-actions .icon-btn { width: 25px; height: 25px; }
.side-actions .icon-btn svg { width: 14px; height: 14px; }

.tree { flex: 1; min-height: 0; padding: 2px 6px 10px; }
#files.is-dragover, #files .tree-folder.is-dragover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--primary);
  border-radius: 6px;
}
#files .tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: calc(var(--tree-depth, 0) * 13px + 4px);
  padding-right: 4px;
  border-radius: 6px;
  min-width: 0;
  min-height: 28px;
}
#files .tree-row:hover { background: var(--hover); }
#files .tree-row.is-active { background: var(--sel); }
#files .tree-row.is-active .tree-file { color: var(--text); font-weight: 500; }

#files .tree-build-toggle {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  margin: 0 3px 0 1px;
  flex: none;
  cursor: pointer;
}
#files .tree-folder, #files .tree-file {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
#files .tree-row:hover .tree-file, #files .tree-row:hover .tree-folder { color: var(--text); }
#files .tree-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#files .tw { width: 12px; display: grid; place-items: center; flex: none; }
#files .tw svg { width: 11px; height: 11px; transition: transform .12s ease; }
#files .tree-row.is-open .tw svg { transform: rotate(90deg); }
#files .fi-folder { display: inline-flex; color: var(--accent); flex: none; }
#files .fi-folder svg { width: 14px; height: 14px; }
#files .file-icon {
  display: inline-block;
  min-width: 22px;
  font: 700 9.5px var(--mono);
  color: var(--primary);
  letter-spacing: .02em;
  flex: none;
}
#files .file-icon.ext-mem, #files .file-icon.ext-hex { color: var(--accent); }
#files .file-icon.ext-asm, #files .file-icon.ext-s { color: var(--s-directive); }
#files .file-icon.ext-mem { font-weight: 700; }
#files .file-icon.ext-vcd { color: var(--success); }
#files .excluded-note { color: var(--muted); font-size: 10.5px; opacity: .75; margin-left: 4px; flex: none; }

#files .tree-acts { display: none; gap: 1px; flex: none; }
#files .tree-row:hover .tree-acts, #files .tree-row.is-active .tree-acts { display: flex; }
#files .tree-act, #files .tree-more {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
#files .tree-act:hover, #files .tree-more:hover { background: var(--hover); color: var(--text); }
#files .tree-act svg, #files .tree-more svg { width: 13px; height: 13px; }
#files .tree-more { opacity: .45; }
#files .tree-row:hover .tree-more { opacity: 1; }
#files .tree-rename {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: 5px;
  font: 12.5px var(--mono);
}

.file-actions {
  padding: 8px 10px;
  border-top: 1px solid var(--hair);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#active-file { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.file-action-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.chip.selected, .chip.active, .chip[aria-pressed="true"] { background: var(--primary); color: #fff; font-weight: 600; }
.mobile-import { display: none; }
.sidebar-footer { padding: 8px 12px 10px; color: var(--muted); font-size: 11px; opacity: .75; }

/* ------------------------------------------------------------------ split editor groups */
.editor-groups { display: flex; flex: 1; min-height: 0; min-width: 0; position: relative; background: var(--surface); }
.editor-group, .group-split { display: flex; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.editor-group { flex-direction: column; position: relative; background: var(--surface); }
.group-split.split-row { flex-direction: row; }
.group-split.split-column { flex-direction: column; }

.group-bar {
  display: flex;
  min-height: 34px;
  background: var(--panel);
  border-bottom: 2px solid transparent;
  flex-shrink: 0;
}
.active-group > .group-bar { border-bottom-color: var(--primary); }
.group-tabs { display: flex; flex: 1; min-width: 40px; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 3px 4px; }
.group-tabs::-webkit-scrollbar { display: none; }
.group-tab {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
}
.group-tab:hover { background: var(--hover); color: var(--text); }
.group-tab.selected { background: var(--raised); color: var(--text); }
.group-tab .tab-label { padding: 3px 6px 3px 9px; font: 12.5px var(--mono); white-space: nowrap; }
.group-tab .tab-close {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  margin-right: 3px;
  opacity: .55;
}
.group-tab .tab-close:hover:not(:disabled) { opacity: 1; background: var(--hover); }
.group-actions { display: flex; align-items: center; padding-right: 4px; gap: 2px; flex-shrink: 0; }
.group-actions button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
}
.group-actions button:hover { background: var(--hover); color: var(--text); }
.group-actions button svg { width: 14px; height: 14px; }

.group-body { flex: 1; min-width: 0; min-height: 0; display: flex; overflow: hidden; background: var(--surface); }
.group-divider { flex: 0 0 4px; background: var(--panel); touch-action: none; z-index: 2; }
.split-row > .group-divider { cursor: col-resize; }
.split-column > .group-divider { cursor: row-resize; }
.group-divider:hover, .group-divider:focus { background: color-mix(in srgb, var(--primary) 42%, var(--panel)); outline: none; }

.single-group .group-split { display: contents; }
.single-group .group-divider, .single-group .editor-group:not(.active-group) { display: none; }
.single-group .editor-group.active-group { flex: 1 !important; }

.editor-group[data-drop]::after {
  content: "Drop pane here";
  position: absolute;
  inset: 34px 0 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  border: 2px solid var(--primary);
  border-radius: 4px;
  color: var(--text);
  font-weight: 600;
  z-index: 5;
}
.editor-group[data-drop="left"]::after { right: 50%; }
.editor-group[data-drop="right"]::after { left: 50%; }
.editor-group[data-drop="top"]::after { bottom: 50%; }
.editor-group[data-drop="bottom"]::after { top: 50%; }

/* ------------------------------------------------------------------ CodeMirror 6 styling */
.group-body .cm-editor { flex: 1; height: 100%; width: 100%; background: var(--surface); color: var(--text); }
.group-body .cm-scroller { font-family: var(--mono); line-height: 1.55; overflow: auto; }
.group-body .cm-gutters { background: var(--surface); color: color-mix(in srgb, var(--muted) 75%, transparent); border-right: 1px solid var(--hair); }
.group-body .cm-activeLine { background: color-mix(in srgb, var(--text) 4.5%, transparent); }
.group-body .cm-activeLineGutter { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.group-body.hide-active-line .cm-activeLine, .group-body.hide-active-line .cm-activeLineGutter { background: transparent; }
.group-body.hide-line-numbers .cm-lineNumbers { display: none; }
.group-body.hide-fold-gutter .cm-foldGutter { display: none; }
.group-body .cm-diagnostic-line { background: var(--s-errbg); box-shadow: inset 3px 0 0 var(--error); }
.group-body .cm-selectionBackground { background: var(--sel) !important; }
.group-body .cm-cursor { border-left: 2px solid var(--primary); }
.group-body .cm-panels { background: var(--panel); color: var(--text); border-color: var(--hair); }
.group-body .cm-panels input, .group-body .cm-panels button { background: var(--chip); color: var(--text); border-radius: 5px; border: 0; padding: 4px 8px; }
.group-body .cm-tooltip-autocomplete {
  background: var(--raised);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  font: 13px var(--mono);
  overflow: hidden;
}
.group-body .cm-tooltip-autocomplete ul li { padding: 4px 10px; color: var(--text); }
.group-body .cm-tooltip-autocomplete ul li[aria-selected] { background: var(--sel); color: var(--text); }

/* ------------------------------------------------------------------ bottom dock & inspector */
.bottom { height: var(--dock-height); flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; overflow: clip; background: var(--panel); }
.panel-head {
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--hair);
}
.panel-tabs { display: flex; gap: 4px; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
.panel-tabs > .chip { flex: none; }
.panel-body { flex: 1; min-height: 0; padding: 10px 14px; color: var(--muted); }
.panel-body h2 { font-size: 14px; color: var(--text); margin: 4px 0; }
.panel-body p, .inspector-content p { font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.empty-state { text-align: center; padding: 20px 10px; }
.empty-icon { font-size: 26px; color: var(--primary); }

#console { display: flex; flex-direction: column; padding: 6px 10px; gap: 6px; overflow: hidden; }
.console-toolbar { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.inline-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.inline-toggle input { accent-color: var(--primary); }
.console-filter { width: 160px; padding: 4px 8px; background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); font: 12px var(--mono); }
.console-filter:focus-visible { outline: 1px solid var(--primary); }
#console-output .con-pass { color: var(--success); }
#console-output .con-fail { color: var(--error); }
#console-output .con-warn { color: var(--warning); }
#console-output {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 6px 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 13px/1.55 var(--mono);
  user-select: text;
}

.problem-summary { margin: 0 0 8px; color: var(--error); font-size: 13px; }
.problem-list { display: flex; flex-direction: column; gap: 3px; font: 12.5px/1.5 var(--mono); }
.problem-item { display: flex; gap: 10px; align-items: baseline; text-align: left; width: 100%; padding: 6px 10px; border-radius: 6px; color: var(--text); }
.problem-item:hover { background: var(--hover); }
.problem-loc { color: var(--primary); white-space: nowrap; font-weight: 600; }
.problem-item.is-error .problem-sev { color: var(--error); font-weight: 700; }
.problem-item.is-warning .problem-sev { color: var(--warning); font-weight: 700; }

/* ------------------------------------------------------------------ waveform */
#waveform:not([hidden]) { display: flex; flex-direction: column; overflow: hidden; padding: 8px 12px; gap: 6px; }
.wave-toolbar { display: flex; align-items: center; justify-content: flex-start; gap: 4px 6px; flex-wrap: wrap; overflow-x: visible; min-width: 0; flex-shrink: 0; }
.wave-toolbar > * { flex: none; }
.wave-toolbar label, .wave-toolbar output { color: var(--muted); font-size: 12px; }
.wave-toolbar select { background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); padding: 4px 8px; font-size: 12px; }
.wave-toolbar input[type="range"] { accent-color: var(--primary); max-width: 90px; }
#wave-error { color: var(--error); margin: 0; font-size: 12px; }
#wave-error:empty { display: none; }
#signal-picker { position: relative; flex-shrink: 0; color: var(--muted); font-size: 12.5px; }
#signal-picker summary { cursor: pointer; padding: 3px 0; color: var(--text); }
#signal-picker input[type="search"] { max-width: 220px; padding: 5px 8px; background: var(--chip); color: var(--text); border: 0; border-radius: 6px; margin-left: 6px; }
#signal-tree { position: absolute; top: 100%; left: 0; z-index: 6; max-height: 180px; min-width: 210px; overflow: auto; padding: 8px; background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.5); }
#signal-tree details { padding-left: 10px; }
#signal-tree label { display: block; padding: 3px 0 3px 8px; }
.signal-tree-row { display: flex; align-items: center; gap: 4px; }
.signal-tree-row label { flex: 1; color: var(--text); }
.signal-tree-row button { padding: 3px 6px; border-radius: 4px; }
.signal-tree-row button:hover { background: var(--hover); }

#wave-grid { position: relative; flex: 1; min-height: 0; font: 12px var(--mono); background: var(--surface); border-radius: 6px; }
.wave-row { display: flex; min-width: max-content; height: 30px; border-bottom: 1px solid var(--hair); }
.wave-ruler { position: sticky; top: 0; z-index: 2; background: var(--panel); }
.wave-label {
  position: sticky; left: 0; z-index: 1;
  width: 200px; flex: 0 0 200px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 8px;
  background: var(--panel);
  border-right: 1px solid var(--hair);
}
.wave-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.wave-label strong { color: var(--text); font-weight: 600; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave-label .signal-radix { width: 54px; min-width: 54px; padding: 2px; color: var(--text); background: var(--chip); border: 0; border-radius: 4px; font-size: 10.5px; }
.wave-row.selected .wave-label { background: var(--sel); }
.wave-track { position: relative; flex: 0 0 auto; height: 100%; touch-action: none; cursor: crosshair; }
.wave-track canvas { position: absolute; top: 0; left: 0; display: block; height: 30px; }
.wave-transport, .wave-search { display: inline-flex; align-items: center; gap: 4px; }
.wave-transport .chip { min-width: 30px; justify-content: center; }
.wave-search input { width: 112px; padding: 4px 8px; background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); font: 12px var(--mono); }
.wave-search input:focus-visible { outline: 1px solid var(--primary); }

/* ------------------------------------------------------------------ inspector */
.inspector-content { padding: 6px 12px 14px; flex: 1; min-height: 0; }
.label { font-size: 10.5px; letter-spacing: .09em; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.config-label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.inspector-content input:not([type=checkbox]), .inspector-content select, #advanced-settings textarea {
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--text);
  font: 13px var(--sans);
}
.inspector-content select option { background: var(--raised); }
#advanced-settings { margin-top: 12px; }
#advanced-settings summary { cursor: pointer; color: var(--text); font-weight: 600; font-size: 12.5px; padding: 4px 0; }
#advanced-settings textarea { min-height: 44px; resize: vertical; font: 12px/1.45 var(--mono); }
#advanced-settings fieldset { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; border: 1px solid var(--hair); border-radius: var(--radius); color: var(--muted); font-size: 12px; }
.config-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--text); font-size: 12.5px; cursor: pointer; }
.config-check input, #advanced-settings fieldset input, .source-row input { accent-color: var(--primary); }
.source-row { display: flex; gap: 4px; align-items: center; margin-top: 5px; }
.source-row label { display: flex; flex: 1; min-width: 0; gap: 6px; align-items: center; font-size: 12.5px; }
.source-row label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-row button { padding: 3px 6px; border-radius: 4px; background: var(--chip); }
.source-row button:hover { background: var(--hover); }
.separator { height: 1px; background: var(--hair); margin: 16px 0; }
.status { margin-top: 6px; color: var(--text); font-weight: 600; font-size: 12.5px; }

.signal-inspector-row { display: flex; align-items: center; gap: 4px; min-width: 0; border-bottom: 1px solid var(--hair); font-size: 12.5px; }
.signal-inspector-row button { padding: 5px 4px; }
.signal-inspector-row.is-pinned { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.inspector-signal-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; white-space: nowrap; color: var(--muted); }
.signal-inspector-row:hover .inspector-signal-name { color: var(--text); }
.inspector-signal-value { max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); color: var(--text); cursor: copy; }
.inspector-signal-value:hover { color: var(--primary); }

/* ------------------------------------------------------------------ status bar + hint */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 10px;
  min-height: 24px;
  background: var(--panel);
  border-top: 1px solid var(--hair);
  color: var(--muted);
  font-size: 12px;
}
body.status-hidden .statusbar { display: none; }
.statusbar .hint { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.statusbar .hint .f { font-family: var(--mono); color: var(--text); margin-right: 8px; }
.statusbar .hint .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 99px; background: var(--chip); color: var(--primary); margin-right: 8px; }
.statusbar .footer-btn { padding: 1px 6px; border-radius: 5px; color: var(--muted); white-space: nowrap; }
.statusbar .footer-btn:hover { background: var(--hover); color: var(--text); }
#cursor { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------ mobile keybar & bottom nav */
.keybar {
  display: none;
  gap: 5px;
  padding: 5px 6px;
  background: var(--raised);
  border-top: 1px solid var(--hair);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  touch-action: pan-x;
  --kb-h: 36px;
  --kb-w: 38px;
  --kb-fs: 14px;
}
.keybar::-webkit-scrollbar { display: none; }
.keybar button {
  flex: none;
  min-width: var(--kb-w);
  height: var(--kb-h);
  padding: 0 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
  font: 600 var(--kb-fs) var(--mono);
  user-select: none;
}
.keybar button.nav { color: var(--primary); }
.keybar button.meta { color: var(--muted); background: var(--chip); }
.keybar button.down { background: var(--primary); color: #fff; }
.keybar button[data-keybar-hide] { font-size: calc(var(--kb-fs) + 6px); line-height: 0; padding-bottom: 8px; }
.keybar.more-right { box-shadow: inset -18px 0 14px -12px var(--primary); }
.keybar.more-left { box-shadow: inset 18px 0 14px -12px var(--primary); }
.keybar.more-left.more-right { box-shadow: inset 18px 0 14px -12px var(--primary), inset -18px 0 14px -12px var(--primary); }
body[data-kb="s"] .keybar { --kb-h: 30px; --kb-w: 32px; --kb-fs: 12.5px; }
body[data-kb="l"] .keybar { --kb-h: 46px; --kb-w: 48px; --kb-fs: 17px; }
body.kb2 .keybar { flex-wrap: wrap; overflow-x: hidden; justify-content: center; box-shadow: none; }
body.kb2 .keybar button { flex: 1 0 auto; }
body.no-keybar .keybar { display: none !important; }

.mobile-nav { display: none; }

@media (max-width: 900px) {
  .sidebar, .inspector { width: 100%; flex: 1; display: none; }
  .splitter, #toggle-explorer, #toggle-inspector, .panel-toggle, #maximize-dock, .mode-switch, .brand, .topbar .sep, .topbar .wide, .btn .lbl, .statusbar .wide { display: none !important; }
  .mobile-title { display: block; }
  .topbar { padding: 2px 6px; min-height: 44px; overflow: hidden; }
  #status-pill { max-width: 132px; overflow: hidden; text-overflow: ellipsis; padding: 3px 7px; font-size: 11px; }
  .pill::before { flex: none; }
  .runbar .btn { min-width: 38px; min-height: 36px; padding: 6px; justify-content: center; }
  body[data-view="files"] .sidebar, body[data-view="inspect"] .inspector { display: flex; }
  body[data-view="files"] .workspace, body[data-view="inspect"] .workspace { display: none; }
  body[data-view="console"] .editor-groups, body[data-view="waveform"] .editor-groups { display: none; }
  body[data-view="console"] .bottom, body[data-view="waveform"] .bottom { height: auto; width: auto; min-height: 0; flex: 1; border-left: 0; }
  .workspace-split { flex-direction: column !important; }
  body[data-view="code"] .bottom { display: none; }
  .showcase-btn { min-width: 34px; min-height: 34px; padding: 5px 8px; justify-content: center; }
  .mobile-import { display: block; margin: 6px 10px; padding: 9px; border-radius: var(--radius); background: var(--chip); color: var(--text); text-align: center; }
  body.typing .keybar { display: flex; }
  body.keyboard-open .mobile-nav { display: none; }
  .statusbar { display: none; min-height: 22px; font-size: 11px; }
  body.typing .statusbar.has-hint { display: flex; }
  .wave-label { width: 120px; flex-basis: 120px; }
  .wave-label .signal-radix { display: none; }

  .mobile-nav {
    display: flex;
    background: var(--panel);
    border-top: 1px solid var(--hair);
    padding: 4px 4px calc(4px + var(--safe-b));
  }
  .mobile-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 0 3px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 11px;
  }
  .mobile-nav button.active { color: var(--primary); }
  .mobile-nav button.active svg { background: color-mix(in srgb, var(--primary) 18%, transparent); border-radius: 99px; }
  .mobile-nav svg { width: 20px; height: 20px; box-sizing: content-box; padding: 2px 10px; }
}

/* ------------------------------------------------------------------ Zen mode (preserves split panes!) */
body.is-zen .topbar, body.is-zen .sidebar, body.is-zen .inspector,
body.is-zen .bottom, body.is-zen .splitter, body.is-zen .statusbar,
body.is-zen .mobile-nav, body.is-zen .keybar { display: none !important; }
body.is-zen .layout { flex: 1; height: 100%; }
body.is-zen .workspace { width: 100%; height: 100%; }
body.is-zen .editor-groups { display: flex; flex: 1; }
.zen-bar {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: color-mix(in srgb, var(--raised) 88%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}

/* ------------------------------------------------------------------ overlays, modals, cards */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 20px 22px;
  max-width: min(500px, 92vw);
  width: 100%;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
dialog.wide-dialog { max-width: min(720px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; }
dialog label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }
dialog input:not([type=checkbox]), dialog select {
  width: 100%;
  padding: 8px 10px;
  background: var(--chip);
  color: var(--text);
  border: 0;
  border-radius: var(--radius);
  font: inherit;
}
dialog select option { background: var(--raised); }
dialog [role="alert"] { color: var(--error); font-size: 12.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dialog-actions button { padding: 7px 14px; border-radius: var(--radius); background: var(--chip); color: var(--text); font-size: 13px; }
.dialog-actions button:hover { background: var(--hover); }
.dialog-actions button.primary, #create-file, #confirm-rename, #create-folder { background: var(--primary); color: #fff; font-weight: 600; }
#confirm-delete { background: color-mix(in srgb, var(--error) 20%, transparent); color: var(--error); font-weight: 600; }

.set-sec { margin: 16px 0 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.theme-card { border-radius: 10px; padding: 8px; text-align: left; box-shadow: inset 0 0 0 1px var(--hair); }
.theme-card.active { box-shadow: inset 0 0 0 2px var(--primary); }
.theme-card .sw { display: flex; gap: 6px; height: 30px; border-radius: 6px; align-items: center; padding: 0 8px; margin-bottom: 5px; font: 11px var(--mono); }
.theme-card .nm { font-size: 12px; font-weight: 500; }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.setting-row label { flex: 1; margin: 0; color: var(--text); font-size: 13px; }
.setting-row select { width: auto; min-width: 170px; }
.check-label { display: flex !important; align-items: center; gap: 10px; padding: 5px 2px; border-radius: 6px; color: var(--text) !important; cursor: pointer; margin: 0 !important; }
.check-label:hover { background: var(--hover); }
.check-label input { width: 16px; height: 16px; accent-color: var(--primary); flex: none; }

.actions-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 14px; }
.actions-list button { text-align: left; padding: 9px 12px; border-radius: var(--radius); color: var(--text); }
.actions-list button:hover { background: var(--hover); }

.palette-dialog { padding: 0; overflow: hidden; }
#palette-input { width: 100%; border-radius: 0; padding: 13px 16px; background: var(--raised); border-bottom: 1px solid var(--hair); outline: none; }
.palette-list { max-height: min(55vh, 420px); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.palette-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 7px; text-align: left; }
.palette-item.selected, .palette-item:hover { background: var(--sel); }
.palette-hint { color: var(--muted); font: 11.5px var(--mono); }

.search-bar { display: flex; align-items: center; gap: 8px; background: var(--chip); border-radius: var(--radius); padding: 0 10px; margin: 8px 0; }
.search-bar input { background: transparent !important; padding: 8px 0 !important; outline: none; }
.help-list { max-height: min(58vh, 480px); display: flex; flex-direction: column; gap: 4px; }
.hitem { padding: 8px 10px; border-radius: 8px; }
.hitem:hover { background: var(--hover); }
.hitem .f { font: 600 13px var(--mono); color: var(--primary); }
.hitem .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.hitem pre { margin: 6px 0 0; padding: 8px; border-radius: 6px; background: var(--surface); font: 12px/1.45 var(--mono); overflow: auto; color: var(--text); }

dialog.sheet-dialog { margin: auto auto 0 auto; border-radius: 16px 16px 0 0; max-width: 640px; padding-bottom: calc(16px + var(--safe-b)); }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 6px; }
.sheet-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 12px; background: var(--chip); font-size: 12px; color: var(--text); }
.sheet-grid button:hover { background: var(--hover); }

.inspector-pop.compact {
  position: fixed;
  z-index: 65;
  width: min(320px, calc(100vw - 16px));
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--raised) 88%, transparent);
  border: 1px solid var(--hair);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
}
.ins-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ins-t { font: 700 13.5px var(--mono); color: var(--primary); }
.ins-s { flex: 1; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font: 12px var(--mono); }
.ins-grid .k { color: var(--muted); font-family: var(--sans); }
.ins-grid .v { cursor: copy; word-break: break-all; }
.ins-grid .v:hover { color: var(--primary); }
.ins-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  pointer-events: none;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  box-shadow: inset 0 0 0 3px var(--primary);
}
.dropzone.on { display: grid; }
.dropzone > div { background: var(--raised); padding: 18px 28px; border-radius: 14px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.dropzone b { display: block; font-size: 16px; margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--hair);
  box-shadow: inset 3px 0 0 var(--primary), 0 10px 30px rgba(0,0,0,.45);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  max-width: min(560px, calc(100vw - 32px));
  width: max-content;
}

/* ------------------------------------------------------------------ batch tests */
#tests:not([hidden]) { display: flex; flex-direction: column; gap: 8px; overflow: hidden; padding: 8px 12px; }
.tests-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.chip.primary-chip:not(:disabled) { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); font-weight: 600; }
.chip.primary-chip:hover:not(:disabled) { background: color-mix(in srgb, var(--success) 28%, transparent); color: var(--success); }
.tests-summary { font-size: 12.5px; color: var(--muted); }
.tests-summary.is-pass { color: var(--success); font-weight: 600; }
.tests-summary.is-fail { color: var(--error); font-weight: 600; }
.tests-body { flex: 1; min-height: 0; display: flex; gap: 12px; }
.tests-files-box { flex: 0 0 240px; min-width: 0; overflow: auto; font-size: 12.5px; }
.tests-files-box summary { cursor: pointer; color: var(--text); font-weight: 600; padding: 2px 0; }
.tests-help { margin: 4px 0 6px; font-size: 11.5px !important; }
.tests-file { display: flex; align-items: center; gap: 6px; padding: 3px 2px; color: var(--text); cursor: pointer; }
.tests-file input { accent-color: var(--primary); }
.tests-file span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.tests-file.is-excluded { opacity: .5; }
.tests-role { font-size: 10px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.tests-results-wrap { flex: 1; min-width: 0; overflow: auto; }
.tests-results { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); color: var(--text); }
.tests-results th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font: 600 10.5px var(--sans); letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--hair); }
.tests-results td { padding: 5px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.tests-results td.tests-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tests-status { font-weight: 700; }
.tests-results tr.is-pass { background: color-mix(in srgb, var(--success) 8%, transparent); }
.tests-results tr.is-pass .tests-status { color: var(--success); }
.tests-results tr.is-fail, .tests-results tr.is-error { background: color-mix(in srgb, var(--error) 9%, transparent); }
.tests-results tr.is-fail .tests-status, .tests-results tr.is-error .tests-status { color: var(--error); }
.tests-results tr.is-running .tests-status { color: var(--primary); }
.tests-results tr.is-stopped .tests-status, .tests-results tr.is-skipped .tests-status, .tests-results tr.is-queued .tests-status { color: var(--muted); }
.tests-actions .chip + .chip { margin-left: 4px; }

@media (max-width: 900px) {
  .tests-body { flex-direction: column; }
  .tests-files-box { flex: 0 0 auto; max-height: 30%; }
}

/* ------------------------------------------------------------------ workspace search */
.search-dialog { width: min(760px, 94vw); }
.search-options { display: flex; align-items: center; gap: 14px; margin: 0 0 6px; }
.search-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.search-results { max-height: min(56vh, 460px); display: flex; flex-direction: column; gap: 2px; }
.search-result { display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 6px 10px; border-radius: 6px; text-align: left; font: 12.5px/1.45 var(--mono); color: var(--text); }
.search-result:hover, .search-result.selected { background: var(--sel); }
.search-loc { flex-shrink: 0; color: var(--primary); font-weight: 600; }
.search-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; color: var(--muted); }
.search-text mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); border-radius: 2px; }
.search-kind { color: var(--s-keyword); font-weight: 600; }

/* ------------------------------------------------------------------ MIPS decode popover */
.mips-bits { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 8px; }
.mips-bitgroup { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 5px; border-radius: 4px; background: var(--chip); }
.mips-bitgroup code { font: 11.5px var(--mono); color: var(--text); letter-spacing: .04em; }
.mips-bitgroup small { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.mips-field code { color: var(--s-number); }

/* ------------------------------------------------------------------ register file / memory state */
#hw-state:not([hidden]) { display: flex; flex-direction: column; gap: 8px; overflow: hidden; padding: 8px 12px; }
.hw-toolbar, .board-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.hw-toolbar select, .board-toolbar select { background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); padding: 4px 8px; font-size: 12px; }
.hw-toolbar label, .board-toolbar label { color: var(--muted); font-size: 12px; }
.hw-arrays { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.hw-arrays .chip { font-family: var(--mono); font-size: 11.5px; }
.hw-transport, .board-clock, .segmented { display: inline-flex; align-items: center; gap: 4px; }
.hw-transport .chip { min-width: 30px; justify-content: center; }
.hw-time { min-width: 64px; font: 12px var(--mono); color: var(--text); }
.hw-filter { width: 150px; padding: 4px 8px; background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); font: 12px var(--mono); }
.hw-filter:focus-visible { outline: 1px solid var(--primary); }
.hw-body { flex: 1; min-height: 0; overflow: auto; }
.hw-note { margin: 6px 0 0; font-size: 12px; color: var(--warning) !important; }
.hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.hw-cell { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 5px 9px; border-radius: 6px; background: var(--chip); border: 1px solid transparent; font: 12.5px var(--mono); color: var(--text); text-align: left; transition: background .25s, box-shadow .25s, border-color .25s; }
.hw-cell:hover { border-color: var(--hair); }
.hw-name { color: var(--muted); }
.hw-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: copy; }
.hw-table { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); color: var(--text); }
.hw-table th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font: 600 10.5px var(--sans); letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--hair); }
.hw-table td { padding: 3px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; transition: background .25s; }
.hw-table td.hw-pc { width: 18px; color: var(--success); }
.hw-addr { color: var(--muted); }
.hw-asm { color: var(--s-keyword); }
.hw-row.is-pc td { background: color-mix(in srgb, var(--success) 16%, transparent); }
.hw-row.is-pc td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.heat0 { background: color-mix(in srgb, var(--accent) 34%, var(--chip)); border-color: color-mix(in srgb, var(--accent) 80%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 45%, transparent); }
.heat1 { background: color-mix(in srgb, var(--accent) 22%, var(--chip)); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.heat2 { background: color-mix(in srgb, var(--accent) 13%, var(--chip)); }
.heat3 { background: color-mix(in srgb, var(--accent) 7%, var(--chip)); }
.hw-row.heat0, .hw-row.heat1, .hw-row.heat2, .hw-row.heat3 { box-shadow: none; }
.hw-row.heat0 td { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.hw-row.heat1 td { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.hw-row.heat2 td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.hw-row.heat3 td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.hw-row.heat0 .hw-value { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ hardware board */
#board:not([hidden]) { display: flex; flex-direction: column; gap: 8px; overflow: hidden; padding: 8px 12px; }
.board-mode:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.board-signal-select { max-width: 220px; font-family: var(--mono) !important; }
.board-widgets { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; overflow: auto; }
#board-widgets { flex: 1; min-height: 0; }
.board-widget { min-width: 120px; padding: 8px 10px; border-radius: 10px; background: var(--raised); border: 1px solid var(--hair); }
.board-widget header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.board-widget-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: 600 12px var(--mono); }
.board-widget header small { color: var(--muted); font: 10.5px var(--mono); }
.board-remove { width: 20px; height: 20px; font-size: 14px; color: var(--muted); }
.board-widget-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.board-readout { font: 600 13px var(--mono); color: var(--text); }
.led-row { display: flex; flex-wrap: wrap; gap: 5px; max-width: 360px; }
.led-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.led-cell small { font: 9px var(--mono); color: var(--muted); }
.led { width: 14px; height: 14px; border-radius: 50%; background: color-mix(in srgb, var(--success) 12%, var(--chip)); border: 1px solid var(--hair); transition: background .15s, box-shadow .15s; }
.led.led-1 { background: var(--success); box-shadow: 0 0 10px var(--success), 0 0 3px var(--success); border-color: transparent; }
.led.led-x { background: var(--error); box-shadow: 0 0 8px color-mix(in srgb, var(--error) 70%, transparent); }
.led.led-z { background: var(--warning); box-shadow: 0 0 8px color-mix(in srgb, var(--warning) 70%, transparent); }
.seg-display { display: flex; gap: 4px; padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--bg) 85%, var(--success) 3%); border: 1px solid var(--hair); }
.seg-digit { width: 26px; height: 46px; }
.seg { fill: color-mix(in srgb, var(--success) 9%, transparent); transition: fill .15s; }
.seg.on { fill: var(--success); filter: drop-shadow(0 0 3px var(--success)); }
.seg.on.unknown { fill: var(--error); filter: drop-shadow(0 0 3px var(--error)); }
.board-live-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.board-inputs { display: flex; flex-wrap: wrap; gap: 8px; }
.board-input { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--raised); border: 1px solid var(--hair); }
.board-input-name { font: 600 12px var(--mono); color: var(--text); }
.board-switch { min-width: 44px; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--muted); font: 600 12px var(--mono); border: 1px solid var(--hair); transition: background .15s, color .15s; }
.board-switch[aria-checked="true"] { background: var(--success); color: #000; border-color: transparent; box-shadow: 0 0 10px color-mix(in srgb, var(--success) 55%, transparent); }
.board-bus-input { width: 80px; padding: 4px 8px; background: var(--chip); color: var(--text); border: 0; border-radius: 6px; font: 12px var(--mono); }
.board-bits { display: flex; flex-wrap: wrap; gap: 2px; max-width: 320px; }
.board-bit { width: 18px; height: 20px; border-radius: 4px; background: var(--chip); color: var(--muted); font: 11px var(--mono); }
.board-bit.bit-1 { background: color-mix(in srgb, var(--success) 70%, transparent); color: #000; }
.board-live-status { font-size: 12px; color: var(--muted); }
.board-live-status.is-error { color: var(--error); white-space: pre-wrap; }
.board-mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 2px 10px; max-width: 520px; font: 11.5px var(--mono); color: var(--text); }
.board-mem-cell { white-space: nowrap; }
.segmented .chip { border-radius: 999px; }

/* Live board: switches beside the output widgets so both fit the default dock height. */
#board:not([hidden]) { gap: 6px; padding: 6px 12px; }
.board-mode:not([hidden]) { gap: 6px; }
.board-live-stage { flex-direction: row; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 12px; padding: 2px 0 4px; }
.board-live-stage .board-inputs { flex: 0 1 auto; max-width: 100%; flex-direction: column; flex-wrap: nowrap; gap: 6px; }
.board-live-stage .board-widgets { flex: 1 1 260px; min-width: 0; overflow: visible; gap: 8px; }
#board-live .board-input { padding: 4px 8px; }
#board-live .board-widget { padding: 6px 8px; }
#board-live .board-widget header { margin-bottom: 4px; }
#board-live .seg-display { padding: 4px 6px; }
#board-live .seg-digit { width: 22px; height: 38px; }

/* ------------------------------------------------------------------ RTL schematic */
#schematic:not([hidden]) { display: flex; flex-direction: column; gap: 6px; overflow: hidden; padding: 6px 12px; }
.schem-toolbar { display: flex; align-items: center; justify-content: flex-start; gap: 4px 6px; flex-wrap: wrap; overflow-x: visible; min-width: 0; flex-shrink: 0; }
.schem-toolbar > * { flex: none; }
.schem-toolbar select { background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); padding: 4px 8px; font: 12px var(--mono); max-width: 200px; }
.schem-zoom { display: inline-flex; gap: 4px; }
.schem-crumbs { display: inline-flex; align-items: center; gap: 2px; min-width: 0; font: 12px var(--mono); }
.schem-crumb { padding: 3px 7px; border-radius: 6px; color: var(--primary); }
.schem-crumb:hover:not(:disabled) { background: var(--hover); }
.schem-crumb:disabled { color: var(--text); font-weight: 600; cursor: default; }
.schem-crumb-sep { color: var(--muted); }
.schem-statusbar { display: flex; gap: 12px; flex-shrink: 0; font-size: 11.5px; color: var(--muted); }
.schem-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schem-status.is-error { color: var(--error); white-space: normal; }
.schem-scope { margin-left: auto; font-family: var(--mono); white-space: nowrap; }
.schem-warnings { display: flex; gap: 4px; overflow-x: auto; flex-shrink: 0; padding-bottom: 2px; }
.schem-warnings[hidden] { display: none; }
.schem-warning { display: inline-flex; align-items: baseline; gap: 6px; max-width: 520px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; color: var(--text); background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); white-space: nowrap; }
.schem-warning span:last-child { overflow: hidden; text-overflow: ellipsis; }
.schem-warning b { color: var(--warning); font-size: 10px; letter-spacing: .06em; }
.schem-warning.is-error { background: color-mix(in srgb, var(--error) 12%, transparent); border-color: color-mix(in srgb, var(--error) 45%, transparent); }
.schem-warning.is-error b { color: var(--error); }
.schem-warning-loc { color: var(--primary); font-family: var(--mono); }
.schem-warning:hover:not(:disabled) { filter: brightness(1.2); }
.schem-stage { position: relative; flex: 1; min-height: 0; border-radius: 8px; border: 1px solid var(--hair); background-color: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1px); background-size: 16px 16px; overflow: hidden; }
.schem-stage .empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; }
.schem-stage .empty-state[hidden] { display: none; }
.schem-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; }
.schem-canvas.is-panning { cursor: grabbing; }
.schem-canvas text { font-family: var(--mono); font-size: 10px; fill: var(--text); }
.schem-shape { fill: var(--raised); stroke: color-mix(in srgb, var(--text) 38%, transparent); stroke-width: 1.2; }
.schem-cell.has-src { cursor: pointer; }
.schem-cell.has-src:hover .schem-shape { stroke: var(--primary); stroke-width: 1.8; }
.schem-cell.kind-mux .schem-shape { stroke: var(--primary); fill: color-mix(in srgb, var(--primary) 10%, var(--raised)); }
.schem-cell.kind-dff .schem-shape, .schem-cell.kind-mem .schem-shape { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 8%, var(--raised)); }
.schem-cell.kind-latch .schem-shape { stroke: var(--warning); stroke-width: 2; stroke-dasharray: 5 3; fill: color-mix(in srgb, var(--warning) 10%, var(--raised)); }
.schem-cell.kind-op .schem-shape { stroke: var(--s-keyword); }
.schem-cell.kind-gate .schem-shape { stroke: var(--s-type); }
.schem-cell.kind-const .schem-shape { stroke: color-mix(in srgb, var(--s-number) 60%, transparent); fill: var(--panel); }
.schem-cell.kind-const text { fill: var(--s-number); font-size: 9px; }
.schem-cell.kind-module .schem-shape { stroke: var(--primary); stroke-width: 1.5; fill: var(--panel); }
.schem-cell.kind-module { cursor: zoom-in; }
.schem-header { fill: color-mix(in srgb, var(--primary) 26%, var(--panel)); }
.schem-canvas .schem-title { font-weight: 700; font-size: 9.5px; }
.schem-canvas .schem-drill { fill: var(--primary); font-size: 11px; }
.schem-canvas .schem-glyph { font-weight: 700; font-size: 14px; }
.schem-canvas .schem-glyph.small { font-size: 8px; letter-spacing: .05em; fill: var(--muted); }
.schem-canvas .schem-pin { font-size: 8.5px; fill: var(--muted); }
.schem-clock { fill: none; stroke: var(--accent); stroke-width: 1.2; }
.schem-bubble { fill: var(--raised); stroke: var(--s-type); stroke-width: 1.2; }
.schem-badge { fill: var(--warning); }
.schem-canvas .schem-badge-text { fill: #000; font-weight: 800; font-size: 9px; }
.schem-port.is-input .schem-shape { fill: color-mix(in srgb, var(--success) 14%, var(--raised)); stroke: var(--success); }
.schem-port.is-output .schem-shape { fill: color-mix(in srgb, var(--primary) 16%, var(--raised)); stroke: var(--primary); }
.schem-port.is-inout .schem-shape { fill: color-mix(in srgb, var(--warning) 14%, var(--raised)); stroke: var(--warning); }
.schem-canvas .schem-port text { font-weight: 600; }
.schem-wire { fill: none; stroke: color-mix(in srgb, var(--text) 42%, transparent); stroke-width: 1.5; stroke-linejoin: round; transition: stroke .12s; }
.schem-wire.schem-bus { stroke-width: 2.5; stroke: color-mix(in srgb, var(--s-keyword) 70%, transparent); }
.schem-wire.is-const { stroke-dasharray: 3 2; stroke: color-mix(in srgb, var(--s-number) 55%, transparent); }
.schem-wire.wire-1 { stroke: var(--success); }
.schem-wire.wire-0 { stroke: color-mix(in srgb, var(--muted) 70%, transparent); }
.schem-wire.wire-x { stroke: var(--error); }
.schem-wire.wire-z { stroke: var(--warning); stroke-dasharray: 4 3; }
.schem-width rect { fill: var(--panel); stroke: var(--hair); }
.schem-canvas .schem-width text { font-size: 8px; fill: var(--muted); }
.schem-value rect { fill: color-mix(in srgb, var(--primary) 82%, var(--bg)); }
.schem-canvas .schem-value text { font-size: 8.5px; font-weight: 700; fill: #fff; }
.schem-value.is-unknown rect { fill: var(--error); }
.runbar .btn[hidden] { display: none; }

/* ------------------------------------------------------------------ showcase projects gallery */
dialog.showcase-dialog { max-width: min(680px, 94vw); max-height: 85dvh; padding: 18px 18px 14px; display: none; flex-direction: column; overflow: hidden; }
dialog.showcase-dialog[open] { display: flex; }
.showcase-dialog .dialog-head { flex: none; }
.showcase-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; margin: 0 -4px; padding: 0 4px 4px; }
.showcase-heading { margin: 10px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.showcase-heading small { font-weight: 500; letter-spacing: 0; text-transform: none; opacity: .8; }
.showcase-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.showcase-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 12px 13px; border-radius: 12px; background: var(--raised); border: 1px solid var(--hair); color: var(--text); transition: border-color .12s, background .12s; min-width: 0; }
.showcase-card:hover, .showcase-card:focus-visible { border-color: color-mix(in srgb, var(--primary) 60%, transparent); background: color-mix(in srgb, var(--primary) 7%, var(--raised)); }
.showcase-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.showcase-title { font-weight: 700; font-size: 13.5px; }
.showcase-sub { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.showcase-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.showcase-tag { font: 600 10.5px/1 var(--sans); padding: 4px 7px; border-radius: 999px; color: var(--tag, var(--primary)); background: color-mix(in srgb, var(--tag, var(--primary)) 14%, transparent); white-space: nowrap; }
.showcase-tag.t0 { --tag: var(--primary); }
.showcase-tag.t1 { --tag: var(--success); }
.showcase-tag.t2 { --tag: var(--accent); }
.showcase-tag.t3 { --tag: var(--s-directive); }
.showcase-tag.t4 { --tag: var(--s-systask); }
.showcase-note { margin-top: auto; padding-top: 4px; color: var(--muted); font-size: 11px; opacity: .75; }
.quick-templates { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-templates button { padding: 7px 11px; border-radius: var(--radius); background: var(--chip); color: var(--text); font-size: 12.5px; }
.quick-templates button:hover { background: var(--hover); }

@media (max-width: 900px) {
  .toast { bottom: calc(72px + var(--safe-b)); }
  body.keyboard-open .toast { bottom: 16px; }
}
@media (max-width: 640px) {
  dialog.showcase-dialog { padding: 14px 12px 10px; }
  .showcase-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ syntax color key */
.syntax-key { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.syntax-key-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; font-size: 11.5px; color: var(--muted); background: var(--chip); white-space: nowrap; }
.syntax-key-item code { font: 600 11.5px var(--mono); padding: 1px 6px; border-radius: 999px; color: var(--key); background: color-mix(in srgb, var(--key) 14%, transparent); }
.syntax-key-item.k-keyword { --key: var(--s-keyword); }
.syntax-key-item.k-control { --key: var(--s-control); }
.syntax-key-item code.pseudo { font-style: italic; margin-left: -3px; }
.syntax-key-item.k-sim { --key: var(--s-sim); }
.syntax-key-item.k-type { --key: var(--s-type); }
.syntax-key.compact { margin: -2px 0 8px; }
.syntax-key.compact .syntax-key-item { font-size: 10.5px; }

/* ------------------------------------------------------------------ about dialog */
dialog.about-dialog { max-width: min(520px, 94vw); max-height: 85dvh; padding: 18px 18px 16px; display: none; flex-direction: column; overflow: hidden; }
dialog.about-dialog[open] { display: flex; }
.about-head { display: flex; align-items: center; gap: 12px; flex: none; }
.about-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; font-size: 22px; color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); flex: none; }
.about-titles { flex: 1; min-width: 0; }
.about-titles h2 { margin: 0; font-size: 17px; }
.about-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.about-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; margin-top: 14px; }
.about-credit { padding: 12px 14px; border-radius: 12px; background: var(--raised); box-shadow: inset 3px 0 0 var(--primary); }
.about-by { margin: 0; font-size: 14px; }
.about-by a { color: var(--primary); font-weight: 700; text-decoration: none; }
.about-by a:hover { text-decoration: underline; }
.about-repo { margin: 4px 0 0; font-size: 12px; }
.about-repo a { color: var(--muted); text-decoration: none; font-family: var(--mono); font-size: 11.5px; }
.about-repo a:hover { color: var(--primary); text-decoration: underline; }
.about-tagline { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.about-heading { margin: 14px 0 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.about-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.about-pills li { padding: 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.about-licenses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.about-licenses li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid var(--hair); font-size: 12.5px; }
.about-licenses small, .about-licenses a { color: var(--muted); font: 11.5px var(--mono); }
.about-licenses a, .about-note a { color: var(--primary); }
.about-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ history back button */
.nav-back[hidden] { display: none !important; }
.nav-back { color: var(--primary); }

/* ------------------------------------------------------------------ schematic interactivity */
.schem-find { display: inline-flex; align-items: center; gap: 4px; }
.schem-find input { width: 150px; background: var(--chip); color: var(--text); border: 0; border-radius: var(--radius); padding: 4px 8px; font: 12px var(--mono); outline: none; }
.schem-find input:focus { box-shadow: 0 0 0 1px var(--primary); }
.schem-search-count { font: 11px var(--mono); color: var(--muted); min-width: 0; }
.schem-hit { fill: none; stroke: transparent; stroke-width: 10; pointer-events: stroke; cursor: pointer; }
.schem-cell, .schem-port { cursor: pointer; transition: opacity .12s; }
.schem-canvas.has-focus .schem-wire, .schem-canvas.has-focus .schem-cell, .schem-canvas.has-focus .schem-port { opacity: .22; }
.schem-canvas.has-focus .schem-wire-labels { opacity: .35; }
.schem-canvas.has-focus .is-selected, .schem-canvas.has-focus .is-fanin, .schem-canvas.has-focus .is-fanout { opacity: 1; }
.schem-wire.is-selected { stroke: var(--primary) !important; stroke-width: 3; }
.schem-wire.is-fanin { stroke: var(--s-type) !important; stroke-width: 2.6; }
.schem-wire.is-fanout { stroke: var(--accent) !important; stroke-width: 2.6; }
.schem-cell.is-selected .schem-shape, .schem-port.is-selected .schem-shape { stroke: var(--primary); stroke-width: 2.6; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--primary) 60%, transparent)); }
.schem-cell.is-fanin .schem-shape, .schem-port.is-fanin .schem-shape { stroke: var(--s-type); stroke-width: 2.2; }
.schem-cell.is-fanout .schem-shape, .schem-port.is-fanout .schem-shape { stroke: var(--accent); stroke-width: 2.2; }

.schem-inspector { position: absolute; right: 10px; bottom: 10px; z-index: 3; width: min(300px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--hair); box-shadow: 0 14px 40px rgba(0,0,0,.45); backdrop-filter: blur(6px); font-size: 12px; }
.schem-inspector[hidden] { display: none; }
.schem-inspector header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.schem-inspector header > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.si-title { font: 700 12.5px var(--mono); color: var(--text); overflow-wrap: anywhere; }
.si-sub { color: var(--muted); font-size: 11px; }
.si-close { width: 24px; height: 24px; flex: none; font-size: 16px; }
.si-explain { margin: 0; color: var(--muted); line-height: 1.4; }
.si-explain.is-equation { color: var(--text); font: 600 12px var(--mono); overflow-wrap: anywhere; }
.si-explain.is-warn { color: var(--warning); }
.si-pins { width: 100%; border-collapse: collapse; font: 11.5px var(--mono); }
.si-pins td { padding: 3px 4px; border-top: 1px solid var(--hair); white-space: nowrap; }
.si-pins td:nth-child(2), .si-pins td:nth-child(3) { color: var(--muted); }
.si-pins td.si-value { text-align: right; color: var(--s-number); }
.si-pins tr.is-active td { background: color-mix(in srgb, var(--success) 10%, transparent); }
.si-active { display: inline-block; padding: 0 6px; border-radius: 999px; font: 600 9.5px var(--sans); color: var(--success); background: color-mix(in srgb, var(--success) 18%, transparent); vertical-align: 1px; }
.si-link { color: var(--primary); font: inherit; text-align: left; }
.si-link:hover { text-decoration: underline; }
.si-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.si-actions .chip[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

.schem-minimap { position: absolute; left: 10px; bottom: 10px; z-index: 2; width: 140px; height: 90px; border-radius: 8px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--hair); cursor: crosshair; touch-action: none; }
.schem-minimap[hidden] { display: none; }
.mm-node { fill: color-mix(in srgb, var(--text) 30%, transparent); }
.mm-node.kind-module { fill: color-mix(in srgb, var(--primary) 55%, transparent); }
.mm-node.kind-dff, .mm-node.kind-mem { fill: color-mix(in srgb, var(--accent) 55%, transparent); }
.mm-node.kind-latch { fill: var(--warning); }
.mm-view { fill: color-mix(in srgb, var(--primary) 12%, transparent); stroke: var(--primary); vector-effect: non-scaling-stroke; stroke-width: 1.5; }

.schem-learn-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; font-size: 11.5px; min-height: 24px; }
.schem-learn-bar[hidden] { display: none; }
.learn-pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font: 600 11.5px var(--mono); white-space: nowrap; background: var(--chip); color: var(--text); }
.learn-instr { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.learn-label { color: var(--muted); font-size: 11px; }
.learn-change.kind-mem { color: var(--success); background: color-mix(in srgb, var(--success) 13%, transparent); }
button.learn-change:hover { filter: brightness(1.2); }
.learn-change.kind-state { color: var(--s-control); background: color-mix(in srgb, var(--s-control) 14%, transparent); }
.learn-idle { color: var(--muted); font-weight: 500; }
.learn-more { color: var(--muted); font-size: 11px; }
@media (max-width: 640px) {
  .schem-find input { width: 110px; }
  .schem-inspector { left: 0; right: 0; bottom: 0; width: auto; max-height: 55%; border-radius: 14px 14px 0 0; }
}
.schem-wire-labels { pointer-events: none; }

/* ------------------------------------------------------------------ featured banner & interactive tour */
.showcase-btn {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  font-weight: 600;
}
.showcase-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 20%, transparent); }

.featured-hero, .tour-rail {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transform: translateY(-4px);
  flex: none;
  overflow: hidden;
  transition: grid-template-rows .24s cubic-bezier(.2, .8, .2, 1), opacity .2s ease, transform .24s cubic-bezier(.2, .8, .2, 1);
}
.featured-hero[hidden], .tour-rail[hidden] { display: none; }
.featured-hero.is-open, .tour-rail.is-open { grid-template-rows: 1fr; opacity: 1; transform: none; }
.featured-inner, .tour-inner { min-height: 0; overflow: hidden; }

.featured-hero {
  background:
    radial-gradient(640px 180px at 8% 0%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%),
    radial-gradient(520px 160px at 92% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 72%),
    var(--panel);
  border-bottom: 1px solid var(--hair);
}
.featured-inner { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.featured-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.featured-copy { flex: 1 1 320px; min-width: 0; }
.featured-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  margin-bottom: 5px;
}
.featured-copy h2 { margin: 0; font-size: 15.5px; font-weight: 700; line-height: 1.25; }
.featured-copy p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; max-width: 68ch; }
.featured-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.featured-chapters { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
.featured-chapters::-webkit-scrollbar { display: none; }
.featured-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--hair);
  font-size: 12px;
  white-space: nowrap;
  flex: none;
}
.featured-chip:hover { border-color: color-mix(in srgb, var(--primary) 55%, transparent); background: color-mix(in srgb, var(--primary) 9%, var(--raised)); }
.fc-num {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font: 700 10.5px var(--mono);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.tour-rail {
  background: color-mix(in srgb, var(--primary) 5%, var(--panel));
  border-bottom: 1px solid var(--hair);
  box-shadow: inset 3px 0 0 var(--primary);
}
.tour-inner { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; }
.tour-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tour-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  font: 700 11px var(--mono);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}
.tour-steps { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tour-steps::-webkit-scrollbar { display: none; }
.tour-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 4px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--chip);
  white-space: nowrap;
  flex: none;
}
.tour-step:hover { color: var(--text); background: var(--hover); }
.ts-dot {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font: 700 10px var(--mono);
  background: color-mix(in srgb, var(--text) 10%, transparent);
}
.tour-step.is-active { color: var(--text); font-weight: 600; background: color-mix(in srgb, var(--primary) 18%, transparent); }
.tour-step.is-active .ts-dot { background: var(--primary); color: #fff; }
.tour-step.is-done { color: var(--success); }
.tour-step.is-done .ts-dot { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.tour-busy {
  flex: none;
  font-size: 11.5px;
  color: var(--accent);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tour-busy::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; }
.tour-busy[hidden] { display: none; }
.tour-close { width: 24px; height: 24px; flex: none; }
.tour-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tour-copy { margin: 0; flex: 1 1 280px; min-width: 0; font-size: 12.5px; color: var(--text); line-height: 1.38; }
.tour-copy.is-swapping { animation: tourSwap .18s ease-out; }
.tour-controls { display: inline-flex; align-items: center; gap: 6px; flex: none; }

.dialog-tour-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: linear-gradient(125deg, color-mix(in srgb, var(--primary) 14%, var(--raised)), color-mix(in srgb, var(--accent) 8%, var(--raised)));
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--hair));
}
.dialog-tour-hero strong { display: block; font-size: 13.5px; }
.dialog-tour-hero small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel-body:not([hidden]) { animation: panelFade .15s ease-out; }
.tour-spot { box-shadow: 0 0 0 2px var(--accent), 0 0 14px color-mix(in srgb, var(--accent) 36%, transparent); border-radius: 8px; animation: tourSpot 1.9s ease-in-out infinite; }
.schem-cell.tour-spot { box-shadow: none; border-radius: 0; animation: none; }
.schem-cell.tour-spot .schem-shape { stroke: var(--accent) !important; stroke-width: 2.8; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 75%, transparent)); }

@keyframes panelFade { from { opacity: .65; } to { opacity: 1; } }
@keyframes tourSwap { from { opacity: .35; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes tourSpot { 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 20px color-mix(in srgb, var(--accent) 52%, transparent); } }

body.is-zen .featured-hero, body.is-zen .tour-rail { display: none !important; }

@media (min-width: 1080px) {
  .tour-inner { flex-direction: row; align-items: center; gap: 10px; padding: 5px 12px; }
  .tour-nav, .tour-bar { display: contents; }
  .tour-steps { flex: 0 1 auto; }
  .tour-copy { flex: 1 1 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tour-close { order: 10; }
}

@media (max-width: 900px) {
  .featured-inner { padding: 10px 10px; gap: 8px; }
  .featured-copy h2 { font-size: 14px; }
  .featured-copy p { font-size: 12px; }
  .tour-inner { padding: 7px 10px; gap: 5px; }
  .tour-copy { font-size: 12px; }
  .tour-controls { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .featured-hero, .tour-rail, .panel-body:not([hidden]), .tour-copy.is-swapping, .tour-spot { animation: none !important; transition: none !important; }
}
.cm-inline-val { margin-left: 10px; padding: 0 6px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 9%, transparent); border: 1px solid color-mix(in srgb, var(--border, var(--hair)) 75%, transparent); color: var(--muted); font: 0.84em var(--mono); user-select: none; }
.hierarchy-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar > .side-head { min-width: 0; padding: 6px 8px 3px; }
.side-switch { display: flex; width: 100%; padding: 2px; border-radius: 8px; background: var(--chip); }
.side-switch .chip { flex: 1; justify-content: center; padding: 4px; }
.side-actions { display: flex; justify-content: space-evenly; align-items: center; padding: 2px 6px 4px; min-width: 0; }
.side-actions .icon-btn { flex: 0 1 25px; min-width: 0; }
.schem-toolbar .chip, .wave-toolbar .chip { padding: 3px 7px; }
.schem-toolbar .spacer { display: none; }
.schem-toolbar > *, .wave-toolbar > * { max-width: 100%; }
.schem-crumbs { max-width: 100%; overflow-x: auto; }
#wave-cursor { white-space: normal; overflow-wrap: anywhere; }

/* Strict lint and synthesis insights share the workspace's theme colors. */
.problem-detail { min-width: 0; overflow-wrap: anywhere; }
.problem-rule { display: inline-block; color: var(--warning); background: color-mix(in srgb, var(--warning) 13%, transparent); border-radius: 4px; padding: 0 4px; font-size: 11px; font-weight: 700; }
.problem-hint { display: block; color: var(--muted); font: 11.5px/1.4 var(--sans); margin-top: 2px; }
#schem-critpath[aria-pressed="true"], #schem-resources[aria-pressed="true"] { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 15%, var(--chip)); }
.schem-cell.is-critpath .schem-shape { stroke: var(--warning) !important; stroke-width: 3 !important; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--warning) 65%, transparent)); }
.schem-wire.is-critpath { stroke: var(--warning) !important; stroke-width: 3.5 !important; }
.schem-canvas.has-focus .schem-cell.is-critpath, .schem-canvas.has-focus .schem-wire.is-critpath { opacity: 1; }
#schem-critpath-banner, #schem-resources-panel { flex: none; min-width: 0; max-height: min(18vh, 128px); overflow: auto; padding: 7px 9px; border: 1px solid var(--hair); border-radius: 7px; color: var(--text); background: var(--panel); font-size: 12px; }
#schem-critpath-banner strong { color: var(--warning); overflow-wrap: anywhere; }
.schem-critical-steps, .schem-resource-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.schem-critical-steps { flex-wrap: nowrap; overflow-x: auto; }
.schem-critical-steps .chip { flex: none; white-space: nowrap; }
.schem-resource-badge { padding: 2px 6px; border-radius: 5px; background: var(--chip); white-space: nowrap; }
.schem-resource-table { width: 100%; border-collapse: collapse; margin-top: 6px; text-align: left; font-size: 11px; }
.schem-resource-table th, .schem-resource-table td { padding: 3px 5px; border-bottom: 1px solid var(--hair); }
.schem-resource-table td:first-child { overflow-wrap: anywhere; }
.schem-resource-table button { color: var(--primary); padding: 0; text-align: left; background: none; border: 0; cursor: pointer; }
@media (max-width: 900px) {
  #schem-critpath-banner, #schem-resources-panel { max-height: 15vh; }
  .schem-resource-table { font-size: 10px; }
  .schem-resource-table th, .schem-resource-table td { padding: 3px 2px; }
}

/* Editor craft, tab actions and workspace replacement. */
.cm-word-occ { background: color-mix(in srgb, var(--primary) 13%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent); border-radius: 2px; }
.cm-indent-guide { border-left: 1px solid color-mix(in srgb, var(--muted) 28%, transparent); box-sizing: border-box; }
.cm-hover-card { max-width: min(360px, 85vw); max-height: 40vh; overflow: auto; padding: 8px 10px; color: var(--text); background: var(--raised); border: 1px solid var(--hair); border-radius: 7px; font-size: 12px; }
.cm-editor.is-module-drop { outline: 2px dashed var(--primary); outline-offset: -3px; background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.group-tab.is-pinned { color: var(--primary); }
.tab-pin { font-size: 9px; margin-left: 6px; color: var(--primary); }
.tab-context-menu { position: fixed; z-index: 1000; min-width: 160px; max-width: calc(100vw - 8px); padding: 4px; background: var(--raised); border: 1px solid var(--hair); border-radius: 8px; box-shadow: 0 8px 24px #0006; }
.tab-context-menu button { display: block; width: 100%; padding: 6px 10px; text-align: left; color: var(--text); border-radius: 5px; font-size: 12px; }
.tab-context-menu button:hover:not(:disabled), .tab-context-menu button:focus-visible { background: var(--hover); }
.tab-context-menu button:disabled { opacity: .45; }
.search-options { flex-wrap: wrap; gap: 6px 12px; }
.search-replace-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.search-replace-row input { flex: 1 1 160px; min-width: 0; max-width: 100%; padding: 6px 8px; color: var(--text); background: var(--chip); border: 1px solid var(--hair); border-radius: var(--radius); }
.search-count.is-error { color: var(--error); overflow-wrap: anywhere; }

/* Tactile waveform, schematic and board interactions. */
.wave-zoom-box { position: absolute; top: 0; bottom: 0; z-index: 4; min-width: 1px; pointer-events: none; background: color-mix(in srgb, var(--primary) 25%, transparent); border: 1px solid var(--primary); color: var(--text); font: 10px var(--mono); white-space: nowrap; }
#waveform.is-plot-drop { outline: 2px dashed var(--primary); outline-offset: -3px; background: color-mix(in srgb, var(--primary) 8%, var(--panel)); }
.wave-row.is-drop-above { box-shadow: inset 0 3px var(--primary); }
.wave-row.is-drop-below { box-shadow: inset 0 -3px var(--primary); }
.schem-inspector header { cursor: grab; touch-action: none; user-select: none; }
.schem-inspector.is-dragging header, .schem-cell.is-dragging { cursor: grabbing; }
.schem-cell.is-dragging .schem-shape { stroke: var(--primary); stroke-width: 2.5; }
.schem-cell { touch-action: none; }
.si-pins tr[draggable="true"] { cursor: grab; }
#schem-reset-layout:not(:disabled) { color: var(--primary); }
.board-widget > header[draggable="true"], .board-input-name[draggable="true"] { cursor: grab; }
.board-widget.is-dragging, .board-input.is-dragging { opacity: .45; }
.board-widget.is-drop-before, .board-input.is-drop-before { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Compact editor navigation, quick open and tactile actions. */
.editor-column { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
#editor-breadcrumbs { display: flex; align-items: center; gap: 4px; height: 22px; flex: none; min-width: 0; padding: 0 8px; overflow-x: auto; color: var(--muted); background: var(--surface); font: 11px var(--mono); }
#editor-breadcrumbs button { color: inherit; white-space: nowrap; padding: 2px 3px; border-radius: 4px; }
#editor-breadcrumbs button:hover { color: var(--text); background: var(--hover); }
body.dock-maximized .editor-column, .mode-wave .editor-column { display: none; }
@media (max-width: 900px) { body[data-view="console"] .editor-column, body[data-view="waveform"] .editor-column { display: none; } }
#quick-open-dialog { width: min(680px, 94vw); }
#quick-open-input { width: 100%; border: 0; border-bottom: 1px solid var(--hair); border-radius: 0; }
.quick-open-item { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 7px 10px; color: var(--text); text-align: left; }
.quick-open-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-open-item small { margin-left: auto; flex: none; color: var(--muted); font-size: 11px; }
.quick-open-item.selected, .quick-open-item:hover { background: var(--sel); }
.problem-row { display: flex; align-items: center; gap: 4px; }
.problem-row .problem-item { flex: 1; min-width: 0; }
.problem-fix { flex: none; margin-right: 5px; }
.hierarchy-row { display: flex; align-items: center; min-width: 0; }
.hierarchy-row .hierarchy-item { flex: 1; min-width: 0; }
.hierarchy-add { flex: none; padding: 2px 7px; color: var(--primary); border-radius: 5px; }
.hierarchy-add:hover { background: var(--hover); }
.panel-tabs .is-dragging { opacity: .5; }
.panel-tabs .is-drop-target, #toggle-dock-side.is-drop-target { outline: 2px solid var(--primary); outline-offset: -2px; }
.signal-inspector-row[draggable="true"] { cursor: grab; }

.bridge-pill { flex: none; color: var(--primary); background: var(--chip); border-radius: 99px; padding: 2px 8px; font-size: 11px; white-space: nowrap; }
.bridge-pill.is-disconnected { color: var(--muted); }
.bridge-dialog { width: min(520px, 94vw); }
.bridge-dialog > input { width: 100%; margin-bottom: 10px; }
.bridge-dialog h3 { font-size: 12px; color: var(--muted); }
#bridge-clients { max-height: 130px; overflow: auto; padding-left: 20px; color: var(--text); font-size: 12px; }
#bridge-status { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { body:not(.status-hidden):has(#bridge-pill:not([hidden])) .statusbar { display: flex; } }
