/* AskDimitri Stats, reconstruct patient data from Kaplan-Meier curves (/tools/stats/reconstruct/).
   Builds on /tools/stats/stats.css (the steps, the sections, the result card); colours from
   /css/tokens.css. Five steps. The workbench (the figure and the steps that click on it) widens
   beyond the 720 px column on a desktop, with the figure held in view while the steps scroll; on
   a tablet the figure stays at the top of the screen; on a phone everything is one column. */

.rc-flow { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rc-flow::before { right: calc(20% - 19px); }
.rc-page .eyebrow a { color: inherit; }

.rc-drop { display: flex; flex-direction: column; align-items: center; border: 1.5px dashed var(--field-border); border-radius: 16px; padding: 22px 18px 16px; background: var(--card); text-align: center; transition: border-color .2s ease, background-color .2s ease; }
.rc-drop.over { border-color: var(--ink); background: var(--tint); }
.rc-drop-art { width: 72px; height: auto; margin-bottom: 8px; }
.rc-art-frame { fill: var(--paper); stroke: var(--hairline); stroke-width: 1.2; }
.rc-art-axis { fill: none; stroke: var(--text); stroke-width: 1.4; }
.rc-art-curve { fill: none; stroke: #0072B2; stroke-width: 2; }
.rc-art-curve2 { fill: none; stroke: #D55E00; stroke-width: 2; }
.rc-art-tick { fill: none; stroke: var(--gold-ink); stroke-width: 1.6; }
.rc-art-mark { fill: none; stroke: var(--gold-ink); stroke-width: 1.6; }
.rc-art-click { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.rc-art-text { font: 8.5px var(--sans); fill: var(--text); }
.rc-art-row { fill: none; stroke: var(--gold-ink); stroke-width: 1.4; }
.rc-drop-text { margin: 0 0 4px; font-family: var(--serif); font-size: 18px; color: var(--ink); }
.rc-drop .st-actions { justify-content: center; }
.rc-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.rc-file:focus-visible + .link-button, .rc-file-label:focus-within { outline: 2px solid var(--ink); }
.rc-file-label { cursor: pointer; }

/* The workbench */
.rc-desk { margin-top: 8px; }
.rc-work { margin-top: 28px; }
.rc-modes { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.rc-modes legend { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; padding: 0; }
.rc-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-seg-opt { position: relative; }
.rc-seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.rc-seg-opt label { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--field-border); border-radius: 999px; background: var(--card); font-size: 14px; color: var(--text); cursor: pointer; transition: background-color .15s ease, border-color .15s ease; }
.rc-seg-opt label:hover { border-color: var(--ink); }
.rc-seg-opt input:checked + label { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.rc-seg-opt input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }
.rc-hint { font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--gold-tint); border: 1px solid var(--gold-line); border-radius: 10px; padding: 9px 14px; margin: 8px 0 10px; }
.rc-hint:empty { display: none; }
.rc-toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 10px 0 6px; }
.rc-toolbar .field { margin: 0; display: flex; align-items: center; gap: 8px; }
.rc-toolbar .field label { margin: 0; font-size: 13px; color: var(--muted); }
.rc-toolbar .btn { margin: 0; height: 40px; font-size: 14.5px; }
.rc-toolbar select { width: auto; height: 40px; }

.rc-stage { position: relative; }
.rc-scroll { overflow: auto; max-height: 78vh; border: 1px solid var(--hairline); border-radius: 12px; background: #ffffff; box-shadow: 0 18px 36px -30px color-mix(in srgb, var(--ink) 50%, transparent); }
.rc-canvas { display: block; width: 100%; height: auto; cursor: crosshair; touch-action: none; image-rendering: auto; }
.rc-loupe { position: absolute; top: 8px; right: 8px; width: 168px; height: 168px; border: 2px solid var(--ink); border-radius: 50%; background: #ffffff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); pointer-events: none; opacity: 0; transition: opacity .12s; }
.rc-loupe.on { opacity: 1; }
.rc-readout { font-variant-numeric: tabular-nums; }

.rc-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 0; padding: 0; font-size: 13px; color: var(--text); }
.rc-legend li { display: inline-flex; align-items: center; gap: 7px; }
.rc-key { display: inline-block; flex: none; }
.rc-key-dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid; background: #ffffff; }
.rc-key-dash { width: 22px; height: 0; border-top: 2.5px dashed; }
.rc-key-tick { width: 2px; height: 12px; background: #B8860B; }
.rc-key-hide { width: 14px; height: 10px; background: rgba(120, 120, 120, 0.35); border: 1px solid rgba(60, 60, 60, 0.7); }

/* Steps 2 to 4 */
.rc-panel .st-section:first-child { border-top: 0; }
.rc-how { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: start; }
.rc-illus { width: 120px; height: auto; margin-top: 4px; }
.rc-refs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 4px 0 6px; }
.rc-ref { display: grid; grid-template-columns: minmax(0, 1fr) 84px auto; gap: 8px; align-items: center; }
.rc-ref input[type="text"] { width: 100%; box-sizing: border-box; }
.rc-ref-state { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.rc-ref-state.is-marked { color: var(--delta); font-weight: 500; }
.rc-ref-state.is-marked::before { content: "\2713  "; }

.rc-arms { display: grid; gap: 12px; }
.rc-arm { border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 16px; background: var(--card); transition: border-color .15s ease; }
.rc-arm.active { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--gold); }
.rc-arm-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.rc-arm-head .field { margin: 0; }
.rc-arm-name input { width: 180px; max-width: 100%; box-sizing: border-box; }
.rc-arm-tol input[type="range"] { width: 150px; accent-color: var(--ink); }
.rc-swatch { width: 22px; height: 22px; border-radius: 50%; border: 3px solid; box-sizing: border-box; align-self: center; flex: none; }
.rc-arm-actions { margin-top: 10px; }
.rc-count { font-size: 13.5px; color: var(--muted); }
.rc-details { margin-top: 8px; font-size: 14px; }
.rc-details summary { cursor: pointer; color: var(--ink); }
.rc-points-text { min-height: 100px; }

.rc-wide { width: 100%; max-width: 520px; box-sizing: border-box; }
.rc-risk { display: grid; gap: 10px; margin-top: 12px; }
.rc-risk-arm { border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 14px 12px; margin: 0; min-width: 0; background: var(--card); }
.rc-risk-arm legend { font-size: 14px; font-weight: 600; color: var(--ink); padding: 0 4px; }
.rc-risk-arm .field { margin: 0 0 8px; }
.rc-risk-risk input { width: 100%; box-sizing: border-box; }
.rc-risk-totals { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.rc-risk-totals input { width: 120px; }

/* Step 5: the verdict card */
.rc-verdict { margin: -4px -4px 0; padding: 22px 22px 18px; border-radius: 14px; border: 1px solid var(--hairline); }
.rc-verdict .st-r-answer { margin-bottom: 16px; }
.rc-verdict-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 4px 12px 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; background: var(--card); }
.rc-verdict-dot { width: 10px; height: 10px; border-radius: 50%; }
.rc-good { background: color-mix(in srgb, var(--light-green) 7%, var(--card)); border-color: color-mix(in srgb, var(--light-green) 40%, var(--card)); }
.rc-good .rc-verdict-badge { color: var(--light-green); }
.rc-good .rc-verdict-dot { background: var(--light-green); }
.rc-fair { background: var(--gold-tint); border-color: var(--gold-line); }
.rc-fair .rc-verdict-badge { color: var(--gold-ink); }
.rc-fair .rc-verdict-dot { background: var(--light-amber); }
.rc-poor { background: var(--danger-bg); border-color: var(--danger-line); }
.rc-poor .rc-verdict-badge { color: var(--danger); }
.rc-poor .rc-verdict-dot { background: var(--light-red); }
.rc-verdict .st-key { background: var(--card); }
.rc-files-note { font-size: 14.5px; line-height: 1.55; margin: 0 0 10px; }
.rc-approx { font-size: 14px; color: var(--muted); margin: 14px 0 0; }

/* Tablets: the figure stays at the top of the screen while the steps scroll under it. */
@media (min-width: 700px) and (max-width: 1099.98px) {
  .rc-desk.has-image .rc-work { position: sticky; top: 0; z-index: 10; background: var(--paper); padding: 10px 0 8px; border-bottom: 1px solid var(--hairline); }
  .rc-desk.has-image .rc-scroll { max-height: 44vh; }
  .rc-desk.has-image .rc-readout { display: none; }
  .rc-desk.has-image .rc-panel .st-section { scroll-margin-top: 58vh; }
}
/* Desktop: the workbench is wider than the column; the figure on the left, the steps on the right. */
@media (min-width: 1100px) {
  .rc-desk.has-image { width: min(1240px, calc(100vw - 64px)); margin-left: calc(50% - min(620px, 50vw - 32px)); display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 0 36px; align-items: start; }
  .rc-desk.has-image .rc-work { position: sticky; top: 16px; margin-top: 40px; }
  .rc-desk.has-image .rc-scroll { max-height: calc(100vh - 230px); }
  .rc-desk.has-image .rc-panel .st-section:first-child { margin-top: 40px; padding-top: 0; }
  .rc-desk.has-image .rc-how { grid-template-columns: 1fr; gap: 6px; }
  .rc-desk.has-image .rc-illus { width: 140px; }
  .rc-desk.has-image .rc-refs { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .rc-flow .st-flow-n { width: 30px; height: 30px; }
  .rc-flow::before { top: 15px; right: calc(20% - 15px); }
  .rc-flow .st-flow-title { font-size: 14px; }
  .rc-refs { grid-template-columns: 1fr; }
  .rc-how { grid-template-columns: 1fr; gap: 4px; }
  .rc-illus { width: 110px; }
  .rc-loupe { width: 112px; height: 112px; }
  .rc-verdict { margin: -2px; padding: 16px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .rc-drop, .rc-seg-opt label, .rc-arm, .rc-loupe { transition: none; }
}
@media print {
  .rc-drop, .rc-work, #rc-form, .rc-loupe, .rc-flow { display: none !important; }
}
