:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a26;
  --bg-elevated: #1e1e2e;
  --bg-glass: rgba(26, 26, 42, 0.72);
  --bg-glass-light: rgba(40, 40, 66, 0.5);
  --border-subtle: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.1);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-tertiary: #5a5a72;
  --accent: #2AABEE;
  --accent-hover: #1d95d2;
  --accent-glow: rgba(42,171,238,0.15);
  --accent-glow-strong: rgba(42,171,238,0.3);
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --purple: #AF52DE;
  --bubble-out: #2AABEE;
  --bubble-in: #1e1e2e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(42,171,238,0.15);
  --transition-fast: 150ms cubic-bezier(0.25,0.1,0.25,1);
  --transition-normal: 250ms cubic-bezier(0.25,0.1,0.25,1);
  --transition-spring: 400ms cubic-bezier(0.34,1.56,0.64,1);
  --sidebar-width: 340px;
  --profile-width: 320px;
  --header-height: 60px;
  --composer-min-height: 56px;
  --nav-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif; background: var(--bg-primary); color: var(--text-primary); overflow: hidden; -webkit-font-smoothing: antialiased; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
input, textarea, button, select { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
.icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ===== LANDING ===== */
#landing-page { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; background: var(--bg-primary); transition: opacity 0.5s ease, transform 0.5s ease; }
#landing-page.hidden { opacity: 0; transform: scale(1.05); pointer-events: none; }
.landing-bg { position: absolute; inset: 0; overflow: hidden; }
.landing-bg::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(ellipse at 30% 50%, rgba(42,171,238,0.08) 0%, transparent 50%), radial-gradient(ellipse at 70% 50%, rgba(175,82,222,0.06) 0%, transparent 50%); animation: bgDrift 20s ease-in-out infinite; }
@keyframes bgDrift { 0%, 100% { transform: translate(0,0); } 33% { transform: translate(2%,-1%); } 66% { transform: translate(-1%,2%); } }
.landing-card { position: relative; width: 420px; max-width: 90vw; padding: 48px 40px; background: var(--bg-glass); backdrop-filter: blur(40px) saturate(1.5); -webkit-backdrop-filter: blur(40px) saturate(1.5); border: 1px solid var(--border-light); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg), var(--shadow-glow); text-align: center; animation: cardEntry 0.8s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes cardEntry { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.landing-logo { width: 64px; height: 64px; margin: 0 auto 24px; background: linear-gradient(135deg, var(--accent), var(--purple)); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(42,171,238,0.3); }
.landing-logo .icon { width: 32px; height: 32px; color: #fff; }
.landing-card h1 { font-size: 28px; font-weight: 700; background: linear-gradient(135deg, #fff, #ccc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 8px; }
.landing-card p { color: var(--text-secondary); font-size: 15px; margin-bottom: 32px; line-height: 1.5; }
.token-input-wrapper { position: relative; margin-bottom: 20px; }
.token-input-wrapper .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); width: 18px; height: 18px; transition: color var(--transition-fast); }
.token-input-wrapper.focused .icon { color: var(--accent); }
.token-input-wrapper.error .icon { color: var(--red); }
.token-input-wrapper.success .icon { color: var(--green); }
#token-input { width: 100%; padding: 14px 16px 14px 44px; background: var(--bg-secondary); border: 1.5px solid var(--border-light); border-radius: var(--radius-md); color: var(--text-primary); font-size: 15px; outline: none; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
#token-input::placeholder { color: var(--text-tertiary); }
#token-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.token-input-wrapper.error #token-input { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,59,48,0.15); }
.token-input-wrapper.success #token-input { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52,199,89,0.15); }
.token-feedback { font-size: 13px; margin-top: 8px; min-height: 20px; }
.token-feedback.error { color: var(--red); }
.token-feedback.success { color: var(--green); }
#connect-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--accent), #1d8ac0); border: none; border-radius: var(--radius-md); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; transition: all var(--transition-fast); position: relative; overflow: hidden; }
#connect-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(42,171,238,0.4); }
#connect-btn:disabled { opacity: 0.6; cursor: not-allowed; }
#connect-btn .spinner { display: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; margin: 0 auto; }
#connect-btn.loading .btn-text { display: none; }
#connect-btn.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.saved-sessions { margin-top: 28px; border-top: 1px solid var(--border-subtle); padding-top: 20px; }
.saved-sessions h3 { font-size: 13px; color: var(--text-tertiary); font-weight: 500; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.saved-session-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 8px; transition: all var(--transition-fast); }
.saved-session-item:hover { border-color: var(--accent); background: var(--bg-tertiary); }
.saved-session-item .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: #fff; flex-shrink: 0; }
.saved-session-item .info { flex: 1; text-align: left; min-width: 0; }
.saved-session-item .info .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-session-item .info .username { font-size: 12px; color: var(--text-secondary); }

/* ===== DASHBOARD ===== */
#dashboard { position: fixed; inset: 0; display: none; opacity: 0; transition: opacity 0.4s ease; }
#dashboard.visible { display: flex; opacity: 1; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; flex-shrink: 0; height: 100%; }
.sidebar-header { padding: 16px; flex-shrink: 0; }
.bot-card { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; position: relative; }
.bot-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: #fff; flex-shrink: 0; }
.bot-info { flex: 1; min-width: 0; }
.bot-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-username { font-size: 12px; color: var(--text-secondary); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px rgba(52,199,89,0.5); flex-shrink: 0; }
.search-bar { position: relative; }
.search-bar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary); }
#search-input { width: 100%; padding: 10px 12px 10px 36px; background: var(--bg-tertiary); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; outline: none; transition: border-color var(--transition-fast); }
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-tertiary); }

.chat-list { flex: 1; overflow-y: auto; padding: 0 8px; min-height: 0; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition-fast); }
.chat-item:hover { background: var(--bg-tertiary); }
.chat-item.active { background: var(--accent-glow); }
.chat-item .avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; color: #fff; flex-shrink: 0; }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.chat-item-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-item-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; margin-left: 8px; }
.chat-item-bottom { display: flex; align-items: center; justify-content: space-between; }
.chat-item-preview { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.unread-badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0; margin-left: 8px; }

/* Sidebar Nav - always visible */
.sidebar-nav { display: flex; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--border-subtle); flex-shrink: 0; background: var(--bg-secondary); }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border: none; background: transparent; color: var(--text-tertiary); font-size: 10px; font-weight: 500; cursor: pointer; border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.nav-btn .icon { width: 20px; height: 20px; }
.nav-btn:hover { color: var(--text-secondary); background: var(--bg-tertiary); }
.nav-btn.active { color: var(--accent); }

/* Chat Panel */
.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); min-width: 0; height: 100%; }
.chat-header { display: none; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; height: var(--header-height); }
.chat-header .back-btn { display: none; background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 4px; border-radius: 50%; }
.contact-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: #fff; flex-shrink: 0; cursor: pointer; }
.contact-info { flex: 1; min-width: 0; cursor: pointer; }
.contact-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-status { font-size: 12px; color: var(--text-secondary); }
.header-actions { display: flex; gap: 4px; }
.header-actions button { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 50%; transition: all var(--transition-fast); }
.header-actions button:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.empty-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-tertiary); gap: 12px; }
.empty-chat .icon { width: 64px; height: 64px; opacity: 0.3; }
.empty-chat h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }

.messages-container { flex: 1; overflow-y: auto; padding: 16px; display: none; flex-direction: column; gap: 2px; min-height: 0; }
.date-separator { text-align: center; padding: 12px 0; }
.date-separator span { background: var(--bg-elevated); color: var(--text-tertiary); font-size: 12px; padding: 4px 12px; border-radius: var(--radius-full); }
.message-row { display: flex; margin-bottom: 2px; }
.message-row.incoming { justify-content: flex-start; }
.message-row.outgoing { justify-content: flex-end; }
.message-row.grouped { margin-top: -2px; }
.message-bubble { max-width: 70%; padding: 8px 12px; border-radius: 16px; position: relative; animation: msgIn 0.2s ease; word-wrap: break-word; overflow-wrap: break-word; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.incoming .message-bubble { background: var(--bubble-in); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.outgoing .message-bubble { background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg-text a { color: inherit; text-decoration: underline; }
.outgoing .msg-text a { color: rgba(255,255,255,0.9); }
.msg-caption { font-size: 14px; line-height: 1.4; padding-top: 6px; }
.msg-media { margin: -4px -8px 4px; border-radius: 12px; overflow: hidden; }
.msg-media img, .msg-media video { max-width: 100%; max-height: 400px; display: block; object-fit: contain; cursor: pointer; width: 100%; background: var(--bg-tertiary); }
.msg-media.sticker { background: transparent; margin: 0; }
.msg-media.sticker img { cursor: default; background: transparent; width: auto; }
.msg-audio { margin: 4px 0; }
.msg-audio audio { width: 100%; height: 40px; border-radius: 20px; }
.msg-document { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,0.05); border-radius: var(--radius-sm); text-decoration: none; color: inherit; transition: background var(--transition-fast); }
.msg-document:hover { background: rgba(255,255,255,0.08); }
.doc-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--accent-glow); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-size { font-size: 11px; color: var(--text-secondary); }
.msg-location { width: 220px; height: 150px; border-radius: var(--radius-sm); overflow: hidden; }
.msg-location img { width: 100%; height: 100%; object-fit: cover; }
.msg-reply-preview { font-size: 12px; color: rgba(255,255,255,0.6); padding: 4px 8px; margin: -4px -4px 6px; border-left: 2px solid var(--accent); border-radius: 2px; background: rgba(42,171,238,0.08); }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px; }
.msg-time { font-size: 11px; color: rgba(255,255,255,0.45); }
.outgoing .msg-time { color: rgba(255,255,255,0.6); }

.scroll-to-bottom { position: absolute; bottom: 76px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text-primary); cursor: pointer; display: none; align-items: center; justify-content: center; z-index: 5; box-shadow: var(--shadow-md); }
.scroll-to-bottom.visible { display: flex; }

/* Composer */
.composer { flex-shrink: 0; padding: 8px 12px; background: var(--bg-secondary); border-top: 1px solid var(--border-subtle); display: none; }
.reply-preview-bar { display: none; align-items: center; justify-content: space-between; padding: 8px 12px; margin-bottom: 8px; background: var(--bg-tertiary); border-left: 3px solid var(--accent); border-radius: 4px; font-size: 13px; color: var(--text-secondary); }
.reply-preview-bar.visible { display: flex; }
.reply-preview-bar .reply-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#close-reply { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 2px; flex-shrink: 0; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.attach-area { position: relative; }
.attach-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-tertiary); border: none; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); flex-shrink: 0; }
.attach-btn:hover { background: var(--accent-glow); color: var(--accent); }
.attach-menu { position: absolute; bottom: 50px; left: 0; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 8px; min-width: 160px; display: none; box-shadow: var(--shadow-lg); z-index: 10; }
.attach-menu.visible { display: block; }
.attach-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text-primary); transition: background var(--transition-fast); }
.attach-menu-item:hover { background: var(--bg-tertiary); }
.attach-menu-item .icon { width: 18px; height: 18px; }
.composer-input-wrapper { flex: 1; min-width: 0; }
#message-input { width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border-subtle); border-radius: 20px; color: var(--text-primary); font-size: 14px; outline: none; resize: none; max-height: 120px; line-height: 1.4; transition: border-color var(--transition-fast); }
#message-input:focus { border-color: var(--accent); }
#message-input::placeholder { color: var(--text-tertiary); }
.send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); flex-shrink: 0; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: var(--accent-hover); transform: scale(1.05); }

/* Profile Panel */
.profile-panel { width: var(--profile-width); background: var(--bg-secondary); border-left: 1px solid var(--border-subtle); overflow-y: auto; flex-shrink: 0; transition: transform 0.3s ease, opacity 0.3s ease; }
.profile-panel.hidden { display: none; }
.profile-panel .screen-header { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border-subtle); }
.profile-panel .screen-header button { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 4px; }
.profile-panel .screen-header h2 { font-size: 16px; font-weight: 600; }
.profile-content { padding: 24px 16px; text-align: center; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; color: #fff; }
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.profile-username { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.profile-section { text-align: left; margin-bottom: 20px; }
.profile-section-title { font-size: 12px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 12px; }
.profile-field { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.profile-field:last-child { border: none; }
.field-label { font-size: 14px; color: var(--text-secondary); }
.field-value { font-size: 14px; font-weight: 500; }
.profile-actions { margin-top: 20px; }
.block-btn, .unblock-btn { width: 100%; padding: 10px; border: 1px solid rgba(255,59,48,0.3); border-radius: var(--radius-sm); color: var(--red); background: rgba(255,59,48,0.08); font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--transition-fast); }
.block-btn:hover, .unblock-btn:hover { background: rgba(255,59,48,0.15); }
.unblock-btn { border-color: rgba(52,199,89,0.3); color: var(--green); background: rgba(52,199,89,0.08); }
.unblock-btn:hover { background: rgba(52,199,89,0.15); }

/* Screen Overlay */
.screen-overlay { position: fixed; inset: 0; background: var(--bg-primary); z-index: 50; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1); }
.screen-overlay.visible { transform: translateY(0); }
.screen-header { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.screen-header button { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 4px; }
.screen-header .icon { width: 20px; height: 20px; }
.screen-header h2 { font-size: 18px; font-weight: 600; }
.screen-body { flex: 1; overflow-y: auto; padding: 20px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px; text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.chart-section { background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 20px; margin-bottom: 20px; }
.chart-section h4 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.chart-bar-container { display: flex; align-items: flex-end; gap: 2px; height: 200px; padding-top: 20px; }
.chart-bar { flex: 1; background: linear-gradient(to top, var(--accent), rgba(42,171,238,0.4)); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.6s cubic-bezier(0.34,1.56,0.64,1); position: relative; }
.chart-bar:hover { opacity: 0.8; }
.chart-bar .chart-tooltip { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); background: var(--bg-elevated); border: 1px solid var(--border-light); padding: 2px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; display: none; z-index: 5; }
.chart-bar:hover .chart-tooltip { display: block; }
.chart-labels { display: flex; gap: 2px; margin-top: 8px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-tertiary); }
.type-distribution { display: flex; flex-direction: column; gap: 12px; }
.type-bar-row { display: flex; align-items: center; gap: 12px; }
.type-bar-row .type-name { width: 80px; font-size: 13px; color: var(--text-secondary); text-transform: capitalize; }
.type-bar-row .type-bar-bg { flex: 1; height: 24px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.type-bar-row .type-bar-fill { height: 100%; border-radius: 4px; transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1); }
.type-bar-row .type-count { width: 50px; font-size: 13px; text-align: right; color: var(--text-secondary); }

/* Media Gallery */
.media-filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.media-filter-btn { padding: 8px 16px; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition-fast); }
.media-filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.media-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.media-grid-item { aspect-ratio: 1; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; position: relative; transition: all var(--transition-fast); }
.media-grid-item:hover { border-color: var(--accent); transform: scale(1.02); }
.media-grid-item img, .media-grid-item video { width: 100%; height: 100%; object-fit: cover; }
.media-grid-item .media-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px; background: linear-gradient(transparent, rgba(0,0,0,0.8)); font-size: 11px; color: rgba(255,255,255,0.8); }
.media-grid-item .doc-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; color: var(--text-tertiary); }

/* Settings */
.settings-section { background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 20px; margin-bottom: 20px; }
.settings-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.setting-row:last-child { border: none; }
.setting-row .setting-label { font-size: 14px; }
.setting-row .setting-value { font-size: 14px; color: var(--text-secondary); font-family: 'SF Mono', monospace; }
.storage-bar-wrapper { margin-top: 16px; }
.storage-bar-outer { height: 12px; background: var(--bg-tertiary); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.storage-bar-inner { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--purple)); }
.disconnect-btn { width: 100%; padding: 12px; background: rgba(255,59,48,0.1); border: 1px solid rgba(255,59,48,0.2); border-radius: var(--radius-sm); color: var(--red); font-size: 15px; font-weight: 600; cursor: pointer; transition: all var(--transition-fast); }
.disconnect-btn:hover { background: rgba(255,59,48,0.2); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 200; display: none; align-items: center; justify-content: center; cursor: pointer; }
.lightbox.visible { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; cursor: default; border-radius: var(--radius-sm); }
.lightbox .close-lightbox { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.1); border: none; width: 40px; height: 40px; border-radius: 50%; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Location Modal */
.location-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: none; align-items: center; justify-content: center; }
.location-modal.visible { display: flex; }
.location-modal .modal-card { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; width: 360px; max-width: 90vw; }
.location-modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.location-modal input { width: 100%; padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; outline: none; margin-bottom: 12px; }
.location-modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.location-modal .modal-actions button { padding: 8px 20px; border-radius: var(--radius-sm); border: none; font-size: 14px; cursor: pointer; }
.location-modal .cancel-btn { background: var(--bg-tertiary); color: var(--text-primary); }
.location-modal .confirm-btn { background: var(--accent); color: #fff; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  :root { --sidebar-width: 100%; --profile-width: 100%; }
  #dashboard { flex-direction: column; }

  .sidebar {
    width: 100%; position: absolute; inset: 0; z-index: 10;
    transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1);
    display: flex; flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .sidebar.slide-out { transform: translateX(-100%); }

  .sidebar-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--bg-secondary); border-top: 1px solid var(--border-subtle);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0));
  }

  .chat-list { padding-bottom: calc(var(--nav-height) + 8px); }

  .chat-panel {
    position: absolute; inset: 0; z-index: 15;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1);
    background: var(--bg-primary);
  }
  .chat-panel.visible { transform: translateX(0); }
  .chat-header .back-btn { display: flex; }

  .profile-panel {
    position: absolute; inset: 0; width: 100%; z-index: 20;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1);
  }
  .profile-panel.visible { transform: translateX(0); }
  .profile-panel.hidden { width: 100%; transform: translateX(100%); display: block; }

  .message-bubble { max-width: 85%; }
  .screen-overlay { z-index: 40; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-card { padding: 32px 24px; }
}
