/* ============================================
   ContextSpace — Shared Design System
   ============================================
   Cool slate dark theme with teal accents.
   All screens link to this file.
   ============================================ */

:root {
    /* Brand colors */
    --primary: #2dd4bf;
    --primary-hover: #14b8a6;
    --primary-muted: rgba(45, 212, 191, 0.15);
    --primary-glow: rgba(45, 212, 191, 0.25);

    /* Brand gradients */
    --gradient-brand: linear-gradient(135deg, #2dd4bf, #06b6d4);
    --gradient-brand-vivid: linear-gradient(135deg, #2dd4bf, #3b82f6);
    --gradient-brand-warm: linear-gradient(135deg, #2dd4bf, #8b5cf6);
    --gradient-accent-subtle: linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(6, 182, 212, 0.06));
    --gradient-surface: linear-gradient(180deg, rgba(45, 212, 191, 0.04) 0%, transparent 60%);
    --gradient-mesh-1: radial-gradient(ellipse at 20% 0%, rgba(45, 212, 191, 0.08) 0%, transparent 50%);
    --gradient-mesh-2: radial-gradient(ellipse at 80% 100%, rgba(99, 102, 241, 0.06) 0%, transparent 50%);
    --gradient-mesh-3: radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);

    /* Surfaces — cool slate progression */
    --bg-deepest: #0d1117;
    --bg-deep: #121820;
    --bg-base: #171c28;
    --bg-raised: #1e2535;
    --bg-elevated: #252d3f;
    --bg-hover: #2a3349;
    --bg-active: #313b52;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(45, 212, 191, 0.3);

    /* Text */
    --text-primary: #e8ecf0;
    --text-secondary: #8b95a8;
    --text-muted: #5a6478;
    --text-accent: #2dd4bf;
    --text-inverse: #0d1117;

    /* Status colors */
    --online: #34d399;
    --away: #fbbf24;
    --offline: #5a6478;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;

    /* Unread / notification */
    --unread-badge: #f43f5e;
    --unread-dot: #2dd4bf;

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;
    --text-3xl: 36px;

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --leading-tight: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(45, 212, 191, 0.15);
    --shadow-glow-strong: 0 0 30px rgba(45, 212, 191, 0.25), 0 0 60px rgba(45, 212, 191, 0.1);

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-fast: 0.12s ease;
    --ease-base: 0.2s ease;
    --ease-slow: 0.4s ease;
    --ease-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --sidebar-spaces-w: 64px;
    --sidebar-channels-w: 240px;
    --thread-list-w: 340px;
}

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

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

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-deepest);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--ease-base);
    background: var(--gradient-brand);
    color: var(--text-inverse);
}
.btn:hover {
    background: var(--gradient-brand-vivid);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), var(--shadow-glow-strong);
}
.btn:active {
    transform: scale(0.97);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
    box-shadow: none;
    transform: none;
}

/* ---- Avatar ---- */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--text-inverse);
    flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-base); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--text-xl); }

/* ---- Status dot ---- */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-base);
    flex-shrink: 0;
}
.status-dot.online { background: var(--online); }
.status-dot.away { background: var(--away); }
.status-dot.offline { background: var(--offline); }

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--weight-bold);
    background: var(--unread-badge);
    color: white;
}

/* ---- Input ---- */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    transition: border-color var(--ease-base), box-shadow var(--ease-base);
}
.input::placeholder {
    color: var(--text-muted);
}
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-glow);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.animate-in {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.4s; }

.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.5s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Material Icons ---- */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
}
.material-icons.sm { font-size: 16px; }
.material-icons.lg { font-size: 24px; }
.material-icons.xl { font-size: 32px; }

/* ---- Tooltip ---- */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease-fast);
    box-shadow: var(--shadow-md);
    z-index: 100;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ---- Settings Content ---- */
.settings-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    min-width: 0;
    overflow-y: auto;
    animation: fadeIn 0.5s ease 0.2s forwards;
    opacity: 0;
}
.settings-content-header {
    padding: var(--space-6) var(--space-8) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.settings-content-header h2 {
    font-size: var(--text-xl);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.settings-content-header h2 .material-icons {
    color: var(--primary);
    font-size: 24px;
    -webkit-text-fill-color: initial;
}
.settings-content-body {
    padding: var(--space-6) var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    max-width: 840px;
}

/* ---- Section Headers ---- */
.section-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-1);
}
.section-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-5);
}

/* ---- Theme Mode Cards ---- */
.theme-cards {
    display: flex;
    gap: var(--space-5);
}
.theme-card {
    flex: 1;
    cursor: pointer;
    border: 2px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--ease-base);
    position: relative;
    background: var(--bg-raised);
}
.theme-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.theme-card.selected {
    border-color: var(--border-accent);
    background: var(--gradient-accent-subtle);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}
.theme-card-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--ease-spring);
    z-index: 2;
}
.theme-card-check .material-icons {
    font-size: 16px;
    color: var(--text-inverse);
}
.theme-card.selected .theme-card-check {
    opacity: 1;
    transform: scale(1);
}

/* Mini app preview inside the theme card */
.theme-preview {
    height: 120px;
    display: flex;
    margin: var(--space-3);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}
.theme-preview-sidebar {
    width: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    gap: 4px;
    flex-shrink: 0;
}
.theme-preview-sidebar-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}
.theme-preview-channels {
    width: 64px;
    display: flex;
    flex-direction: column;
    padding: 8px 6px;
    gap: 4px;
    flex-shrink: 0;
}
.theme-preview-channel-item {
    height: 8px;
    border-radius: 3px;
    width: 80%;
}
.theme-preview-channel-item.active-item {
    width: 90%;
}
.theme-preview-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 6px;
}
.theme-preview-msg {
    display: flex;
    gap: 4px;
    align-items: flex-start;
}
.theme-preview-msg-avatar {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    margin-top: 1px;
}
.theme-preview-msg-lines {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.theme-preview-msg-line {
    height: 5px;
    border-radius: 2px;
}

/* Dark preview colors */
.theme-preview.dark {
    background: #0d1117;
}
.theme-preview.dark .theme-preview-sidebar {
    background: #0d1117;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.theme-preview.dark .theme-preview-sidebar-dot {
    background: #252d3f;
}
.theme-preview.dark .theme-preview-sidebar-dot:first-child {
    background: var(--primary);
}
.theme-preview.dark .theme-preview-channels {
    background: #121820;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.theme-preview.dark .theme-preview-channel-item {
    background: #252d3f;
}
.theme-preview.dark .theme-preview-channel-item.active-item {
    background: var(--primary-muted);
}
.theme-preview.dark .theme-preview-chat {
    background: #171c28;
}
.theme-preview.dark .theme-preview-msg-avatar {
    background: #6366f1;
}
.theme-preview.dark .theme-preview-msg-line {
    background: #252d3f;
}
.theme-preview.dark .theme-preview-msg-line.short { width: 60%; }
.theme-preview.dark .theme-preview-msg-line.long { width: 90%; }

/* Light preview colors */
.theme-preview.light {
    background: #f0f2f5;
}
.theme-preview.light .theme-preview-sidebar {
    background: #e8eaed;
    border-right: 1px solid rgba(0,0,0,0.08);
}
.theme-preview.light .theme-preview-sidebar-dot {
    background: #d1d5db;
}
.theme-preview.light .theme-preview-sidebar-dot:first-child {
    background: var(--primary);
}
.theme-preview.light .theme-preview-channels {
    background: #f0f2f5;
    border-right: 1px solid rgba(0,0,0,0.08);
}
.theme-preview.light .theme-preview-channel-item {
    background: #d1d5db;
}
.theme-preview.light .theme-preview-channel-item.active-item {
    background: var(--primary);
    opacity: 0.25;
}
.theme-preview.light .theme-preview-chat {
    background: #ffffff;
}
.theme-preview.light .theme-preview-msg-avatar {
    background: #6366f1;
}
.theme-preview.light .theme-preview-msg-line {
    background: #e5e7eb;
}
.theme-preview.light .theme-preview-msg-line.short { width: 60%; }
.theme-preview.light .theme-preview-msg-line.long { width: 90%; }

.theme-card-label {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border-top: 1px solid var(--border-subtle);
}
.theme-card-label .material-icons {
    font-size: 18px;
    color: var(--text-muted);
}

/* ---- Accent Color Swatches ---- */
.color-grid {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ease-spring);
    position: relative;
    border: 2px solid transparent;
}
.color-swatch:hover {
    transform: scale(1.15);
}
.color-swatch.selected {
    box-shadow: 0 0 0 3px var(--bg-base), 0 0 0 5px currentColor, var(--shadow-glow-strong);
    transform: scale(1.1);
}
.color-swatch .material-icons {
    font-size: 18px;
    color: #fff;
    opacity: 0;
    transition: opacity var(--ease-fast);
}
.color-swatch.selected .material-icons {
    opacity: 1;
}
.color-swatch-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--ease-fast);
    pointer-events: none;
}
.color-swatch:hover .color-swatch-label,
.color-swatch.selected .color-swatch-label {
    opacity: 1;
}

/* ---- Live Preview ---- */
.live-preview-wrapper {
    background: var(--bg-raised);
    background-image: var(--gradient-mesh-1), var(--gradient-mesh-3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.live-preview-bar {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.live-preview-bar-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.live-preview-bar-title .material-icons {
    font-size: 18px;
    color: var(--primary);
}
.live-preview-badge {
    font-size: 10px;
    font-weight: var(--weight-semibold);
    color: var(--primary);
    background: var(--primary-muted);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-preview {
    display: flex;
    height: 260px;
    transition: background var(--ease-slow), color var(--ease-slow);
}

/* Preview sidebar */
.lp-sidebar {
    width: 160px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background var(--ease-slow), border-color var(--ease-slow);
}
.lp-sidebar-header {
    padding: 12px 14px 8px;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    transition: color var(--ease-slow);
}
.lp-sidebar-label {
    padding: 8px 14px 4px;
    font-size: 10px;
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    transition: color var(--ease-slow);
}
.lp-channel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    font-size: var(--text-xs);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-right: 8px;
    transition: all var(--ease-fast);
}
.lp-channel .material-icons {
    font-size: 14px;
}

/* Preview chat area */
.lp-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: background var(--ease-slow);
}
.lp-chat-header {
    padding: 10px 14px;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--ease-slow), border-color var(--ease-slow);
}
.lp-chat-header .material-icons {
    font-size: 16px;
}
.lp-messages {
    flex: 1;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}
.lp-msg {
    display: flex;
    gap: 8px;
}
.lp-msg-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: var(--weight-bold);
    font-family: var(--font-display);
}
.lp-msg-body {
    flex: 1;
    min-width: 0;
}
.lp-msg-name {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    margin-bottom: 2px;
    transition: color var(--ease-slow);
}
.lp-msg-text {
    font-size: 11px;
    line-height: 1.5;
    transition: color var(--ease-slow);
}
.lp-msg-text code {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    transition: background var(--ease-slow), color var(--ease-slow);
}
.lp-composer {
    margin: 0 14px 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 11px;
    transition: background var(--ease-slow), border-color var(--ease-slow), color var(--ease-slow);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.lp-send-btn {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ease-slow);
}
.lp-send-btn .material-icons {
    font-size: 13px;
}

/* Dark theme for preview */
.live-preview.dark-mode {
    background: #171c28;
}
.live-preview.dark-mode .lp-sidebar {
    background: #121820;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.live-preview.dark-mode .lp-sidebar-header { color: #e8ecf0; }
.live-preview.dark-mode .lp-sidebar-label { color: #5a6478; }
.live-preview.dark-mode .lp-channel { color: #8b95a8; }
.live-preview.dark-mode .lp-channel.lp-active {
    color: var(--primary);
}
.live-preview.dark-mode .lp-chat { background: #171c28; }
.live-preview.dark-mode .lp-chat-header {
    color: #e8ecf0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.live-preview.dark-mode .lp-chat-header .material-icons { color: var(--primary); }
.live-preview.dark-mode .lp-msg-name { color: #e8ecf0; }
.live-preview.dark-mode .lp-msg-text { color: #8b95a8; }
.live-preview.dark-mode .lp-msg-text code {
    background: #252d3f;
    color: var(--primary);
}
.live-preview.dark-mode .lp-composer {
    background: #1e2535;
    border: 1px solid rgba(255,255,255,0.1);
    color: #5a6478;
}
.live-preview.dark-mode .lp-send-btn {
    background: var(--gradient-brand);
    box-shadow: var(--shadow-glow);
}
.live-preview.dark-mode .lp-send-btn .material-icons { color: #0d1117; }

/* Light theme for preview */
.live-preview.light-mode {
    background: #ffffff;
}
.live-preview.light-mode .lp-sidebar {
    background: #f0f2f5;
    border-right: 1px solid rgba(0,0,0,0.08);
}
.live-preview.light-mode .lp-sidebar-header { color: #1a1a1a; }
.live-preview.light-mode .lp-sidebar-label { color: #8b95a8; }
.live-preview.light-mode .lp-channel { color: #4b5563; }
.live-preview.light-mode .lp-channel.lp-active {
    color: var(--primary);
}
.live-preview.light-mode .lp-chat { background: #ffffff; }
.live-preview.light-mode .lp-chat-header {
    color: #1a1a1a;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.live-preview.light-mode .lp-chat-header .material-icons { color: var(--primary); }
.live-preview.light-mode .lp-msg-name { color: #1a1a1a; }
.live-preview.light-mode .lp-msg-text { color: #4b5563; }
.live-preview.light-mode .lp-msg-text code {
    background: #f0f2f5;
    color: var(--primary);
}
.live-preview.light-mode .lp-composer {
    background: #f0f2f5;
    border: 1px solid rgba(0,0,0,0.1);
    color: #9ca3af;
}
.live-preview.light-mode .lp-send-btn {
    background: var(--gradient-brand);
    box-shadow: var(--shadow-glow);
}
.live-preview.light-mode .lp-send-btn .material-icons { color: #ffffff; }

/* Active channel highlight */
.lp-channel.lp-active {
    font-weight: var(--weight-semibold);
}
.live-preview.dark-mode .lp-channel.lp-active {
    background: rgba(45, 212, 191, 0.15);
}
.live-preview.light-mode .lp-channel.lp-active {
    background: rgba(45, 212, 191, 0.12);
}

/* ---- Stagger Animations ---- */
.stagger-1 { animation: fadeInUp 0.5s ease 0.1s forwards; opacity: 0; }
.stagger-2 { animation: fadeInUp 0.5s ease 0.25s forwards; opacity: 0; }
.stagger-3 { animation: fadeInUp 0.5s ease 0.4s forwards; opacity: 0; }

/* ============================================
   App Shell
   ============================================ */
.app {
    display: flex;
    height: 100vh;
    background: var(--bg-deepest);
    position: relative;
    overflow: hidden;
}
.app::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        var(--gradient-mesh-1),
        var(--gradient-mesh-2);
    pointer-events: none;
    z-index: 0;
}
.app > * {
    position: relative;
    z-index: 1;
}

/* ---- Space Rail ---- */
.space-rail {
    width: var(--sidebar-spaces-w);
    background: var(--bg-deepest);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4) 0;
    gap: var(--space-2);
    flex-shrink: 0;
    animation: slideInLeft 0.4s ease forwards;
}
.space-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-base);
    position: relative;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
    color: var(--text-primary);
}
.space-icon:hover {
    border-radius: var(--radius-md);
    transform: scale(1.05);
}
.space-icon.active {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glow-strong);
}
.space-icon.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--gradient-brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.space-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
}
.space-divider {
    width: 28px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
    margin: var(--space-2) 0;
}
.space-add {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: 2px dashed var(--border-default);
    color: var(--text-muted);
    transition: all var(--ease-base);
}
.space-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--gradient-accent-subtle);
    box-shadow: var(--shadow-glow);
}

/* ---- Channel Sidebar ---- */
.channel-sidebar {
    width: var(--sidebar-channels-w);
    background: var(--bg-deep);
    background-image: var(--gradient-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    animation: slideInLeft 0.4s ease 0.1s forwards;
    opacity: 0;
}
.channel-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.channel-header-settings {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}
.channel-header-settings:hover {
    opacity: 1;
    color: var(--text-primary);
}
.channel-header h2 {
    font-size: var(--text-lg);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-1);
}
.channel-header p {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.channel-search {
    padding: var(--space-3) var(--space-5);
}
.channel-search .input {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    background: var(--bg-base);
    border-color: transparent;
}
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3);
}
.channel-section-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: var(--space-4) var(--space-3) var(--space-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.channel-section-label .material-icons {
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--ease-fast);
}
.channel-section-label:hover .material-icons {
    opacity: 1;
}
.channel-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}
.channel-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.channel-item.active {
    background: var(--gradient-accent-subtle);
    color: var(--text-accent);
    border-left: 2px solid var(--primary);
}
.channel-item .material-icons {
    font-size: 18px;
    opacity: 0.6;
}
.channel-item.active .material-icons {
    opacity: 1;
    color: var(--primary);
}
.channel-item .channel-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.channel-item .badge {
    flex-shrink: 0;
}
.channel-item.unread {
    color: var(--text-primary);
    font-weight: var(--weight-medium);
}

/* User footer */
.user-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, transparent, rgba(45, 212, 191, 0.03));
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.user-footer .avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.user-footer-info {
    flex: 1;
    min-width: 0;
}
.user-footer-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}
.user-footer-status {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.user-footer-actions {
    display: flex;
    gap: var(--space-1);
}
.user-footer-actions .material-icons {
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.user-footer-actions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Thread List Panel ---- */
.thread-list-panel {
    width: var(--thread-list-w);
    background: var(--bg-base);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    animation: fadeIn 0.5s ease 0.2s forwards;
    opacity: 0;
}
.thread-list-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.thread-list-header h3 {
    font-size: var(--text-md);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.thread-list-header h3 .material-icons {
    color: var(--primary);
}
.thread-list-header .btn {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}
.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}
.thread-item {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    border: 1px solid transparent;
    margin-bottom: var(--space-1);
}
.thread-item:hover {
    background: var(--bg-raised);
    border-color: var(--border-subtle);
}
.thread-item.active {
    background: var(--gradient-accent-subtle);
    border-color: var(--border-accent);
    box-shadow: inset 3px 0 0 var(--primary), var(--shadow-glow);
}
.thread-item-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.thread-item-title .pinned {
    color: var(--primary);
    font-size: 14px;
}
.thread-item-preview {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-2);
}
.thread-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.thread-item-participants {
    display: flex;
    align-items: center;
}
.thread-item-participants .avatar {
    width: 20px;
    height: 20px;
    font-size: 9px;
    margin-right: -6px;
    border: 2px solid var(--bg-base);
}
.thread-item-participants .avatar:last-of-type {
    margin-right: var(--space-2);
}
.thread-item.unread .thread-item-title {
    color: var(--text-primary);
}
.thread-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    box-shadow: 0 0 8px var(--primary-glow);
    flex-shrink: 0;
}

/* ---- Thread View ---- */
.thread-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    background-image: var(--gradient-mesh-3);
    min-width: 0;
    animation: fadeIn 0.5s ease 0.3s forwards;
    opacity: 0;
}
.thread-view-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, var(--bg-raised), var(--bg-base));
}
.thread-view-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.thread-view-title h2 {
    font-size: var(--text-lg);
}
.thread-view-title .thread-channel {
    font-size: var(--text-xs);
    color: var(--text-accent);
    background: var(--primary-muted);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-accent);
}
.thread-view-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.thread-view-actions .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--ease-fast);
}
.thread-view-actions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Messages ---- */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}
.message {
    display: flex;
    gap: var(--space-3);
    max-width: 100%;
    position: relative;
}
.message-avatar .avatar {
    margin-top: 2px;
}
.message-body {
    flex: 1;
    min-width: 0;
}
.message-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}
.message-author {
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--text-primary);
}
.message-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.message-content {
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: var(--leading-relaxed);
}
.message-content p {
    margin-bottom: var(--space-2);
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content code {
    background: var(--bg-elevated);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-accent);
}
.message-content pre {
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin: var(--space-3) 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
}
.message-reactions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}
.reaction {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.reaction:hover {
    border-color: var(--primary);
    background: var(--primary-muted);
}
.reaction.active {
    border-color: var(--primary);
    background: var(--primary-muted);
}
.message-attachment {
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    transition: all var(--ease-fast);
    max-width: 360px;
}
.message-attachment:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
}
.message-attachment .material-icons {
    color: var(--primary);
}
.message-attachment-info {
    flex: 1;
}
.message-attachment-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}
.message-attachment-size {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Message hover actions */
.message-hover-actions {
    position: absolute;
    top: -12px;
    right: 0;
    display: none;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.message:hover .message-hover-actions {
    display: flex;
}
.message-hover-actions .material-icons {
    font-size: 16px;
    padding: var(--space-1);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.message-hover-actions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Thread reply indicator (chat mode) */
.thread-replies {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--text-accent);
    cursor: pointer;
    transition: all var(--ease-fast);
    background: transparent;
}
.thread-replies:hover {
    background: var(--primary-muted);
}
.thread-replies .material-icons {
    font-size: 16px;
}
.thread-replies-avatars {
    display: flex;
    align-items: center;
}
.thread-replies-avatars .avatar {
    width: 20px;
    height: 20px;
    font-size: 9px;
    margin-right: -5px;
    border: 2px solid var(--bg-base);
}
.thread-replies-avatars .avatar:last-child {
    margin-right: var(--space-2);
}
.thread-replies-text {
    color: var(--text-accent);
}
.thread-replies-time {
    color: var(--text-muted);
    font-weight: var(--weight-normal);
}

/* Date divider */
.date-divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}
.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
}

/* Typing indicator */
.typing-indicator {
    padding: var(--space-2) var(--space-6);
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 28px;
}
.typing-dots {
    display: flex;
    gap: 3px;
}
.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: pulse 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; }

/* ---- Composer ---- */
.composer {
    padding: var(--space-4) var(--space-6) var(--space-5);
}
.composer-box {
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    transition: border-color var(--ease-base), box-shadow var(--ease-base);
}
.composer-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-glow);
}
.composer-input {
    width: 100%;
    padding: var(--space-4) var(--space-5);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 160px;
}
.composer-input::placeholder {
    color: var(--text-muted);
}
.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--border-subtle);
}
.composer-toolbar-left {
    display: flex;
    gap: var(--space-1);
}
.composer-toolbar .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.composer-toolbar .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.composer-send {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-base);
}
.composer-send .material-icons {
    color: var(--text-inverse);
    font-size: 18px;
}
.composer-send:hover {
    background: var(--gradient-brand-vivid);
    transform: scale(1.08);
    box-shadow: var(--shadow-glow-strong);
}

/* ---- Chat Main (Chat Mode) ---- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    background-image: var(--gradient-mesh-3);
    min-width: 0;
    animation: fadeIn 0.5s ease 0.2s forwards;
    opacity: 0;
}
.chat-main-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, var(--bg-raised), var(--bg-base));
}
.chat-main-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.chat-main-title h2 {
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.chat-main-title h2 .material-icons {
    color: var(--primary);
}
.chat-main-title .member-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.chat-main-title .member-count .material-icons {
    font-size: 14px;
}
.mode-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    background: var(--primary-muted);
    color: var(--text-accent);
    border: 1px solid var(--border-accent);
    cursor: pointer;
    transition: all var(--ease-base);
}
.mode-pill .material-icons {
    font-size: 14px;
}
.mode-pill:hover {
    background: rgba(45, 212, 191, 0.25);
    box-shadow: var(--shadow-glow);
}
.mode-pill-readonly {
    cursor: default;
    opacity: 0.85;
}
.mode-pill-readonly:hover {
    background: var(--primary-muted);
    box-shadow: none;
}

/* Channel item wrapper for settings dropdown */
.channel-item-wrapper {
    position: relative;
}
.channel-mode-icon {
    font-size: 14px !important;
    opacity: 0.4 !important;
    margin-left: auto;
    flex-shrink: 0;
}
.channel-settings-icon {
    font-size: 16px !important;
    opacity: 0 !important;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity var(--ease-fast), color var(--ease-fast);
    padding: 2px;
    border-radius: var(--radius-sm);
}
.channel-item:hover .channel-settings-icon {
    opacity: 0.6 !important;
}
.channel-settings-icon:hover {
    opacity: 1 !important;
    color: var(--text-accent);
    background: var(--bg-active);
}
.channel-settings-dropdown {
    position: absolute;
    top: 100%;
    right: var(--space-2);
    z-index: 50;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: var(--space-1) 0;
    animation: fadeIn 0.12s ease;
}
.channel-settings-dropdown-header {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.channel-settings-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.channel-settings-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.channel-settings-dropdown-item .material-icons {
    font-size: 16px;
    color: var(--text-accent);
}

.chat-main-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.chat-main-actions .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--ease-fast);
}
.chat-main-actions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Thread Side Panel (Chat Mode) ---- */
.thread-panel {
    width: 380px;
    background: var(--bg-base);
    border-left: 2px solid transparent;
    border-image: var(--gradient-brand-warm) 1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    animation: slideInRight 0.35s ease forwards;
    opacity: 0;
    animation-fill-mode: forwards;
}
.thread-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 30%, rgba(45, 212, 191, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}
.thread-panel > * {
    position: relative;
    z-index: 1;
}
.thread-panel-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, var(--bg-raised), var(--bg-base));
}
.thread-panel-header h3 {
    font-size: var(--text-md);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.thread-panel-header h3 .material-icons {
    color: var(--primary);
    font-size: 20px;
}
.thread-panel-close {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.thread-panel-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.thread-parent {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--gradient-accent-subtle);
}
.thread-parent .message {
    gap: var(--space-3);
}
.thread-parent .message-content {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.thread-parent .message-author {
    font-size: var(--text-sm);
}
.thread-reply-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: var(--space-2) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.thread-reply-count::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-default), transparent);
}
.thread-panel .messages {
    padding: var(--space-4) var(--space-5);
    gap: var(--space-4);
}
.thread-panel .message-content {
    font-size: var(--text-sm);
}
.thread-panel .composer {
    padding: var(--space-3) var(--space-4) var(--space-4);
}
.thread-panel .composer-input {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    min-height: 38px;
}

/* ============================================
   DM View
   ============================================ */
.dm-sidebar {
    width: var(--sidebar-channels-w);
    background: var(--bg-deep);
    background-image: var(--gradient-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    animation: slideInLeft 0.4s ease 0.1s forwards;
    opacity: 0;
}
.dm-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dm-header h2 {
    font-size: var(--text-lg);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.dm-header .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.dm-header .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.dm-search {
    padding: var(--space-3) var(--space-5);
}
.dm-search .input {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    background: var(--bg-base);
    border-color: transparent;
}
.dm-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3);
}
.dm-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    position: relative;
    margin-bottom: var(--space-1);
}
.dm-item:hover {
    background: var(--bg-hover);
}
.dm-item.active {
    background: var(--gradient-accent-subtle);
    border-left: 2px solid var(--primary);
}
.dm-item-avatar {
    position: relative;
    flex-shrink: 0;
}
.dm-item-avatar .status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
}
.dm-item-info {
    flex: 1;
    min-width: 0;
}
.dm-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 2px;
}
.dm-item-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dm-item.active .dm-item-name {
    color: var(--text-accent);
}
.dm-item-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: var(--space-2);
}
.dm-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dm-item-preview {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.dm-item.unread .dm-item-name {
    font-weight: var(--weight-semibold);
}
.dm-item.unread .dm-item-preview {
    color: var(--text-secondary);
}
.dm-item .badge {
    flex-shrink: 0;
    margin-left: var(--space-2);
}

/* ============================================
   Search Overlay
   ============================================ */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    background: radial-gradient(ellipse at 50% 30%, rgba(45, 212, 191, 0.06) 0%, transparent 50%), rgba(13, 17, 23, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: overlayFadeIn 0.25s ease forwards;
}

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

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

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

.search-palette {
    width: 680px;
    max-height: 75vh;
    background: var(--gradient-mesh-1), var(--gradient-mesh-2), var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(45, 212, 191, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: paletteSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}
.search-input-wrapper .search-icon {
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
}
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-xl);
    font-weight: var(--weight-medium);
    outline: none;
    caret-color: var(--primary);
}
.search-input::placeholder {
    color: var(--text-muted);
    font-weight: var(--weight-normal);
}
.search-kbd-esc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    flex-shrink: 0;
    cursor: pointer;
}

.search-filters {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-base);
    white-space: nowrap;
}
.filter-chip:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.filter-chip.active {
    background: var(--gradient-accent-subtle);
    border-color: var(--border-accent);
    color: var(--text-accent);
}
.filter-chip .material-icons {
    font-size: 14px;
}
.filter-divider {
    width: 1px;
    height: 20px;
    background: var(--border-default);
    margin: 0 var(--space-1);
}
.filter-chip-space {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-base);
}
.filter-chip-space:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.filter-chip-space .material-icons {
    font-size: 14px;
    color: var(--text-muted);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4);
}
.search-results-header {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.search-result {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    border: 1px solid transparent;
}
.search-result:hover,
.search-result.selected {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
}
.result-type-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.result-type-icon.message-type {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}
.result-type-icon.thread-type {
    background: var(--primary-muted);
    color: var(--primary);
    box-shadow: 0 0 12px rgba(45, 212, 191, 0.15);
}
.result-type-icon.file-type {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.15);
}
.result-type-icon .material-icons {
    font-size: 18px;
}
.result-body {
    flex: 1;
    min-width: 0;
}
.result-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.result-type-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-normal);
    color: var(--text-muted);
    background: var(--bg-active);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}
.result-preview {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.result-preview mark {
    background: rgba(45, 212, 191, 0.1);
    color: var(--text-accent);
    text-decoration: underline;
    text-decoration-color: var(--primary);
    text-underline-offset: 2px;
    font-weight: var(--weight-medium);
    padding: 1px 3px;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.12);
}
.result-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.result-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.result-breadcrumb .sep { color: var(--text-muted); opacity: 0.5; }
.result-breadcrumb .space-name { color: var(--text-secondary); }
.result-breadcrumb .channel-name { color: var(--text-secondary); }
.result-breadcrumb .thread-name { color: var(--text-accent); }
.result-author {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.result-time { color: var(--text-muted); }

.recent-searches { padding: var(--space-3) var(--space-4); }
.recent-header {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.recent-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}
.recent-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.recent-item .material-icons { font-size: 16px; color: var(--text-muted); }
.recent-item-text { flex: 1; }
.recent-item-scope { font-size: var(--text-xs); color: var(--text-muted); }

.search-footer {
    padding: var(--space-3) var(--space-6);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--gradient-accent-subtle);
}
.search-footer-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
}

/* ============================================
   Space Switcher Overlay
   ============================================ */
.switcher-backdrop {
    position: fixed;
    inset: 0;
    left: var(--sidebar-spaces-w);
    background: radial-gradient(ellipse at 50% 40%, rgba(45, 212, 191, 0.05) 0%, transparent 60%), rgba(13, 17, 23, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes panelReveal {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.switcher-panel {
    position: fixed;
    top: 50%;
    left: calc(var(--sidebar-spaces-w) + 50%);
    transform: translate(-50%, -50%);
    width: min(920px, calc(100vw - var(--sidebar-spaces-w) - 80px));
    max-height: calc(100vh - 80px);
    background: var(--gradient-mesh-1), var(--gradient-mesh-2), rgba(30, 37, 53, 0.85);
    backdrop-filter: blur(40px) saturate(1.3);
    -webkit-backdrop-filter: blur(40px) saturate(1.3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 80px rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: panelReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.switcher-header {
    padding: var(--space-6) var(--space-8) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.switcher-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.switcher-header-left h2 {
    font-size: var(--text-xl);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.switcher-header-left .material-icons {
    font-size: 24px;
    color: var(--primary);
}
.switcher-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--gradient-brand);
    border: none;
    color: var(--text-inverse);
    transition: all var(--ease-fast);
}
.switcher-close:hover {
    background: var(--gradient-brand-vivid);
    box-shadow: var(--shadow-glow-strong);
}
.switcher-close .material-icons { font-size: 18px; }

.switcher-search {
    padding: 0 var(--space-8) var(--space-5);
    flex-shrink: 0;
}
.switcher-search-box { position: relative; }
.switcher-search-box .material-icons {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
    pointer-events: none;
}
.switcher-search-box .input {
    padding-left: 44px;
    background: rgba(13, 17, 23, 0.5);
    border-color: var(--border-subtle);
    font-size: var(--text-md);
    height: 48px;
    border-radius: var(--radius-lg);
}
.switcher-search-box .input:focus {
    background: rgba(13, 17, 23, 0.7);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-glow);
}
.shortcut-hint {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
}

.switcher-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-8) var(--space-6);
}

.switcher-section-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: var(--space-2) 0 var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.switcher-section-label .material-icons { font-size: 14px; }

.spaces-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.space-card {
    background: rgba(18, 24, 32, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.space-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    opacity: 0;
    transition: opacity 0.25s ease;
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.05), transparent);
}
.space-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}
.space-card:hover::before { opacity: 1; }
.space-card.current {
    border-color: var(--border-accent);
    background: var(--gradient-accent-subtle);
}
.space-card.current::after {
    content: 'Current';
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    font-size: 10px;
    font-weight: var(--weight-semibold);
    color: var(--primary);
    background: var(--primary-muted);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.space-card-top {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.space-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-lg);
    color: var(--text-primary);
    flex-shrink: 0;
    position: relative;
}
.space-card-icon .badge { position: absolute; top: -4px; right: -6px; }
.space-card-info { flex: 1; min-width: 0; }
.space-card-name {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.space-card-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.space-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.space-card-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.space-card-meta-item .material-icons { font-size: 14px; color: var(--text-muted); }

.space-card-create {
    background: transparent;
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 130px;
}
.space-card-create:hover {
    border-color: var(--primary);
    background: var(--gradient-accent-subtle);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}
.space-card-create-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px dashed var(--border-default);
    transition: all var(--ease-base);
}
.space-card-create:hover .space-card-create-icon {
    background: var(--primary-muted);
    border-color: var(--primary);
}
.space-card-create-icon .material-icons {
    font-size: 24px;
    color: var(--text-muted);
    transition: color var(--ease-base);
}
.space-card-create:hover .space-card-create-icon .material-icons { color: var(--primary); }
.space-card-create-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    transition: color var(--ease-base);
}
.space-card-create:hover .space-card-create-label { color: var(--primary); }

.recent-dms {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.dm-avatar { position: relative; flex-shrink: 0; }
.dm-info { flex: 1; min-width: 0; }
.dm-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}
.dm-preview {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dm-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    flex-shrink: 0;
}
.dm-time { font-size: var(--text-xs); color: var(--text-muted); }
.dm-item.unread .dm-name {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}
.dm-item.unread .dm-preview { color: var(--text-secondary); }

.switcher-footer {
    padding: var(--space-3) var(--space-8);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-6);
    font-size: var(--text-xs);
    color: var(--text-muted);
    flex-shrink: 0;
    background: rgba(13, 17, 23, 0.3);
}
.switcher-footer-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.switcher-footer-item kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* ============================================
   Invite & Member Management
   ============================================ */
.settings-sidebar {
    width: var(--sidebar-channels-w);
    background: var(--bg-deep);
    background-image: var(--gradient-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    animation: slideInLeft 0.4s ease 0.1s forwards;
    opacity: 0;
}
.settings-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}
.settings-header h2 {
    font-size: var(--text-lg);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-1);
}
.settings-header p {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.settings-nav {
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.settings-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}
.settings-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.settings-nav-item.active {
    background: var(--gradient-accent-subtle);
    color: var(--text-accent);
    border-left: 2px solid var(--primary);
}
.settings-nav-item .material-icons { font-size: 18px; opacity: 0.6; }
.settings-nav-item.active .material-icons { opacity: 1; color: var(--primary); }

.members-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.members-table th {
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
}
.members-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.members-table tr { transition: background var(--ease-fast); }
.members-table tbody tr:hover { background: var(--gradient-accent-subtle); }
.member-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.member-details {
    display: flex;
    flex-direction: column;
}
.member-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}
.member-email {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}
.role-badge.owner {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(6, 182, 212, 0.1));
    color: var(--primary);
}
.role-badge.member {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.08));
    color: #818cf8;
}
.role-badge.guest {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(245, 158, 11, 0.08));
    color: var(--warning);
}
.channel-tags {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}
.channel-tag {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 1px 8px;
    border-radius: var(--radius-sm);
}
.channel-tag.all {
    color: var(--text-muted);
    font-style: italic;
    background: transparent;
}
.member-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.member-actions {
    display: flex;
    gap: var(--space-1);
}
.member-actions .material-icons {
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.member-actions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.member-actions .material-icons.danger:hover {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.1);
}

.invitations-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.invitation-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--ease-fast);
}
.invitation-item:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
}
.invitation-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.invitation-icon .material-icons { font-size: 18px; color: var(--primary); }
.invitation-details { flex: 1; min-width: 0; }
.invitation-email {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: 2px;
}
.invitation-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.invitation-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}
.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}
.btn-danger-ghost:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--danger);
    box-shadow: none;
    transform: none;
}

.invite-form-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}
.invite-form-card h3 {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.invite-form-card h3 .material-icons { color: var(--primary); font-size: 20px; }
.form-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.form-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-selector {
    display: flex;
    gap: var(--space-2);
}
.role-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-base);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    font-family: var(--font-body);
}
.role-option:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.role-option.selected {
    border-color: var(--primary);
    background: var(--primary-muted);
    color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
}
.role-option .material-icons { font-size: 18px; }
.channel-checkboxes {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    max-height: 180px;
    overflow-y: auto;
    animation: fadeInUp 0.3s ease forwards;
}
.channel-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--ease-fast);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.channel-checkbox:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.channel-checkbox .material-icons { font-size: 16px; opacity: 0.5; }
.form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}
.invite-link-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}
.link-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--ease-base);
}
.link-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-muted);
}
.link-btn .material-icons { font-size: 15px; }

/* ============================================
   Onboarding
   ============================================ */
.onboarding-backdrop {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-deepest);
    background-image:
        var(--gradient-mesh-1),
        var(--gradient-mesh-2);
}
.onboarding-card {
    width: 440px;
    padding: var(--space-10);
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 80px rgba(45, 212, 191, 0.06);
    animation: paletteSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.onboarding-brand {
    text-align: center;
    margin-bottom: var(--space-6);
}
.onboarding-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    box-shadow: var(--shadow-glow-strong);
}
.onboarding-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
}
.onboarding-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.onboarding-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--space-6);
}
.onboarding-step-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    border: 2px solid var(--border-default);
    transition: all var(--ease-base);
}
.onboarding-step-dot.active {
    background: var(--gradient-brand);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}
.onboarding-step-dot.done {
    background: var(--primary);
    border-color: var(--primary);
}
.onboarding-step-line {
    width: 40px;
    height: 2px;
    background: var(--border-default);
}
.onboarding-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.onboarding-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: calc(-1 * var(--space-1));
}
.onboarding-btn {
    width: 100%;
    justify-content: center;
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
}
.onboarding-error {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: var(--text-sm);
    margin-bottom: var(--space-3);
}
.onboarding-success {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    color: var(--online);
    font-size: var(--text-sm);
}

/* ============================================
   Invite Accept Page
   ============================================ */
.invite-accept-backdrop {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-deepest);
    background-image:
        var(--gradient-mesh-1),
        var(--gradient-mesh-2);
}
.invite-accept-card {
    width: 440px;
    padding: var(--space-10);
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 80px rgba(45, 212, 191, 0.06);
    animation: paletteSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.invite-accept-loading {
    text-align: center;
    padding: var(--space-8) 0;
}
.invite-accept-content {
    text-align: center;
}
.invite-details-box {
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin: var(--space-5) 0;
    text-align: left;
}
.invite-detail-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.invite-detail-row .material-icons {
    color: var(--primary);
}
.invite-detail-row strong {
    color: var(--text-primary);
}
.invite-auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: left;
}

/* ============================================
   File Upload & File Browser
   ============================================ */

/* ---- File Drop Zone ---- */
.file-drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* ---- Drag & Drop Overlay ---- */
.drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.08), rgba(6, 182, 212, 0.05));
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease forwards;
}
.drop-overlay-inner {
    border: 2.5px dashed var(--primary);
    border-radius: var(--radius-xl);
    padding: var(--space-12) var(--space-10);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    background: rgba(45, 212, 191, 0.06);
    box-shadow: var(--shadow-glow-strong);
}
.drop-overlay-inner .material-icons {
    font-size: 56px;
    color: var(--primary);
    filter: drop-shadow(0 0 12px rgba(45, 212, 191, 0.4));
}
.drop-overlay-text {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}
.drop-overlay-sub {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ---- Upload Progress in Composer ---- */
.composer-uploads {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.upload-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-deep);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}
.upload-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.upload-item-icon.img-icon {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}
.upload-item-icon.pdf-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}
.upload-item-icon.spreadsheet-icon {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
.upload-item-icon.generic-icon {
    background: var(--primary-muted);
    color: var(--primary);
}
.upload-item-icon .material-icons { font-size: 18px; }
.upload-item-info { flex: 1; min-width: 0; }
.upload-item-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-item-status {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.upload-progress-bar {
    width: 100%;
    height: 3px;
    background: var(--bg-active);
    border-radius: var(--radius-full);
    margin-top: var(--space-1);
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--primary-glow);
}
.upload-item-cancel {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-fast);
    flex-shrink: 0;
}
.upload-item-cancel:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--danger);
}
.upload-item-cancel .material-icons {
    font-size: 14px;
    color: var(--text-muted);
}
.upload-item-cancel:hover .material-icons {
    color: var(--danger);
}

/* ---- Image Preview in Message ---- */
.message-image-preview {
    margin-top: var(--space-3);
    position: relative;
    display: inline-block;
    max-width: 400px;
    cursor: pointer;
}
.message-image-preview img {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    display: block;
}
.message-image-preview .image-expand {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--ease-fast);
}
.message-image-preview:hover .image-expand { opacity: 1; }
.message-image-preview .image-expand .material-icons {
    color: white;
    font-size: 18px;
}

/* ---- File Attachment Card ---- */
.file-card {
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.file-card:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
}
.file-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.file-card-icon.pdf {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}
.file-card-icon.spreadsheet {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
.file-card-icon.image {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}
.file-card-icon.generic {
    background: var(--primary-muted);
    color: var(--primary);
}
.file-card-info { flex: 1; min-width: 0; }
.file-card-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-card-size {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.file-card-download {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--ease-fast);
    flex-shrink: 0;
    text-decoration: none;
}
.file-card-download:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-muted);
}
.file-card-download .material-icons { font-size: 16px; }

/* ---- Multi-File Grid ---- */
.multi-file-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-top: var(--space-3);
    max-width: 500px;
}
.multi-file-grid .file-card {
    margin-top: 0;
}
.multi-file-grid .message-image-preview {
    margin-top: 0;
    max-width: 100%;
}
.multi-file-grid .message-image-preview img {
    height: 120px;
    object-fit: cover;
}

/* ---- Image Lightbox ---- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease forwards;
}
.lightbox-close {
    position: absolute;
    top: var(--space-5);
    right: var(--space-5);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-fast);
    z-index: 1001;
}
.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}
.lightbox-close .material-icons {
    color: white;
    font-size: 24px;
}
.lightbox-download {
    position: absolute;
    top: var(--space-5);
    right: 80px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-fast);
    z-index: 1001;
}
.lightbox-download:hover {
    background: rgba(45, 212, 191, 0.2);
    border-color: var(--primary);
}
.lightbox-download .material-icons {
    color: white;
    font-size: 20px;
}
.lightbox-image {
    max-width: 80vw;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}
.lightbox-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
}
.lightbox-meta {
    margin-top: var(--space-4);
    text-align: center;
}
.lightbox-filename {
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: white;
}
.lightbox-info {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.5);
    margin-top: var(--space-1);
}

/* ---- Files Panel ---- */
.files-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    background-image: var(--gradient-mesh-3);
    min-width: 0;
}
.files-panel-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, var(--bg-raised), var(--bg-base));
}
.files-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}
.files-panel-top h2 {
    font-size: var(--text-lg);
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.files-panel-top h2 .material-icons {
    color: var(--primary);
}
.files-panel-top h2 .channel-tag {
    font-size: var(--text-sm);
    color: var(--text-accent);
    font-weight: var(--weight-normal);
}
.files-panel-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.files-search {
    width: 260px;
    padding: var(--space-2) var(--space-3);
    padding-left: var(--space-8);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--ease-base), box-shadow var(--ease-base);
}
.files-search::placeholder { color: var(--text-muted); }
.files-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-glow);
}
.files-search-wrapper {
    position: relative;
}
.files-search-wrapper .material-icons {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.view-toggle {
    display: flex;
    background: var(--bg-deep);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}
.view-toggle-btn {
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ease-fast);
}
.view-toggle-btn:hover { color: var(--text-primary); }
.view-toggle-btn.active {
    background: var(--primary-muted);
    color: var(--primary);
}
.view-toggle-btn .material-icons { font-size: 18px; }

/* Filter tabs */
.files-filter-tabs {
    display: flex;
    gap: var(--space-1);
}
.filter-tab {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-fast);
    background: transparent;
    border: 1px solid transparent;
}
.filter-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.filter-tab.active {
    background: var(--primary-muted);
    color: var(--text-accent);
    border-color: var(--border-accent);
}

/* ---- List View ---- */
.files-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-6);
}
.files-date-group {
    margin-bottom: var(--space-6);
}
.files-date-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-2);
}
.file-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    border: 1px solid transparent;
}
.file-row:hover {
    background: var(--bg-raised);
    border-color: var(--border-subtle);
}
.file-row-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.file-row-icon.pdf { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.file-row-icon.spreadsheet { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.file-row-icon.image { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.file-row-icon.generic { background: var(--primary-muted); color: var(--primary); }
.file-row-icon.other { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.file-row-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-row-thumb-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.file-row-thumb-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(45, 212, 191, 0.15));
}
.file-row-thumb-inner .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    position: relative;
}
.file-row-info {
    flex: 1;
    min-width: 0;
}
.file-row-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-row-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.file-row-date {
    font-size: var(--text-sm);
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 80px;
    text-align: right;
}
.file-row-size {
    font-size: var(--text-sm);
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 60px;
    text-align: right;
}
.file-row-download {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--ease-fast);
    flex-shrink: 0;
    opacity: 0;
    text-decoration: none;
}
.file-row:hover .file-row-download { opacity: 1; }
.file-row-download:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-muted);
}
.file-row-download .material-icons { font-size: 16px; }

/* ---- Grid View ---- */
.files-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    flex: 1;
    overflow-y: auto;
    align-content: start;
}
.files-grid.visible { display: grid; }
.grid-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--ease-fast);
}
.grid-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.grid-card-thumb {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.grid-card-thumb.img-thumb {
    background: linear-gradient(135deg, #1e293b, #334155);
}
.grid-card-thumb.img-thumb::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(99, 102, 241, 0.12), transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(45, 212, 191, 0.08), transparent 50%);
}
.grid-card-thumb.img-thumb .material-icons {
    font-size: 36px;
    color: var(--text-muted);
    position: relative;
}
.grid-card-thumb.doc-thumb {
    background: var(--bg-deep);
}
.grid-card-thumb.doc-thumb .thumb-doc {
    width: 60px;
    height: 80px;
    background: white;
    border-radius: 3px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 3px;
}
.grid-card-thumb.doc-thumb .line {
    height: 2px;
    background: #d1d5db;
    border-radius: 1px;
}
.grid-card-thumb.doc-thumb .line.short { width: 60%; }
.grid-card-thumb.doc-thumb .line.medium { width: 80%; }
.grid-card-info {
    padding: var(--space-3);
}
.grid-card-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-1);
}
.grid-card-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* File count summary */
.files-summary {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-xs);
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, transparent, rgba(45, 212, 191, 0.02));
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.files-summary .material-icons {
    font-size: 14px;
    color: var(--text-muted);
}

/* ============================================
   Rich Composer, Emoji Picker, Mentions
   ============================================ */

/* ---- Formatting Toolbar ---- */
.formatting-toolbar {
    display: flex;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    gap: var(--space-1);
}
.fmt-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
}
.fmt-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.fmt-btn.active {
    color: var(--text-accent);
    background: var(--primary-muted);
}
.fmt-btn .material-icons {
    font-size: 18px;
}
.fmt-divider {
    width: 1px;
    height: 20px;
    background: var(--border-default);
    margin: 0 var(--space-2);
    flex-shrink: 0;
}

/* ---- Rich Composer Bottom Toolbar ---- */
.composer-bottom-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--border-subtle);
}
.composer-bottom-left {
    display: flex;
    gap: var(--space-1);
    align-items: center;
}
.composer-bottom-toolbar .material-icons {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--ease-fast);
}
.composer-bottom-toolbar .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Mentions Dropdown ---- */
.mentions-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: var(--space-6);
    width: 280px;
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    overflow: hidden;
    animation: fadeInUp 0.15s ease forwards;
}
.mentions-header {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-subtle);
}
.mentions-list {
    max-height: 300px;
    overflow-y: auto;
}
.mention-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.mention-item:hover {
    background: var(--bg-hover);
}
.mention-item.selected {
    background: var(--gradient-accent-subtle);
}
.mention-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--text-inverse);
}
.mention-special-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-elevated);
}
.mention-special-icon .material-icons {
    font-size: 18px;
    color: var(--primary);
}
.mention-item-info {
    flex: 1;
    min-width: 0;
}
.mention-item-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.mention-item-name .match {
    color: var(--primary);
    font-weight: var(--weight-semibold);
}
.mention-item-username {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.mention-item-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.mention-status {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}
.mentions-footer {
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.mentions-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 10px;
    color: var(--text-secondary);
}
.mentions-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0;
}

/* ---- @mention highlight in messages ---- */
.mention-highlight {
    color: var(--text-accent);
    background: var(--primary-muted);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
}

/* ---- Edited label ---- */
.message-edited {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    margin-left: var(--space-1);
}

/* ---- Bookmarked state ---- */
.message-hover-actions .material-icons.bookmarked {
    color: var(--primary);
}

/* ---- Quick Reactions Row ---- */
.quick-reactions {
    position: absolute;
    top: -16px;
    right: 0;
    display: none;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    z-index: 60;
    align-items: center;
}
.message:hover .quick-reactions {
    display: flex;
}
.quick-reaction {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all var(--ease-fast);
    background: transparent;
    border: none;
    line-height: 1;
}
.quick-reaction:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}
.quick-reactions-divider {
    width: 1px;
    height: 20px;
    background: var(--border-default);
    margin: 0 2px;
}
.quick-reactions .material-icons {
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-full);
    transition: all var(--ease-fast);
}
.quick-reactions .material-icons:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Full Emoji Picker ---- */
.emoji-picker {
    width: 320px;
    height: 400px;
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 70;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.2s ease forwards;
}
.emoji-picker-search {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}
.emoji-picker-search input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    padding-left: 34px;
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--ease-base);
}
.emoji-picker-search input::placeholder {
    color: var(--text-muted);
}
.emoji-picker-search input:focus {
    border-color: var(--primary);
}
.emoji-search-wrapper {
    position: relative;
}
.emoji-search-wrapper .material-icons {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
}
.emoji-categories {
    display: flex;
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    gap: 0;
}
.emoji-cat-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    border-bottom: 2px solid transparent;
    transition: all var(--ease-fast);
}
.emoji-cat-tab:hover {
    color: var(--text-secondary);
}
.emoji-cat-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.emoji-cat-tab .material-icons {
    font-size: 18px;
}
.emoji-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3);
}
.emoji-section-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-2) var(--space-1);
    margin-top: var(--space-1);
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.emoji-cell {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--ease-fast);
    line-height: 1;
}
.emoji-cell:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
}
.emoji-footer {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.emoji-preview {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.emoji-preview-glyph {
    font-size: 28px;
    line-height: 1;
}

/* ---- Composer richtext mention styling ---- */
.composer-richtext .mention {
    color: var(--text-accent);
    background: var(--primary-muted);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
}

/* ============================================
   Profile Settings
   ============================================ */

.avatar-section {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}
.avatar-edit {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-2xl);
    color: white;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}
.avatar-edit-overlay {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--ease-fast);
}
.avatar-edit:hover .avatar-edit-overlay {
    opacity: 1;
}
.avatar-edit-overlay .material-icons {
    font-size: 24px;
    color: white;
}
.avatar-edit-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--ease-base);
    background: transparent;
    color: var(--text-secondary);
}
.btn-upload:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.avatar-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Form fields (profile) */
.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    transition: border-color var(--ease-base), box-shadow var(--ease-base);
}
.form-input::placeholder {
    color: var(--text-muted);
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-glow);
}
.form-input.readonly {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-subtle);
}

/* Status input */
.status-input-wrapper {
    display: flex;
    gap: var(--space-2);
}
.status-input-wrapper .form-input {
    flex: 1;
}
.emoji-picker-btn {
    width: 42px;
    height: 42px;
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-fast);
    flex-shrink: 0;
}
.emoji-picker-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.emoji-picker-btn .material-icons {
    font-size: 20px;
    color: var(--text-muted);
}
.emoji-picker-btn:hover .material-icons {
    color: var(--text-primary);
}
.clear-status {
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-2);
    transition: color var(--ease-fast);
    cursor: pointer;
}
.clear-status:hover {
    color: var(--text-secondary);
}
.status-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-4);
}
.status-preset {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.status-preset:hover {
    background: var(--primary-muted);
    border-color: var(--border-accent);
    color: var(--text-accent);
}
.status-preset .preset-emoji {
    font-size: 16px;
}
.btn-save {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-8);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all var(--ease-base);
    background: var(--gradient-brand);
    color: var(--text-inverse);
}
.btn-save:hover {
    background: var(--gradient-brand-vivid);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), var(--shadow-glow-strong);
}
.btn-save:active {
    transform: scale(0.98);
}
.section-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-5);
}

/* Stagger animations */
.stagger-1 { animation: fadeInUp 0.5s ease 0.1s forwards; opacity: 0; }
.stagger-2 { animation: fadeInUp 0.5s ease 0.25s forwards; opacity: 0; }
.stagger-3 { animation: fadeInUp 0.5s ease 0.4s forwards; opacity: 0; }
.stagger-4 { animation: fadeInUp 0.5s ease 0.55s forwards; opacity: 0; }

/* ============================================
   Member Management
   ============================================ */

/* Search & filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.filter-select {
    padding: var(--space-3) var(--space-4);
    padding-right: 36px;
    background: var(--bg-deep);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
    cursor: pointer;
    transition: border-color var(--ease-base);
    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='%235a6478'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 140px;
}
.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

/* Role dropdown */
.role-dropdown-wrapper {
    position: relative;
}
.role-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all var(--ease-fast);
    border: 1px solid transparent;
    font-family: var(--font-body);
}
.role-dropdown-trigger:hover {
    filter: brightness(1.2);
    border-color: rgba(255,255,255,0.1);
}
.role-dropdown-trigger.owner {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(6, 182, 212, 0.1));
    color: var(--primary);
}
.role-dropdown-trigger.member {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.08));
    color: #818cf8;
}
.role-dropdown-trigger.admin {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.08));
    color: #818cf8;
}
.role-dropdown-trigger.guest {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(245, 158, 11, 0.08));
    color: var(--warning);
}
.role-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--space-1);
    animation: fadeInUp 0.2s ease forwards;
}
.role-dropdown-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--ease-fast);
}
.role-dropdown-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Actions menu */
.actions-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--space-1);
    animation: fadeInUp 0.2s ease forwards;
}
.actions-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--ease-fast);
}
.actions-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.actions-menu-item.danger {
    color: var(--danger);
}
.actions-menu-item.danger:hover {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
}
.actions-menu-item .material-icons {
    font-size: 18px;
}
.actions-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* Guest channel editor */
.guest-channel-editor {
    background: var(--bg-raised);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    animation: fadeInUp 0.3s ease forwards;
}
.guest-channel-editor-header {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.guest-channel-editor-header .material-icons {
    font-size: 16px;
    color: var(--primary);
}
.channel-checkboxes {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.channel-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--ease-fast);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.channel-checkbox:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.channel-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
    cursor: pointer;
    position: relative;
    transition: all var(--ease-fast);
    flex-shrink: 0;
}
.channel-checkbox input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.channel-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid var(--text-inverse);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.guest-channel-editor-actions {
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}
.guest-channel-editor-actions .btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

/* Confirmation modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease forwards;
}
.modal-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.3s ease forwards;
}
.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: rgba(248, 113, 113, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-5);
}
.modal-icon .material-icons {
    font-size: 24px;
    color: var(--danger);
}
.modal-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}
.modal-body {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-6);
}
.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}
.btn-danger {
    background: var(--danger);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--ease-base);
}
.btn-danger:hover {
    background: #ef4444;
    box-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
    transform: translateY(-1px);
}

/* Form hint text */
.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Textarea styling in forms */
textarea.input {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-body);
}

/* ============================================
   Channel Context Menu
   ============================================ */

.context-menu {
    position: absolute;
    min-width: 220px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    padding: var(--space-1);
    animation: fadeIn 0.15s ease forwards;
}
.context-menu-title {
    padding: var(--space-3) var(--space-4) var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    font-family: var(--font-display);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-1);
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all var(--ease-fast);
}
.context-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.context-menu-item .material-icons {
    font-size: 18px;
    opacity: 0.7;
}
.context-menu-item .submenu-arrow {
    margin-left: auto;
    font-size: 16px;
    opacity: 0.5;
}
.context-menu-item.danger {
    color: var(--danger);
}
.context-menu-item.danger:hover {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
}
.context-menu-item.danger .material-icons {
    opacity: 1;
}
.context-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* Notification submenu */
.notification-submenu {
    position: absolute;
    top: 0;
    left: calc(100% + 4px);
    min-width: 240px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 101;
    padding: var(--space-3);
    animation: slideInRight 0.2s ease forwards;
}
.notification-submenu-title {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-2);
}
.notification-option {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--ease-fast);
}
.notification-option:hover {
    background: var(--bg-hover);
}
.notification-radio {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-strong);
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
    transition: all var(--ease-fast);
}
.notification-option.selected .notification-radio {
    border-color: var(--primary);
}
.notification-option.selected .notification-radio::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--primary);
}
.notification-option-content {
    flex: 1;
}
.notification-option-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: 2px;
}
.notification-option-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-normal);
}

/* Muted channel */
.channel-item.muted {
    opacity: 0.45;
}
.channel-item.muted .channel-name {
    text-decoration: line-through;
    text-decoration-color: var(--text-muted);
}
/* Context menu highlight */
.channel-item.context-active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   New Messages Pill
   ============================================ */

.new-messages-pill {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-brand);
    color: var(--text-inverse);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: var(--shadow-lg), var(--shadow-glow-strong);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    z-index: 20;
    animation: fadeInUp 0.3s ease forwards;
    transition: all var(--ease-base);
}
.new-messages-pill:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow-strong);
}
.new-messages-pill .material-icons {
    font-size: 16px;
}
