:root {
  --primary: #00A1D6;
  --bg: #17181A;
  --panel: #222326;
  --line: #2C2D31;
  --text: #E5E9EF;
  --sub: #9499A0;
  --accent: #FF6699;
  --top-h: 52px;
  --chat-w: 340px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
ul, ol { list-style: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--top-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: 100%;
  max-width: 1440px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.brand-logo {
  font-size: 24px; font-weight: 800; font-style: italic;
  color: var(--primary); letter-spacing: -0.5px;
}
.brand-tag {
  font-size: 12px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
  background: var(--primary); color: #fff;
}
.nav { display: flex; gap: 4px; }
.nav-item {
  padding: 6px 12px; border-radius: 6px;
  color: var(--sub); font-size: 15px; white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-item:hover { color: var(--text); background: var(--line); }
.nav-item.active { color: var(--primary); }
.search {
  margin-left: auto;
  display: flex; align-items: center;
  width: 320px; height: 36px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 4px 0 12px;
}
.search:focus-within { border-color: var(--primary); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; }
.search input::placeholder { color: var(--sub); }
.search-btn { width: 32px; height: 28px; border-radius: 6px; color: var(--sub); display: grid; place-items: center; }
.search-btn:hover { color: var(--primary); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-weight: 700; color: #fff;
  border: 2px solid var(--line); cursor: pointer;
}

/* ---------- Room layout ---------- */
.room {
  max-width: 1440px; margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-w);
  gap: 16px;
  align-items: start;
}
.stage { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Player ---------- */
.player {
  background: #000;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: relative;
  width: 100%; aspect-ratio: 16 / 9;
}
.player:fullscreen { border-radius: 0; border: 0; aspect-ratio: auto; }
.player:fullscreen .video-area { flex: 1; }
.video-area {
  position: relative;
  width: 100%; flex: 1; min-height: 0;
  background: #000; overflow: hidden;
}
.video-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background:
    linear-gradient(#dceaff0a 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, #dceaff0a 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(ellipse at 20% 12%, #245068, transparent 58%),
    radial-gradient(ellipse at 85% 80%, #503455, transparent 60%), #121825;
}
.live-dot {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 8px; border-radius: 4px; background: var(--accent); color: #fff;
}
.live-dot i { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.placeholder-text { font-size: clamp(28px, 4vw, 54px); font-weight: 700; color: #f6f7ff; }
.placeholder-sub { font-size: 13px; color: #c6cbd9; }
.player:not(.paused) #playState, .player.paused .poster-hint { display: none; }

.danmaku-layer { position: absolute; inset: 0 0 20% 0; pointer-events: none; overflow: hidden; }
.danmaku-layer.off { display: none; }
.dm {
  position: absolute; left: 100%;
  white-space: nowrap; font-size: 20px; font-weight: 600;
  color: #fff; text-shadow: 0 0 2px #000, 1px 1px 2px #000;
  animation: dm-fly linear forwards;
  will-change: transform;
}
.dm.self { border: 1px solid var(--primary); padding: 0 6px; border-radius: 4px; }
@keyframes dm-fly {
  from { transform: translateX(0); }
  to { transform: translateX(var(--dm-dist, -2000px)); }
}
.player.paused .dm { animation-play-state: paused; }

.player-float {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.float-btn {
  width: 52px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(23, 24, 26, .72); border-radius: 10px;
  color: var(--text); font-size: 11px;
  transition: color .15s, transform .15s;
}
.float-btn:hover { color: var(--primary); }
.float-btn.liked { color: var(--accent); }
.float-btn.pop { transform: scale(1.15); }

.controls {
  height: 44px; padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.ctrl-left, .ctrl-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctrl-btn {
  width: 34px; height: 34px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text);
}
.ctrl-btn:hover, .ctrl-text:hover { color: var(--primary); }
.ico-play { display: none; }
.player.paused .ico-play { display: block; }
.player.paused .ico-pause { display: none; }
.volume { display: flex; align-items: center; gap: 4px; }
.vol-mute { display: none; }
.volume.muted .vol-mute { display: block; }
.volume.muted .vol-wave { display: none; }
#volRange { width: 80px; accent-color: var(--primary); cursor: pointer; }
.ctrl-latency { font-size: 12px; color: var(--sub); white-space: nowrap; }
.ctrl-text {
  height: 28px; padding: 0 10px; border-radius: 6px;
  font-size: 13px; color: var(--text); white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
}
.dm-ico {
  width: 20px; height: 18px; font-size: 11px; line-height: 16px; text-align: center;
  border: 1.5px solid currentColor; border-radius: 4px;
}
.danmaku-switch.on .dm-ico { background: var(--primary); border-color: var(--primary); color: #fff; }
.danmaku-switch:not(.on) { color: var(--sub); }

/* ---------- Anchor bar ---------- */
.anchor-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--panel); border-radius: 8px; border: 1px solid var(--line);
}
.anchor-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 0 0 2px var(--accent);
}
.anchor-info { flex: 1; min-width: 0; }
.anchor-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.anchor-lv { font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 3px; color: var(--accent); border: 1px solid var(--accent); }
.anchor-meta { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anchor-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-follow, .btn-airi {
  height: 32px; padding: 0 14px; border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: opacity .15s, background .15s;
}
.btn-follow { background: var(--primary); color: #fff; }
.btn-follow.followed { background: var(--line); color: var(--sub); }
.btn-airi { border: 1px solid var(--accent); color: var(--accent); }
.btn-airi:hover { background: var(--accent); color: #fff; }
.btn-follow:hover { opacity: .88; }

/* ---------- Chat ---------- */
.chat {
  width: var(--chat-w);
  height: calc(100vh - var(--top-h) - 40px);
  min-height: 520px;
  position: sticky; top: calc(var(--top-h) + 20px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden;
}
.chat-tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-tab {
  flex: 1; height: 42px; color: var(--sub); font-size: 14px; position: relative;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.active { color: var(--primary); font-weight: 600; }
.chat-tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 2px; background: var(--primary);
}
.chat-panels { flex: 1; min-height: 0; position: relative; }
.panel { position: absolute; inset: 0; overflow-y: auto; display: none; padding: 8px 12px; }
.panel.active { display: block; }
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.msg { padding: 5px 0; line-height: 28px; word-break: break-word; font-size: 14px; }
.msg.system { color: var(--sub); font-size: 14px; }
.msg.gift { color: var(--accent); }
.badge-lv, .badge-fan {
  display: inline-flex; align-items: center; vertical-align: 2px;
  height: 18px; font-size: 12px; line-height: 16px; border-radius: 3px; margin-right: 4px; font-weight: 600;
}
.badge-lv { padding: 0 4px; border: 1px solid currentColor; }
.badge-fan { overflow: hidden; border: 1px solid var(--accent); }
.badge-fan .fn { padding: 0 4px; background: var(--accent); color: #fff; }
.badge-fan .fl { padding: 0 4px; color: var(--accent); background: var(--bg); }
.msg .uname { color: var(--sub); margin-right: 4px; cursor: pointer; }
.msg .uname:hover { color: var(--primary); }
.msg .uname.guard { color: var(--primary); }
.msg .text { color: var(--text); }

.rank-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.rank-no { width: 22px; text-align: center; font-weight: 700; color: var(--sub); }
.rank-list li:first-child { border: 1px solid #e8c366; border-radius: 8px; }
.rank-list li:first-child .rank-no { color: #e8c366; }
.rank-list li:nth-child(2) .rank-no { color: var(--primary); }
.rank-list li:nth-child(3) .rank-no { color: #E5E9EF; }
.rank-ava {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); font-size: 12px; color: var(--text);
}
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: var(--accent); font-size: 12px; }

.notice h3 { font-size: 15px; margin: 6px 0 10px; color: var(--text); }
.notice p { font-size: 13px; color: var(--sub); margin-bottom: 8px; }

.chat-input {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--line);
}
.gift-entry {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--accent); background: var(--bg);
  border: 1px solid var(--line);
}
.gift-entry:hover { border-color: var(--accent); }
#chatInput {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: 0;
}
#chatInput:focus { border-color: var(--primary); }
#chatInput::placeholder { color: var(--sub); }
.send-btn {
  height: 36px; padding: 0 16px; border-radius: 8px; flex-shrink: 0;
  background: var(--primary); color: #fff; font-weight: 600;
}
.send-btn:hover { opacity: .9; }
.send-btn:disabled { background: var(--line); color: var(--sub); cursor: not-allowed; opacity: 1; }

/* ---------- Gift panel ---------- */
.gift-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.gift-mask[hidden] { display: none; }
.gift-panel {
  width: 420px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; animation: pop-in .18s ease-out;
}
@keyframes pop-in { from { transform: translateY(12px); opacity: 0; } }
.gift-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.gift-close { font-size: 22px; line-height: 1; color: var(--sub); width: 28px; height: 28px; }
.gift-close:hover { color: var(--text); }
.gift-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 16px; }
.gift-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  transition: border-color .15s, transform .15s;
}
.gift-item:hover { transform: translateY(-2px); }
.gift-item.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.gift-emoji { font-size: 30px; line-height: 1.1; }
.gift-name { font-size: 13px; color: var(--text); }
.gift-price { font-size: 11px; color: var(--sub); }
.gift-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.balance { font-size: 13px; color: var(--sub); }
.balance b { color: var(--primary); }

/* ---------- Slice1 fix additions ---------- */
.anchor-hot { color: var(--accent); font-weight: 600; }
.anchor-hot svg { vertical-align: -2px; margin-right: 2px; }
.dm-setting-panel {
  position: absolute; right: 12px; bottom: 52px; z-index: 20;
  width: 260px; padding: 14px 16px;
  background: rgba(34, 35, 38, .96); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px; font-size: 13px;
}
.dm-setting-panel[hidden] { display: none; }
.dm-setting-panel .ds-title { font-weight: 600; }
.dm-setting-panel label { display: flex; align-items: center; gap: 10px; color: var(--sub); }
.dm-setting-panel label > span:first-child { width: 56px; flex-shrink: 0; }
.dm-setting-panel input[type=range] { flex: 1; accent-color: var(--primary); }
.dm-setting-panel .ds-val { width: 36px; text-align: right; color: var(--text); }
.dm-setting-panel input[type=text] {
  flex: 1; min-width: 0; height: 28px; padding: 0 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; outline: 0;
}
.dm-setting-panel input[type=text]:focus { border-color: var(--primary); }
.chat-input { position: relative; }
.emoji-btn {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; font-size: 18px;
  display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line);
}
.emoji-btn:hover { border-color: var(--primary); }
.emoji-pop {
  position: absolute; left: 12px; bottom: 100%; margin-bottom: 6px; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.emoji-pop[hidden] { display: none; }
.emoji-pop button { width: 32px; height: 32px; font-size: 20px; border-radius: 6px; }
.emoji-pop button:hover { background: var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 8px 16px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 13px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar-inner { gap: 16px; padding: 0 16px; }
  .search { width: 220px; }
  .room { padding: 16px; }
}

@media (max-width: 860px) {
  .room { grid-template-columns: minmax(0, 1fr); }
  .chat {
    width: 100%; position: static;
    height: 480px; min-height: 0;
  }
}

@media (max-width: 640px) {
  :root { --top-h: 50px; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .brand-logo { font-size: 20px; }
  .nav { display: none; }
  .search { width: auto; flex: 1; min-width: 0; height: 32px; }
  .user-avatar { width: 32px; height: 32px; }
  .room { padding: 0 0 12px; gap: 10px; }
  .player { border-radius: 0; border-left: 0; border-right: 0; }
  .controls { padding: 0 6px; gap: 4px; }
  .ctrl-left, .ctrl-right { gap: 2px; }
  #volRange { display: none; }
  .ctrl-text { padding: 0 6px; font-size: 12px; }
  .dm-label { display: none; }
  .ctrl-latency { font-size: 11px; }
  .dm { font-size: 15px; }
  .player-float { right: 8px; bottom: 8px; gap: 6px; }
  .float-btn { width: 42px; padding: 4px 0; font-size: 10px; }
  .float-btn svg { width: 18px; height: 18px; }
  .anchor-bar { margin: 0 10px; padding: 10px 12px; gap: 10px; }
  .anchor-name { font-size: 15px; }
  .btn-follow, .btn-airi { height: 30px; padding: 0 10px; font-size: 12px; }
  .chat { margin: 0 10px; width: auto; height: 420px; }
  .gift-grid { gap: 8px; padding: 12px; }
}

@media (max-width: 400px) {
  .anchor-bar { flex-wrap: wrap; }
  .anchor-actions { width: 100%; }
  .btn-follow, .btn-airi { flex: 1; }
  .placeholder-text { font-size: 18px; }
}

.live2d-stage{position:absolute;inset:0;z-index:1;pointer-events:none}
.live2d-stage canvas{display:block;width:100%!important;height:100%!important}
.live2d-hud{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);color:#8f93a0;font-size:12px}

.video-area.has-live2d .placeholder-text,
.video-area.has-live2d .poster-hint,
.video-area.has-live2d .placeholder-sub:not(#playState){display:none}
