/* ================= 全局变量 ================= */
:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg-dark: #0f172a;
  --bg-light: #f8fafc;
  --text-dark: #0f172a;
  --text-light: #ffffff;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  
  /* 玻璃拟态配置 */
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: 20px;
  
  /* 输入框配置 */
  --input-border: #cbd5e1;
  --input-bg: rgba(255, 255, 255, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-dark: #ffffff;
    --text-dark: #ffffff;
    --card-bg: #000000;
    --border: #333333;
    --input-border: #4b5563;
    --glass-bg: rgba(40, 40, 40, 0.6);
    --glass-border: rgba(255, 255, 255, 0.15);
    --input-bg: rgba(60, 60, 60, 0.55);
  }
  body { color: white; }
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--card-bg);
  color: var(--text-dark);
  margin: 0;
  transition: background 0.3s;
}

/* ================= 组件样式 ================= */

/* 基础按钮和输入框通用类 */
.input-base {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  transition: transform 0.2s ease;
  color: inherit;
  outline: none;
}

.input-base:hover, .input-base:focus {
  transform: scale(1.02);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* 聊天室/毛玻璃输入框 */
.input-glass, .btn-circle {
  background: var(--input-bg) !important;
  backdrop-filter: blur(25px);
  border: 1.5px solid var(--input-border) !important;
  color: inherit !important;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow: none;
}

.input-glass {
  height: 42px;
  border-radius: 12px;
  padding: 0 12px;
}

.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.input-glass:hover, .input-glass:focus, 
.btn-circle:hover, .btn-circle:focus {
  transform: scale(1.03);
  border-color: var(--input-border) !important;
}
.input-glass:active, .btn-circle:active { transform: scale(0.97); }

/* 聊天室图标点击/打开状态 */
#chat-toggle {
  transition: all 0.2s ease-out;
  color: #64748b !important; /* 默认灰色 */
  transform: scale(1); /* 明确初始缩放 */
}
#chat-toggle.toggled {
  color: #3b82f6 !important; /* 打开时蓝色 */
  transform: scale(1.2); /* 打开时放大 */
}

/* 弹窗玻璃容器 */
.popup-glass {
  position: fixed;
  top: 50%; left: 50%;
  width: calc(100% - 32px); max-width: 600px; height: 500px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 1002;
  opacity: 0; visibility: hidden;
  transform: translate(-50%, -45%) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.popup-glass.show {
  opacity: 1; visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* 分组卡片 */
.group-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
}
.group-card:hover { background: var(--bg-light); }
.group-card.selected { background: var(--primary); color: white; border-color: var(--primary); }
@media (prefers-color-scheme: dark) { .group-card:hover { background: #1f2937; } }

/* 电台列表项 */
.radio-item, .search-result-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.radio-item:hover, .search-result-item:hover { background: rgba(0,0,0,0.05); }
@media (prefers-color-scheme: dark) { .radio-item:hover { background: rgba(255,255,255,0.1); } }
.radio-item.selected { background: rgba(59,130,246,0.1); border-left: 4px solid var(--primary); }
.radio-item.selected .font-medium { color: var(--primary); }

/* 聊天气泡 */
.chat-message { max-width: 85%; margin-bottom: 0.5rem; font-size: 0.875rem; position: relative; }
.chat-message.self { align-self: flex-end; margin-left: auto; }
.chat-message.other { align-self: flex-start; margin-right: auto; }

.msg-bubble { padding: 0.5rem 0.75rem; border-radius: 18px; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.chat-message.self .msg-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.chat-message.other .msg-bubble { background: #f1f5f9; color: #0f172a; border-bottom-left-radius: 4px; }
@media (prefers-color-scheme: dark) { .chat-message.other .msg-bubble { background: #2d3748; color: white; } }

.chat-image { max-width: 200px; border-radius: 8px; cursor: zoom-in; transition: transform 0.2s; }
.chat-image:hover { transform: scale(1.02); }

/* 图片modal效果 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000; /* 高于其他弹窗 */
  cursor: pointer;
}
.modal-img {
  max-width: 90%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* 固定播放器 */
#fixed-player {
  position: fixed; bottom: 20px; right: 20px; width: 280px;
  background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border); border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 1001; display: none;
}
@media (max-width: 640px) { #fixed-player { width: calc(100% - 32px); left: 16px; right: 16px; bottom: 16px; } }

/* 遮罩层 */
#popup-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: transparent;
  opacity: 0; visibility: hidden;
}
#popup-overlay.show { opacity: 1; visibility: visible; }

/* 顶部公告栏 */
.announcement-bar {
  background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur));
  border-radius: 12px; padding: 0.4rem 0.8rem;
  display: flex; align-items: center; min-height: 52px; /* 改为min-height，自适应换行 */
  overflow: visible; /* 允许溢出可见 */
}
.announcement-item { font-size: 0.85rem; font-weight: 500; animation: flipIn 0.5s ease forwards; }
@keyframes flipIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.3s ease; }
.hidden { display: none !important; }

/* 聊天室公告调整 */
#chat-announcement-content {
  overflow: visible !important; /* 允许换行溢出 */
}
#chat-window > div:first-child { /* 聊天公告父容器 */
  min-height: 26px; /* 改为min-height */
  height: auto;
  overflow: visible;
}