:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --online: #16a34a;
  --offline: #dc2626;
  --user-bg: #eef2ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e6e8eb;
    --muted: #8b929c;
    --line: #2a2e36;
    --accent: #3b82f6;
    --online: #22c55e;
    --offline: #ef4444;
    --user-bg: #232a3a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; }

header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 20px; margin-bottom: 16px;
}
.title { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
h1 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--online); box-shadow: 0 0 0 4px color-mix(in srgb, var(--online) 20%, transparent); }
.dot.off { background: var(--offline); }
.count { margin: 0; color: var(--muted); }
.count strong { color: var(--text); font-size: 18px; }
.join {
  background: var(--accent); color: var(--accent-text); text-decoration: none;
  padding: 7px 14px; border-radius: 8px; font-weight: 600;
}
.join:hover { filter: brightness(1.1); }

.help {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; margin: -4px 0 16px; font-size: 14px;
}
.help[hidden] { display: none; }
.help p { margin: 0 0 8px; }
.help-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 6px; }
.help code {
  background: var(--user-bg); padding: 3px 8px; border-radius: 6px;
  font: 600 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all;
}
.help button {
  font: inherit; font-size: 13px; color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; cursor: pointer;
}
.help button.link { border: 0; color: var(--accent); padding: 3px 0; }
.help .dl { color: var(--accent); font-weight: 600; text-decoration: none; }
.help .dl:hover, .help button.link:hover { text-decoration: underline; }

.tree {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px;
}
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 18px; border-left: 1px solid var(--line); margin-left: 9px; }
.ch { padding: 4px 8px; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.ch::before { content: "#"; color: var(--muted); font-weight: 600; }
.ch.empty { color: var(--muted); }
.ch.full { font-weight: 600; }
.tree ul.flat { padding-left: 0; border-left: 0; margin-left: 0; }
.tree ul.users { padding: 2px 0 4px 26px; border: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.users li {
  background: var(--user-bg); border-radius: 999px; padding: 2px 10px 2px 8px;
  display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere;
}
.users li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--online); flex: none; }
.users li.away { opacity: .7; }
.users li.away::before { background: var(--muted); }
.users .ico {
  width: 14px; height: 14px; flex: none; color: var(--muted);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.users .amsg {
  color: var(--muted); font-style: italic; font-size: 13px;
  max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.users .since { color: var(--muted); font-size: 12px; white-space: nowrap; }
.spacer { padding: 10px 8px 4px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.spacer.c { text-align: center; }
.spacer.r { text-align: right; }
.spacer.line { padding: 8px; }
.spacer.line::after { content: ""; display: block; border-top: 1px solid var(--line); }
.hide-empty .is-empty { display: none; }

.activity {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 16px 12px; margin-top: 20px;
}
.act-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.act-head h2 { margin: 0; font-size: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 13px; color: var(--muted); background: transparent;
  border: 0; padding: 4px 12px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--user-bg); color: var(--text); font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 14px 0 8px; }
.stat { display: flex; flex-direction: column; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat .sub { color: var(--muted); font-size: 12px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; outline: none; }
.chart svg:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 6px; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .baseline, .chart .tickmark { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hdot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 10px; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.tip[hidden] { display: none; }
.tip strong { font-size: 14px; }
.tip span { color: var(--muted); }
.note { font-size: 12px; margin: 6px 0 0; }
.table-view { margin-top: 8px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--accent); }
.table-view table { border-collapse: collapse; margin-top: 8px; width: 100%; max-width: 360px; }
.table-view th, .table-view td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--line); }
.table-view th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table-view td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-view th:last-child { text-align: right; }

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding: 0 4px; font-size: 13px;
}
footer label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--offline); padding: 8px; margin: 0; }
