:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #667085; --line: #e3e6eb; --accent: #2f6fed;
  --angry: #e5484d; --disgust: #46a758; --fearful: #8e4ec6; --happy: #f5b700; --neutral: #9aa3af;
  --sad: #3e82d6; --surprised: #f76808;
  --working: #2f9e6b; --entertaining: #c05fd6; --other: #a8afb9; --idle: #7d848e; --unknown: #7d848e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --text: #e7eaee; --muted: #98a2b3; --line: #2a303a; --accent: #6d9bff; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: color-mix(in srgb, var(--line) 60%, transparent); padding: .1em .35em; border-radius: 4px; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.banner { background: color-mix(in srgb, var(--happy) 22%, var(--card)); border-bottom: 1px solid var(--line);
  padding: 8px 24px; font-size: 13.5px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
h1 { font-size: 26px; margin: 4px 0 4px; }
h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h2.section { margin-top: 28px; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 80ch; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.sidebar { grid-template-columns: 260px minmax(0, 1fr); }
.stack > .card:last-child { margin-bottom: 16px; }
@media (max-width: 860px) { .grid.two, .grid.sidebar { grid-template-columns: minmax(0, 1fr); } main { padding: 16px; } }
.frame-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
.frame-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.frame-off { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd2da; padding: 20px; text-align: center; }
.big { font-size: 22px; margin-bottom: 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 2px 12px; border-radius: 999px; font-weight: 700; color: #fff;
  background: var(--neutral); text-transform: capitalize; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.tag.on { color: var(--working); border-color: var(--working); }
.bars { display: grid; grid-template-columns: 84px 1fr 44px; gap: 5px 8px; align-items: center; font-size: 13px; }
.bars .track { height: 10px; background: color-mix(in srgb, var(--line) 70%, transparent); border-radius: 5px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 5px; width: 0; transition: width .25s ease; }
.bars .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chart { position: relative; width: 100%; } .h140 { height: 140px; } .h180 { height: 180px; } .h220 { height: 220px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-bottom: 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tiles.compact .tile { background: transparent; padding: 8px 10px; }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .v.cap { text-transform: capitalize; }
.tile .s { font-size: 12.5px; color: var(--muted); }
.notes { list-style: none; padding: 0; margin: 0 0 16px; }
.notes li { padding: 8px 12px; border-left: 4px solid var(--line); margin-bottom: 8px; background: color-mix(in srgb, var(--line) 25%, transparent); border-radius: 0 8px 8px 0; }
.notes li.attention { border-color: var(--surprised); } .notes li.positive { border-color: var(--working); } .notes li.info { border-color: var(--sad); }
.toolbar { display: flex; gap: 6px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
button, input[type=date] { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 12px; cursor: pointer; }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.heat { text-align: center; font-variant-numeric: tabular-nums; border-radius: 4px; }
table.dense th, table.dense td { padding: 6px 5px; }
table.dense th { letter-spacing: 0; }
.list { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.list li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
.list li button.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
pre { background: color-mix(in srgb, var(--line) 35%, transparent); padding: 14px; border-radius: 8px; overflow-x: auto; margin: 0; white-space: pre-wrap; word-break: break-word; }
.bubble { max-width: 520px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px; padding: 12px 14px; white-space: pre-wrap; line-height: 1.45; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.clips { display: grid; gap: 16px; }
.clip { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 860px) { .clip { grid-template-columns: minmax(0, 1fr); } }
.clip video { width: 100%; border-radius: 8px; background: #000; display: block; max-height: 520px; }
.clip h3 { margin: 0 0 4px; font-size: 17px; }
.strip { width: 100%; height: 26px; border-radius: 6px; display: block; margin: 8px 0 4px; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.flow { display: flex; align-items: stretch; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.flow div { flex: 1 1 150px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.flow b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.flow span { font-size: 13.5px; }
.flow i { align-self: center; color: var(--muted); font-style: normal; }
.rules b { text-transform: capitalize; }
.rules p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
footer { max-width: 1180px; margin: 10px auto 30px; padding: 0 24px; color: var(--muted); font-size: 12.5px; }
footer p { margin: 2px 0; }
.c-angry { background: var(--angry); } .c-disgust { background: var(--disgust); } .c-fearful { background: var(--fearful); }
.c-happy { background: var(--happy); } .c-neutral { background: var(--neutral); } .c-sad { background: var(--sad); }
.c-surprised { background: var(--surprised); } .c-working { background: var(--working); }
.c-entertaining { background: var(--entertaining); } .c-other { background: var(--other); }
.c-idle, .c-unknown, .c-away { background: var(--idle); }

/* try-it-yourself page */
.frame-wrap video, .frame-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.frame-wrap.mirror video, .frame-wrap.mirror canvas { transform: scaleX(-1); }
ul.plain { margin: 0 0 14px; padding-left: 20px; max-width: 90ch; }
ul.plain li { margin-bottom: 6px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--angry); border-color: var(--angry); }
button:disabled { opacity: .5; cursor: default; }
.error { color: var(--angry); font-size: 13.5px; }
.ok { color: var(--working); }
.toolbar.spaced { margin: 12px 0 6px; }
.toolbar.tight { margin: 0; gap: 4px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
form input[type=text], form input[type=password] { display: block; width: 100%; margin-top: 3px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
