/* ========================================
   初源CHAT - Style System
   ======================================== */

/* === CSS Variables === */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1a2e;
    --text-secondary: #65676b;
    --text-muted: #8e8e93;
    --accent: #4f46e5;
    --accent-light: #818cf8;
    --accent-dark: #3730a3;
    --accent-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
    --ai-gradient: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --msg-own: #4f46e5;
    --msg-own-text: #ffffff;
    --msg-other: #ffffff;
    --msg-other-text: #1a1a2e;
    --nav-bg: #ffffff;
    --header-bg: #ffffff;
    --input-bg: #f0f2f5;
    --card-bg: #ffffff;
    --overlay: rgba(0,0,0,0.5);
    --sidebar-width: 280px;
    --header-height: 56px;
    --nav-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #8e8e93;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --border: #2d2d44;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --msg-own: #4f46e5;
    --msg-own-text: #ffffff;
    --msg-other: #1e1e36;
    --msg-other-text: #e4e6eb;
    --nav-bg: #1a1a2e;
    --header-bg: #1a1a2e;
    --input-bg: #16213e;
    --card-bg: #1e1e36;
    --overlay: rgba(0,0,0,0.7);
}

/* === Font Options === */
.font-default { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif; }
.font-serif { font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; }
.font-rounded { font-family: 'Nunito', 'Varela Round', 'PingFang SC', sans-serif; }
.font-elegant { font-family: 'Playfair Display', 'Noto Serif SC', 'Georgia', serif; }

/* === Layout Options === */
.layout-default { --sidebar-width: 280px; }
.layout-compact { --sidebar-width: 220px; font-size: 14px; }
.layout-wide { --sidebar-width: 320px; }

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

textarea {
    resize: none;
    line-height: 1.5;
}

input::-webkit-search-cancel-button {
    display: none !important;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes particleFloat {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) translateX(50px); opacity: 0; }
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

@keyframes navIndicator {
    from { transform: translateX(var(--nav-from)); }
    to { transform: translateX(var(--nav-to)); }
}

/* === Toast === */
#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 12px 24px;
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: toastIn 0.3s ease;
    max-width: 90%;
    text-align: center;
    border-left: 4px solid var(--accent);
}

#toast.toast-success { border-left-color: var(--success); }
#toast.toast-error { border-left-color: var(--danger); }
#toast.toast-warning { border-left-color: var(--warning); }
#toast.toast-hide { animation: toastOut 0.3s ease forwards; }

/* ========================================
   AUTH PAGE
   ======================================== */
.auth-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overflow: hidden;
}

.auth-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e, #0f0c29);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

.auth-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.auth-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

.auth-container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 420px;
    animation: scaleIn 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-text {
    font-size: 42px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #667eea);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
    letter-spacing: 2px;
    text-shadow: none;
}

.logo-subtitle {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    margin-top: 8px;
    letter-spacing: 4px;
}

.auth-form {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-lg);
    padding: 32px;
    animation: slideUp 0.4s ease;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-form .input-wrapper {
    position: relative;
}

.auth-form .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,0.4);
    pointer-events: none;
}

.auth-form input {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    padding: 12px 14px 12px 42px;
    color: #ffffff;
    font-size: 15px;
    transition: all var(--transition);
}

.auth-form input::placeholder {
    color: rgba(255,255,255,0.4);
}

.auth-form input:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

.input-with-btn {
    display: flex;
    align-items: center;
}

.input-with-btn input {
    flex: 1;
    padding-right: 110px;
}

.input-with-btn .btn-small {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-size: 12px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    border-radius: 6px;
    transition: all var(--transition);
}

.input-with-btn .btn-small:hover {
    background: rgba(255,255,255,0.25);
}

.input-with-btn .btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    margin-top: 20px;
}

.auth-switch a {
    color: #818cf8;
    font-weight: 600;
}

.auth-switch a:hover {
    color: #a5b4fc;
    text-decoration: none;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-text {
    background: transparent;
    color: var(--accent);
    padding: 6px 12px;
}

.btn-text:hover {
    background: rgba(79, 70, 229, 0.08);
}

.btn-small {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-ai {
    background: var(--ai-gradient);
    color: #ffffff;
}

.btn-ai:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   APP PAGE
   ======================================== */
.app-page {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* === Header === */
.app-header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 50;
    flex-shrink: 0;
    transition: background var(--transition);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.header-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.3s ease;
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--nav-bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: background var(--transition);
}

.nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    transition: transform var(--transition);
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active svg {
    transform: scale(1.1);
}

.nav-item-ai.active {
    color: #a855f7;
}

.nav-item-ai.active svg {
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.4));
}

.nav-badge {
    position: absolute;
    top: 6px;
    right: 50%;
    margin-right: -20px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === App Content === */
.app-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding-top: var(--header-height);
    padding-bottom: var(--nav-height);
}

.tab-content {
    position: absolute;
    inset: 0;
    padding-top: var(--header-height);
    padding-bottom: var(--nav-height);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.tab-content.active {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================
   CHAT LAYOUT (Messages & Channels)
   ======================================== */
.chat-layout {
    display: flex;
    height: 100%;
}

.chat-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: background var(--transition), width var(--transition);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-search {
    padding: 8px 16px;
}

.sidebar-search input {
    background: var(--input-bg);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
}

.conversation-list,
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

/* Conversation Item */
.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.active {
    background: var(--bg-tertiary);
}

.conversation-item .avatar {
    position: relative;
    flex-shrink: 0;
}

.conversation-item .avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.conversation-item .avatar .online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: var(--success);
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
}

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

.conversation-info .conv-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-info .conv-last-msg {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.conversation-meta .conv-time {
    font-size: 11px;
    color: var(--text-muted);
}

.conv-unread {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Channel Sidebar */
.channel-category {
    margin-bottom: 4px;
}

.channel-category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
}

.channel-category-header svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
}

.channel-category-header.collapsed svg {
    transform: rotate(-90deg);
}

.channel-category-list {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.channel-category-list.collapsed {
    max-height: 0 !important;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 28px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 14px;
    color: var(--text-secondary);
}

.channel-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.channel-item.active {
    background: var(--bg-tertiary);
    color: var(--accent);
    font-weight: 600;
}

.channel-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.channel-item .ch-unread {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Chat Main === */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    transition: background var(--transition);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info h4 {
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mobile-back {
    display: none;
}

.pin-indicator {
    color: var(--warning);
    display: flex;
    align-items: center;
}

.pin-indicator svg {
    width: 18px;
    height: 18px;
}

/* === Message List === */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.load-more {
    text-align: center;
    padding: 8px;
}

/* === Message Bubble === */
.message-bubble {
    display: flex;
    gap: 8px;
    max-width: 75%;
    animation: messageIn 0.3s ease;
}

.message-bubble.own {
    flex-direction: row-reverse;
    margin-left: auto;
}

.message-bubble .msg-avatar {
    flex-shrink: 0;
}

.message-bubble .msg-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.message-bubble .msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble .msg-sender {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.message-bubble.own .msg-sender {
    text-align: right;
}

.message-bubble .msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.message-bubble:not(.own) .msg-bubble {
    background: var(--msg-other);
    color: var(--msg-other-text);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-bubble.own .msg-bubble {
    background: var(--msg-own);
    color: var(--msg-own-text);
    border-top-right-radius: 4px;
}

.message-bubble .msg-bubble img.msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 4px;
}

.message-bubble .msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.message-bubble.own .msg-time {
    text-align: right;
}

.message-bubble .msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.message-bubble:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    transition: all var(--transition);
}

.msg-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

/* Reply reference */
.msg-reply-ref {
    background: rgba(0,0,0,0.05);
    border-left: 3px solid var(--accent);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    cursor: pointer;
}

[data-theme="dark"] .msg-reply-ref {
    background: rgba(255,255,255,0.05);
}

.msg-reply-ref .reply-ref-name {
    font-weight: 600;
    color: var(--accent);
}

/* Recalled message */
.message-bubble.recalled .msg-bubble {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* === Reply Bar === */
.reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    animation: slideUp 0.2s ease;
}

.reply-bar-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reply-bar-label {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    flex-shrink: 0;
}

.reply-bar-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Typing Indicator === */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    font-size: 12px;
    color: var(--text-muted);
    animation: fadeIn 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* === Mention Panel === */
.mention-panel {
    position: absolute;
    bottom: 60px;
    left: 16px;
    right: 16px;
    max-height: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    z-index: 20;
    animation: slideUp 0.2s ease;
}

.mention-panel-header {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.mention-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background var(--transition);
}

.mention-list-item:hover {
    background: var(--bg-tertiary);
}

.mention-list-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.mention-list-item .mention-name {
    font-size: 14px;
    font-weight: 500;
}

/* === Chat Input Area === */
.chat-input-area {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    transition: background var(--transition);
}

.input-actions {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-row textarea {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color var(--transition);
}

.input-row textarea:focus {
    border-color: var(--accent);
}

.btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send svg {
    width: 18px;
    height: 18px;
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-muted);
    animation: fadeIn 0.5s ease;
}

.empty-state svg {
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
}

/* ========================================
   MOMENTS
   ======================================== */
.moments-container {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
}

.moment-composer {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}

.composer-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.composer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    overflow: hidden;
}

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

.composer-header textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 15px;
    min-height: 60px;
}

.composer-header textarea:focus {
    box-shadow: none;
}

.composer-images {
    margin-top: 12px;
}

.image-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-preview {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.composer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.visibility-select {
    width: auto;
    padding: 4px 28px 4px 10px;
    font-size: 13px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Moment Card */
.moment-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    animation: slideUp 0.3s ease;
}

.moment-card:hover {
    box-shadow: var(--shadow-lg);
}

.moment-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.moment-card-header img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.moment-user-info {
    flex: 1;
}

.moment-user-info .moment-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.moment-user-info .moment-time {
    font-size: 12px;
    color: var(--text-muted);
}

.moment-content {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.moment-images {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.moment-images.grid-1 { grid-template-columns: 1fr; max-width: 300px; }
.moment-images.grid-2 { grid-template-columns: 1fr 1fr; max-width: 400px; }
.moment-images.grid-3 { grid-template-columns: 1fr 1fr 1fr; max-width: 450px; }

.moment-images img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    transition: opacity var(--transition);
}

.moment-images img:hover {
    opacity: 0.9;
}

.moment-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.moment-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.moment-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.moment-action-btn svg {
    width: 18px;
    height: 18px;
}

.moment-action-btn.liked {
    color: var(--danger);
}

.moment-action-btn.liked svg {
    fill: var(--danger);
}

/* Moment Comments */
.moment-comments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.moment-comment {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.moment-comment .comment-name {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.moment-comment .comment-text {
    color: var(--text-primary);
    word-break: break-word;
}

.moment-comment-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.moment-comment-input input {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 20px;
}

/* ========================================
   AI TAB
   ======================================== */
.ai-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ai-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.ai-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.ai-status {
    font-size: 12px;
    color: var(--success);
}

.ai-status.offline {
    color: var(--text-muted);
}

.ai-disabled {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    color: var(--text-muted);
}

.ai-disabled p {
    font-size: 18px;
    font-weight: 600;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    text-align: center;
    color: var(--text-muted);
    animation: fadeIn 0.5s ease;
}

.ai-welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(168,85,247,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.ai-welcome h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.ai-welcome p {
    font-size: 14px;
}

.ai-msg-bubble {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

.ai-msg-bubble.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.ai-msg-bubble .ai-msg-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
}

.ai-msg-bubble .ai-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-msg-bubble .ai-msg-text {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.ai-msg-bubble:not(.user) .ai-msg-text {
    background: var(--msg-other);
    color: var(--msg-other-text);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow);
}

.ai-msg-bubble.user .ai-msg-text {
    background: var(--ai-gradient);
    color: #ffffff;
    border-top-right-radius: 4px;
}

.ai-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ========================================
   PROFILE
   ======================================== */
.profile-container {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    transition: background var(--transition);
}

.profile-avatar-wrapper {
    position: relative;
    cursor: pointer;
    margin-bottom: 12px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    overflow: hidden;
    transition: transform var(--transition);
}

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

.profile-avatar-wrapper:hover .profile-avatar {
    transform: scale(1.05);
}

.avatar-edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    color: #fff;
}

.avatar-edit-overlay svg {
    width: 24px;
    height: 24px;
}

.profile-avatar-wrapper:hover .avatar-edit-overlay {
    opacity: 1;
}

.profile-username {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-uid {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.profile-bio {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Stats */
.profile-stats {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}

.settings-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 12px;
}

.settings-item:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.settings-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
}

.settings-value {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-input {
    flex: 1;
    text-align: right;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 10px;
    font-size: 14px;
    max-width: 200px;
}

.settings-input:focus {
    border-color: var(--accent);
    background: var(--input-bg);
    text-align: left;
}

.settings-input[type="text"],
.settings-input textarea {
    text-align: left;
    max-width: 100%;
}

.settings-item .form-group {
    flex: 1;
}

/* QQ Avatar Input */
.qq-avatar-input {
    display: flex;
    gap: 8px;
    flex: 1;
}

.qq-avatar-input input {
    flex: 1;
    text-align: left;
    max-width: none;
}

/* Preset Avatar Grid */
.preset-avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.preset-avatar-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition);
}

.preset-avatar-item:hover {
    border-color: var(--accent-light);
    transform: scale(1.05);
}

.preset-avatar-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

.preset-avatar-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Wallpaper Grid */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.wallpaper-item {
    aspect-ratio: 16/9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition);
}

.wallpaper-item:hover {
    border-color: var(--accent-light);
    transform: scale(1.02);
}

.wallpaper-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

.wallpaper-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Font Options */
.font-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.font-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.font-option:hover {
    border-color: var(--accent-light);
}

.font-option.active {
    border-color: var(--accent);
    background: rgba(79, 70, 229, 0.05);
}

.font-preview {
    font-size: 16px;
    color: var(--text-primary);
}

.font-option span {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Layout Options */
.layout-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.layout-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.layout-option:hover {
    border-color: var(--accent-light);
}

.layout-option.active {
    border-color: var(--accent);
    background: rgba(79, 70, 229, 0.05);
}

.layout-preview {
    width: 100%;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    display: flex;
    overflow: hidden;
}

.lp-sidebar {
    background: var(--accent-light);
    opacity: 0.3;
    transition: width var(--transition);
}

.lp-content {
    background: var(--text-muted);
    opacity: 0.15;
}

.layout-option span {
    font-size: 12px;
    color: var(--text-muted);
}

/* Theme Toggle */
.theme-toggle-item {
    justify-content: space-between;
}

.theme-switch {
    cursor: pointer;
}

.theme-switch-track {
    width: 52px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 14px;
    position: relative;
    transition: background var(--transition);
    border: 2px solid var(--border);
}

[data-theme="dark"] .theme-switch-track {
    background: var(--accent);
    border-color: var(--accent);
}

.theme-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .theme-switch-thumb {
    transform: translateX(24px);
    background: #1a1a2e;
}

.sun-icon {
    color: #f59e0b;
}

.moon-icon {
    color: #6366f1;
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

/* Friend List */
.friend-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
}

.friend-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.friend-list-item:last-child {
    border-bottom: none;
}

.friend-list-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.friend-list-item .friend-info {
    flex: 1;
    min-width: 0;
}

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

.friend-list-item .friend-nickname {
    font-size: 12px;
    color: var(--text-muted);
}

.friend-list-item .btn-remove-friend {
    font-size: 12px;
    color: var(--danger);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.friend-list-item .btn-remove-friend:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-body {
    padding: 20px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

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

.search-row input {
    flex: 1;
}

.search-results {
    margin-top: 10px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.search-result-item .result-info {
    flex: 1;
}

.search-result-item .result-name {
    font-size: 14px;
    font-weight: 600;
}

.search-result-item .result-uid {
    font-size: 12px;
    color: var(--text-muted);
}

.request-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.request-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.request-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border-bottom: 1px solid var(--border);
}

.request-list-item:last-child {
    border-bottom: none;
}

.request-list-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.request-list-item .req-info {
    flex: 1;
    min-width: 0;
}

.request-list-item .req-name {
    font-size: 14px;
    font-weight: 600;
}

.request-list-item .req-msg {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.request-list-item .req-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ========================================
   IMAGE VIEWER
   ======================================== */
.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.image-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background var(--transition);
    z-index: 1;
}

.image-viewer-close:hover {
    background: rgba(255,255,255,0.2);
}

.image-viewer-close svg {
    width: 24px;
    height: 24px;
}

#viewer-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    animation: scaleIn 0.3s ease;
}

/* ========================================
   ADD MENU
   ======================================== */
.add-menu {
    position: fixed;
    top: var(--header-height);
    right: 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 100;
    min-width: 160px;
    padding: 8px 0;
    animation: slideDown 0.2s ease;
}

.add-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background var(--transition);
    text-align: left;
}

.add-menu-item:hover {
    background: var(--bg-tertiary);
}

.add-menu-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ========================================
   RESPONSIVE (Mobile)
   ======================================== */
@media (max-width: 767px) {
    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        inset: 0;
        z-index: 10;
    }

    .chat-main {
        position: absolute;
        inset: 0;
        z-index: 15;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .chat-main.mobile-show {
        transform: translateX(0);
    }

    .mobile-back {
        display: flex !important;
    }

    .message-bubble {
        max-width: 85%;
    }

    .moment-images.grid-1 { max-width: 100%; }
    .moment-images.grid-2 { max-width: 100%; }
    .moment-images.grid-3 { max-width: 100%; }

    .layout-options {
        grid-template-columns: 1fr;
    }

    .preset-avatar-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .profile-stats {
        gap: 8px;
    }

    .stat-value {
        font-size: 16px;
    }

    .modal {
        max-height: 90vh;
    }

    .ai-msg-bubble {
        max-width: 90%;
    }

    .composer-header {
        flex-direction: column;
    }

    .composer-avatar {
        display: none;
    }
}

@media (min-width: 768px) {
    .chat-sidebar {
        position: relative;
    }

    .chat-main {
        position: relative;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.text-center {
    text-align: center;
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

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

/* Shimmer loading effect */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* Group members panel */
.members-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 260px;
    height: 100%;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    z-index: 20;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease;
    box-shadow: -4px 0 12px rgba(0,0,0,0.1);
}

.members-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.members-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.member-item:hover {
    background: var(--bg-tertiary);
}

.member-item img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.member-item .member-name {
    font-size: 14px;
    font-weight: 500;
}

.member-item .member-role {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

/* Notification dropdown */
.notification-dropdown {
    position: absolute;
    top: var(--header-height);
    right: 16px;
    width: 320px;
    max-height: 400px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 100;
    overflow-y: auto;
    animation: slideDown 0.2s ease;
}

.notification-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.notification-item:hover {
    background: var(--bg-tertiary);
}

.notification-item.unread {
    background: rgba(79, 70, 229, 0.05);
}

.notification-item .notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.notification-item .notif-content {
    flex: 1;
    min-width: 0;
}

.notification-item .notif-text {
    font-size: 13px;
    line-height: 1.4;
}

.notification-item .notif-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* System message in chat */
.system-message {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    align-self: center;
    animation: fadeIn 0.3s ease;
}

/* Image message grid */
.msg-image-grid {
    display: grid;
    gap: 4px;
    margin-top: 4px;
}

.msg-image-grid.grid-1 { grid-template-columns: 1fr; }
.msg-image-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.msg-image-grid.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.msg-image-grid img {
    width: 100%;
    max-width: 200px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity var(--transition);
}

.msg-image-grid img:hover {
    opacity: 0.9;
}
