/* ==========================================================================
   GMSG 사내 메신저 — 디자인 시스템 (GLDAP·glicense 와 동일한 변수·컴포넌트)
   ========================================================================== */

:root {
  --bg-app: #090d16;
  --bg-sidebar: #0f1524;
  --bg-card: rgba(20, 27, 45, 0.6);
  --bg-card-hover: rgba(28, 38, 62, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  --glow-blue: 0 0 15px rgba(59, 130, 246, 0.3);

  --color-primary: #3b82f6;
  --color-primary-grad: linear-gradient(135deg, #3b82f6, #1d4ed8);
  --color-secondary: #64748b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;
  --color-purple: #8b5cf6;
  --color-rose-grad: linear-gradient(135deg, #ef4444, #b91c1c);
  --color-emerald-grad: linear-gradient(135deg, #10b981, #047857);

  --bubble-me: linear-gradient(135deg, #3b82f6, #2563eb);
  --bubble-other: rgba(255, 255, 255, 0.06);

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-theme {
  --bg-app: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
  --glow-blue: 0 0 12px rgba(59, 130, 246, 0.15);

  --bubble-other: rgba(15, 23, 42, 0.05);
}

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

body {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  /* 모바일 브라우저의 100vh 는 주소창에 가려지는 영역까지 포함해 아래가 잘린다.
     dvh(실제로 보이는 높이)를 쓰고, 지원하지 않는 브라우저는 vh 로 떨어진다. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; outline: none; }
.hidden { display: none !important; }

/* 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.35) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, 0.5); }
.light-theme, .light-theme * { scrollbar-color: rgba(100, 116, 139, 0.4) transparent; }
.light-theme *::-webkit-scrollbar-thumb { background-color: rgba(100, 116, 139, 0.3); }

/* ==========================================================================
   공통 컴포넌트
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: all var(--transition-fast);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-primary-grad); color: #fff; box-shadow: var(--glow-blue); }
.btn-primary:hover { opacity: 0.9; box-shadow: 0 0 20px rgba(59, 130, 246, 0.45); }
.btn-secondary { background-color: rgba(255, 255, 255, 0.05); border-color: var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background-color: rgba(255, 255, 255, 0.08); }
.light-theme .btn-secondary { background-color: rgba(15, 23, 42, 0.04); }
.btn-danger { background: var(--color-rose-grad); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--color-emerald-grad); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 0.8rem; border-radius: 8px; gap: 6px; }
.btn-sm svg, .btn-sm i { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.btn-icon-plain {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; transition: all var(--transition-fast);
}
.btn-icon-plain:hover { background: var(--bg-card-hover); color: var(--text-main); }
.btn-icon-plain.active { color: var(--color-warning); }
.btn-icon-plain i, .btn-icon-plain svg { width: 17px; height: 17px; }

.glass {
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 16px; box-shadow: var(--shadow-md); backdrop-filter: blur(16px);
}
.badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px;
  font-size: 0.7rem; font-weight: 700; line-height: 1; white-space: nowrap;
}
.badge.count { background: var(--color-primary); color: #fff; }
.badge.mention { background: var(--color-danger); color: #fff; }
.badge.soft { background: rgba(148, 163, 184, 0.16); color: var(--text-muted); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; background-color: rgba(0, 0, 0, 0.15); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 10px 14px; color: var(--text-main); font-size: 0.9rem;
  transition: all var(--transition-fast);
}
.light-theme .form-control { background-color: #f8fafc; }
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
.form-row { display: flex; gap: 16px; }
.form-row .col { flex: 1; }
textarea.form-control { resize: vertical; }

select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px;
  padding-right: 32px !important; cursor: pointer;
}
select option { background-color: var(--bg-sidebar); color: var(--text-main); }

.hint-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.empty-state { text-align: center; color: var(--text-muted); padding: 24px 12px; font-size: 0.85rem; }

.notice-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--color-primary); font-size: 0.82rem; margin-bottom: 16px; line-height: 1.5;
}
.notice-bar i, .notice-bar svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.search-box { position: relative; display: flex; align-items: center; }
.search-box i, .search-box svg {
  position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-box input {
  width: 100%; background-color: rgba(0, 0, 0, 0.18); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 9px 12px 9px 36px; color: var(--text-main); font-size: 0.85rem;
}
.light-theme .search-box input { background-color: #f1f5f9; }
.search-box input:focus { border-color: var(--border-focus); }
.search-box.small input { padding-top: 7px; padding-bottom: 7px; font-size: 0.82rem; }

/* ==========================================================================
   레이아웃
   ========================================================================== */
.app-container { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* 모바일에서 메뉴를 닫았을 때 다시 여는 버튼 · 열렸을 때 뒤를 덮는 막 */
.mobile-menu-btn {
  display: none; position: fixed; top: 10px; left: 10px; z-index: 46;
  width: 40px; height: 40px; border-radius: 12px; align-items: center; justify-content: center;
  background: var(--bg-sidebar); border: 1px solid var(--border-color); color: var(--text-main);
  box-shadow: var(--shadow-md); cursor: pointer;
}
.mobile-menu-btn i, .mobile-menu-btn svg { width: 20px; height: 20px; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(5, 7, 12, 0.5); }

.sidebar {
  width: 300px; flex-shrink: 0; background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color); display: flex; flex-direction: column;
  transition: width var(--transition-normal);
}
.app-container.sidebar-collapsed .sidebar { width: 74px; }
.app-container.sidebar-collapsed .logo-text-box,
.app-container.sidebar-collapsed .sidebar-search,
.app-container.sidebar-collapsed .side-tab span,
.app-container.sidebar-collapsed .sidebar-body,
.app-container.sidebar-collapsed .profile-info,
.app-container.sidebar-collapsed .footer-actions { display: none; }
.app-container.sidebar-collapsed .side-tabs { flex-direction: column; gap: 4px; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px; border-bottom: 1px solid var(--border-color);
}
.logo-container { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.logo-icon-box {
  width: 40px; height: 40px; border-radius: 12px; background: var(--color-primary-grad);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
.logo-text-box { display: flex; flex-direction: column; }
.logo-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.5px; }
.logo-subtitle { font-size: 0.72rem; color: var(--text-muted); }
.sidebar-toggle {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: var(--bg-card-hover); color: var(--text-main); }
.sidebar-toggle i { width: 18px; height: 18px; }

.sidebar-search { padding: 12px 14px 6px; }

.side-tabs { display: flex; gap: 6px; padding: 8px 12px 10px; }
.side-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 6px; border-radius: 10px; background: transparent; border: 1px solid transparent;
  color: var(--text-muted); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition-fast);
}
.side-tab i { width: 15px; height: 15px; }
.side-tab:hover { background: var(--bg-card); color: var(--text-main); }
.side-tab.active { background: var(--color-primary-grad); color: #fff; box-shadow: var(--glow-blue); }

.sidebar-body { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.side-pane { display: none; }
.side-pane.active { display: block; }
.pane-actions { display: flex; gap: 6px; padding: 4px 4px 10px; }
.pane-actions .btn { flex: 1; }
.pane-title {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.6px; padding: 12px 8px 6px;
}

/* 대화 목록 항목 */
.room-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px;
  cursor: pointer; transition: background var(--transition-fast); margin-bottom: 2px;
}
.room-item:hover { background: var(--bg-card); }
.room-item.active { background: var(--bg-card-hover); box-shadow: inset 2px 0 0 var(--color-primary); }
.room-item .avatar { flex-shrink: 0; }
.room-main { flex: 1; min-width: 0; }
.room-line { display: flex; align-items: center; gap: 6px; }
.room-title {
  font-size: 0.88rem; font-weight: 600; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-item.unread .room-title { font-weight: 800; }
.room-preview {
  font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; margin-top: 2px;
}
.room-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.room-time { font-size: 0.68rem; color: var(--text-muted); }
.room-icon-badge {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(59, 130, 246, 0.14); color: var(--color-primary); flex-shrink: 0;
}
.room-icon-badge i { width: 17px; height: 17px; }
.room-icon-badge.private { background: rgba(139, 92, 246, 0.15); color: var(--color-purple); }
.room-icon-badge.group { background: rgba(16, 185, 129, 0.15); color: var(--color-success); }

/* 아바타 · 프레즌스 */
.avatar {
  width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff; position: relative; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 0.68rem; }
.avatar.lg { width: 44px; height: 44px; border-radius: 14px; font-size: 0.9rem; }
.presence-dot {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%;
  background: #64748b; border: 2px solid var(--bg-sidebar);
}
.presence-dot.online { background: var(--color-success); }
.presence-dot.away { background: var(--color-warning); }
.presence-dot.busy { background: var(--color-danger); }
.p-online { color: var(--color-success); }
.p-away { color: var(--color-warning); }
.p-busy { color: var(--color-danger); }

/* 조직도 */
.org-dept { margin-bottom: 4px; }
.org-dept-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px;
  cursor: pointer; font-size: 0.85rem; font-weight: 700; color: var(--text-main);
}
.org-dept-head:hover { background: var(--bg-card); }
/* lucide 가 <i> 를 <svg> 로 바꾸므로 태그가 아니라 클래스로 잡는다 */
.org-dept-head .caret { width: 15px; height: 15px; color: var(--text-muted); transition: transform var(--transition-fast); }
.org-dept.open .org-dept-head .caret { transform: rotate(90deg); }
.org-dept-count { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.org-members { display: none; padding-left: 8px; }
.org-dept.open .org-members { display: block; }
.org-person {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 10px; cursor: pointer;
}
.org-person:hover { background: var(--bg-card); }
.org-person .who { min-width: 0; flex: 1; }
.org-person .nm { font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-person .tt { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-person .dm-btn { opacity: 0; }
.org-person:hover .dm-btn { opacity: 1; }

.sidebar-footer { border-top: 1px solid var(--border-color); padding: 12px 14px; }
.user-profile { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me-box { display: flex; align-items: center; gap: 10px; overflow: hidden; cursor: pointer; flex: 1; }
.profile-info { overflow: hidden; }
.profile-name { display: block; font-size: 0.85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-role { display: block; font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ==========================================================================
   대화 영역
   ========================================================================== */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-app); }
.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-muted); text-align: center; padding: 40px;
}
.chat-empty h2 { font-size: 1.2rem; color: var(--text-main); }
.chat-empty p { font-size: 0.88rem; line-height: 1.7; }
.empty-illustration {
  width: 90px; height: 90px; border-radius: 28px; background: var(--bg-card);
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color);
}
.empty-illustration i { width: 40px; height: 40px; color: var(--color-primary); }

.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar); flex-shrink: 0;
}
.chat-title-box { display: flex; align-items: center; gap: 12px; min-width: 0; }
.room-kind-icon {
  width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: rgba(59, 130, 246, 0.14); color: var(--color-primary); flex-shrink: 0;
}
.chat-header h2 { font-size: 1.02rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-topic { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.chat-header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.member-avatars { display: flex; margin-right: 8px; }
.member-avatars .avatar { margin-left: -8px; border: 2px solid var(--bg-sidebar); }
.member-avatars .more {
  background: var(--bg-card-hover); color: var(--text-muted); font-size: 0.65rem;
}

/* 메시지는 아래에서부터 쌓인다 — 대화가 짧아도 입력창 바로 위에 붙어 보이게 한다 */
.messages-scroll {
  flex: 1; overflow-y: auto; padding: 18px 22px 8px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
#message-list { flex: 0 0 auto; }
.load-more-box { text-align: center; padding-bottom: 12px; flex-shrink: 0; }

/* 테마 토글은 지금 켤 수 있는 테마의 아이콘만 보여 준다 */
.dark-theme #theme-toggle-btn .moon-icon,
.light-theme #theme-toggle-btn .sun-icon { display: none; }

.date-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; }
.date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
.date-divider span { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.msg-row { display: flex; gap: 10px; padding: 3px 0; position: relative; }
.msg-row.grouped { padding-top: 0; }
.msg-row:hover { background: rgba(148, 163, 184, 0.05); border-radius: 10px; }
.msg-avatar-col { width: 36px; flex-shrink: 0; }
.msg-body-col { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-author { font-size: 0.86rem; font-weight: 700; }
.msg-title-tag { font-size: 0.72rem; color: var(--text-muted); }
.msg-time { font-size: 0.7rem; color: var(--text-muted); }
.msg-text {
  font-size: 0.9rem; line-height: 1.6; color: var(--text-main);
  white-space: pre-wrap; word-break: break-word;
}
.msg-text .mention {
  background: rgba(59, 130, 246, 0.18); color: var(--color-primary);
  padding: 1px 5px; border-radius: 5px; font-weight: 600;
}
.msg-text .mention.me { background: rgba(245, 158, 11, 0.2); color: var(--color-warning); }
.msg-text a { color: var(--color-primary); text-decoration: underline; }
.msg-deleted { font-style: italic; color: var(--text-muted); font-size: 0.85rem; }
.msg-edited { font-size: 0.68rem; color: var(--text-muted); margin-left: 6px; }
.msg-sticker { font-size: 3.4rem; line-height: 1.15; }

.msg-system { text-align: center; margin: 10px 0; }
.msg-system span {
  display: inline-block; font-size: 0.75rem; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--border-color);
  padding: 5px 12px; border-radius: 20px;
}

/* 메시지 위 액션 */
.msg-actions {
  position: absolute; right: 8px; top: -10px; display: none; gap: 2px;
  background: var(--bg-sidebar); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 2px; box-shadow: var(--shadow-sm); z-index: 5;
}
.msg-row:hover .msg-actions { display: flex; }
.msg-actions button {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
}
.msg-actions button:hover { background: var(--bg-card-hover); color: var(--text-main); }
.msg-actions i { width: 15px; height: 15px; }

/* 반응 */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border-color); cursor: pointer;
  font-size: 0.78rem; transition: all var(--transition-fast);
}
.reaction-chip:hover { background: var(--bg-card-hover); }
.reaction-chip.mine { border-color: var(--color-primary); background: rgba(59, 130, 246, 0.16); }
.reaction-chip .cnt { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.reaction-chip.mine .cnt { color: var(--color-primary); }
.reaction-add { padding: 3px 7px; color: var(--text-muted); }
.reaction-add i { width: 13px; height: 13px; }

/* 쓰레드 요약 줄 */
.thread-link {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; padding: 5px 10px;
  border-radius: 9px; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.22);
  color: var(--color-primary); font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.thread-link:hover { background: rgba(59, 130, 246, 0.18); }
.thread-link i { width: 14px; height: 14px; }

/* 파일 · 이미지 */
.file-card {
  display: flex; align-items: center; gap: 12px; margin-top: 6px; padding: 10px 12px;
  border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border-color);
  max-width: 420px;
}
.file-icon {
  width: 38px; height: 38px; border-radius: 10px; background: rgba(59, 130, 246, 0.14);
  color: var(--color-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 0.72rem; color: var(--text-muted); }
.msg-image {
  margin-top: 6px; max-width: 360px; max-height: 320px; border-radius: 12px;
  border: 1px solid var(--border-color); cursor: zoom-in; display: block;
}

/* 읽음 표시 */
.read-mark { font-size: 0.68rem; color: var(--color-primary); margin-left: 6px; font-weight: 600; }

.typing-bar { height: 20px; padding: 0 24px; font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

/* 입력창 */
.composer { padding: 10px 20px 16px; flex-shrink: 0; }
.composer-row {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px;
}
.composer-row:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); }
.composer-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.composer-btn:hover { background: var(--bg-card-hover); color: var(--color-primary); }
.composer-btn i { width: 18px; height: 18px; }
.composer textarea {
  flex: 1; background: transparent; border: none; color: var(--text-main); font-size: 0.92rem;
  line-height: 1.5; padding: 7px 4px; resize: none; max-height: 180px; min-height: 34px;
}
.composer-send {
  width: 36px; height: 36px; border-radius: 11px; border: none; cursor: pointer; flex-shrink: 0;
  background: var(--color-primary-grad); color: #fff; display: flex; align-items: center; justify-content: center;
}
.composer-send:hover { opacity: 0.9; }
.composer-send i { width: 17px; height: 17px; }
.composer-preview {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px;
}
.pending-file {
  display: flex; align-items: center; gap: 8px; font-size: 0.78rem;
  background: var(--bg-card-hover); border-radius: 8px; padding: 5px 8px;
}
.pending-file button { background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; }
.pending-file i { width: 13px; height: 13px; }

/* ==========================================================================
   쓰레드 패널
   ========================================================================== */
.thread-panel {
  width: 400px; flex-shrink: 0; background: var(--bg-sidebar); position: relative;
  border-left: 1px solid var(--border-color); display: flex; flex-direction: column;
}

/* 왼쪽 모서리를 잡아 끌어 너비를 바꾼다 */
.thread-resizer {
  position: absolute; left: -3px; top: 0; width: 7px; height: 100%; z-index: 10;
  cursor: col-resize; background: transparent; transition: background var(--transition-fast);
}
.thread-resizer::after {
  content: ''; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 46px; border-radius: 3px; background: var(--border-color);
  transition: background var(--transition-fast);
}
.thread-resizer:hover::after, body.resizing .thread-resizer::after { background: var(--color-primary); }
.thread-resizer:hover { background: rgba(59, 130, 246, 0.12); }
/* 끄는 동안 글자가 잡히거나 커서가 바뀌지 않게 한다 */
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing .messages-scroll { pointer-events: none; }
.thread-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.thread-header h3 { font-size: 0.98rem; font-weight: 700; }
.thread-sub { font-size: 0.75rem; color: var(--text-muted); }
.thread-scroll { flex: 1; overflow-y: auto; padding: 16px 16px 4px; }
.thread-root {
  padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border-color);
}
.thread-count { font-size: 0.75rem; color: var(--text-muted); margin: 6px 0 10px; font-weight: 600; }
.thread-composer { padding: 10px 14px 14px; }

/* ==========================================================================
   @ 멘션 자동완성
   ========================================================================== */
.mention-pop {
  position: fixed; z-index: 1300; width: min(340px, calc(100vw - 24px));
  max-height: 300px; overflow-y: auto; border-radius: 14px; padding: 6px;
  background: var(--bg-sidebar);
}
.mention-head {
  font-size: 0.7rem; color: var(--text-muted); padding: 6px 8px 8px; border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 10px; cursor: pointer;
}
.mention-item.active, .mention-item:hover { background: rgba(59, 130, 246, 0.16); }
.mention-item .who { min-width: 0; flex: 1; }
.mention-item .nm { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-item .nm .uid { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.mention-item .tt { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   선택기 (이모지 · 이모티콘)
   ========================================================================== */
.picker {
  position: fixed; z-index: 1200; width: 330px; max-height: 340px;
  display: flex; flex-direction: column; overflow: hidden; border-radius: 14px;
}
.picker-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; }
.picker-tab {
  background: none; border: none; cursor: pointer; font-size: 1rem; padding: 5px 8px; border-radius: 8px;
}
.picker-tab:hover, .picker-tab.active { background: var(--bg-card-hover); }
.picker-title { padding: 10px 12px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }
.picker-body { overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.picker-body button {
  background: none; border: none; cursor: pointer; font-size: 1.25rem; padding: 5px; border-radius: 8px;
}
.picker-body button:hover { background: var(--bg-card-hover); transform: scale(1.15); }
.sticker-grid { grid-template-columns: repeat(5, 1fr); }
.sticker-grid button { font-size: 2rem; }

/* ==========================================================================
   모달
   ========================================================================== */
.modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-normal);
}
.modal.active { opacity: 1; pointer-events: auto; }
.modal-overlay { position: absolute; inset: 0; background-color: rgba(5, 7, 12, 0.6); backdrop-filter: blur(8px); }
.modal-container {
  width: 90%; max-width: 550px; position: relative; z-index: 1001; display: flex; flex-direction: column;
  border-radius: 20px; overflow: hidden; transform: scale(0.95); transition: transform var(--transition-normal);
  max-height: 90vh; background: var(--bg-sidebar);
}
.modal.active .modal-container { transform: scale(1); }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.btn-close-modal { background: transparent; border: none; color: var(--text-muted); cursor: pointer; display: flex; }
.btn-close-modal:hover { color: var(--text-main); }
.modal-container > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-body p { font-size: 0.9rem; line-height: 1.6; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border-color); display: flex;
  justify-content: flex-end; gap: 10px; background-color: rgba(0, 0, 0, 0.1); flex-shrink: 0;
}

.radio-row { display: flex; flex-direction: column; gap: 8px; }
.radio-chip { display: flex; align-items: center; cursor: pointer; }
.radio-chip input { margin-right: 8px; }
.radio-chip span { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; }
.radio-chip i { width: 15px; height: 15px; }

.member-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 12px; padding: 6px; }
.picker-search { margin-bottom: 8px; }
.member-option {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 10px; cursor: pointer;
}
.member-option:hover { background: var(--bg-card); }
.member-option.selected { background: rgba(59, 130, 246, 0.14); }
.member-option .who { flex: 1; min-width: 0; }
.member-option .nm { font-size: 0.85rem; font-weight: 600; }
.member-option .tt { font-size: 0.73rem; color: var(--text-muted); }
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--border-color); margin-bottom: 6px;
}
.member-row .who { flex: 1; min-width: 0; }

/* 공유 링크 */
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row .form-control { font-size: 0.82rem; font-family: 'Outfit', monospace; }
.link-row .btn { flex-shrink: 0; }
.link-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border-color); margin-bottom: 8px;
}
.link-card.dead { opacity: 0.55; }
.link-card .link-main { flex: 1; min-width: 0; }
.link-card .link-url {
  font-size: 0.8rem; font-family: 'Outfit', monospace; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-card .link-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

.file-row {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px;
  border: 1px solid var(--border-color); margin-bottom: 8px;
}
.search-hit {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-color);
  margin-bottom: 8px; cursor: pointer;
}
.search-hit:hover { background: var(--bg-card); }
.search-hit .where { font-size: 0.74rem; color: var(--color-primary); font-weight: 700; margin-bottom: 3px; }
.search-hit .what { font-size: 0.86rem; color: var(--text-main); line-height: 1.5; }
.search-hit .when { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

.stats-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-mini {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 12px; text-align: center;
}
.stat-mini .v { font-size: 1.2rem; font-weight: 800; }
.stat-mini .l { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* 이미지 뷰어 */
.image-viewer {
  position: relative; z-index: 1001; max-width: 92vw; max-height: 92vh;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.image-viewer img { max-width: 92vw; max-height: 80vh; border-radius: 14px; box-shadow: var(--shadow-lg); }
.image-viewer-bar { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 0.85rem; }

/* ==========================================================================
   토스트
   ========================================================================== */
/* 대화 헤더의 버튼들과 겹치지 않도록 헤더 아래에서 시작한다
   (겹치면 토스트가 떠 있는 동안 헤더 버튼 클릭이 먹히지 않는다) */
#toast-container {
  position: fixed; top: 76px; right: 20px; z-index: 2000; display: flex; flex-direction: column;
  gap: 10px; pointer-events: none; max-width: min(380px, calc(100vw - 48px));
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  border-radius: 12px; background: var(--bg-sidebar); border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-primary); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  color: var(--text-main); font-size: 0.88rem; transform: translateX(120%); opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.28s ease;
}
.toast.toast-in { transform: translateX(0); opacity: 1; }
.toast.toast-out { transform: translateX(120%); opacity: 0; }
.toast .toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast .toast-msg { flex: 1; line-height: 1.45; word-break: break-word; }
.toast .toast-sub { color: var(--text-muted); font-size: 0.82rem; }
.toast-click { cursor: pointer; }
.toast-click:hover { border-color: var(--color-primary); transform: translateX(-2px); }

/* 알림 권한 안내 줄 (대화 영역 맨 위) */
.notify-banner {
  display: flex; align-items: center; gap: 10px; margin: 12px 20px 0; padding: 10px 14px;
  border-radius: 12px; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--text-main); font-size: 0.82rem; line-height: 1.5;
}
.notify-banner > i, .notify-banner > svg { width: 17px; height: 17px; color: var(--color-primary); flex-shrink: 0; }
/* 실시간 연결 끊김 — 눈에 띄되 대화를 가리지 않게 */
.notify-banner.rt-down {
  background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.28);
}
.notify-banner.rt-down > i, .notify-banner.rt-down > svg { color: var(--color-danger); }
.notify-banner span { flex: 1; }

/* 내 상태 모달의 알림 상태 표시 */
.notify-state {
  font-size: 0.8rem; line-height: 1.5; padding: 9px 12px; border-radius: 10px; margin-bottom: 12px;
  background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.28); color: var(--color-success);
}
.notify-state.warn {
  background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.28); color: var(--color-warning);
}
.notify-state div { margin-bottom: 4px; }
.notify-state .notify-hint {
  margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--border-color);
  color: var(--text-muted); font-size: 0.76rem;
}
.check-row { display: flex; align-items: center; gap: 9px; padding: 6px 2px; cursor: pointer; font-size: 0.86rem; }
.check-row input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }
.toast-success { border-left-color: var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-primary); }

/* ==========================================================================
   로그인
   ========================================================================== */
.login-screen {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  background-color: #0a0f1e;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%23ffffff' stroke-opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at 16% 20%, rgba(59, 130, 246, 0.30), transparent 45%),
    radial-gradient(circle at 84% 78%, rgba(139, 92, 246, 0.26), transparent 45%),
    linear-gradient(135deg, #0a0f1e 0%, #121a30 50%, #0a0f1e 100%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 44px 44px, cover, cover, cover;
}
.light-theme .login-screen {
  background-color: #eef2f9;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%230f172a' stroke-opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at 16% 20%, rgba(59, 130, 246, 0.18), transparent 45%),
    radial-gradient(circle at 84% 78%, rgba(139, 92, 246, 0.16), transparent 45%),
    linear-gradient(135deg, #eef2f9 0%, #e2e8f5 50%, #eef2f9 100%);
}
.login-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; display: flex !important; }
.login-card {
  width: 100%; max-width: 420px; padding: 40px; border-radius: 24px; position: relative; z-index: 1;
  background: rgba(15, 23, 42, 0.45); border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); backdrop-filter: blur(20px);
}
.light-theme .login-card { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.06); }
.login-brand { margin-bottom: 30px; text-align: center; }
.login-brand .brand-logo {
  width: 60px; height: 60px; border-radius: 16px; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}
.login-brand h2 { font-size: 1.5rem; font-weight: 800; }
.login-brand .subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.auth-toggle-text { margin-top: 16px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* ==========================================================================
   반응형
   ========================================================================== */
@media (max-width: 1200px) {
  .thread-panel { width: 340px; }
}
@media (max-width: 900px) {
  .sidebar { position: absolute; z-index: 50; height: 100dvh; box-shadow: var(--shadow-lg); }
  .app-container.sidebar-collapsed .sidebar { width: 0; border: none; overflow: hidden; }
  .thread-panel { position: absolute; right: 0; height: 100dvh; z-index: 60; width: min(420px, 100vw) !important; }
  .thread-resizer { display: none; }   /* 좁은 화면에서는 전체 폭으로 쓴다 */
  .room-topic { max-width: 40vw; }

  /* 메뉴를 닫으면 여는 버튼이 뜨고, 열면 뒤를 덮어 아무 데나 눌러 닫을 수 있다 */
  .app-container.sidebar-collapsed .mobile-menu-btn { display: flex; }
  .app-container:not(.sidebar-collapsed) .sidebar-backdrop { display: block; }
  /* 여는 버튼이 헤더 내용을 가리지 않게 자리를 비운다 */
  .app-container.sidebar-collapsed .chat-header { padding-left: 58px; }
  .app-container.sidebar-collapsed .chat-empty { padding-top: 60px; }
  .app-container.sidebar-collapsed .notify-banner { margin-left: 58px; }

  /* 아래가 잘리지 않게 — 홈 인디케이터·주소창 영역만큼 여유를 준다 */
  .messages-scroll { padding: 12px 12px 4px; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .thread-composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .composer textarea { font-size: 16px; }   /* iOS 는 16px 미만이면 입력 시 화면을 확대한다 */
  .typing-bar { padding: 0 14px; }
}

@media (max-width: 600px) {
  /* 헤더 버튼이 넘쳐 잘리지 않도록 촘촘하게 */
  .chat-header { padding: 10px 8px; gap: 6px; }
  .chat-header h2 { font-size: 0.95rem; }
  .chat-header-actions { gap: 0; }
  .member-avatars { display: none; }
  .btn-icon-plain { width: 30px; height: 30px; }
  .btn-icon-plain i, .btn-icon-plain svg { width: 16px; height: 16px; }
  .room-kind-icon { width: 32px; height: 32px; }
  /* 안내 줄이 화면을 많이 차지하지 않게 */
  .notify-banner { margin: 8px 10px 0; padding: 8px 10px; font-size: 0.76rem; gap: 8px; }
  .notify-banner .btn { padding: 6px 10px; font-size: 0.74rem; }
  .msg-image { max-width: 78vw; }
  .file-card { max-width: 78vw; }
  .login-card { padding: 26px 20px; }
  .modal-container { width: 94%; max-height: 88dvh; }
  .picker { width: min(320px, calc(100vw - 24px)); }
}
