/* Health score playground · LAB59
   Builds on /assets/css/site.css tokens. */

.page-lab {
  --ok: #12895A;
  --ok-tint: #DDF3E9;
  --warn: #D98A00;
  --warn-tint: #FFF1D6;
  --crit: var(--hanko);
  --crit-tint: #FDE3E0;
  --line: rgba(14, 20, 51, .14);
  --nav-h: 66px;
}

/* ---------- intro ---------- */
.lab-hero { background: var(--royal); color: var(--paper); padding: clamp(40px, 7vw, 88px) 0 clamp(40px, 6vw, 72px); }
.lab-hero__grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr); gap: clamp(32px, 6vw, 80px); align-items: end; }
.lab-hero__crumb { font-size: .95rem; opacity: .85; margin-bottom: 1.2rem; }
.lab-hero__crumb a { font-weight: 700; text-underline-offset: 4px; }
.lab-hero__title { font: 900 clamp(2.4rem, 6.4vw, 4.8rem)/.95 var(--display); letter-spacing: -0.05em; margin-bottom: .45em; max-width: 13ch; }
.lab-hero__lede { max-width: 54ch; font-size: clamp(1.05rem, 1.6vw, 1.18rem); opacity: .95; }
.lab-hero__links { display: flex; flex-wrap: wrap; gap: 12px; margin: 1.6rem 0 0; }

.lab-hero__model { margin: 0; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.22); border-radius: 18px; padding: 8px 22px; }
.lab-hero__model div { display: grid; grid-template-columns: 1fr; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.16); }
.lab-hero__model div:last-child { border-bottom: 0; }
.lab-hero__model dt { font: 800 1rem/1.3 var(--display); letter-spacing: -0.01em; margin-bottom: 2px; }
.lab-hero__model dd { margin: 0; font-size: .96rem; opacity: .92; }
.lab-hero__model b { font-family: var(--mono); font-size: 1.05rem; }
.lab-hero__override dt::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--hanko); margin-right: 8px; box-shadow: 0 0 0 3px rgba(255,255,255,.9);
}
@media (max-width: 900px) { .lab-hero__grid { grid-template-columns: 1fr; } }

/* ---------- sticky switch ---------- */
.switchbar {
  position: sticky; top: var(--nav-h); z-index: 40;
  background: var(--paper); border-bottom: 1px solid var(--line);
  transition: box-shadow .2s ease;
}
.switchbar.is-stuck { box-shadow: 0 12px 30px -18px rgba(14,20,51,.45); }
.switchbar__inner { display: flex; align-items: center; gap: 14px 28px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.switchbar__summary { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.switch {
  display: inline-flex; align-items: center; gap: 12px; background: none; border: 0; padding: 4px 0; cursor: pointer;
  font: 700 1.05rem/1 var(--display); color: var(--ink); letter-spacing: -0.01em;
}
.switch__track {
  position: relative; width: 58px; height: 32px; border-radius: 999px; background: var(--hanko);
  transition: background-color .2s ease;
}
.switch__thumb {
  position: absolute; top: 4px; left: 30px; width: 24px; height: 24px; border-radius: 50%; background: var(--paper);
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s cubic-bezier(.3,1.4,.6,1);
}
.switch[aria-pressed="false"] .switch__track { background: #A7AEC8; }
.switch[aria-pressed="false"] .switch__thumb { left: 4px; }
.switch__label b { color: var(--hanko); }
.switch[aria-pressed="false"] .switch__label b { color: var(--ink-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font: 600 .86rem/1 var(--body); white-space: nowrap;
}
.pill b { font-family: var(--mono); font-size: .95rem; }
.pill--healthy { background: var(--ok-tint); color: #0B5E3D; }
.pill--atrisk { background: var(--warn-tint); color: #8A5600; }
.pill--critical { background: var(--crit-tint); color: #A3241A; }

/* ---------- sections ---------- */
.lab-section { padding: clamp(56px, 8vw, 104px) 0; }
.lab-section--mist { background: var(--mist); }
.lab-section--ink { background: var(--ink); color: var(--paper); }
.lab-section--ink .lab-head__lede { color: rgba(255,255,255,.78); }
.lab-head { max-width: 760px; margin-bottom: clamp(28px, 4vw, 44px); }
.lab-h2 { font: 900 clamp(2rem, 4.6vw, 3.25rem)/1.02 var(--display); letter-spacing: -0.04em; margin-bottom: .4em; }
.lab-head__lede { color: var(--ink-soft); font-size: 1.1rem; margin: 0; max-width: 62ch; }
.textbtn {
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--royal);
  font: 600 1rem/1.4 var(--body); text-decoration: underline; text-underline-offset: 4px;
}
.textbtn:hover { color: var(--royal-deep); }

/* ---------- segment ---------- */
.seg { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.seg__dots {
  display: grid; grid-template-columns: repeat(40, 1fr); gap: 3px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: clamp(10px, 2vw, 18px);
}
.seg__dots i {
  display: block; aspect-ratio: 1; border-radius: 50%; background: #C9CEE0;
  transition: background-color .45s ease, box-shadow .45s ease, transform .45s ease;
}
.seg__dots i.t-healthy { background: #8FD3B4; }
.seg__dots i.t-atrisk { background: #F6C766; }
.seg__dots i.t-critical { background: #F08A80; }
.seg__dots i.is-caught { background: var(--crit); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); transform: scale(1.12); position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .seg__dots i { transition: none; } }

.seg__side { display: grid; gap: 18px; }
.tierbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--mist); }
.tb { transition: flex-basis .45s ease; }
.tb--healthy { background: var(--ok); }
.tb--atrisk { background: var(--warn); }
.tb--critical { background: var(--crit); }
.tiercount { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.tc { display: grid; grid-template-columns: 16px 1fr auto 48px; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tc__dot { width: 12px; height: 12px; border-radius: 50%; }
.tc--healthy .tc__dot { background: var(--ok); }
.tc--atrisk .tc__dot { background: var(--warn); }
.tc--critical .tc__dot { background: var(--crit); }
.tc__label { font-weight: 500; }
.tc__n { font: 700 1.25rem/1 var(--mono); }
.tc__pct { text-align: right; color: var(--ink-soft); font-family: var(--mono); }

.callout { border-radius: 14px; padding: 18px 20px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: start; transition: background-color .3s ease; }
.callout p { margin: 0; font-size: .98rem; line-height: 1.5; }
.callout__n { font: 900 2.6rem/.9 var(--display); letter-spacing: -0.04em; }
.callout--on { background: var(--crit-tint); color: #5A1610; }
.callout--on .callout__n { color: var(--crit); }
.callout--off { background: var(--ink); color: var(--paper); }
.callout--off .callout__n { color: #F6C766; }
.seg__time { margin: 0; font-size: .95rem; color: var(--ink-soft); }
.seg__time b { color: var(--ink); }

@media (max-width: 900px) {
  .seg { grid-template-columns: 1fr; }
  .seg__dots { grid-template-columns: repeat(30, 1fr); gap: 2px; }
}
@media (max-width: 480px) { .seg__dots { grid-template-columns: repeat(24, 1fr); gap: 2px; padding: 8px; } }

/* ---------- accounts ---------- */
.acct { display: grid; gap: 10px; }
.acc { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: border-color .2s ease, box-shadow .2s ease; }
.acc.is-open { border-color: var(--royal); box-shadow: 0 18px 40px -28px rgba(23,48,184,.55); }
.acc.is-flagged { border-left: 5px solid var(--crit); }
.acc__head {
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left; color: inherit; font: inherit;
  display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(140px, .9fr) minmax(180px, 1.4fr) 24px;
  align-items: center; gap: 16px; padding: 16px 20px;
}
.acc__head:hover { background: #FAFBFF; }
.acc__name b { display: block; font: 800 1.05rem/1.25 var(--display); letter-spacing: -0.015em; }
.acc__name small { color: var(--ink-soft); font-size: .88rem; }
.acc__score { display: flex; align-items: center; gap: 12px; }
.meter { flex: 1; height: 8px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.meter__fill { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s ease, background-color .3s ease; }
.acc[data-tier="atrisk"] .meter__fill { background: var(--warn); }
.acc[data-tier="critical"] .meter__fill { background: var(--crit); }
.acc__num { font: 700 1.15rem/1 var(--mono); width: 2.2ch; text-align: right; }
.acc__tier { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.acc__alone { font-size: .8rem; color: var(--ink-soft); }
.acc__alone--warn { color: #A3241A; font-weight: 500; }
.acc__why { font-size: .92rem; color: var(--ink-soft); }
.acc.is-flagged .acc__why { color: #A3241A; font-weight: 500; }
.acc__chev { width: 12px; height: 12px; border-right: 2.5px solid var(--ink-soft); border-bottom: 2.5px solid var(--ink-soft); transform: rotate(45deg); justify-self: center; transition: transform .2s ease; margin-top: -6px; }
.acc.is-open .acc__chev { transform: rotate(-135deg); margin-top: 6px; }

.acc__body { border-top: 1px solid var(--line); padding: 22px 20px 24px; background: #FBFCFF; }
.ed { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); }
.ed__ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; align-content: start; }
.mods { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.mods legend { font-weight: 500; font-size: .95rem; margin-bottom: 8px; padding: 0; }
.chip {
  border: 2px solid var(--line); background: var(--paper); color: var(--ink-soft); border-radius: 999px;
  padding: 8px 14px; font: 500 .92rem/1 var(--body); cursor: pointer; transition: all .15s ease;
}
.chip:hover { border-color: var(--royal); }
.chip[aria-pressed="true"] { background: var(--royal); border-color: var(--royal); color: var(--paper); }
.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .92rem; color: var(--ink-soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--royal); }

.ed__out { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; align-self: start; }
.ed__total { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; }
.ed__num { font: 900 3rem/1 var(--display); letter-spacing: -0.04em; }
.ed__total span { color: var(--ink-soft); }
.part { margin-bottom: 12px; }
.part__row { display: flex; justify-content: space-between; font-size: .92rem; margin-bottom: 5px; }
.part__row b { font-family: var(--mono); }
.part__row small { color: var(--ink-soft); font-weight: 400; }
.part__bar { height: 8px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.part__fill { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.part__fill--e { background: var(--royal); }
.part__fill--f { background: #5B74F0; }
.part__fill--s { background: #9AABF7; }
.ed__verdict { margin: 14px 0 0; padding-top: 14px; border-top: 1px dashed var(--line); font-size: .95rem; line-height: 1.5; }
.acct__foot { margin: 18px 0 0; }

@media (max-width: 980px) {
  .acc__head { grid-template-columns: 1fr auto 24px; grid-template-areas: "name tier chev" "score score score" "why why why"; gap: 10px 14px; }
  .acc__name { grid-area: name; } .acc__tier { grid-area: tier; align-items: flex-end; } .acc__chev { grid-area: chev; }
  .acc__score { grid-area: score; } .acc__why { grid-area: why; }
  .ed { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .ed__ctl { grid-template-columns: 1fr; } .acc__head { padding: 14px 16px; } .acc__body { padding: 18px 16px; } }

/* ---------- controls ---------- */
.ctl__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.ctl__row label { font-weight: 500; font-size: .95rem; }
.ctl__row output { font: 700 .95rem/1 var(--mono); color: var(--royal); white-space: nowrap; }
.ctl input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(to right, var(--royal) 0 var(--pct, 50%), #D7DCEF var(--pct, 50%) 100%);
}
.ctl input[type=range].is-muted { background: #E4E7F2; opacity: .55; }
.ctl input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--paper);
  border: 3px solid var(--royal); box-shadow: 0 2px 6px rgba(14,20,51,.25);
}
.ctl input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--paper); border: 3px solid var(--royal); }
.ctl input[type=range]:focus-visible { outline: 3px solid var(--hanko); outline-offset: 4px; }

.model { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px 22px; margin: 0; display: grid; gap: 18px; align-content: start; background: var(--paper); }
.panel legend { font: 800 1.15rem/1 var(--display); letter-spacing: -0.02em; padding: 0 8px; margin-left: -8px; }
.panel--override { border-color: rgba(229,57,42,.45); background: #FFF8F7; }
.panel--override .ctl input[type=range] { background: linear-gradient(to right, var(--hanko) 0 var(--pct, 50%), #F3D5D1 var(--pct, 50%) 100%); }
.panel--override .ctl input[type=range]::-webkit-slider-thumb { border-color: var(--hanko); }
.panel--override .ctl__row output { color: var(--hanko); }
.panel__note { margin: 0; font-size: .9rem; color: var(--ink-soft); }
.weights { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; }
.wseg { transition: flex-basis .3s ease; }
.wseg--e { background: var(--royal); } .wseg--f { background: #5B74F0; } .wseg--s { background: #9AABF7; }
@media (max-width: 900px) { .model { grid-template-columns: 1fr; } }

/* ---------- plays ---------- */
.plays { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.play { border-radius: 16px; padding: 22px; background: #18204A; display: flex; flex-direction: column; border-top: 5px solid var(--ok); transition: opacity .3s ease; }
.play--atrisk { border-top-color: var(--warn); }
.play--dorm, .play--det { border-top-color: var(--crit); }
.play--det { background: var(--paper); color: var(--ink); }
.play__who { font-size: .88rem; opacity: .8; margin: 0 0 4px; }
.play__title { font: 800 1.2rem/1.2 var(--display); letter-spacing: -0.02em; margin-bottom: 14px; }
.play__n { font: 900 2.6rem/1 var(--display); letter-spacing: -0.04em; margin-bottom: 12px; }
.play__text { margin: 0; font-size: .95rem; line-height: 1.5; opacity: .9; }
.play__off { margin: 12px 0 0; font-size: .88rem; font-weight: 500; color: #F6C766; }
.play--det .play__off { color: #A3241A; }
.play.is-off { opacity: .55; }
@media (max-width: 980px) { .plays { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .plays { grid-template-columns: 1fr; } }

/* ---------- playbook ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.tab {
  font: 700 1rem/1 var(--display); padding: 13px 20px; border-radius: 999px; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 2px solid var(--line);
}
.tab:hover { border-color: var(--royal); }
.tab[aria-selected="true"] { background: var(--royal); border-color: var(--royal); color: var(--paper); }

.phases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 3px solid var(--ink); }
.phase { padding: 24px 28px 8px 0; position: relative; }
.phase + .phase { padding-left: 28px; border-left: 1px solid var(--line); }
.phase__when { font: 700 .95rem/1 var(--mono); color: var(--royal); margin-bottom: 10px; }
.phase__title { font: 800 1.35rem/1.15 var(--display); letter-spacing: -0.025em; margin-bottom: 14px; }
.phase ul { margin: 0; padding-left: 1.1em; color: var(--ink-soft); }
.phase li { margin-bottom: .55em; }
@media (max-width: 860px) {
  .phases { grid-template-columns: 1fr; }
  .phase, .phase + .phase { padding: 22px 0 6px; border-left: 0; border-bottom: 1px solid var(--line); }
}

.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rule { border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; }
.rule h3 { font: 800 1.2rem/1.2 var(--display); letter-spacing: -0.02em; margin-bottom: 8px; }
.rule p { margin: 0; color: var(--ink-soft); }
.rule--hold { background: #FFF8F7; border-color: rgba(229,57,42,.45); }
.rule--hold b { color: #A3241A; }
.pane__live { margin: 20px 0 0; padding: 16px 20px; border-radius: 14px; background: var(--mist); }
@media (max-width: 760px) { .rules { grid-template-columns: 1fr; } }

.report { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 4vw, 48px); }
.report h3 { font: 800 1.35rem/1.15 var(--display); letter-spacing: -0.025em; margin-bottom: 8px; padding-bottom: 12px; border-bottom: 3px solid var(--ok); }
.report__col--flag h3 { border-bottom-color: var(--crit); }
.report dl { margin: 0; }
.report dl div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.report dt { font-weight: 700; margin-bottom: 3px; }
.report dd { margin: 0; color: var(--ink-soft); }
@media (max-width: 760px) { .report { grid-template-columns: 1fr; } }

/* ---------- close ---------- */
.lab-close { background: var(--royal); color: var(--paper); padding: clamp(56px, 8vw, 96px) 0; }
.lab-close__inner { display: grid; grid-template-columns: minmax(0, 1.4fr) auto; gap: 28px 48px; align-items: end; }
.lab-close__title { font: 900 clamp(2rem, 4.6vw, 3.25rem)/1.02 var(--display); letter-spacing: -0.04em; margin-bottom: .4em; }
.lab-close p { max-width: 56ch; margin: 0; font-size: 1.08rem; opacity: .95; }
.lab-close__actions { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 860px) { .lab-close__inner { grid-template-columns: 1fr; } }
