:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaef;
  --muted: #8b92a5;
  --twitch: #9146ff;
  --youtube: #ff0000;
  --accent: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --font: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 280px 1fr;
  align-items: start;
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
}

header.brand {
  grid-column: 1 / -1;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

header.brand h1 { margin: 0; font-size: 1.35rem; }
header.brand p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; }

.sidebar { display: flex; flex-direction: column; gap: 0.75rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel h2 .dot { width: 8px; height: 8px; border-radius: 50%; }
.panel.twitch h2 .dot { background: var(--twitch); }
.panel.youtube h2 .dot { background: var(--youtube); }

label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.25rem; }

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
}

input:focus { outline: none; border-color: var(--accent); }

.btn-row { display: flex; gap: 0.5rem; }

button {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-connect { background: var(--accent); color: #fff; }
.btn-disconnect { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-small { flex: none; padding: 0.3rem 0.65rem; font-size: 0.72rem; }

.status { font-size: 0.75rem; margin-top: 0.5rem; color: var(--muted); }
.status.connected { color: var(--success); }
.status.error { color: var(--danger); }

.feed-wrap { display: flex; flex-direction: column; width: 100%; }

.feed-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.unified-feed {
  min-height: min(480px, calc(100vh - 11rem));
  max-height: calc(100vh - 11rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem;
}

.msg {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.msg:hover { background: rgba(255, 255, 255, 0.03); }

.msg .badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}

.msg.twitch .badge { background: rgba(145, 70, 255, 0.25); color: #c9a3ff; }
.msg.youtube .badge { background: rgba(255, 0, 0, 0.2); color: #ff8a8a; }

.msg .author { font-weight: 600; }
.msg .text { word-break: break-word; }
.msg .meta { font-size: 0.7rem; color: var(--muted); margin-left: auto; }

.feed-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  font-size: 0.85rem;
}

.hint { font-size: 0.7rem; color: var(--muted); margin: -0.35rem 0 0.5rem; }
.hint a { color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  flex: none;
  width: auto;
  margin-bottom: 0.5rem;
}

.app.obs-mode { max-width: none; padding: 0; grid-template-columns: 1fr; }
.app.obs-mode .sidebar,
.app.obs-mode header.brand,
.app.obs-mode .feed-toolbar { display: none; }
.app.obs-mode .unified-feed {
  min-height: 100vh;
  max-height: 100vh;
  border: none;
  border-radius: 0;
}
