/* Interactive demo page. Colours follow the Nature figure palette:
   a deep blue for DSBR, a strong red for Entropy Minimization, muted class hues. */
:root {
  color-scheme: only light;
  --ink: #272727;
  --muted: #5f5f66;
  --line: #e2e2e6;
  --soft: #f6f6f8;
  /* Method colours shared with the project page: Entropy Minimization in the
     paper figure's orange, DSBR in the site's purple. Marks are highlighter tints. */
  --em: #e68c3b;
  --em-tint: #fff1dc;
  --em-ink: #9a4a00;
  --em-mark: #ffdcb0;
  --ds: #6d3f9c;
  --ds-tint: #f1e9f8;
  --ds-mark: #e6d5f5;
  --accent: #6d3f9c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: #fff; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #fff; color: var(--ink); font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
::selection { background: var(--ds-tint); }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ds); outline-offset: 2px; border-radius: 3px; }
.wrap { width: min(1160px, 100%); margin-inline: auto; padding-inline: 32px; }
.num { font-variant-numeric: tabular-nums; }

.masthead { position: relative; padding-top: 24px; text-align: center; }
.back { position: absolute; top: 24px; left: 32px; font-size: 0.95rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.venue { width: fit-content; margin: 0 auto 14px; padding: 6px 16px; border-radius: 6px; background: #fff1dc; color: #9a4a00; font-size: 0.95rem; }
.paper-title { max-width: 30em; margin: 0 auto 10px; font-size: clamp(1.3rem, 2.6vw, 1.8rem); font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
.authors { margin: 0; font-size: 1.02rem; }
.contrib { margin: 2px 0 0; font-size: 0.875rem; font-weight: 500; }
h1 { margin: 36px 0 10px; padding-top: 28px; border-top: 1px solid var(--line); font-size: clamp(1.45rem, 2.8vw, 2rem); line-height: 1.3; letter-spacing: -0.015em; text-wrap: balance; }
.lede { margin: 0 0 22px; color: #3d3d44; font-size: 1.05rem; }
.live { display: flex; align-items: center; gap: 8px; margin: 8px 2px 0; color: var(--muted); font-size: 0.8rem; }
.truth { margin: 2px 2px 0; color: var(--muted); font-size: 0.8rem; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: #9a9aa2; }
.live.on .dot { background: #2e9e44; animation: live 1.6s ease-in-out infinite; }
@keyframes live { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Console */
.console { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.transport { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; }
.play { display: grid; place-items: center; flex: none; width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%; background: var(--ds); color: #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); transition: transform .12s, background .12s; }
.play:hover { background: #573080; }
.play:active { transform: scale(0.96); }
.play svg, .restart svg { fill: currentColor; }
.restart { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); cursor: pointer; }
.restart:hover { border-color: var(--ds); color: var(--ds); }
.progress { display: grid; flex: 1 1 auto; gap: 6px; min-width: 140px; color: var(--muted); font-size: 0.85rem; }
.progress output { color: var(--ink); font-weight: 650; }
.track { height: 6px; border-radius: 3px; background: #e4e4ea; overflow: hidden; }
.track i { display: block; width: 0; height: 100%; background: var(--ds); }
.settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 22px; }
.field { display: grid; gap: 4px; color: var(--muted); font-size: 0.82rem; }
.field output { color: var(--ink); font-weight: 650; }
.slider input { width: 170px; height: 26px; margin: 0; accent-color: var(--ds); cursor: pointer; }
.seg { display: flex; gap: 2px; width: fit-content; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.seg button { min-width: 38px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked=true] { background: var(--ds-tint); color: var(--ds); font-weight: 650; }

/* Panels */
.panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; }
.panel { min-width: 0; padding: 16px 18px 14px; border: 1px solid var(--line); border-radius: 10px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.panel h2 { margin: 0; font-size: 1.15rem; line-height: 1.35; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 3px; vertical-align: -1px; }
.swatch.em { background: var(--em); }
.swatch.ds { background: var(--ds); }
.panel[data-method="EM"] h2 { color: var(--em-ink); }
.panel[data-method="DSBR"] h2 { color: var(--ds); }
mark { padding: 0.05em 0.25em; border-radius: 3px; color: var(--ink); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.em { background: var(--em-mark); }
mark.ds { background: var(--ds-mark); }
.cite { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.status { margin: 0; padding: 4px 11px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.status.collapsed { background: var(--em-tint); color: var(--em-ink); }
.status.balanced { background: var(--ds-tint); color: var(--ds); }
.axis-title { margin: 6px 0 4px; font-size: 0.85rem; font-weight: 600; }
.axis-title span { color: var(--muted); font-weight: 400; }
.stream-wrap { position: relative; }
.stream { display: block; width: 100%; height: 220px; touch-action: pan-y; }
.weights { display: block; width: 100%; height: 160px; overflow: visible; shape-rendering: geometricPrecision; }
.weights text { font-family: Helvetica, Arial, sans-serif; font-size: 12px; font-variant-numeric: tabular-nums; }
.weights .tick { fill: #4a4a52; }
.weights .val { fill: var(--ink); font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.readout { min-height: 1.5em; margin: 4px 0 6px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.caption { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }
.insight { min-height: 1.6em; margin: 18px 0 0; font-size: 1.02rem; }
.insight b { font-weight: 650; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }
footer { padding-block: 32px 40px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 860px) {
  .wrap { padding-inline: 16px; }
  .back { position: static; display: inline-block; margin-bottom: 14px; }
  .masthead { text-align: left; }
  .venue, .paper-title { margin-left: 0; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .slider input { width: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .play { transition: none; }
  .live.on .dot { animation: none; }
}
