:root {
  --red: #dc2626;
  --red-light: #ef4444;
  --red-dark: #b91c1c;
  --gold: #f59e0b;
  --bg: #14171a;
  --surface: #1e2125;
  --surface-2: #24272b;
  --border: #2d3136;
  --input-border: #3a3e43;
  --text: #f0f0f0;
  --text-muted: #8e9297;
  --code-bg: #24272b;
  --panel: #1e2125;
  --panel-2: #24272b;
  --line: #2d3136;
  --ink: #f0f0f0;
  --muted: #8e9297;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.4);
  --font: 'Lato', sans-serif;
}
body[data-theme="light"] {
  --bg: #fafafa; --surface: #ffffff; --surface-2: #f5f5f5;
  --border: #e0e0e0; --input-border: #ccc; --text: #14171a;
  --text-muted: #666; --code-bg: #f0f0f0; --panel: #ffffff;
  --panel-2: #f5f5f5; --line: #e0e0e0; --ink: #14171a; --muted: #666;
  --shadow: 0 1px 3px rgba(0,0,0,0.06); --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
}
body[data-theme="light"] .gold-topup {
  background: rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
}
body[data-theme="light"] .gold-topup .gold-num { color: #1a1a1a; text-shadow: none; }
body[data-theme="light"] .gold-topup-btn { background: #ef4444; }
body[data-theme="light"] .gold-topup-btn:hover { background: #dc2626; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

/* ============ LOGIN GATE ============ */
.gate {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 32px; max-width: 380px; width: 100%; text-align: center;
}
.gate-logo { width: 52px; height: 52px; object-fit: contain; margin-bottom: 14px; filter: drop-shadow(0 2px 6px rgba(220,38,38,0.3)); }
.gate-card h1 { font-size: 24px; margin: 0 0 6px; color: var(--ink); font-weight: 900; letter-spacing: -0.5px; }
.gate-card h1 .accent { color: var(--red); }
.gate-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.gate-card input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--input-border);
  background: var(--panel-2); color: var(--ink); font-size: 14px; margin-bottom: 14px; text-align: center;
}
.gate-card input::placeholder { color: var(--muted); }
.gate-card input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }
.msg { font-size: 13px; padding: 8px; border-radius: var(--radius-sm); margin-bottom: 10px; display: none; }
.msg.error { display: block; background: rgba(220,38,38,0.1); color: var(--red-light); border: 1px solid rgba(220,38,38,0.2); }
.msg.success { display: block; background: rgba(22,163,74,0.1); color: #4ade80; border: 1px solid rgba(22,163,74,0.2); }
.btn-choice {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--red); color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all 0.15s; margin-bottom: 10px; border: 2px solid transparent;
}
.btn-choice:hover { background: var(--red-dark); }
.btn-choice svg { width: 20px; height: 20px; }
.btn-choice-outline { background: transparent; border: 2px solid var(--border); color: var(--ink); }
.btn-choice-outline:hover { border-color: var(--red); color: var(--red); }
.btn-back { width: 100%; padding: 10px; border-radius: var(--radius-md); background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 8px; }
.btn-back:hover { color: var(--ink); }
.btn-primary { width: 100%; padding: 12px; border-radius: var(--radius-md); background: var(--red); color: #fff; font-weight: 700; font-size: 14px; }
.btn-primary:hover { background: var(--red-dark); }

/* ============ TOPBAR ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo { height: 26px; width: auto; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.gold-topup {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; padding: 4px 4px 4px 10px;
  height: 34px;
}
.gold-topup .gold-icon { width: 20px; height: 20px; flex-shrink: 0; }
.gold-topup .gold-num {
  font-size: 13px; font-weight: 700; color: #fff;
  line-height: 1; min-width: 12px; text-align: center;
}
.gold-topup-btn {
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 5px 12px; border-radius: 6px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s; line-height: 1;
}
.gold-topup-btn:hover { background: #dc2626; }
.btn-theme {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.btn-theme:hover { color: var(--ink); background: var(--surface-2); }
.btn-logout-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border);
}
.btn-logout-icon:hover { color: var(--red); border-color: var(--red); background: rgba(220,38,38,0.1); }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============ MAIN BODY ============ */
.main-body {
  display: flex; flex-direction: column; min-height: calc(100vh - 56px);
}
@media (min-width: 980px) {
  .main-body { flex-direction: row; height: calc(100vh - 56px); min-height: auto; }
}

/* ============ VIDEO SECTION ============ */
.video-section {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.video-wrapper {
  position: relative; width: 100%; background: #000;
  aspect-ratio: 16/9; max-height: 56vh;
}
@media (min-width: 980px) {
  .video-wrapper { aspect-ratio: auto; flex: 1; max-height: none; }
}
.player-box { width: 100%; height: 100%; }

/* LIVE overlay top-right */
.live-overlay-topright {
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.6);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700; color: #fff; z-index: 20;
}
.live-dot-sm { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse-dot 1.5s infinite; display: inline-block; }
.live-sep { color: rgba(255,255,255,0.4); }

/* IDN logo overlay — below LIVE badge */
.live-overlay-idn-logo {
  position: absolute; top: 40px; right: 10px;
  z-index: 20; opacity: 0.9;
  pointer-events: none;
}
.live-overlay-idn-logo img {
  display: block;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ============ STREAM INFO BAR ============ */
.stream-info-bar {
  display: flex; flex-direction: column;
  padding: 14px 16px; background: var(--surface); border-top: 1px solid var(--line);
  gap: 10px;
}
/* Row 1: avatar + badge + stats + buttons — all inline */
.stream-info-row1 {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: nowrap;
}
.stream-info-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Avatar + frame — bigger per IDN reference */
.streamer-avatar {
  position: relative; width: 56px; height: 56px; flex-shrink: 0;
}
.avatar-frame {
  position: absolute; top: -7px; left: -7px;
  width: 70px; height: 70px; object-fit: contain; z-index: 2;
  pointer-events: none;
}
.avatar-img {
  position: relative; width: 48px; height: 48px;
  border-radius: 50%; object-fit: cover; border: 2px solid var(--border);
  margin: 4px; z-index: 1;
}

.streamer-meta { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.streamer-badge-img { height: 22px; width: auto; object-fit: contain; }
.streamer-name { font-weight: 900; font-size: 15px; }

/* Following / Followers stats — centered between left and right */
.stream-info-stats {
  display: flex; gap: 24px;
  margin-left: auto; margin-right: auto;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-num { font-weight: 900; font-size: 16px; color: var(--ink); }
.stat-label { font-size: 11px; color: var(--muted); }

/* Actions: Following + Share buttons — inline with stats */
.stream-info-actions {
  display: flex; gap: 8px; align-items: center; margin-left: auto;
}

/* Following button — red outline per IDN */
.btn-following {
  padding: 8px 24px; border-radius: 20px;
  border: 2px solid var(--red); color: var(--red);
  font-size: 13px; font-weight: 700;
  background: transparent; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.btn-following:hover {
  background: var(--red); color: #fff;
}
.btn-following.btn-following-active {
  background: var(--red); color: #fff; border-color: var(--red);
}

/* Share button */
.btn-share {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.btn-share:hover { color: var(--ink); border-color: var(--muted); }

/* Stream switch — full width row below */
.stream-switch-inline {
  display: flex; gap: 8px; justify-content: center;
}
.stream-switch-inline .stream-switch-btn {
  padding: 8px 22px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 700;
  transition: all 0.2s; cursor: pointer; white-space: nowrap;
}
.stream-switch-inline .stream-switch-btn:hover {
  border-color: var(--red-light); color: var(--ink);
}
.stream-switch-inline .stream-switch-btn.active {
  background: var(--red); border-color: var(--red); color: #fff;
}

/* Following button — red outline per IDN */
.btn-following {
  padding: 8px 24px; border-radius: 20px;
  border: 2px solid var(--red); color: var(--red);
  font-size: 13px; font-weight: 700;
  background: transparent; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.btn-following:hover {
  background: var(--red); color: #fff;
}
.btn-following.btn-following-active {
  background: var(--red); color: #fff; border-color: var(--red);
}

/* Share button */
.btn-share {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.btn-share:hover { color: var(--ink); border-color: var(--muted); }

/* ============ CHAT SECTION ============ */
.chat-section {
  width: 100%; border-top: 1px solid var(--line);
  flex-shrink: 0;
}
@media (min-width: 980px) {
  .chat-section {
    width: 360px; flex-shrink: 0;
    border-top: none; border-left: 1px solid var(--line);
    height: calc(100vh - 56px);
  }
}
.chat-panel {
  display: flex; flex-direction: column; height: 420px;
}
@media (min-width: 980px) {
  .chat-panel { height: 100%; }
}
.chat-tabs {
  display: flex; border-bottom: 1px solid var(--line); padding: 0 16px;
}
.chat-tab {
  padding: 12px 16px; font-size: 14px; font-weight: 700;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.chat-tab.active { color: var(--ink); border-bottom-color: var(--red); }
.chat-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-title {
  text-align: center; font-size: 14px; font-weight: 700;
  padding: 10px 16px 0; color: var(--ink);
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-msg {
  font-size: 13px; line-height: 1.5;
  padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2);
}
.chat-msg .sender { font-weight: 700; color: #60a5fa; margin-right: 4px; }
.chat-msg .sender.admin { color: var(--red); font-weight: 800; }
.chat-msg .sender.member { color: #60a5fa; }
.chat-msg .time { font-size: 10px; color: var(--muted); margin-left: 4px; }
.chat-msg .body { color: var(--ink); word-break: break-word; margin-top: 2px; }
.admin-badge {
  display: inline-block; font-size: 9px; font-weight: 800; color: #fff; background: var(--red);
  padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: middle;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }
.chat-input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-input-area input {
  flex: 1; padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--input-border);
  background: var(--panel-2); color: var(--ink); font-size: 13px;
}
.chat-input-area input::placeholder { color: var(--muted); }
.chat-input-area input:focus { outline: none; border-color: var(--red); }
.chat-send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--red); color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat-send-btn:hover { background: var(--red-dark); }
.chat-admin-ctrl { display: flex; gap: 4px; margin-top: 4px; justify-content: flex-end; }
.chat-ctrl-btn {
  padding: 2px 8px; border-radius: 4px; font-size: 11px; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted); cursor: pointer;
}
.chat-ctrl-btn:hover { background: var(--code-bg); color: var(--ink); }

/* ============ FEEDBACK ============ */
.fb-float {
  position: fixed; bottom: 80px; right: 18px; z-index: 90;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(220,38,38,0.4);
}
.fb-float:hover { transform: scale(1.1); }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 210;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-sheet {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; max-width: 400px; width: 100%;
}
.modal-sheet h3 { margin: 0 0 4px; font-weight: 900; }
.modal-sheet p { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.modal-sheet textarea {
  width: 100%; min-height: 100px; padding: 12px; border-radius: var(--radius-md);
  border: 1px solid var(--input-border); background: var(--panel-2);
  color: var(--ink); font-size: 13.5px; resize: vertical; margin-bottom: 14px;
}
.modal-sheet textarea::placeholder { color: var(--muted); }
.modal-sheet textarea:focus { outline: none; border-color: var(--red); }
.modal-row { display: flex; gap: 10px; }
.btn-ghost {
  flex: 1; padding: 12px; border-radius: var(--radius-md);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--ink); font-weight: 600; font-size: 13.5px;
}

/* ============ ARTPLAYER ============ */
.art-video-player { font-family: var(--font) !important; }

/* ============ MOBILE ============ */
@media (max-width: 600px) {
  .topbar { padding: 0 10px; height: 48px; }
  .topbar-logo { height: 22px; }
  .topbar-right { gap: 6px; }
  .gold-topup { padding: 3px 3px 3px 8px; gap: 4px; height: 30px; border-radius: 6px; }
  .gold-topup .gold-icon { width: 16px; height: 16px; }
  .gold-topup .gold-num { font-size: 11px; }
  .gold-topup-btn { font-size: 9px; padding: 4px 8px; border-radius: 4px; }
  .btn-theme { width: 28px; height: 28px; }
  .btn-logout-icon { width: 28px; height: 28px; }
  .stream-info-bar { padding: 10px 12px; }
  .stream-info-row1 { gap: 10px; }
  .stream-info-left { gap: 8px; }
  .streamer-avatar { width: 48px; height: 48px; }
  .avatar-frame { width: 60px; height: 60px; top: -6px; left: -6px; }
  .avatar-img { width: 40px; height: 40px; margin: 4px; }
  .streamer-badge-img { height: 22px; }
  .streamer-name { font-size: 13px; }
  .stream-info-stats { gap: 12px; }
  .stat-num { font-size: 14px; }
  .stat-label { font-size: 10px; }
  .btn-following { padding: 6px 14px; font-size: 12px; border-width: 1.5px; }
  .btn-share { width: 34px; height: 34px; }
  .btn-share svg { width: 14px; height: 14px; }
  .stream-switch-inline .stream-switch-btn { padding: 6px 14px; font-size: 12px; }
  .chat-panel { height: 400px; }
  .chat-msg { font-size: 12px; padding: 6px 10px; }
  .chat-input-area input { padding: 8px 12px; font-size: 12px; }
  .chat-send-btn { width: 34px; height: 34px; }
}
