/* Live demo page. Builds on page.css: same tokens, a wider column for the tool. */
main.demo { width: min(100% - 2 * var(--side), 1120px); }
main.demo .lead { max-width: 46em; }
.notice { margin: 0 0 28px; padding: 14px 18px; border-radius: 8px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 15px; color: var(--text); max-width: 46em; }
.opt { font-weight: 400; color: var(--muted); }

.demo-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.d-step { padding: 24px; border-radius: 10px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }
.d-step h2 { margin: 0 0 18px; padding: 0; border: 0; font-size: 20px; }
.demo-grid .d-step:first-child { grid-row: span 2; }

.d-pick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.d-samples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.d-samples button { padding: 0; border: 0; border-radius: 8px; background: var(--ground); cursor: pointer; aspect-ratio: 1; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.d-samples img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0.62; transition: opacity 200ms ease; }
.d-samples button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent-text); }
.d-samples button[aria-pressed="true"] img, .d-samples button:hover img { opacity: 1; }
.d-lensbox { margin: 0; }
.d-lens { width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--ground); box-shadow: 0 0 0 1px var(--line-2); }
.d-lens img { display: block; width: 100%; height: 100%; object-fit: cover; }
.d-lensbox figcaption { margin-top: 12px; font-size: 13px; line-height: 1.5; }

.d-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.d-field { display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
.d-field input, .d-field select { width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--radius); background: var(--ground); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); font: inherit; font-size: 16px; }
.d-field input::placeholder { color: var(--muted); }
.d-field input:focus-visible, .d-field select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.d-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.d-row .btn { min-height: 44px; padding: 0 16px; font-size: 15px; }

.d-go .btn { width: 100%; }
.d-go .btn[disabled] { opacity: 0.6; cursor: progress; }
.d-go progress { display: block; width: 100%; height: 4px; margin-top: 14px; border: 0; border-radius: 2px; background: var(--line); appearance: none; -webkit-appearance: none; }
.d-go progress::-webkit-progress-bar { background: var(--line); border-radius: 2px; }
.d-go progress::-webkit-progress-value { background: var(--accent-text); border-radius: 2px; }
.d-go progress::-moz-progress-bar { background: var(--accent-text); border-radius: 2px; }
.d-status { min-height: 1.5em; margin: 12px 0 0; font-size: 15px; color: var(--text); }
.d-note { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

.d-result { margin-top: 20px; padding: 24px; border-radius: 10px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2); }
.d-result h2 { margin: 0 0 6px; padding: 0; border: 0; font-size: 24px; }
.d-result h2:focus { outline: none; }
.d-runs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 18px 0 10px; }
.d-run { padding: 18px 20px; border-radius: 8px; background: var(--ground); box-shadow: inset 0 0 0 1px var(--line); }
.d-run h3 { margin: 0 0 14px; font-size: 16px; color: var(--text-2); }
.d-bar { display: grid; grid-template-columns: 9.5em minmax(0, 1fr) 3em; align-items: center; gap: 12px; margin: 0 0 10px; font-size: 15px; }
.d-bar .k { color: var(--text-2); }
.d-bar .track { position: relative; height: 8px; border-radius: 4px; background: var(--line); }
.d-bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 4px; background: var(--text-2); transition: width 700ms cubic-bezier(0.23, 1, 0.32, 1); }
.d-bar[data-k="mel"] .fill { background: var(--accent-text); }
.d-bar .cut { position: absolute; top: -4px; bottom: -4px; left: 27.8%; width: 2px; border-radius: 1px; background: var(--text); }
.d-bar .v { text-align: right; color: var(--text); font-weight: 500; }
.d-sugg { margin: 14px 0 0; color: var(--text-2); }
.d-key { font-size: 14px; color: var(--muted); }
.d-biopsy { margin: 6px 0 0; }

.d-next { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); max-width: 46em; }
.d-next h2 { margin: 0 0 10px; padding: 0; border: 0; }

@media (max-width: 900px) {
  .demo-grid { grid-template-columns: minmax(0, 1fr); }
  .demo-grid .d-step:first-child { grid-row: auto; }
}
@media (max-width: 560px) {
  .d-pick { grid-template-columns: minmax(0, 1fr); }
  .d-lensbox { max-width: 240px; margin: 0 auto; }
  .d-fields { grid-template-columns: minmax(0, 1fr); }
  .d-step, .d-result { padding: 18px; }
  .d-bar { grid-template-columns: 8em minmax(0, 1fr) 2.8em; gap: 10px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .d-bar .fill, .d-samples img { transition: none; } }
