:root {
  --kakao-yellow: #fee500;
  --kakao-yellow-hover: #f5dc00;
  --kakao-brown: #3c1e1e;
  --chat-bg: #abc1d1;
  --chat-header-bg: #a3b9c9;
  --rail-bg: #ececed;
  --sidebar-bg: #ffffff;
  --border: #e5e7eb;
  --text: #191919;
  --muted: #6b7280;
  --unread: #ff5442;
  --unread-count: #ffeb00;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 58px 332px 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ── Left Rail ───────────────────────────────────────────────────────────── */
.rail {
  background: var(--rail-bg);
  border-right: 1px solid #dcdce0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
}

.rail-top,
.rail-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.rail-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: #7c8089;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}

.rail-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1f2937;
}

.rail-btn.active {
  background: #ffffff;
  color: #191919;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.rail-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--unread);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 999px;
  min-width: 15px;
  text-align: center;
  line-height: 1.2;
}

.status-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--rail-bg);
}

.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-err { background: var(--err); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.sidebar-pane.active {
  display: flex;
}

.sidebar-header {
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f2f4;
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.sync-toggle .sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
}

.sync-toggle.on {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.sync-toggle.on .sync-dot {
  background: #10b981;
}

.sidebar-search {
  padding: 10px 14px 8px;
  border-bottom: 1px solid #f1f2f4;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f5f6f8;
  font-size: 13px;
  outline: none;
}

.sidebar-search input:focus {
  border-color: #cbd5e1;
  background: #ffffff;
}

.filter-chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  border: none;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f2f4;
  color: #4b5563;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip.active {
  background: #191919;
  color: #ffffff;
}

.search-row {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: #1f2937;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-small {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: var(--kakao-yellow);
  color: var(--kakao-brown);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-small:hover {
  background: var(--kakao-yellow-hover);
}

.btn-secondary {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #f9fafb;
}

/* ── Room List & KakaoTalk Collage Avatars ───────────────────────────────── */
.room-list,
.search-results,
.runtime-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.room-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  align-items: center;
  border-bottom: 1px solid #f7f8fa;
  transition: background 0.1s;
}

.room-item:hover {
  background: #f6f7f9;
}

.room-item.active {
  background: #edf2f7;
}

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar.collage-2 {
  background: transparent !important;
  overflow: visible;
}

.avatar.collage-2 img {
  position: absolute;
  width: 31px;
  height: 31px;
  border-radius: 12px;
  border: 2px solid #ffffff;
}

.avatar.collage-2 img:first-child {
  top: 0;
  left: 0;
}

.avatar.collage-2 img:last-child {
  bottom: 0;
  right: 0;
}

.avatar.collage-grid {
  background: transparent !important;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  border-radius: 0;
}

.avatar.collage-grid img {
  width: 23px;
  height: 23px;
  border-radius: 9px;
}

.room-body {
  min-width: 0;
}

.room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.room-name-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.room-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-members {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 500;
  flex-shrink: 0;
}

.muted-bell {
  display: inline-flex;
  align-items: center;
  color: #9ca3af;
  flex-shrink: 0;
}

.fav-star {
  color: #f59e0b;
  font-size: 11px;
  flex-shrink: 0;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  flex-shrink: 0;
}

.room-time {
  font-size: 11px;
  color: #9ca3af;
  flex-shrink: 0;
}

.room-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
}

.room-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  background: var(--unread);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 19px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Search Results ──────────────────────────────────────────────────────── */
.search-hit {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f2f4;
  cursor: pointer;
}

.search-hit:hover {
  background: #f8fafc;
}

.search-hit-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.search-hit-room {
  font-weight: 600;
  color: #1f2937;
}

.search-hit-preview {
  font-size: 13px;
  color: #374151;
  line-height: 1.4;
  word-break: break-word;
}

.empty-hint {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ── Runtime Panel ───────────────────────────────────────────────────────── */
.runtime-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.runtime-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fafafa;
}

.runtime-card h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.kv-label {
  color: var(--muted);
}

.pill {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.pill-ok { background: #dcfce7; color: #166534; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-err { background: #fee2e2; color: #991b1b; }

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dbrate-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.dbrate-row select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 12px;
  background: #fff;
}

/* ── Main Chat Area ──────────────────────────────────────────────────────── */
.main-area {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--chat-bg);
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.empty-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.kakao-badge {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--kakao-yellow);
  color: var(--kakao-brown);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.empty-card h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.onboarding-box {
  margin-top: 16px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
}

.onboarding-box code {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.onboarding-box a {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--kakao-yellow);
  color: var(--kakao-brown);
  font-weight: 700;
  text-decoration: none;
}

/* ── Active Chat View ────────────────────────────────────────────────────── */
.chat-view {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-header {
  height: 56px;
  padding: 0 14px;
  background: var(--chat-header-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-avatar .avatar {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  font-size: 13px;
}

.header-avatar .avatar.collage-2 img {
  width: 24px;
  height: 24px;
  border-radius: 9px;
}

.header-avatar .avatar.collage-grid img {
  width: 17px;
  height: 17px;
  border-radius: 6px;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-count-btn {
  border: none;
  background: rgba(0, 0, 0, 0.07);
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  cursor: pointer;
}

.member-count-btn:hover {
  background: rgba(0, 0, 0, 0.14);
}

.chat-subtitle {
  font-size: 11px;
  color: #475569;
  margin-top: 1px;
}

.chat-header-actions {
  display: flex;
  gap: 2px;
}

/* Floating Notice Banner */
.notice-banner {
  margin: 10px 14px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

.notice-icon {
  margin-top: 1px;
  flex-shrink: 0;
}

.notice-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.42;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.notice-text.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notice-close {
  width: 24px;
  height: 24px;
  font-size: 13px;
  flex-shrink: 0;
}

.room-search-bar {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.room-search-bar input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
}

.room-search-results {
  max-height: 220px;
  overflow-y: auto;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

/* Members Drawer */
.members-drawer {
  position: absolute;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 260px;
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 25;
}

.members-drawer-header {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f2f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.members-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.member-row .avatar {
  width: 34px;
  height: 34px;
  border-radius: 13px;
  font-size: 12px;
}

/* ── Messages Canvas ─────────────────────────────────────────────────────── */
.messages-wrap {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 18px;
  min-height: 0;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.load-more-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.18);
  color: #ffffff;
  cursor: pointer;
}

.load-more-btn:hover {
  background: rgba(0, 0, 0, 0.28);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.date-divider {
  align-self: center;
  margin: 12px 0 8px;
  padding: 4px 13px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 500;
}

.system-pill,
.deleted-pill {
  align-self: center;
  margin: 6px 0;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.11);
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  max-width: 82%;
  text-align: center;
}

.system-pill {
  background: rgba(0, 0, 0, 0.14);
  color: #ffffff;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 80%;
  transition: background 0.3s;
  border-radius: 10px;
}

.msg-row.highlight-flash {
  background: rgba(254, 229, 0, 0.35);
}

.msg-row.new-group {
  margin-top: 9px;
}

.msg-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.other {
  align-self: flex-start;
}

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 15px;
  font-size: 13px;
  flex-shrink: 0;
}

.msg-avatar-spacer {
  width: 38px;
  flex-shrink: 0;
}

.msg-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.msg-sender {
  font-size: 12px;
  color: #2c3e50;
  margin: 0 0 4px 2px;
  font-weight: 500;
}

.msg-bubble-line {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.msg-row.mine .msg-bubble-line {
  flex-direction: row-reverse;
}

.msg-content-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}

.msg-row.mine .msg-content-stack {
  align-items: flex-end;
}

.bubble {
  position: relative;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  max-width: 440px;
}

.bubble-text {
  display: block;
  white-space: pre-wrap;
}

.msg-row.other .bubble {
  background: #ffffff;
  color: var(--text);
}

.msg-row.other.new-group .bubble:not(.media-only):not(.emoji-only)::before {
  content: "";
  position: absolute;
  top: 7px;
  left: -5px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid #ffffff;
}

.msg-row.mine .bubble {
  background: var(--kakao-yellow);
  color: var(--text);
}

.msg-row.mine.new-group .bubble:not(.media-only):not(.emoji-only)::before {
  content: "";
  position: absolute;
  top: 7px;
  right: -5px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--kakao-yellow);
}

.bubble.deleted {
  color: #6b7280;
  font-style: italic;
}

.bubble.media-only,
.bubble.emoji-only {
  padding: 0;
  background: transparent !important;
  box-shadow: none;
}

.big-emoji {
  font-size: 54px;
  line-height: 1.12;
  display: inline-block;
  padding: 2px 4px;
}

.emoticon-img {
  width: 136px;
  height: 136px;
  object-fit: contain;
  display: block;
}

.emoticon-img.emoticon-big {
  width: 172px;
  height: 172px;
}

.mini-emoji-solo-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.emoticon-img.mini-emoji-solo {
  width: 96px;
  height: 96px;
}

.mini-emoji-inline {
  display: inline-block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: -5px;
  margin: 0 1px;
}

.emoticon-fallback {
  padding: 10px 14px;
  font-size: 12.5px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 12px;
}

/* Reply Quote Block (type=26) */
.reply-quote {
  white-space: normal;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.11);
  cursor: pointer;
}

.reply-quote:hover .reply-quote-text {
  color: #1f2937;
}

.reply-quote-author {
  font-size: 11.5px;
  font-weight: 700;
  color: #374151;
  line-height: 1.3;
}

.reply-quote-text {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Photos & Videos & Files */
.msg-photo {
  display: block;
  max-width: 260px;
  max-height: 320px;
  border-radius: 12px;
  cursor: zoom-in;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.35);
}

.msg-photo-expired {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: #64748b;
  font-size: 12px;
  border: 1px dashed rgba(100, 116, 139, 0.35);
}

.msg-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 130px));
  gap: 4px;
}

.msg-photo-grid .msg-photo {
  width: 100%;
  height: 124px;
}

.msg-video {
  max-width: 270px;
  max-height: 280px;
  border-radius: 12px;
  background: #000;
  display: block;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  max-width: 280px;
  text-decoration: none;
  color: inherit;
}

.file-card:hover {
  background: #f8fafc;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Link Preview & Rich Cards */
.link-card {
  display: block;
  width: 265px;
  max-width: 100%;
  background: #ffffff;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: var(--text);
}

.link-card:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
}

.link-card-img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  display: block;
  background: #e5e7eb;
}

.link-card-body {
  padding: 10px 12px;
}

.link-card-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 5px;
}

.link-card-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card-desc {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card-domain {
  font-size: 11.5px;
  color: #2563eb;
  text-decoration: underline;
  margin-top: 6px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Meta Stack Beside Bubble: Yellow Unread Count + Time + Hover Reply */
.msg-meta-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
  margin-bottom: 1px;
}

.msg-meta-col:empty {
  display: none;
}

.msg-row.mine .msg-meta-col {
  align-items: flex-end;
}

.msg-row.other .msg-meta-col {
  align-items: flex-start;
}

.msg-unread {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--unread-count);
  text-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.28);
  line-height: 1.1;
}

.msg-time {
  font-size: 10.5px;
  color: #3f4f61;
  white-space: nowrap;
}

.msg-actions {
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  gap: 3px;
  align-self: center;
  transition: opacity 0.12s;
  flex-shrink: 0;
}

.msg-row:hover .msg-actions,
.msg-row.selected .msg-actions {
  opacity: 1;
  pointer-events: auto;
}

.msg-action-btn {
  border: none;
  background: rgba(255, 255, 255, 0.78);
  color: #374151;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.msg-action-btn:hover {
  background: #ffffff;
  color: #111827;
}

/* Reaction Chips */
.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 11.5px;
  font-weight: 600;
  color: #374151;
}

.scroll-bottom-btn {
  position: sticky;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(25, 25, 25, 0.82);
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(25, 25, 25, 0.45);
  display: grid;
  place-items: center;
  z-index: 40;
  pointer-events: none;
}

.drop-overlay-box {
  background: #ffffff;
  color: #191919;
  padding: 24px 32px;
  border-radius: 16px;
  border: 2px dashed #f59e0b;
  font-weight: 700;
  font-size: 15px;
}

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer-wrap {
  background: #ffffff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: #fefce8;
  border-bottom: 1px solid #fef08a;
  font-size: 12px;
}

.reply-bar-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.reply-bar-body span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.attachment-thumbs {
  display: flex;
  gap: 6px;
}

.attachment-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.attachment-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.attachment-meta strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
}

.attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #374151;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

.attach-btn:hover {
  background: #e5e7eb;
}

#composer-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  max-height: 140px;
  padding: 6px 4px;
}

.send-btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  background: var(--kakao-yellow);
  color: var(--kakao-brown);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--kakao-yellow-hover);
}

.send-btn:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

/* ── Lightbox & Toast ────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
}

.lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 8px;
}

.lightbox-toolbar {
  position: fixed;
  top: 16px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.lightbox-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

.lightbox-counter {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #f9fafb;
  font-size: 12.5px;
  font-weight: 600;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.35);
}

.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }

/* ── Auth Overlay ────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-card h2 { margin: 0; font-size: 18px; }

.auth-signin {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 40px;
  text-decoration: none;
}

.session-dialog {
  display: none;
  margin: auto;
  border: 0;
  max-height: 85dvh;
}

.session-dialog[open] { display: flex; }
.session-dialog::backdrop { background: rgba(15, 23, 42, 0.65); }

.session-list {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
  text-align: left;
  list-style: none;
}

.session-list li {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.session-list .btn-secondary { justify-self: start; }

.auth-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
}

.auth-error {
  color: #dc2626;
  font-size: 12.5px;
  font-weight: 600;
}

/* ── Room Settings Dropdown & Composer Popovers ──────────────────────────── */
.room-menu {
  position: absolute;
  top: 52px;
  right: 12px;
  width: 210px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 35;
}

.room-menu-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
}

.room-menu-item:hover {
  background: #f3f4f6;
}

.composer-wrap {
  position: relative;
}

.mention-popover {
  position: absolute;
  bottom: 100%;
  left: 14px;
  right: 14px;
  max-width: 300px;
  max-height: 220px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.14);
  padding: 4px;
  margin-bottom: 6px;
  z-index: 30;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.mention-item:hover,
.mention-item.active {
  background: #fef9c3;
}

.mention-item .avatar {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  font-size: 11px;
}

.emoticon-popover {
  position: absolute;
  bottom: 100%;
  right: 14px;
  width: min(372px, calc(100vw - 28px));
  max-height: 410px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.16);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow: hidden;
}

.emoticon-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #f1f2f4;
  font-size: 12.5px;
  gap: 8px;
}

.emoticon-popover-header strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emoticon-pack-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  overflow-x: auto;
  border-bottom: 1px solid #f1f2f4;
  background: #f8fafc;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.emoticon-pack-tab {
  flex: 0 0 auto;
  width: 38px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 3px;
  font-size: 16px;
  transition: background 0.1s, border-color 0.1s;
}

.emoticon-pack-tab:hover {
  background: #e2e8f0;
}

.emoticon-pack-tab.active {
  background: #ffffff;
  border-color: #facc15;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.emoticon-pack-tab img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.emoticon-preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #fefce8;
  border-bottom: 1px solid #fef08a;
  flex-shrink: 0;
}

.emoticon-preview-bar img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex-shrink: 0;
}

.emoticon-preview-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #334155;
}

.emoticon-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.emoticon-grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  overflow-y: auto;
  min-height: 160px;
}

.emoticon-pick-btn {
  border: 1.5px solid transparent;
  background: #f8fafc;
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1.1;
  transition: background 0.1s, transform 0.08s, border-color 0.1s;
}

.emoticon-pick-btn:hover {
  background: #fef9c3;
  transform: scale(1.05);
}

.emoticon-pick-btn.selected {
  background: #fef08a;
  border-color: #eab308;
}

.emoticon-pick-btn img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

/* ── V3 Rich Message Cards (Vote, Call, Map, Audio, Profile, Contact, AI, Spoilers, Mentions) */
.pin-icon {
  font-size: 10px;
  color: #64748b;
  flex-shrink: 0;
}

.room-load-more {
  width: calc(100% - 28px);
  margin: 10px 14px 16px;
  padding: 9px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  color: #374151;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.room-load-more:hover { background: #f3f4f6; }

.friend-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid #f7f8fa;
  cursor: pointer;
}

.friend-row:hover { background: #f6f7f9; }
.friend-row .avatar { width: 42px; height: 42px; border-radius: 15px; font-size: 14px; }
.friend-name { font-size: 13.5px; font-weight: 600; }
.friend-sub { font-size: 11.5px; color: var(--muted); }

.msg-edited-tag {
  font-size: 10px;
  color: #475569;
  white-space: nowrap;
}

.mention-tag {
  color: #1d4ed8;
  font-weight: 700;
}

.spoiler-mask {
  background: #334155;
  color: transparent;
  border-radius: 4px;
  padding: 0 3px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.spoiler-mask.revealed {
  background: rgba(51, 65, 85, 0.12);
  color: inherit;
  user-select: text;
}

.longtext-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.65);
  color: #1f2937;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.longtext-btn:hover { background: #ffffff; }

.md-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.md-body code {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.video-wrap {
  position: relative;
  display: inline-block;
}

.video-duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.68);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.audio-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  background: #ffffff;
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  width: 255px;
  max-width: 100%;
}

.audio-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.audio-card audio {
  width: 100%;
  height: 32px;
}

.call-card {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  background: #ffffff;
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 13px;
}

.call-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.call-card-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.vote-card {
  width: 268px;
  max-width: 100%;
  background: #ffffff;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.vote-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fef9c3;
  color: #713f12;
  font-size: 12px;
  font-weight: 700;
}

.vote-card-head.closed {
  background: #f1f5f9;
  color: #475569;
}

.vote-card-body {
  padding: 10px 12px;
}

.vote-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #191919;
  line-height: 1.35;
}

.vote-options {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vote-option-item {
  padding: 6px 9px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  color: #334155;
}

.location-card {
  display: block;
  width: 255px;
  max-width: 100%;
  background: #ffffff;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: inherit;
}

.location-card-banner {
  height: 62px;
  background: linear-gradient(135deg, #dbeafe, #fef9c3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.location-card-body {
  padding: 9px 12px;
}

.profile-share-card {
  width: 240px;
  max-width: 100%;
  background: #ffffff;
  border-radius: 13px;
  padding: 11px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-share-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: 15px;
}

.link-card-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

.link-card-price {
  margin-top: 5px;
  font-size: 13.5px;
  font-weight: 800;
  color: #111827;
}

.link-card-items {
  margin-top: 8px;
  border-top: 1px solid #f1f5f9;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link-card-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  font-size: 12px;
}

.link-card-item img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.link-card-buttons {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.link-card-btn {
  flex: 1;
  text-align: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #1f2937;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.link-card-btn:hover { background: #e5e7eb; }

.reply-quote-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reply-quote-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.rail-btn.notif-on {
  color: #059669;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  border-radius: 10px;
  background: #1f2937;
  color: #ffffff;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 110;
}

.mobile-only {
  display: none;
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 48px 1fr;
  }
  .app-shell.mobile-chat-open {
    grid-template-columns: 1fr;
  }
  .app-shell.mobile-chat-open .rail,
  .app-shell.mobile-chat-open .sidebar {
    display: none;
  }
  .app-shell:not(.mobile-chat-open) .main-area {
    display: none;
  }
  .mobile-only {
    display: grid;
  }
  .chat-header {
    padding: 0 8px;
    gap: 6px;
  }
  .chat-header h2 {
    font-size: 14.5px;
  }
  .messages-wrap {
    padding: 10px 10px 14px;
  }
  .msg-row {
    max-width: 92%;
  }
  .composer-row {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .composer-row textarea {
    font-size: 13.5px;
    min-height: 38px;
  }
}
