/* ==========================================================================
   bedside.css: bedside scores and scales (Braden, Morse, CIWA-Ar, COWS,
   creatinine clearance, QTc, ABG). Loads after /tools/tokens.css and
   /tools/tool.css and only adds the .b-* components. TND v2 tokens only.
   Band colours: teal = low, amber = watch, rose = act now. Every band also
   carries an icon and a word, so colour is never the only signal.
   ========================================================================== */

.b-calc { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 40px; padding: 40px 0 88px; align-items: start; }
.b-calc-result { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 960px) {
  .b-calc { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .b-calc-result { position: static; }
}

/* ---------- privacy strip under the deck ---------- */
.b-private { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 8px 14px; border-radius: var(--radius-pill);
  background: var(--teal-tint); color: var(--teal-deep); font: 500 13px/1.3 var(--font-sans); }
.b-private svg { color: var(--teal-deep); }

/* ---------- progress ---------- */
.b-progress { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; font: 500 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.b-progress-bar { flex: 1; height: 4px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.b-progress-bar span { display: block; height: 100%; width: 100%; background: var(--teal); transform-origin: left; transform: scaleX(0); transition: transform 360ms cubic-bezier(.45,0,.1,1); }

/* ---------- one scale item ---------- */
.b-items { display: flex; flex-direction: column; gap: 14px; }
.b-item { margin: 0; padding: 22px 22px 20px; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--bg-card); min-width: 0;
  transition: border-color 150ms cubic-bezier(.2,.7,.4,1); }
.b-item[data-done] { border-color: var(--teal-wash); }
.b-item legend { display: contents; }
.b-item-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.b-item-n { flex: none; font: 500 12px var(--font-mono); color: var(--ink-mute); letter-spacing: .06em; }
.b-item-name { font: 400 26px/1.15 var(--font-serif); letter-spacing: -.01em; color: var(--ink); }
.b-item-score { margin-left: auto; flex: none; font: 600 13px var(--font-mono); color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.b-item[data-done] .b-item-score { color: var(--teal-deep); }
.b-item-hint { margin: 0 0 14px 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); }
.b-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.b-opts[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.b-opts--compact, .b-opts--compact[data-n="3"] { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
@media (max-width: 560px) { .b-opts, .b-opts[data-n="3"] { grid-template-columns: minmax(0, 1fr); } .b-opts--compact, .b-opts--compact[data-n="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.b-opt { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 13px; border: 1px solid var(--rule); border-radius: var(--radius-md);
  background: var(--bg-input); cursor: pointer; min-height: 44px;
  transition: border-color 150ms cubic-bezier(.2,.7,.4,1), background-color 150ms cubic-bezier(.2,.7,.4,1); }
.b-opt:hover { border-color: var(--t-control-edge-hover); }
.b-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.b-opt-top { display: flex; align-items: center; gap: 8px; }
.b-pts { flex: none; display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 7px; border-radius: 6px;
  background: var(--bg-soft); color: var(--ink); font: 600 13px var(--font-mono); font-variant-numeric: tabular-nums;
  transition: background-color 150ms, color 150ms; }
.b-opt-name { font: 600 14.5px/1.3 var(--font-sans); color: var(--ink); }
.b-opt-desc { font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); }
.b-opt:has(input:checked) { border-color: var(--teal-deep); background: var(--teal-tint); box-shadow: inset 0 0 0 1px var(--teal-deep); }
.b-opt:has(input:checked) .b-pts { background: var(--teal-deep); color: var(--bg-card); }
.b-opt:has(input:focus-visible) { outline: 2px solid var(--teal-deep); outline-offset: 2px; }
[data-theme="night"] .b-opt:has(input:checked) .b-pts { color: #1f2a2a; }

/* numeric inputs on the formula tools */
.b-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.b-fields > .b-full { grid-column: 1 / -1; }
@media (max-width: 560px) { .b-fields { grid-template-columns: minmax(0, 1fr); } }
.b-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.b-field-label { display: flex; justify-content: space-between; gap: 10px; font: 600 14.5px var(--font-sans); color: var(--ink); }
.b-field-label small { font: 400 12px var(--font-mono); color: var(--ink-mute); letter-spacing: .04em; }
.b-field-row { display: flex; gap: 8px; align-items: stretch; }
.b-field-row .t-input { flex: 1; min-width: 0; }
.b-field-row .t-seg { flex: none; }
.b-field-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.b-field[data-state="error"] .t-input { border-color: var(--rose); }
.b-field-err { margin: 0; font-size: 13px; color: var(--rose); font-weight: 600; }
[data-theme="night"] .b-field-err { color: #f3d9d4; }
.b-optional { margin: 6px 0 0; padding-top: 16px; border-top: 1px dashed var(--rule); }
.b-optional > summary { cursor: pointer; font: 600 14.5px var(--font-sans); color: var(--teal-deep); list-style: none; display: flex; align-items: center; gap: 8px; }
.b-optional > summary::-webkit-details-marker { display: none; }
.b-optional[open] > summary svg { transform: rotate(180deg); }
.b-optional > .b-fields { margin-top: 16px; }

/* ---------- result panel ---------- */
.b-result { background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.b-result-top { padding: 24px 26px 20px; }
.b-result-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.b-score { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 6px; font: 400 clamp(84px, 9vw, 112px)/.9 var(--font-serif); letter-spacing: -.035em; color: var(--ink); font-variant-numeric: tabular-nums; }
.b-score small { font: 400 22px var(--font-mono); letter-spacing: 0; color: var(--ink-mute); }
.b-score[data-empty] { color: var(--rule); }
.b-band { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--rule); background: var(--bg-input); font: 600 14px var(--font-sans); color: var(--ink); }
.b-band svg { width: 16px; height: 16px; }
.b-band[data-tone="low"] svg { color: var(--teal); }
.b-band[data-tone="watch"] svg { color: var(--amber); }
.b-band[data-tone="act"] svg { color: var(--rose); }
.b-band[data-tone="none"] svg { color: var(--ink-mute); }
.b-sub { margin: 12px 0 0; font: italic 400 19px/1.35 var(--font-serif); color: var(--ink-soft); text-wrap: pretty; }

/* band meter: segments sized by their share of the range, one travelling marker */
.b-meter { position: relative; margin: 22px 0 6px; padding-top: 16px; }
.b-meter-track { display: flex; gap: 3px; height: 10px; }
.b-meter-seg { height: 100%; border-radius: 3px; opacity: .38; transition: opacity 150ms; }
.b-meter-seg[data-on] { opacity: 1; }
.b-meter-seg[data-tone="low"] { background: var(--teal); }
.b-meter-seg[data-tone="watch"] { background: var(--amber); }
.b-meter-seg[data-tone="act"] { background: var(--rose); }
.b-meter-seg[data-tone="none"] { background: var(--ink-mute); }
.b-meter-pin { position: absolute; top: 0; left: 0; width: 100%; height: 30px; pointer-events: none; transform: translateX(0); transition: transform 400ms cubic-bezier(.22,.9,.3,1); }
.b-meter-pin::before { content: ""; position: absolute; left: -6px; top: 0; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 9px solid var(--ink); }
.b-meter-pin::after { content: ""; position: absolute; left: -1px; top: 10px; width: 2px; height: 18px; background: var(--ink); border-radius: 2px; }
.b-meter-pin[hidden] { display: none; }
.b-meter-ticks { display: flex; gap: 3px; margin-top: 8px; }
.b-meter-ticks span { font: 500 10.5px var(--font-mono); letter-spacing: .04em; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="night"] .b-meter-pin::before { border-top-color: #f5f1ea; }
[data-theme="night"] .b-meter-pin::after { background: #f5f1ea; }

.b-result-sec { padding: 18px 26px 20px; border-top: 1px dashed var(--rule); }
.b-result-sec h3 { margin: 0 0 10px; font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--teal-deep); }
.b-do { margin: 0; padding: 0; list-style: none; counter-reset: b; display: flex; flex-direction: column; gap: 8px; }
.b-do li { counter-increment: b; display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.b-do li::before { content: counter(b); font: 600 12px/1.9 var(--font-mono); color: var(--teal-deep); }
.b-empty { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); }

/* chart note */
.b-note { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-soft); font: 400 13.5px/1.6 var(--font-mono); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.b-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.b-actions .t-btn--ghost { height: 38px; }
.b-copied { font: 500 13px var(--font-sans); color: var(--teal-deep); align-self: center; opacity: 0; transition: opacity 150ms; }
.b-copied[data-on] { opacity: 1; }

/* step list for ABG and formula breakdowns */
.b-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.b-step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.b-step-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--teal-tint); color: var(--teal-deep); font: 600 12px var(--font-mono); }
.b-step-t { margin: 0; font: 600 14.5px/1.4 var(--font-sans); color: var(--ink); }
.b-step-d { margin: 2px 0 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }

/* small comparison table inside the result (QTc formulas, CrCl weights) */
.b-mini { width: 100%; border-collapse: collapse; font-size: 14px; }
.b-mini th { text-align: left; font: 500 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute); padding: 0 0 8px; }
.b-mini td { padding: 9px 0; border-top: 1px solid var(--rule-soft); color: var(--ink); white-space: nowrap; }
.b-mini td.n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.b-mini tr[data-pick] td { color: var(--teal-deep); }
.b-mini tr[data-pick] td:first-child::after { content: " (used)"; font: 400 12px var(--font-mono); color: var(--ink-mute); }

/* ABG gauges: three range bars that show where each value sits */
.b-gauges { display: flex; flex-direction: column; gap: 14px; }
.b-gauge-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.b-gauge-head strong { font: 600 14px var(--font-sans); }
.b-gauge-head span { font: 600 14px var(--font-mono); font-variant-numeric: tabular-nums; }
.b-gauge-bar { position: relative; height: 8px; margin-top: 6px; border-radius: 8px; background: linear-gradient(90deg, var(--rose-tint) 0 33.33%, var(--teal-wash) 33.33% 66.66%, var(--rose-tint) 66.66% 100%); }
.b-gauge-dot { position: absolute; top: 50%; left: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--ink); border: 2px solid var(--bg-card);
  transition: transform 400ms cubic-bezier(.22,.9,.3,1); }
.b-gauge-scale { display: flex; justify-content: space-between; margin-top: 4px; font: 500 10.5px var(--font-mono); color: var(--ink-mute); }
.b-gauge-scale span { flex: 1; text-align: center; }
.b-gauge-scale span:first-child { text-align: left; }
.b-gauge-scale span:last-child { text-align: right; }

/* the whole scale as a reference table in the guide */
.b-ref { width: 100%; border-collapse: collapse; margin: 18px 0 8px; font-size: 14.5px; }
.b-ref caption { text-align: left; font: 500 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); padding-bottom: 10px; }
.b-ref th { text-align: left; font: 500 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute); padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.b-ref td { padding: 11px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; line-height: 1.5; }
.b-ref td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.b-ref-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--bg-card); margin: 18px 0; }
.b-ref-wrap .b-ref { margin: 0; }
.b-ref-wrap .b-ref caption { padding: 14px 12px 4px; }

/* mobile: a slim score bar that follows the reader while they score */
.b-dock { display: none; }
@media (max-width: 960px) {
  .b-dock { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px;
    border-radius: 16px; background: var(--bg-dark); color: var(--ink-on-dark); box-shadow: 0 14px 34px rgba(26,36,50,.18);
    transform: translateY(0); transition: transform 360ms cubic-bezier(.45,0,.1,1), opacity 150ms; }
  .b-dock[data-off] { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .b-dock-score { font: 400 34px/1 var(--font-serif); font-variant-numeric: tabular-nums; }
  .b-dock-band { flex: 1; font: 500 13px/1.3 var(--font-sans); color: var(--ink-on-dark-soft); }
  .b-dock a { flex: none; height: 38px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--teal); color: #fff !important; font: 600 13.5px var(--font-sans); text-decoration: none; }
}

@media print {
  #main-nav, .tnd-footer-canon, .b-dock, .b-actions, .t-signup-wrap, .tnd-related, .t-head-meta .t-btn--ghost { display: none !important; }
  .b-calc { grid-template-columns: 1fr; }
  .b-calc-result { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  .b-progress-bar span, .b-meter-pin, .b-gauge-dot, .b-dock, .b-opt, .b-item { transition: none !important; }
}

/* numeric rows (CIWA-Ar 0 to 7, orientation 0 to 4): one tile per point, anchors labelled */
.b-row { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; }
.b-row-opt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 52px; padding: 10px 4px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--bg-input); cursor: pointer; text-align: center; transition: border-color 150ms cubic-bezier(.2,.7,.4,1), background-color 150ms cubic-bezier(.2,.7,.4,1); }
.b-row-opt:hover { border-color: var(--t-control-edge-hover); }
.b-row-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.b-row-n { font: 400 26px/1 var(--font-serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.b-row-lab { font: 500 11.5px/1.3 var(--font-sans); color: var(--ink-soft); }
.b-row-opt:has(input:checked) { border-color: var(--teal-deep); background: var(--teal-deep); }
.b-row-opt:has(input:checked) .b-row-n, .b-row-opt:has(input:checked) .b-row-lab { color: var(--bg-card); }
.b-row-opt:has(input:focus-visible) { outline: 2px solid var(--teal-deep); outline-offset: 2px; }
[data-theme="night"] .b-row-opt:has(input:checked) .b-row-n, [data-theme="night"] .b-row-opt:has(input:checked) .b-row-lab { color: #1f2a2a; }
.b-row-said { margin: 10px 0 0; font-size: 14px; line-height: 1.45; color: var(--teal-deep); min-height: 1.45em; }
@media (max-width: 640px) { .b-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } .b-row[style*="--cols:5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* formula tools */
.b-card .b-item-head { margin-bottom: 14px; }
.b-card .b-item-hint { margin-top: -6px; }
.b-score--text { font-size: clamp(38px, 4.4vw, 50px); line-height: 1.02; letter-spacing: -.02em; text-wrap: balance; }
.b-field .t-seg { height: auto; }
.b-field .t-seg button { min-height: 44px; }
.b-gauges + .b-steps { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--rule); }
form.b-calc-inputs { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
