:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1f242d;
  --border: #2a303b;
  --text: #e6e9ef;
  --muted: #8b93a1;
  --accent: #5b8cff;
  --live: #ff4d4f;
  --system: #f0b429;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
}
.dot.live { background: var(--live); box-shadow: 0 0 0 4px rgba(255,77,79,.2); }

.meta { display: flex; align-items: center; gap: 16px; }
.viewers { color: var(--muted); font-size: 14px; }

.badge {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  padding: 4px 8px; border-radius: 6px;
}
.badge.offline { background: var(--panel-2); color: var(--muted); }
.badge.live { background: var(--live); color: #fff; }

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.video-wrap {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
}
#video { width: 100%; height: 100%; display: block; background: #000; }
#player { width: 100%; height: 100%; border: 0; display: none; }
#player.on { display: block; }

.offline-card {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at center, #12161d, #0a0d12);
  text-align: center;
}
.offline-card.hidden { display: none; }
.offline-inner p { margin: 8px 0 4px; font-size: 18px; }
.offline-inner small { color: var(--muted); }
.pulse {
  width: 40px; height: 40px; margin: 0 auto 12px;
  border-radius: 50%; background: var(--muted);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .3; transform: scale(.9); }
  50% { opacity: .7; transform: scale(1.05); }
}

.summary { color: var(--muted); margin: 12px 4px; }

.social { display: flex; gap: 14px; margin: 14px 4px 0; align-items: center; }
.social a {
  color: var(--muted); display: inline-flex;
  transition: color .15s ease, transform .15s ease;
}
.social a:hover { color: var(--accent); transform: translateY(-1px); }

.credit { margin: 8px 4px 0; font-size: 12px; color: var(--muted); }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

.chat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 400px;
}
.chat-header {
  padding: 12px 16px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.messages {
  list-style: none; margin: 0; padding: 12px 16px;
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
.messages li { font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.messages .who { font-weight: 600; color: var(--accent); margin-right: 6px; }
.messages li.system { color: var(--system); font-style: italic; }

.chat-form { padding: 12px; border-top: 1px solid var(--border); }
.name-input {
  width: 100%; margin-bottom: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 10px;
}
.send-row { display: flex; gap: 8px; }
.msg-input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
}
button {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
input:focus { outline: none; border-color: var(--accent); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .chat { height: 60vh; }
}

/* Admin page */
.admin {
  max-width: 560px; margin: 40px auto; padding: 0 20px;
}
.admin h1 { font-size: 22px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; margin-top: 16px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px; font: inherit;
}
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }
.help { margin: 0; padding-left: 18px; color: var(--text); font-size: 14px; line-height: 1.6; }
.help li { margin-bottom: 6px; }
.help b { color: var(--text); }
.note { color: var(--system); font-size: 13px; margin-top: 8px; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }
