/* insight widget styles: #tb-dose and #tb-anatomy (prefix .tbi-) */

/* ============================== #tb-dose ============================== */
#tb-dose .tbi-head-ctrl { display: flex; flex-wrap: wrap; gap: 8px 10px; }
#tb-dose .tbi-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(18px, 2.4vw, 30px); align-items: start; }
@media (max-width: 900px) { #tb-dose .tbi-grid { grid-template-columns: minmax(0, 1fr); } }
#tb-dose .tbi-main { min-width: 0; }

/* control row */
#tb-dose .tbi-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
#tb-dose .tbi-play { min-width: 92px; justify-content: center; }
#tb-dose .tbi-play[aria-pressed="true"] { border-color: var(--ours); color: var(--ours-ink); }
#tb-dose .tbi-s { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; flex: 1 1 260px; min-width: 0; }
#tb-dose .tbi-s__label { font-size: 0.86rem; color: var(--muted); font-weight: 600; }
#tb-dose .tbi-s__num { font-size: 1.6rem; font-weight: 600; color: var(--ink); min-width: 3.4ch; line-height: 1; }
#tb-dose .tbi-s__meta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
#tb-dose .tbi-s__sub { font-size: 0.84rem; color: var(--muted); }
#tb-dose .tbi-s__chip { transition: background .25s, color .25s; }
#tb-dose .tbi-zoom[aria-pressed="true"] { border-color: var(--ours); background: var(--ours-soft); color: var(--ours-ink); }

#tb-dose .tbi-legrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin-bottom: 4px; min-height: 22px; }
#tb-dose .tbi-ytitle { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
#tb-dose .tbi-legend { font-size: 0.78rem; gap: 4px 14px; }
#tb-dose .tbi-sw-sel { background: linear-gradient(to right, var(--ours) 50%, var(--bad) 50%) !important; }
#tb-dose .tbi-sw-other { background: var(--neutral) !important; }
#tb-dose .tbi-sw-band { background: var(--neutral) !important; opacity: .28; }

/* chart */
#tb-dose .tbi-chart { position: relative; width: 100%; height: 340px; }
#tb-dose .tbi-svg { display: block; overflow: visible; font-family: var(--sans); touch-action: pan-y; }
#tb-dose .tbi-mildbg { fill: var(--ours); opacity: .07; }
#tb-dose .tbi-gl { stroke: var(--rule); stroke-width: 1; }
#tb-dose .tbi-axis { stroke: var(--rule-2); stroke-width: 1; }
#tb-dose .tbi-tick { fill: var(--muted); font: 500 12px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
#tb-dose .tbi-zero { stroke: var(--ink-2); stroke-width: 1.2; opacity: .7; }
#tb-dose .tbi-tol { stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: 5 4; }
#tb-dose .tbi-tol-t { fill: var(--bad); font: 600 12px var(--sans); }
#tb-dose .tbi-rec { stroke: var(--ours-ink); stroke-width: 1.2; stroke-dasharray: 2 4; opacity: .85; }
#tb-dose .tbi-rec-t { fill: var(--ours-ink); font: 600 12px var(--sans); }
#tb-dose .tbi-band { stroke: none; }
#tb-dose .tbi-band--other { fill: var(--neutral); opacity: .16; }
#tb-dose .tbi-band--pos { fill: var(--ours); opacity: .2; }
#tb-dose .tbi-band--neg { fill: var(--bad); opacity: .16; }
#tb-dose .tbi-line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
#tb-dose .tbi-line--other { stroke: var(--neutral); stroke-width: 1.8; opacity: .9; }
#tb-dose .tbi-line--pos { stroke: var(--ours); stroke-width: 2.8; }
#tb-dose .tbi-line--neg { stroke: var(--bad); stroke-width: 2.8; }
#tb-dose .tbi-dot { fill: var(--surface); stroke: var(--ours); stroke-width: 1.6; }
#tb-dose .tbi-dot.is-neg { stroke: var(--bad); }
#tb-dose .tbi-br { fill: none; stroke-width: 1.6; }
#tb-dose .tbi-br--mild { stroke: var(--ours); }
#tb-dose .tbi-br--rem { stroke: var(--bad); }
#tb-dose .tbi-reg { font: 650 12.5px var(--sans); letter-spacing: .01em; }
#tb-dose .tbi-reg--mild { fill: var(--ours-ink); }
#tb-dose .tbi-reg--rem { fill: var(--bad); }
#tb-dose .tbi-reg--rem.is-off { fill: var(--muted); font-weight: 550; }
#tb-dose .tbi-cursor { stroke: var(--ink); stroke-width: 1.3; opacity: .55; }
#tb-dose .tbi-cdot { stroke: var(--surface); stroke-width: 2.2; }
#tb-dose .tbi-cdot--sel { fill: var(--ours); }
#tb-dose .tbi-cdot--sel.is-neg { fill: var(--bad); }
#tb-dose .tbi-cdot--other { fill: var(--neutral); }
#tb-dose .tbi-pill rect { fill: var(--surface); stroke: var(--rule-2); stroke-width: 1; }
#tb-dose .tbi-pill text { font: 650 12.5px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; fill: var(--muted); }
#tb-dose .tbi-pill--sel rect { fill: var(--ours); stroke: none; }
#tb-dose .tbi-pill--sel.is-neg rect { fill: var(--bad); }
#tb-dose .tbi-pill--sel.is-pos rect, #tb-dose .tbi-pill--sel rect { filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
#tb-dose .tbi-pill--sel text { fill: #fff; }
:root[data-theme="dark"] #tb-dose .tbi-pill--sel text { fill: #15181e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #tb-dose .tbi-pill--sel text { fill: #15181e; } }
#tb-dose .tbi-hit { fill: transparent; cursor: ew-resize; }

/* slider under the plot, aligned with the x axis by JS */
#tb-dose .tbi-range-wrap { margin-top: 2px; }
#tb-dose .tbi-range { display: block; }
#tb-dose .tbi-ends { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.78rem; color: var(--muted); margin-top: 2px; min-height: 1.4em; }
#tb-dose .tbi-ends > span:first-child, #tb-dose .tbi-ends > span:last-child { flex: 1 1 0; }
#tb-dose .tbi-ends > span:last-child { text-align: right; color: var(--bad); }
#tb-dose .tbi-ends__mid { font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* side column */
#tb-dose .tbi-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
#tb-dose .tbi-schem-card { border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface-2); padding: 8px 10px 10px; }
#tb-dose .tbi-schem { aspect-ratio: 300 / 176; width: 100%; max-width: 420px; margin: 0 auto; }
#tb-dose .tbi-ssvg { width: 100%; height: 100%; overflow: visible; }
#tb-dose .tbi-schem__cap { margin: 4px 0 0; font-size: 0.76rem; line-height: 1.4; color: var(--muted); }
#tb-dose .tbi-s-axis { stroke: var(--faint); stroke-width: 1.3; fill: none; }
#tb-dose .tbi-s-hn { stroke: var(--ours); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#tb-dose .tbi-s-lab { fill: var(--muted); font: 600 12px var(--sans); }
#tb-dose .tbi-s-lab--hn { fill: var(--ours-ink); }
#tb-dose .tbi-s-ghost { fill: none; stroke: var(--faint); stroke-width: 1.2; stroke-dasharray: 4 4; }
#tb-dose .tbi-s-cur { fill: var(--ours); fill-opacity: .07; stroke: var(--ours); stroke-opacity: .55; stroke-width: 1.3; }
#tb-dose .tbi-s-pt { stroke: var(--surface-2); stroke-width: .8; }
#tb-dose .tbi-s-pt--img { fill: var(--img); }
#tb-dose .tbi-s-pt--txt { fill: var(--txt); }
#tb-dose .tbi-s-factor { fill: var(--ink-2); font: 600 12.5px var(--mono); }

#tb-dose .tbi-readout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#tb-dose .tbi-ro { padding: 8px 10px; transition: border-color .2s, box-shadow .2s; }
#tb-dose .tbi-ro.is-sel { border-color: var(--ours); box-shadow: inset 0 0 0 1px var(--ours); }
#tb-dose .tbi-ro .readout__label { font-size: 0.7rem; }
#tb-dose .tbi-ro .readout__value { font-size: 1.22rem; }
#tb-dose .tbi-ro.is-na .readout__value { color: var(--faint); }
#tb-dose .tbi-ro__sub { font: 500 0.72rem/1.35 var(--sans); color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#tb-dose .tbi-best { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--muted); }
#tb-dose .tbi-best__lab { flex: 1 0 100%; font-weight: 600; }
#tb-dose .tbi-best__item { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface-2); transition: background .2s, border-color .2s, color .2s; }
#tb-dose .tbi-best__item b { color: var(--ink); font-weight: 650; }
#tb-dose .tbi-best__item.is-cur { background: var(--ours-soft); border-color: var(--ours); color: var(--ours-ink); }
#tb-dose .tbi-best__item.is-cur b { color: var(--ours-ink); }

@media (max-width: 900px) {
  #tb-dose .tbi-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  #tb-dose .tbi-best { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  #tb-dose .tbi-side { display: flex; }
  #tb-dose .tbi-s__num { font-size: 1.4rem; }
  #tb-dose .tbi-head-ctrl .seg button { padding: 7px 11px; }
}

/* ============================= #tb-anatomy ============================= */
#tb-anatomy .tbi-part + .tbi-part { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
#tb-anatomy .tbi-sub { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
#tb-anatomy .tbi-sub__t { margin: 0; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); }
#tb-anatomy .tbi-sub__t b { color: var(--ink); }
#tb-anatomy .legend { font-size: 0.78rem; }
#tb-anatomy .tbi-c-bad { background: var(--bad) !important; }
#tb-anatomy .tbi-c-ours { background: var(--ours) !important; }

#tb-anatomy .tbi-bars { display: flex; flex-direction: column; gap: 6px; }
#tb-anatomy .tbi-row { display: grid; grid-template-columns: 178px minmax(0, 1fr); align-items: center; gap: 12px; }
#tb-anatomy .tbi-row--first-shrink { margin-top: 8px; }
#tb-anatomy .tbi-row__lab { font-size: 0.82rem; line-height: 1.25; color: var(--ink-2); text-align: right; }
#tb-anatomy .tbi-track { position: relative; height: 24px; }
#tb-anatomy .tbi-zero-l { position: absolute; top: -4px; bottom: -4px; width: 1px; background: var(--ink-2); opacity: .55; }
#tb-anatomy .tbi-bar { position: absolute; top: 3px; height: 18px; border-radius: 4px; transform: scaleX(0); transition: transform .7s cubic-bezier(.2,.7,.2,1); }
#tb-anatomy .tbi-bar--remove { background: var(--bad); }
#tb-anatomy .tbi-bar--shrink { background: var(--ours); }
#tb-anatomy .tbi-val { position: absolute; top: 50%; transform: translateY(-50%); padding: 0 6px; font-size: 0.8rem; font-weight: 650; white-space: nowrap; opacity: 0; transition: opacity .4s ease; }
#tb-anatomy .tbi-val--remove { color: var(--bad); }
#tb-anatomy .tbi-val--shrink { color: var(--ours-ink); }
#tb-anatomy .is-in .tbi-bar { transform: scaleX(1); }
#tb-anatomy .is-in .tbi-val { opacity: 1; }
#tb-anatomy .tbi-row--axis { margin-top: 2px; }
#tb-anatomy .tbi-track--axis { height: 18px; border-top: 1px solid var(--rule-2); }
#tb-anatomy .tbi-axt { position: absolute; top: 3px; transform: translateX(-50%); font-size: 12px; color: var(--muted); }
#tb-anatomy .tbi-align { margin: 14px 0 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }
#tb-anatomy .tbi-align .num { color: var(--ink); font-weight: 600; }

#tb-anatomy .tbi-strip { position: relative; width: 100%; }
#tb-anatomy .tbi-ssv { display: block; overflow: visible; font-family: var(--sans); }
#tb-anatomy .tbi-grp { font: 650 13px var(--sans); }
#tb-anatomy .tbi-grp.is-keep { fill: var(--ink); }
#tb-anatomy .tbi-grp.is-red { fill: var(--ours-ink); }
#tb-anatomy .tbi-rlab { font: 600 12px var(--sans); fill: var(--ink-2); }
#tb-anatomy .tbi-rlab--img { fill: var(--img); }
#tb-anatomy .tbi-rlab--txt { fill: var(--txt); }
#tb-anatomy .tbi-strip-gl { stroke: var(--rule); stroke-width: 1; }
#tb-anatomy .tbi-strip-zero { stroke: var(--ink-2); stroke-width: 1.1; opacity: .55; }
#tb-anatomy .tbi-strip-axis { stroke: var(--rule-2); stroke-width: 1; }
#tb-anatomy .tbi-tick { fill: var(--muted); font: 500 12px var(--mono); letter-spacing: -0.02em; }
#tb-anatomy .tbi-sdot { stroke: var(--surface); stroke-width: 1; fill-opacity: .85; }
#tb-anatomy .tbi-sdot--gap { fill: var(--ink-2); }
#tb-anatomy .tbi-sdot--img { fill: var(--img); }
#tb-anatomy .tbi-sdot--txt { fill: var(--txt); }
#tb-anatomy .tbi-med { stroke-width: 2.4; stroke-linecap: round; }
#tb-anatomy .tbi-med--gap { stroke: var(--ink); }
#tb-anatomy .tbi-med--img { stroke: var(--img); }
#tb-anatomy .tbi-med--txt { stroke: var(--txt); }
#tb-anatomy .tbi-medt { font: 600 12px var(--mono); letter-spacing: -0.02em; fill: var(--ink-2); }
#tb-anatomy .tbi-medt--img { fill: var(--img); }
#tb-anatomy .tbi-medt--txt { fill: var(--txt); }
#tb-anatomy .tbi-strip__note { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }

#tb-anatomy .is-narrow .tbi-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
#tb-anatomy .is-narrow .tbi-row__lab { text-align: left; }
#tb-anatomy .is-narrow .tbi-row--axis .tbi-row__lab { display: none; }
#tb-anatomy .is-narrow .tbi-bars { gap: 8px; }
@media (prefers-reduced-motion: reduce) { #tb-anatomy .tbi-bar, #tb-anatomy .tbi-val { transition: none; } }
#tb-anatomy .tbi-medh { font: 600 12px var(--sans); fill: var(--muted); }
#tb-anatomy .tbi-static .tbi-bar, #tb-anatomy .tbi-static .tbi-val { transition: none; }
