/* ============ 全局 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --panel: #ffffff;
  --primary: #4f7cff;
  --primary-dark: #3b5fd9;
  --green: #10b981;
  --green-dark: #059669;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(2, 6, 23, .25);
  --calendar-width: 260px;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }

/* ============ 登录界面 ============ */
.login-view {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #4f46e5 100%);
}
.login-view::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  background: radial-gradient(circle at 20% 20%, rgba(99,102,241,.35), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(56,189,248,.3), transparent 50%);
}
.login-bg-text {
  position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  width: 100%; height: 100%; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
  font-size: clamp(34px, 7vw, 80px);
  font-weight: 800;
  letter-spacing: .12em;
  color: rgba(255,255,255,.16);
  text-shadow: 0 0 60px rgba(255,255,255,.12), 0 0 120px rgba(99,102,241,.35);
  white-space: nowrap;
  animation: bgTextBreathe 6s ease-in-out infinite;
}
@keyframes bgTextBreathe {
  0%, 100% { opacity: .85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}
.login-card {
  position: relative; z-index: 1;
  width: 400px; max-width: calc(100vw - 40px);
  background: rgba(255,255,255,.96);
  border-radius: 22px; padding: 40px 36px 28px;
  box-shadow: var(--shadow);
  animation: fadeUp .5s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.login-logo { text-align: center; margin-bottom: 26px; }
.logo-icon {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 18px; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f7cff, #7c5cff);
  box-shadow: 0 8px 24px rgba(79,124,255,.4);
}
.logo-icon.small { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; margin: 0; box-shadow: none; flex-shrink: 0; }
.login-logo h1 { font-size: 22px; color: var(--text); }
.login-logo p { color: var(--text-2); font-size: 13px; margin-top: 6px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; background: #f1f5f9; padding: 4px; border-radius: 12px; }
.tab-btn {
  flex: 1; padding: 8px 0; border: none; border-radius: 9px;
  background: transparent; color: var(--text-2); font-size: 14px;
  cursor: pointer; transition: all .2s; font-weight: 600;
}
.tab-btn.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.tab-panel input {
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.tab-panel input:focus { border-color: var(--primary); }
.btn-primary {
  padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79,124,255,.4); }
.btn-primary:active { transform: none; }
.login-error {
  color: var(--danger); font-size: 13px; text-align: center;
  margin-top: 12px; min-height: 18px;
}
.login-tip { text-align: center; color: var(--text-2); font-size: 12px; margin-top: 16px; }

/* ============ 主界面布局 ============ */
.main-view { display: flex; height: 100vh; }
.sidebar {
  width: 250px; background: var(--bg-2); color: #e2e8f0;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.my-nick { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.my-user { font-size: 11px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.08); border: none; border-radius: 8px;
  padding: 6px 8px; cursor: pointer; font-size: 14px; transition: background .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.18); }
.sidebar-section { flex: 1; overflow-y: auto; padding: 14px; }
.section-title {
  font-size: 12px; color: #94a3b8; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px;
}
.badge {
  background: rgba(255,255,255,.14); border-radius: 10px;
  padding: 1px 8px; font-size: 11px; margin-left: 6px;
}
.online-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.online-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 9px; font-size: 13px;
  transition: background .15s;
}
.online-list li:hover { background: rgba(255,255,255,.07); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.online-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-me { color: #7dd3fc; font-size: 11px; }
.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.conn-status { font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.conn-status.conn-offline .dot { background: var(--danger); }
.conn-status.conn-reconnect .dot { background: #f59e0b; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.btn-logout {
  background: rgba(255,255,255,.08); color: #e2e8f0; border: none;
  padding: 5px 12px; border-radius: 8px; font-size: 12px; cursor: pointer; transition: background .2s;
}
.btn-logout:hover { background: rgba(239,68,68,.35); }

/* ============ 聊天区 ============ */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel); position: relative; }
.calendar-panel {
  width: var(--calendar-width); flex-shrink: 0;
  background: #fff; border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.calendar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.cal-nav {
  width: 26px; height: 26px; border: none; border-radius: 6px;
  background: #f1f5f9; color: var(--text); font-size: 16px; cursor: pointer;
  transition: background .15s;
}
.cal-nav:hover { background: #e2e8f0; }
#cal-title { font-weight: 700; font-size: 14px; color: var(--text); }
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 0 14px 6px; text-align: center;
  font-size: 11px; color: var(--text-2); font-weight: 600;
}
.calendar-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 0 14px 14px; gap: 4px;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 12px; cursor: pointer; position: relative;
  transition: background .15s, color .15s;
}
.cal-day:hover { background: #f1f5f9; }
.cal-day.other { color: #cbd5e1; }
.cal-day.today { background: #eef2ff; color: var(--primary); font-weight: 700; }
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-day.selected:hover { background: var(--primary-dark); }
.cal-day.has-msg::after {
  content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--green);
}
.cal-day.selected.has-msg::after { background: rgba(255,255,255,.75); }
.cal-empty-hint {
  padding: 20px 14px; text-align: center;
  font-size: 13px; color: var(--text-2);
}
.calendar-foot {
  padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
}
.cal-selected { font-weight: 700; color: var(--text); }
.cal-count { color: var(--text-2); }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: #fff;
}
.room-tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.room-tabs::-webkit-scrollbar { display: none; }
.room-tab {
  padding: 6px 14px; border: 1px solid var(--border); background: #f8fafc;
  border-radius: 20px; font-size: 13px; cursor: pointer; white-space: nowrap;
  color: var(--text-2); transition: all .2s; font-weight: 600;
}
.room-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(79,124,255,.35);
}
.room-tab .tab-count { font-size: 11px; opacity: .8; margin-left: 4px; }
.btn-add-room {
  padding: 7px 14px; border: 1.5px dashed var(--primary); background: transparent;
  color: var(--primary); border-radius: 20px; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: all .2s; font-weight: 600;
}
.btn-add-room:hover { background: rgba(79,124,255,.08); }
.room-info { display: flex; align-items: center; gap: 8px; min-width: 120px; justify-content: flex-end; }
#current-room-name { font-weight: 700; font-size: 15px; }
.room-count { color: var(--text-2); font-size: 12px; background: #f1f5f9; padding: 2px 10px; border-radius: 12px; }

.room-members {
  background: #f8fafc; border-bottom: 1px solid var(--border);
  padding: 8px 18px; display: flex; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-2);
}
.room-members .chip { background: #fff; border: 1px solid var(--border); padding: 3px 10px; border-radius: 14px; }

.msg-list { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; background: transparent; position: relative; }
.msg-list::before {
  content: '黔南2026暑期AI创造营';
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(34px, 5.5vw, 72px);
  font-weight: 900; letter-spacing: .12em; white-space: nowrap;
  color: rgba(79,124,255,.18);
  text-shadow: 0 0 60px rgba(79,124,255,.25), 0 0 100px rgba(124,92,255,.15);
  pointer-events: none;
  animation: bgTextBreathe 6s ease-in-out infinite;
  z-index: 0;
}
.msg-list > * { position: relative; z-index: 1; }
@keyframes bgTextBreathe {
  0%, 100% { opacity: .85; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}
.msg-placeholder { margin: auto; text-align: center; color: var(--text-2); }
.ph-icon { font-size: 48px; margin-bottom: 10px; }
.ph-sub { font-size: 12px; opacity: .7; margin-top: 4px; }
.date-banner { text-align: center; font-size: 12px; color: var(--text-2); padding: 4px 0 10px; z-index: 1; }

/* 消息气泡 */
.msg-row { display: flex; gap: 10px; animation: msgIn .25s ease; max-width: 100%; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-row .avatar { margin-top: 2px; }
.msg-body { max-width: min(560px, 75%); display: flex; flex-direction: column; gap: 3px; }
.msg-name { font-size: 12px; color: var(--text-2); }
.msg-bubble {
  padding: 10px 14px; border-radius: 4px 14px 14px 14px;
  background: #fff; border: 1px solid var(--border);
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.msg-row.self { flex-direction: row-reverse; }
.msg-row.self .msg-body { align-items: flex-end; }
.msg-row.self .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; border-radius: 14px 4px 14px 14px;
}
.msg-time { font-size: 10px; color: #cbd5e1; }

/* 系统消息 */
.msg-row.system { justify-content: center; }
.msg-row.system .system-text {
  background: rgba(100,116,139,.1); color: var(--text-2);
  padding: 4px 14px; border-radius: 12px; font-size: 12px;
}

/* 文件卡片 */
.file-card {
  display: flex; align-items: center; gap: 12px; min-width: 260px;
}
.file-card .file-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: linear-gradient(135deg, #4f7cff, #7c5cff); color: #fff;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.file-meta { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.file-caption { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.btn-download {
  padding: 6px 14px; border: none; border-radius: 8px;
  background: #eef2ff; color: var(--primary); font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: all .2s;
}
.btn-download:hover { background: #e0e7ff; }
.msg-row.self .file-card .file-icon { background: linear-gradient(135deg, rgba(255,255,255,.25), rgba(255,255,255,.15)); }
.msg-row.self .file-info, .msg-row.self .file-caption { color: rgba(255,255,255,.85); }
.msg-row.self .btn-download { background: rgba(255,255,255,.2); color: #fff; }
.msg-row.self .btn-download:hover { background: rgba(255,255,255,.3); }
.msg-image img {
  max-width: 280px; max-height: 320px; border-radius: 10px;
  cursor: pointer; display: block; border: 1px solid var(--border);
}
.msg-row.self .msg-image img { border: none; }

/* 图片全屏预览 */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ============ 输入区 ============ */
.input-area {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border); background: #fff;
}
.input-btn {
  width: 40px; height: 40px; border: none; background: #f1f5f9;
  border-radius: 10px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s; flex-shrink: 0;
}
.input-btn:hover { background: #e2e8f0; }
#msg-input {
  flex: 1; resize: none; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; line-height: 1.5; font-family: inherit;
  outline: none; max-height: 140px; transition: border-color .2s; background: #f8fafc;
}
#msg-input:focus { border-color: var(--primary); background: #fff; }
.btn-send {
  padding: 10px 24px; border: none; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .2s;
}
.btn-send:hover { box-shadow: 0 5px 16px rgba(16,185,129,.4); transform: translateY(-1px); }
.btn-send:active { transform: none; }

/* 文件上传队列 */
.file-queue {
  padding: 10px 18px; border-top: 1px solid var(--border);
  background: #f8fafc; display: flex; flex-direction: column; gap: 8px;
  max-height: 160px; overflow-y: auto;
}
.queue-item {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.queue-item .file-icon { width: 32px; height: 32px; border-radius: 8px; font-size: 16px; display: flex; align-items: center; justify-content: center; background: #eef2ff; color: var(--primary); flex-shrink: 0; }
.queue-item .file-name { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-progress-wrap { width: 160px; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.queue-progress { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 3px; transition: width .15s; }
.queue-pct { font-size: 11px; color: var(--text-2); width: 40px; text-align: right; flex-shrink: 0; }
.queue-cancel { border: none; background: transparent; color: var(--text-2); cursor: pointer; font-size: 14px; flex-shrink: 0; }
.queue-cancel:hover { color: var(--danger); }
.queue-item.done .queue-progress { background: var(--green); }

/* 表情栏 */
.emoji-bar {
  padding: 8px 18px; border-top: 1px solid var(--border); background: #fff;
  display: flex; gap: 4px; flex-wrap: wrap;
}
.emoji-bar button { border: none; background: transparent; font-size: 20px; cursor: pointer; padding: 4px 6px; border-radius: 6px; transition: background .15s; }
.emoji-bar button:hover { background: #f1f5f9; }

/* 拖拽遮罩 */
.drop-overlay {
  position: fixed; inset: 0; z-index: 150; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.45); backdrop-filter: blur(2px);
}
.drop-box {
  padding: 30px 50px; border-radius: 18px; background: rgba(255,255,255,.95);
  font-size: 20px; font-weight: 700; color: var(--primary);
  border: 3px dashed var(--primary); animation: pulse .8s infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.04); } }

/* Toast */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 300; background: #1e293b; color: #fff; padding: 10px 22px;
  border-radius: 12px; font-size: 13px; box-shadow: var(--shadow);
  animation: fadeUp .3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--green); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .calendar-panel { display: none; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .msg-body { max-width: 85%; }
}
