/* Catppuccin Mocha palette */
:root {
  --base: #1e1e2e; --mantle: #181825; --crust: #11111b;
  --s0: #313244; --s1: #45475a; --s2: #585b70; --ov0: #6c7086; --ov1: #7f849c;
  --sub0: #a6adc8; --sub1: #bac2de; --text: #cdd6f4;
  --red: #f38ba8; --live: #ff3b5c; --peach: #fab387; --yellow: #f9e2af;
  --green: #a6e3a1; --teal: #94e2d5; --sky: #89dceb; --blue: #89b4fa;
  --mauve: #cba6f7; --pink: #f5c2e7; --lav: #b4befe;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --vh: 100dvh;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.45 var(--sans);
  color: var(--text);
  background: var(--base);
  min-height: var(--vh);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
button { font: inherit; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--mantle);
  border-bottom: 1px solid var(--s0);
}
.brand { font-family: var(--mono); font-weight: 500; color: var(--text); text-decoration: none; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--mauve); }
.userbox { display: flex; gap: 8px; flex: 1; max-width: 520px; }
#user {
  flex: 1; min-width: 0; padding: 9px 12px;
  border: 1px solid var(--s1); border-radius: 8px;
  background: var(--crust); color: var(--text); font: 14px var(--mono);
}
#user::placeholder { color: var(--ov0); }
#user:focus { outline: 2px solid var(--mauve); outline-offset: -1px; border-color: var(--mauve); }
.go {
  padding: 9px 16px; border: 0; border-radius: 8px; white-space: nowrap;
  background: var(--mauve); color: var(--crust); font-weight: 600; cursor: pointer;
}
.go:hover { background: var(--lav); }
.sub { font-size: 11px; color: var(--ov1); margin-left: auto; white-space: nowrap; }
.sub.ok { color: var(--green); }
.sub.err { color: var(--red); }

.recents { display: flex; align-items: center; gap: 10px; padding: 8px 20px; border-bottom: 1px solid var(--s0); overflow-x: auto; scrollbar-width: none; }
.recents::-webkit-scrollbar { display: none; }
.recents-head { font-size: 11px; color: var(--ov0); }
.recents ul { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.recent-item {
  padding: 3px 10px; border: 1px solid var(--s1); border-radius: 999px;
  background: transparent; color: var(--sub1); font: 12px var(--mono); cursor: pointer; white-space: nowrap;
}
.recent-item:hover { background: var(--s0); color: var(--text); }
.recents:has(ul:empty) { display: none; }

/* ---------- tools menu (shared with tools pages) ---------- */
.toolnav { display: flex; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--s0); overflow-x: auto; scrollbar-width: none; background: var(--mantle); }
.toolnav::-webkit-scrollbar { display: none; }
.toolnav a { color: var(--sub0); text-decoration: none; font-size: 12px; padding: 5px 10px; border-radius: 6px; white-space: nowrap; }
.toolnav a:hover { background: var(--s0); color: var(--text); }
.toolnav a.on { background: var(--s0); color: var(--mauve); }

/* ---------- stage ---------- */
.stage {
  flex: 1; display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 380px;
  gap: 20px; padding: 20px; align-items: start;
  max-width: 1500px; width: 100%; margin: 0 auto;
}

/* ads (placeholders; swap for AdSense) */
.ads { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.ad-slot {
  display: grid; place-items: center;
  border: 1px dashed var(--s2); border-radius: 8px;
  background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.015) 10px 20px);
  color: var(--ov0); font: 11px var(--mono); overflow: hidden;
}
.ad-tall { width: 160px; height: 600px; }
.ad-box { width: 160px; height: 250px; }
.ad-mobile { display: none; width: 320px; max-width: 100%; height: 100px; margin: 0 auto; }

/* ---------- player column ---------- */
.player-col { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.streamer { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; }
.avatar-wrap { width: 48px; height: 48px; border-radius: 50%; padding: 2px; background: linear-gradient(135deg, var(--live), var(--mauve)); flex: none; }
.avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--s0); display: block; border: 2px solid var(--base); }
.avatar:not([src]), .avatar[src=""] { visibility: hidden; }
.who { min-width: 0; flex: 1; }
.stitle { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handle { font-size: 12px; color: var(--sub0); }
.live-badge {
  background: var(--live); color: #fff; font: 700 11px var(--mono); letter-spacing: .08em;
  padding: 3px 8px; border-radius: 4px; animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .65; } }
.watching { font-size: 12px; color: var(--sub1); white-space: nowrap; }

.video-box {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 9 / 16;
  height: min(calc(var(--vh) - 250px), 780px); min-height: 360px; max-width: 100%;
  border: 1px solid var(--s0);
}
body.larger .video-box { height: min(calc(var(--vh) - 150px), 1100px); }
body.larger .ads { display: none; }
body.larger .stage { grid-template-columns: minmax(0, 1fr) 380px; }
#liveVideo { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-box:fullscreen { height: 100%; width: 100%; aspect-ratio: auto; border-radius: 0; border: 0; }
.video-box:-webkit-full-screen { height: 100%; width: 100%; aspect-ratio: auto; border-radius: 0; border: 0; }
.live-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--sub0); background: rgba(17,17,27,.82); font: 13px var(--mono);
}
.live-overlay b { color: var(--text); }
.live-overlay button { margin-top: 12px; }
.live-overlay.passthrough { pointer-events: none; }
.unmute {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer;
  background: rgba(17,17,27,.85); color: var(--text); font: 12px var(--mono);
}
.player-bar { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 560px; }
.ctl {
  padding: 6px 12px; border: 1px solid var(--s1); border-radius: 6px; cursor: pointer;
  background: var(--s0); color: var(--text); font: 12px var(--mono);
}
.ctl:hover { background: var(--s1); }
.ctl.small { padding: 3px 9px; font-size: 11px; }
body.larger #largerBtn { background: var(--mauve); color: var(--crust); border-color: var(--mauve); }
.pstat { margin-left: auto; font-size: 11px; color: var(--ov1); white-space: nowrap; }

/* ---------- chat ---------- */
.chat-col {
  display: flex; flex-direction: column; background: var(--mantle);
  border: 1px solid var(--s0); border-radius: 12px; overflow: hidden;
  height: min(calc(var(--vh) - 130px), 900px); min-height: 420px;
  position: sticky; top: 20px;
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--s0); }
.chat-title { font-size: 12px; color: var(--sub0); text-transform: lowercase; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title b { color: var(--text); font-weight: 500; text-transform: uppercase; }
.ev-toggle { font-size: 11px; color: var(--ov1); display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.ev-toggle input { accent-color: var(--mauve); margin: 0; }
.chat { flex: 1; overflow-y: auto; padding: 8px 0; overscroll-behavior: contain; }
.chat .empty { color: var(--ov0); font-size: 12px; text-align: center; padding: 30px 12px; }
.msg { padding: 4px 14px; font-size: 13px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .u { color: var(--mauve); font-weight: 600; margin-right: 6px; }
.msg.ev { font: 11.5px var(--mono); color: var(--ov1); }
.msg.ev .u { color: var(--sub0); font-weight: 500; }
.msg.ev.gift { color: var(--peach); }
.msg.ev.follow { color: var(--teal); }
.msg.ev.share { color: var(--green); }
.msg.ev.like { color: var(--pink); }
.msg.sys { font: 11.5px var(--mono); color: var(--yellow); text-align: center; }
.msg.sys.err { color: var(--red); }
body.hide-events .msg.ev { display: none; }
.chat-foot { padding: 9px 14px; border-top: 1px solid var(--s0); font-size: 11px; color: var(--ov1); display: flex; gap: 4px; align-items: center; }
.chat-foot .room { margin-left: auto; color: var(--ov0); }
.st-live { color: var(--green); }
.st-reconnecting, .st-connecting { color: var(--yellow); }
.st-ended, .st-error { color: var(--red); }
.jump {
  position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%);
}

/* ---------- responsive ---------- */
@media (max-width: 1150px) {
  .stage { grid-template-columns: minmax(0, 1fr) 340px; }
  .ads { display: none; }
  .ad-mobile { display: grid; }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .userbox { order: 3; max-width: none; flex-basis: 100%; }
  .recents { padding: 6px 12px; }
  .stage { grid-template-columns: 1fr; padding: 12px; gap: 14px; }
  body.larger .stage { grid-template-columns: 1fr; }
  .video-box { height: auto; width: 100%; max-height: 66vh; min-height: 0; }
  .player-bar { flex-wrap: wrap; }
  .pstat { font-size: 10px; }
  body.larger .video-box { max-height: none; height: auto; }
  .chat-col { position: static; height: 55vh; min-height: 300px; }
}
