/* Stack page (stack.html). Uses the colour tokens of style.css. */
.stack main { max-width: 1180px; }
.stack h2 { font-size: 1.15rem; margin: 34px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.stack h3 { font-size: .98rem; margin: 18px 0 6px; }
.stack p.lead, .stack .sub { color: var(--ink-2); font-size: .9rem; margin: 4px 0 10px; max-width: 80ch; }
.stack nav.toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; }
.stack nav.toc a { color: var(--ink-2); }
.stack code, .stack .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82em; }
.cfg { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; font-size: .8rem; }
.cfg span { border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; background: var(--surface); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table.t { border-collapse: collapse; width: 100%; font-size: .82rem; }
table.t th, table.t td { text-align: left; vertical-align: top; padding: 6px 9px; border-bottom: 1px solid var(--line); }
table.t th { font-weight: 600; color: var(--ink-2); white-space: nowrap; background: var(--bg); position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t td.src { color: var(--ink-2); font-size: .74rem; white-space: nowrap; }
table.t tr.off td { color: var(--ink-2); }
.tag { display: inline-block; font-size: .7rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin: 1px 2px 1px 0; white-space: nowrap; }
.tag.trained { border-color: var(--ink); }
.tag.hard { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tag.na { border-style: dashed; color: var(--ink-2); }
.mermaid-box { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px; overflow-x: auto; }
.mermaid-box .mermaid { min-width: 860px; }

/* live trace */
.tform { display: grid; gap: 8px; }
.tform .row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: .88rem; }
.tform input[type=search] { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 1rem; }
.tform select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 4px 6px; }
.tform button.primary { padding: 0 18px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); cursor: pointer; min-height: 40px; }
.tform .examples button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: .8rem; cursor: pointer; }
.tform .photo-prev { max-height: 64px; border-radius: 6px; border: 1px solid var(--line); }
.steps { counter-reset: step; display: grid; gap: 10px; margin-top: 14px; }
.step { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 12px; }
.step > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.step > header h4 { margin: 0; font-size: .92rem; }
.step > header h4::before { counter-increment: step; content: counter(step) ". "; color: var(--ink-2); }
.step .ms { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--ink-2); white-space: nowrap; }
.step .what { color: var(--ink-2); font-size: .8rem; margin: 2px 0 6px; }
.step .kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; font-size: .82rem; }
.step .kv dt { color: var(--ink-2); }
.step .kv dd { margin: 0; overflow-wrap: anywhere; }
.step details { margin-top: 6px; font-size: .8rem; }
.step details summary { cursor: pointer; color: var(--ink-2); }
.step pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .75rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-height: 320px; overflow: auto; }
.frame-h { font-size: .95rem; margin: 18px 0 2px; }
.bar-chart { display: grid; gap: 3px; font-size: .78rem; margin-top: 6px; }
.bar-chart .b { display: grid; grid-template-columns: 9.5em minmax(0, 1fr) 5.5em; gap: 8px; align-items: center; }
.bar-chart .b i { display: block; height: 10px; background: var(--ink-2); border-radius: 2px; min-width: 1px; }
.bar-chart .b span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
@media (min-width: 640px) { .thumbs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) { .thumbs { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.thumb { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); font-size: .72rem; }
.thumb img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--line); }
.thumb div { padding: 4px 6px; }
.thumb .tt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb .meta { color: var(--ink-2); }
.diff-new { font-weight: 600; }
.err { color: var(--err); }
.steps { grid-template-columns: minmax(0, 1fr); }
.step, #tout { min-width: 0; }
#tout > details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .72rem; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.step code { overflow-wrap: anywhere; }
.cfg span { overflow-wrap: anywhere; max-width: 100%; }

/* two-column split: left = how the index is built, right = a live query */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
@media (min-width: 1060px) { .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; align-items: start; } }
.split .col { min-width: 0; }
.split .col > h2:first-child { margin-top: 0; }
/* the first "looks like" vector box can be wide; let it scroll inside its column */
.split .mermaid-box .mermaid { min-width: 520px; }

/* measured vs derived labels, and the plain-language takeaway box */
.tag.meas { border-color: var(--ink); }
.tag.calc { border-style: dashed; color: var(--ink-2); }
.lesson { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--surface); padding: 11px 13px; margin-top: 14px; font-size: .86rem; line-height: 1.5; }
.step .ms .tag { margin-left: 4px; }

/* saved traces page (traces.html) */
.stack.tr main { max-width: 1500px; }
.tr-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 10px; }
@media (min-width: 900px) { .tr-split { grid-template-columns: 340px minmax(0, 1fr); align-items: start; } }
.tr-list { min-width: 0; }
.tr-list input[type=search] { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: .95rem; }
.tr-list .tr-count { color: var(--ink-2); font-size: .78rem; margin: 6px 0; }
.tr-rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); max-height: 72vh; overflow-y: auto; }
@media (min-width: 900px) { .tr-list { position: sticky; top: 8px; } }
.tr-rows li { padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .84rem; }
.tr-rows li:last-child { border-bottom: 0; }
.tr-rows li.sel { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.tr-rows .q { font-weight: 600; overflow-wrap: anywhere; }
.tr-rows .m { color: var(--ink-2); font-size: .74rem; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.tr-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; font-size: .86rem; }
.tr-nav button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 12px; cursor: pointer; min-height: 32px; }
.tr-nav button:disabled { opacity: .45; cursor: default; }
.tr-nav .pos { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tr-detail { min-width: 0; }
.tr-detail h2.tr-q { margin: 0 0 4px; border-top: 0; padding-top: 0; overflow-wrap: anywhere; }
.tr-empty { color: var(--ink-2); padding: 20px 0; }
