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

body {
  font-family: "Comic Sans MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #ffe0ec, #d0f0ff);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }
.view { height: 100vh; }

button { cursor: pointer; border: none; border-radius: 12px; font-size: 18px; }

.btn-primary {
  background: #ff7eb3; color: #fff; padding: 10px 24px;
  font-weight: bold; transition: transform .1s;
}
.btn-primary:hover { transform: scale(1.05); background: #ff5c9e; }

.btn-danger { background: #ff5252; color: #fff; padding: 10px 24px; font-weight: bold; }
.btn-danger:hover { background: #e63946; }

.error { color: #e63946; min-height: 20px; margin-top: 8px; }

/* ===== 登录注册 ===== */
#auth-view { display: flex; align-items: center; justify-content: center; }

.auth-card {
  background: #fff; border-radius: 24px; padding: 40px;
  width: 380px; text-align: center;
  box-shadow: 0 8px 30px rgba(255, 126, 179, .35);
}
.auth-card h1 { color: #ff5c9e; font-size: 28px; }
.subtitle { color: #888; margin: 8px 0 20px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; background: #f0f0f0; color: #666; font-weight: bold; }
.tab.active { background: #ff7eb3; color: #fff; }

.auth-card input[type=text], .auth-card input[type=password] {
  width: 100%; padding: 12px; margin-bottom: 12px;
  border: 2px solid #ffd0e4; border-radius: 12px; font-size: 16px; outline: none;
}
.auth-card input:focus { border-color: #ff7eb3; }

.role-picker { display: flex; justify-content: space-around; margin-bottom: 16px; font-size: 16px; }
.role-picker label { cursor: pointer; }

/* ===== 聊天主界面 ===== */
#chat-view { display: flex; }

#sidebar {
  width: 260px; background: #fff; padding: 16px;
  border-right: 3px solid #ffd0e4; overflow-y: auto;
}

.me-card {
  display: flex; align-items: center; gap: 10px;
  background: #fff0f6; border-radius: 16px; padding: 12px; margin-bottom: 16px;
}
.me-name { font-weight: bold; color: #333; }
.me-role { font-size: 12px; color: #999; }
#btn-logout { margin-left: auto; background: none; font-size: 20px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #ffe0ec; display: inline-flex;
  align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0;
  overflow: hidden;
}
.avatar.small { width: 32px; height: 32px; font-size: 18px; }
.avatar.clickable { cursor: pointer; transition: transform .1s; }
.avatar.clickable:hover { transform: scale(1.1); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }

#sidebar h3 { color: #ff5c9e; margin-bottom: 8px; }

.sidebar-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.sidebar-title h3 { margin-bottom: 0; }
#btn-add-friend, #btn-settings { background: #ffe0ec; padding: 4px 10px; font-size: 16px; }
#btn-add-friend:hover, #btn-settings:hover { background: #ffc4dd; }

#no-friends-tip {
  text-align: center; color: #bbb; margin-top: 24px; line-height: 1.8;
}

/* ===== 好友申请 ===== */
#friend-requests h4, #outgoing-requests h4 { color: #ff9ec4; font-size: 13px; margin: 10px 0 4px; }
#request-list, #outgoing-list { list-style: none; }
#request-list li, #outgoing-list li {
  display: flex; align-items: center; gap: 8px;
  background: #fff8e6; border-radius: 12px; padding: 6px 8px; margin-bottom: 6px;
}
#outgoing-list li { background: #f4f4f4; }
.req-name { flex: 1; font-weight: bold; font-size: 14px; }
.req-accept, .req-reject { background: none; font-size: 16px; padding: 2px 4px; }
.req-accept:hover { transform: scale(1.2); }
.req-reject:hover { transform: scale(1.2); }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 150;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: 24px; padding: 32px;
  width: 380px; text-align: center;
  box-shadow: 0 8px 30px rgba(255,126,179,.35);
}
.modal-card h2 { color: #ff5c9e; margin-bottom: 12px; }
.modal-tip { color: #999; font-size: 14px; margin: 10px 0; }
.modal-card input[type=text], .modal-card input[type=number], .modal-card input[type=password] {
  width: 100%; padding: 12px; margin-bottom: 14px;
  border: 2px solid #ffd0e4; border-radius: 12px; font-size: 16px; outline: none;
}
.modal-card input:focus { border-color: #ff7eb3; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.btn-plain { background: #f0f0f0; color: #666; padding: 10px 24px; font-weight: bold; }
.btn-plain:hover { background: #e2e2e2; }
.modal-msg { min-height: 22px; margin-top: 10px; font-weight: bold; }

/* 设置弹窗分区 */
.settings-card { text-align: left; max-height: 85vh; overflow-y: auto; }
.settings-card h2 { text-align: center; }
.settings-section {
  background: #fff8fb; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 12px;
}
.settings-section label {
  display: block; font-size: 14px; color: #888; margin-bottom: 8px; font-weight: bold;
}
.settings-section input { margin-bottom: 8px; }
.btn-small { padding: 6px 18px; font-size: 14px; }
.settings-card .modal-actions { margin-top: 4px; }

#avatar-presets {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  max-height: 200px; overflow-y: auto; margin-bottom: 8px;
}
#avatar-presets span {
  font-size: 28px; cursor: pointer; padding: 4px;
  border-radius: 10px; transition: transform .1s;
}
#avatar-presets span:hover { background: #ffe0ec; transform: scale(1.2); }

#contact-list { list-style: none; }
#contact-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 14px; cursor: pointer; position: relative;
}
#contact-list li:hover { background: #fff0f6; }
#contact-list li.active { background: #ffe0ec; }
.contact-name { font-weight: bold; }
.contact-role { font-size: 12px; color: #999; }
.online-dot {
  position: absolute; right: 12px; width: 12px; height: 12px;
  border-radius: 50%; background: #ccc;
}
.online-dot.online { background: #4cd964; }

#chat-main { flex: 1; display: flex; flex-direction: column; }

.chat-placeholder {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #ff9ec4;
}

#chat-panel { flex: 1; display: flex; flex-direction: column; height: 100vh; }

#chat-header {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 12px 20px; border-bottom: 3px solid #ffd0e4;
}
#peer-name { font-size: 20px; font-weight: bold; }
.status { font-size: 13px; color: #999; }
.status.online { color: #4cd964; }
.call-buttons { margin-left: auto; display: flex; gap: 8px; }
.call-buttons button { background: #e8f8ff; padding: 8px 14px; font-size: 22px; }
.call-buttons button:hover { background: #c8eeff; }

#message-list {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}

.msg-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }

.bubble {
  max-width: 60%; padding: 10px 14px; border-radius: 18px;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.08);
  font-size: 16px; word-break: break-word;
}
.msg-row.mine .bubble { background: #ff7eb3; color: #fff; }
.bubble .time { display: block; font-size: 11px; opacity: .6; margin-top: 4px; }
.bubble img { max-width: 240px; max-height: 240px; border-radius: 12px; cursor: zoom-in; display: block; }
.bubble video { max-width: 280px; border-radius: 12px; display: block; }
.bubble audio { max-width: 240px; }

#input-bar {
  display: flex; align-items: center; gap: 8px;
  background: #fff; padding: 12px 16px; border-top: 3px solid #ffd0e4;
  position: relative;
}
#input-bar > button { background: #f0f7ff; padding: 8px 12px; font-size: 22px; }
#input-bar > button:hover { background: #d8edff; }
#btn-record.recording { background: #ff5252; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

#msg-input {
  flex: 1; padding: 12px; border: 2px solid #ffd0e4;
  border-radius: 20px; font-size: 16px; outline: none;
}
#msg-input:focus { border-color: #ff7eb3; }

#emoji-panel {
  position: absolute; bottom: 64px; left: 12px;
  background: #fff; border-radius: 16px; padding: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; z-index: 10;
}
#emoji-panel span { font-size: 24px; cursor: pointer; padding: 4px; border-radius: 8px; }
#emoji-panel span:hover { background: #ffe0ec; }

#recording-tip {
  position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: #ff5252; color: #fff; padding: 8px 20px;
  border-radius: 20px; font-weight: bold; z-index: 10;
}

/* ===== 通话界面 ===== */
#call-overlay {
  position: fixed; inset: 0; background: #1a1a2e; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#remote-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
#local-video {
  position: absolute; right: 24px; bottom: 100px;
  width: 180px; border-radius: 12px; border: 3px solid #ff7eb3; background: #000;
}
#call-info {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  text-align: center; color: #fff; z-index: 101;
}
#call-title { font-size: 22px; font-weight: bold; }
#call-timer { font-size: 16px; color: #ffd0e4; margin-top: 4px; }
#call-actions { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); }
#btn-hangup { font-size: 20px; padding: 14px 32px; border-radius: 40px; }

/* ===== 来电提示 ===== */
#incoming-call {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.incoming-card {
  background: #fff; border-radius: 24px; padding: 40px;
  text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.ring { font-size: 48px; animation: shake .6s infinite; }
@keyframes shake { 25% { transform: rotate(15deg); } 75% { transform: rotate(-15deg); } }
#incoming-text { font-size: 20px; margin: 16px 0; }
.incoming-actions { display: flex; gap: 16px; justify-content: center; }
.incoming-actions button { font-size: 18px; }

/* ===== 图片查看器 ===== */
#img-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 300;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
#img-viewer img { max-width: 92%; max-height: 92%; border-radius: 8px; }
