:root {
  --bg: #080c13;
  --bg-grid: rgba(56, 189, 248, 0.035);
  --surface: #101725;
  --surface-2: #162033;
  --surface-3: #1e2c44;
  --border: #24324c;
  --border-hi: #354b70;
  --text: #e6eef9;
  --text-muted: #93a5c0;
  --text-dim: #64748b;

  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --cyan: #38bdf8;
  --cyan-soft: rgba(56, 189, 248, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.15);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.15);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}

button, select, input, textarea {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 12, 19, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.brand-chip {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, #14243d, #0d1525);
  border: 1px solid var(--cyan);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.22);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.select {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  max-width: 240px;
}

.synth-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  border: 1px solid var(--border-hi);
  background: var(--surface-2);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.synth-pill.ok {
  border-color: rgba(16, 185, 129, 0.45);
  background: var(--green-soft);
  color: #a7f3d0;
}

.synth-pill.err {
  border-color: rgba(251, 113, 133, 0.55);
  background: var(--rose-soft);
  color: #fecdd3;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Buttons & Badges */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: var(--text);
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: border-color 0.14s ease, background 0.14s ease;
  touch-action: manipulation;
}

.btn:hover { background: var(--surface-3); border-color: var(--cyan); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-primary { background: rgba(16, 185, 129, 0.18); border-color: var(--green); color: #a7f3d0; }
.btn-accent { background: var(--cyan-soft); border-color: var(--cyan); color: #bae6fd; }
.btn.active-toggle { background: var(--cyan-soft); border-color: var(--cyan); color: #fff; }

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge-green { background: var(--green-soft); border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.badge-cyan { background: var(--cyan-soft); border-color: rgba(56, 189, 248, 0.4); color: #7dd3fc; }
.badge-amber { background: var(--amber-soft); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
.badge-violet { background: var(--violet-soft); border-color: rgba(167, 139, 250, 0.4); color: #ddd6fe; }

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

/* Mobile View Switcher */
.mobile-nav {
  display: none;
  position: sticky;
  top: 52px;
  z-index: 35;
  background: rgba(10, 15, 25, 0.96);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  gap: 5px;
}

.mob-tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.mob-tab.active {
  background: var(--cyan-soft);
  border-color: var(--cyan);
  color: #fff;
}

/* Main Workbench Grid */
.workbench {
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 16px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.92fr);
  gap: 14px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
  max-width: 100%;
}

/* Editor Pane */
.pane-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.mobile-pip {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #090e18;
  border-bottom: 1px solid var(--border);
}

.pip-canvas {
  width: 72px;
  height: 54px;
  border-radius: 5px;
  border: 1px solid var(--border-hi);
  image-rendering: pixelated;
  background: #05080f;
  flex-shrink: 0;
}

.pip-info { flex: 1; min-width: 0; }
.pip-title { font-size: 12.5px; font-weight: 650; }
.pip-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.file-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #0c121e;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.file-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}

.file-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.file-tab.active {
  background: var(--surface-3);
  border-color: var(--cyan);
  color: #fff;
}

.file-tab-close {
  opacity: 0.6;
  font-size: 13px;
  line-height: 1;
}
.file-tab-close:hover { opacity: 1; color: var(--rose); }

.file-actions { display: flex; gap: 6px; }

/* IP Block Drawer */
.ip-drawer {
  background: #0b111d;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.ip-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 650;
  margin-bottom: 8px;
  color: var(--cyan);
}

.ip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 8px;
}

.ip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ip-card-title { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: #ddd6fe; }
.ip-card-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }

/* Mobile Quick-Insert Snippet Bar */
.snippet-bar {
  display: flex;
  gap: 5px;
  padding: 7px 10px;
  background: #0d1422;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.snippet-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: #cbd5e1;
  padding: 4px 9px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
}

.snippet-chip:hover { border-color: var(--cyan); color: #fff; }
.snippet-chip:active { background: var(--cyan-soft); }

/* Code Editor Shell */
.editor-shell {
  display: grid;
  grid-template-columns: 40px 1fr;
  background: #080d16;
  height: 580px;
  position: relative;
}

.line-gutter {
  background: #0a101b;
  border-right: 1px solid var(--border);
  padding: 12px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  text-align: right;
  overflow: hidden;
  user-select: none;
  white-space: pre;
}

.line-gutter .err-line {
  color: #fff;
  background: rgba(251, 113, 133, 0.55);
  border-radius: 3px;
  padding: 0 3px;
  display: inline-block;
}

.code-textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: #e2ecf9;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 12px;
  tab-size: 2;
  overflow: auto;
  white-space: pre;
}

.diag-bar {
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: #0b111d;
}

.diag-bar.ok { color: #86efac; }
.diag-bar.err { background: rgba(251, 113, 133, 0.12); color: #fecdd3; }
.diag-hint { color: var(--text-dim); font-size: 11px; }

/* Hardware Pane */
.pane-hardware {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.crt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.scanline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.crt-bezel {
  background: #04070d;
  border: 2px solid var(--border-hi);
  border-radius: 10px;
  padding: 8px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.85);
}

.crt-screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 5px;
  background: #05080f;
}

.crt-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
}

.sim-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.speed-group, .step-group {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* Arcade Gamepad */
.gamepad {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0b111d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  user-select: none;
  -webkit-user-select: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  grid-template-rows: repeat(3, 38px);
  gap: 3px;
  flex-shrink: 0;
}

.dpad-center {
  background: #121c2e;
  border-radius: 4px;
}

.pad-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: none;
}

.pad-btn.pressed, .pad-btn:active {
  background: var(--cyan);
  color: #031521;
  border-color: #bae6fd;
}

.pad-meta {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.pad-hint-main {
  font-size: 12px;
  color: var(--text);
  font-weight: 550;
}

.pad-hint-keys {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.ab-btns {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.ab-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
}

.ab-a {
  background: rgba(251, 113, 133, 0.18);
  border: 1.5px solid var(--rose);
  color: #fecdd3;
}
.ab-a.pressed, .ab-a:active { background: var(--rose); color: #1b0509; }

.ab-b {
  background: rgba(245, 158, 11, 0.16);
  border: 1.5px solid var(--amber);
  color: #fde68a;
}
.ab-b.pressed, .ab-b:active { background: var(--amber); color: #1c1002; }

/* Read-Only Visual Previews */
.vis-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.vis-tab {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.vis-tab.active {
  background: var(--violet-soft);
  border-color: var(--violet);
  color: #fff;
}

.vis-panel { display: none; min-width: 0; max-width: 100%; }
.vis-panel.active { display: block; }

/* RTL SVG Schematic */
.rtl-canvas-wrap {
  background: #070b13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.rtl-svg {
  width: 100%;
  min-width: 460px;
  height: auto;
  display: block;
}

.rtl-col-label {
  fill: #64748b;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.rtl-node { cursor: pointer; }
.rtl-node:hover .rtl-node-bg { stroke: #fff; stroke-width: 1.8; }
.rtl-node.selected .rtl-node-bg { stroke: #fff; stroke-width: 2.3; filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5)); }

.rtl-node-title {
  fill: #e6eef9;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
}

.rtl-node-sub {
  fill: #8ea1bd;
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.rtl-node-val {
  fill: #fcd34d;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
}

.rtl-wire {
  stroke: #263854;
  stroke-width: 1.2;
  transition: stroke 0.12s ease;
}
.rtl-wire.active { stroke: rgba(56, 189, 248, 0.65); }
.rtl-wire.rtl-wire-seq.active { stroke: rgba(245, 158, 11, 0.65); }
.rtl-wire.rtl-wire-out.active { stroke: rgba(16, 185, 129, 0.78); }
.rtl-wire.highlighted { stroke: #fff !important; stroke-width: 2.1; }

.rtl-inspector {
  margin-top: 10px;
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.insp-empty { color: var(--text-dim); font-size: 12px; }
.insp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.insp-vals {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.insp-vals b { color: var(--amber); }

.insp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.insp-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
}
.insp-row small { color: var(--text-dim); }
.insp-row code { color: var(--cyan); }

.insp-lut { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.insp-lut-title { font-family: var(--font-mono); font-size: 11px; color: var(--violet); margin-bottom: 6px; }
.mini-lut-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.mini-lut-cell {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.mini-lut-cell.hi { border-color: var(--green); background: var(--green-soft); color: #a7f3d0; }

/* Logic Scope */
.probe-bar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.probe-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}
.probe-chip.active {
  background: var(--cyan-soft);
  border-color: var(--cyan);
  color: #fff;
}

.scope-canvas {
  width: 100%;
  height: 210px;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #070b13;
}

/* FPGA Fabric Panel */
.fabric-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric-card {
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.metric-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-val { font-family: var(--font-mono); font-size: 16px; font-weight: 750; color: var(--cyan); margin-top: 2px; }

.fabric-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.fbar-row { display: flex; flex-direction: column; gap: 3px; }
.fbar-head { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.fbar-track { height: 7px; background: #090e18; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.fbar-fill { height: 100%; border-radius: 999px; }

.fabric-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

.reg-live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
}

.reg-live-card {
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--font-mono);
}

.reg-live-name { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-live-val { font-size: 12.5px; font-weight: 700; color: var(--amber); }

.lut-list { display: flex; flex-direction: column; gap: 8px; }
.lut-card {
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
}

/* 2D Die Floorplan & Bitstream Inspector */
.die-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.die-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.die-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.die-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.die-canvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #060a12;
  cursor: pointer;
}

.bitstream-box {
  margin-top: 10px;
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.bitstream-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bit-sec-bar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.bit-sec-chip {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bit-sec-chip small { opacity: 0.7; }

.bit-sec-chip.active {
  border-color: var(--sec-col, var(--cyan));
  background: rgba(56, 189, 248, 0.14);
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.16);
}

.bit-desc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.bit-dump {
  background: #060a12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: #7dd3fc;
  word-break: break-all;
}

.bit-raw {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  word-break: break-all;
}

.bit-raw code { color: #a7f3d0; }

/* =========================================================================
   MOBILE-FRIENDLY RESPONSIVE LAYOUT (< 1024px)
   ========================================================================= */
@media (max-width: 1023px) {
  .topbar {
    position: static;
    padding: 7px 10px;
    gap: 6px;
  }
  .topbar-left {
    width: 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .topbar-right {
    width: 100%;
    gap: 5px;
    flex-wrap: nowrap;
  }
  .brand-sub { display: none; }
  .brand-title { font-size: 13.5px; }
  .brand-chip { width: 26px; height: 26px; font-size: 9.5px; }
  .core-select { flex: 1; min-width: 0; max-width: none; font-size: 12px; padding: 5px 8px; }
  .synth-pill {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    font-size: 10.5px;
    padding: 4px 7px;
  }
  .topbar-right .btn-sm {
    padding: 4px 7px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .mobile-nav {
    display: flex;
    top: 0;
    padding: 6px 8px;
  }

  .workbench {
    grid-template-columns: 1fr;
    padding: 8px 8px 20px;
    gap: 10px;
  }

  .card { padding: 10px; }
  .crt-top { margin-bottom: 6px; gap: 5px; }
  .crt-bezel { padding: 6px; }
  .sim-controls { margin-top: 7px; gap: 5px; }
  .sim-controls .btn-sm { padding: 4px 7px; font-size: 11.5px; }
  .gamepad { margin-top: 8px; padding: 8px 12px; }

  /* Prevent iOS Safari zoom on editor focus! */
  .code-textarea, .line-gutter {
    font-size: 15px;
  }

  .file-bar { padding: 6px 8px; gap: 6px; }
  .editor-shell {
    height: 56vh;
    min-height: 300px;
  }

  .mobile-pip { display: flex; }

  /* Show/hide panels cleanly per active mobile tab */
  .workbench[data-mobile-view="play"] .pane-editor { display: none; }
  .workbench[data-mobile-view="play"] #section-visuals { display: none; }

  .workbench[data-mobile-view="code"] .pane-hardware { display: none; }

  .workbench[data-mobile-view="rtl"] .pane-editor,
  .workbench[data-mobile-view="die"] .pane-editor,
  .workbench[data-mobile-view="scope"] .pane-editor,
  .workbench[data-mobile-view="fabric"] .pane-editor { display: none; }

  .workbench[data-mobile-view="rtl"] #section-play,
  .workbench[data-mobile-view="die"] #section-play,
  .workbench[data-mobile-view="scope"] #section-play,
  .workbench[data-mobile-view="fabric"] #section-play { display: none; }

  .workbench[data-mobile-view="rtl"] .vis-tabs,
  .workbench[data-mobile-view="die"] .vis-tabs,
  .workbench[data-mobile-view="scope"] .vis-tabs,
  .workbench[data-mobile-view="fabric"] .vis-tabs { display: none; }

  .mob-tab { font-size: 11.5px; padding: 7px 2px; }

  .fabric-metrics { grid-template-columns: repeat(2, 1fr); }
  .pad-meta { display: none; }
  .dpad { grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 38px); }
  .ab-btn { width: 50px; height: 50px; }
}
