:root {
  --navy: #1a2332;
  --navy-light: #243044;
  --navy-lighter: #2d3b50;
  --gold: #d4a843;
  --gold-hover: #e0b94f;
  --gold-dim: rgba(212,168,67,0.15);
  --white: #ffffff;
  --warm-white: #f8f6f1;
  --warm-gray: #f0ede6;
  --text: #1a2332;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e2db;
  --msg-own-bg: #d4a843;
  --msg-own-text: #1a2332;
  --msg-other-bg: #ffffff;
  --msg-other-text: #1a2332;
  --sidebar-bg: #243044;
  --sidebar-text: #c9d1d9;
  --sidebar-hover: rgba(255,255,255,0.12);
  --sidebar-active: rgba(212,168,67,0.2);
  --main-bg: #f8f6f1;
  --composer-bg: #ffffff;
  --overlay-bg: rgba(0,0,0,0.5);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --transition: 0.2s ease;
}
[data-theme="dark"] {
  --warm-white: #1e2a3a;
  --warm-gray: #162030;
  --text: #e4e8ec;
  --text-secondary: #8b95a5;
  --text-muted: #5a6577;
  --border: #2d3b50;
  --msg-own-bg: #d4a843;
  --msg-own-text: #1a2332;
  --msg-other-bg: #243044;
  --msg-other-text: #e4e8ec;
  --main-bg: #141d2b;
  --composer-bg: #1a2332;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { display: flex; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; background: var(--main-bg); color: var(--text); height: 100dvh; height: 100vh; overflow: hidden; }
.app { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar { width: 280px; min-width: 280px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s ease; }
.sidebar-header { padding: 16px 20px; padding-top: max(54px, calc(env(safe-area-inset-top, 54px) + 6px)); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-header .logo { font-size: 24px; }
.sidebar-header h1 { font-size: 18px; font-weight: 700; color: var(--gold); }
.sidebar-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
.sidebar-section { padding: 12px 0; }
.sidebar-section-header { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.sidebar-section-header button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px; border-radius: 4px; }
.sidebar-section-header button:hover { color: var(--gold); background: rgba(255,255,255,0.12); }
.channel-item { display: flex; align-items: center; gap: 8px; padding: 6px 16px; cursor: pointer; transition: background var(--transition); font-size: 14px; position: relative; min-height: 36px; }
.channel-item:hover { background: var(--sidebar-hover); }
.channel-item.active { background: var(--sidebar-active); color: var(--gold); }
.channel-item .ch-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.channel-item .ch-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-item.muted .ch-name { opacity: 0.5; }
.channel-item.muted .ch-badge { opacity: 0.3; }

.channel-item.unread .ch-name { font-weight: 700; color: #fff; }
.dm-item.unread .ch-name { font-weight: 700; color: #fff; }
.badge { background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; flex-shrink: 0; }
.mention-badge { background: #ef4444; }
.unread-badge { background: #ef4444; }

/* DM items */
.dm-item { display: flex; align-items: center; gap: 8px; padding: 6px 16px; cursor: pointer; transition: background var(--transition); font-size: 14px; }
.dm-item:hover { background: var(--sidebar-hover); }
.dm-item.active { background: var(--sidebar-active); }

/* User avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; position: relative; overflow: hidden; background-size: cover; background-position: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: 16px; }
.status-dot { position: absolute; bottom: -1px; right: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sidebar-bg); }
.status-dot.online { background: #22c55e; }
.status-dot.away { background: #f59e0b; }
.status-dot.invisible { background: #6b7280; }
.status-dot.offline { background: #6b7280; }
.status-dot.dnd { background: #ef4444; }

/* Online users */
.online-user { display: flex; align-items: center; gap: 8px; padding: 4px 16px; font-size: 13px; }
.online-user .avatar { width: 24px; height: 24px; font-size: 10px; }
.online-user .status-dot { width: 8px; height: 8px; border-width: 1.5px; }

/* Sidebar footer */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 10px; }
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 768px) { .sidebar-footer { display: none !important; } }
.sidebar-footer .user-status { font-size: 11px; color: var(--text-muted); }
.theme-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 18px; padding: 4px; border-radius: 4px; }
.theme-toggle:hover { background: rgba(255,255,255,0.08); }

/* Main area */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* Channel header */
.channel-header { padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--composer-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; min-height: 56px; flex-shrink: 0; }
.channel-header .back-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); padding: 4px; }
.channel-header .header-info { flex: 1; min-width: 0; }
.channel-header .header-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.channel-header .header-desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.header-actions button { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 18px; padding: 8px; border-radius: var(--radius-sm); transition: all var(--transition); }
.header-actions button:hover { background: var(--warm-gray); color: var(--text); }
.header-stats { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; }

/* Messages area */
.messages-container { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Message */
.message-group { display: flex; gap: 10px; padding: 4px 0; position: relative; max-width: 85%; }
.message-group:hover .msg-actions { opacity: 1; }
.message-group.own { align-self: flex-end; flex-direction: row-reverse; }
.message-group .avatar { flex-shrink: 0; margin-top: 2px; }
.msg-body { min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.message-group.own .msg-header { flex-direction: row-reverse; }
.msg-author { font-size: 13px; font-weight: 700; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-bubble { padding: 8px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; word-wrap: break-word; position: relative; }
.message-group:not(.own) .msg-bubble { background: var(--msg-other-bg); color: var(--msg-other-text); border-top-left-radius: 4px; box-shadow: var(--shadow); }
.message-group.own .msg-bubble { background: var(--msg-own-bg); color: var(--msg-own-text); border-top-right-radius: 4px; }
.msg-bubble a { color: inherit; text-decoration: underline; }
.msg-bubble code { background: rgba(0,0,0,0.1); padding: 1px 4px; border-radius: 3px; font-family: 'SF Mono', Monaco, monospace; font-size: 13px; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble .mention { background: var(--gold-dim); color: var(--gold); font-weight: 600; padding: 0 2px; border-radius: 3px; }
.message-group.own .msg-bubble .mention { background: rgba(0,0,0,0.15); color: #1a2332; }
.msg-bubble, .tp-body, .tr-body, .sr-content { user-select: text; -webkit-user-select: text; }
.msg-actions, .reaction-pill, .thread-count, .reply-preview { user-select: none; -webkit-user-select: none; }
.message-jump-highlight .msg-bubble { box-shadow: 0 0 0 3px rgba(198,137,63,0.65), 0 10px 26px rgba(198,137,63,0.22); }

/* Reply preview */
.reply-preview { font-size: 12px; color: var(--text-muted); padding: 4px 10px; margin-bottom: 4px; border-left: 3px solid var(--gold); background: rgba(0,0,0,0.04); border-radius: 0 6px 6px 0; cursor: pointer; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview .reply-author { font-weight: 600; }

/* File message */
.msg-file { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,0.06); border-radius: var(--radius-sm); margin-top: 4px; text-decoration: none; color: inherit; }
.msg-file .file-icon { font-size: 24px; }
.file-preview-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); z-index: 10000; display: none; flex-direction: column; }
.file-preview-overlay.show { display: flex; }
.file-preview-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #002A3A; color: white; flex-shrink: 0; }
.file-preview-bar .fpb-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: 12px; }
.file-preview-bar button { background: rgba(255,255,255,0.15); color: white; border: none; padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; margin-left: 8px; }
.file-preview-bar button:hover { background: rgba(255,255,255,0.25); }
.file-preview-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; }
.file-preview-body iframe { width: 100%; height: 100%; border: none; border-radius: 8px; background: white; }
.file-preview-body .no-preview { color: #94a3b8; text-align: center; font-size: 15px; }
.msg-file .file-name { font-size: 13px; font-weight: 500; }
.msg-file-image { max-width: 300px; border-radius: var(--radius-sm); margin-top: 4px; cursor: pointer; }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-pill { display: flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 12px; font-size: 12px; border: 1px solid var(--border); background: var(--composer-bg); cursor: pointer; transition: all var(--transition); }
.reaction-pill:hover { border-color: var(--gold); }
.reaction-pill.own { background: var(--gold-dim); border-color: var(--gold); }
.reaction-pill .r-count { font-weight: 600; }
.reaction-names { font-size: 11px; color: var(--text-secondary); padding: 2px 0; animation: fadeIn 0.15s ease; }
.reaction-pill { position: relative; cursor: pointer; -webkit-tap-highlight-color: rgba(0,0,0,0.1); }

/* System message */
.system-message { text-align: center; padding: 8px 0; font-size: 13px; color: var(--text-muted); font-style: italic; }

/* Date separator */
.date-separator { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.date-separator::before, .date-separator::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.date-separator span { font-size: 12px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

/* Message actions */
.msg-actions { position: absolute; top: -10px; right: 0; display: flex; gap: 2px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; box-shadow: var(--shadow); opacity: 0; transition: opacity var(--transition); z-index: 10; }
.message-group.own .msg-actions { right: auto; left: 0; }
.msg-actions button { background: none; border: none; cursor: pointer; padding: 4px 6px; font-size: 14px; border-radius: 4px; color: var(--text-secondary); }
.msg-actions button:hover { background: var(--warm-gray); }

/* Reaction quick bar */
.reaction-bar { position: absolute; top: -40px; display: flex; gap: 2px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: 20px; padding: 4px; box-shadow: var(--shadow-lg); z-index: 11; }
.reaction-bar button { background: none; border: none; cursor: pointer; padding: 4px; font-size: 18px; border-radius: 50%; transition: transform 0.15s; }
.reaction-bar button:hover { transform: scale(1.3); }
.pull-refresh-indicator { position: fixed; top: -50px; left: 50%; transform: translateX(-50%); background: var(--gold); color: var(--navy); padding: 8px 20px; border-radius: 0 0 16px 16px; font-size: 13px; font-weight: 700; z-index: 999; transition: top 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.pull-refresh-indicator.visible { top: 0; }
/* Poll Cards */
.poll-card { background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 280px; max-width: 380px; box-shadow: var(--shadow); }
.poll-card .poll-question { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.poll-card .poll-option { cursor: pointer; margin-bottom: 8px; border-radius: var(--radius-sm); overflow: hidden; position: relative; padding: 8px 12px; border: 1px solid var(--border); transition: all 0.2s; }
.poll-card .poll-option:hover { border-color: var(--gold); }
.poll-card .poll-option.voted { border-color: var(--gold); background: var(--gold-dim); }
.poll-card .poll-bar { position: absolute; top: 0; left: 0; height: 100%; background: rgba(212,168,67,0.12); border-radius: var(--radius-sm); transition: width 0.4s ease; z-index: 0; }
.poll-card .poll-option.voted .poll-bar { background: rgba(212,168,67,0.25); }
.poll-card .poll-option-inner { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.poll-card .poll-option-label { display: flex; align-items: center; gap: 6px; }
.poll-card .poll-option-pct { font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.poll-card .poll-footer { font-size: 12px; color: var(--text-muted); margin-top: 8px; }


.reaction-more-btn:hover { opacity: 1 !important; }
.reaction-emoji-picker { position: absolute; bottom: 8px; right: 0; width: 320px; max-height: 350px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; display: flex; flex-direction: column; overflow: hidden; }
.rep-search { padding: 8px; border-bottom: 1px solid var(--border); }
.rep-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--warm-gray); color: var(--text); box-sizing: border-box; outline: none; }
.rep-search input:focus { border-color: var(--gold); }
.rep-grid { padding: 8px; overflow-y: auto; flex: 1; }
.rep-cat { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 4px 4px; margin-top: 4px; }
.rep-grid button { background: none; border: none; cursor: pointer; padding: 6px; font-size: 22px; border-radius: 8px; transition: background 0.15s, transform 0.1s; }
.rep-grid button:hover { background: var(--warm-gray); transform: scale(1.2); }
@media (max-width: 768px) { .reaction-emoji-picker { width: 280px; right: -20px; max-height: 300px; } }

/* Typing indicator */
.typing-indicator { padding: 4px 20px; font-size: 12px; color: var(--text-muted); font-style: italic; min-height: 24px; flex-shrink: 0; }

/* Composer */
.composer-wrapper { padding: 12px 20px 16px; background: var(--composer-bg); border-top: 1px solid var(--border); flex-shrink: 0; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 8px; background: var(--warm-gray); border-radius: var(--radius-sm); border-left: 3px solid var(--gold); font-size: 13px; }
.reply-bar .reply-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar .reply-close { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 2px; }
.composer { display: flex; align-items: flex-end; gap: 8px; background: var(--warm-gray); border-radius: 24px; padding: 6px 8px 6px 16px; border: 2px solid transparent; transition: border-color var(--transition); }
.composer:focus-within { border-color: var(--gold); }
.composer textarea { flex: 1; border: none; background: none; resize: none; font-size: 14px; font-family: inherit; color: var(--text); line-height: 1.5; max-height: 96px; min-height: 24px; height: 24px; outline: none; padding: 2px 0; }
.composer textarea::placeholder { color: var(--text-muted); }
.composer-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 4px; border-radius: 50%; transition: all var(--transition); flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.composer-btn:hover { color: var(--gold); background: var(--gold-dim); }
.send-btn { background: var(--gold) !important; color: var(--navy) !important; border-radius: 50% !important; }
.send-btn:hover { background: var(--gold-hover) !important; }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.desktop-activity-btn { display: none; padding: 8px 12px; margin: 4px 8px 0; background: transparent; color: var(--text-muted); border: 1px solid var(--border); border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; text-align: center; transition: all 0.2s; }
.desktop-activity-btn:hover { background: rgba(212,168,67,0.1); border-color: var(--gold); color: var(--gold); }
.desktop-activity-btn.has-mentions { color: var(--gold); border-color: var(--gold); }
@media (min-width: 769px) { .desktop-activity-btn { display: block; } }
.desktop-action-row { display: none; }
@media (min-width: 769px) { .desktop-action-row { display: flex !important; } }
.desktop-activity-panel { display: none; position: fixed; top: 0; right: 0; bottom: 0; width: 380px; color: #e4e8ec; background: var(--sidebar-bg); border-left: 1px solid var(--border); z-index: 900; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,0.3); }
.desktop-activity-panel.show { display: flex; }
.desktop-activity-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.desktop-activity-header h3 { margin: 0; color: #d4a843; font-size: 16px; }
.desktop-activity-list { flex: 1; overflow-y: auto; padding: 8px 16px; }
.desktop-activity-item { display: flex; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; transition: background 0.15s; }
.desktop-activity-item:hover { background: rgba(255,255,255,0.05); }
.desktop-activity-item .act-content { flex: 1; min-width: 0; }
.desktop-activity-item .act-channel { font-size: 11px; color: #d4a843; font-weight: 600; }
.desktop-activity-item .act-text { font-size: 13px; margin-top: 2px; color: #e4e8ec; }
.desktop-activity-item .act-time { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.new-dm-desktop { display: none; padding: 8px 12px; margin: 4px 8px 8px; background: var(--gold); color: var(--navy); border: none; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; text-align: center; transition: background 0.2s; }
.new-dm-desktop:hover { background: var(--gold-hover); }
@media (min-width: 769px) { .new-dm-desktop { display: block; } }

/* Mention autocomplete */
.mention-popup { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 200px; overflow-y: auto; display: none; z-index: 50; margin-bottom: 4px; }
.mention-popup.show { display: block; }
.mention-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.mention-item:hover, .mention-item.selected { background: var(--gold-dim); }
.mention-item .avatar { width: 24px; height: 24px; font-size: 10px; }

/* Emoji picker */
.gif-picker { position: absolute; bottom: 100%; right: 40px; width: 360px; height: 420px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; z-index: 50; margin-bottom: 4px; flex-direction: column; overflow: hidden; }
.gif-picker.show { display: flex; }
.gif-picker-header { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.gif-picker-header input { flex: 1; border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 13px; background: var(--warm-gray); color: var(--text); outline: none; font-family: inherit; }
.gif-picker-header input:focus { border-color: var(--gold); }
.gif-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 8px; }
.gif-grid img { width: 100%; border-radius: 6px; cursor: pointer; transition: transform .15s; display: block; }
.gif-grid img:hover { transform: scale(1.03); }
@media (max-width: 768px) { .gif-picker { width: 300px; height: 360px; right: 0; } }
.emoji-picker { position: absolute; bottom: 100%; right: 0; width: 320px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; z-index: 50; margin-bottom: 4px; }
.emoji-picker.show { display: flex; flex-direction: column; }
.emoji-search { padding: 8px; border-bottom: 1px solid var(--border); }
.emoji-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--warm-gray); color: var(--text); outline: none; }
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); }
.emoji-tabs button { flex: 1; padding: 6px; background: none; border: none; cursor: pointer; font-size: 16px; opacity: 0.5; transition: all var(--transition); }
.emoji-tabs button:hover, .emoji-tabs button.active { opacity: 1; background: var(--warm-gray); }
.emoji-grid { padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 200px; overflow-y: auto; }
.emoji-grid button { background: none; border: none; cursor: pointer; font-size: 22px; padding: 4px; border-radius: 4px; transition: background 0.15s; }
.emoji-grid button:hover { background: var(--warm-gray); }
.emoji-recent { padding: 4px 8px; }
.emoji-recent-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; margin-bottom: 2px; }

/* Context menu */
.context-menu { position: fixed; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 200; min-width: 180px; padding: 4px; display: none; max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.context-menu.show { display: block; }
.ctx-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; border-radius: var(--radius-xs); color: var(--text); width: 100%; background: none; border: none; text-align: left; }
.ctx-item:hover { background: var(--gold-dim); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Reminder submenu */
.reminder-submenu { padding: 4px; }
.reminder-submenu .ctx-item { font-size: 12px; padding: 6px 12px; }

/* Search overlay */
.search-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 1100; display: none; align-items: flex-start; justify-content: center; padding-top: 60px; }
.search-overlay.show { display: flex; }
.search-panel { background: var(--composer-bg); border-radius: var(--radius); width: 90%; max-width: 560px; max-height: 70vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.search-panel-header { padding: 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.search-panel-header input { flex: 1; border: none; background: none; font-size: 16px; color: var(--text); outline: none; }
.search-panel-header button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.search-results { flex: 1; overflow-y: auto; padding: 8px; }
.search-result { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.search-result:hover { background: var(--warm-gray); }
.search-result .sr-channel { font-size: 11px; color: var(--gold); font-weight: 600; }
.search-result .sr-author { font-size: 12px; font-weight: 600; }
.search-result .sr-content { font-size: 13px; margin-top: 2px; }
.search-result .sr-time { font-size: 11px; color: var(--text-muted); }
.search-empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* Pins panel */
.pins-panel { position: absolute; top: 56px; right: 0; width: 360px; max-width: 100%; height: calc(100% - 56px); background: var(--composer-bg); border-left: 1px solid var(--border); z-index: 50; display: none; flex-direction: column; box-shadow: var(--shadow-lg); }
.pins-panel.show { display: flex; }
.pins-panel-header { padding: 16px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.pins-panel-header button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.pins-list { flex: 1; overflow-y: auto; padding: 8px; }
.pinned-msg { padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; }
.pinned-msg .pm-author { font-size: 12px; font-weight: 600; }
.pinned-msg .pm-content { font-size: 13px; margin-top: 4px; }
.pinned-msg .pm-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Members panel */
.members-panel { position: absolute; top: 56px; right: 0; width: 280px; max-width: 100%; height: calc(100% - 56px); background: var(--composer-bg); border-left: 1px solid var(--border); z-index: 50; display: none; flex-direction: column; }
.members-panel.show { display: flex; }
.members-panel-header { padding: 16px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.members-panel-header button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.members-list { flex: 1; overflow-y: auto; padding: 8px; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.member-item .member-name { font-size: 13px; font-weight: 500; }
.member-item .member-role { font-size: 11px; color: var(--text-muted); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 300; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-overlay .btn { -webkit-tap-highlight-color: rgba(0,0,0,0.1); touch-action: manipulation; cursor: pointer; position: relative; z-index: 10; }
.modal { background: var(--composer-bg); border-radius: var(--radius); width: 90%; max-width: 440px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: 16px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--composer-bg); color: var(--text); transition: all var(--transition); }
.btn-primary { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-hover); }
.format-toolbar { display:flex; gap:4px; flex-wrap:wrap; }
.fmt-btn { background:var(--hover); border:1px solid var(--border); border-radius:4px; padding:4px 10px; cursor:pointer; font-size:13px; color:var(--text); transition:all .15s; }
.fmt-btn:hover { background:var(--gold); color:var(--navy); }
.icon-option { cursor:pointer; font-size:22px; padding:4px 6px; border-radius:6px; border:2px solid transparent; transition:all .15s; }
.icon-option:hover { background:var(--hover); }
.icon-option.selected { border-color:var(--gold); background:rgba(212,168,67,0.15); }

/* DM modal pills */
.selected-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 0; }
.selected-pill { display: flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--gold-dim); border-radius: 16px; font-size: 12px; font-weight: 600; }
.selected-pill button { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); }
.staff-check-list { display: flex; flex-direction: column; gap: 2px; }
.staff-check-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.staff-check-item:hover { background: var(--warm-gray); }
.staff-check-item input { accent-color: var(--gold); width: 16px; height: 16px; }
.staff-check-item .avatar { width: 28px; height: 28px; font-size: 11px; }

/* Status modal */
.status-option { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.status-option:hover { background: var(--warm-gray); }
.status-option.active { background: var(--gold-dim); }
.status-custom-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; margin-top: 12px; background: var(--warm-gray); color: var(--text); outline: none; }

/* Confetti */
.confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti-piece { position: absolute; top: -10px; width: 10px; height: 10px; animation: confetti-fall 3s linear forwards; }
@keyframes confetti-fall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Reminder popup */
.reminder-toast { position: fixed; top: 20px; right: 20px; background: var(--composer-bg); border: 2px solid var(--gold); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-lg); z-index: 500; max-width: 320px; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.reminder-toast .rt-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.reminder-toast .rt-text { font-size: 13px; margin-top: 4px; }
.reminder-toast .rt-close { position: absolute; top: 8px; right: 8px; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); }
.onboard-toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--composer-bg); border: 2px solid #3b82f6; border-image: linear-gradient(135deg, #3b82f6, #d4a017) 1; border-radius: 0; padding: 16px 20px; box-shadow: var(--shadow-lg); z-index: 500; max-width: 340px; animation: slideIn 0.3s ease; text-align: center; }
.onboard-toast .ot-text { font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.help-tip { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.help-tip:last-child { border-bottom: none; }
.help-tip strong { color: var(--gold); }
.onboard-toast .ot-btn { background: linear-gradient(135deg, #3b82f6, #d4a017); color: #fff; border: none; border-radius: 8px; padding: 8px 24px; font-size: 14px; font-weight: 700; cursor: pointer; }


/* Drag overlay */
.drag-overlay { position: absolute; inset: 0; background: rgba(212,168,67,0.15); border: 3px dashed var(--gold); display: none; align-items: center; justify-content: center; z-index: 100; pointer-events: none; border-radius: var(--radius); }
.drag-overlay.show { display: flex; }
.drag-overlay span { font-size: 18px; font-weight: 700; color: var(--gold); background: var(--composer-bg); padding: 12px 24px; border-radius: var(--radius); }

/* Loading */
.loading-messages { text-align: center; padding: 20px; color: var(--text-muted); }

/* Hamburger */
.hamburger { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); padding: 4px; }

/* Mobile */
@media (max-width: 768px) {
  html, body { height: 100%; overflow: hidden; }
  /* .app height handled by flex */
  .main { height: var(--pack-viewport-height, 100dvh); height: -webkit-fill-available; display: flex; flex-direction: column; }
  .sidebar { position: fixed; left: 0; top: 0; width: 100%; height: 100%; padding-top: 48px; padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); transform: translateX(0); z-index: 200; overflow-y: auto; }
  .sidebar.hidden { transform: translateX(-100%); }
  .sidebar-backdrop { display: none; }
  .hamburger { display: block; }
  .channel-header .back-btn { display: block; }
  .channel-header { flex-shrink: 0; gap: 6px; padding-left: 8px; padding-right: 8px; }
  .channel-header .header-name { font-size: 14px; overflow: hidden; white-space: nowrap; }
  .channel-header .header-name span[style*="font-size:10px"] { display: none !important; }
  .header-stats { display: none !important; }
  .header-actions button { padding: 6px; font-size: 16px; }
  .messages-container { flex: 1; min-height: 0; padding-bottom: 14px; }
  .composer-wrapper { flex-shrink: 0; padding: 8px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .format-toolbar { padding: 4px 8px 0 !important; }
  .pins-panel, .members-panel { width: 100%; }
  .message-group { max-width: 95%; }
  .gif-picker { position: absolute; bottom: 100%; right: 40px; width: 360px; height: 420px; background: var(--composer-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; z-index: 50; margin-bottom: 4px; flex-direction: column; overflow: hidden; }
.gif-picker.show { display: flex; }
.gif-picker-header { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.gif-picker-header input { flex: 1; border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 13px; background: var(--warm-gray); color: var(--text); outline: none; font-family: inherit; }
.gif-picker-header input:focus { border-color: var(--gold); }
.gif-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 8px; }
.gif-grid img { width: 100%; border-radius: 6px; cursor: pointer; transition: transform .15s; display: block; }
.gif-grid img:hover { transform: scale(1.03); }
@media (max-width: 768px) { .gif-picker { width: 300px; height: 360px; right: 0; } }
.emoji-picker { width: 280px; right: -40px; }
}

@keyframes slideDown { from { transform: translateX(-50%) translateY(-100%); opacity:0; } to { transform: translateX(-50%) translateY(0); opacity:1; } }
/* Notification sound (via Web Audio) */

/* Forward modal */
.forward-modal-list { max-height: 300px; overflow-y: auto; }
.forward-ch-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-radius: 8px; font-size: 14px; }
.forward-ch-item:hover { background: var(--warm-gray); }
.forward-ch-item .fwd-icon { font-size: 16px; width: 24px; text-align: center; }

/* New messages indicator */
.new-msg-bar { position: sticky; bottom: 0; left: 0; right: 0; text-align: center; padding: 8px 16px; background: var(--gold); color: var(--navy); font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 20px; margin: 4px auto; max-width: 200px; box-shadow: var(--shadow-lg); z-index: 20; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.new-msg-bar:hover { background: var(--gold-hover); }
.new-msg-divider { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: #ef4444; font-size: 12px; font-weight: 700; }
.new-msg-divider::before, .new-msg-divider::after { content: ''; flex: 1; height: 1px; background: #ef4444; }

/* Sidebar quick actions (mobile) */
.sidebar-quick-actions { display: none; padding: 8px 16px; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-quick-actions button { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; }
.sidebar-quick-actions button:active { background: rgba(255,255,255,0.12); }
@media (max-width: 768px) { .sidebar-quick-actions { display: flex; } }

/* Bookmarks bar */
.bookmarks-bar { display: flex; align-items: center; gap: 8px; padding: 8px 20px; background: var(--composer-bg); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; width: 100%; z-index: 50; }
.bookmark-close-btn { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 2px 8px; margin-left: auto; border-radius: 4px; }
.bookmark-close-btn:hover { color: var(--text); background: rgba(0,0,0,0.1); }
.bookmark-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--warm-gray); border: 1px solid var(--border); color: var(--text); transition: all var(--transition); white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.bookmark-btn:hover { background: var(--gold-dim); border-color: var(--gold); }
.bookmark-btn:hover { background: var(--gold-dim); border-color: var(--gold); }
.bookmark-btn .bm-count { background: var(--gold); color: var(--navy); font-size: 10px; padding: 0 5px; border-radius: 8px; font-weight: 700; min-width: 16px; text-align: center; }

/* Bookmarks panel */
.bookmarks-panel { position: fixed; top: 36px; left: 280px; right: 0; background: var(--composer-bg); border-bottom: 2px solid var(--border); z-index: 150; max-height: 50vh; overflow-y: auto; box-shadow: var(--shadow-lg); display: none; padding: 12px 20px; }
.bookmarks-panel.show { display: block; }
@media (max-width: 768px) { .bookmarks-panel { left: 0 !important; right: 0 !important; top: 50px !important; padding: 12px !important; max-height: 60vh !important; } }
.bm-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 6px; }
.bm-item .bm-content { flex: 1; min-width: 0; font-size: 13px; }
.bm-item .bm-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bm-item .bm-cancel-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; color: var(--text-secondary); white-space: nowrap; }
.bm-cancel-btn:active { background: var(--hover); }
.bm-delete { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 2px; flex-shrink: 0; }
.bm-item .bm-delete:hover { color: #e74c3c; }
.bm-empty { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* Channel reorder buttons */
.reorder-btns { display: flex; flex-direction: column; gap: 0; margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.channel-item:hover .reorder-btns { opacity: 1; }
.reorder-btn { background: none; border: none; cursor: pointer; font-size: 10px; line-height: 1; padding: 1px 4px; color: var(--text-muted); border-radius: 2px; }
.reorder-btn:hover { color: var(--gold); background: rgba(255,255,255,0.1); }

/* Mobile adjustments */
@media (max-width: 768px) {
  .bookmarks-bar { padding: 4px 12px; gap: 4px; display: none !important; }
  .bookmark-btn { padding: 3px 8px; font-size: 11px; }
  .reorder-btns { opacity: 0.6; }
}

/* Scrollbar global */
* { scrollbar-width: thin; }

/* ═══ MOBILE UX: Slack-style cards, bottom nav, FAB ═══ */
.mobile-card-strip {
  display: none;
  padding: 10px 12px;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.mobile-card-strip::-webkit-scrollbar { display: none; }
.mobile-card {
  flex: 0 0 auto;
  width: 120px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s;
}
.mobile-card:active { background: rgba(255,255,255,0.15); }
.mobile-card-icon { font-size: 20px; }
.online-carousel { display: flex; gap: 12px; padding: 12px 16px 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; position: relative; }
.online-carousel::-webkit-scrollbar { display: none; }
.carousel-wrap { position: relative; }
.carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 28px; height: 28px; border-radius: 50%; background: var(--composer-bg); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s; }
.carousel-wrap:hover .carousel-arrow { opacity: 1; }
.carousel-arrow.left { left: 4px; }
.carousel-arrow.right { right: 4px; }
@media (max-width: 768px) { .carousel-arrow { display: none !important; } }
.notes-card { min-width: 100px; max-width: 130px; background: var(--hover); border-radius: 10px; padding: 6px 8px; cursor: pointer; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; border: 1.5px solid var(--gold-dim); transition: border-color .2s; }
.notes-card:hover { border-color: var(--gold); }
.notes-card-header { font-size: 11px; font-weight: 700; color: var(--gold); display: flex; align-items: center; gap: 4px; }
.notes-card-body { font-size: 10px; color: var(--muted); line-height: 1.2; max-height: 28px; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.notes-card-empty { font-size: 11px; color: var(--muted); opacity: .5; font-style: italic; }
.notes-modal-textarea { width: 100%; min-height: 150px; background: var(--sidebar); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 14px; font-family: inherit; resize: vertical; }
.notes-toolbar { display: flex; gap: 2px; padding: 4px; background: var(--sidebar); border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; flex-wrap: wrap; }
.notes-toolbar button { background: none; border: none; color: var(--text); cursor: pointer; padding: 4px 8px; border-radius: 4px; font-size: 14px; min-width: 30px; }
.notes-toolbar button:hover { background: var(--hover); }
.notes-toolbar .tb-sep { width: 1px; background: var(--border); margin: 2px 4px; }
.notes-editor { width: 100%; min-height: 180px; background: var(--sidebar); color: var(--text); border: 1px solid var(--border); border-radius: 0 0 8px 8px; padding: 10px; font-size: 14px; font-family: inherit; outline: none; overflow-y: auto; max-height: 50vh; line-height: 1.5; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; }
.notes-editor:empty:before { content: attr(data-placeholder); color: var(--muted); opacity: .5; }
.notes-editor ul, .notes-editor ol { padding-left: 20px; margin: 4px 0; }
.notes-editor h3 { margin: 4px 0; font-size: 16px; }
.notes-editor blockquote { border-left: 3px solid var(--gold); padding-left: 10px; margin: 4px 0; color: var(--muted); }
.msg-color-picker { display: none; position: fixed; background: var(--sidebar); border: 1px solid var(--border); border-radius: 8px; padding: 6px; gap: 4px; flex-wrap: wrap; z-index: 9999; width: 120px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.msg-color-picker.show { display: flex; }
.notes-color-picker { display: none; position: absolute; background: var(--sidebar); border: 1px solid var(--border); border-radius: 8px; padding: 6px; gap: 4px; flex-wrap: wrap; z-index: 99; width: 120px; }
.notes-color-picker.show { display: flex; }
.notes-color-dot { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.notes-color-dot:hover { border-color: var(--gold); }
.notes-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; max-height: 30vh; overflow-y: auto; }
.notes-list-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--hover); border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; transition: all .15s; }
.notes-list-item:hover { background: var(--border); }
.notes-list-item.active { border-left-color: var(--gold); background: var(--border); }
.notes-list-item .nli-title { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-list-item .nli-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.notes-list-item .nli-delete { opacity: .4; font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.notes-list-item .nli-delete:hover { opacity: 1; background: #e74c3c33; color: #e74c3c; }
.notes-title-input { background: none; border: none; color: var(--text); font-size: 16px; font-weight: 700; width: 100%; outline: none; padding: 4px 0; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.notes-add-btn { background: var(--gold-dim); color: var(--gold); border: none; border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; align-self: flex-start; }
.notes-add-btn:hover { background: var(--gold); color: #000; }
.notes-view-list .notes-edit-area { display: none; }
.notes-view-edit .notes-list-area { display: none; }
.online-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; cursor: pointer; }
.online-avatar-wrap img, .online-avatar-wrap .online-avatar-placeholder { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); }
.online-avatar-placeholder { background: var(--gold-dim); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: var(--gold); }
.online-avatar-wrap .online-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--navy); position: absolute; bottom: 14px; right: 0; }
.online-avatar-wrap .av-container { position: relative; }
.online-avatar-wrap .online-name { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56px; text-align: center; }
.mobile-card-label { font-size: 12px; font-weight: 600; color: var(--sidebar-text); }
.mobile-card-count { font-size: 11px; color: var(--gold); font-weight: 700; }

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--composer-bg);
  border-top: 1px solid var(--border);
  z-index: 250;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bottom-nav-inner { display: flex; height: 56px; }
.mobile-nav-tab { touch-action: manipulation;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 10px; font-weight: 600;
  padding: 0; transition: color 0.15s; position: relative;
}
.mobile-nav-tab.active { color: var(--gold); }
.mobile-nav-tab-icon { font-size: 22px; line-height: 1; }
.mobile-nav-tab .nav-badge {
  position: absolute; top: 4px; right: 50%; margin-right: -18px;
  background: #ef4444; color: #fff; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 8px; padding: 0 4px;
}

.mobile-fab {
  display: none;
  position: fixed; bottom: 116px; right: 16px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gold); color: var(--navy); border: none; cursor: pointer;
  font-size: 28px; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 210; transition: transform 0.2s;
  align-items: center; justify-content: center;
}
.mobile-fab:active { transform: scale(0.92); }
.mobile-fab-menu {
  display: none; position: fixed; bottom: 180px; right: 16px;
  background: var(--composer-bg); border-radius: 12px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  z-index: 220; overflow: hidden; min-width: 180px;
}
.mobile-fab-menu.show { display: block; }
.mobile-fab-item {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; background: none;
  border: none; width: 100%; color: var(--text); text-align: left;
}
.mobile-fab-item:active { background: var(--warm-gray); }
.mobile-fab-item + .mobile-fab-item { border-top: 1px solid var(--border); }

.mobile-activity-panel {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 56px;
  background: var(--main-bg); z-index: 195; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-activity-panel.show { display: flex; }
.mobile-activity-header {
  padding: 16px 20px; padding-top: max(16px, env(safe-area-inset-top));
  font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.mobile-activity-list { flex: 1; overflow-y: auto; padding: 8px 16px; }
.mobile-activity-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.mobile-activity-item .act-content { flex: 1; min-width: 0; }
.mobile-activity-item .act-channel { font-size: 11px; color: var(--gold); font-weight: 600; }
.mobile-activity-item .act-text { font-size: 13px; margin-top: 2px; }
.mobile-activity-item .act-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.mobile-more-panel {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 56px;
  background: var(--main-bg); z-index: 195; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-more-panel.show { display: flex; }
.mobile-more-scroll { flex: 1; overflow-y: auto; padding: 12px 16px; }
.mobile-more-item { touch-action: manipulation;
  display: flex; align-items: center; gap: 12px; padding: 14px 12px;
  border-radius: 10px; font-size: 15px; cursor: pointer; color: var(--text); text-decoration: none;
}
.mobile-more-item:active { background: var(--warm-gray); }
.mobile-more-item .more-icon { font-size: 20px; width: 28px; text-align: center; }
.mobile-more-section {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.05em; padding: 16px 12px 6px;
}

@media (max-width: 768px) {
  .sidebar-quick-actions { display: none !important; }
  .mobile-card-strip { display: none; } /* hidden by default, toggled */
  .mobile-card-strip.expanded { display: flex !important; }
  .online-carousel { display: none; } /* hidden by default, toggled */
  .online-carousel.expanded { display: flex !important; }
  .sidebar-top-toggle { display: flex !important; }
  .mobile-bottom-nav { display: block; }
  .mobile-fab { display: flex; }
  .composer-wrapper { padding-bottom: max(12px, env(safe-area-inset-bottom)) !important; margin-bottom: 56px; }
  body.mobile-channel-open .composer-wrapper { margin-bottom: 0 !important; }
  body.mobile-channel-open .mobile-bottom-nav,
  body.mobile-channel-open .mobile-fab { display: none !important; }
  body.mobile-keyboard-open .mobile-bottom-nav,
  body.mobile-keyboard-open .mobile-fab { display: none !important; }
  body.mobile-keyboard-open .composer-wrapper { padding-bottom: max(8px, env(safe-area-inset-bottom)) !important; }
}
@media (min-width: 769px) {
  .mobile-card-strip, .mobile-bottom-nav, .mobile-fab,
  .mobile-activity-panel, .mobile-more-panel { display: none !important; }
  .mobile-fab-menu { display: none; }
}


/* Compact mobile cards */
@media (max-width: 768px) {
  .mobile-card { padding: 8px 12px !important; min-width: 90px !important; }
  .mobile-card-icon { font-size: 18px !important; }
  .mobile-card-label { font-size: 11px !important; }
  .mobile-card-count { font-size: 10px !important; }
  .online-carousel { padding: 6px 12px !important; }
  .online-avatar-wrap img, .online-avatar-wrap .av-container { width: 40px !important; height: 40px !important; }
  .online-name { font-size: 10px !important; }
  .sidebar-header { padding: 10px 16px !important; }
  .sidebar-header h1 { font-size: 16px !important; }
  .sidebar-header .logo, .sidebar-header img { width: 36px !important; height: 36px !important; }
}

/* Thread panel */
.thread-panel { position: fixed; top: 0; right: 0; width: 380px; height: 100%; background: var(--composer-bg); border-left: 1px solid var(--border); z-index: 300; display: none; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,0.15); }
.thread-panel.show { display: flex; }
.thread-header { padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top, 14px)); font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.thread-header button { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--text-muted); padding: 8px 12px; border-radius: 8px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.thread-messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.thread-parent { padding: 12px; background: var(--warm-gray); border-radius: 12px; border-left: 3px solid var(--gold); margin-bottom: 8px; }
.thread-parent .tp-name { font-weight: 700; font-size: 13px; }
.thread-parent .tp-time { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.thread-parent .tp-body { font-size: 14px; margin-top: 4px; line-height: 1.5; }
.thread-reply { padding: 8px 12px; border-radius: 10px; }
.thread-reply .tr-name { font-weight: 600; font-size: 12px; }
.thread-reply .tr-time { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.thread-reply .tr-body { font-size: 14px; margin-top: 2px; line-height: 1.4; }
.thread-composer { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.thread-composer textarea { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font-size: 14px; font-family: inherit; resize: none; max-height: 80px; min-height: 36px; background: var(--warm-gray); color: var(--text); outline: none; }
.thread-composer button { background: var(--gold); color: var(--navy); border: none; border-radius: 50%; width: 36px; height: 36px; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.thread-count { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--gold); cursor: pointer; margin-top: 2px; font-weight: 600; }
.thread-count:hover { text-decoration: underline; }
@media (max-width: 768px) {
  .thread-panel { width: 100%; }
}


/* ─── Rich Text: Colors, Sizes, Tags ─── */
.fmt-colors { display: flex; gap: 4px; align-items: center; margin-left: 6px; }
.fmt-color-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform 0.15s, border-color 0.15s; flex-shrink: 0; }
.fmt-color-dot:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.5); }
.fmt-sizes { display: flex; gap: 2px; margin-left: 6px; }
.fmt-size-btn { padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); background: var(--composer-bg); color: var(--text); cursor: pointer; font-weight: 600; font-size: 11px; }
.fmt-size-btn:hover { background: var(--gold-dim); border-color: var(--gold); }
.fmt-tags { display: flex; gap: 3px; margin-left: 6px; }
.fmt-tag-btn { padding: 2px 7px; border-radius: 10px; border: none; cursor: pointer; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.fmt-tag-btn.tag-action { background: #e74c3c; color: #fff; }
.fmt-tag-btn.tag-fyi { background: #3498db; color: #fff; }
.fmt-tag-btn.tag-urgent { background: #e74c3c; color: #fff; animation: pulse-urgent 1s infinite; }
.msg-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-right: 4px; margin-bottom: 4px; }
.msg-tag-action { background: #e74c3c; color: #fff; }
.msg-tag-fyi { background: #3498db; color: #fff; }
.msg-tag-urgent { background: #e74c3c; color: #fff; animation: pulse-urgent 1.5s infinite; }
@keyframes pulse-urgent { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ─── Format bar mobile scroll ─── */
.format-toolbar { display: flex; align-items: center; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 2px; }
.format-toolbar::-webkit-scrollbar { display: none; }

/* ─── Message Effects ─── */
@keyframes confetti-fall { 0% { transform: translateY(-100%) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }
@keyframes fire-glow { 0% { box-shadow: 0 0 5px #ff6600, 0 0 10px #ff3300; } 50% { box-shadow: 0 0 15px #ff6600, 0 0 25px #ff3300, 0 0 35px #ff0000; } 100% { box-shadow: 0 0 5px #ff6600, 0 0 10px #ff3300; } }
.msg-effect-confetti { position: relative; overflow: visible; }
.msg-effect-confetti::before { content: "🎉"; position: absolute; top: -8px; right: -8px; font-size: 20px; animation: confetti-fall 2s ease-out forwards; pointer-events: none; }
.msg-effect-fire { animation: fire-glow 1.5s ease-in-out 3; border-radius: 12px; }
.confetti-piece { position: fixed; top: -10px; width: 10px; height: 10px; border-radius: 2px; animation: confetti-fall 3s ease-out forwards; pointer-events: none; z-index: 9999; }

/* ─── Birthday Banner ─── */
.birthday-banner { background: linear-gradient(135deg, #ff6b9d, #c44dff, #6e8efb); padding: 10px 14px; margin: 8px 12px; border-radius: 12px; color: #fff; font-size: 13px; text-align: center; animation: birthday-shimmer 3s ease infinite; }
@keyframes birthday-shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.birthday-banner { background-size: 200% 200%; }

/* ─── Daily Trivia Card ─── */
.trivia-card { background: var(--composer-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 8px 12px; }
.trivia-card h4 { margin: 0 0 8px; font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.05em; }
.trivia-card .trivia-q { font-size: 13px; margin-bottom: 8px; line-height: 1.4; }
.trivia-choices { display: flex; flex-direction: column; gap: 4px; }
.trivia-choice { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; font-size: 12px; text-align: left; transition: all 0.2s; }
.trivia-choice:hover { border-color: var(--gold); background: var(--gold-dim); }
.trivia-choice.correct { background: #2ecc71; color: #fff; border-color: #27ae60; }
.trivia-choice.wrong { background: #e74c3c; color: #fff; border-color: #c0392b; }


/* Image Lightbox */
.vv-lightbox { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.92); z-index:99999; align-items:center; justify-content:center; flex-direction:column; }
.vv-lightbox.active { display:flex; }
.vv-lightbox img { max-width:92vw; max-height:85vh; object-fit:contain; border-radius:8px; }
.vv-lightbox-close { position:absolute; top:max(16px, env(safe-area-inset-top, 16px)); right:16px; background:rgba(255,255,255,0.2); border:none; color:#fff; font-size:28px; width:44px; height:44px; border-radius:50%; cursor:pointer; display:flex; align-items:center; justify-content:center; z-index:100000; -webkit-tap-highlight-color:transparent; }
.vv-lightbox-close:hover { background:rgba(255,255,255,0.4); }
/* ── Mobile composer: collapse attach/poll/gif behind + button ── */
@media (max-width: 768px) {
  .composer-desktop-btn { display: none !important; }
  #composerMoreBtn { display: flex !important; font-size: 22px; font-weight: 700; color: var(--text-muted); }
  #composerMoreBtn.active { color: var(--gold); background: var(--gold-dim); }
}
@media (min-width: 769px) {
  #composerMoreBtn { display: none !important; }
  #composerMoreMenu { display: none !important; }
  .composer-desktop-btn { display: flex; }
}
.composer-more-menu {
  position: absolute;
  bottom: 100%;
  left: 12px;
  background: var(--composer-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 55;
  margin-bottom: 6px;
}
.composer-more-menu .composer-btn {
  font-size: 13px;
  width: auto;
  padding: 6px 12px;
  border-radius: 8px;
  gap: 4px;
  white-space: nowrap;
}

/* Sidebar top toggle (mobile only) */
.sidebar-top-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4px 16px 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
  letter-spacing: .03em;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-top-toggle:active { opacity: 0.7; }

