/* forth-stepper: a debugger layout. Controls; three columns (source+console |
   execution | stacks); tabbed tables below. Everything is scoped to .fst,
   which carries its own light/dark tokens. */

.fst {
  --fst-bg: #eef0f2; --fst-panel: #ffffff; --fst-ink: #16202a; --fst-muted: #5d6b78; --fst-line: #d5dbe1;
  --fst-accent: #b45309; --fst-accent-bg: #fdf0dc;
  --fst-n: #3b5b7a; --fst-addr: #0f766e; --fst-xt: #7c3aed; --fst-flag: #a16207; --fst-err: #b91c1c;
  --fst-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fst-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fst {
    --fst-bg: #11161b; --fst-panel: #192028; --fst-ink: #e3e8ed; --fst-muted: #8b98a5; --fst-line: #2c3743;
    --fst-accent: #f59e0b; --fst-accent-bg: #3a2a10;
    --fst-n: #93b4d4; --fst-addr: #5eead4; --fst-xt: #c4b5fd; --fst-flag: #fcd34d; --fst-err: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] .fst {
  --fst-bg: #11161b; --fst-panel: #192028; --fst-ink: #e3e8ed; --fst-muted: #8b98a5; --fst-line: #2c3743;
  --fst-accent: #f59e0b; --fst-accent-bg: #3a2a10;
  --fst-n: #93b4d4; --fst-addr: #5eead4; --fst-xt: #c4b5fd; --fst-flag: #fcd34d; --fst-err: #f87171;
  color-scheme: dark;
}

.fst { background: var(--fst-bg); color: var(--fst-ink); font: 14px/1.45 var(--fst-sans); padding: 12px; border-radius: 10px; }
.fst * { box-sizing: border-box; }
.fst code, .fst pre, .fst textarea, .fst input, .fst .mono { font-family: var(--fst-mono); font-size: 13px; }
.fst h2 { font: 600 12px var(--fst-sans); text-transform: uppercase; letter-spacing: .06em; color: var(--fst-muted); margin: 0 0 6px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; border: 0; padding: 0; }
.fst h2 .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }
.fst h3 { font: 600 12px var(--fst-sans); margin: 0 0 4px; color: var(--fst-muted); text-transform: uppercase; letter-spacing: .05em; }

.fst-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.fst-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fst button, .fst select { font: 500 13px var(--fst-sans); color: var(--fst-ink); background: var(--fst-panel); border: 1px solid var(--fst-line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.fst button:hover { border-color: var(--fst-muted); }
.fst button.primary { background: var(--fst-ink); color: var(--fst-panel); border-color: var(--fst-ink); }
.fst button:focus-visible, .fst select:focus-visible, .fst input:focus-visible, .fst textarea:focus-visible { outline: 2px solid var(--fst-accent); outline-offset: 1px; }
.fst kbd { font: 11px var(--fst-mono); color: var(--fst-muted); border: 1px solid var(--fst-line); border-radius: 3px; padding: 0 3px; margin-left: 4px; background: none; box-shadow: none; }
.fst button.primary kbd { color: inherit; opacity: .7; }
.fst-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; font-size: 13px; color: var(--fst-muted); }
.fst .chip { font: 600 11px var(--fst-mono); padding: 2px 7px; border-radius: 99px; border: 1px solid currentColor; }
.fst .chip.interp { color: var(--fst-addr); }
.fst .chip.comp { color: var(--fst-accent); }
.fst .chip.err { color: var(--fst-err); }

.fst-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(0, .9fr); gap: 12px; }
@media (max-width: 1000px) { .fst-grid { grid-template-columns: 1fr 1fr; } .fst .col3 { grid-column: 1 / -1; } }
@media (max-width: 640px) { .fst-grid { grid-template-columns: 1fr; } }
.fst .col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fst .panel { background: var(--fst-panel); border: 1px solid var(--fst-line); border-radius: 8px; padding: 10px 12px; min-width: 0; }

#fst-prog { width: 100%; min-height: 190px; resize: vertical; border: 1px solid var(--fst-line); border-radius: 6px; padding: 8px; background: var(--fst-bg); color: var(--fst-ink); line-height: 1.5; }
.fst .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.fst .repl { display: flex; gap: 6px; margin-top: 6px; }
.fst .repl input { flex: 1; min-width: 0; border: 1px solid var(--fst-line); border-radius: 6px; padding: 6px 8px; background: var(--fst-bg); color: var(--fst-ink); }
.fst pre { margin: 0; white-space: pre-wrap; word-break: break-word; border: 0; color: var(--fst-ink); }
#fst-console { min-height: 90px; max-height: 220px; overflow: auto; background: var(--fst-bg); border-radius: 6px; padding: 8px; }
#fst-console .err { color: var(--fst-err); }
.fst .hint { color: var(--fst-muted); font-size: 12px; margin: 0; }

#fst-input { max-height: 230px; overflow: auto; background: var(--fst-bg); border-radius: 6px; padding: 8px; line-height: 1.55; }
#fst-input .done { color: var(--fst-muted); opacity: .7; }
#fst-input .tok { background: var(--fst-accent-bg); color: var(--fst-accent); outline: 1px solid var(--fst-accent); border-radius: 2px; font-weight: 600; }
.fst .lastlog { margin-top: 6px; font-size: 13px; }
.fst .lastlog b { font-family: var(--fst-mono); color: var(--fst-accent); }

.fst .chain { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font: 12px var(--fst-mono); color: var(--fst-muted); margin-bottom: 6px; }
.fst .chain span.w { color: var(--fst-ink); background: var(--fst-bg); border: 1px solid var(--fst-line); border-radius: 4px; padding: 0 5px; }
.fst .chain span.w.now { border-color: var(--fst-accent); color: var(--fst-accent); }
.fst .body { font: 13px var(--fst-mono); display: grid; grid-template-columns: 2.4em 1fr auto; column-gap: 8px; row-gap: 1px; max-height: 440px; overflow: auto; }
.fst .body > div { padding: 1px 4px; border-radius: 3px; }
.fst .body .ix { color: var(--fst-muted); text-align: right; }
.fst .body .tgt { color: var(--fst-muted); }
.fst .body .cur { background: var(--fst-accent-bg); color: var(--fst-accent); font-weight: 600; }
.fst .body .ix.jump { box-shadow: inset -2px 0 0 var(--fst-xt); }
.fst .wordhead { font: 13px var(--fst-mono); margin-bottom: 6px; }
.fst .wordhead b { color: var(--fst-accent); }
.fst .empty { color: var(--fst-muted); font-size: 13px; font-style: italic; }

.fst .stack { display: flex; flex-direction: column; gap: 3px; font: 13px var(--fst-mono); }
.fst .item { display: grid; grid-template-columns: 1.6em minmax(4.5em, auto) auto 1fr; gap: 6px; align-items: center; padding: 3px 6px; border: 1px solid var(--fst-line); border-radius: 5px; }
.fst .item .d { color: var(--fst-muted); font-size: 11px; text-align: right; }
.fst .item .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.fst .item .note { color: var(--fst-muted); font-size: 12px; overflow-wrap: anywhere; }
.fst .tag { font: 600 10px var(--fst-mono); padding: 1px 5px; border-radius: 3px; border: 1px solid currentColor; text-transform: lowercase; }
.fst .tag.n { color: var(--fst-n); } .fst .tag.addr { color: var(--fst-addr); } .fst .tag.xt { color: var(--fst-xt); } .fst .tag.flag { color: var(--fst-flag); }
.fst .tag.ret, .fst .tag.hdr { color: var(--fst-muted); } .fst .tag.code, .fst .tag.loop { color: var(--fst-xt); }
.fst .tag.val, .fst .tag.orig, .fst .tag.dest, .fst .tag.do { color: var(--fst-accent); } .fst .tag.float { color: var(--fst-addr); }
.fst .item.retf { border-style: dashed; }
.fst .item.new, .fst .item.wrote { border-color: var(--fst-accent); background: var(--fst-accent-bg); }
.fst .item.here { border-style: dashed; color: var(--fst-muted); }
.fst .item .a { color: var(--fst-muted); font-size: 12px; }
.fst .memrow { grid-template-columns: 5.6em minmax(4.5em, auto) auto 1fr; }
.fst .legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--fst-muted); align-items: center; }

.fst .tabs { display: flex; gap: 2px; margin-top: 12px; border-bottom: 1px solid var(--fst-line); flex-wrap: wrap; }
.fst .tab { font: 500 13px var(--fst-sans); padding: 6px 12px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: none; color: var(--fst-muted); cursor: pointer; }
.fst .tab[aria-selected="true"] { background: var(--fst-panel); color: var(--fst-ink); border-color: var(--fst-line); margin-bottom: -1px; }
.fst .tabpanel { background: var(--fst-panel); border: 1px solid var(--fst-line); border-top: none; border-radius: 0 0 8px 8px; padding: 10px 12px; overflow-x: auto; }
.fst .tabpanel[hidden] { display: none; }
.fst table { border-collapse: collapse; width: 100%; font: 13px var(--fst-mono); margin: 0; }
.fst th { text-align: left; font: 600 11px var(--fst-sans); text-transform: uppercase; letter-spacing: .05em; color: var(--fst-muted); padding: 4px 8px; border-bottom: 1px solid var(--fst-line); background: none; }
.fst td { padding: 3px 8px; border-bottom: 1px solid var(--fst-line); vertical-align: top; font-variant-numeric: tabular-nums; color: var(--fst-ink); background: none; }
.fst tr.click { cursor: pointer; }
.fst tr.click:hover td { background: var(--fst-bg); }
.fst tr.sel td { background: var(--fst-accent-bg); }
.fst tr.shadow td { color: var(--fst-muted); text-decoration: line-through; }
.fst td.num, .fst th.num { text-align: right; }
.fst .bp { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--fst-muted); display: inline-block; vertical-align: middle; cursor: pointer; background: none; padding: 0; }
.fst .bp.on { background: var(--fst-err); border-color: var(--fst-err); }
.fst .prims { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 18px; }
.fst .prims button { display: grid; grid-template-columns: 6.5em 1fr; gap: 6px; width: 100%; text-align: left; border: none; background: none; padding: 2px 4px; font: 13px var(--fst-mono); border-radius: 4px; }
.fst .prims button:hover { background: var(--fst-bg); }
.fst .prims .eff { color: var(--fst-muted); }
.fst .imm { color: var(--fst-accent); font-size: 11px; }
.fst .toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--fst-muted); flex-wrap: wrap; }
.fst .note-text { font-size: 12.5px; color: var(--fst-muted); max-width: 72ch; margin: 8px 0 0; }

.fst .ex-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.fst .ex-overlay[hidden] { display: none; }
/* scrolling inside the dialog, or any panel that scrolls, must not chain to the page */
.fst .ex-overlay, .fst .ex-card, #fst-console, #fst-input, .fst .body, .fst .tabpanel { overscroll-behavior: contain; }
.fst .ex-card { background: var(--fst-panel); color: var(--fst-ink); border: 1px solid var(--fst-line); border-radius: 10px; padding: 14px 16px; width: min(520px, 100%); max-height: 80vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.fst .ex-card > .sub { color: var(--fst-muted); font-size: 13px; margin-bottom: 8px; }
.fst .ex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.fst .ex-head button { border: none; background: none; font-size: 20px; line-height: 1; color: var(--fst-muted); padding: 0 4px; }
.fst .ex-list { display: flex; flex-direction: column; gap: 6px; }
.fst .ex-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--fst-line); border-radius: 6px; background: var(--fst-bg); color: var(--fst-ink); }
.fst .ex-item:hover { border-color: var(--fst-accent); }
.fst .ex-title { display: block; font: 600 13px var(--fst-sans); }
.fst .ex-note { display: block; font: 12px var(--fst-mono); color: var(--fst-muted); margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .fst * { transition: none !important; } }
