/* IARI Live: the site's black sheet (index.html #demo) as a full-screen app. */
:root {
  --dark: #0d0d0c; --dark2: #181816; --dark3: #22221f; --dark-line: #2a2a27;
  --on-dark: #f4f4f1; --on-dark-muted: #a6a6a0;
  --accent: #ff4a1a; --accent-ink: #d93c0e; --wait: #ffb224;
  --display: "Outfit", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: var(--dark); color: var(--on-dark); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }

/* the bar */
.bar { display: flex; align-items: center; gap: 8px; min-width: 0; padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 12px) 8px calc(env(safe-area-inset-left) + 12px); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--on-dark); text-decoration: none; font-family: var(--display); font-size: 1.05rem; white-space: nowrap; }
.brand img { height: 30px; width: auto; background: #fff; border-radius: 8px; padding: 3px 4px; }
.brand b { font-weight: 500; color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid var(--dark-line); border-radius: 999px; font-size: 12px; color: var(--on-dark-muted); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--on-dark-muted); }
.chip.live i { background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blink 1.6s infinite; }
.chip.live { color: var(--on-dark); }
.chip.demo i { background: var(--on-dark); }
.chip.wait i { background: var(--wait); animation: blink .8s infinite; }
.chip.bad i { background: var(--accent-ink); }
@keyframes blink { 50% { opacity: .35; } }
.tools { margin-left: auto; display: flex; gap: 6px; }
.tb { height: 34px; min-width: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--dark-line); background: var(--dark2); cursor: pointer; font-size: 13px; display: inline-grid; place-items: center; }
.tb.icon { padding: 0; }
.tb.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tb[hidden] { display: none; }

/* the picture */
.stage { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 62dvh; background: #000; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fatal { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--on-dark-muted); }

/* the panel */
.panel { container-type: inline-size; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 12px); display: grid; gap: 10px; align-content: start; }
.k { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--on-dark-muted); display: flex; align-items: center; gap: 10px; }
.verdict { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; background: var(--dark2); border: 1px solid var(--dark-line); border-radius: 18px; padding: 14px 16px; }
.cls { font-family: var(--display); font-size: clamp(1.3rem, 9cqi, 2.2rem); overflow-wrap: anywhere; font-weight: 500; letter-spacing: .02em; line-height: 1.15; margin-top: 4px; }
.pbar { height: 4px; background: var(--dark3); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.lvl { text-align: right; }
.lvl .num { font-family: var(--display); font-size: clamp(1.15rem, 7cqi, 1.6rem); white-space: nowrap; font-variant-numeric: tabular-nums; margin-top: 4px; }
.lvl .sub { font-size: 12px; color: var(--on-dark-muted); white-space: nowrap; }
.lvl .sub.on { color: var(--accent); }
.card { position: relative; background: var(--dark2); border: 1px solid var(--dark-line); border-radius: 18px; padding: 12px 10px 6px 12px; }
.chart { height: 130px; margin-top: 6px; }
.card.nodata::after { content: attr(data-empty); position: absolute; inset: 34px 12px 8px; display: grid; place-items: center; text-align: center; font-size: 13px; color: var(--on-dark-muted); background: rgba(24, 24, 22, .7); border-radius: 12px; pointer-events: none; }
.leg { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; letter-spacing: .06em; text-transform: none; }
.leg i { display: inline-block; width: 14px; height: 2px; background: var(--accent); }
.leg i.m { background: var(--on-dark-muted); margin-left: 8px; }
.events { list-style: none; padding: 6px 0 6px; font-size: 14px; }
.events li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 5px 2px; border-bottom: 1px solid var(--dark-line); }
.events li:last-child { border-bottom: 0; }
.events time { font-family: var(--mono); font-size: 12px; color: var(--on-dark-muted); padding-top: 2px; }
.events b { font-family: var(--display); font-weight: 500; letter-spacing: .04em; }
.events span { color: var(--on-dark-muted); font-variant-numeric: tabular-nums; }
.stats { font-family: var(--mono); font-size: 11px; color: var(--on-dark-muted); line-height: 1.6; padding: 0 4px; }
.legal { font-size: 12px; color: var(--on-dark-muted); text-align: center; padding: 8px 0 4px; }
.legal a { color: var(--on-dark-muted); }

/* uPlot on the dark sheet */
.uplot, .u-wrap { font-family: var(--body); }

/* double tap: the picture alone */
body.immersive .panel, body.immersive .bar { display: none; }
body.immersive .app { grid-template-rows: minmax(0, 1fr); }
body.immersive .stage { aspect-ratio: auto; max-height: none; height: 100%; }

/* landscape: the picture left, the panel right */
@media (orientation: landscape) and (min-aspect-ratio: 5 / 4) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(280px, 32vw); grid-template-rows: auto minmax(0, 1fr); }
  .bar { grid-column: 1 / -1; }
  .stage { aspect-ratio: auto; max-height: none; height: 100%; }
  .panel { grid-column: 2; grid-row: 2; }
  body.immersive .app { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .brand span { display: none; } .tb { padding: 0 10px; } }
@media (max-width: 340px) { #btnFull { display: none; } }

/* the connect sheet */
dialog { margin: auto auto 0; width: 100%; max-width: 560px; border: 0; background: transparent; color: var(--on-dark); }
@media (min-width: 600px) { dialog { margin: auto; } }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
.sheet { position: relative; background: var(--dark2); border: 1px solid var(--dark-line); border-radius: 22px 22px 0 0; padding: 22px 18px calc(env(safe-area-inset-bottom) + 20px); display: grid; gap: 10px; }
@media (min-width: 600px) { .sheet { border-radius: 22px; } }
.sheet h2 { font-family: var(--display); font-weight: 500; font-size: 1.4rem; }
.sheet .muted { color: var(--on-dark-muted); font-size: .95rem; line-height: 1.5; }
.sheet label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--on-dark-muted); margin-top: 6px; }
.sheet input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--dark-line); background: var(--dark); color: var(--on-dark); font: inherit; font-size: 16px; }
.sheet input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { flex: 1; min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--dark-line); background: var(--dark3); cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.err { color: #ffd2c4; background: rgba(255, 74, 26, .12); border: 1px solid rgba(255, 74, 26, .35); padding: 10px 12px; border-radius: 12px; font-size: .92rem; line-height: 1.45; }
.note { color: var(--on-dark-muted); font-size: .9rem; line-height: 1.45; }
.sheet details { margin-top: 4px; font-size: .92rem; color: var(--on-dark-muted); line-height: 1.5; }
.sheet summary { cursor: pointer; color: var(--on-dark); padding: 6px 0; }
.sheet ul { padding-left: 18px; display: grid; gap: 6px; }
.sheet b { color: var(--on-dark); font-weight: 600; }
.sheet code { font-family: var(--mono); font-size: .9em; color: var(--on-dark); }
.close { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--dark3); cursor: pointer; font-size: 20px; line-height: 1; }
