/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1e1a1a;
  --surface:   #24242a;
  --border:    #38383f;
  --accent:    #7c6af2;
  --accent2:   #5fa8d3;
  --text:      #d4d4d8;
  --text-dim:  #71717a;
  --text-em:   #f4f4f5;
  --ok:        #4ade80;
  --ok-a10:    rgba(74, 222, 128, 0.10);
  --err:       #f87171;
  --warn:      #fbbf24;
  --accent-a06: rgba(124, 106, 242, 0.06);
  --accent-a08: rgba(124, 106, 242, 0.08);
  --accent-a12: rgba(124, 106, 242, 0.12);
  --accent-a15: rgba(124, 106, 242, 0.15);
  --accent-a18: rgba(124, 106, 242, 0.18);
  --accent-a20: rgba(124, 106, 242, 0.20);
  --accent-a35: rgba(124, 106, 242, 0.35);
  --accent-a40: rgba(124, 106, 242, 0.40);
  --err-a08:    rgba(248, 113, 113, 0.08);
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --font-ui:   system-ui, -apple-system, sans-serif;
  --radius:    6px;
  --header-h:  44px;
  --pane-hdr:  36px;
  --splitter-line: 1px;
  --splitter-hitbox: 8px;
}

/* ── Rock Bottom light theme ── */
[data-theme="light"] {
  --bg:        #efece4;
  --surface:   #e5e2d8;
  --border:    #c9c4b4;
  --accent:    #4a7c7c;
  --accent2:   #3d6b6b;
  --text:      #4a4740;
  --text-dim:  #8a857a;
  --text-em:   #2a2824;
  --ok:        #3a7a52;
  --ok-a10:    rgba(58, 122, 82, 0.10);
  --err:       #b54a3a;
  --warn:      #9a7020;
  --accent-a06: rgba(74, 124, 124, 0.07);
  --accent-a08: rgba(74, 124, 124, 0.10);
  --accent-a12: rgba(74, 124, 124, 0.14);
  --accent-a15: rgba(74, 124, 124, 0.18);
  --accent-a18: rgba(74, 124, 124, 0.22);
  --accent-a20: rgba(74, 124, 124, 0.25);
  --accent-a35: rgba(74, 124, 124, 0.30);
  --accent-a40: rgba(74, 124, 124, 0.35);
  --err-a08:    rgba(181, 74, 58, 0.10);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
}
body.is-resizing,
body.is-resizing * {
  user-select: none;
}
body.is-resizing {
  cursor: var(--resize-cursor, default);
}

/* ── Top header ── */
header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}
/* ── Three-pane workspace ── */
.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) var(--splitter-line) minmax(260px, 1fr) var(--splitter-line) minmax(280px, 1fr);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.pane-header {
  height: var(--pane-hdr);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pane-title {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.pane-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-body-analysis {
  display: grid;
  grid-template-rows: minmax(120px, 1fr) var(--splitter-line) minmax(180px, 1fr);
  min-height: 0;
}

.pane-splitter {
  position: relative;
  background: transparent;
  touch-action: none;
  z-index: 2;
}
.pane-splitter::before {
  content: "";
  position: absolute;
  background: var(--border);
}
.pane-splitter:hover,
.pane-splitter.is-active {
  background: var(--accent-a40);
}
.pane-splitter-x {
  width: var(--splitter-hitbox);
  justify-self: center;
  align-self: stretch;
  cursor: ew-resize;
}
.pane-splitter-x::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}
.pane-splitter-y {
  height: var(--splitter-hitbox);
  align-self: center;
  justify-self: stretch;
  cursor: ns-resize;
}
.pane-splitter-y::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}

/* ── Buttons ── */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-primary:hover  { opacity: 0.85; }
.btn-secondary:hover { opacity: 0.75; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── File pane ── */
.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sel-examples {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
  max-width: 140px;
}
.sel-examples:focus { border-color: var(--accent); }

.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}
.editor-wrap .cm-editor {
  height: 100%;
  color: var(--text);
}
.editor-wrap .cm-scroller {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
}
.editor-wrap .cm-content {
  padding: 12px 0;
}
.editor-wrap .cm-gutters {
  background: var(--bg);
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 0 4px 0 8px;
}
.editor-wrap .cm-activeLineGutter {
  background: transparent;
  color: var(--text);
}
.editor-wrap .cm-activeLine {
  background: var(--accent-a06);
}
.editor-wrap .cm-selectionBackground {
  background: var(--accent-a35) !important;
}
.editor-wrap .cm-cursor {
  border-left-color: var(--text);
}
.editor-wrap .cm-panels {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
}
.editor-wrap .cm-search {
  padding: 6px 10px;
}
.editor-wrap .cm-search .cm-textfield {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  outline: none;
  min-width: 140px;
}
.editor-wrap .cm-search .cm-textfield:focus {
  border-color: var(--accent);
}
.editor-wrap .cm-button {
  all: unset !important;
  display: inline-block !important;
  background: var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  font: 12px var(--font-ui) !important;
  -webkit-font-smoothing: auto !important;
  padding: 4px 12px !important;
  cursor: pointer !important;
  text-transform: capitalize !important;
  transition: opacity 0.15s !important;
  margin: 0 3px !important;
}
.editor-wrap .cm-button:active {
  all: unset !important;
  display: inline-block !important;
  background: var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  font: 12px var(--font-ui) !important;
  -webkit-font-smoothing: auto !important;
  padding: 4px 12px !important;
  cursor: pointer !important;
  text-transform: capitalize !important;
  margin: 0 3px !important;
}
.editor-wrap .cm-button:hover {
  opacity: 0.75 !important;
}
.editor-wrap .cm-search label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}
.editor-wrap .cm-search input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0 0 0 6px;
}
.editor-wrap .cm-search button[name="close"] {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  margin-left: auto;
}
.editor-wrap .cm-search button[name="close"]:hover { color: var(--text); }
.editor-wrap .cm-selectionMatch {
  background: var(--accent-a20);
}
.editor-wrap .cm-searchMatch {
  background: var(--accent-a35);
}
.editor-wrap .cm-searchMatch-selected {
  background: var(--accent-a40);
}

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  height: 28px;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar {
  display: none;
}
.tab-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 160px;
  overflow: hidden;
}
.tab-item:hover {
  background: var(--accent-a08);
}
.tab-item--active {
  color: var(--text-em);
  background: var(--bg);
  border-bottom: 2px solid var(--accent);
}
.tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-item--dirty .tab-name::after {
  content: ' •';
  color: var(--text-dim);
}
.tab-close {
  font-size: 10px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  visibility: hidden;
}
.tab-item:hover .tab-close,
.tab-item--active .tab-close {
  visibility: visible;
}
.tab-close:hover {
  color: var(--err);
}
.tab-new {
  padding: 0 10px;
  font-size: 14px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
}
.tab-new:hover {
  color: var(--text-em);
}
.tab-rename {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  color: var(--text-em);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0 4px;
  width: 90px;
  outline: none;
}
.tab-rename--error {
  border-color: var(--err);
  color: var(--err);
}

.output-area {
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-y: auto;
  color: var(--text-dim);
  min-height: 0;
}

/* ── Accordion ── */
.acc-module {
  border-bottom: 1px solid var(--border);
}
.acc-module > summary {
  padding: 6px 12px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.acc-module > summary::before {
  content: "▸ ";
}
.acc-module[open] > summary::before {
  content: "▾ ";
}
.acc-module > .acc-type {
  border-bottom: none;
}
.acc-module > .acc-type:last-child {
  border-bottom: none;
}
.acc-type {
  border-bottom: 1px solid var(--border);
}
.acc-type > summary {
  padding: 6px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--accent2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.acc-type > summary::before {
  content: "▸ ";
  color: var(--text-dim);
}
.acc-type[open] > summary::before {
  content: "▾ ";
}
.acc-type-body {
  padding-left: 8px;
}

.acc-section > summary {
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.acc-section > summary::before {
  content: "▸ ";
}
.acc-section[open] > summary::before {
  content: "▾ ";
}
.acc-count {
  font-weight: 400;
  opacity: 0.6;
}
.acc-section-body {
  padding-left: 8px;
}

.acc-item > summary {
  padding: 2px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.acc-item > summary::before {
  content: "▸ ";
  color: var(--text-dim);
}
.acc-item[open] > summary::before {
  content: "▾ ";
}
.acc-item-body {
  padding: 1px 12px 4px 24px;
  color: var(--text-dim);
}
.acc-leaf {
  padding: 2px 12px;
}
.acc-dim {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* Hover highlights for all accordion rows */
.acc-module > summary:hover,
.acc-type > summary:hover,
.acc-section > summary:hover,
.acc-item > summary:hover,
.acc-leaf:hover {
  background: var(--accent-a08);
}

/* ── Thin toggle on generator rows ── */
.acc-leaf-gen {
  display: flex;
  align-items: center;
}
.acc-leaf-text {
  flex: 1;
  min-width: 0;
}
.acc-leaf--thin .acc-leaf-text {
  opacity: 0.45;
}
.thin-toggle {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.acc-leaf-gen:hover .thin-toggle,
.thin-toggle--active {
  opacity: 1;
}
.thin-toggle::after {
  content: '';
  display: block;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: all 0.15s ease;
}
.thin-toggle--active::after {
  width: 5px;
  height: 5px;
  background: var(--text-dim);
  border: none;
}

/* ── Analysis pane ── */
.vis-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}
.vis-controls select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  padding: 2px 6px;
  outline: none;
}
.vis-controls select:focus { border-color: var(--accent); }

.appearance-dropdown { position: relative; }
.appearance-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s;
}
.appearance-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.appearance-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  z-index: 20;
  min-width: 200px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.appearance-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.appearance-item:hover { background: var(--accent-a08); }
.appearance-item input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}
.appearance-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 10px;
}
.appearance-item select {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  padding: 2px 6px;
  outline: none;
}
.appearance-item select:focus { border-color: var(--accent); }
.zoom-slider {
  width: 80px;
  margin-left: auto;
  accent-color: var(--accent);
}
.zoom-label {
  font-family: var(--font-mono);
  font-size: 11px;
  min-width: 30px;
  text-align: right;
}
.btn-zoom-reset {
  background: var(--border);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
}
.btn-zoom-reset:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Infobox ── */
.infobox {
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(56px, auto) var(--splitter-line) minmax(120px, 1fr) var(--splitter-line) minmax(72px, 0.45fr);
}
.infobox[hidden] { display: none; }
.infobox-header {
  min-height: 0;
  overflow-y: auto;
  background: var(--surface);
}
.infobox-text {
  padding: 8px 12px;
  color: var(--text);
  line-height: 1.6;
}
.infobox-qual {
  font-size: 11px;
  color: var(--text-dim);
}
.infobox-name {
  font-weight: 600;
}
.infobox-actions {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 4px;
}
.btn-target-vis, .btn-undo-vis, .btn-redo-vis {
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  cursor: pointer;
  user-select: none;
}
.btn-target-vis:active { background: var(--accent); color: #fff; }
.btn-undo-vis, .btn-redo-vis { font-size: 14px; }
.btn-undo-vis:disabled, .btn-redo-vis:disabled { cursor: not-allowed; }
.btn-view-toggle {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.15s, border-color 0.15s;
}
.btn-view-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.infobox-text { position: relative; }

.infobox-label {
  margin-top: 2px;
}
.infobox-boundary {
  color: var(--text-dim);
  margin-top: 2px;
}
/* Open holes of a map, shown above the "Image of" selector. */
.infobox-holes {
  margin-top: 6px;
}
.infobox-holes-title {
  font-size: 11px;
  color: var(--text-dim);
}
.infobox-hole {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.infobox-hole-bd {
  flex: 1;
  font-family: var(--font-mono, monospace);
}
.btn-fill-hole {
  padding: 2px 10px;
  font-size: 11px;
}
/* The fill session's Done button, sized to match the other infobox actions. */
.btn-done-fill {
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
}
.btn-done-fill:disabled { cursor: not-allowed; }
/* Transient highlight over a clause inserted by `done`. */
.cm-fill-flash {
  background: var(--ok-a10);
  border-radius: 2px;
  animation: banner-in 0.4s ease-out;
}
.infobox-map-gen {
  margin-top: 4px;
}
.infobox-map-gen label {
  width: auto;
  font-family: var(--font-ui);
}
.infobox-map-gen select {
  font-family: var(--font-ui);
}
.target-reached-banner {
  margin-top: 6px;
  padding: 3px 8px;
  background: var(--ok-a10);
  border-left: 2px solid var(--ok);
  color: var(--ok);
  font-weight: 600;
  font-size: 11px;
  animation: banner-in 0.4s ease-out;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.boundary-controls[hidden] { display: none; }
.boundary-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 6px;
  font-size: 12px;
}
.boundary-controls select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  padding: 2px 6px;
  outline: none;
}
.boundary-controls select:focus { border-color: var(--accent); }
.sign-controls {
  display: inline-flex;
  gap: 8px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 11px;
}
.sign-controls label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.sign-controls input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

.vis-container {
  position: relative;
  overflow: auto;
  min-height: 0;
}
.vis-container.target-reached-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ok-a10);
  pointer-events: none;
  animation: reached-flash 1.2s ease-out forwards;
}
@keyframes reached-flash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}
.vis-container canvas {
  display: block;
}

/* ── Rewrite list ── */
.rewrite-list {
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 0;
  min-height: 0;
}
.rewrite-row {
  padding: 4px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}
.rewrite-row:hover { background: var(--accent-a08); }
.rewrite-row--selected { background: var(--accent-a15) !important; }
.rewrite-row .rw-index { color: var(--accent); font-weight: 600; min-width: 24px; }
.rewrite-row .rw-name { color: var(--text-em); }
.rw-parallel-badge {
  font-size: 0.8em;
  color: var(--accent2);
  border: 1px solid var(--accent2);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
}
.rewrite-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  visibility: hidden;
}
.rewrite-row:hover .rewrite-actions {
  visibility: visible;
}
.rw-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.rewrite-actions button {
  border: none;
  border-radius: var(--radius);
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
}
.rw-btn-preview, .rw-btn-bunch {
  background: var(--border);
  color: var(--text);
}
.rw-btn-preview:hover, .rw-btn-bunch:hover { background: var(--accent); color: #fff; }
.rw-btn-preview:active, .rw-btn-bunch:active { background: var(--accent); color: #fff; }

/* Bunch card */
.rewrite-row--bunch {
  background: var(--accent-a12);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
  margin-bottom: 4px;
}
.rewrite-row--bunch:hover { background: var(--accent-a20); }
.rewrite-actions--bunch { visibility: visible; }
.rw-bunch-label {
  color: var(--accent);
  font-weight: 600;
  min-width: 24px;
}
.rw-btn-unbunch {
  background: var(--border);
  color: var(--text);
}
.rw-btn-unbunch:hover { background: #c44; color: #fff; }
.rw-btn-unbunch:active { background: #c44; color: #fff; }

/* ── Selected accordion item ── */
.acc-leaf--selected {
  background: var(--accent-a18) !important;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.vis-info {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
  text-align: center;
  line-height: 1.6;
}

/* ── REPL pane ── */
.repl-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.session-setup {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  flex-shrink: 0;
}
.session-setup[hidden] { display: none; }
.session-stop {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.session-stop[hidden] { display: none; }
.session-stop button { width: 100%; }
.setup-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.setup-row label {
  width: 52px;
  text-align: right;
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}
.setup-row select, .setup-row input[type="text"] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
}
.setup-row select:focus, .setup-row input[type="text"]:focus {
  border-color: var(--accent);
}
.setup-row .setup-check {
  width: auto;
  text-align: left;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.setup-check input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

.repl-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  min-height: 0;
}

.repl-entry { margin-bottom: 8px; }
.repl-cmd { color: var(--text-em); }
.repl-cmd::before { content: "> "; color: var(--accent); }
.repl-result { color: var(--text-dim); white-space: pre-wrap; }
.repl-result.ok  { color: var(--text); }
.repl-result.err { color: var(--err); }

.err-block { margin-top: 2px; }
.err-block + .err-block { margin-top: 6px; }
.err-header { white-space: pre-wrap; }
.err-kind { font-weight: 600; }
.err-loc { color: var(--text-dim); }
.err-msg { color: var(--err); }
.err-snippet {
  margin: 4px 0 0 0;
  padding: 4px 8px;
  background: var(--err-a08);
  border-left: 2px solid var(--err);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre;
  overflow-x: auto;
}
.err-note {
  color: var(--text-dim);
  margin-top: 2px;
  padding-left: 8px;
}

.repl-section-title {
  color: var(--accent2);
  font-weight: 600;
  margin-bottom: 2px;
}
.repl-dim { color: var(--text-dim); }
.repl-hi  { color: var(--text-em); }
.repl-ok  { color: var(--ok); }
.repl-match-hi { color: var(--warn); font-weight: 600; }
.repl-src { color: var(--warn); font-weight: 600; }
.repl-tgt { color: var(--accent2); font-weight: 600; }
.repl-warn { color: var(--warn); }

.repl-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.repl-prompt { color: var(--accent); font-family: var(--font-mono); font-size: 13px; }
.repl-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-em);
  font-family: var(--font-mono);
  font-size: 13px;
}
.repl-input::placeholder { color: var(--text-dim); }
.repl-input:disabled { opacity: 0.4; }

/* ── Theme toggle ── */
.header-spacer { flex: 1; }
.btn-theme {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.15s, border-color 0.15s;
}
.btn-theme:hover {
  color: var(--text);
  border-color: var(--accent);
}
