/* ─── Discord 테마 변수 ──────────────────────────────────── */
:root {
  --bg-primary: #36393f;
  --bg-secondary: #2f3136;
  --bg-tertiary: #202225;
  --bg-modifier-hover: #34373c;
  --bg-modifier-active: #393c43;
  --bg-modifier-selected: #3f4248;
  --bg-accent: #40444b;
  --bg-floating: #18191c;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --text-normal: #dcddde;
  --text-muted: #72767d;
  --text-link: #00aff4;
  --header-primary: #fff;
  --header-secondary: #b9bbbe;
  --online: #3ba55d;
  --idle: #faa61a;
  --offline: #747f8d;
  --danger: #ed4245;
  --positive: #3ba55d;
  --border-subtle: rgba(255,255,255,.06);
  --radius: 4px;
  --radius-md: 8px;
  --font-ui: 'Malgun Gothic', '맑은 고딕', 'Noto Sans KR', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-message: 'Malgun Gothic', '맑은 고딕', 'Noto Sans KR', sans-serif;
  --fs-xxs: clamp(9px, .58vw, 10px);
  --fs-xs: clamp(10px, .64vw, 11px);
  --fs-sm: clamp(11px, .72vw, 12px);
  --fs-base: clamp(12px, .82vw, 13px);
  --fs-md: clamp(13px, .9vw, 14px);
  --fs-lg: clamp(16px, 1.15vw, 18px);
  --fs-xl: clamp(20px, 1.4vw, 22px);
  --fs-message: 10pt;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-normal);
  height: 100vh;
  overflow: hidden;
  font-size: var(--fs-base);
  line-height: 1.375;
}

/* ─── 로그인 ──────────────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-tertiary);
}

.auth-box {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 32px;
  width: 400px;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}

.auth-logo { text-align: center; margin-bottom: 20px; }
.discord-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; background: var(--brand);
  border-radius: 16px; font-weight: 800; font-size: var(--fs-xl); color: #fff;
  margin-bottom: 8px;
}
.auth-logo h1 { font-size: var(--fs-xl); color: var(--header-primary); font-weight: 700; }
.auth-logo p { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; }

.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle); padding-bottom: 0;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--text-muted);
  padding: 10px 0; cursor: pointer; font-size: var(--fs-base); font-weight: 500;
  border-bottom: 2px solid transparent; transition: color .2s;
}
.tab-btn.active { color: var(--header-primary); border-bottom-color: var(--brand); }
.tab-btn:hover:not(.active) { color: var(--text-normal); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em; color: var(--header-secondary);
}
.form-group input {
  background: var(--bg-tertiary); border: none; border-radius: var(--radius);
  color: var(--text-normal); padding: 10px 12px; font-size: var(--fs-md); outline: none;
}
.form-group input:focus { outline: 2px solid var(--brand); }

.auth-note { color: var(--text-muted); font-size: var(--fs-xs); text-align: center; }

.auth-message {
  margin-top: 12px; padding: 10px; border-radius: var(--radius);
  font-size: var(--fs-sm); text-align: center;
}
.auth-message.error { background: rgba(237,66,69,.15); color: var(--danger); }
.auth-message.success { background: rgba(59,165,93,.15); color: var(--positive); }

/* ─── 버튼 공통 ──────────────────────────────────────────── */
.btn-primary {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius); padding: 12px; font-size: var(--fs-base);
  font-weight: 600; cursor: pointer; transition: background .2s; width: 100%;
}
.btn-primary:hover { background: var(--brand-hover); }

.icon-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: color .15s;
}
.icon-btn:hover { color: var(--text-normal); }

.btn-start-chat {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius); padding: 8px 12px; font-size: var(--fs-sm);
  font-weight: 600; cursor: pointer; width: 100%;
  transition: background .17s;
}
.btn-start-chat:hover { background: var(--brand-hover); }

/* ─── 메인 레이아웃 ──────────────────────────────────────── */
#app-page { display: flex; height: 100vh; }

.panel {
  display: flex; flex-direction: column; overflow: hidden;
  flex-shrink: 0;
}

.panel-users   { width: 15%; min-width: 120px; background: var(--bg-secondary); }
.panel-rooms   { width: 20%; min-width: 140px; background: var(--bg-secondary); border-left: 1px solid var(--bg-tertiary); }
.panel-chat    { flex: 1; min-width: 200px; background: var(--bg-primary); display: flex; flex-direction: column; flex-shrink: 1; }
.panel-members { width: 15%; min-width: 120px; background: var(--bg-secondary); border-left: 1px solid var(--bg-tertiary); }

/* 리사이즈 핸들 */
.resize-handle {
  width: 4px; cursor: col-resize;
  background: transparent; flex-shrink: 0;
  position: relative; z-index: 10;
  transition: background .15s;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--brand);
}
.resize-handle::before {
  content: ''; position: absolute;
  top: 0; bottom: 0; left: -3px; right: -3px;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; height: 48px;
  border-bottom: 1px solid var(--bg-tertiary);
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  flex-shrink: 0;
}
.panel-title {
  font-weight: 600; font-size: var(--fs-sm); color: var(--header-secondary);
  text-transform: uppercase; letter-spacing: .02em;
}

.panel-scroll {
  overflow-y: auto; flex: 1; padding: 4px 8px;
}
.panel-scroll::-webkit-scrollbar { width: 12px; }
.panel-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,.18); }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border: 3px solid transparent; background-clip: padding-box; border-radius: 6px; }

.stealth-members-section { display: none; }

/* ─── 사용자 목록 ────────────────────────────────────────── */
.my-tag {
  font-size: var(--fs-xxs); color: var(--brand);
  background: rgba(88,101,242,.15); padding: 1px 8px;
  border-radius: 10px;
}

.action-bar { padding: 8px; flex-shrink: 0; }

.section-label {
  padding: 18px 16px 4px; font-size: var(--fs-xxs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em;
  color: var(--text-muted); flex-shrink: 0;
}

.user-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; cursor: pointer;
  border-radius: var(--radius); transition: background .12s;
}
.user-item:hover { background: var(--bg-modifier-hover); }
.user-item.selected { background: var(--bg-modifier-selected); }
.user-item.self { cursor: default; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm); color: #fff;
  flex-shrink: 0; position: relative;
}
.avatar-sm { width: 24px; height: 24px; font-size: var(--fs-sm); }

.status-badge {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  position: absolute; bottom: -1px; right: -1px;
}
.status-badge.online  { background: var(--online); }
.status-badge.offline { background: var(--offline); }

.user-info { overflow: hidden; }
.user-name {
  font-size: var(--fs-base); font-weight: 500; color: var(--text-normal);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.user-sub {
  font-size: var(--fs-xs); color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}

.panel-footer {
  padding: 8px; border-top: 1px solid var(--bg-tertiary);
  background: rgba(0,0,0,.15); flex-shrink: 0;
}
.my-info {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); font-weight: 600;
}
.status-text { font-size: var(--fs-xxs); font-weight: 400; }
.status-text.online { color: var(--online); }

/* ─── 대화방 목록 ────────────────────────────────────────── */
.room-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; cursor: pointer;
  border-radius: var(--radius); transition: background .12s;
  margin-bottom: 1px;
}
.room-item:hover { background: var(--bg-modifier-hover); }
.room-item.active { background: var(--bg-modifier-selected); }

.room-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; color: #fff; flex-shrink: 0;
}

.room-info { overflow: hidden; flex: 1; }
.room-name {
  font-size: var(--fs-base); font-weight: 500; color: var(--text-normal);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room-meta { font-size: var(--fs-xxs); color: var(--text-muted); margin-top: 2px; }
.room-members-count { font-weight: 600; }
.room-members-detail { margin-left: 2px; }
.rm-online { color: var(--online); }
.rm-offline { color: var(--offline); }

/* ─── 채팅 영역 ──────────────────────────────────────────── */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 48px;
  border-bottom: 1px solid var(--bg-tertiary);
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  flex-shrink: 0; background: var(--bg-primary);
}
.chat-header-left { display: flex; align-items: center; gap: 6px; }
.chat-icon {
  font-weight: 700; font-size: var(--fs-lg); color: var(--text-muted); margin-right: 4px;
}
#chat-room-name { font-weight: 700; font-size: var(--fs-sm); color: var(--header-primary); }
.badge-e2e {
  font-size: var(--fs-xxs); color: var(--positive); background: rgba(59,165,93,.15);
  padding: 2px 6px; border-radius: 3px; font-weight: 700;
}
.chat-header-right { display: flex; gap: 8px; align-items: center; position: relative; }

/* 방 설정 드롭다운 */
.room-menu-wrap { position: relative; }
.room-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-floating); border-radius: var(--radius);
  padding: 6px; min-width: 180px; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; background: none; border: none;
  color: var(--text-normal); font-size: var(--fs-sm); cursor: pointer;
  border-radius: 3px; text-align: left;
}
.dropdown-item:hover { background: var(--brand); color: #fff; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger); color: #fff; }
.dropdown-item svg { flex-shrink: 0; }

.messages-area {
  flex: 1; overflow-y: auto; padding: 16px 0;
  display: flex; flex-direction: column;
}
.messages-area::-webkit-scrollbar { width: 12px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border: 3px solid transparent; background-clip: padding-box; border-radius: 6px; }

.welcome-msg {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; color: var(--text-muted);
  text-align: center; gap: 8px;
}
.welcome-msg h2 { color: var(--header-primary); font-size: var(--fs-xl); }
.welcome-msg p { line-height: 1.6; }

/* 날짜 구분 */
.date-divider {
  display: flex; align-items: center; margin: 16px 16px 8px; gap: 8px;
}
.date-divider::before, .date-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--bg-accent);
}
.date-divider span {
  font-size: var(--fs-xxs); font-weight: 700; color: var(--text-muted);
  white-space: nowrap;
}

/* 메시지 (디스코드 스타일) */
.msg-group {
  display: flex; padding: 2px 16px; gap: 16px;
  transition: background .1s;
}
.msg-group:hover { background: rgba(0,0,0,.06); }
.msg-group.first-in-group { margin-top: 16px; }

.msg-avatar-col { flex-shrink: 0; width: 40px; padding-top: 2px; }
.msg-avatar-col .avatar { width: 40px; height: 40px; font-size: var(--fs-sm); }

.msg-body { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-author { font-weight: 600; font-size: var(--fs-sm); cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.msg-timestamp { font-size: var(--fs-xxs); color: var(--text-muted); }
.msg-delete-btn {
  display: none; background: none; border: 0; color: var(--text-muted);
  padding: 1px 4px; font-size: var(--fs-xxs); cursor: pointer;
}
.msg-group.mine:hover .msg-delete-btn { display: inline-block; }
.msg-delete-btn:hover { color: #ed4245; text-decoration: underline; }

.msg-text {
  color: var(--text-normal); word-break: break-word;
  white-space: pre-wrap; line-height: 1.45;
  font-family: var(--font-message);
  font-size: var(--fs-message);
}

/* 내 메시지 (오른쪽 정렬) */
.msg-group.mine {
  flex-direction: row-reverse;
}
.msg-group.mine .msg-body {
  display: flex; flex-direction: column; align-items: flex-end;
}
.msg-group.mine .msg-header {
  flex-direction: row-reverse;
}
.msg-group.mine .msg-text {
  background: var(--brand); color: #fff;
  padding: 8px 12px; border-radius: 16px 4px 16px 16px;
  display: inline-block; max-width: 100%;
}
.msg-group.mine .file-attachment {
  direction: rtl;
}

/* 상대 메시지 말풍선 */
.msg-group:not(.mine) .msg-text {
  background: var(--bg-secondary);
  padding: 8px 12px; border-radius: 4px 16px 16px 16px;
  display: inline-block; max-width: 100%;
}

/* 연속 메시지 (아바타 없음) */
.msg-group.continuation {
  margin-top: 0; padding-top: 0; padding-bottom: 0;
}
.msg-group.continuation .msg-avatar-col { visibility: hidden; height: 0; padding: 0; }
.msg-group.continuation .msg-header { display: none; }

/* 파일 메시지 */
.file-attachment {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-secondary); border: 1px solid var(--bg-accent);
  border-radius: var(--radius-md); padding: 12px 16px;
  margin-top: 4px; max-width: 400px; cursor: pointer;
  transition: background .15s;
}
.file-attachment:hover { background: var(--bg-modifier-hover); }

.document-attachment {
  display: flex; align-items: center; gap: 10px; min-width: 260px;
  padding: 10px 12px; background: var(--bg-secondary);
  border: 1px solid rgba(88,101,242,.35); border-radius: var(--radius-md);
}
.document-attachment-icon {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: rgba(88,101,242,.2); color: #aeb5ff;
  font-size: 22px; flex-shrink: 0;
}
.document-attachment-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.document-attachment-info strong { color: var(--header-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-attachment-info span { color: var(--text-muted); font-size: var(--fs-xs); }
.document-closed-label { color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.file-icon { font-size: 28px; }
.file-details { flex: 1; overflow: hidden; }
.file-fname {
  font-weight: 500; color: var(--text-link); font-size: var(--fs-base);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-fsize { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.file-download-icon { color: var(--text-muted); }
.file-expired {
  display: inline-flex; align-items: center;
  min-height: 42px; margin-top: 4px; padding: 10px 14px;
  color: var(--text-muted); background: var(--bg-secondary);
  border: 1px solid var(--bg-accent); border-radius: var(--radius-md);
  font-size: var(--fs-sm); cursor: default;
}

/* ─── 입력 영역 ──────────────────────────────────────────── */
.input-area {
  padding: 0 16px 24px; flex-shrink: 0;
}
.input-wrapper {
  display: flex; align-items: flex-end;
  background: var(--bg-accent); border-radius: var(--radius-md);
  padding: 2px 4px 2px 12px;
}

.attach-btn {
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; padding: 8px 4px;
  transition: color .15s;
}
.attach-btn:hover { color: var(--text-normal); }

#msg-input {
  flex: 1; background: none; border: none; color: var(--text-normal);
  padding: 10px 12px; font-size: var(--fs-message); line-height: 1.45; outline: none;
  font-family: var(--font-message); resize: none; overflow-y: auto; min-height: 40px; max-height: 160px;
}
#msg-input::placeholder { color: var(--text-muted); }
#msg-input:disabled { opacity: .5; }

.send-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 8px; display: flex; align-items: center;
  border-radius: var(--radius); transition: color .15s;
}
.send-btn:hover { color: var(--brand); }
.send-btn:disabled { opacity: .3; cursor: default; }

/* ─── 참가자 목록 ────────────────────────────────────────── */
.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; border-radius: var(--radius);
  transition: background .12s; cursor: default;
}
.member-item:hover { background: var(--bg-modifier-hover); }
.member-name { font-size: var(--fs-sm); font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state {
  color: var(--text-muted); font-size: var(--fs-sm);
  text-align: center; padding: 20px 12px;
}

/* 멤버 추가 버튼 */
.add-member-wrap { padding: 8px; flex-shrink: 0; }
.btn-add-member {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: transparent; border: 1px dashed var(--offline);
  border-radius: var(--radius); color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.btn-add-member:hover {
  border-color: var(--brand); color: var(--brand);
  background: rgba(88,101,242,.1);
}
.btn-add-member svg { flex-shrink: 0; }

/* ─── 모달 ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg-primary); border-radius: var(--radius-md);
  width: 440px; max-height: 600px; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--bg-tertiary);
}
.modal-header h3 { font-size: clamp(14px, 1vw, 15px); color: var(--header-primary); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-hint { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 12px; }

.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}
.btn-cancel {
  background: none; border: none; color: var(--text-muted);
  padding: 8px 16px; font-size: var(--fs-base); cursor: pointer;
  border-radius: var(--radius); font-weight: 500;
}
.btn-cancel:hover { text-decoration: underline; color: var(--text-normal); }
.btn-primary-sm {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius); padding: 8px 20px;
  font-size: var(--fs-base); font-weight: 600; cursor: pointer;
}
.btn-primary-sm:hover { background: var(--brand-hover); }
.btn-danger-sm {
  background: #ed4245; color: #fff; border: none;
  border-radius: var(--radius); padding: 6px 16px;
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.btn-danger-sm:hover { background: #c03537; }

/* 텔레그램 연동 */
.telegram-setup {
  display: flex; flex-direction: column; gap: 8px;
}
.telegram-setup input[type="text"] {
  width: 100%; padding: 8px 10px;
  background: var(--bg-primary); border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius); color: var(--text-normal); font-size: var(--fs-sm);
}
.telegram-btn-row {
  display: flex; align-items: center; gap: 8px;
}
.telegram-status {
  font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 10px;
}
.telegram-status.connected {
  color: #57f287; background: rgba(87, 242, 135, 0.1);
}
.telegram-status.disconnected {
  color: var(--text-muted); background: rgba(255,255,255,0.05);
}

/* 텔레그램 방 아이콘 */
.room-item .room-avatar[style*="0088cc"] {
  font-size: clamp(15px, 1.05vw, 16px);
}

/* 메시지 컨텍스트 메뉴 */
.msg-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  padding: 4px 0;
  min-width: 100px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.ctx-item {
  padding: 8px 14px;
  font-size: var(--fs-sm);
  color: var(--text-normal);
  cursor: pointer;
  white-space: nowrap;
}
.ctx-item:hover { background: var(--brand-color); color: #fff; }
.ctx-delete { color: #ed4245; }
.ctx-delete:hover { background: #ed4245; color: #fff; }

.modal-body .form-group { margin-bottom: 8px; }
.modal-body .form-group input {
  background: var(--bg-tertiary); border: none; border-radius: var(--radius);
  color: var(--text-normal); padding: 10px 12px; font-size: var(--fs-md);
  outline: none; width: 100%;
}
.modal-body .form-group input:focus { outline: 2px solid var(--brand); }

.invite-list { display: flex; flex-direction: column; gap: 4px; }
.invite-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg-secondary);
  border-radius: var(--radius); transition: background .12s;
}
.invite-item:hover { background: var(--bg-modifier-hover); }
.invite-item-left { display: flex; align-items: center; gap: 10px; }
.btn-invite {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius); padding: 6px 14px;
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.btn-invite:hover { background: var(--brand-hover); }

/* ─── 파일 진행률 ────────────────────────────────────────── */
.file-progress {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-floating); border-radius: var(--radius-md);
  padding: 12px 20px; width: 340px; z-index: 50;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: 12px;
}
.fp-name { font-size: var(--fs-xs); color: var(--text-normal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.fp-track { flex: 1; background: var(--bg-accent); border-radius: 4px; height: 6px; overflow: hidden; }
.fp-fill { background: var(--brand); height: 100%; width: 0%; transition: width .15s; border-radius: 4px; }
.fp-pct { font-size: var(--fs-xs); color: var(--text-muted); min-width: 32px; text-align: right; }

/* ─── 알림 토스트 ────────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  background: var(--bg-floating); border-radius: var(--radius-md);
  padding: 12px 16px; font-size: var(--fs-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  max-width: 320px; animation: toastIn .25s ease;
  border-left: 3px solid var(--brand);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--positive); }
.toast.info { border-left-color: var(--brand); }

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── 읽음 표시 (메시지 옆 숫자) ─────────────────────────── */
.msg-unread-badge {
  font-size: var(--fs-xxs); color: var(--brand);
  font-weight: 700; min-width: 14px;
  text-align: center; padding: 0 2px;
  align-self: flex-end; margin-bottom: 2px;
  flex-shrink: 0;
}

/* ─── 안읽은 메시지 뱃지 (대화방 목록) ──────────────────── */
.unread-badge {
  background: var(--danger); color: #fff;
  font-size: var(--fs-xxs); font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px; display: flex;
  align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}

/* ─── 로그인 정보 저장 체크박스 ──────────────────────────── */
.remember-check {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: var(--fs-sm);
  cursor: pointer; margin-top: -4px;
}
.remember-check input[type="checkbox"] {
  accent-color: var(--brand);
  width: 16px; height: 16px;
}
.profile-check {
  margin-top: 4px;
  margin-bottom: 16px;
}

/* ─── 이미지 메시지 ─────────────────────────────────────── */
.image-attachment {
  margin-top: 4px; max-width: 400px;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--bg-accent);
}
.msg-image {
  display: block; max-width: 100%; max-height: 300px;
  cursor: pointer; border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: opacity .15s;
}
.msg-image:hover { opacity: .9; }
.image-info {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; cursor: pointer;
  transition: background .15s;
}
.image-info:hover { background: var(--bg-modifier-hover); }
.image-info .file-fname {
  font-size: var(--fs-xs); color: var(--text-link);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.image-info .file-fsize { font-size: var(--fs-xxs); color: var(--text-muted); flex-shrink: 0; }

/* ─── 붙여넣기 미리보기 ────────────────────────────────── */
.paste-preview-img {
  max-width: 100%; max-height: 300px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-accent);
  margin-bottom: 8px;
}
.paste-preview-name {
  font-size: var(--fs-sm); color: var(--text-muted);
  margin-bottom: 4px;
}

/* ─── 이미지 뷰어 (전체화면) ─────────────────────────── */
.image-viewer-fullscreen {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.92);
  overflow: hidden;
  cursor: default;
}
.image-viewer-fullscreen .image-viewer-img {
  position: absolute;
  transform-origin: 0 0;
  user-select: none;
  transition: none;
}
.image-viewer-toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 210;
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.6); border-radius: var(--radius-md);
  padding: 4px 8px;
}
.image-viewer-zoom-text {
  font-size: var(--fs-xs); color: #ccc; min-width: 40px;
  text-align: center; margin-right: 4px;
}
.image-viewer-btn {
  background: none; border: none; color: #ccc;
  font-size: var(--fs-base); font-weight: 600; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.image-viewer-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.image-viewer-close-btn { margin-left: 4px; }

/* ─── 검색 UI ──────────────────────────────────────────── */
.search-wrap {
  position: absolute;
  right: 80px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-accent);
  border-radius: 4px;
  padding: 2px 6px;
  gap: 4px;
}
.search-icon-svg { opacity: 0.5; flex-shrink: 0; }
.search-input-wrap input {
  background: transparent;
  border: none;
  color: var(--text-normal);
  font-size: var(--fs-sm);
  width: 180px;
  padding: 4px;
  outline: none;
}
.search-count {
  font-size: var(--fs-xxs);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 50px;
  text-align: center;
}
.search-nav-btn {
  padding: 2px !important;
  width: 22px !important;
  height: 22px !important;
}
.search-highlight {
  background: rgba(88, 101, 242, 0.25) !important;
  border-left: 3px solid #5865f2;
  animation: searchPulse 1.5s ease-out;
}
@keyframes searchPulse {
  0% { background: rgba(88, 101, 242, 0.5); }
  100% { background: rgba(88, 101, 242, 0.25); }
}

/* ─── 무한 스크롤 로딩 ─────────────────────────────────── */
.load-more-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--bg-accent);
  border-top-color: #5865f2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── 방장 관련 ─────────────────────────────────────────── */
.owner-tag {
  font-size: var(--fs-xxs); color: var(--idle);
  background: rgba(250,166,26,.15); padding: 1px 8px;
  border-radius: 10px; font-weight: 600;
  margin-left: 4px;
}
.owner-tag:empty { display: none; }

.owner-badge {
  font-size: var(--fs-xxs); color: var(--idle);
  background: rgba(250,166,26,.15); padding: 1px 6px;
  border-radius: 8px; font-weight: 700;
  margin-left: 4px;
}

.btn-transfer-owner {
  background: none; border: none; cursor: pointer;
  font-size: var(--fs-base); padding: 2px 4px; border-radius: var(--radius);
  opacity: 0; transition: opacity .15s;
  margin-left: auto;
}
.member-item:hover .btn-transfer-owner { opacity: 1; }
.btn-transfer-owner:hover { background: rgba(250,166,26,.2); }

.btn-edit-name { margin-left: 2px; }

.room-name-edit {
  display: flex; align-items: center; gap: 4px;
}
.room-name-edit input {
  background: var(--bg-tertiary); border: 1px solid var(--brand);
  border-radius: var(--radius); color: var(--text-normal);
  padding: 4px 8px; font-size: var(--fs-base); outline: none;
  width: 200px;
}
.btn-primary-xs {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius); padding: 4px 10px;
  font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
}
.btn-primary-xs:hover { background: var(--brand-hover); }
.btn-cancel-xs {
  background: none; border: none; color: var(--text-muted);
  padding: 4px 8px; font-size: var(--fs-xs); cursor: pointer;
}
.btn-cancel-xs:hover { color: var(--text-normal); }
.btn-danger-xs {
  background: none; border: none; color: #ed4245;
  padding: 4px 8px; font-size: var(--fs-xs); cursor: pointer;
}
.btn-danger-xs:hover { color: #ff6b70; text-decoration: underline; }

/* ─── 공유 문서 ───────────────────────────────────────────── */
.doc-header-btn {
  background: rgba(88,101,242,.18); border: 1px solid rgba(88,101,242,.35);
  color: #c9cdfd; border-radius: var(--radius); padding: 5px 9px;
  font-size: var(--fs-xs); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.doc-header-btn:hover { background: rgba(88,101,242,.32); color: #fff; }

.document-modal {
  width: min(1100px, 94vw); height: min(760px, 92vh);
  background: var(--bg-primary); border-radius: var(--radius-md);
  box-shadow: 0 10px 45px rgba(0,0,0,.65); display: flex; flex-direction: column;
  overflow: hidden;
}
.document-modal.document-modal-fullscreen {
  width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0;
}
.document-modal.document-modal-fullscreen .shared-document-grid { min-height: 0; }
.document-modal-body { display: flex; flex: 1; min-height: 0; }
.shared-document-sidebar {
  width: 260px; flex-shrink: 0; padding: 14px; background: var(--bg-secondary);
  border-right: 1px solid var(--bg-tertiary); overflow-y: auto;
}
.shared-document-sidebar > .btn-primary-sm { width: 100%; margin-bottom: 12px; }
.shared-document-list { display: flex; flex-direction: column; gap: 6px; }
.shared-document-item {
  display: flex; align-items: center; gap: 8px; padding: 9px;
  border-radius: var(--radius); background: rgba(0,0,0,.12);
}
.shared-document-item:hover { background: var(--bg-modifier-hover); }
.shared-document-item-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.shared-document-item-info strong { color: var(--header-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-document-item-info span { color: var(--text-muted); font-size: var(--fs-xxs); }
.shared-document-item button:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.shared-document-editor { min-width: 0; flex: 1; display: flex; flex-direction: column; padding: 14px; }
.shared-document-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 72px; margin-bottom: 10px; }
.shared-document-status { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 28px; overflow: hidden; white-space: nowrap; }
.shared-document-toolbar strong { color: var(--header-primary); font-size: var(--fs-md); flex: 0 0 auto; }
.shared-document-status-badge { flex: 0 0 auto; padding: 2px 7px; border-radius: 10px; font-size: var(--fs-xxs); font-weight: 600; }
.shared-document-status-badge.draft { color: #d8b4fe; background: rgba(155,89,255,.16); }
.shared-document-status-badge.shared { color: #57f287; background: rgba(87,242,135,.14); }
.shared-document-status-badge.ended { color: #faa61a; background: rgba(250,166,26,.14); }
.shared-document-presence { color: var(--online); font-size: var(--fs-xs); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-document-selection { color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.shared-document-shortcuts { color: var(--text-muted); font-size: var(--fs-xxs); white-space: nowrap; }
.shared-document-actions { display: flex; align-items: center; gap: 8px; min-height: 32px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.shared-document-actions::-webkit-scrollbar { display: none; }
.shared-document-actions button:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.shared-document-style-control { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; color: var(--text-muted); font-size: var(--fs-xxs); white-space: nowrap; }
.shared-document-format-toolbar { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; padding: 3px 4px; border: 0; border-bottom: 1px solid #c7cbd1; background: #f5f6f8; }
.shared-document-format-toolbar .shared-document-style-control { height: 27px; border-color: #d4d7dc; background: #fff; color: #1f2937; }
.document-font-family-select { width: 132px; }
.document-font-size-select { width: 54px; }
.document-format-separator { width: 1px; height: 22px; margin: 0 3px; background: #d3d6db; }
.document-format-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 27px; padding: 2px; border: 0; border-radius: 3px; background: transparent; color: #374151; font-size: 15px; cursor: pointer; }
.document-format-icon:hover { background: #e4e7eb; }
.document-format-icon.active { background: #dbe7f8; box-shadow: inset 0 0 0 1px #7aa7e8; color: #174ea6; }
.document-format-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.document-format-thin { font-weight: 300; }
.document-format-bold { font-weight: 700; }
.shared-document-color-picker { position: relative; display: inline-flex; }
.shared-document-color-trigger { position: relative; display: inline-flex; align-items: flex-start; justify-content: center; width: 29px; height: 27px; padding: 1px 3px 5px; border: 0; border-radius: 3px; background: transparent; color: #374151; cursor: pointer; }
.shared-document-color-trigger:hover { background: #e4e7eb; }
.document-color-trigger-icon { display: block; border: 0; background: transparent; color: inherit; font-size: 16px; font-weight: 600; line-height: 18px; }
.document-fill-color-trigger .document-color-trigger-icon { font-size: 14px; transform: rotate(-12deg); }
.document-color-trigger-bar { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 4px; border: 1px solid rgba(0,0,0,.22); background: var(--document-color, #fff); }
.shared-document-color-trigger.document-color-no-fill .document-color-trigger-bar { background: linear-gradient(135deg, transparent 43%, #d22 44%, #d22 56%, transparent 57%), #fff; }
.document-color-popover { position: fixed; z-index: 1000; width: 244px; padding: 12px 10px 10px; border: 1px solid #777; border-radius: 4px; background: #fff; color: #222; box-shadow: 0 5px 18px rgba(0,0,0,.35); }
.document-color-divider { margin: 3px 0 2px; border-top: 1px solid #d5d5d5; }
.document-color-grid { display: grid; grid-template-rows: repeat(6, 18px); grid-auto-flow: column; grid-auto-columns: 18px; gap: 3px; padding: 2px 3px; }
.document-standard-color-grid { grid-template-columns: repeat(10, 18px); grid-template-rows: 18px; grid-auto-flow: row; grid-auto-columns: 18px; }
.document-color-swatch { width: 18px; height: 18px; padding: 0; border: 1px solid #999; border-radius: 2px; cursor: pointer; }
.document-color-swatch:hover,
.document-color-swatch.selected { outline: 2px solid var(--brand); outline-offset: 1px; }
.document-color-none { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; border: 0; border-top: 1px solid #d5d5d5; background: #fff; color: #222; text-align: left; font-size: 12px; cursor: pointer; }
.document-color-none::before { content: '□ '; color: #666; }
.document-color-none:hover { background: #f1f1f1; }
.shared-document-actions select.shared-document-style-control { height: 26px; padding: 2px 4px; border: 1px solid var(--bg-tertiary); border-radius: var(--radius); background: var(--bg-secondary); color: var(--text-normal); font-size: var(--fs-xxs); }
.shared-document-actions .shared-document-format-toolbar select.shared-document-style-control { height: 27px; border-color: #d4d7dc; background: #fff; color: #1f2937; font-size: 12px; }
.shared-document-actions input[type="color"] { width: 28px; height: 26px; padding: 1px; border: 1px solid var(--bg-tertiary); border-radius: var(--radius); background: var(--bg-secondary); cursor: pointer; }
.shared-document-style-edit:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.shared-document-grid { flex: 1; min-height: 250px; overflow: auto; border: 1px solid #b7b7b7; background: #fff; color: #000; }
.shared-document-grid::-webkit-scrollbar-track { background: #f2f2f2; }
.shared-document-grid::-webkit-scrollbar-thumb { background: #b7b7b7; border-color: #f2f2f2; }
.shared-document-grid::-webkit-scrollbar-thumb:hover { background: #888; }
.shared-document-table { border-collapse: collapse; table-layout: fixed; min-width: 820px; user-select: none; background: #fff; }
.shared-document-table th,
.shared-document-table td { border: 1px solid #d9d9d9; height: 32px; min-width: 0; padding: 0; position: relative; }
.shared-document-table td { vertical-align: top; }
.shared-document-table th { position: relative; border: 1px solid #b7b7b7; width: 80px; min-width: 34px; background: #f3f3f3; color: #000; font-size: var(--fs-xs); text-align: center; }
.shared-document-table tr th:first-child { width: 38px; min-width: 38px; }
.document-column-resizer,
.document-row-resizer { position: absolute; z-index: 3; display: block; }
.document-column-resizer { top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; }
.document-row-resizer { left: 0; right: 0; bottom: -4px; height: 8px; cursor: row-resize; }
.document-column-resizer:hover,
.document-row-resizer:hover { background: var(--brand); opacity: .7; }
.shared-document-cell { display: block; width: 100%; height: 31px; margin: 0; padding: 5px 7px; border: 0; outline: none; background: #fff; color: #000; font: inherit; box-sizing: border-box; resize: none; overflow: auto; scrollbar-width: none; white-space: pre-wrap; line-height: 20px; vertical-align: top; }
.shared-document-cell::-webkit-scrollbar { display: none; }
.shared-document-cell:focus { background: #fffef0; box-shadow: inset 0 0 0 2px #5b9bd5; }
.shared-document-cell.document-cell-readonly { background: #f7f7f7; cursor: default; }
.shared-document-table td.document-cell-selected { background: #eaf3ff; box-shadow: inset 0 0 0 1px #5b9bd5; }
.shared-document-table td.document-cell-selected .shared-document-cell { box-shadow: inset 0 0 0 2px #5b9bd5; }
.shared-document-history-wrap { flex-shrink: 0; margin-top: 12px; padding: 10px; max-height: 150px; overflow-y: auto; border-top: 1px solid var(--bg-tertiary); }
.shared-document-history-wrap > strong { display: block; color: var(--header-secondary); font-size: var(--fs-xs); margin-bottom: 6px; }
.shared-document-history { color: var(--text-muted); font-size: var(--fs-xs); }
.shared-document-history-item { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); }
.shared-document-history-item strong { color: var(--header-secondary); white-space: nowrap; }
.shared-document-history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-document-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: var(--fs-sm); }

@media (max-width: 720px) {
  .document-modal { width: 98vw; height: 96vh; }
  .document-modal-body { flex-direction: column; }
  .shared-document-sidebar { width: auto; max-height: 180px; border-right: 0; border-bottom: 1px solid var(--bg-tertiary); }
  .shared-document-editor { padding: 10px; }
  .shared-document-presence { display: none; }
}

/* ─── 스크롤바 기본 ──────────────────────────────────────── */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,.18); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border: 3px solid transparent; background-clip: padding-box; border-radius: 7px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); border-width: 2px; }
.shared-document-grid { scrollbar-width: auto; scrollbar-color: var(--bg-tertiary) rgba(0,0,0,.18); }

/* ─── 스텔스 모드 ──────────────────────────────────────── */
.stealth-iframe {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  border: none;
  z-index: 0;
  pointer-events: none;
}
.stealth-iframe.hidden { display: none; }

/* 스텔스 모드: 앱을 플로팅 팝업으로 변환 */
body.stealth-active #app-page {
  position: fixed !important;
  z-index: 10;
  width: var(--stealth-popup-w, 500px);
  height: var(--stealth-popup-h, 600px);
  left: var(--stealth-popup-x, auto);
  top: var(--stealth-popup-y, auto);
  right: var(--stealth-popup-right, 20px);
  bottom: var(--stealth-popup-bottom, 20px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-primary) !important;
  opacity: var(--stealth-ui-opacity, 1);
  transition: opacity 0.15s;
  display: flex;
}

/* 사용자 패널, 멤버 패널, 리사이즈 핸들 숨기기 */
body.stealth-active #panel-users,
body.stealth-active #panel-members,
body.stealth-active .resize-handle {
  display: none !important;
}

/* 왼쪽 패널: 위는 참가자, 아래는 대화방 목록 */
body.stealth-active #panel-rooms {
  width: 200px !important;
  min-width: 0 !important;
  max-width: 260px !important;
  flex: none !important;
  display: flex !important;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-secondary) !important;
  transition: width 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
}
body.stealth-active #stealth-members-section {
  display: flex;
  flex: 1 1 50%;
  min-height: 0;
  flex-direction: column;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.08);
}
body.stealth-active #panel-rooms > .panel-header:not(.stealth-members-header) {
  min-height: 40px;
  height: 40px;
  padding: 8px 12px;
}
body.stealth-active .stealth-members-header {
  min-height: 40px;
  height: 40px;
  padding: 8px 12px;
}
body.stealth-active #stealth-participants-list,
body.stealth-active #room-list {
  flex: 1 1 0;
  min-height: 0;
}
body.stealth-active #room-list {
  border-top: 0;
}
body.stealth-active #panel-rooms.stealth-rooms-hidden {
  width: 0 !important;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

/* 대화 패널: 나머지 공간 차지 */
body.stealth-active #panel-chat {
  flex: 1 !important;
  width: auto !important;
  background: var(--bg-primary) !important;
}
body.stealth-active #room-owner-name {
  display: none;
}

/* 왼쪽 패널 토글 버튼: 스텔스 모드에서만 표시 */
.stealth-toggle-rooms { display: none !important; }
body.stealth-active .stealth-toggle-rooms {
  display: flex !important;
  margin-right: 4px;
  color: var(--text-muted);
  transition: color 0.15s;
}
body.stealth-active .stealth-toggle-rooms:hover { color: var(--text-normal); }

/* 메시지 영역 투명도 */
body.stealth-active .msg-group {
  opacity: var(--stealth-msg-opacity, 1);
  transition: opacity 0.15s;
}
body.stealth-active .date-divider {
  opacity: var(--stealth-msg-opacity, 1);
}
body.stealth-active .input-area,
body.stealth-active .input-wrapper {
  opacity: var(--stealth-input-opacity, 1);
  transition: opacity 0.15s;
}
body.stealth-active #msg-input,
body.stealth-active #msg-input::placeholder {
  color: var(--stealth-text-color, inherit) !important;
}

/* 팝업 상단 드래그 바 */
.stealth-drag-bar {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  cursor: move;
  z-index: 50;
  background: linear-gradient(180deg, rgba(88,101,242,0.4) 0%, transparent 100%);
}
.stealth-drag-bar:hover {
  background: linear-gradient(180deg, rgba(88,101,242,0.7) 0%, transparent 100%);
}
body.stealth-active .stealth-drag-bar { display: block; }

/* 팝업 리사이즈 핸들 (코너) */
.stealth-resize-handle {
  display: none;
  position: absolute;
  width: 14px; height: 14px;
  z-index: 50;
}
body.stealth-active .stealth-resize-handle { display: block; }
.stealth-resize-nw { top: 0; left: 0; cursor: nw-resize; }
.stealth-resize-ne { top: 0; right: 0; cursor: ne-resize; }
.stealth-resize-sw { bottom: 0; left: 0; cursor: sw-resize; }
.stealth-resize-se { bottom: 0; right: 0; cursor: se-resize; }
/* 변 리사이즈 */
.stealth-resize-n { top: 0; left: 14px; right: 14px; height: 4px; cursor: n-resize; }
.stealth-resize-s { bottom: 0; left: 14px; right: 14px; height: 4px; cursor: s-resize; }
.stealth-resize-w { left: 0; top: 14px; bottom: 14px; width: 4px; cursor: w-resize; }
.stealth-resize-e { right: 0; top: 14px; bottom: 14px; width: 4px; cursor: e-resize; }

/* 스텔스 컨트롤 패널 */
.stealth-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: move;
}
.stealth-controls.hidden { display: none; }
.stealth-control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.stealth-control-row label {
  color: #dcddde;
  font-size: var(--fs-xs);
  min-width: 80px;
  white-space: nowrap;
}
.stealth-control-row input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: #4f545c;
  border-radius: 2px;
  outline: none;
}
.stealth-control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #5865f2;
  cursor: pointer;
}
.stealth-control-row span {
  color: #b9bbbe;
  font-size: var(--fs-xxs);
  min-width: 35px;
  text-align: right;
}
.stealth-controls-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  cursor: move;
}
.stealth-title {
  flex: 1;
  color: #dcddde;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.stealth-header-btn {
  width: 22px; height: 22px;
  background: #4f545c;
  color: #dcddde;
  border: none;
  border-radius: 4px;
  font-size: var(--fs-base);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stealth-header-btn:hover { background: #5865f2; color: white; }
#stealth-controls-body.hidden { display: none; }
.stealth-shortcut-hint {
  text-align: center;
  color: #72767d;
  font-size: var(--fs-xxs);
  margin-top: 6px;
}
