/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d1a;
  --bg2:       #13132a;
  --bg3:       #1a1a35;
  --sidebar:   #0f0f22;
  --accent:    #ff6b9d;
  --accent2:   #c17bff;
  --accent3:   #6bdfff;
  --text:      #e8e8ff;
  --text-dim:  #8888aa;
  --border:    #2a2a4a;
  --msg-self:  #1e1040;
  --msg-other: #12122a;
  --glow:      0 0 12px rgba(255,107,157,0.4);
  --glow2:     0 0 12px rgba(193,123,255,0.4);
}

html, body { height: 100%; font-family: 'Noto Sans KR', sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }

/* ===== SAKURA ===== */
.sakura-container { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.petal { position: absolute; top: -20px; opacity: 0.6; animation: fall linear infinite; user-select: none; }
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0.7; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== LOGIN MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #1a0a2e 0%, #0d0d1a 70%);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 40px; width: 460px; max-width: 95vw;
  box-shadow: 0 0 60px rgba(255,107,157,.15), 0 0 30px rgba(193,123,255,.1);
  animation: modalIn 0.4s cubic-bezier(.17,.67,.35,1.2); position: relative; z-index: 101;
}
@keyframes modalIn {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-title { text-align: center; margin-bottom: 24px; }
.modal-emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.modal-title h1 {
  font-size: 26px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.modal-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.modal-box label { display: block; font-size: 12px; color: var(--accent2); text-transform: uppercase; letter-spacing: 1px; margin: 16px 0 6px; }
.modal-box input[type="text"] {
  width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px; outline: none; transition: border-color .2s;
}
.modal-box input[type="text"]:focus { border-color: var(--accent); box-shadow: var(--glow); }
.avatar-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-option {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; border-radius: 10px; cursor: pointer; background: var(--bg3);
  border: 2px solid transparent; transition: all .15s;
}
.avatar-option:hover { border-color: var(--accent2); transform: scale(1.1); }
.avatar-option.selected { border-color: var(--accent); background: #2a1040; box-shadow: var(--glow); }
.room-select { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.room-option {
  padding: 8px 10px; border-radius: 10px; background: var(--bg3);
  border: 2px solid transparent; cursor: pointer; transition: all .15s; font-size: 13px;
}
.room-option:hover { border-color: var(--accent2); }
.room-option.selected { border-color: var(--accent); background: #1a0a30; box-shadow: var(--glow); }
.room-option-name { font-weight: 700; font-size: 13px; }
.room-option-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.btn-enter {
  margin-top: 24px; width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 12px; color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: opacity .2s, transform .1s; letter-spacing: 1px;
}
.btn-enter:hover { opacity: .9; transform: translateY(-1px); box-shadow: var(--glow); }
.btn-enter:active { transform: translateY(0); }

/* ===== CONFIRM MODAL ===== */
.confirm-box { max-width: 360px; }
.confirm-msg {
  margin: 6px 0 4px; text-align: center; font-size: 15px;
  line-height: 1.55; color: var(--text); word-break: keep-all; white-space: pre-line;
}

/* 파일 전송 미리보기 모달 */
#filePreviewModal { background: rgba(8,8,18,.55); backdrop-filter: blur(3px); }
.file-preview-box { width: 300px; max-width: 88vw; padding: 20px 22px; }
.file-preview-box .modal-title { margin-bottom: 12px; }
.file-preview-box .modal-emoji { font-size: 26px; margin-bottom: 4px; }
.file-preview-box .modal-title h1 { font-size: 18px; }
.fp-dest { text-align: center; font-size: 12px; color: var(--text-dim); margin: 0 0 10px; word-break: keep-all; }
.fp-preview {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  min-height: 90px; max-height: 180px; overflow: hidden; padding: 6px;
}
.fp-preview img, .fp-preview video {
  max-width: 100%; max-height: 168px; border-radius: 6px; object-fit: contain;
}
.fp-preview .fp-icon { font-size: 52px; line-height: 1; }
.fp-meta { margin: 10px 0 2px; text-align: center; }
.fp-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  word-break: break-all; line-height: 1.35;
}
.fp-size { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
/* 버튼 컴팩트 */
.file-preview-box .profile-modal-btns { margin-top: 14px; gap: 8px; }
.file-preview-box .btn-enter { margin-top: 0; padding: 8px; font-size: 14px; letter-spacing: .5px; border-radius: 9px; }
.file-preview-box .btn-cancel { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn-danger {
  background: linear-gradient(135deg, #ff5b7f, #ff3b6b) !important;
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(255,59,107,.4) !important; }

/* ===== APP LAYOUT ===== */
.app { display: flex; height: 100vh; position: relative; z-index: 1; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px; min-width: 240px; background: var(--sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-logo {
  padding: 18px 16px; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  border-bottom: 1px solid var(--border);
}
.sidebar-section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.sidebar-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; padding: 0 14px 6px; display: flex; align-items: center; gap: 6px; }
.badge { background: var(--accent); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 20px; }
.sidebar-room {
  padding: 8px 14px; cursor: pointer; border-radius: 8px; margin: 2px 6px;
  font-size: 14px; transition: background .15s; display: flex; align-items: center; gap: 6px;
}
.sidebar-room:hover { background: var(--bg3); }
.sidebar-room.active { background: linear-gradient(90deg, rgba(255,107,157,.2), rgba(193,123,255,.1)); border-left: 3px solid var(--accent); }
.sidebar-room-body { flex: 1; min-width: 0; }
.sidebar-room-name-row { display: flex; align-items: center; gap: 4px; }
.sidebar-room-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-room-count { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.sidebar-room-preview { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; opacity: .75; }
.sidebar-room-unread {
  flex-shrink: 0; display: none; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.sidebar-room-unread.show { display: inline-block; }
.sidebar-room-live { font-size: 10px; color: #ff4444; font-weight: 700; letter-spacing: .5px; animation: liveTextPulse 1.5s ease-in-out infinite; }
@keyframes liveTextPulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }
.sidebar-user { padding: 5px 14px; font-size: 13px; display: flex; align-items: center; gap: 7px; overflow: hidden; }
.sidebar-users-list { max-height: 180px; overflow-y: auto; }
.sidebar-users-list::-webkit-scrollbar { width: 8px; }
.user-nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.my-profile { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg3); }
.my-profile-info { flex: 1; overflow: hidden; }
.my-profile-nick { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-profile-sub { font-size: 11px; color: var(--text-dim); }

/* ===== 친구 목록 ===== */
.add-friend-btn {
  margin-left: auto; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--accent2); font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.add-friend-btn:hover { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.friend-empty { font-size: 11px; color: var(--text-dim); padding: 4px 14px 8px; }
.friend-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 14px; cursor: pointer;
  border-radius: 8px; transition: background .12s;
}
.friend-row:hover { background: var(--bg3); }
.friend-row.active { background: var(--msg-self); }
.friend-avatar { position: relative; font-size: 22px; flex-shrink: 0; line-height: 1; }
.friend-dot {
  position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%;
  background: #555; border: 2px solid var(--sidebar);
}
.friend-dot.on { background: #22c55e; }
.friend-info { flex: 1; overflow: hidden; }
.friend-nick { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-handle { font-size: 11px; color: var(--text-dim); }
.friend-unread {
  display: none; flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.friend-unread.show { display: inline-block; }
.friend-del {
  width: 20px; height: 20px; border: none; background: transparent; color: var(--text-dim);
  font-size: 11px; line-height: 1; border-radius: 6px; cursor: pointer; flex-shrink: 0;
  display: none; padding: 0;
}
.friend-row:hover .friend-del { display: block; }
.friend-del:hover { background: rgba(244,63,94,.5); color: #fff; }

/* ===== 받은 친구 요청 ===== */
.req-row { display: flex; align-items: center; gap: 8px; padding: 7px 14px; }
.req-row .friend-avatar { font-size: 20px; }
.req-accept, .req-decline {
  width: 24px; height: 24px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 700; line-height: 1; flex-shrink: 0; padding: 0;
}
.req-accept { background: rgba(34,197,94,.18); color: #22c55e; }
.req-accept:hover { background: #22c55e; color: #fff; }
.req-decline { background: var(--bg3); color: var(--text-dim); }
.req-decline:hover { background: rgba(244,63,94,.5); color: #fff; }

/* ===== 보낸 요청 (친구추가 모달) ===== */
.sent-req-wrap { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.sent-req-list { max-height: 160px; overflow-y: auto; }
.sent-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.sent-row .friend-avatar { font-size: 20px; }
.sent-pending { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.sent-cancel {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--bg3); color: var(--text-dim);
  font-size: 11px; padding: 4px 10px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.sent-cancel:hover { background: rgba(244,63,94,.4); color: #fff; border-color: transparent; }

/* ===== 친구추가 모달 / 로그아웃 ===== */
.friend-find-result { min-height: 24px; margin: 8px 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.friend-find-result .ff-avatar { font-size: 20px; }
.friend-find-result .ff-handle { color: var(--text-dim); }
.friend-find-result .ff-none { color: var(--text-dim); }
.friend-find-result .ff-ok { color: #4ade80; font-weight: 700; }
.profile-myid { font-size: 12px; color: var(--text-dim); background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; text-align: center; }
.profile-myid b { color: var(--accent2); font-size: 14px; letter-spacing: .5px; }
.profile-myid .myid-hint { opacity: .7; display: block; margin-top: 4px; }
.myid-copy {
  margin-left: 8px; padding: 2px 10px; font-size: 11px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  border: none; border-radius: 6px; vertical-align: middle; transition: opacity .15s;
}
.myid-copy:hover { opacity: .9; }
.btn-logout {
  width: 100%; margin-top: 12px; padding: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); border-radius: 10px; font-size: 13px;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-logout:hover { border-color: var(--rose, #f43f5e); color: var(--rose, #f43f5e); background: rgba(244,63,94,.08); }

/* ===== CHAT AREA ===== */
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.chat-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg2);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.menu-btn { display: none; } /* 데스크탑에서 숨김 */
.menu-unread-badge {
  display: none; position: absolute; top: 1px; right: 1px;
  min-width: 15px; height: 15px; padding: 0 4px; box-sizing: border-box;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
  pointer-events: none;
}
.menu-unread-badge.show { display: inline-block; }
.sidebar-backdrop { display: none; }
.chat-header-right { display: flex; align-items: center; gap: 10px; }
.room-desc { font-size: 13px; color: var(--text-dim); }
.notif-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 17px; padding: 4px 6px; border-radius: 6px; line-height: 1;
  transition: color .15s, opacity .15s; flex-shrink: 0;
}
.notif-btn:hover { color: var(--accent); }
.notif-btn.off { opacity: .4; }

/* ===== BROADCAST LIST (다중 방송) ===== */
.broadcast-list {
  flex-shrink: 0; padding: 8px 16px; gap: 7px;
  background: linear-gradient(90deg, rgba(229,57,53,.1), rgba(255,107,157,.05));
  border-bottom: 1px solid rgba(229,57,53,.25);
  flex-direction: column;
}
.bc-list-header {
  display: flex; align-items: center; gap: 7px; font-size: 12px;
}
.bc-list-count { font-weight: 700; color: #ff6b6b; }
.bc-list-items {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
}
.bc-list-items::-webkit-scrollbar { height: 8px; }
.bc-list-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 8px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(229,57,53,.2);
  border-radius: 20px; white-space: nowrap; flex-shrink: 0;
  transition: border-color .15s, background .15s;
}
.bc-list-item.is-watching {
  background: rgba(229,57,53,.12); border-color: rgba(229,57,53,.5);
}
.bc-item-nick { font-size: 13px; font-weight: 700; }
.bc-item-watch {
  padding: 3px 11px; background: linear-gradient(135deg, #43e97b, #38f9d7);
  border: none; border-radius: 10px; color: #000; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.bc-item-watch:hover { opacity: .85; }
.bc-item-watch.active {
  background: rgba(229,57,53,.25); color: #ff8a80;
  border: 1px solid rgba(229,57,53,.4);
}
.bc-live {
  display: inline-flex; align-items: center; gap: 5px;
  background: #e53935; color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 7px 2px 5px; border-radius: 4px; flex-shrink: 0; letter-spacing: 1px;
}
.bc-live-sm {
  display: inline-flex; align-items: center; gap: 4px;
  background: #e53935; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 5px 1px 4px; border-radius: 3px; letter-spacing: .8px;
}
.bc-dot {
  width: 6px; height: 6px; background: #fff; border-radius: 50%;
  animation: dotPulse 1.2s ease-in-out infinite; flex-shrink: 0;
}
@keyframes dotPulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.7); } }
.bc-dim { color: var(--text-dim); white-space: nowrap; }

/* ===== BROADCAST VIDEO PANEL ===== */
.broadcast-panel {
  flex-shrink: 0; display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border); background: #000;
  max-height: 42vh;
}
.bc-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--bg3); border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 8px;
}
.bc-panel-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; flex: 1; min-width: 0; }
.bc-panel-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bc-stop-watch-btn {
  padding: 3px 10px; background: rgba(229,57,53,.2); border: 1px solid rgba(229,57,53,.4);
  border-radius: 7px; color: #ff8a80; font-size: 11px; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.bc-stop-watch-btn:hover { background: rgba(229,57,53,.35); }
.bc-close-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; padding: 2px 7px; border-radius: 4px; transition: color .15s, background .15s; line-height: 1;
}
.bc-close-btn:hover { color: var(--accent); background: rgba(255,107,157,.12); }
.bc-video-wrap {
  position: relative; width: 100%; flex: 1; background: #000;
  display: flex; align-items: center; justify-content: center; min-height: 120px; overflow: hidden;
}
#broadcastVideo, .bc-self-video { width: 100%; height: 100%; max-height: 38vh; object-fit: contain; display: block; }
/* 분할화면(시청 + 내 방송 동시) */
.bc-video-wrap.split { gap: 2px; }
.bc-video-wrap.split #broadcastVideo,
.bc-video-wrap.split .bc-self-video { flex: 1 1 0; min-width: 0; width: 50%; }
.bc-vid-label {
  position: absolute; top: 6px; z-index: 3; display: none; pointer-events: none;
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,.6); color: #fff;
}
.bc-vid-label.remote { left: 6px; }
.bc-vid-label.self   { right: 6px; }
.bc-video-wrap.split .bc-vid-label { display: block; }
.bc-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-dim); font-size: 13px; background: rgba(0,0,0,.8);
}
.bc-loading.hidden { display: none; }

/* ── 마이크 레벨 미터 (방송자에게 마이크 음량 표시) ── */
.mic-level-meter {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
}
.mic-level-icon { font-size: 13px; line-height: 1; flex-shrink: 0; }
.mic-level-track {
  flex: 1; height: 7px; min-width: 60px; border-radius: 4px;
  background: rgba(255,255,255,.14); overflow: hidden;
}
.mic-level-fill {
  height: 100%; width: 0%; border-radius: 4px;
  background: linear-gradient(90deg,#7bed9f,#48dbfb);
  transition: width .06s linear;
}
/* 큰 패널 위에 떠 있는 형태(반투명 바) */
.mic-level-panel {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 4;
  background: rgba(0,0,0,.55); border-radius: 8px; padding: 5px 10px;
  backdrop-filter: blur(4px); pointer-events: none;
}
/* 떠다니는 미리보기 안에서는 꽉 찬 바 */
.self-preview .mic-level-meter { padding: 5px 8px 7px; background: rgba(0,0,0,.35); }
.bc-spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BROADCAST START BUTTON ===== */
.bc-start-btn {
  padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); font-size: 16px; cursor: pointer;
  transition: all .15s; flex-shrink: 0; line-height: 1;
}
.bc-start-btn:hover { border-color: var(--accent); color: var(--accent); }
.quality-select {
  padding: 6px 8px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); font-size: 12px; cursor: pointer;
  outline: none; transition: border-color .15s; flex-shrink: 0;
  font-family: 'Noto Sans KR', sans-serif;
}
.quality-select:hover { border-color: var(--accent2); }
.quality-select:focus { border-color: var(--accent); }
.bc-start-btn.broadcasting {
  background: rgba(229,57,53,.15); border-color: #e53935; color: #ff6b6b;
  animation: bcBtnPulse 1.5s ease-in-out infinite;
}
.bc-start-btn.broadcasting:hover { background: rgba(229,57,53,.3); }
@keyframes bcBtnPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(229,57,53,0); }
}

/* ===== MESSAGES ===== */
.messages {
  flex: 1 1 0; min-height: 0;   /* min-height:0 → 메시지 많아도 입력창을 밀어내지 않음 */
  overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
.messages { scrollbar-width: thin; scrollbar-color: var(--accent2) transparent; }
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-track { background: transparent; margin: 4px 0; }
.messages::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent2));
  border-radius: 6px; border: 2px solid transparent; background-clip: padding-box;
  min-height: 40px;
}
.messages::-webkit-scrollbar-thumb:hover { background: linear-gradient(var(--accent2), var(--accent)); background-clip: padding-box; }
.msg-system {
  text-align: center; font-size: 12px; color: var(--text-dim);
  padding: 4px 16px; background: rgba(255,255,255,.03); border-radius: 20px; align-self: center;
}
/* 맨 아래로 내려가기 버튼 (메시지가 위로 스크롤됐을 때만 표시) */
.scroll-bottom-btn {
  position: absolute; right: 18px; bottom: 96px; z-index: 20;
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.45), var(--glow);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(.85);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.scroll-bottom-btn.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.scroll-bottom-btn:hover { filter: brightness(1.12); transform: translateY(-2px) scale(1.05); }
.sbb-arrow { font-size: 26px; line-height: 1; margin-top: -6px; font-weight: 700; }
.sbb-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: #ff3b6b; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  display: none; box-shadow: 0 0 0 2px var(--bg);
}
.sbb-badge.show { display: block; }

.msg-wrap { display: flex; gap: 10px; align-items: flex-end; animation: msgIn .2s ease; }
@keyframes msgIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.msg-wrap.self { flex-direction: row-reverse; }
.msg-avatar { font-size: 28px; flex-shrink: 0; line-height: 1; }

/* 유저 카드 (아바타/닉 클릭 팝업) */
.user-card { position: fixed; z-index: 600; width: 200px; padding: 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.uc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.uc-av { font-size: 30px; line-height: 1; }
.uc-nick { font-weight: 700; }
.uc-handle { font-size: 12px; color: var(--text-dim); }
.uc-btn { width: 100%; padding: 9px; border: none; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.uc-btn:hover { filter: brightness(1.08); }
.uc-note { font-size: 12px; color: var(--text-dim); text-align: center; }
.msg-content { max-width: 65%; }
.msg-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.msg-wrap.self .msg-meta { flex-direction: row-reverse; }
.msg-nick { font-weight: 700; }
.msg-bubble {
  padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap;
}
.msg-wrap:not(.self) .msg-bubble { background: var(--msg-other); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-wrap.self .msg-bubble { background: var(--msg-self); border: 1px solid rgba(193,123,255,.3); border-bottom-right-radius: 4px; box-shadow: var(--glow2); }
.msg-time { font-size: 10px; color: var(--text-dim); align-self: flex-end; flex-shrink: 0; }

/* ===== TYPING / INPUT ===== */
.typing-indicator { min-height: 20px; padding: 2px 20px; font-size: 12px; color: var(--accent); font-style: italic; flex-shrink: 0; }
.input-area {
  padding: 12px 16px; background: var(--bg2); border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-end; position: relative; flex-shrink: 0;
}
.emoji-btn {
  cursor: pointer; padding: 6px 8px; border-radius: 8px; background: var(--bg3);
  border: 1px solid var(--border); user-select: none; transition: background .15s;
  white-space: nowrap; color: var(--text-dim); font-size: 13px; flex-shrink: 0;
}
.emoji-btn:hover { background: var(--border); color: var(--accent); }
#msgInput {
  flex: 1 1 0; min-width: 0;
  padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none;
  transition: border-color .2s; font-family: 'Noto Sans KR', sans-serif;
  /* 자동 줄바꿈되는 여러 줄 입력 */
  resize: none; line-height: 1.4; max-height: 120px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
#msgInput:focus { border-color: var(--accent); box-shadow: var(--glow); }
.send-btn {
  flex-shrink: 0;   /* 전송 버튼은 항상 온전히 보이게 (줄어들지 않음) */
  padding: 10px 18px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 10px; color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: opacity .15s, transform .1s; white-space: nowrap;
}
.send-btn:hover { opacity: .9; }
.send-btn:active { transform: scale(.97); }
/* ===== 이모티콘(스티커) 피커 ===== */
.sticker-picker {
  position: absolute; bottom: 62px; left: 16px; right: 16px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 14px; padding: 12px;
  display: none; gap: 10px; max-height: 280px; overflow-y: auto;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 50;
}
.sticker-picker.open { display: grid; }
.sticker-item {
  width: 100%; aspect-ratio: 1 / 1; object-fit: contain;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px; cursor: pointer; transition: transform .1s, border-color .15s;
}
.sticker-item:hover { transform: scale(1.06); border-color: var(--accent); }
.sticker-empty { grid-column: 1 / -1; text-align: center; color: var(--text-dim); font-size: 13px; line-height: 1.7; padding: 20px; }

/* 채팅에 표시되는 스티커 메시지 (말풍선 배경 없이 큰 이미지) */
.msg-wrap.sticker-msg .msg-bubble { background: none !important; padding: 0 !important; border: none !important; box-shadow: none !important; }
.msg-sticker { width: 140px; height: 140px; object-fit: contain; display: block; }

/* ===== VOLUME CONTROL ===== */
.bc-volume-ctrl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bc-mute-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; padding: 2px 4px; border-radius: 4px; transition: color .15s; line-height: 1;
}
.bc-mute-btn:hover { color: var(--accent3); }
.bc-vol-slider {
  -webkit-appearance: none; appearance: none;
  width: 80px; height: 4px; border-radius: 2px;
  background: var(--border); cursor: pointer; outline: none;
}
.bc-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: var(--accent3); cursor: pointer;
}
.bc-vol-slider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent3); border: none; cursor: pointer;
}

/* ===== MIC BUTTON ===== */
.mic-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 10px; border-radius: 8px; font-size: 16px;
  cursor: pointer; transition: all .15s; flex-shrink: 0; line-height: 1;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text-dim);
}
.mic-btn.active {
  background: rgba(34,197,94,.15); border-color: #22c55e; color: #22c55e;
  animation: micPulse 1.8s ease-in-out infinite;
}
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
.mic-btn.muted {
  background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.5); color: #f43f5e;
}
.mic-btn.no-mic { opacity: .35; cursor: not-allowed; }

/* ===== FILE ATTACH ===== */
.attach-btn {
  padding: 7px 9px; border-radius: 8px; background: var(--bg3);
  border: 1px solid var(--border); cursor: pointer; font-size: 16px; line-height: 1;
  transition: border-color .15s, color .15s; flex-shrink: 0; user-select: none;
  color: var(--text-dim); display: flex; align-items: center; justify-content: center;
}
.attach-btn:hover { border-color: var(--accent2); color: var(--accent2); }

/* ===== FILE MESSAGE ===== */
.msg-image {
  max-width: 280px; max-height: 220px; border-radius: 10px; display: block;
  cursor: pointer; object-fit: contain; border: 1px solid var(--border); transition: opacity .15s;
}
.msg-image:hover { opacity: .85; }
.msg-file-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,.03); min-width: 160px; max-width: 280px;
  text-decoration: none; color: var(--text); transition: background .15s;
}
.msg-file-card:hover { background: rgba(255,255,255,.08); }
.msg-file-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.msg-file-dl { font-size: 14px; flex-shrink: 0; }

/* ===== DRAG-OVER DROP ZONE ===== */
.messages.drag-over {
  outline: 2px dashed var(--accent2); outline-offset: -4px;
  background: rgba(193,123,255,.05);
}

/* ===== GLOBAL SCROLLBAR ===== */
* { scrollbar-width: thin; scrollbar-color: var(--accent2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent2));
  border-radius: 6px; border: 2px solid transparent; background-clip: padding-box;
  min-height: 40px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(var(--accent2), var(--accent)); background-clip: padding-box; }

/* ===== LIGHTBOX ===== */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.88); display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  animation: lbFadeIn .18s ease;
}
@keyframes lbFadeIn { from { opacity:0; } to { opacity:1; } }
.lightbox-inner {
  position: relative; max-width: 92vw; max-height: 86vh;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.lightbox-inner img {
  max-width: 90vw; max-height: 80vh; border-radius: 10px;
  object-fit: contain; box-shadow: 0 0 60px rgba(0,0,0,.8);
  display: block;
}
.lightbox-inner video {
  max-width: 90vw; max-height: 80vh; border-radius: 10px;
  box-shadow: 0 0 60px rgba(0,0,0,.8); background: #000; display: block;
}
.lightbox-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; background: rgba(255,255,255,.07);
  border-radius: 20px; backdrop-filter: blur(6px);
}
.lightbox-name {
  font-size: 13px; color: var(--text); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox-dl {
  padding: 5px 14px; background: linear-gradient(135deg,var(--accent),var(--accent2));
  border: none; border-radius: 12px; color: #fff; font-size: 12px;
  font-weight: 700; cursor: pointer; text-decoration: none;
  transition: opacity .15s; white-space: nowrap;
}
.lightbox-dl:hover { opacity: .85; }
.lightbox-close {
  position: fixed; top: 18px; right: 22px;
  background: rgba(255,255,255,.12); border: none; color: #fff;
  font-size: 22px; width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s; line-height: 1; z-index: 1000;
}
.lightbox-close:hover { background: rgba(255,107,157,.4); }

/* ===== VIDEO MESSAGE ===== */
.msg-video-wrap {
  position: relative; max-width: 280px; border-radius: 10px;
  overflow: hidden; cursor: pointer; border: 1px solid var(--border);
  background: #000;
}
.msg-video-thumb {
  width: 100%; max-height: 180px; object-fit: cover; display: block;
  transition: opacity .15s;
}
.msg-video-wrap:hover .msg-video-thumb { opacity: .75; }
.msg-play-btn {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 36px; pointer-events: none;
}

/* ===== MESSAGE ACTIONS (reply button beside bubble) ===== */
.msg-content { position: relative; }
.msg-actions {
  display: none; position: absolute;
  top: 50%; transform: translateY(-50%);
  gap: 3px; align-items: center; white-space: nowrap; z-index: 10;
}
/* 내 메시지: 말풍선 왼쪽 */
.msg-wrap.self .msg-actions { right: calc(100% + 6px); }
/* 상대방 메시지: 말풍선 오른쪽 */
.msg-wrap:not(.self) .msg-actions { left: calc(100% + 6px); }
.msg-wrap:hover .msg-actions { display: flex; }
.msg-action-btn {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; cursor: pointer;
  padding: 3px 9px; border-radius: 10px; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  transition: color .12s, background .12s, border-color .12s;
}
.msg-action-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(255,107,157,.08); }

/* ===== REPLY QUOTE (in bubble) ===== */
.msg-reply-quote {
  display: flex; border-left: 3px solid var(--accent2);
  background: rgba(193,123,255,.08); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 6px; gap: 6px;
  cursor: pointer; transition: background .12s; min-width: 0;
}
.msg-reply-quote:hover { background: rgba(193,123,255,.16); }
.rq-bar { display: flex; flex-direction: column; min-width: 0; }
.rq-nick { font-size: 11px; font-weight: 700; color: var(--accent2); margin-bottom: 2px; }
.rq-text {
  font-size: 12px; color: var(--text-dim); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 220px;
}

/* ===== REPLY PREVIEW BAR (above input) ===== */
.reply-preview {
  display: none; align-items: center; gap: 8px;
  padding: 6px 16px; background: var(--bg2);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.reply-preview.open { display: flex; }
.rp-bar { width: 3px; height: 32px; background: var(--accent2); border-radius: 2px; flex-shrink: 0; }
.rp-body { flex: 1; min-width: 0; }
.rp-nick { font-size: 11px; font-weight: 700; color: var(--accent2); }
.rp-text { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-cancel {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 18px; padding: 2px 6px; border-radius: 4px;
  transition: color .12s; line-height: 1; flex-shrink: 0;
}
.rp-cancel:hover { color: var(--accent); }

/* ===== READ RECEIPTS ===== */
.msg-reads { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; min-height: 14px; position: relative; cursor: default; }
.msg-wrap.self .msg-reads { justify-content: flex-end; }
.msg-read-av { font-size: 11px; line-height: 1; }
/* 읽음 아이콘 호버 시 이름 잠깐 표시 */
.read-tip {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 4px;
  background: rgba(20,20,40,.96); color: #e8e8ff; border: 1px solid var(--border);
  font-size: 11px; white-space: nowrap; padding: 4px 9px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); pointer-events: none;
  opacity: 0; transform: translateY(3px); transition: opacity .15s, transform .15s; z-index: 30;
}
.msg-reads:hover .read-tip { opacity: 1; transform: translateY(0); }

/* ===== 로그인: 계정 목록 / 코드 ===== */
#accountList { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.account-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.account-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.account-row:active { transform: scale(.99); }
.account-av { font-size: 26px; flex-shrink: 0; line-height: 1; }
.account-info { flex: 1; overflow: hidden; text-align: left; }
.account-nick { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-handle { font-size: 11px; color: var(--text-dim); }
.account-del {
  width: 24px; height: 24px; border: none; background: transparent; color: var(--text-dim);
  font-size: 12px; border-radius: 6px; cursor: pointer; flex-shrink: 0;
}
.account-del:hover { background: rgba(244,63,94,.4); color: #fff; }
.btn-outline {
  width: 100%; margin-top: 8px; padding: 11px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-dim); border-radius: 10px; font-size: 13px;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-outline:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-back {
  width: 100%; margin-top: 8px; padding: 10px; border: none; background: transparent;
  color: var(--text-dim); font-size: 12px; cursor: pointer; font-family: inherit;
}
.btn-back:hover { color: var(--text); }
.code-msg { min-height: 18px; font-size: 12px; color: var(--rose, #f43f5e); margin: 6px 0; }
.profile-code-wrap { margin-bottom: 14px; }
.code-copy-row { display: flex; gap: 6px; }
.code-copy-row input {
  flex: 1; min-width: 0; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); font-size: 11px; font-family: monospace;
}
.code-copy-row button {
  flex-shrink: 0; padding: 8px 14px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent2); color: #fff; font-size: 12px; font-weight: 700; font-family: inherit;
}
.code-copy-row button:hover { opacity: .9; }

/* ===== MENTION DROPDOWN ===== */
.mention-dropdown {
  position: absolute; bottom: 62px; left: 16px; right: 16px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; z-index: 60;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5); display: none; max-height: 180px; overflow-y: auto;
}
.mention-dropdown.open { display: block; }
.mention-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13px;
  transition: background .1s;
}
.mention-item:hover, .mention-item.active { background: rgba(193,123,255,.15); }
.mention-item-nick { font-weight: 700; }

/* ===== HYPERLINK ===== */
.msg-link {
  color: var(--accent3); text-decoration: underline;
  text-underline-offset: 2px; word-break: break-all;
  transition: color .12s, opacity .12s;
}
.msg-link:hover { color: var(--accent2); opacity: .85; }

/* ===== @MENTION HIGHLIGHT ===== */
.msg-mention { color: var(--accent2); font-weight: 700; }

/* ===== MESSAGE HIGHLIGHT FLASH ===== */
@keyframes msgHighlight {
  0%,100% { background: transparent; }
  30%      { background: rgba(193,123,255,.25); }
}
.msg-wrap.highlighted .msg-bubble { animation: msgHighlight .9s ease; border-radius: 16px; }

/* ===== SELF BROADCAST PREVIEW ===== */
.self-preview {
  position: fixed; bottom: 80px; right: 20px; z-index: 200;
  width: 220px; background: #000;
  border: 2px solid var(--accent); border-radius: 12px;
  overflow: hidden; box-shadow: 0 6px 30px rgba(0,0,0,.6);
  user-select: none;
}
.self-preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; background: rgba(229,57,53,.85);
  cursor: grab; gap: 6px;
}
.self-preview-bar:active { cursor: grabbing; }
.self-preview-btns { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.self-preview-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 14px; padding: 0 2px; line-height: 1; flex-shrink: 0;
  opacity: .8; transition: opacity .15s;
}
.self-preview-close:hover { opacity: 1; }
#selfPreviewVideo {
  width: 100%; display: block;
  max-height: 130px; object-fit: contain; background: #000;
}
.self-preview.collapsed #selfPreviewVideo { display: none; }

/* ===== WELCOME BACK CARD ===== */
.welcome-card {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(255,107,157,.12), rgba(193,123,255,.1));
  border: 1px solid rgba(193,123,255,.3); border-radius: 14px;
  padding: 14px 16px; margin: 8px 0 16px;
}
.welcome-avatar { font-size: 34px; flex-shrink: 0; }
.welcome-info { flex: 1; min-width: 0; }
.welcome-nick { font-size: 17px; font-weight: 700; color: var(--text); display: block; }
.welcome-sub  { font-size: 12px; color: var(--text-dim); }
.btn-change-account {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim); font-size: 12px; padding: 5px 10px; cursor: pointer;
  white-space: nowrap; transition: border-color .15s, color .15s; flex-shrink: 0;
}
.btn-change-account:hover { border-color: var(--accent2); color: var(--accent2); }

/* ===== PROFILE MODAL ===== */
.profile-modal-btns {
  display: flex; gap: 10px; margin-top: 22px;
}
.btn-cancel {
  padding: 12px 18px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text-dim); font-size: 14px; cursor: pointer;
  transition: background .15s; white-space: nowrap;
}
.btn-cancel:hover { background: var(--border); }
.my-profile:hover { background: rgba(255,107,157,.1); }
.my-profile:hover::after {
  content: '✏️'; font-size: 13px; margin-left: auto;
}

/* ===== CHAT PANEL (normal mode: takes remaining vertical space) ===== */
.chat-panel {
  display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0;
  position: relative;
}

/* ===== CINEMA / FULLSCREEN MODE ===== */
/* 사이드바 축소 */
.app.cinema-mode .sidebar,
.app.theater-mode .sidebar {
  width: 56px; min-width: 56px; overflow: hidden;
  transition: width .25s ease;
}
.app.cinema-mode .sidebar-logo span:last-child,
.app.cinema-mode .sidebar-section .sidebar-label,
.app.cinema-mode .sidebar-room-body,
.app.cinema-mode .sidebar-users-list,
.app.cinema-mode .my-profile-info,
.app.theater-mode .sidebar-logo span:last-child,
.app.theater-mode .sidebar-section .sidebar-label,
.app.theater-mode .sidebar-room-body,
.app.theater-mode .sidebar-users-list,
.app.theater-mode .my-profile-info { display: none; }
.app.cinema-mode .sidebar-room,
.app.theater-mode .sidebar-room { justify-content: center; padding: 10px 0; }

/* chat-area → 가로 배치 + 명시적 높이 (자식 flex:1 정상 작동) */
.app.cinema-mode .chat-area,
.app.theater-mode .chat-area {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

/* 방송 영역: 좌측 flex 확장 */
.app.cinema-mode .broadcast-list,
.app.theater-mode .broadcast-list { display: none !important; }

.app.cinema-mode .broadcast-panel,
.app.theater-mode .broadcast-panel {
  flex: 1 1 0; min-width: 0;
  max-height: none;
  border-bottom: none; border-right: 1px solid var(--border);
}
.app.cinema-mode .bc-video-wrap,
.app.theater-mode .bc-video-wrap { flex: 1; min-height: 0; }
.app.cinema-mode #broadcastVideo,
.app.theater-mode #broadcastVideo,
.app.cinema-mode .bc-self-video,
.app.theater-mode .bc-self-video {
  max-height: none; height: 100%; width: 100%; object-fit: contain;
}
.app.cinema-mode .bc-video-wrap.split #broadcastVideo,
.app.cinema-mode .bc-video-wrap.split .bc-self-video,
.app.theater-mode .bc-video-wrap.split #broadcastVideo,
.app.theater-mode .bc-video-wrap.split .bc-self-video { width: 50%; }

/* 채팅 패널: 우측 고정 폭(넓게 확보), 전체 높이 */
.app.cinema-mode .chat-panel,
.app.theater-mode .chat-panel {
  flex: 0 0 380px; min-width: 340px; max-width: 420px;
  display: flex; flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

/* 영화관/전체화면 입력칸: 이모지·파일·입력·전송만 남기고 방송/마이크/화질 숨김 */
.app.cinema-mode .input-area .bc-start-btn,
.app.cinema-mode .input-area .mic-btn,
.app.cinema-mode .input-area .quality-select,
.app.theater-mode .input-area .bc-start-btn,
.app.theater-mode .input-area .mic-btn,
.app.theater-mode .input-area .quality-select { display: none !important; }

/* 🎬 active 상태 */
.bc-cinema-btn.active { color: var(--accent3); background: rgba(107,223,255,.12); }

/* cinema / fullscreen buttons */
.bc-cinema-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 15px; padding: 3px 6px; border-radius: 5px;
  transition: color .15s, background .15s; line-height: 1;
}
.bc-cinema-btn:hover { color: var(--accent3); background: rgba(107,223,255,.12); }
.bc-cinema-btn.active { color: var(--accent3); }

/* ===== MOBILE ===== */
@media (max-width: 768px) {

  /* 전체 높이: dvh(dynamic viewport) 사용 → 키보드 올라와도 안 잘림 */
  html, body { height: 100%; height: 100dvh; }
  .app { height: 100dvh; }

  /* ── 햄버거 버튼 ── */
  .menu-btn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text);
    font-size: 22px; line-height: 1; padding: 4px 6px;
    border-radius: 6px; cursor: pointer; flex-shrink: 0;
    min-width: 36px; min-height: 36px;
  }

  /* ── 사이드바: 오버레이 드로어 ── */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 260px !important; min-width: 260px !important;
    z-index: 300; transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 6px 0 30px rgba(0,0,0,.5);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }

  /* 드로어 백드롭 */
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.55); z-index: 299;
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  .app.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: all; }

  /* 사이드바 안 텍스트 모두 표시 */
  .sidebar-logo span:last-child, .sidebar-label, .sidebar-room-name,
  .sidebar-room-count, .sidebar-user .user-nick, .my-profile-info { display: revert; }
  .sidebar-room { padding: 8px 14px; justify-content: flex-start; }
  .sidebar-users-list { max-height: 200px; }

  /* ── 채팅 영역 ── */
  .chat-area { flex: 1; min-width: 0; }
  .msg-content { max-width: 82%; }

  /* 입력창 iOS 줌 방지 (font-size < 16px 이면 자동 줌) */
  #msgInput { font-size: 16px; }

  /* 입력 영역: 방송 관련 버튼 숨김 */
  .bc-start-btn, .quality-select { display: none; }

  /* 터치 타겟 최소화 (44px) */
  .send-btn, .attach-btn, .emoji-btn, .notif-btn {
    min-height: 44px; min-width: 44px;
    display: flex; align-items: center; justify-content: center;
  }
  .input-area { padding: 8px 10px; gap: 6px; }

  /* ── 로그인 모달 ── */
  .modal-overlay { align-items: flex-end; }
  .modal-box {
    padding: 24px 18px 32px;
    width: 100%; border-radius: 20px 20px 0 0;
    max-height: 92dvh; overflow-y: auto;
  }
  .room-select { grid-template-columns: 1fr; }
  .bc-dim { display: none; }

  /* ── 방송 목록 ── */
  .bc-list-item { padding: 4px 8px; }

  /* ── 라이트박스 ── */
  .lightbox-inner img, .lightbox-inner video { max-width: 98vw; }

  /* ── 모바일은 영화관 모드 없음 → 🎬 버튼 숨김 ── */
  #cinemaBtn { display: none !important; }

  /* ── 전체화면(⛶): 방송 영상이 화면 전체(가로)를 채움, 채팅은 숨김 ── */
  .app.theater-mode .chat-area {
    flex-direction: column;
    height: 100dvh;
  }
  .app.theater-mode .sidebar { transform: translateX(-100%); }
  .app.theater-mode .broadcast-panel {
    flex: 1; height: 100dvh; max-height: none;
    border: none; width: 100%;
  }
  .app.theater-mode .bc-video-wrap { flex: 1; min-height: 0; }
  .app.theater-mode #broadcastVideo,
  .app.theater-mode .bc-self-video {
    width: 100%; height: 100%; max-height: none; object-fit: contain;
  }
  /* 전체화면에서는 채팅 패널을 숨겨 방송이 가로 전체를 쓰게 함 (헤더 컨트롤만 남김) */
  .app.theater-mode .chat-panel { display: none; }

  /* ── 내 방송 미리보기 ── */
  .self-preview { width: 140px; bottom: 70px; right: 10px; }
}

/* =====================================================
   KAKAO-STYLE TOAST NOTIFICATIONS
   ===================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 320px;
  width: 320px;
}

.toast {
  pointer-events: all;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px 16px;
  background: rgba(18, 18, 40, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.55), 0 0 0 1px rgba(255,107,157,.08);
  cursor: pointer;
  overflow: hidden;
  animation: toastIn .28s cubic-bezier(.17,.67,.35,1.15);
  transition: opacity .25s, transform .25s;
}
.toast:hover { border-left-color: var(--accent2); box-shadow: 0 10px 36px rgba(0,0,0,.65); }
.toast.toast-out {
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
}
.toast.mention { border-left-color: var(--accent3); box-shadow: 0 8px 30px rgba(107,223,255,.15); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(28px) scale(.96); }
  to   { opacity: 1; transform: translateX(0)    scale(1);   }
}

/* 아바타 */
.toast-avatar {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

/* 바디 */
.toast-body { flex: 1; min-width: 0; }
.toast-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.toast-nick {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px;
}
.toast-room {
  font-size: 11px; color: var(--text-dim);
  background: var(--bg3); border-radius: 6px; padding: 1px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 80px;
}
.toast-msg {
  font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.5;
}

/* 닫기 버튼 */
.toast-close-btn {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-dim);
  font-size: 13px; cursor: pointer; line-height: 1; padding: 2px 4px;
  border-radius: 4px; transition: color .15s, background .15s;
}
.toast-close-btn:hover { color: var(--text); background: var(--bg3); }

/* 하단 진행 바 */
.toast-bar {
  position: absolute; bottom: 0; left: 0;
  height: 3px; border-radius: 0 0 13px 13px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  animation: toastBarShrink var(--dur, 4s) linear forwards;
}
.toast.mention .toast-bar { background: linear-gradient(90deg, var(--accent3), var(--accent)); }

@keyframes toastBarShrink {
  from { width: 100%; }
  to   { width: 0%;   }
}

@media (max-width: 768px) {
  .toast-container { bottom: 80px; right: 12px; left: 12px; width: auto; max-width: none; }
  .toast { max-width: 100%; }
}
