/* representing-sets: SICP 2.3.3 trace explorer. Reuses the site's :root
   tokens (--bg, --bg-content, --text, --text-secondary, --accent,
   --accent-light, --border, --code-bg) from style.css. The site has no
   dark mode; semantic status colors below are hardcoded hex (matching
   counting-change.css's palette) rather than CSS variables. */

#tool-root { font-size: 15px; }
#tool-root button, #tool-root input, #tool-root select { font: inherit; }

.rs-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin: 1rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.rs-lbl { display: block; font-weight: 600; margin-bottom: 6px; }
.rs-field { display: grid; grid-template-columns: 1.6em 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.rs-field b { font: 600 14px monospace; color: var(--text-secondary); }
.rs-field input, .rs-xin { width: 100%; font: 14px monospace; padding: 6px 9px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-content); }
.rs-xin { width: 8ch; }
.rs-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.rs-preset, .rs-smallbtn { border: 1px solid var(--border); background: transparent; border-radius: 14px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.rs-preset:hover, .rs-smallbtn:hover { border-color: var(--accent); }
.rs-hint { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }
.rs-err { color: #c2413b; font-size: 13px; }

.rs-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; background: var(--bg-content); flex-wrap: wrap; }
.rs-seg label { position: relative; }
.rs-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.rs-seg span { display: block; padding: 5px 12px; font-size: 13.5px; border-right: 1px solid var(--border); cursor: pointer; }
.rs-seg label:last-child span { border-right: 0; }
.rs-seg input:checked + span { background: var(--accent); color: #fff; }
.rs-opts { display: grid; gap: 12px; }
.rs-opt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.rs-opt > span:first-child { min-width: 7.5em; color: var(--text-secondary); }
.rs-chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.rs-chk input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.rs-result { padding: 18px 0 6px; }
.rs-answer { font-size: 20px; line-height: 1.4; max-width: 72ch; }
.rs-answer code { font: 600 18px monospace; }
.rs-compare { color: var(--text-secondary); margin-top: 6px; max-width: 95ch; }
table.rs-cost { border-collapse: collapse; margin-top: 12px; font-size: 13.5px; }
table.rs-cost th { font-weight: 600; color: var(--text-secondary); text-align: right; padding: 4px 12px; border-bottom: 1px solid var(--border); }
table.rs-cost th:first-child, table.rs-cost td:first-child { text-align: left; }
table.rs-cost td { padding: 4px 12px; text-align: right; font-family: monospace; font-size: 13px; border-bottom: 1px solid var(--border); }
table.rs-cost td:first-child { font-family: inherit; font-size: 13.5px; }
table.rs-cost tr.rs-sel td { background: var(--accent-light); }
table.rs-cost tr.rs-sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.rs-transport { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 10px; border-bottom: 1px solid var(--border); margin-top: 14px; }
.rs-tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rs-tbar button { min-width: 34px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--bg-content); border-radius: 4px; cursor: pointer; padding: 0 8px; }
.rs-tbar button:hover { border-color: var(--accent); }
.rs-tbar .rs-play { min-width: 60px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#rs-step-range { flex: 1; min-width: 160px; accent-color: var(--accent); }
.rs-steplabel { font: 13px monospace; color: var(--text-secondary); min-width: 13ch; text-align: right; }
.rs-speed { font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.rs-strip { display: block; width: 100%; height: 52px; margin-top: 10px; cursor: crosshair; touch-action: none; border-radius: 3px; }
.rs-caption { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.rs-work { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; margin-top: 16px; }
.rs-panel { background: var(--bg-content); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; min-width: 0; }
.rs-panel h2 { font-size: 14px; margin: 0 0 10px; }
.rs-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.rs-struct { padding: 10px 0; border-top: 1px solid var(--border); }
.rs-struct:first-child { border-top: 0; padding-top: 0; }
.rs-struct h3 { font-size: 13.5px; font-weight: 500; margin: 0 0 6px; color: var(--text-secondary); }
.rs-cells { display: flex; flex-wrap: wrap; gap: 4px 0; align-items: center; font: 13px monospace; }
.rs-cell { min-width: 34px; text-align: center; padding: 4px 6px; border: 1.5px solid var(--border); border-radius: 3px; background: var(--bg-content); }
.rs-arrow { color: var(--text-secondary); padding: 0 3px; font-size: 12px; }
.rs-cell.seen { background: var(--accent-light); border-color: var(--accent-light); }
.rs-cell.cur { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 1.5px var(--accent); }
.rs-cell.new { border-color: #c27d0e; box-shadow: 0 0 0 1.5px #c27d0e; }
.rs-cell.found { border-color: #178577; box-shadow: 0 0 0 1.5px #178577; }
.rs-empty { color: var(--text-secondary); font-size: 13px; }
.rs-treebox { overflow: auto; max-height: 360px; }
.rs-treebox svg { display: block; }
.rs-tr .e { stroke: var(--border); }
.rs-tr .n circle { fill: var(--bg-content); stroke: var(--text-secondary); stroke-width: 1.5; }
.rs-tr .n text { font: 600 11px monospace; text-anchor: middle; fill: var(--text); }
.rs-tr .n.seen circle { fill: var(--accent-light); stroke: var(--accent); }
.rs-tr .n.cur circle { fill: var(--accent-light); stroke: var(--accent); stroke-width: 3.5; }
.rs-tr .n.new circle { stroke: #c27d0e; stroke-width: 3.5; }
.rs-tr .n.found circle { stroke: #178577; stroke-width: 3.5; }

.rs-code { font: 12.5px/1.65 monospace; margin: 0; background: var(--code-bg); padding: 8px; border-radius: 4px; overflow-x: auto; }
.rs-code .rs-ln { display: block; padding: 0 8px 0 2.2em; text-indent: -1.6em; border-left: 3px solid transparent; white-space: pre-wrap; }
.rs-code .rs-ln.rs-hl { background: var(--accent-light); border-left-color: var(--accent); }
.rs-event { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); min-height: 4.5em; font-size: 13.5px; }
.rs-phase { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

.rs-growpanel { margin-top: 16px; }
#rs-grow { display: block; width: 100%; height: 260px; }
.rs-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.rs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rs-sw { width: 16px; height: 3px; display: inline-block; }

@media (max-width: 920px) {
    .rs-controls { grid-template-columns: 1fr; }
    .rs-work { grid-template-columns: 1fr; }
}
