/* Silex visualizer — styled to match the Lithos playground (GitHub-dark palette). */
:root {
  --bg: #0b0f16; --bg2: #0d1220; --panel: #161b22; --panel2: #0e1420;
  --border: #2a3340; --fg: #e6edf3; --muted: #8b949e; --faint: #5b6675;
  --accent: #58a6ff; --ok: #3fb950;
  --if: #58a6ff; --id: #3fb950; --ex: #f0883e; --mem: #a371f7; --wb: #f85149;
  --stall: #56607a; --flag: #f0883e; --fwd: #3fb950;
  --radius: 10px; --shadow: 0 6px 24px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--fg);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(88,166,255,0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(163,113,247,0.08), transparent 55%),
    var(--bg);
  font: 14px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header { padding: 24px 28px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(88,166,255,0.06), transparent); }
h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; font-weight: 700; }
h1 .sub { color: var(--muted); font-weight: 400; font-size: 15px; }
.tagline { color: var(--muted); max-width: 1040px; margin: 9px 0 0; }
.tagline a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted rgba(88,166,255,0.5); }
.tagline a:hover { border-bottom-style: solid; }
.tagline b { color: var(--fg); font-weight: 600; }
code { color: var(--muted); background: var(--panel2); padding: 1px 5px; border-radius: 4px;
  font: 12px ui-monospace, Consolas, monospace; }

/* ---- Row 1: controls (examples | editor | compare) ---- */
.controls { display: flex; gap: 18px; padding: 18px 28px; align-items: stretch; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); max-width: 1720px; margin: 0 auto; }
.clabel { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.c-examples { flex: 0 0 158px; display: flex; flex-direction: column; }
.c-examples #examples { display: flex; flex-direction: column; gap: 7px; }
.c-examples .run { margin-top: 12px; }
.c-editor { flex: 1 1 460px; min-width: 320px; display: flex; flex-direction: column; }
.c-compare { flex: 0 0 300px; display: flex; flex-direction: column; }

#examples button { background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 12px; transition: all .15s ease; text-align: left; }
#examples button:hover { border-color: var(--accent); color: #fff; }
#examples button.active { background: rgba(88,166,255,0.15); border-color: var(--accent); color: #fff;
  box-shadow: 0 0 0 1px rgba(88,166,255,0.3) inset; }

#editor { width: 100%; height: 230px; background: var(--panel2); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px;
  font: 13px/1.55 "SF Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
  resize: vertical; box-shadow: inset 0 1px 3px rgba(0,0,0,0.4); tab-size: 2; }
#editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88,166,255,0.15); }
.hint-small { color: var(--faint); font-size: 11.5px; margin: 9px 0 0; line-height: 1.6; }

button.run { background: linear-gradient(180deg, #46c463, var(--ok)); color: #05210f; border: none;
  border-radius: 8px; padding: 9px 18px; font-weight: 700; cursor: pointer; font-size: 14px;
  box-shadow: 0 2px 10px rgba(63,185,80,0.35); transition: filter .15s ease, transform .05s ease; }
button.run:hover { filter: brightness(1.08); }
button.run:active { transform: translateY(1px); }
.error { color: var(--wb); margin-top: 10px; font: 12px ui-monospace, monospace; min-height: 16px; }

.isa-checks { display: flex; flex-direction: column; gap: 7px; }
.isa-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; font-size: 12.5px;
  transition: all .15s ease; user-select: none; }
.isa-chip:hover { border-color: var(--accent); }
.isa-chip small { color: var(--muted); }
.isa-chip input { accent-color: var(--accent); cursor: pointer; }
.isa-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.playback { display: flex; gap: 7px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.playback button { background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 11px; cursor: pointer; transition: all .15s ease; font-size: 13px; }
.playback button:hover { border-color: var(--accent); color: #fff; }
.speedrow { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; width: 130px;
  background: var(--border); border-radius: 3px; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 0 3px rgba(88,166,255,0.2); }
.cycle { font: 14px ui-monospace, monospace; color: var(--accent); margin-top: 12px; font-variant-numeric: tabular-nums; }

/* ---- Collapsible sections ---- */
details.section { border-bottom: 1px solid var(--border); padding: 6px 28px 20px; max-width: 1720px; margin: 0 auto; }
details.section > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--fg);
  list-style: none; padding: 14px 2px; display: flex; align-items: center; gap: 9px; user-select: none;
  border-radius: 8px; transition: color .15s ease; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; font-size: 12px; }
details.section[open] > summary::before { transform: rotate(90deg); }
details.section > summary:hover { color: var(--accent); }
details.section > summary .scount { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 4px; }

.verdict { color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.verdict b { color: var(--fg); }
.verdict code { color: var(--accent); }

/* Race bars */
.race { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px;
  background: linear-gradient(180deg, var(--panel), var(--panel2)); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.race-row { display: grid; grid-template-columns: 120px 1fr 84px; gap: 12px; align-items: center; }
.race-row .rname { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.race-row .rname .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.track { position: relative; height: 16px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 9px; overflow: hidden; }
.track .ghost { position: absolute; top: 0; left: 0; height: 100%; background: rgba(255,255,255,0.05); }
.track .fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 9px; transition: width .05s linear;
  box-shadow: 0 0 10px rgba(255,255,255,0.15); }
.track .finish { position: absolute; top: -4px; height: 24px; width: 2px; background: var(--ok);
  box-shadow: 0 0 6px rgba(63,185,80,0.6); }
.race-row .rcyc { font: 12px ui-monospace, monospace; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.race-row .rcyc.done { color: var(--ok); font-weight: 700; }

/* ---- Live 5-stage pipeline columns (side by side) ---- */
#panels { display: flex; flex-direction: row; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.isa-panel { flex: 1 1 200px; min-width: 190px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--panel2)); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 15px; box-shadow: var(--shadow); }
.isa-panel.winner { border-color: rgba(63,185,80,0.45); box-shadow: 0 0 0 1px rgba(63,185,80,0.18), var(--shadow); }
.isa-panel .name { font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 7px; }
.isa-panel .name .dot { width: 10px; height: 10px; border-radius: 50%; }
.isa-panel .name .tag { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .05em;
  color: var(--ok); background: rgba(63,185,80,0.12); border: 1px solid rgba(63,185,80,0.3);
  padding: 1px 7px; border-radius: 10px; }
.isa-panel .bigcyc { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 8px; }
.isa-panel .bigcyc.win { color: var(--ok); } .isa-panel .bigcyc.lose { color: var(--wb); }
.isa-panel .bigcyc small { color: var(--muted); font-size: 12px; font-weight: 400; }
.isa-panel .substats { color: var(--muted); font-size: 11.5px; margin: 4px 0 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.isa-panel .substats b { color: var(--fg); }
.pipeline { display: flex; flex-direction: column; gap: 7px; }
.stage { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: center; }
.stage .slabel { color: var(--faint); font-size: 10.5px; letter-spacing: .08em; text-align: right; font-weight: 600; }
.sbox { min-height: 44px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.25); display: flex;
  align-items: center; justify-content: center; text-align: center;
  font: 11.5px/1.25 ui-monospace, Consolas, monospace; padding: 4px 6px; overflow: hidden;
  color: #08101c; font-weight: 600; box-shadow: inset 0 -2px 6px rgba(0,0,0,0.18);
  transition: background-color .1s linear, box-shadow .1s; word-break: break-word; }
.sbox.empty { color: var(--faint); background: var(--panel2) !important; border: 1px dashed var(--border);
  font-weight: 400; box-shadow: none; }
.sbox.flag { box-shadow: 0 0 0 2px var(--flag), 0 0 10px rgba(240,136,62,0.5); }

/* ---- Gantt row (RV | x86 | Silex-E side by side) ---- */
#tables { display: flex; flex-direction: row; gap: 14px; align-items: flex-start; }
#tables .isa-panel { flex: 1 1 0; min-width: 0; box-shadow: none; }
#tables .tname { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 7px; }
#tables .tname .dot { width: 9px; height: 9px; border-radius: 50%; }
.scroll { overflow: auto; max-height: 420px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); }
.scroll::-webkit-scrollbar { height: 10px; width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.scroll::-webkit-scrollbar-track { background: var(--panel2); }
canvas { display: block; background: var(--bg); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 12px; align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.legend .sw.ring { background: transparent; border: 2px solid var(--flag); }
.legend .sw.dot { border-radius: 50%; }
.legend .hint { flex-basis: 100%; color: var(--faint); line-height: 1.6; }
.legend .hint b { color: var(--muted); font-weight: 600; }

footer { padding: 18px 28px 30px; color: var(--muted); font-size: 12px; max-width: 1720px; margin: 0 auto;
  border-top: 1px solid var(--border); }
footer code { color: var(--fg); }
