:root {
  --bg: #0f0f12;
  --surface: #18181d;
  --surface-2: #222229;
  --border: #2c2c35;
  --text: #f1f1f4;
  --muted: #9a9aa6;
  --accent: #ff2d55;
  --accent-soft: rgba(255, 45, 85, 0.14);
  --ok: #2ecc71;
  --warn: #f5a623;
  --gold: #ffcc33;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.topbar .spacer { flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; margin-left: 16px; }
.topbar nav a:hover { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: #444452; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.icon { width: 38px; padding: 0; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.input, select.input {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); }

/* ── live layout ── */
.live-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px;
  padding: 20px; height: calc(100vh - 56px);
}
.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow: auto; }

.player {
  position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; width: 100%; max-height: calc(100vh - 220px);
}
.player video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; text-align: center; padding: 20px;
  background: radial-gradient(circle at center, #1b1b22, #050507); color: var(--muted); font-size: 15px;
}
.overlay strong { color: var(--text); font-size: 18px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid #333; border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 2; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 6px;
  background: rgba(0, 0, 0, .6); font-weight: 600; font-size: 13px; backdrop-filter: blur(6px);
}
.badge.live { background: var(--accent); letter-spacing: .06em; }
.badge svg { width: 14px; height: 14px; }

.player-controls {
  position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; z-index: 2;
}
.player-controls .input { background: rgba(0, 0, 0, .65); height: 34px; border-color: transparent; }
.unmute {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; background: rgba(0, 0, 0, .7);
  border: 0; height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.notice {
  position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(0, 0, 0, .65);
  padding: 4px 10px; border-radius: 6px; font-size: 12px; color: var(--muted);
}

.hearts { position: absolute; right: 24px; bottom: 56px; width: 60px; height: 70%; pointer-events: none; z-index: 3; }
.heart-float {
  position: absolute; bottom: 0; left: 50%; font-size: 24px; color: var(--accent);
  animation: floatUp 2.4s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  15% { opacity: 1; transform: translate(-50%, -20px) scale(1); }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -320px) scale(1.1); opacity: 0; }
}

.stream-info h1 { margin: 0 0 4px; font-size: 20px; }
.stream-info .by { color: var(--muted); }

/* ── chat ── */
.chat {
  display: flex; flex-direction: column; min-height: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.chat-head .meta { color: var(--muted); font-weight: 400; font-size: 12px; }
.chat-pinned {
  margin: 10px 10px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2);
  border-left: 3px solid var(--gold); font-size: 13px; display: flex; gap: 8px; align-items: flex-start;
}
.chat-pinned .label { color: var(--gold); font-weight: 600; white-space: nowrap; }
.chat-pinned .unpin { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 6px; min-height: 0; }
.msg {
  position: relative; padding: 4px 8px; border-radius: 6px; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg:hover { background: var(--surface-2); }
.msg .name { font-weight: 600; color: var(--muted); margin-right: 6px; }
.msg.role-publisher .name { color: #fff; background: var(--accent); padding: 0 6px; border-radius: 4px; }
.msg.role-moderator .name { color: #6aa8ff; }
.msg.mine .name { color: var(--ok); }
.msg.pending { opacity: .65; }
.msg.paid { background: linear-gradient(90deg, rgba(255, 204, 51, .18), transparent); border-left: 3px solid var(--gold); margin: 4px 0; }
.msg.paid .amount { display: block; color: var(--gold); font-weight: 700; font-size: 12px; }
.msg.system { color: var(--muted); font-style: italic; }
.msg .actions { position: absolute; right: 4px; top: 2px; display: none; gap: 2px; }
.msg:hover .actions { display: flex; }
.msg .actions button {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; font-size: 11px;
  padding: 1px 6px; cursor: pointer; color: var(--muted);
}
.msg .actions button:hover { color: var(--text); }
.chat-new {
  align-self: center; margin: -40px 0 8px; position: relative; z-index: 2; font-size: 12px; height: 28px;
}
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form .input { flex: 1; }
.chat-note { padding: 0 12px 10px; color: var(--muted); font-size: 12px; min-height: 16px; }
.chat-note.error { color: var(--warn); }

/* ── pages ── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }
.hero h1 { font-size: 32px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 0 28px; max-width: 640px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stream-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px;
  text-decoration: none; border: 1px solid transparent;
}
.stream-row:hover { background: var(--surface-2); border-color: var(--border); }
.stream-row .t { font-weight: 600; }
.stream-row .s { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 8px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--ok); }

.studio-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.status-dot.live { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-dot.connecting { background: var(--warn); }

@media (max-width: 900px) {
  .live-layout { grid-template-columns: 1fr; height: auto; padding: 0 0 16px; gap: 0; }
  .player { border-radius: 0; max-height: none; }
  .stage { overflow: visible; }
  .stream-info, .studio-panel { padding: 12px 16px; }
  .chat { height: 60vh; margin: 12px 16px 0; }
  .topbar { padding: 0 16px; }
}
