/* ═══════════════════════════════════════════════════════════════
   Command Line In Depth — Visualizers
   1px hairlines only, tabular numbers, no horizontal overflow at 390px.
   ═══════════════════════════════════════════════════════════════ */

.simulator-mount { margin: 1.75rem 0; }

.sh-sim {
  border: 1px solid var(--border);
  border-radius: var(--r-xl, 14px);
  background: var(--surface);
  padding: 1.1rem 1.25rem 1.25rem;
  min-width: 0;
}
.sh-sim:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; }

.sh-sim__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sh-sim__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--fg); letter-spacing: -0.005em; }
.sh-sim__badge {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.sh-sim__blurb { margin: 0.4rem 0 0.9rem; font-size: 13.5px; color: var(--fg-muted); line-height: 1.55; }

.sh-sim__controls { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 0.85rem; }
.sh-sim__preset { font-size: 12.5px; color: var(--fg-muted); display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.sh-sim__preset select {
  font: inherit; font-size: 12.5px; color: var(--fg);
  background: var(--bg-alt, var(--surface)); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; max-width: 100%; min-width: 0;
}
.sh-sim__buttons { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.sh-sim__buttons button:disabled { opacity: 0.45; cursor: default; }
.sh-sim__status { margin-left: auto; font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--fg-muted); }

.sh-sim__stage {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-alt, var(--bg)); padding: 14px;
  display: grid; gap: 12px; min-height: 120px; overflow-x: auto;
}
.sh-sim__note { margin: 0.75rem 0 0; font-size: 14px; line-height: 1.6; color: var(--fg-prose, var(--fg)); min-height: 3.2em; }
.sh-sim__note code, .sh-sim__blurb code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.92em; }

.sh-sim__live { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }
.sh-sim__live code {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px;
  flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; color: var(--fg);
}
.sh-sim__live[hidden] { display: none; }

/* States shared by every helper */
.sh-sim .is-on   { border-color: var(--fg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--fg); }
.sh-sim .is-done { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.sh-sim .is-err  { color: var(--error); border-color: var(--error-border); background: var(--error-bg); }
.sh-sim .is-warn { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }
.sh-sim .is-dim  { opacity: 0.45; }

.sh-caption { font-size: 11.5px; font-weight: 600; color: var(--fg-muted); margin-bottom: 6px; }
.sh-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }

/* Terminal */
.sh-term {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; line-height: 1.6;
  font-variant-numeric: tabular-nums;
  background: #0f0f10; color: #e4e4e7; border-radius: 8px; padding: 10px 12px; min-width: 0; overflow-x: auto;
}
.sh-term__title { color: #a1a1aa; font-size: 11px; margin-bottom: 4px; }
.sh-term__line { white-space: pre; border-radius: 3px; padding: 0 4px; margin: 0 -4px; }
.sh-term__line.is-cmd { color: #fafafa; }
.sh-term__ps { color: #a1a1aa; }
.sh-sim .sh-term__line.is-on   { background: rgba(250, 250, 250, 0.12); box-shadow: none; border: 0; color: #fff; }
.sh-sim .sh-term__line.is-done { background: rgba(74, 222, 128, 0.14); color: #bbf7d0; }
.sh-sim .sh-term__line.is-err  { background: rgba(248, 113, 113, 0.16); color: #fecaca; }
.sh-sim .sh-term__line.is-warn { background: rgba(251, 191, 36, 0.14); color: #fde68a; }

/* Table */
.sh-table-wrap { overflow-x: auto; min-width: 0; }
.sh-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; margin: 0; }
.sh-table caption { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); padding-bottom: 6px; }
.sh-table th { text-align: left; font-weight: 600; color: var(--fg-muted); border-bottom: 1px solid var(--border); padding: 5px 8px; }
.sh-table td { font-family: var(--font-mono, ui-monospace, monospace); border-bottom: 1px solid var(--border); padding: 5px 8px; white-space: nowrap; }
.sh-table tr:last-child td { border-bottom: 0; }
.sh-sim .sh-table tr.is-on td { background: var(--surface); font-weight: 600; box-shadow: none; }

/* Flow */
.sh-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sh-flow__node {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  padding: 6px 10px; display: grid; gap: 1px; min-width: 0; max-width: 100%;
}
.sh-flow__label { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; overflow-wrap: anywhere; }
.sh-flow__sub { font-size: 11px; color: var(--fg-muted); }
.sh-flow__node.is-done .sh-flow__sub, .sh-flow__node.is-err .sh-flow__sub { color: inherit; opacity: 0.8; }
.sh-flow__arrow { color: var(--fg-muted); font-size: 13px; }

/* Tree */
.sh-tree { list-style: none; margin: 0; padding: 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; }
.sh-tree__item { padding: 2px 6px 2px calc(6px + var(--d) * 18px); border: 1px solid transparent; border-radius: 4px; position: relative; }
.sh-tree__item::before { content: ''; position: absolute; left: calc(var(--d) * 18px - 8px); top: 50%; width: 8px; border-top: 1px solid var(--border); }
.sh-tree__item[style*="--d:0"]::before { display: none; }
.sh-tree__sub { color: var(--fg-muted); font-size: 11.5px; }

/* Cells */
.sh-cells { display: flex; flex-wrap: wrap; gap: 4px; }
.sh-cell {
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  min-width: 30px; padding: 4px 7px; display: grid; justify-items: center; gap: 1px;
}
.sh-cell__v { font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; white-space: pre; }
.sh-cell__tag { font-size: 10px; color: var(--fg-muted); white-space: nowrap; }
.sh-cell.is-done .sh-cell__tag, .sh-cell.is-err .sh-cell__tag, .sh-cell.is-warn .sh-cell__tag { color: inherit; }

/* Stack */
.sh-stack { display: grid; gap: 4px; min-width: 0; }
.sh-stack__layer {
  display: grid; grid-template-columns: minmax(3.5em, max-content) 1fr; gap: 10px; align-items: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 5px 10px;
}
.sh-stack__key { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.sh-stack__label { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; overflow-wrap: anywhere; }
.sh-stack__layer.is-done .sh-stack__key, .sh-stack__layer.is-err .sh-stack__key { color: inherit; }

/* Facts */
.sh-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; }
.sh-facts__item { display: grid; gap: 1px; }
.sh-facts dt { font-size: 11px; color: var(--fg-muted); }
.sh-facts dd { margin: 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; font-variant-numeric: tabular-nums; }

@media (max-width: 480px) {
  .sh-sim { padding: 0.9rem; }
  .sh-sim__status { margin-left: 0; }
  .sh-sim__stage { padding: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sh-sim__stage > * { animation: sh-fade 160ms ease-out; }
  @keyframes sh-fade { from { opacity: 0.4; } to { opacity: 1; } }
}
