:root {
  --bg: #f6f6f9;
  --panel: #ffffff;
  --text: #1b1b22;
  --muted: #6b6b78;
  --line: #e3e3ea;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --danger: #c43d3d;
  --ok: #2f9e5a;
  --warn: #c98a12;
  --paid: #fff4d6;
  --twitch: #9146ff;
  --youtube: #e62117;
  --tiktok: #111111;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111116;
    --panel: #1b1b22;
    --text: #ececf1;
    --muted: #9a9aa8;
    --line: #2c2c36;
    --accent: #7c7cf0;
    --paid: #3a3020;
    --tiktok: #e8e8e8;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: .9rem; flex: 1; }
.top nav a { color: var(--muted); }
.top nav a.on { color: var(--text); font-weight: 600; }
.who { color: var(--muted); font-size: .9rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem;
}
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

input, select, button, textarea { font: inherit; color: inherit; }
input, select {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
button {
  padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--muted); padding: .2rem; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .7rem; }
.field input, .field select { width: 100%; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }

.login { max-width: 360px; margin: 12vh auto 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.card { display: block; color: var(--text); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.card .name { font-weight: 600; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .4rem .7rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }

.group-layout { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .group-layout { grid-template-columns: 1fr; } }

.source { padding: .6rem 0; border-top: 1px solid var(--line); }
.source:first-of-type { border-top: 0; }
.source .head { display: flex; align-items: center; gap: .45rem; }
.source .handle { font-weight: 600; overflow-wrap: anywhere; flex: 1; }
.source .meta { font-size: .85rem; color: var(--muted); margin: .15rem 0 .35rem 1.1rem; }
.source .actions { margin-left: 1.1rem; }
.source .actions button { font-size: .85rem; padding: .25rem .55rem; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot.connected { background: var(--ok); }
.dot.connecting, .dot.reconnecting, .dot.checking { background: var(--warn); }
.dot.failing { background: var(--danger); }
.dot.offline, .dot.idle { background: var(--line); border: 1px solid var(--muted); }
.plat { font-size: .7rem; font-weight: 700; letter-spacing: .03em; padding: .05rem .35rem; border-radius: 4px; color: #fff; }
.plat.twitch { background: var(--twitch); }
.plat.youtube { background: var(--youtube); }
.plat.tiktok { background: var(--tiktok); color: var(--panel); }

.feed-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.feed {
  height: 70vh; overflow-y: auto; overflow-x: hidden; padding: .2rem .2rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
@media (max-width: 820px) { .feed { height: 60vh; } }
.msg { padding: .25rem .5rem; border-radius: 6px; overflow-wrap: anywhere; }
.msg + .msg { margin-top: 1px; }
.msg .t { color: var(--muted); font-size: .75rem; margin-right: .35rem; font-variant-numeric: tabular-nums; }
.msg .p { margin-right: .3rem; vertical-align: 1px; }
.msg .a { font-weight: 600; margin-right: .3rem; }
.msg .badge { height: 1em; vertical-align: -2px; margin-right: 2px; }
.msg img.emote { height: 1.5em; vertical-align: middle; }
.msg.paid { background: var(--paid); }
.msg.paid .amt { font-weight: 700; margin-right: .3rem; }
.msg.event { color: var(--muted); font-style: italic; }
.msg.deleted { opacity: .45; text-decoration: line-through; }
.feed .note { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .4rem; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; border-top: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { font-size: .85rem; padding: .2rem .5rem; }
.table-wrap { overflow-x: auto; }
.pill { font-size: .75rem; padding: .05rem .4rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .55rem .9rem; border-radius: 8px; max-width: calc(100% - 32px);
}

a.button {
  display: inline-block; padding: .2rem .5rem; font-size: .85rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
a.button:hover { text-decoration: none; border-color: var(--muted); }

@media (max-width: 560px) {
  .top { gap: .6rem; }
  .top nav { gap: .6rem; }
  .who { display: none; }
}
