:root {
  --bg: #0c0c10;
  --panel: #15151d;
  --panel-2: #1c1c27;
  --line: #2c2c3a;
  --text: #f2f2f7;
  --muted: #9a9aab;
  --accent: #9146ff;
  --accent-2: #772ce8;
  --ok: #3dd68c;
  --warn: #f5c542;
  --err: #ff5d73;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: #c5a6ff; }
code { color: #d7c4ff; word-break: break-all; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(12,12,16,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; gap: 8px; align-items: center; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.user-chip { color: var(--muted); font-size: .9rem; }

.pill, .status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: .75rem;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.account-b { background: #2a1848; color: #d9c4ff; border-color: #4a2d7a; }
.status.ok { color: var(--ok); border-color: #1f5c40; }
.status.error { color: var(--err); border-color: #6b2432; }
.status.connecting { color: var(--warn); }

.layout {
  max-width: 1100px; margin: 0 auto; padding: 16px;
  display: grid; gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.section-head, .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
h1, h2 { margin: 0 0 12px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { color: var(--err); }

.favorites { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.favorites button.on { outline: 2px solid #3dd68c; outline-offset: 1px; }
.favorites button.focus { box-shadow: 0 0 0 3px rgba(145,70,255,.45); }
.now-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.now-card { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--panel-2); border-radius: 12px; cursor: pointer; border: 1px solid transparent; text-align: left; color: inherit; width: 100%; }
.now-card.focus { border-color: var(--accent); }
.chan { display: inline-block; min-width: 4.5rem; margin-right: 6px; color: #c5a6ff; font-size: .75rem; text-transform: uppercase; }
.favorites button, .card, .open-form button, .chat-form button, .login-card button, .button, button {
  border: 0; border-radius: 12px; cursor: pointer;
}
.favorites button, .open-form button, .chat-form button, .login-card button, .button, button:not(.ghost) {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white; font-weight: 650; padding: 12px 16px;
}
button.ghost, .ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); padding: 8px 12px; border-radius: 12px;
}
a.button { display: inline-flex; align-items: center; text-decoration: none; }

.open-form, .chat-form { display: flex; gap: 8px; }
input, .open-form input, .chat-form input {
  flex: 1; min-width: 0;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 1rem;
}
.stack { display: grid; gap: 10px; margin-top: 12px; }
.stack label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--text); }

.now { margin-top: 16px; padding: 12px; background: var(--panel-2); border-radius: 12px; }
.now-head { display: flex; gap: 12px; align-items: center; }
.now-head img { width: 48px; height: 48px; border-radius: 12px; }
.live { color: var(--err); font-weight: 700; letter-spacing: .04em; }
.viewers { color: var(--muted); }

.cards {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  text-align: left; background: var(--panel-2); color: var(--text);
  overflow: hidden; padding: 0; border: 1px solid var(--line);
}
.card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.card .meta { padding: 10px 12px; }
.card .meta strong { display: block; }
.card .meta span { color: var(--muted); font-size: .85rem; }

.chat-log, .event-log {
  height: 320px; overflow: auto; background: #101018;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
  font-size: .95rem; line-height: 1.4;
}
.chat-line { margin: 0 0 6px; }
.chat-line .name { font-weight: 700; margin-right: 6px; }
.chat-line.system { color: var(--muted); font-style: italic; }
.event-log div { color: var(--muted); margin-bottom: 8px; }

.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 400px at 50% -10%, #3b1d73, transparent), var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px; display: grid; gap: 10px;
}
.login-card h1 { font-size: 1.8rem; margin: 0; }
.eyebrow { letter-spacing: .14em; text-transform: uppercase; color: #c5a6ff; margin: 0; font-size: .75rem; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .open-form, .chat-form, .row { flex-direction: column; }
  .chat-log, .event-log { height: 240px; }
}
