/* "How to read" guides. Uses the app's theme tokens; medium colours are fixed in reading-guides.js. */
.rg-launch { font:600 12px 'IBM Plex Sans',sans-serif; min-height:44px; padding:8px 12px; margin-top:8px; display:inline-flex; align-items:center; gap:6px;
  color:var(--brand); background:var(--surface); border:1px solid var(--line-strong); border-radius:10px; cursor:pointer; }
.rg-launch::before { content:""; width:14px; height:14px; border-radius:50%; border:2px solid currentColor; box-sizing:border-box;
  background:conic-gradient(currentColor 0 25%, transparent 25% 100%); }
.rg-launch:hover { border-color:var(--brand); }
.rg-launch:focus-visible, .rg-btn:focus-visible, .rg-outcome:focus-visible, .rg-range:focus-visible, .rg-inline > summary:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.test-row .label .visual-launcher + .rg-launch { margin-left:8px; }

.rg-dialog { width:min(960px, calc(100vw - 24px)); max-height:calc(100dvh - 24px); padding:0; border:1px solid var(--line-strong); border-radius:22px;
  background:var(--paper); color:var(--ink); box-shadow:0 30px 80px -30px rgba(0,0,0,.6); }
.rg-dialog::backdrop { background:rgba(10,14,15,.55); }
.rg-dialog-head { position:sticky; top:0; z-index:2; display:flex; justify-content:space-between; align-items:flex-start; gap:12px;
  padding:16px 18px 12px; background:var(--paper); border-bottom:1px solid var(--line); }
.rg-dialog-head h2 { margin:2px 0 0; font:600 22px/1.2 'Fraunces',Georgia,serif; text-wrap:balance; }
.rg-eyebrow { font:600 11px/1.3 'JetBrains Mono',monospace; letter-spacing:.08em; text-transform:uppercase; color:var(--brand); }
.rg-dialog-body { padding:16px 18px 20px; }

.rg { display:flex; flex-direction:column; gap:16px; }
.rg-outcomes { display:flex; flex-wrap:wrap; gap:8px; }
.rg-outcome { min-height:44px; padding:8px 12px; border-radius:12px; border:1px solid var(--line-strong); background:var(--surface); color:var(--ink);
  font:500 13.5px/1.25 'IBM Plex Sans',sans-serif; cursor:pointer; display:flex; flex-direction:column; align-items:flex-start; gap:2px; text-align:left; }
.rg-outcome small { font:500 11px/1.3 'JetBrains Mono',monospace; color:var(--ink-faint); font-style:italic; }
.rg-outcome[aria-pressed="true"] { border-color:var(--brand); background:var(--brand-tint); box-shadow:inset 0 0 0 1px var(--brand); }

.rg-bench { display:grid; grid-template-columns:minmax(200px, 280px) minmax(0,1fr); gap:16px; align-items:start; }
@media (max-width:680px) { .rg-bench { grid-template-columns:1fr; } }
.rg-figure { margin:0; background:var(--surface); border:1px solid var(--line); border-radius:18px; padding:14px; display:flex; flex-direction:column; align-items:center; gap:8px; }
.rg-figure svg { width:100%; max-width:240px; height:auto; display:block; }
.rg-figcaption { font:500 11.5px/1.4 'JetBrains Mono',monospace; color:var(--ink-faint); text-align:center; }
.rg-glass { fill:var(--line-strong); opacity:.9; }
.rg-glass-edge { stroke:var(--line-strong); stroke-width:3; }
.rg-tube-air { fill:var(--surface-sunk); opacity:.35; }
.rg-label line { stroke:var(--ink-faint); stroke-width:1; }
.rg-label text, .rg-label-text { font:500 11px 'JetBrains Mono',monospace; fill:var(--ink-faint); }
.rg-dish { fill:var(--surface-sunk); stroke:var(--line-strong); stroke-width:2; }
.rg-disc-text { font:600 7px 'JetBrains Mono',monospace; fill:#4A4A44; }
.rg-ruler line { stroke:var(--ink); stroke-width:1.5; }
.rg-ruler text { font:600 12px 'JetBrains Mono',monospace; fill:var(--ink); }
.rg-dark { fill:#151A1B; }
.rg-dark-text { font:500 11px 'JetBrains Mono',monospace; fill:#B3BABC; }

.rg-panel { display:flex; flex-direction:column; gap:12px; min-width:0; }
.rg-timeline, .rg-readout { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:14px; display:flex; flex-direction:column; gap:10px; }
.rg-time-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.rg-btn { min-height:44px; min-width:44px; padding:0 14px; border-radius:12px; border:1px solid var(--line-strong); background:var(--surface-sunk); color:var(--ink);
  font:600 13.5px 'IBM Plex Sans',sans-serif; cursor:pointer; }
.rg-play { background:var(--brand); border-color:var(--brand); color:var(--surface); }
.rg-clock { font:600 20px/1 'JetBrains Mono',monospace; font-variant-numeric:tabular-nums; min-width:5ch; }
.rg-chip { font:600 11.5px/1.2 'JetBrains Mono',monospace; padding:6px 10px; border-radius:999px; border:1px solid var(--line); background:var(--surface-sunk); color:var(--ink-soft); }
.rg-chip[data-state="read"] { background:var(--brand-tint); border-color:var(--brand); color:var(--ink); }
.rg-chip[data-state="early"], .rg-chip[data-state="late"] { background:var(--st-warn-bg); border-color:var(--st-warn-line); color:var(--st-warn-ink); }
.rg-range { width:100%; accent-color:var(--brand); height:28px; margin:0; }
.rg-ticks { position:relative; height:22px; font:500 10.5px/1 'JetBrains Mono',monospace; color:var(--ink-faint); margin:0 6px; }
.rg-ticks span { position:absolute; transform:translateX(-50%); white-space:nowrap; }
.rg-ticks .rg-tick-on { color:var(--brand); font-weight:600; }
.rg-ticks .rg-band { top:-30px; height:5px; border-radius:3px; background:var(--brand); opacity:.35; transform:none; }
.rg-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

.rg-read-title { margin:0; font:600 15px/1.35 'Fraunces',Georgia,serif; }
.rg-cells { display:grid; grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:8px; }
.rg-cell { border:1px solid var(--line); border-radius:12px; padding:9px 10px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.rg-cell > span { font:500 10.5px/1.3 'JetBrains Mono',monospace; color:var(--ink-faint); text-transform:uppercase; letter-spacing:.05em; }
.rg-cell b { font:600 14px/1.3 'IBM Plex Sans',sans-serif; display:flex; align-items:center; gap:6px; overflow-wrap:anywhere; }
.rg-swatch { display:inline-block; width:14px; height:14px; border-radius:4px; border:1px solid rgba(0,0,0,.25); flex-shrink:0; }
.rg-entry { font:500 12.5px/1.5 'JetBrains Mono',monospace; background:var(--surface-sunk); border-radius:10px; padding:9px 11px; overflow-wrap:anywhere; }
.rg-narr { margin:0; color:var(--ink-soft); font-size:14px; line-height:1.5; }
.rg-note { margin:0; font-size:13px; line-height:1.45; color:var(--st-warn-ink); background:var(--st-warn-bg); border:1px solid var(--st-warn-line); border-radius:12px; padding:9px 11px; }
.rg-note[hidden] { display:none; }

.rg-key { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; }
.rg-key > div { display:flex; gap:9px; align-items:flex-start; font-size:12.5px; color:var(--ink-soft); }
.rg-key .rg-swatch { width:20px; height:20px; }
.rg-key b { display:block; color:var(--ink); font-size:13px; }
.rg-foot { display:flex; flex-direction:column; gap:6px; font-size:12.5px; line-height:1.5; color:var(--ink-soft); border-top:1px solid var(--line); padding-top:12px; }
.rg-foot p { margin:0; }
.rg-foot a { color:var(--brand); }
.rg-source-note { color:var(--ink-faint); }

.rg-inline { margin:12px 0; border:1px solid var(--line); border-radius:14px; background:var(--surface); }
.rg-inline > summary { cursor:pointer; min-height:44px; display:flex; align-items:center; padding:10px 14px; font:600 13.5px 'IBM Plex Sans',sans-serif; color:var(--brand); }
.rg-inline[open] > summary { border-bottom:1px solid var(--line); }
.rg-inline > .rg { padding:14px; }

/* Phone: keep drawing, timeline and readout within reach. */
.rg-dialog-head .rg-btn { white-space:nowrap; }
@media (max-width:680px) {
  .rg-dialog-head { padding:12px 14px 10px; }
  .rg-dialog-head h2 { font-size:19px; }
  .rg-dialog-body { padding:12px 14px 16px; }
  .rg-outcomes { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:6px; }
  .rg-outcome { padding:7px 10px; font-size:12.5px; }
  .rg-outcome small { font-size:10px; overflow-wrap:anywhere; }
  .rg-figure { padding:10px; }
  .rg-figure svg { max-height:34vh; width:auto; max-width:100%; }
}

/* Tests dictionary: How to read button with a one-line explanation. */
.rg-dictionary-guide { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; margin:12px 0; font-size:13px; color:var(--ink-soft); }
.rg-dictionary-guide .rg-launch { margin-top:0; }

/* Identification worksheet: picture of the final reaction after entry. */
.rg-thumb-slot:empty { display:none; }
.rg-thumb-slot { margin-top:8px; }
/* Unhoused: no card, border or fill. The drawing and caption sit directly on the worksheet surface;
   the whole picture stays one button (hover lift, focus ring) that opens the guide. */
.rg-thumb { display:inline-flex; align-items:center; gap:12px; max-width:100%; min-height:44px; padding:0; text-align:left; cursor:pointer;
  background:none; border:0; border-radius:10px; box-shadow:none; color:var(--ink); font:inherit; -webkit-tap-highlight-color:transparent; }
.rg-thumb:focus-visible { outline:3px solid var(--brand); outline-offset:4px; }
.rg-thumb:hover .rg-thumb-text b { color:var(--brand); }

/* Scaling: every drawing gets the same display box, cropped to the object by fitThumb() and
   centred. The box is a little taller than wide, so dishes and plates (limited by width) and upright
   tubes and bottles (limited by height) read with similar visual weight. */
.rg-thumb { --rg-thumb:60px; --rg-thumb-h:74px; }
.rg-thumb-art { flex:0 0 auto; display:block; width:var(--rg-thumb); height:var(--rg-thumb-h); }
.rg-thumb svg { width:100%; height:100%; display:block; overflow:visible; transition:transform .18s ease, filter .18s ease; }
.rg-thumb:hover svg, .rg-thumb:focus-visible svg { transform:translateY(-2px); filter:drop-shadow(0 6px 8px rgba(0,0,0,.18)); }
@media (prefers-reduced-motion: reduce) { .rg-thumb svg { transition:none; } .rg-thumb:hover svg { transform:none; } }
/* In-drawing labels, rulers and disc lettering are unreadable at this size; the caption carries the result. */
.rg-thumb .rg-label, .rg-thumb .rg-label-text, .rg-thumb .rg-ruler, .rg-thumb .rg-dark-text, .rg-thumb .rg-disc-text { display:none; }
.rg-thumb-text { display:flex; flex-direction:column; gap:2px; min-width:0; }
.rg-thumb-text b { font:600 13px/1.3 'IBM Plex Sans',sans-serif; overflow-wrap:anywhere; }
.rg-thumb-text small { font:500 10.5px/1.3 'JetBrains Mono',monospace; color:var(--ink-faint); }
@media (prefers-reduced-motion: no-preference) { .rg-thumb { animation:rgThumbIn .25s ease-out both; } }
@keyframes rgThumbIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* Chart-style worksheet (one narrow column per test): stack picture and a short label. */
#testGrid.is-chart .rg-thumb { flex-direction:column; align-items:center; gap:8px; width:100%; padding:4px 0; text-align:center; }
#testGrid.is-chart .rg-thumb { --rg-thumb:86px; --rg-thumb-h:108px; }
@media (max-width:600px) { #testGrid.is-chart .rg-thumb { --rg-thumb:78px; --rg-thumb-h:98px; } }
/* Line pictures up across the chart: pin each picture to the bottom of the header row and reserve
   three caption lines, so drawings share one baseline whatever the test name or caption length. */
#testGrid.is-chart .test-row .label > .rg-thumb-slot:not(:empty) { margin-top:auto; width:100%; }
#testGrid.is-chart .rg-thumb-text { min-height:calc(3 * 1.25 * 11.5px + 2px + 12px); justify-content:flex-start; }
#testGrid.is-chart .rg-thumb-text b { font-size:11.5px; line-height:1.25; overflow-wrap:normal; word-break:normal; hyphens:auto; }
#testGrid.is-chart .rg-thumb-text small { font-size:9.5px; }
/* List layout: centre the test name against its picture instead of the picture's baseline. */
#testGrid:not(.is-chart) .test-row .label:has(.rg-thumb) { align-items:center; }
/* Worksheet rows that do not apply because of another result (see DEPENDENT_ROWS in app.html). */
.toggle.is-not-applicable button[data-val]:disabled { opacity:.38; cursor:not-allowed; }
.row-na-note { grid-column:1 / -1; margin:4px 0 0; font-size:11.5px; line-height:1.35; color:var(--ink-faint); text-align:left; }
#testGrid:not(.is-chart) .toggle.is-not-applicable { flex-wrap:wrap; justify-content:flex-end; }
#testGrid:not(.is-chart) .row-na-note { flex:1 0 100%; text-align:right; }
#testGrid.is-chart .row-na-note { flex:none; width:100%; }
/* Taller picture box for slant tubes (TSI, LIA): the whole tube, cap included, drawn larger. */
.rg-thumb.rg-thumb-tall { --rg-thumb-h:96px; }
#testGrid.is-chart .rg-thumb.rg-thumb-tall { --rg-thumb-h:148px; }
@media (max-width:600px) { #testGrid.is-chart .rg-thumb.rg-thumb-tall { --rg-thumb-h:134px; } }
