/* Biomed study · tokens from /assets/base.css. Everything here is scoped to this page (bm- prefix). */

/* The diagram needs more room than the 720px column the other drills use. */
.wrap.bm-wrap { max-width: 1160px; }

/* Section tabs: same pill language as .btn */
.bm-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.bm-tab {
  appearance: none; border: 1px solid var(--line-strong); background: transparent; border-radius: 999px;
  padding: 9px 18px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.bm-tab:hover { border-color: var(--fg); }
.bm-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Layout: diagram first, question panel on the right */
.bm { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; margin-bottom: 48px; }
@media (max-width: 920px) { .bm { grid-template-columns: 1fr; } }

.bm-stage { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); min-width: 0; }
.bm-stage__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.bm-stage__body { padding: 8px 12px; }
.bm-stage__hint { margin: 0; padding: 0 14px 12px; color: var(--muted); font-size: 13px; }
#explore[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Segmented controls */
.bm-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.bm-seg button {
  appearance: none; border: 0; background: transparent; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.bm-seg button:hover { color: var(--fg); }
.bm-seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--line-strong); }
.bm-seg--full { display: flex; margin-bottom: 8px; }
.bm-seg--full button { flex: 1; }
.bm-seg--sub { display: flex; margin-bottom: 16px; background: transparent; border-color: transparent; padding: 0; gap: 6px; }
.bm-seg--sub button { border: 1px solid var(--line); padding: 5px 11px; }
.bm-seg--sub button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); box-shadow: none; }
.btn[aria-pressed="true"] { border-color: var(--fg); }

/* Panel */
.bm-panel { position: sticky; top: 16px; min-width: 0; }
@media (max-width: 920px) { .bm-panel { position: static; } }
.bm-prog { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bm-prog i { display: block; height: 100%; width: 0; background: var(--fg); transition: width var(--dur-short) var(--ease-out); }
.bm-stats { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 16px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bm-card {
  display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.bm-card__label { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.bm-card__prompt { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -0.03em; font-weight: 500; overflow-wrap: anywhere; }
.bm-card[data-kind="text"] .bm-card__prompt, .bm-card[data-kind="scrub"] .bm-card__prompt,
.bm-card[data-kind="choice"] .bm-card__prompt, .bm-card[data-kind="order"] .bm-card__prompt { font-size: 18px; }
.bm-card__body:empty { display: none; }
.bm-hint { margin: 0; color: var(--muted); font-size: 14px; }

.bm-input {
  border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px; width: 100%; min-width: 0;
}
.bm-input:focus { outline: none; border-color: var(--fg); }
.bm-input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.bm-input.is-ok { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.bm-input.is-no { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }

.bm-cloze { margin: 0; font-size: 17px; line-height: 2.2; }
.bm-blank { width: auto; display: inline-block; padding: 4px 8px; margin: 0 4px; font-size: 16px; line-height: 1.3; vertical-align: baseline; }
.bm-fix { display: inline-block; margin-right: 4px; font-size: 13px; font-weight: 500; color: var(--bad); line-height: 1.3; }

.bm-choices { display: grid; gap: 8px; }
.bm-choice {
  appearance: none; display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 15px; cursor: pointer; transition: border-color .15s;
}
.bm-choice:hover:not(:disabled) { border-color: var(--fg); }
.bm-choice:disabled { cursor: default; }
.bm-choice kbd {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line);
  border-radius: 5px; font: 12px var(--font); color: var(--muted);
}
.bm-choice.is-ok { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.bm-choice.is-no { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.bm-choice.is-ok::after { content: "✓"; margin-left: auto; color: var(--good); font-weight: 600; }
.bm-choice.is-no::after { content: "✗"; margin-left: auto; color: var(--bad); font-weight: 600; }

.bm-order { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 6px; }
.bm-step {
  counter-increment: step; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); font-size: 14px;
}
.bm-step::before { content: counter(step); flex: none; width: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bm-step__text { flex: 1; min-width: 0; }
.bm-step__move { display: flex; gap: 4px; }
.bm-step.is-ok { border-color: var(--good); }
.bm-step.is-no { border-color: var(--bad); }
.bm-icon {
  appearance: none; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 999px; background: transparent;
  cursor: pointer; font-size: 14px; line-height: 1;
}
.bm-icon:hover:not(:disabled) { border-color: var(--fg); }
.bm-icon:disabled { opacity: .35; cursor: default; }

.bm-verdict { min-height: 0; margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); }
.bm-verdict:empty { display: none; }
.bm-verdict.good { color: var(--good); }
.bm-verdict.bad { color: var(--bad); }

.bm-explain { display: grid; gap: 6px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.bm-explain p { margin: 0; }
.bm-ref { display: grid; gap: 2px; font-weight: 500; }
.bm-ref span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bm-more { color: var(--muted); }
.bm-actions { margin-top: 4px; }

.bm-missed { margin: 0; padding-left: 1.1em; font-size: 14px; display: grid; gap: 4px; }

.bm-tools { margin-top: 12px; }
.bm-keys { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
@media (hover: none) { .bm-keys { display: none; } }

/* Explore panel */
.bm-ref__title { margin: 4px 0 8px; font-size: 22px; font-weight: 500; letter-spacing: -0.03em; }
.bm-ref__rows { margin-bottom: 20px; min-height: 48px; }
.bm-dl { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.bm-dl dt { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bm-dl dd { margin: 0; }
.bm-ref__h { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bm-chip {
  appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 5px 11px; font-size: 13px; cursor: pointer;
}
.bm-chip:hover { border-color: var(--fg); }
.bm-chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ---------- Diagrams ---------- */
.bm-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.bm-pat-bg { fill: var(--bg); }
.bm-pat-ink { stroke: var(--fg); stroke-width: 2.6; }
.bm-pat-ok { stroke: var(--good); stroke-width: 2.6; }
.bm-pat-no { stroke: var(--bad); stroke-width: 2.6; }

.bm-figure svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.bm-figure svg[hidden] { display: none; }
.bm-caption { margin: 0 0 4px; text-align: center; font-size: 13px; color: var(--muted); }

.bm-svg .shape { fill: var(--bg); stroke: var(--fg); stroke-width: 1.5; stroke-linejoin: round; transition: fill .15s, stroke .15s; }
.bm-svg .shape.thin { fill: var(--bg); }
.bm-svg .outline { fill: none; stroke: var(--fg); stroke-width: 2.2; pointer-events: none; }
.bm-svg .deco { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-linecap: round; pointer-events: none; }
.bm-svg .deco.fill { fill: var(--fg); stroke: none; }
.bm-svg .deco.band { fill: var(--surface); stroke: var(--line-strong); }
.bm-svg .hit { fill: transparent; stroke: none; }
.bm-svg .nerve { fill: none; stroke-width: 4; stroke-linecap: round; }
.bm-svg .nerve-hit { fill: none; stroke: transparent; stroke-width: 16; stroke-linecap: round; }

.bm-svg.is-pickable .part { cursor: pointer; }
.bm-svg.is-pickable .part:hover .shape:not(.nerve) { fill: var(--line); }
.bm-svg.is-pickable .part:hover .shape.nerve { stroke-width: 6; }
.bm-svg .part:focus { outline: none; }
.bm-svg .part:focus-visible .shape { stroke: var(--color-focus); stroke-width: 3; }

.bm-svg .part.is-cue .shape:not(.nerve) { fill: url(#bm-hatch); stroke-width: 2.6; }
.bm-svg .part.is-cue .shape.thin { fill: var(--fg); }
.bm-svg .part.is-ok .shape:not(.nerve) { fill: url(#bm-hatch-ok); stroke: var(--good); stroke-width: 2.6; }
.bm-svg .part.is-ok .shape.thin { fill: var(--good); }
.bm-svg .part.is-no .shape:not(.nerve) { fill: url(#bm-hatch-no); stroke: var(--bad); stroke-width: 2.6; }
.bm-svg .part.is-no .shape.thin { fill: var(--bad); }
.bm-svg .part.is-cue .shape.nerve { stroke-width: 7; }
.bm-svg .part.is-ok .shape.nerve { stroke: var(--good); stroke-width: 7; }
.bm-svg .part.is-no .shape.nerve { stroke: var(--bad); stroke-width: 7; }

.bm-labels { display: none; pointer-events: none; }
.bm-svg.show-labels .bm-labels { display: inline; }
.bm-label {
  font: 500 13px var(--font); fill: var(--fg); letter-spacing: -0.01em;
  paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round;
}
.bm-leader { stroke: var(--muted); stroke-width: 1; }

/* Action potential */
.bm-figure--ap { display: grid; gap: 4px; }
.bm-svg .zone { stroke: none; }
.bm-svg.is-pickable .part:hover .zone { fill: var(--surface); }
.bm-svg .part.is-ok .zone, .bm-svg .part.is-no .zone { opacity: .4; }
.bm-svg .bilayer .head { fill: var(--surface); stroke: var(--fg); stroke-width: 1.1; }
.bm-svg .bilayer .tail { stroke: var(--line-strong); stroke-width: 1.2; }
.bm-svg .protein rect, .bm-svg .protein circle { fill: var(--surface); stroke: var(--fg); stroke-width: 1.5; }
.bm-svg .protein .chain { fill: none; stroke: var(--fg); stroke-width: 1.2; }
.bm-svg .ion circle { stroke: var(--fg); stroke-width: 1.5; }
.bm-svg .ion--na circle { fill: var(--fg); }
.bm-svg .ion--na path { stroke: var(--bg); stroke-width: 1.8; }
.bm-svg .ion--k circle { fill: var(--bg); }
.bm-svg .ion--k path { stroke: var(--fg); stroke-width: 1.8; }
.bm-svg .flow { fill: none; stroke: var(--fg); stroke-width: 3; }
.bm-svg .flow.faint { stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 4 4; }
.bm-svg .arrowhead { fill: var(--fg); }
.bm-svg text { font-family: var(--font); }
.bm-zone { font-size: 12px; font-weight: 600; fill: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bm-prot { font-size: 12px; font-weight: 500; fill: var(--fg); }
.bm-flowtext { font-size: 12px; font-weight: 500; fill: var(--fg); }
.bm-flowtext.faint { fill: var(--muted); }
.bm-sign { font-size: 20px; font-weight: 600; fill: var(--fg); }
.bm-sign.is-hidden { fill: var(--muted); font-size: 15px; }

.bm-legend { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.bm-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--fg); }
.bm-dot--na { background: var(--fg); }
.bm-dot--k { background: var(--bg); margin-left: 8px; }
.bm-legend__sep { width: 12px; }

.bm-trace { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 4px; cursor: ew-resize; touch-action: none; }
.bm-trace:focus { outline: none; }
.bm-trace:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.bm-trace.is-locked { cursor: default; }
.bm-trace .grid { stroke: var(--line); stroke-width: 1; fill: none; }
.bm-trace .grid--dash { stroke: var(--line-strong); stroke-dasharray: 4 4; }
.bm-trace .band--abs { fill: var(--surface); }
.bm-trace .band--rel { fill: var(--surface); opacity: .5; }
.bm-trace .curve { fill: none; stroke: var(--fg); stroke-width: 2.5; stroke-linejoin: round; }
.bm-trace .cursor__line { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 3 3; }
.bm-trace .cursor__dot { fill: var(--bg); stroke: var(--fg); stroke-width: 2.5; }
.bm-axis { font-size: 11px; fill: var(--muted); }
.bm-axis--n { font-weight: 600; }
.bm-ap-tools { gap: 6px; }
.bm-readout { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 4px; }

@media (max-width: 560px) {
  .bm-stage__body { padding: 4px 6px; }
  .bm-card { padding: 14px; }
  .bm-card__prompt { font-size: 19px; }
}
