/* ============================
   Online compiler page
   Everything here is scoped to the compiler; the page used to carry an
   inline <style> block that had grown past what belongs in a document head.
   ============================ */

/* The stylesheet has no [hidden] rule of its own, so the UA default loses to
   any author `display` — .btn, .modal-overlay, .metrics and .popover all set
   one, which left every element this page hides with `el.hidden = true` still
   on screen. This file only loads here, so the override is page-scoped. */
[hidden] { display: none !important; }

.compiler-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.compiler-head h2 { margin: 0; font-size: 1.2rem; }
.compiler-anon { display: none; margin-left: auto; font-size: 0.8rem; color: var(--text3); }
.compiler-anon a { color: var(--accent); }

@media (max-width: 700px) {
  .compiler-tagline { display: none; }
}

/* ── Layout ───────────────────────────────────────────────── */
/* The split is a real, draggable column: --split holds the editor's share and
   is persisted, so the ratio survives a reload. */
.compiler-layout {
  display: grid;
  grid-template-columns: var(--split, 1fr) 10px minmax(280px, 1fr);
  gap: 0;
  align-items: start;
}
.editor-pane, .io-pane { min-width: 0; }
.io-pane { display: flex; flex-direction: column; gap: 1rem; }

.split-handle {
  align-self: stretch;
  min-height: 200px;
  cursor: col-resize;
  position: relative;
  background: transparent;
  border-radius: 2px;
}
.split-handle::after {
  content: '';
  position: absolute;
  inset: 0 4px;
  border-radius: 2px;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}
.split-handle:hover::after, .split-handle:focus-visible::after, .split-handle.dragging::after { opacity: 1; }
.split-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* While dragging, the iframe-like Monaco surface must not eat the mousemove. */
body.splitting { cursor: col-resize; user-select: none; }
body.splitting .editor-host { pointer-events: none; }

@media (max-width: 900px) {
  .compiler-layout { grid-template-columns: 1fr; gap: 1rem; }
  .split-handle { display: none; }
}

/* ── Panels and toolbars ──────────────────────────────────── */
#compilerRoot .panel-body { padding: 0.75rem 1rem; }

.tool-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.lang-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--accent); }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.3rem 0.45rem;
}
.icon-btn:hover { color: var(--text); background: var(--bg3); border-color: var(--border); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* ── File tabs (C++ in several files) ─────────────────────── */
.file-tabs {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.file-tabs[hidden] { display: none; }
.file-tab {
  display: flex;
  align-items: center;
  flex: none;
  border-right: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text2);
}
.file-tab.on { background: var(--bg); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.file-tab .ft-name {
  background: none; border: 0; color: inherit; font: inherit;
  padding: 0.45rem 0.75rem; cursor: pointer; white-space: nowrap;
}
.file-tab .ft-x {
  background: none; border: 0; color: var(--text3); cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 0.2rem 0.5rem 0.2rem 0; margin-left: -0.35rem;
}
.file-tab .ft-x:hover { color: var(--error); }
.ft-add {
  flex: none; background: none; border: 0; color: var(--text2); cursor: pointer;
  font-size: 1.05rem; padding: 0 0.8rem;
}
.ft-add:hover { color: var(--accent); }
.file-tab button:focus-visible, .ft-add:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ft-input {
  flex: none; width: 10rem; margin: 0.25rem 0.4rem; padding: 0.15rem 0.45rem;
  font-family: var(--mono); font-size: 0.8rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--accent); border-radius: var(--radius-sm);
}

/* ── Editor ───────────────────────────────────────────────── */
/* Draggable height as well as the draggable width of the split handle;
   Monaco's automaticLayout picks the resize up on its own. */
.editor-host {
  height: 460px;
  min-height: 160px;
  resize: vertical;
  overflow: hidden;
}

.editor-footer {
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.editor-footer #runBtn { flex: 1; min-width: 130px; }
.kbd-hint {
  font-size: 0.7rem;
  opacity: 0.75;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 0.25rem;
  margin-left: 0.35rem;
  white-space: nowrap;
}
.editor-stat { font-size: 0.75rem; color: var(--text3); font-variant-numeric: tabular-nums; }
.editor-footer .editor-stat:nth-of-type(1) { margin-left: auto; }

/* ── Focus mode ───────────────────────────────────────────── */
/* Not the Fullscreen API: staying in the document keeps the toasts, the
   settings popover and the snippet modal on screen with the editor. */
body.focus-mode .navbar,
body.focus-mode .compiler-head,
body.focus-mode .io-pane,
body.focus-mode .split-handle,
body.focus-mode #chat-widget,
body.focus-mode footer { display: none !important; }
body.focus-mode .compiler-layout { grid-template-columns: 1fr; }
body.focus-mode .page { padding: 0 !important; }
body.focus-mode .container { max-width: none; padding: 0; }
/* Fill the window: the editor keeps its fixed 460px otherwise, leaving most
   of a focus-mode screen empty. */
body.focus-mode .editor-pane {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
body.focus-mode .editor-host { flex: 1; height: auto; resize: none; }

/* ── Settings popover ─────────────────────────────────────── */
/* .question-panel is overflow:hidden, which would clip an absolutely
   positioned child. A fixed popover escapes that clipping (nothing here
   creates a containing block for it); JS parks it under the gear button. */
.popover {
  position: fixed;
  z-index: 60;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 250px;
  font-size: 0.85rem;
}
.popover label { display: flex; align-items: center; gap: 0.5rem; color: var(--text2); }
.popover label.check { cursor: pointer; }
.popover input[type=range] { flex: 1; }
.popover output { min-width: 2ch; text-align: right; color: var(--text); }
.popover select { margin-left: auto; }

/* ── Input options ────────────────────────────────────────── */
.mono { font-family: var(--mono); font-variant-ligatures: none; font-size: 0.875rem; }
#customInput { resize: vertical; }

.run-opts {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.run-opts label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text3);
  flex: 1;
  min-width: 150px;
}
.run-opts input { flex: 1; min-width: 0; padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* ── Output ───────────────────────────────────────────────── */
.status-chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.status-chip.ok      { background: var(--success-dim); color: var(--success); }
.status-chip.bad     { background: var(--error-dim);   color: var(--error); }
.status-chip.warn    { background: var(--warn-dim);    color: var(--warn); }
.status-chip.running { background: var(--accent-dim);  color: var(--accent); }

.metrics {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.metric {
  font-size: 0.7rem;
  color: var(--text2);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.45rem;
  font-variant-numeric: tabular-nums;
}
.metric b { color: var(--text); font-weight: 600; }

.output-area {
  margin: 0;
  min-height: 120px;
  max-height: 420px;
  overflow: auto;
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.85rem;
  color: var(--text2);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}
.output-area.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.output-area:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.stderr-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--error);
  margin: 0.7rem 0 0.3rem;
  letter-spacing: 0.03em;
}
.stderr-area { color: var(--error); background: var(--error-dim); min-height: 0; }

/* Why the run stopped, kept visually apart from whatever the program printed
   before it did. */
.run-message {
  color: var(--error);
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
}
/* With no stdout above it, the separator has nothing to separate. */
.output-area > .run-message:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* A compile/runtime error line the user can click to jump to in the editor. */
.err-jump {
  color: var(--error);
  text-decoration: underline dotted;
  cursor: pointer;
}
.err-jump:hover { text-decoration: underline; }

.truncated-note { color: var(--warn); font-size: 0.75rem; margin-top: 0.4rem; }

/* ── History ──────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 230px; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  cursor: pointer;
  font-size: 0.78rem;
  text-align: left;
  width: 100%;
  color: var(--text2);
}
.history-item:hover { background: var(--bg3); color: var(--text); }
.history-item .h-lang { font-weight: 600; color: var(--text); min-width: 4.5rem; }
.history-item .h-time { margin-left: auto; color: var(--text3); font-variant-numeric: tabular-nums; }

/* ── Snippets ─────────────────────────────────────────────── */
.save-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.save-row input { flex: 1; }
.snippet-list { display: flex; flex-direction: column; gap: 0.4rem; }
.snippet-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.snippet-row .s-name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-row .s-meta { font-size: 0.72rem; color: var(--text3); margin-left: auto; white-space: nowrap; }

/* ── Simulate ─────────────────────────────────────────────── */
.sim-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sim-switch:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.sim-switch input { margin: 0; accent-color: var(--accent); }

/* While a simulation is open, it sits beside the editor at the editor's
   height (compiler-sim.js, fitSimToEditor); the input and the run history step
   aside until it is closed. */
body.sim-on #inputPanel, body.sim-on #historyPanel { display: none; }
.sim-panel { display: flex; flex-direction: column; min-height: 360px; overflow: hidden; }
.sim-line-chip {
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.55rem;
  font-variant-numeric: tabular-nums;
}
.sim-line-chip:empty { display: none; }

.sim-note {
  font-size: 0.8rem;
  color: var(--warn);
  background: var(--warn-dim);
  padding: 0.45rem 1rem;
}
.sim-note.sim-note-bad { color: var(--error); background: var(--error-dim); }

.sim-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: auto;
  padding: 0.9rem 1rem;
  outline: none;
}

/* ── Player bar ── */
.sim-player {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.8rem;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.sim-btn {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text2);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.sim-btn:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.sim-btn:disabled { opacity: 0.3; cursor: default; }
.sim-btn:focus-visible, .sim-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sim-play {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  margin: 0 0.15rem;
}
.sim-play:hover:not(:disabled) { background: var(--accent-h); color: #fff; }

.sim-track {
  position: relative;
  flex: 1;
  min-width: 80px;
  height: 24px;
  margin: 0 0.6rem;
  cursor: pointer;
  touch-action: none;
}
.sim-track-rail, .sim-track-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
}
.sim-track-rail { right: 0; background: var(--bg3); }
.sim-track-fill { width: 0; background: var(--accent); transition: width 0.35s ease; }
.sim-track-dots { position: absolute; inset: 0; pointer-events: none; }
.sim-dot {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  border: 1.5px solid var(--bg2);
}
.sim-dot-call { background: #8250df; }
.sim-dot-out  { background: var(--success); }
.sim-track-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--bg2);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: left 0.35s ease, transform 0.15s;
}
.sim-track:hover .sim-track-thumb, .sim-track.dragging .sim-track-thumb { transform: scale(1.2); }
.sim-track.dragging .sim-track-fill, .sim-track.dragging .sim-track-thumb { transition: none; }
.sim-pos {
  flex: none;
  min-width: 4.5rem;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

/* ── Frames and variables ── */
.sim-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
}
.sim-frame-active { border-color: var(--accent); box-shadow: 0 2px 12px var(--accent-dim); }
.sim-frame-globals { background: transparent; border-style: dashed; }
.sim-frame-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text2);
  padding: 0.5rem 0.85rem 0;
}
.sim-frame-active .sim-frame-head { color: var(--accent); }
.sim-frame-line { color: var(--text3); font-weight: 400; }
.sim-ret {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.55rem 0.85rem 0;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: var(--success-dim);
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.75rem;
  color: var(--text2);
}
.sim-ret-arrow { color: var(--success); font-weight: 600; }
.sim-ret-call { color: var(--text); }
.sim-ret-word { color: var(--text3); }
.sim-deep { font-size: 0.75rem; color: var(--text3); text-align: center; }

.sim-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.4rem;
  padding: 0.7rem 0.85rem 0.85rem;
  align-items: flex-start;
}
.sim-var { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; max-width: 100%; }
.sim-name {
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}
/* the type is there when you want it, quiet when you don't */
.sim-type { margin-left: 0.4rem; font-size: 0.68rem; font-weight: 400; color: var(--text3); opacity: 0; transition: opacity 0.2s; }
.sim-var:hover .sim-type { opacity: 1; }
@media (hover: none) { .sim-type { opacity: 1; } }
.sim-val { min-width: 0; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 2px; }

.sim-box, .sim-cell, .sim-grid td {
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.sim-box {
  display: inline-block;
  min-width: 2.6rem;
  padding: 0.35rem 0.7rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-all;
}
.sim-box-sm { min-width: 1.8rem; padding: 0.15rem 0.5rem; font-size: 0.78rem; border-radius: 6px; }
.sim-b, .sim-p { color: var(--text2); }

.sim-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px; }
.sim-row-wide { gap: 0.5rem; }
.sim-cell-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sim-cell {
  min-width: 2.4rem;
  padding: 0.35rem 0.45rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  white-space: pre;
}
.sim-cell-wide { padding: 0.4rem; }
.sim-idx { font-size: 0.62rem; color: var(--text3); font-variant-numeric: tabular-nums; }
.sim-pointed { border-color: var(--accent); }
.sim-ptrs { display: flex; flex-direction: column; align-items: center; }
.sim-ptr {
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.15;
}
.sim-ptr::before { content: '▲ '; font-size: 0.5rem; vertical-align: 1px; }
.sim-more, .sim-empty { font-size: 0.72rem; color: var(--text3); align-self: center; padding: 0 0.3rem; }

.sim-grid-wrap { overflow: visible; }
.sim-grid { border-collapse: separate; border-spacing: 3px; }
.sim-grid th { font-size: 0.62rem; font-weight: 400; color: var(--text3); padding: 0 0.2rem; text-align: center; }
.sim-grid td {
  min-width: 2.1rem;
  padding: 0.25rem 0.35rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.sim-grid td.sim-grid-more { border: none; background: none; color: var(--text3); }

.sim-map { border-collapse: separate; border-spacing: 0 3px; font-family: var(--mono); font-variant-ligatures: none; font-size: 0.8rem; }
.sim-map td { border: 1px solid var(--border); padding: 0.25rem 0.65rem; background: var(--bg); }
.sim-map-key { color: var(--text2); background: var(--bg3) !important; border-radius: 8px 0 0 8px; border-right: none !important; }
.sim-map-val { border-radius: 0 8px 8px 0; }

.sim-fields { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; }
.sim-field { display: flex; align-items: center; gap: 0.3rem; }
.sim-field-name { font-family: var(--mono); font-variant-ligatures: none; font-size: 0.7rem; color: var(--text3); }

/* ── Simulate: motion ─────────────────────────────────────
   Slow, soft and eased: a changed value glows gently and its new value rolls
   in; frames, variables and index markers glide to their new places
   (compiler-sim.js, flipPlay); anything new fades in. Play runs one step a
   second, so --sim-dur takes most of it. */
.sim-view { --sim-dur: 650ms; --sim-ease: cubic-bezier(0.22, 1, 0.36, 1); }
.sim-view [data-flip] { transition: transform var(--sim-dur) var(--sim-ease); }
.sim-cell, .sim-box, .sim-grid td, .sim-frame {
  transition: background-color var(--sim-dur) ease, border-color var(--sim-dur) ease, box-shadow var(--sim-dur) ease;
}

/* a value that changed on this step */
.sim-hot {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
  animation: sim-glow calc(var(--sim-dur) * 2.2) ease-out;
}
.sim-var-new > .sim-name { color: var(--accent); }
.sim-roll { display: inline-block; animation: sim-roll var(--sim-dur) var(--sim-ease); }
.sim-enter { animation: sim-enter var(--sim-dur) var(--sim-ease); }
.sim-ptr { transition: transform var(--sim-dur) var(--sim-ease); }

@keyframes sim-glow {
  from { box-shadow: 0 0 0 4px var(--accent-dim), 0 0 14px var(--accent-dim); }
  to   { box-shadow: 0 0 0 0 transparent, 0 0 0 transparent; }
}
@keyframes sim-roll {
  from { opacity: 0; transform: translateY(55%); filter: blur(1px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes sim-enter {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sim-hot, .sim-roll, .sim-enter { animation: none; }
  .sim-view [data-flip], .sim-cell, .sim-box, .sim-grid td, .sim-frame { transition: none; }
}

/* the line about to run, in the editor */
.monaco-editor .sim-line { background: var(--accent-dim); animation: sim-line-in 0.35s ease-out; }
@keyframes sim-line-in { from { opacity: 0; } to { opacity: 1; } }
.monaco-editor .sim-line-mark { background: var(--accent); width: 3px !important; margin-left: 3px; }

/* ── Simulate: pictures (compiler-sim-views.js) ───────────── */
.sim-var-wide { flex-basis: 100%; }
.sim-as {
  margin-left: 0.5rem;
  font-family: inherit;
  font-size: 0.68rem;
  color: var(--text2);
  background: var(--bg3);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
  cursor: pointer;
}
.sim-as:focus-visible { outline: 2px solid var(--accent); }

/* segment tree */
.sim-tree svg { display: block; max-width: none; }
.sim-tree-edge { stroke: var(--border); stroke-width: 1.5; transition: stroke 0.4s; }
.sim-tree-edge.on { stroke: var(--accent); stroke-width: 2.5; }
.sim-tree-node rect { fill: var(--bg); stroke: var(--border); stroke-width: 1.2; }
.sim-tree-node text { text-anchor: middle; font-family: var(--mono); font-variant-ligatures: none; }
.sim-tree-node .v { font-size: 12px; fill: var(--text); font-variant-numeric: tabular-nums; }
.sim-tree-node .i { font-size: 8.5px; fill: var(--text3); }
.sim-tree-node .r { font-size: 9px; fill: var(--text3); }
.sim-tree-node.on rect { stroke: var(--accent); stroke-width: 2; }
.sim-tree-node.now rect { fill: var(--accent); stroke: var(--accent); }
.sim-tree-node.now .v { fill: #fff; font-weight: 600; }
.sim-tree-node.hot rect { animation: sim-node-glow calc(var(--sim-dur) * 2.2) ease-out; }
.sim-tree-node.hot:not(.now) rect { fill: color-mix(in srgb, var(--accent) 18%, var(--bg)); }
@keyframes sim-node-glow {
  from { filter: drop-shadow(0 0 6px var(--accent)); }
  to   { filter: none; }
}

/* DP table */
.sim-dp { position: relative; display: inline-block; max-width: 100%; overflow-x: auto; }
.sim-dp table { border-collapse: separate; border-spacing: 3px; }
.sim-dp th { font-size: 0.62rem; font-weight: 400; color: var(--text3); padding: 0 0.2rem; text-align: center; }
.sim-dp td {
  min-width: 2.2rem;
  padding: 0.3rem 0.35rem;
  text-align: center;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.sim-dp td.tgt { border: 2px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.sim-dp td.src { border: 1.5px dashed var(--accent); }
.sim-dp-arrows { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.sim-dp-arrows .arw {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  opacity: 0.8;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: sim-draw var(--sim-dur) var(--sim-ease) forwards;
}
.sim-dp-arrows marker path { fill: var(--accent); }
@keyframes sim-draw { to { stroke-dashoffset: 0; } }

/* graph */
.sim-graph svg { display: block; max-width: 100%; height: auto; }
.sim-graph-edge { stroke: var(--text3); stroke-width: 1.4; opacity: 0.7; }
.sim-graph-edge.on { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.sim-graph marker path { fill: var(--text3); }
.sim-graph .wt { font-family: var(--mono); font-variant-ligatures: none; font-size: 9.5px; fill: var(--text2); text-anchor: middle; paint-order: stroke; stroke: var(--bg2); stroke-width: 3px; }
.sim-graph-node circle { fill: var(--bg); stroke: var(--text3); stroke-width: 1.5; transition: fill 0.4s; }
.sim-graph-node text { text-anchor: middle; font-family: var(--mono); font-variant-ligatures: none; font-size: 11px; fill: var(--text); }
.sim-graph-node .lab { font-size: 9.5px; fill: var(--accent); font-weight: 600; }
.sim-graph-node.vis circle { fill: var(--success-dim); stroke: var(--success); }
.sim-graph-node.wait circle { stroke: var(--warn); stroke-dasharray: 3 2; stroke-width: 2; }
.sim-graph-node.next circle { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 4 2; }
.sim-graph-node.now circle { fill: var(--accent); stroke: var(--accent); }
.sim-graph-node.now text:not(.lab) { fill: #fff; font-weight: 600; }
.sim-graph-node.hot circle { animation: sim-node-glow calc(var(--sim-dur) * 2.2) ease-out; }
.sim-graph-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; margin-top: 0.3rem; font-size: 0.7rem; color: var(--text3); }
.sim-graph-legend .lg::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.3rem;
  border-radius: 50%;
  vertical-align: -1px;
  border: 1.5px solid var(--text3);
}
.sim-graph-legend .now::before  { background: var(--accent); border-color: var(--accent); }
.sim-graph-legend .next::before { border: 2px dashed var(--accent); }
.sim-graph-legend .vis::before  { background: var(--success-dim); border-color: var(--success); }
.sim-graph-legend .wait::before { border: 2px dashed var(--warn); }
.sim-graph-legend .lab::before  { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sim-tree-node.hot rect, .sim-graph-node.hot circle, .sim-dp-arrows path { animation: none; stroke-dashoffset: 0; }
}
.sim-frame-folded .sim-frame-head { padding-bottom: 0.5rem; }
.sim-frame [data-fold] { cursor: pointer; }
.sim-frame [data-fold] .sim-call::before { content: '▾ '; font-size: 0.65rem; color: var(--text3); }
.sim-frame-folded [data-fold] .sim-call::before { content: '▸ '; }

/* ── Simulate: full screen ── */
/* Like the editor's focus mode, but for the simulation: nothing else on screen. */
body.sim-full .navbar,
body.sim-full .compiler-head,
body.sim-full .editor-pane,
body.sim-full .split-handle,
body.sim-full .io-pane > :not(#simPanel),
body.sim-full #chat-widget,
body.sim-full footer { display: none !important; }
body.sim-full .page { padding: 0 !important; }
body.sim-full .container { max-width: none; padding: 0; }
body.sim-full .compiler-layout { grid-template-columns: 1fr; }
body.sim-full .io-pane { gap: 0; }
body.sim-full .sim-panel { height: 100vh !important; margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
#simFullBtn.active { color: var(--accent); }
/* with the whole screen, the graph may grow */
body.sim-full .sim-graph svg { width: min(100%, 560px); height: auto; max-height: 55vh; }

/* a pair: (1, 2) in one box */
.sim-pair {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono); font-variant-ligatures: none;
  font-size: 0.85rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.3rem 0.6rem;
  font-variant-numeric: tabular-nums;
}
.sim-pair::before { content: '('; color: var(--text3); }
.sim-pair::after  { content: ')'; color: var(--text3); }
.sim-pair-el + .sim-pair-el::before { content: ', '; color: var(--text3); }

/* the snippets window: your snippets, then the built-in templates */
.snippet-section {
  margin: 1rem 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
}
.snippet-section span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.template-list .s-meta { white-space: normal; text-align: right; }

/* Xalça: the page title and the icon buttons */
.compiler-title { font-size: clamp(1.6rem, 2.4vw, 2.1rem); letter-spacing: -0.04em; }
.icon-btn svg { width: 17px; height: 17px; display: block; }
