/* results widget styles: #tb-results, #tb-families, #tb-hubness */

/* ===================================== #tb-results ===================================== */
#tb-results { --lw: 240px; --pr: 54px; }
#tb-results.is-narrow { --lw: 0px; --pr: 46px; }
#tb-results .figure__head { align-items: center; }
#tb-results .seg button:disabled { opacity: .36; cursor: not-allowed; }
#tb-results .seg button:disabled:hover { color: var(--muted); }

/* summary readouts */
.tbres-sum { display: grid; grid-template-columns: 1fr 1fr 1fr 1.45fr 1.35fr; gap: 10px; margin-bottom: 18px; }
.tbres-sum__item { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; text-align: left; padding: 11px 13px 12px; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink); font: inherit; min-width: 0; }
button.tbres-sum__item { cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s, transform .2s; }
button.tbres-sum__item:hover { border-color: var(--rule-2); transform: translateY(-1px); }
button.tbres-sum__item[aria-pressed="true"] { border-color: var(--ours); background: var(--surface); box-shadow: inset 0 0 0 1px var(--ours); }
.tbres-sum__value { font-size: 1.42rem; font-weight: 600; line-height: 1.1; display: inline-flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.tbres-sum__ours { color: var(--ours-ink); }
.tbres-sum__agent { color: var(--agent); }
.tbres-sum__sep { font: 500 0.82rem/1 var(--sans); color: var(--muted); letter-spacing: 0; }
.tbres-sum__label { font-size: 0.78rem; line-height: 1.35; color: var(--muted); }

/* controls */
.tbres-controls { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: flex-end; margin-bottom: 16px; }
.tbres-ctl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tbres-ctl__label { font: 600 0.75rem/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-left: 4px; }
#tb-results .seg button { white-space: nowrap; }

/* caption line */
.tbres-cap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 18px; padding: 10px 0 2px; border-top: 1px solid var(--rule); }
.tbres-cap__text { margin: 0; font-size: 0.86rem; color: var(--ink-2); font-weight: 550; }
.tbres-legend { font-size: 0.78rem; gap: 4px 14px; }
.tbres-sw { width: 14px !important; height: 9px !important; border-radius: 2px !important; }
.tbres-sw--ours { background: var(--ours) !important; }
.tbres-sw--agent { background: var(--agent) !important; }
.tbres-glyph { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
.tbres-legend .tbres-glyph { width: 8px; height: 8px; border-radius: 50%; }
.tbres-glyph--session { background: var(--agent) !important; }
.tbres-glyph--unseen { background: transparent !important; border: 1.5px solid var(--neutral); }
.tbres-glyph--fresh { background: var(--neutral) !important; border-radius: 1px !important; transform: rotate(45deg) scale(.9); }

/* chart */
.tbres-stage { position: relative; }
.tbres-chart { position: relative; transition: height .5s cubic-bezier(.3,.7,.2,1); }
.tbres-plot { z-index: 0; position: absolute; left: var(--lw); right: var(--pr); top: 22px; bottom: 8px; pointer-events: none; }
.tbres-gridlayer { position: absolute; inset: 0; }
.tbres-grid { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--rule); transition: left .5s cubic-bezier(.3,.7,.2,1); }
.tbres-zero { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid var(--faint); transition: left .5s cubic-bezier(.3,.7,.2,1); z-index: 1; }
.tbres-tol { position: absolute; top: -14px; bottom: 0; width: 0; border-left: 2px dashed var(--bad); z-index: 2; }
.tbres-tol__label { position: absolute; top: -8px; left: 6px; font: 600 0.75rem/1 var(--sans); color: var(--bad); white-space: nowrap; }
.tbres-mean { position: absolute; top: -14px; bottom: 0; width: 0; border-left: 1.5px dashed var(--ink-2); z-index: 3; transition: left .55s cubic-bezier(.3,.7,.2,1), opacity .3s; }
.tbres-mean.is-out { opacity: 0; }
.tbres-mean__label { position: absolute; top: -10px; left: 0; transform: translateX(-50%); padding: 2px 7px; border-radius: 999px; background: var(--surface); border: 1px solid currentColor; color: var(--ink-2); font-size: 0.75rem; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.tbres-mean--agent { top: 0; bottom: -40px; border-left-color: var(--agent); transition: left .55s cubic-bezier(.3,.7,.2,1), opacity .3s, bottom .5s; }
.tbres-mean--agent .tbres-mean__label { top: auto; bottom: -14px; color: var(--agent); }
#tb-results.is-imagenet .tbres-mean__label { transform: translateX(-30%); }

.tbres-row { position: absolute; left: 0; right: 0; top: 0; transition: transform .6s cubic-bezier(.3,.7,.2,1), opacity .35s ease, visibility 0s; border-radius: 6px; outline-offset: -1px; }
.tbres-row.no-move { transition: none; }
.tbres-row.is-out { opacity: 0; visibility: hidden; pointer-events: none; transition: transform .6s cubic-bezier(.3,.7,.2,1), opacity .3s ease, visibility 0s .3s; }
.tbres-row::before { content: ""; position: absolute; inset: 0 calc(var(--pr) * -0.2) 0 -6px; border-radius: 6px; background: var(--surface-2); opacity: 0; transition: opacity .15s; }
.tbres-row:hover::before, .tbres-row:focus-visible::before { opacity: 1; }
.tbres-lab { position: absolute; left: 0; top: 0; bottom: 0; width: var(--lw); padding-right: 12px; display: flex; align-items: center; gap: 7px; font-size: 0.86rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.tbres-lab__arch { font-size: 0.78rem; color: var(--muted); flex: none; }
.tbres-lab__data { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tbres-lab__tag { font: 600 0.75rem/1 var(--sans); letter-spacing: .04em; color: var(--muted); border: 1px solid var(--rule-2); border-radius: 999px; padding: 2px 6px; flex: none; }
.tbres-track { position: absolute; left: var(--lw); right: var(--pr); top: 0; bottom: 0; }
.tbres-bar { position: absolute; top: calc(50% - 7px); height: 14px; border-radius: 0 3px 3px 0; transition: left .6s cubic-bezier(.3,.7,.2,1), width .6s cubic-bezier(.3,.7,.2,1), top .45s ease, height .45s ease, opacity .3s; }
.tbres-bar.is-neg { border-radius: 3px 0 0 3px; }
.tbres-bar--tb { background: var(--ours); }
.tbres-bar--agent { background: var(--agent); top: calc(50% + 2px); height: 0; }
.tbres-val { position: absolute; top: 50%; transform: translateY(-50%); padding: 0 3px; margin-left: -3px; border-radius: 4px; background: var(--surface); line-height: 1.3; font-size: 0.76rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: left .6s cubic-bezier(.3,.7,.2,1), top .45s ease, opacity .35s; }
.tbres-val--agent { color: var(--agent); transition: left .6s cubic-bezier(.3,.7,.2,1), top .45s ease, opacity .3s ease .3s; }
.tbres-val--tb { color: var(--ours-ink); }
#tb-results.is-paired .tbres-bar--tb { top: calc(50% - 13px); height: 11px; }
#tb-results.is-paired .tbres-bar--agent { top: calc(50% + 2px); height: 11px; }
#tb-results.is-paired .tbres-val--tb { top: calc(50% - 7.5px); }
#tb-results.is-paired .tbres-val--agent { top: calc(50% + 7.5px); }

.tbres-hdr { position: absolute; left: 0; right: 0; top: 0; height: 28px; display: flex; align-items: flex-end; padding-bottom: 5px; font: 650 0.8rem/1 var(--sans); letter-spacing: .02em; color: var(--muted); border-bottom: 1px solid var(--rule); transition: transform .6s cubic-bezier(.3,.7,.2,1), opacity .3s; pointer-events: none; margin-right: var(--pr); }
.tbres-hdr span { background: var(--surface); padding-right: 8px; }
.tbres-hdr.is-out { opacity: 0; }

.tbres-axis { position: absolute; left: var(--lw); right: var(--pr); top: 0; height: 22px; transition: top .5s cubic-bezier(.3,.7,.2,1); }
.tbres-tick { position: absolute; top: 4px; transform: translateX(-50%); font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

/* table view */
.tbres-tablewrap { margin-top: 6px; }
.tbres-table { font-size: 0.86rem; min-width: 720px; }
.tbres-tnote { font-size: 0.8rem; color: var(--muted); margin: 4px 0 8px; }
.tbres-table td { white-space: nowrap; padding: 9px 8px; }
.tbres-table thead th { white-space: normal; vertical-align: bottom; padding: 8px 8px; }
.tbres-table tr > :first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.tbres-table .is-cur-agent { background: var(--agent-soft); color: var(--agent); }
.tbres-table th.num, .tbres-table td.num { text-align: right; }
.tbres-table td.num { white-space: nowrap; }
.tbres-table tbody th { font-weight: 550; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 0.86rem; white-space: nowrap; border-bottom: 1px solid var(--rule); padding: 9px 10px; }
.tbres-table .is-cur { background: var(--ours-soft); color: var(--ours-ink); }
.tbres-table thead .is-cur { color: var(--ours-ink); }
.tbres-table tfoot th, .tbres-table tfoot td { font-weight: 650; border-top: 1px solid var(--rule-2); border-bottom: 0; padding: 9px 10px; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 0.86rem; }
.tbres-table tfoot th { text-align: left; }

/* tooltip content (the shared tooltip lives outside the mount; classes are prefixed) */
.tbres-tip { border-collapse: collapse; margin: 6px 0 2px; font-size: 0.8rem; }
.tbres-tip th { font-weight: 600; opacity: .7; text-align: right; padding: 0 0 2px 12px; }
.tbres-tip td { padding: 1px 0; }
.tb-tooltip .tbres-tip td.num { text-align: right; padding-left: 12px; font-family: var(--mono); font-size: 0.78rem; }
.tb-tooltip .tbres-tip__sub .num { font-size: 1em; }
.tbres-tip tr.is-cur td { font-weight: 700; }
.tbres-tip__sub { opacity: .72; font-size: 0.76rem; }

/* narrow */
#tb-results.is-narrow .tbres-sum { grid-template-columns: 1fr 1fr; }
#tb-results.is-narrow .tbres-sum__item--wide { grid-column: 1 / -1; order: 5; }
#tb-results.is-narrow .tbres-sum__item--r1 { order: 4; }
#tb-results.is-narrow .tbres-sum__value { font-size: 1.2rem; }
#tb-results.is-narrow .seg { border-radius: 16px; }
#tb-results.is-narrow .seg button { padding: 7px 11px; }
#tb-results.is-narrow .tbres-controls { gap: 12px; }
#tb-results.is-narrow .tbres-lab { font-size: 0.8rem; gap: 5px; padding: 0 8px 0 0; height: 18px; bottom: auto; top: 4px; width: max-content; max-width: 100%; background: var(--surface); border-radius: 0 6px 6px 0; z-index: 1; }
#tb-results.is-narrow .tbres-track { top: 21px; }
#tb-results.is-narrow .tbres-row:hover .tbres-lab, #tb-results.is-narrow .tbres-row:focus-visible .tbres-lab { background: var(--surface-2); }
#tb-results.is-narrow .tbres-lab__arch { font-size: 0.75rem; }
#tb-results.is-narrow .tbres-legend { gap: 4px 10px; }
#tb-results.is-narrow .tbres-tol__label { display: none; }
.tbres-sw--tol { background: transparent !important; width: 0 !important; height: 12px !important; border-left: 2px dashed var(--bad); border-radius: 0 !important; margin: 0 4px; }
@media (max-width: 980px) { #tb-results:not(.is-narrow) .tbres-sum { grid-template-columns: repeat(3, 1fr); } }

/* ===================================== #tb-families ===================================== */
.tbfam, .tbhub { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(14px, 2vw, 20px); container-type: inline-size; }
.tbfam-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 76px 116px; gap: 0 14px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.tbfam-row--head { align-items: end; padding: 0 0 8px; font: 600 0.78rem/1.25 var(--sans); color: var(--muted); border-bottom: 1px solid var(--rule-2); }
.tbfam-row--head > span { font: inherit; color: inherit; }
.tbfam-row--head .tbfam-val, .tbfam-row--head .tbfam-test, .tbfam-row--head .tbfam-in { text-transform: none; letter-spacing: 0; font-size: 0.78rem; }
.tbfam-row--head .tbfam-test { text-align: right; }
.tbfam-row--axis { border-bottom: 0; padding: 2px 0 4px; }
.tbfam-name { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.tbfam-model { font-weight: 600; font-size: 0.88rem; line-height: 1.25; }
.tbfam-chip { font-size: 0.75rem; padding: 2px 8px; }
.tbfam-track { position: relative; height: 22px; margin-right: 46px; }
.tbfam-grid { position: absolute; top: -9px; bottom: -9px; border-left: 1px dashed var(--rule); }
.tbfam-track::before { content: ""; position: absolute; left: 0; top: -9px; bottom: -9px; border-left: 1.5px solid var(--faint); }
.tbfam-row--axis .tbfam-track::before, .tbfam-row--axis .tbfam-grid { display: none; }
.tbfam-bar { position: absolute; left: 0; top: 4px; height: 14px; width: 0; border-radius: 0 3px 3px 0; background: var(--ours); transition: width .7s cubic-bezier(.3,.7,.2,1); }
.tbfam-ci { position: absolute; top: 10px; height: 2px; background: var(--ink-2); opacity: 1; transition: opacity .4s ease; }
.tbfam-ci::before, .tbfam-ci::after { content: ""; position: absolute; top: -5px; height: 12px; border-left: 2px solid var(--ink-2); }
.tbfam-ci::before { left: -1px; } .tbfam-ci::after { right: -1px; }
.tbfam-num { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.78rem; font-weight: 600; color: var(--ours-ink); white-space: nowrap; transition: opacity .4s ease .4s; }
.tbfam-test { text-align: right; font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.tbfam-in { display: flex; align-items: center; gap: 8px; }
.tbfam-in .tbfam-num { position: static; transform: none; color: var(--ink-2); transition: none; }
.tbfam-in .tbfam-num.c-bad { color: var(--bad); }
.tbfam-intrack { position: relative; flex: 1; height: 14px; min-width: 44px; border-right: 1.5px solid var(--faint); }
.tbfam-intrack::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--rule); }
.tbfam-intol { position: absolute; top: -3px; bottom: -3px; border-left: 1.5px dashed var(--bad); }
.tbfam-inbar { position: absolute; right: 0; top: 3px; height: 8px; width: 0; border-radius: 3px 0 0 3px; background: var(--neutral); transition: width .7s cubic-bezier(.3,.7,.2,1); }
.tbfam-inbar.is-bad { background: var(--bad); }
.tbfam-row--head .tbfam-in { display: block; }
.tbfam-row.is-muted .tbfam-model, .tbfam-row.is-muted .tbfam-test { color: var(--muted); }
.tbfam-row.is-muted .tbfam-bar { background: var(--neutral); opacity: .7; }
.tbfam-row.is-muted .tbfam-val .tbfam-num { color: var(--muted); }
.tbfam-note { margin: 4px 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
.tbfam-axis { height: 16px; }
.tbfam-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 0.75rem; color: var(--muted); }
.tbfam-legend { margin-top: 8px; font-size: 0.78rem; }
.tbfam-sw { background: var(--ours) !important; width: 14px !important; height: 9px !important; }
.tbfam-sw--ci { background: transparent !important; height: 10px !important; width: 16px !important; border-left: 2px solid var(--ink-2); border-right: 2px solid var(--ink-2); position: relative; border-radius: 0 !important; }
.tbfam-sw--ci::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; border-top: 2px solid var(--ink-2); }
.tbfam-sw--tol { background: transparent !important; width: 0 !important; height: 12px !important; border-left: 1.5px dashed var(--bad); border-radius: 0 !important; margin: 0 3px; }
.tbfam-foot, .tbhub-foot { margin: 8px 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
@container (max-width: 430px) {
  .tbfam-row { grid-template-columns: minmax(0, 1fr) 64px 100px; gap: 4px 10px; }
  .tbfam-row .tbfam-name { grid-column: 1 / -1; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
  .tbfam-row--head .tbfam-name, .tbfam-row--axis .tbfam-name { display: none; }
  .tbfam-track { margin-right: 40px; }
}

/* ===================================== #tb-hubness ===================================== */
.tbhub-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.tbhub-chip { font-size: 0.8rem; padding: 5px 11px; }
.tbhub-chip .num { font-weight: 700; letter-spacing: 0; }
.tbhub-panel { padding: 12px 0 2px; border-bottom: 1px solid var(--rule); }
.tbhub-ptitle { margin: 0 0 4px; font-weight: 600; font-size: 0.9rem; }
.tbhub-ptitle small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.tbhub-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; align-items: end; }
.tbhub-label { font-size: 0.84rem; color: var(--ink-2); padding-bottom: 6px; line-height: 1.2; }
.tbhub-track { position: relative; height: 46px; margin-right: 22px; }
.tbhub-base { position: absolute; left: 0; right: 0; bottom: 12px; border-top: 1px solid var(--rule-2); }
.tbhub-gridl { position: absolute; bottom: 8px; height: 9px; border-left: 1px solid var(--rule-2); }
.tbhub-ghost, .tbhub-mark { position: absolute; bottom: 6px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; z-index: 2; }
.tbhub-ghost { background: var(--surface); border: 2px solid var(--neutral); }
.tbhub-mark { background: var(--ours); box-shadow: 0 0 0 3px var(--surface); z-index: 3; transition: opacity .2s; }
.tbhub-mark.is-zs { opacity: 0; }
.tbhub-link { position: absolute; bottom: 11px; height: 3px; border-radius: 2px; background: var(--ours); opacity: .45; z-index: 1; }
.tbhub-v { position: absolute; top: 2px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.tbhub-v--before { color: var(--muted); transform: translateX(-6px); }
.tbhub-v--now { color: var(--ours-ink); transform: translateX(calc(-100% + 6px)); transition: opacity .2s; }
.tbhub-row--axis { align-items: start; }
.tbhub-axis { position: relative; height: 18px; margin-right: 22px; }
.tbhub-axis span { position: absolute; top: 0; transform: translateX(-50%); font-size: 0.75rem; color: var(--muted); }
.tbhub-legend { margin-top: 10px; font-size: 0.78rem; }
.tbhub-sw { width: 11px !important; height: 11px !important; border-radius: 50% !important; }
.tbhub-sw--zs { background: var(--surface) !important; border: 2px solid var(--neutral); }
.tbhub-sw--tb { background: var(--ours) !important; }
@container (max-width: 430px) {
  .tbhub-row { grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
  .tbhub-label { font-size: 0.78rem; white-space: nowrap; }
}
