:root {
  --bg-deep: #0B0E14;
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  
  --bubble-me: #6366F1;
  --bubble-them: rgba(255, 255, 255, 0.08);
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* 动态背景修饰 */
#particles-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: 
    radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.15) 0%, transparent 50%);
  filter: blur(60px);
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 屏幕管理 */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  animation: fadeIn 0.4s ease-out forwards;
}
.screen.active {
  display: flex;
}

/* ---------------------------------
   大厅/连接截面
--------------------------------- */
#setup-screen {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.brand h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-top: -16px;
  margin-bottom: 8px;
}

.user-info, .connect-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 14px;
  color: var(--text-muted);
}

.id-display {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 16px;
  justify-content: space-between;
}
#my-id {
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 1px;
  user-select: all;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-glass);
}
.divider span {
  padding: 0 16px;
}

.flex-row {
  display: flex;
  gap: 12px;
}

input[type="text"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  transition: all 0.2s;
  min-width: 0;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-glow);
}

/* 按钮通用 */
button {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}

.primary-btn {
  background: var(--primary);
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 600;
  font-size: 15px;
}
.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.icon-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px;
}
.icon-btn:hover {
  background: var(--bg-glass-hover);
}

.danger-btn.icon-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.square-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  padding: 0;
}

.gradient-btn {
  background: linear-gradient(135deg, var(--primary), #a855f7);
}
.gradient-btn:hover {
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

#copy-btn {
  color: var(--text-muted);
}
#copy-btn:hover {
  color: var(--text-main);
}

/* ---------------------------------
   聊天界面
--------------------------------- */
#chat-screen {
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  border-left: 1px solid var(--border-glass);
  border-right: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(20px);
}

.glass-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(11, 14, 20, 0.6);
}

.peer-status {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}
.status-indicator.online {
  background: #10B981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}
.peer-name {
  font-weight: 600;
  font-size: 15px;
}
.peer-id-text {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* 聊天内容区 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
}
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 10px;
}

.system-message {
  align-self: center;
  background: var(--bg-glass);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: messageSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.message-wrapper.me {
  align-self: flex-end;
  align-items: flex-end;
}
.message-wrapper.them {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  word-break: break-all;
}

.message-wrapper.me .message-bubble {
  background: var(--bubble-me);
  color: white;
  border-bottom-right-radius: 4px;
}
.message-wrapper.them .message-bubble {
  background: var(--bubble-them);
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 4px;
}

/* 媒体消息 (图/视频) */
.message-media {
  margin-top: 4px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: transform 0.2s;
}
.message-media:hover {
  transform: scale(1.02);
}
.message-media img, .message-media video {
  display: block;
  max-width: 300px;
  max-height: 400px;
  object-fit: cover;
}

.time-stamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-left: 4px;
  margin-right: 4px;
}

/* 输入区 */
.glass-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 12px;
  background: rgba(11, 14, 20, 0.6);
  z-index: 10;
}

/* 拖拽上传覆盖物 */
.drop-overlay {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 80px;
  background: rgba(99, 102, 241, 0.15);
  backdrop-filter: blur(8px);
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border: 2px dashed var(--primary);
  margin: 10px;
  border-radius: 16px;
}
.drop-overlay.drag-over {
  opacity: 1;
}
.drop-content {
  color: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.drop-content h2 {
  font-weight: 400;
}

/* 全屏查看相册/视频 */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.lightbox.show {
  opacity: 1;
  pointer-events: auto;
}
.close-lightbox {
  position: absolute;
  top: 24px;
  right: 24px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  padding: 8px;
  z-index: 101;
}
.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
}
.lightbox-content img, .lightbox-content video {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* 动画和响应式 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
  #chat-screen {
    border: none;
  }
}
