/* Step 05: when ICP fails (all rules scoped to #s5) */
#s5 .s5-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-block: 18px 10px; }
@media (min-width: 900px) { #s5 .s5-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#s5 .s5-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#s5 .s5-card h3 { margin: 0; font-size: 1.15rem; display: flex; align-items: baseline; gap: 9px; }
#s5 .s5-tag { font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600; color: var(--source); border: 1px solid var(--rule); border-radius: 6px; padding: 0 6px; line-height: 1.5; }
#s5 canvas.plot { touch-action: manipulation; }
#s5 .s5-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
#s5 .s5-key { font-size: 0.84rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#s5 .s5-ring { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--source) 60%, transparent); }
#s5 .s5-dash { display: inline-block; width: 16px; border-top: 2px dashed var(--ink); }
#s5 .s5-out { font-size: 0.8rem; padding: 7px 10px; }
#s5 .readout b.good { color: var(--good); } #s5 .readout b.bad { color: var(--bad); }
#s5 .try { margin-bottom: 18px; }
#s5 .s5-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
#s5 .s5-row.on { box-shadow: inset 3px 0 0 var(--source); margin-left: -10px; padding-left: 10px; }
#s5 .s5-lesson { font-size: 0.93rem; margin: auto 0 0; padding-top: 9px; border-top: 1px solid var(--rule); }
#s5 .s5-opt .tgl { font-size: 0.88rem; }

/* segmented choice in card C */
#s5 .s5-seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--bg); }
#s5 .s5-seg button { font: inherit; font-size: 0.86rem; font-weight: 700; padding: 6px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
#s5 .s5-seg button + button { border-left: 1px solid var(--rule); }
#s5 .s5-seg button[aria-pressed="true"] { background: var(--tint); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

#s5 .s5-cap { margin: 0 0 8px; }
#s5 .s5-g, #s5 .s5-b { font-weight: 700; }
#s5 .s5-g { color: var(--good); } #s5 .s5-b { color: var(--bad); }

/* basin heatmap */
#s5 canvas.s5-heat { aspect-ratio: 2.05 / 1; background: var(--surface); border-color: transparent; cursor: pointer; }
@media (max-width: 640px) { #s5 canvas.s5-heat { aspect-ratio: 1.3 / 1; } }
#s5 canvas.s5-heat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#s5 .s5-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.84rem; color: var(--muted); margin: 8px 2px 0; }
#s5 .s5-legend span { display: inline-flex; align-items: center; gap: 6px; }
#s5 .s5-sw { display: inline-block; width: 22px; height: 12px; border-radius: 3px; }
#s5 .s5-legend span[hidden] { display: none; }
#s5 .s5-sw.ok { background: linear-gradient(90deg, color-mix(in srgb, var(--good) 50%, var(--surface)), color-mix(in srgb, var(--good) 88%, var(--surface))); }
#s5 .s5-sw.bad { background: linear-gradient(90deg, color-mix(in srgb, var(--bad) 32%, var(--surface)), color-mix(in srgb, var(--bad) 92%, var(--surface))); }
#s5 .s5-sw.twin { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bad) 70%, var(--surface)) 0 3px, color-mix(in srgb, var(--surface) 80%, var(--bad)) 3px 5px); }
#s5 .s5-sw.pend { background: var(--grid); border: 1px solid var(--rule); }
#s5 .s5-row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
#s5 .s5-sel { display: grid; gap: 3px; font-size: 0.88rem; min-width: 0; }
#s5 .s5-sel select { width: 100%; }
#s5 .s5-prog { display: grid; gap: 6px; font-size: 0.86rem; color: var(--muted); }
#s5 .s5-prog b { color: var(--ink); }
#s5 .s5-pbar { height: 4px; border-radius: 4px; background: var(--grid); overflow: hidden; }
#s5 .s5-pbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
#s5 .s5-prog.done .s5-pbar { display: none; }
#s5 .s5-info { font-size: 0.8rem; min-height: 6.4em; }
@media (min-width: 900px) { #s5 .s5-basin .s5-prev { max-width: 100%; } }
@media (max-width: 899px) { #s5 .s5-basin .s5-prev { max-width: 420px; margin-inline: auto; width: 100%; } }
/* phones: one column in reading order: choose the shape, see the result line, the map, its key, then the selected run */
@media (max-width: 899px) {
  #s5 .s5-basin .stage, #s5 .s5-basin .controls { display: contents; }
  #s5 .s5-basin .s5-row2 { order: 1; }
  #s5 .s5-basin .s5-prog { order: 2; }
  #s5 .s5-basin .s5-heat-wrap { order: 3; }
  #s5 .s5-basin .s5-legend { order: 4; margin: -4px 2px 0; }
  #s5 .s5-basin .stage > .caption { order: 5; margin: -6px 2px 0; }
  #s5 .s5-basin .s5-info { order: 6; }
  #s5 .s5-basin .s5-prev { order: 7; }
  #s5 .s5-basin .controls > .s5-bar { order: 8; }
}
