@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #1a1a1e;
    --surface: #222226;
    --surface-2: #2a2a2f;
    --surface-3: #38383e;
    --text: #fafafa;
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-tertiary: rgba(255, 255, 255, 0.38);
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-dim: rgba(99, 102, 241, 0.12);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-dim: rgba(59, 130, 246, 0.12);
    --border: rgba(255, 255, 255, 0.10);
    --border-hover: rgba(255, 255, 255, 0.18);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);
    --sidebar-width: 272px;
    --header-height: 56px;
    --mobile-tab-height: 64px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 150ms;
    --duration-fast: 100ms;
    --duration-slow: 300ms;
    --surface-glass: rgba(26, 26, 30, 0.88);
    --accent-light: #818cf8;
    --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-light));
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus, span:focus, div:focus, p:focus,
h1:focus-visible, h2:focus-visible, h3:focus-visible, h4:focus-visible, h5:focus-visible, h6:focus-visible,
span:focus-visible, div:focus-visible, p:focus-visible { outline: none; }
html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    /* iOS PWA standalone bug: without background-attachment: fixed, the layout
       viewport sits at the top of the WKWebView, leaving an unreachable ~62px
       gap below position:fixed bottom:0 elements. Setting bg-attachment: fixed
       triggers iOS to position the layout viewport flush with the screen
       bottom — so the mobile tab bar actually reaches the screen edge. */
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent pull-to-refresh and rubber-band bounce on iOS */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#app { height: 100%; }

::selection { background: var(--accent); color: white; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInOnly { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes slideUpSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(24px); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes cardAppear { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}
@keyframes dropPulse {
    0%, 100% { border-color: var(--accent); }
    50% { border-color: var(--accent-glow); }
}
@keyframes messageSent {
    0% { background: var(--accent-dim); }
    100% { background: transparent; }
}

/* ========================================
   App Shell
   ======================================== */

.app-shell {
    display: flex;
    height: 100%; /* Fills body, which is forced to 100lvh */
    overflow: hidden;
    position: relative; /* Containing block for absolutely positioned mobile tab bar */
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.sidebar-brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }

.sidebar-search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--surface-2);
    color: var(--text-tertiary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    width: calc(100% - 16px);
}
.sidebar-search-btn:hover { background: var(--surface-3); color: var(--text-secondary); }
.sidebar-search-kbd {
    margin-left: auto;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--surface-3);
    color: var(--text-tertiary);
    font-family: inherit;
}

.sidebar-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav a, .sidebar-nav button {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-md);
    color: var(--text-secondary); text-decoration: none;
    font-size: 14px; font-weight: 500;
    border: none; background: none; cursor: pointer;
    width: 100%; text-align: left;
    transition: all var(--duration) var(--ease);
    position: relative;
}

.sidebar-nav a:hover, .sidebar-nav button:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav a.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.sidebar-section {
    padding: 16px 16px 6px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 12px 6px 16px;
    cursor: pointer;
    user-select: none;
}

.sidebar-section-header span {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.sidebar-section-chevron {
    transition: transform var(--duration) var(--ease);
    color: var(--text-tertiary);
}

.sidebar-section-chevron.collapsed {
    transform: rotate(-90deg);
}

.channel-list { padding: 0 8px 8px; }

.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; }

.channel-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; margin: 1px 4px; border-radius: var(--radius-md);
    color: var(--text-secondary); text-decoration: none;
    font-size: 14px; cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.channel-item:hover { background: var(--surface-2); color: var(--text); }
.channel-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.channel-name { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-prefix { color: var(--text-tertiary); font-weight: 400; }

.unread-badge {
    background: var(--accent); color: white;
    font-size: 11px; font-weight: 600;
    padding: 1px 6px; border-radius: 10px;
    min-width: 18px; text-align: center;
    animation: fadeIn 200ms var(--ease);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

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

.sidebar-footer-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer-role {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: capitalize;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status picker */
.status-picker {
    position: absolute;
    bottom: 58px;
    left: 8px;
    right: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 200ms var(--ease);
    z-index: 20;
}
.status-picker-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.status-picker-presets {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.status-preset {
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.status-preset:hover { background: var(--surface-3); }
.status-clear {
    width: 100%;
    text-align: center;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.15s;
}
.status-clear:hover { background: var(--surface-3); color: var(--text); }

/* ========================================
   Main Content Area
   ======================================== */

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; overflow: clip; min-width: 0; }
.main-content > * { animation: fadeIn 150ms var(--ease); }

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

.header-title { font-size: 17px; font-weight: 600; }
.header-topic { font-size: 14px; color: var(--text-secondary); margin-left: 12px; }

.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    animation: fadeIn 200ms var(--ease);
    overscroll-behavior: contain;
    min-height: 0;
}

/* ========================================
   Messages
   ======================================== */

.message-list { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 0; overscroll-behavior: contain; min-height: 0; }

.message {
    display: flex; gap: 14px; padding: 6px 16px; border-radius: var(--radius-lg);
    position: relative;
    transition: background var(--duration-fast) var(--ease);
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
    animation: fadeIn 150ms var(--ease);
}
.message:not(.message-compact) { margin-top: 14px; padding-top: 8px; padding-bottom: 0; }
.message.has-reactions { padding-bottom: 4px; }
.message:not(.message-compact):first-child { margin-top: 0; }
.message:hover { background: var(--surface); }

.message-compact {
    padding: 0 16px;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
    margin-top: 0;
}
.message-compact .message-avatar-wrapper {
    width: 44px;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.message-compact .message-time-inline {
    display: none;
    font-size: 11px;
    color: var(--text-tertiary);
    min-width: 48px;
}

.message-compact:hover .message-time-inline {
    display: inline;
}

.message-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.message-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-dim); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 600; flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.message-avatar-img {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}

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

.avatar-status-online { background: var(--success); }
.avatar-status-away { background: var(--warning); }
.avatar-status-busy { background: var(--danger); }
.avatar-status-offline { background: var(--text-tertiary); }

.avatar-bot-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    border: 2px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.avatar-bot-badge svg { width: 9px; height: 9px; }

.bot-role-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 500;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 999px;
    letter-spacing: 0.02em;
    text-transform: none;
    margin-left: 2px;
}

.bot-failure-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--warning);
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: var(--radius-md);
}
.bot-failure-chip button {
    background: transparent;
    border: none;
    color: var(--warning);
    font-weight: 600;
    cursor: pointer;
    padding: 0 4px;
    text-decoration: underline;
}
.bot-failure-chip button:hover { color: var(--warning-dark, #c47f00); }

.message-body { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: baseline; gap: 10px; }
.message-author { font-weight: 600; font-size: 17px; -webkit-user-select: text; user-select: text; cursor: text; }
.message-time { -webkit-user-select: text; user-select: text; }
.message-time { font-size: 13px; color: var(--text-tertiary); }
.message-content { color: var(--text); line-height: 1.55; word-wrap: break-word; letter-spacing: -0.005em; -webkit-user-select: text; user-select: text; font-size: 16px; white-space: pre-wrap; }
.message-content code {
    background: var(--surface-3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.88em;
    color: var(--accent);
    border: 1px solid var(--border);
}
.message-content pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 8px 0;
    overflow-x: auto;
    white-space: pre;
}
.message-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--text);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}
.message-content a {
    color: var(--accent);
    text-decoration: none;
    transition: text-decoration 0.15s;
}
.message-content a:hover { text-decoration: underline; }
.message-content strong { color: var(--text); font-weight: 600; }
.message-content em { font-style: italic; }
.message-content del { text-decoration: line-through; opacity: 0.7; }

/* Message hover actions */
.message-actions-bar {
    position: absolute;
    top: -12px;
    right: 8px;
    display: none;
    gap: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2px;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.message:hover .message-actions-bar { display: flex; }
.message.picker-open .message-actions-bar { display: none !important; }

.message-action-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease);
}

.message-action-btn:hover { color: var(--text); background: var(--surface-3); }
.message-action-btn.danger:hover { color: var(--danger); background: var(--danger-dim); }

.quick-react-btn {
    background: none;
    border: none;
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease);
    line-height: 1;
}
.quick-react-btn:hover { background: var(--surface-3); transform: scale(1.2); }
.actions-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 2px;
    align-self: center;
}

/* Reactions */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    border: none;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
}
.reaction-pill:active { transform: scale(0.9); }
.reaction-pill:hover { background: var(--surface-3); }
.reaction-pill.reaction-mine { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
.reaction-count { font-size: 12px; font-weight: 600; }

.reaction-pill.reaction-add {
    color: var(--text-tertiary);
    background: transparent;
    border: 1px dashed var(--border);
}
.reaction-pill.reaction-add:hover { color: var(--text-secondary); }

.reaction-picker {
    position: absolute;
    top: -40px;
    right: 8px;
    display: flex;
    gap: 2px;
    background: var(--surface-2);
    border: none;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 20;
}

.reaction-picker-btn {
    background: none;
    border: none;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}

.reaction-picker-btn:hover { background: var(--surface-3); }
.reaction-picker-container { position: relative; }
.reaction-picker-more svg { color: var(--text-tertiary); }

/* Emoji picker component */
.emoji-picker {
    width: 320px;
    max-height: 340px;
    background: var(--surface-2);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fadeIn 150ms var(--ease);
    z-index: 30;
}
.emoji-picker-search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}
.emoji-search-input {
    width: 100%;
    background: var(--surface-3);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.emoji-search-input:focus { border-color: var(--accent); }
.emoji-picker-grid {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-content: flex-start;
}
.emoji-category-label {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 4px 4px;
}
.emoji-category-label:first-child { padding-top: 0; }
.emoji-picker-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    line-height: 1;
}
.emoji-picker-item:hover { background: var(--surface-3); transform: scale(1.15); }

/* Emoji picker positioning for reactions vs input */
.reaction-picker-container .emoji-picker {
    position: absolute;
    bottom: 36px;
    right: 0;
}
.input-emoji-picker-wrapper {
    position: absolute;
    bottom: 40px;
    right: 0;
    z-index: 30;
}

/* Image lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 200ms var(--ease);
    cursor: zoom-out;
}
.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    cursor: default;
    animation: slideUp 200ms var(--ease);
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1001;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* Reply context in messages */
.reply-context {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
    border-left: 2px solid var(--accent);
    border-radius: 0 4px 4px 0;
    background: var(--accent-dim);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    max-width: 400px;
    overflow: hidden;
}
.reply-context svg { flex-shrink: 0; color: var(--accent); }
.reply-context-author { font-weight: 600; color: var(--accent); white-space: nowrap; }
.reply-context-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reply preview bar above message input */
.reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 13px;
    animation: fadeIn 150ms var(--ease);
}
.reply-preview-content {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    color: var(--text-secondary);
}
.reply-preview-content svg { flex-shrink: 0; color: var(--accent); }
.reply-preview-author { font-weight: 600; color: var(--text); white-space: nowrap; }
.reply-preview-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.reply-preview-close:hover { color: var(--text); background: var(--surface-3); }

/* Mentions */
.mention {
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 500;
}

.mention-me {
    background: var(--accent-glow);
    font-weight: 600;
}

/* Mention autocomplete dropdown */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    z-index: 20;
    margin-bottom: 4px;
}

.mention-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    text-align: left;
}

.mention-dropdown-item:hover,
.mention-dropdown-item.selected { background: var(--surface-3); }

.mention-dropdown-item .mention-handle { font-weight: 600; color: var(--text); }
.mention-dropdown-item .mention-display { color: var(--text-tertiary); font-size: 12px; }

/* Date separator */
.date-separator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0 8px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Scroll to bottom FAB */
.scroll-bottom-fab {
    position: absolute;
    bottom: 100px;
    right: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--duration) var(--ease);
    z-index: 10;
    animation: fadeIn 150ms var(--ease);
}

.scroll-bottom-fab:hover { background: var(--surface-3); color: var(--text); transform: translateY(-2px); }

/* New messages banner */
.new-messages-banner {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    animation: slideUp 200ms var(--ease);
    transition: background var(--duration) var(--ease);
    white-space: nowrap;
}
.new-messages-banner:hover { background: var(--accent-hover); }

/* Message input */
.message-input-container { position: relative; padding: 0 16px 8px; flex-shrink: 0; transition: outline 0.15s; }
.message-input-container.drag-active {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius-lg);
}

.message-input {
    display: flex; align-items: flex-end;
    background: var(--surface-2); border: 1px solid transparent;
    border-radius: var(--radius-lg); padding: 7px 8px 7px 14px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.message-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.message-input textarea {
    flex: 1; background: none; border: none;
    color: var(--text); font-family: inherit; font-size: 16px;
    resize: none; outline: none; max-height: 120px; line-height: 1.5;
    padding: 4px 0;
    -webkit-appearance: none;
    appearance: none;
}

.message-input textarea::placeholder { color: var(--text-tertiary); }

.message-toolbar { display: flex; align-items: flex-end; flex-shrink: 0; }
.message-actions { display: flex; align-items: flex-end; gap: 4px; flex-shrink: 0; }

.toolbar-btn {
    background: none; border: none; color: var(--text-tertiary);
    width: 32px; height: 32px; border-radius: var(--radius-md);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--duration) var(--ease); flex-shrink: 0;
}

.toolbar-btn:hover { color: var(--text); background: var(--surface-3); }

.format-btn { width: 28px; height: 28px; }
.format-btn:hover { color: var(--accent); }
@media (max-width: 768px) {
    .format-btn { display: none; }
}

.send-btn {
    background: var(--accent); color: white; border: none;
    width: 32px; height: 32px; border-radius: var(--radius-md);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Attachment previews */
.attachment-preview-bar {
    display: flex; gap: 8px; padding: 8px 8px 4px; overflow-x: auto;
}

.attachment-preview {
    position: relative; display: flex; align-items: center; gap: 6px;
    background: var(--surface-2); border: none;
    border-radius: var(--radius-md); padding: 6px 8px;
    font-size: 12px; color: var(--text-secondary); flex-shrink: 0;
    animation: fadeIn 150ms var(--ease);
}

.attachment-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; }

.attachment-file-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--surface-3); display: flex; align-items: center; justify-content: center;
    color: var(--text-tertiary);
}

.attachment-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attachment-remove {
    background: var(--surface-3); border: none; color: var(--text-tertiary);
    width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--duration) var(--ease);
}

.attachment-remove:hover { background: var(--danger); color: white; }

/* Message attachments display */
.message-attachments { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }

.image-attachment {
    display: inline-block; border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--duration) var(--ease);
}

.image-attachment:hover { box-shadow: var(--shadow-md); }

.image-attachment img {
    display: block; max-width: 360px; max-height: 400px;
    width: auto; height: auto;
    object-fit: contain; border-radius: var(--radius-lg);
}

.file-attachment {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface-2); border: none;
    border-radius: var(--radius-md); padding: 8px 12px;
    color: var(--accent); font-size: 13px; text-decoration: none;
    max-width: 300px; transition: all var(--duration) var(--ease);
}

.file-attachment:hover { background: var(--surface-3); }
.file-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-attachment-size { color: var(--text-tertiary); font-size: 11px; flex-shrink: 0; }

/* Typing indicator */
.typing-indicator { font-size: 13px; color: var(--text-tertiary); display: none; align-items: center; gap: 6px; padding: 2px 4px 4px; }
.typing-indicator.visible { display: flex; }

.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.2s infinite;
    display: inline-block;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 500; font-family: inherit;
    cursor: pointer; border: none;
    transition: all var(--duration) var(--ease);
    user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-icon {
    background: none; border: none; color: var(--text-tertiary);
    cursor: pointer; padding: 2px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--duration) var(--ease);
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }
.btn-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ========================================
   Forms
   ======================================== */

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.form-input {
    padding: 10px 14px; background: var(--surface-2);
    border: 1px solid transparent; border-radius: var(--radius-md);
    color: var(--text); font-size: 14px; font-family: inherit;
    outline: none;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-input::placeholder { color: var(--text-tertiary); }

.form-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input-wrapper .form-input {
    width: 100%;
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration) var(--ease);
}

.password-toggle:hover { color: var(--text-secondary); }

/* Password strength bar */
.password-strength { display: flex; gap: 4px; margin-top: 4px; }
.password-strength-segment {
    height: 3px; flex: 1; border-radius: 2px;
    background: var(--surface-3);
    transition: background var(--duration-slow) var(--ease);
}
.password-strength-segment.active-1 { background: var(--danger); }
.password-strength-segment.active-2 { background: var(--warning); }
.password-strength-segment.active-3 { background: var(--warning); }
.password-strength-segment.active-4 { background: var(--success); }

/* ========================================
   Auth Pages
   ======================================== */

.auth-layout {
    height: 100dvh;
    overflow-y: auto;
    background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.06) 0%, var(--bg) 60%);
}

.auth-container { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; }

.auth-card {
    background: var(--surface); border: none;
    border-radius: var(--radius-2xl); padding: 40px;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-xl);
    animation: slideUp var(--duration-slow) var(--ease);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: white;
}

.auth-wordmark {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.auth-card p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; text-align: center; }

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
    animation: slideDown 200ms var(--ease);
}

.error-banner {
    background: var(--danger-dim);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown 200ms var(--ease);
}

/* ========================================
   Kanban / Projects
   ======================================== */

.kanban-board { display: flex; gap: 16px; height: 100%; overflow-x: auto; padding-bottom: 16px; }

.kanban-column {
    min-width: 300px; width: 300px;
    background: var(--surface); border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    max-height: calc(100dvh - var(--header-height) - 80px);
}

.kanban-column-header {
    padding: 14px 16px; font-size: 14px; font-weight: 600;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.kanban-column-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kanban-status-dot.todo { background: var(--info); }
.kanban-status-dot.in-progress { background: var(--warning); }
.kanban-status-dot.done { background: var(--success); }

.kanban-column-count {
    background: var(--surface-3); color: var(--text-secondary);
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
}

.kanban-progress { height: 2px; background: var(--surface-3); flex-shrink: 0; }
.kanban-progress-fill { height: 100%; transition: width var(--duration-slow) var(--ease); border-radius: 1px; }

.kanban-cards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }

.task-card {
    background: var(--surface-2); border: none;
    border-radius: var(--radius-lg); padding: 14px;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    animation: cardAppear 200ms var(--ease);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.task-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.task-card.dragging { opacity: 0.6; transform: rotate(2deg) scale(1.02); box-shadow: var(--shadow-lg); }
.task-card-title { font-size: 14px; font-weight: 500; margin-bottom: 8px; line-height: 1.4; }
.task-card-description { font-size: 13px; color: var(--text-tertiary); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; }
.task-card-assignee { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); }
.task-card-age { font-size: 11px; color: var(--text-tertiary); }

/* Task priority and due dates */
.task-card-header { display: flex; align-items: flex-start; gap: 6px; }
.task-card-header .task-card-title { flex: 1; }
.task-priority-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.task-priority-dot.priority-urgent { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.task-priority-dot.priority-high { background: var(--warning); }
.task-priority-dot.priority-low { background: var(--text-tertiary); }
.task-overdue { border-color: var(--danger) !important; }
.task-overdue .task-card-title { color: var(--danger); }
.task-due-date {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-tertiary);
}
.task-due-date.overdue { color: var(--danger); font-weight: 600; }

/* Task move menu (mobile alternative to drag) */
.task-move-menu {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.task-move-option {
    flex: 1;
    padding: 8px 10px;
    background: var(--surface-3);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.task-move-option:hover { background: var(--accent-dim); color: var(--accent); }

/* Quick add input at bottom of kanban column */
.kanban-quick-add { margin-top: 4px; }
.kanban-quick-input {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: all 0.15s;
}
.kanban-quick-input::placeholder { color: var(--text-tertiary); }
.kanban-quick-input:focus {
    background: var(--surface-2);
    border-style: solid;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.kanban-cards.drag-over {
    background: var(--accent-dim);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-md);
    animation: dropPulse 1.5s infinite;
}

/* Touch drag highlight for mobile kanban */
.kanban-touch-over {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--accent-dim) !important;
}

/* Status dots */
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); display: inline-block; }

/* ========================================
   Modals
   ======================================== */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    animation: fadeInOnly 150ms var(--ease);
}

.modal {
    background: var(--surface); border: none;
    border-radius: var(--radius-2xl); padding: 28px;
    width: 90%; max-width: 480px; box-shadow: var(--shadow-xl);
    animation: slideUp 200ms var(--ease);
}

.modal h2 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* New Message Modal */
.new-message-modal { padding: 0; max-width: 440px; overflow: hidden; }
.new-message-modal h2 { margin: 0; font-size: 16px; }

.new-message-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px 12px;
}

.new-message-search {
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--border);
}

.new-message-search-input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-size: 14px; font-family: inherit;
}

.new-message-search-input::placeholder { color: var(--text-tertiary); }

.new-message-list {
    max-height: 340px; overflow-y: auto;
    padding: 4px 0;
}

.new-message-empty {
    padding: 32px 16px; text-align: center;
    color: var(--text-tertiary); font-size: 13px;
}

.new-message-person {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 16px;
    background: none; border: none; cursor: pointer;
    color: var(--text); font-family: inherit;
    transition: background var(--duration-fast) var(--ease);
}

.new-message-person:hover { background: var(--surface-2); }

.new-message-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-dim); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
}

.new-message-person-info { flex: 1; text-align: left; min-width: 0; }
.new-message-person-name { font-size: 14px; font-weight: 500; }
.new-message-you { font-size: 12px; color: var(--text-tertiary); margin-left: 4px; }

/* ========================================
   File List
   ======================================== */

.file-list-container {
    background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
}

.file-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background var(--duration) var(--ease);
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--surface); }
.file-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-meta { font-size: 12px; color: var(--text-tertiary); }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.file-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.file-delete-btn { min-width: 36px; min-height: 36px; }

/* File type icon colors */
.file-icon-image { color: var(--info); }
.file-icon-pdf { color: #ef4444; }
.file-icon-doc { color: #3b82f6; }
.file-icon-code { color: #a78bfa; }
.file-icon-archive { color: var(--warning); }
.file-icon-folder { color: var(--warning); }
.file-icon-default { color: var(--text-tertiary); }

/* Drop zone */
.drop-zone {
    position: relative;
    min-height: 200px;
}

.drop-zone-overlay {
    position: absolute;
    inset: 0;
    background: var(--accent-dim);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    animation: fadeInOnly 150ms var(--ease);
}

/* Grid view */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.file-grid-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: all var(--duration) var(--ease);
    text-align: center;
}

.file-grid-card:hover { border-color: var(--border-hover); background: var(--surface-2); transform: translateY(-2px); }
.file-grid-delete-btn {
    position: absolute; top: 8px; right: 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 6px; cursor: pointer; opacity: 0; transition: opacity var(--duration) var(--ease);
    display: flex; align-items: center; justify-content: center;
}
.file-grid-card:hover .file-grid-delete-btn { opacity: 1; }
.file-grid-delete-btn:hover { background: var(--danger); border-color: var(--danger); }
.file-grid-delete-btn:hover svg { stroke: white; }
.file-grid-icon { font-size: 32px; padding: 12px 0; }
.file-grid-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.file-grid-meta { font-size: 11px; color: var(--text-tertiary); }

/* View toggle */
.view-toggle {
    display: flex;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    padding: 2px;
    border: 1px solid var(--border);
}

.view-toggle-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease);
}

.view-toggle-btn.active { background: var(--surface-3); color: var(--text); }
.view-toggle-btn:hover:not(.active) { color: var(--text-secondary); }

.upload-progress {
    margin-top: 16px; display: flex; align-items: center; gap: 8px;
    color: var(--text-secondary); font-size: 13px;
    animation: fadeIn 150ms var(--ease);
}

/* ========================================
   Wiki
   ======================================== */

.wiki-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-2); border: 1px solid transparent;
    border-radius: var(--radius-lg); padding: 10px 14px;
    margin-bottom: 16px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.wiki-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.wiki-search-input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-size: 14px; font-family: inherit;
}
.wiki-search-input::placeholder { color: var(--text-tertiary); }

.wiki-page-list { display: flex; flex-direction: column; gap: 4px; }

.wiki-page-card {
    display: block; text-decoration: none; color: inherit;
    background: var(--surface); border: none;
    border-radius: var(--radius-md); padding: 14px 16px;
    transition: all var(--duration) var(--ease); cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.wiki-page-card:hover { background: var(--surface-2); transform: translateX(2px); box-shadow: var(--shadow-md); }

.wiki-page-card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.wiki-page-card-title { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-page-card-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wiki-page-card-editor { font-size: 12px; color: var(--text-tertiary); }
.wiki-page-card-meta { font-size: 12px; color: var(--text-tertiary); }
.wiki-page-card-snippet {
    margin-top: 6px; font-size: 13px; color: var(--text-tertiary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.4;
}

/* Wiki editor */
.wiki-editor {
    display: flex; flex-direction: column; gap: 12px;
    max-width: 760px;
}

.wiki-editor-toolbar {
    display: flex;
    gap: 2px;
    padding: 6px;
    background: var(--surface-2);
    border: none;
    border-radius: var(--radius-md);
}

.wiki-editor-toolbar .toolbar-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
    font-weight: 600;
}

.wiki-toolbar-separator {
    width: 1px;
    margin: 4px 4px;
    background: var(--border);
}

.wiki-title-input {
    padding: 8px 0; background: none; border: none; border-bottom: 2px solid var(--border);
    color: var(--text); font-size: 24px; font-weight: 700; font-family: inherit;
    outline: none; transition: border-color var(--duration) var(--ease);
}
.wiki-title-input:focus { border-color: var(--accent); }
.wiki-title-input::placeholder { color: var(--text-tertiary); }

.wiki-content-input {
    padding: 12px 0; background: none;
    border: none; border-radius: 0;
    color: var(--text-secondary); font-size: 15px; font-family: inherit;
    line-height: 1.75; resize: vertical; outline: none;
    min-height: 400px;
}
.wiki-content-input::placeholder { color: var(--text-tertiary); }

.wiki-content-preview {
    padding: 12px 0;
    min-height: 400px;
    border-top: 1px solid var(--border);
}

.wiki-editor-toolbar .toolbar-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}

/* Wiki view */
.wiki-view { max-width: 760px; }

.wiki-view-header {
    display: flex;
    gap: 24px;
}

.wiki-view-content { flex: 1; min-width: 0; }

.wiki-toc {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 16px 0;
}

.wiki-toc-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.wiki-toc-item {
    display: block;
    padding: 4px 0;
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--duration) var(--ease);
    cursor: pointer;
}

.wiki-toc-item:hover { color: var(--text-secondary); }
.wiki-toc-item.depth-1 { padding-left: 12px; }
.wiki-toc-item.depth-2 { padding-left: 24px; }

.wiki-view-meta {
    font-size: 12px; color: var(--text-tertiary);
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.wiki-empty-content {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 40px 20px; color: var(--text-tertiary); text-align: center;
}

.wiki-rendered { line-height: 1.75; color: var(--text-secondary); max-width: 680px; }
.wiki-rendered .wiki-h { color: var(--text); margin: 24px 0 8px; }
.wiki-rendered h2.wiki-h { font-size: 22px; font-weight: 700; }
.wiki-rendered h3.wiki-h { font-size: 18px; font-weight: 600; }
.wiki-rendered h4.wiki-h { font-size: 15px; font-weight: 600; }
.wiki-rendered .wiki-p { margin-bottom: 8px; }
.wiki-rendered .wiki-list { padding-left: 20px; margin-bottom: 8px; }
.wiki-rendered .wiki-list li { margin-bottom: 4px; }
.wiki-rendered strong { color: var(--text); font-weight: 600; }

.wiki-subpages { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.wiki-subpages-title {
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-tertiary); margin-bottom: 12px;
}

/* ========================================
   Loading / Empty / Skeleton
   ======================================== */

.loading-spinner { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-tertiary); gap: 10px; }

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--surface-3); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; color: var(--text-tertiary); text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.empty-state-icon::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
    z-index: -1;
}

.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 14px; max-width: 300px; }

/* Skeleton */
.skeleton {
    background: var(--surface-2);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

.skeleton-circle { border-radius: 50%; }

.skeleton-message {
    display: flex;
    gap: 12px;
    padding: 8px 4px;
}

.skeleton-message-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

.skeleton-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
}

.skeleton-card {
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ========================================
   Toast
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: none;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 200ms var(--ease);
    min-width: 280px;
    max-width: 400px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    pointer-events: all;
    backdrop-filter: blur(12px);
}

.toast-exit { animation: slideOutRight 200ms var(--ease) forwards; }

.toast-icon { flex-shrink: 0; display: flex; align-items: center; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-message { flex: 1; line-height: 1.4; }

/* ========================================
   Command Palette
   ======================================== */

.command-palette {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 18vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeInOnly 100ms var(--ease);
}

.command-palette-box {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border: none;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 150ms var(--ease);
}

.command-palette-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.command-palette-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}

.command-palette-input::placeholder { color: var(--text-tertiary); }

.command-palette-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}

.command-palette-section {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.command-palette-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease);
}

.command-palette-item:hover,
.command-palette-item.active {
    background: var(--accent-dim);
    color: var(--text);
}

.command-palette-item-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.command-palette-item.active .command-palette-item-icon { background: var(--accent-dim); color: var(--accent); }

.command-palette-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.command-palette-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.command-palette-kbd {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: inherit;
}

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

.settings-container { max-width: 640px; }

.settings-section {
    margin-bottom: 32px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.notification-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
}

.settings-avatar-picker {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.settings-avatar-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.settings-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.settings-color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.settings-color-btn:hover { transform: scale(1.15); }
.settings-color-btn.active { border-color: white; box-shadow: 0 0 0 2px var(--bg); }

.member-list {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

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

.member-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.member-name { font-weight: 500; font-size: 14px; }
.member-email { font-size: 12px; color: var(--text-tertiary); }

.role-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}

.role-badge-owner { background: var(--warning-dim); color: var(--warning); }
.role-badge-admin { background: var(--accent-dim); color: var(--accent); }
.role-badge-member { background: var(--surface-3); color: var(--text-tertiary); }

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

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

.invite-token {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-2);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* ========================================
   Project Row
   ======================================== */

.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background var(--duration) var(--ease);
    cursor: pointer;
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: var(--surface); }

.project-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* ========================================
   Chat List
   ======================================== */

.chat-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background var(--duration) var(--ease); cursor: pointer;
}
.chat-list-item:last-child { border-bottom: none; }
.chat-list-item:hover { background: var(--surface); }

.chat-list-icon {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    background: var(--surface-2); color: var(--text-tertiary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 600; flex-shrink: 0;
}

.chat-list-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-dim); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
}

/* ========================================
   Mobile
   ======================================== */

.mobile-tab-bar {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: none;
    box-shadow: 0 -1px 12px rgba(0,0,0,0.15);
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 50;
    transition: transform 0.2s ease;
}

/* Slide tab bar off-screen when keyboard is open */
.mobile-tab-bar.keyboard-open { transform: translateY(100%); }

/* Remove bottom padding from main content when keyboard is open so no dead space */
.main-content.keyboard-open {
    padding-bottom: 0 !important;
}

.mobile-tab-bar nav {
    display: flex;
    height: var(--mobile-tab-height);
    max-width: 460px;
    margin: 0 auto;
    padding: 0 4px;
}

.mobile-tab-bar a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    color: var(--text-tertiary); text-decoration: none;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em;
    transition: color var(--duration) var(--ease);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.mobile-tab-bar a svg { width: 28px; height: 28px; }
.mobile-tab-bar a:active { transform: scale(0.95); }

.mobile-tab-bar a.active { color: var(--accent); }

.mobile-tab-bar a::before {
    content: '';
    position: absolute;
    inset: 6px 8px;
    background: transparent;
    border-radius: 16px;
    transition: background 200ms var(--ease);
    z-index: -1;
}
.mobile-tab-bar a.active::before { background: var(--accent-dim); }

.tab-badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 10px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: fadeIn 200ms var(--ease);
}

.mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    text-decoration: none;
    margin-right: 4px;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-md);
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-tab-bar { display: block; }
    .main-content { padding-bottom: calc(var(--mobile-tab-height) + 14px + env(safe-area-inset-bottom)); }

    .mobile-back-btn { display: flex; }
    .header { padding: 0 12px; padding-top: env(safe-area-inset-top); gap: 8px; height: calc(var(--header-height) + env(safe-area-inset-top)); }
    .header-title { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
    .header-topic { display: none; }

    /* Messages — larger sizes for mobile */
    .message-list { padding: 8px 8px 6px; }
    .message { gap: 10px; padding: 4px 10px; -webkit-touch-callout: none; }
    .message:not(.message-compact) { margin-top: 12px; padding-top: 6px; padding-bottom: 0; }
    .message-content { -webkit-user-select: text; user-select: text; font-size: 17px; }
    .message-author { font-size: 15px; font-weight: 600; -webkit-user-select: text; user-select: text; }
    .message-time { font-size: 13px; }
    .message-avatar { width: 36px; height: 36px; font-size: 13px; }
    .message-avatar-img { width: 36px; height: 36px; }
    .message-compact { padding: 0 10px !important; }
    .message-compact .message-avatar-wrapper { width: 36px; }

    /* Message input — clean mobile style, no focus glow, vertically centred */
    .message-input-container { padding: 0 10px 0; }
    .message-input { padding: 6px 8px; align-items: center; box-shadow: none !important; border-color: transparent !important; }
    .message-input textarea { font-size: 16px; max-height: 80px; }
    .message-input:focus-within { box-shadow: none; border-color: transparent; }

    .image-attachment { max-width: 100%; }
    .image-attachment img { max-width: 100%; max-height: 280px; }
    .file-attachment { max-width: 100%; }

    .content { padding: 12px; padding-bottom: calc(12px + var(--mobile-tab-height) + env(safe-area-inset-bottom)); }

    /* Kanban — vertical stack on mobile */
    .kanban-board { padding: 12px; flex-direction: column; overflow-x: hidden; overflow-y: auto; gap: 16px; }
    .kanban-column { min-width: unset; width: 100%; max-height: none; }
    .task-card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    .kanban-column-header { font-size: 15px; padding: 14px 16px; }
    .task-card { padding: 16px; }
    .task-card-title { font-size: 15px; }
    .task-card-description { font-size: 14px; }
    .task-card-assignee { font-size: 13px; }
    .task-card-age { font-size: 12px; }
    .task-move-option { font-size: 13px; padding: 8px 10px; }

    .modal { padding: 20px; }
    .auth-card { padding: 24px; }
    .auth-container { align-items: flex-start; padding-top: 32px; }
    .empty-state { padding: 40px 16px; }

    /* File list */
    .file-item { padding: 14px 12px; }
    .file-name { font-size: 16px; }
    .file-meta { font-size: 14px; }
    .file-actions { gap: 8px; }
    .file-delete-btn { min-width: 44px; min-height: 44px; }
    .btn-icon { min-width: 44px; min-height: 44px; }

    /* Wiki */
    .wiki-page-card { padding: 14px 16px; }
    .wiki-page-card-title { font-size: 16px; }
    .wiki-page-card-right { display: none; }
    .wiki-page-card-snippet { display: none; }
    .wiki-title-input { font-size: 22px; }
    .wiki-content-input { min-height: 300px; font-size: 17px; }
    .wiki-rendered { font-size: 17px; }
    .wiki-view-meta { font-size: 12px; }
    .wiki-toc { display: none; }

    /* Buttons */
    .btn { font-size: 15px; padding: 12px 20px; }
    .btn-sm { font-size: 13px; padding: 8px 14px; }

    .toast-container { left: 12px; right: 12px; bottom: calc(var(--mobile-tab-height) + env(safe-area-inset-bottom) + 8px); }
    .toast { min-width: auto; font-size: 15px; }

    .command-palette { padding-top: calc(env(safe-area-inset-top) + 16px); padding-left: 12px; padding-right: 12px; }

    /* Hide hover action bar on mobile — use long-press context sheet instead */
    .message-actions-bar { display: none !important; }
    /* Show small inline react button on mobile */

    .scroll-bottom-fab { bottom: 80px; right: 12px; }
    .new-messages-banner { bottom: 80px; }

    /* Bottom sheet modals on mobile */
    .modal-overlay { align-items: flex-end; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
        animation: slideUpSheet 300ms var(--ease);
    }

    /* Touch targets — 44px minimum */
    .reaction-pill { min-height: 38px; padding: 8px 12px; font-size: 16px; }
    .toolbar-btn { min-width: 44px; min-height: 44px; }
    .send-btn { min-width: 44px; min-height: 44px; }
    .channel-item { min-height: 44px; font-size: 16px; }
    .tab-item { min-height: 44px; }

    /* Reaction picker — fixed, above the message input area */
    .reaction-picker {
        position: fixed;
        bottom: calc(var(--mobile-tab-height) + 8px + 56px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        top: auto;
        justify-content: center;
        padding: 10px;
        gap: 4px;
        border-radius: 16px;
        z-index: 200;
    }
    .reaction-picker-btn { font-size: 24px; padding: 8px 10px; }
    .picker-overlay { z-index: 199; }

    /* Emoji picker fills mobile */
    .emoji-picker { width: 100%; max-height: 50vh; }
    .input-emoji-picker-wrapper { position: fixed; bottom: calc(var(--mobile-tab-height) + 8px + 56px + env(safe-area-inset-bottom)); left: 8px; right: 8px; z-index: 201; }
    .input-emoji-picker-wrapper .emoji-picker { border-radius: 16px 16px 0 0; }

    /* Form inputs need 16px to prevent iOS zoom */
    .form-input { font-size: 16px; }
    .form-label { font-size: 15px; }

    /* Typing indicator */
    .typing-indicator { font-size: 14px; }

    /* Date separator */
    .date-separator { font-size: 13px; }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
    .modal { padding: 16px; }
    .header-title { max-width: 50vw; font-size: 16px; }
    .btn { padding: 10px 16px; }
}


/* ========================================
   Blazor / Misc
   ======================================== */

.loading-progress { display: none; }
#blazor-error-ui { display: none; background: var(--danger); color: white; padding: 8px; text-align: center; }

/* Inline edit for messages */
.message-edit-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 6px 10px;
    outline: none;
    resize: none;
    line-height: 1.5;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.message-edit-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Breadcrumb links */
.breadcrumb-link {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    transition: color var(--duration) var(--ease);
}

.breadcrumb-link:hover { color: var(--text-secondary); }
.breadcrumb-separator { color: var(--text-tertiary); font-size: 13px; }

/* Context sheet (mobile long-press menu) */
.context-sheet-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    animation: fadeIn 150ms var(--ease);
}
.context-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface-2);
    border-radius: 16px 16px 0 0;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    animation: slideUpSheet 300ms var(--ease);
    z-index: 101;
}
.context-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    margin: 0 auto 12px;
}
.context-sheet-preview {
    padding: 10px 12px;
    background: var(--surface-1);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 13px;
    display: flex;
    gap: 8px;
    align-items: baseline;
    overflow: hidden;
}
.context-sheet-author { font-weight: 600; color: var(--text); white-space: nowrap; }
.context-sheet-text { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-sheet-actions { display: flex; flex-direction: column; gap: 2px; }
.context-sheet-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 17px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}
.context-sheet-btn:hover, .context-sheet-btn:active { background: var(--surface-3); }
.context-sheet-danger { color: var(--danger); }

/* Keyboard open adjustments (iOS Safari) */
body.keyboard-open .mobile-tab-bar { display: none; }
body.keyboard-open .main-content { padding-bottom: 0 !important; }

/* PWA standalone mode — no browser chrome, use full safe area */
@media (display-mode: standalone) {
    body { background-color: var(--surface); } /* Matches tab bar — eliminates black strip */
}

/* ========================================
   Thread Panel
   ======================================== */

.thread-panel {
    width: 400px;
    max-width: 100vw;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    animation: slideInRight 200ms var(--ease);
    box-shadow: var(--shadow-xl);
}

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

.thread-panel-title { font-size: 15px; font-weight: 600; }
.thread-panel-channel {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: 8px;
    font-weight: 400;
}

.thread-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
}

.thread-parent {
    display: flex;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.thread-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.thread-divider::before,
.thread-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.thread-reply { padding: 6px 8px; }

.thread-panel-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
}
.thread-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.also-send-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.also-send-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.thread-panel-input textarea,
.thread-input-row textarea {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    padding: 8px 12px;
    outline: none;
    resize: none;
    -webkit-appearance: none;
    appearance: none;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color var(--duration) var(--ease);
}

.thread-panel-input textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Thread reply count on messages */
.thread-reply-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-top: 4px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast);
}

.thread-reply-count:hover { background: var(--accent-dim); }

.thread-reply-avatars {
    display: flex;
    align-items: center;
}

.thread-reply-avatars > * {
    margin-left: -4px;
    border: 2px solid var(--bg);
    border-radius: 50%;
}

.thread-reply-avatars > *:first-child { margin-left: 0; }

.thread-reply-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    background: var(--accent-dim);
}

/* ========================================
   In-Channel Search
   ======================================== */

.channel-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    animation: slideDown 150ms var(--ease);
}

.channel-search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.channel-search-input::placeholder { color: var(--text-tertiary); }

.channel-search-results {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 20;
    animation: fadeIn 100ms var(--ease);
}

.channel-search-result {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--duration-fast);
    color: var(--text);
    font-family: inherit;
}

.channel-search-result:hover { background: var(--surface-3); }
.channel-search-result:last-child { border-bottom: none; }

.channel-search-result-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.channel-search-result-author { font-weight: 600; font-size: 13px; }
.channel-search-result-time { font-size: 11px; color: var(--text-tertiary); }
.channel-search-result-content {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-search-result-content mark,
.command-palette-item mark {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 2px;
}

/* Message highlight (after search result click) */
.message-highlighted {
    animation: highlightPulse 2s var(--ease);
}

@keyframes highlightPulse {
    0% { background: var(--accent-dim); }
    100% { background: transparent; }
}

/* ========================================
   Light Theme
   ======================================== */

[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f8f9fa;
    --surface-1: #f1f3f5;
    --surface-2: #e9ecef;
    --surface-3: #dee2e6;
    --text: #1a1a1a;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-tertiary: rgba(0, 0, 0, 0.4);
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
    --surface-glass: rgba(248, 249, 250, 0.9);
    --accent-dim: rgba(99, 102, 241, 0.1);
    --accent-glow: rgba(99, 102, 241, 0.2);
    --danger-dim: rgba(239, 68, 68, 0.1);
    --success-dim: rgba(34, 197, 94, 0.1);
    --warning-dim: rgba(245, 158, 11, 0.1);
    --info-dim: rgba(59, 130, 246, 0.1);
    --accent-light: #a5b4fc;
}

[data-theme="light"] body { color: var(--text); }
[data-theme="light"] ::selection { background: var(--accent); color: white; }

[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, var(--surface) 0%, #f1f3f5 100%);
}

[data-theme="light"] .sidebar-logo { color: white; }
[data-theme="light"] .message-avatar { color: white; }
[data-theme="light"] .send-btn { color: white; }
[data-theme="light"] .btn-primary { color: white; }
[data-theme="light"] .unread-badge { color: white; }

/* ========================================
   Sidebar Themes
   ======================================== */

/* Shared sidebar theme text rules — scope to specific elements, NOT * */
[data-sidebar-theme="navy"] .sidebar { background: linear-gradient(180deg, #1e3a5f 0%, #152238 100%); }
[data-sidebar-theme="charcoal"] .sidebar { background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%); }
[data-sidebar-theme="ocean"] .sidebar { background: linear-gradient(180deg, #0e4da4 0%, #083060 100%); }
[data-sidebar-theme="forest"] .sidebar { background: linear-gradient(180deg, #1a4d2e 0%, #0f2d1a 100%); }
[data-sidebar-theme="plum"] .sidebar { background: linear-gradient(180deg, #5b2d6e 0%, #371845 100%); }
[data-sidebar-theme="midnight"] .sidebar { background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%); }
[data-sidebar-theme="slate"] .sidebar { background: linear-gradient(180deg, #3d4f5f 0%, #263240 100%); }
[data-sidebar-theme="wine"] .sidebar { background: linear-gradient(180deg, #5c1a2a 0%, #3a0f1a 100%); }
[data-sidebar-theme="ember"] .sidebar { background: linear-gradient(180deg, #6b3410 0%, #3d1e08 100%); }

/* Shared text rules for all custom sidebar themes */
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-brand h1,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-nav a,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-section-header,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .channel-item,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-footer-name,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-footer-role { color: rgba(255,255,255,0.85); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-nav a.active { background: rgba(255,255,255,0.15); color: white; }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-nav a.active::before { background: white; }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: white; }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-search-btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-search-btn:hover { background: rgba(255,255,255,0.15); color: white; }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-header { border-color: rgba(255,255,255,0.12); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .channel-item.active { background: rgba(255,255,255,0.15); }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .channel-item:hover { background: rgba(255,255,255,0.08); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-search-kbd { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.6); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-section-chevron { color: rgba(255,255,255,0.5); }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-section-header span { color: rgba(255,255,255,0.5); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .channel-name,
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .channel-prefix { color: rgba(255,255,255,0.7); }

[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar .btn-icon { color: rgba(255,255,255,0.6); }
[data-sidebar-theme]:not([data-sidebar-theme="default"]) .sidebar-footer { border-color: rgba(255,255,255,0.12); }

/* Status picker stays on main theme colors regardless of sidebar theme */
[data-sidebar-theme] .status-picker { background: var(--surface-2); border-color: var(--border); }
[data-sidebar-theme] .status-picker-header { color: var(--text-tertiary); }
[data-sidebar-theme] .status-preset { color: var(--text); }
[data-sidebar-theme] .status-preset:hover { background: var(--surface-3); }
[data-sidebar-theme] .status-clear { color: var(--text-secondary); border-color: var(--border); }
[data-sidebar-theme] .status-clear:hover { color: var(--text); background: var(--surface-3); }

/* ========================================
   Message Density
   ======================================== */

[data-density="compact"] .message { padding: 2px 8px; }
[data-density="compact"] .message-compact { padding: 0 8px; }
[data-density="compact"] .message-avatar,
[data-density="compact"] .message-avatar-img { width: 24px; height: 24px; font-size: 10px; }
[data-density="compact"] .message-content { font-size: 14px; }
[data-density="compact"] .message-list { gap: 0; }
[data-density="compact"] .message:not(.message-compact) { margin-top: 4px; padding-bottom: 0; }
[data-density="compact"] .message:not(.message-compact).has-reactions { padding-bottom: 4px; }
[data-density="compact"] .message-compact .message-avatar-wrapper { width: 24px; }

[data-density="cozy"] .message { padding: 12px 18px; }
[data-density="cozy"] .message-compact { padding: 2px 18px; }
[data-density="cozy"] .message-list { gap: 4px; }
[data-density="cozy"] .message-avatar,
[data-density="cozy"] .message-avatar-img { width: 48px; height: 48px; }
[data-density="cozy"] .message:not(.message-compact) { margin-top: 12px; padding-bottom: 0; }
[data-density="cozy"] .message:not(.message-compact).has-reactions { padding-bottom: 4px; }
[data-density="cozy"] .message-compact .message-avatar-wrapper { width: 48px; }

/* ========================================
   Emoji Picker Improvements
   ======================================== */

.emoji-picker-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.emoji-picker-tabs::-webkit-scrollbar { display: none; }

.emoji-picker-tab {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    flex-shrink: 0;
    position: relative;
}

.emoji-picker-tab:hover { background: var(--surface-3); }
.emoji-picker-tab.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 4px;
    right: 4px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.emoji-picker-footer {
    height: 40px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

.emoji-picker-footer-emoji { font-size: 28px; line-height: 1; }
.emoji-picker-footer-name { font-weight: 500; }

.emoji-picker--fixed {
    position: fixed;
    z-index: 50;
}

/* Mobile inline react button — hidden on desktop, shown on mobile */
.picker-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 29;
}

/* Command palette improvements */
.command-palette-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 16px 8px;
}

.command-palette-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    border: none;
}

.command-palette-chip-remove {
    display: flex;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
}

.command-palette-chip-remove:hover { opacity: 1; }

.command-palette-recent-clear {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    float: right;
}

.command-palette-recent-clear:hover { color: var(--text-secondary); }

.command-palette-tip {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
}

/* Theme transition */
body,
.sidebar,
.header,
.main-content,
.message,
.thread-panel {
    transition: background-color 200ms ease, color 200ms ease;
}

/* ========================================
   Appearance Settings
   ======================================== */

.theme-toggle-group {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    padding: 3px;
    border: 1px solid var(--border);
}

.theme-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.theme-toggle-btn:hover { color: var(--text); }
.theme-toggle-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-sm);
}

.sidebar-theme-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sidebar-theme-swatch {
    width: 48px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.sidebar-theme-swatch:hover { transform: scale(1.08); }
.sidebar-theme-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.density-options {
    display: flex;
    gap: 8px;
}

.density-option {
    flex: 1;
    padding: 12px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.density-option:hover { border-color: var(--text-tertiary); color: var(--text); }
.density-option.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ========================================
   Wiki Tree
   ======================================== */

.wiki-tree {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wiki-tree-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    position: relative;
    border-radius: var(--radius-md);
    transition: background var(--duration-fast);
}

.wiki-tree-node:hover { background: var(--surface); }

.wiki-tree-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.wiki-tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
}

.wiki-tree-toggle:hover { background: var(--surface-3); color: var(--text); }
.wiki-tree-toggle svg { transition: transform 0.15s; }
.wiki-tree-toggle svg.collapsed { transform: rotate(-90deg); }

.wiki-node-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.wiki-node-folder { color: var(--accent); }

.wiki-tree-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
    padding: 2px 0;
}

.wiki-tree-title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wiki-tree-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* Mobile thread panel */
@media (max-width: 768px) {
    .thread-panel {
        width: 100vw;
        left: 0;
        bottom: 0;
        z-index: 60; /* Above tab bar (z-index 50) */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .thread-panel-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

    .thread-panel-input {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    /* Ensure thread textarea never triggers iOS auto-zoom */
    .thread-panel-input textarea,
    .thread-input-row textarea {
        font-size: 16px;
    }

    .channel-search-results {
        max-height: 50vh;
    }
}

/* ========================================
   PWA Update Banner
   ======================================== */

#pwa-update-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--accent, #6366f1);
    color: white;
    border-radius: var(--radius-lg, 8px);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: slideUp 0.3s var(--ease);
}

#pwa-update-banner button:first-of-type {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

#pwa-update-banner button:first-of-type:hover {
    background: rgba(255,255,255,0.3);
}

/* ========================================
   Font Size Scaling
   ======================================== */

[data-font-size="small"] { font-size: 14px; }
[data-font-size="default"] { font-size: 16px; }
[data-font-size="large"] { font-size: 18px; }
[data-font-size="larger"] { font-size: 20px; }

[data-font-size="small"] .message-content { font-size: 14px; }
[data-font-size="large"] .message-content { font-size: 18px; }
[data-font-size="larger"] .message-content { font-size: 20px; }

[data-font-size="small"] .message-author { font-size: 14px; }
[data-font-size="large"] .message-author { font-size: 18px; }
[data-font-size="larger"] .message-author { font-size: 20px; }

[data-font-size="small"] .sidebar-nav a { font-size: 13px; }
[data-font-size="large"] .sidebar-nav a,
[data-font-size="larger"] .sidebar-nav a { font-size: 16px; }

[data-font-size="small"] .channel-name { font-size: 13px; }
[data-font-size="large"] .channel-name,
[data-font-size="larger"] .channel-name { font-size: 16px; }

[data-font-size="small"] .message-input textarea { font-size: 14px; }
[data-font-size="large"] .message-input textarea { font-size: 18px; }
[data-font-size="larger"] .message-input textarea { font-size: 20px; }

[data-font-size="small"] .header-title { font-size: 15px; }
[data-font-size="large"] .header-title { font-size: 19px; }
[data-font-size="larger"] .header-title { font-size: 21px; }

[data-font-size="small"] .form-input { font-size: 14px; }
[data-font-size="large"] .form-input { font-size: 18px; }
[data-font-size="larger"] .form-input { font-size: 20px; }

[data-font-size="small"] .date-separator span { font-size: 11px; }
[data-font-size="large"] .date-separator span { font-size: 14px; }
[data-font-size="larger"] .date-separator span { font-size: 15px; }

[data-font-size="small"] .chat-list-item { font-size: 14px; }
[data-font-size="large"] .chat-list-item { font-size: 17px; }
[data-font-size="larger"] .chat-list-item { font-size: 19px; }

[data-font-size="small"] .typing-indicator { font-size: 12px; }
[data-font-size="large"] .typing-indicator { font-size: 15px; }
[data-font-size="larger"] .typing-indicator { font-size: 16px; }

/* ========================================
   Unread Alert Banner
   ======================================== */

.unread-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--duration) var(--ease);
    flex-shrink: 0;
    animation: slideDown 200ms var(--ease);
}
.unread-alert:hover { background: var(--accent-hover); }
.unread-alert span { flex: 1; }

.catchup-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--duration) var(--ease);
    flex-shrink: 0;
    animation: slideDown 200ms var(--ease);
}
.catchup-banner:hover { background: var(--surface-3); }
.catchup-banner svg:first-child { color: var(--accent); flex-shrink: 0; }
.catchup-banner span { flex: 1; }
.catchup-dismiss {
    background: none; border: none; color: var(--text-tertiary); cursor: pointer;
    padding: 2px; border-radius: var(--radius-sm); display: flex;
}
.catchup-dismiss:hover { color: var(--text); background: var(--surface-3); }

@media (max-width: 768px) {
    .unread-alert { padding: 10px 16px; font-size: 14px; }
    .catchup-banner { padding: 10px 16px; }
}

/* ========================================
   Interactive Press States & Polish
   ======================================== */

.channel-item:active { background: var(--surface-3); transform: scale(0.98); }
.sidebar-nav a:active, .sidebar-nav button:active { transform: scale(0.98); }
.btn:active { transform: scale(0.97); }
.context-sheet-btn:active { background: var(--surface-3); }

/* Scroll-to-bottom FAB smooth transition */
.scroll-bottom-fab {
    transition: transform 200ms var(--ease), opacity 200ms var(--ease);
}

/* Focus-visible states for accessibility */
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Custom-styled textarea containers handle their own focus ring — suppress the native one */
.message-input textarea:focus-visible,
.thread-input-row textarea:focus-visible,
.thread-panel-input textarea:focus-visible,
.message-edit-input:focus-visible {
    outline: none;
}

/* Connection status indicator */
.connection-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 300ms var(--ease);
}
.connection-indicator.connected { background: var(--success); }
.connection-indicator.reconnecting { background: var(--warning); animation: pulse 1.5s infinite; }
.connection-indicator.disconnected { background: var(--danger); }

/* Notification enable prompt */
.notification-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: var(--info-dim);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    font-size: 13px;
    color: var(--text);
    flex-shrink: 0;
    animation: slideDown 200ms var(--ease);
}
.notification-prompt-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--info);
}
@media (max-width: 768px) {
    .notification-prompt { padding: 10px 12px; font-size: 14px; }
}

/* ========================================
   Calendar
   ======================================== */

.cal-content { padding: 0 !important; display: flex; flex-direction: column; height: 100%; }
.cal-toolbar {
    display: flex; align-items: center; gap: 8px; padding: 12px 20px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cal-period-label { font-size: 16px; font-weight: 600; margin: 0; white-space: nowrap; }
.cal-view-toggle {
    display: flex; background: var(--surface-2); border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border);
}
.cal-view-toggle button {
    padding: 4px 12px; font-size: 12px; font-weight: 500; background: none; border: none;
    color: var(--text-secondary); cursor: pointer; transition: all var(--duration) var(--ease);
}
.cal-view-toggle button.active { background: var(--accent); color: white; }
.cal-view-toggle button:hover:not(.active) { color: var(--text); }

/* Month view */
.cal-month { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.cal-month-header {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cal-month-day-name {
    padding: 6px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-tertiary); text-align: center; letter-spacing: 0.05em;
}
.cal-month-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr);
    flex: 1; overflow: hidden;
}
.cal-month-cell {
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
    padding: 4px; min-height: 0; overflow: hidden; cursor: pointer;
    transition: background var(--duration-fast);
}
.cal-month-cell:nth-child(7n) { border-right: none; }
.cal-month-cell:hover { background: var(--surface-2); }
.cal-month-cell.other-month { opacity: 0.4; }
.cal-month-cell.today { background: var(--accent-dim); }
.cal-month-date {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; font-size: 12px; font-weight: 500;
    color: var(--text-secondary); border-radius: 50%; margin-bottom: 2px;
}
.cal-month-date.today-badge { background: var(--accent); color: white; font-weight: 600; }

.cal-event-pill {
    font-size: 11px; padding: 1px 6px; border-radius: var(--radius-sm);
    background: var(--accent-dim); color: var(--accent-light); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 1px; transition: background var(--duration-fast);
    line-height: 1.4;
}
.cal-event-pill:hover { background: var(--accent-glow); }
.cal-event-time { font-weight: 600; margin-right: 4px; }
.cal-event-more { font-size: 10px; color: var(--text-tertiary); padding: 0 6px; }

/* Week view */
.cal-week { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.cal-week-header {
    display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cal-week-day-header {
    flex: 1; text-align: center; padding: 6px 4px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.cal-week-day-header.today { background: var(--accent-dim); }
.cal-week-day-name { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-tertiary); letter-spacing: 0.05em; }
.cal-week-day-num {
    font-size: 18px; font-weight: 600; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.cal-week-day-num.today-badge { background: var(--accent); color: white; }

.cal-week-body {
    flex: 1; display: flex; overflow-y: auto; position: relative;
}
.cal-week-gutter {
    width: 52px; flex-shrink: 0; border-right: 1px solid var(--border);
}
.cal-hour-label {
    height: 48px; font-size: 11px; color: var(--text-tertiary);
    padding: 0 8px; display: flex; align-items: flex-start; justify-content: flex-end;
    transform: translateY(-6px);
}
.cal-week-column {
    flex: 1; position: relative; border-right: 1px solid var(--border);
}
.cal-week-column:last-child { border-right: none; }
.cal-week-column.today { background: var(--accent-dim); }
.cal-hour-slot {
    height: 48px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.cal-hour-slot:hover { background: rgba(255,255,255,0.03); }

.cal-week-event {
    position: absolute; left: 2px; right: 2px; padding: 2px 6px;
    background: var(--accent); color: white; border-radius: var(--radius-sm);
    font-size: 11px; overflow: hidden; cursor: pointer; z-index: 1;
    display: flex; flex-direction: column; gap: 1px;
    transition: opacity var(--duration-fast);
}
.cal-week-event:hover { opacity: 0.9; }
.cal-week-event-time { font-weight: 600; font-size: 10px; }

/* Day view */
.cal-day { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.cal-day-header {
    padding: 12px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cal-day-label { font-size: 16px; font-weight: 600; }
.cal-day-allday { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.cal-day-body { flex: 1; display: flex; overflow-y: auto; }
.cal-day-column { flex: 1; position: relative; }

/* Calendar modal */
.cal-modal { max-width: 480px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.cal-toggle {
    position: relative; display: inline-block; width: 40px; height: 22px;
}
.cal-toggle input { opacity: 0; width: 0; height: 0; }
.cal-toggle-slider {
    position: absolute; cursor: pointer; inset: 0; background: var(--surface-3);
    border-radius: 11px; transition: background var(--duration);
}
.cal-toggle-slider::before {
    content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: transform var(--duration);
}
.cal-toggle input:checked + .cal-toggle-slider { background: var(--accent); }
.cal-toggle input:checked + .cal-toggle-slider::before { transform: translateX(18px); }

/* Detail modal */
.cal-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cal-detail-header h2 { margin: 0; }
.cal-detail-info { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.cal-detail-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.cal-detail-description { font-size: 14px; color: var(--text-secondary); padding: 8px 0; line-height: 1.6; }
.cal-detail-section { margin: 16px 0; }
.cal-detail-section h3 { font-size: 13px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.cal-attendee-list { display: flex; flex-direction: column; gap: 6px; }
.cal-attendee { display: flex; align-items: center; gap: 8px; }
.cal-attendee-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3);
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
    overflow: hidden; flex-shrink: 0;
}
.cal-attendee-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cal-attendee-name { font-size: 14px; flex: 1; }
.cal-attendee-status { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-sm); }
.cal-rsvp-accepted { background: var(--success-dim); color: var(--success); }
.cal-rsvp-declined { background: var(--danger-dim); color: var(--danger); }
.cal-rsvp-tentative { background: var(--warning-dim); color: var(--warning); }
.cal-rsvp-pending { background: var(--surface-3); color: var(--text-tertiary); }
.cal-rsvp-actions {
    display: flex; align-items: center; gap: 8px; padding: 12px 0;
    border-top: 1px solid var(--border); margin-top: 12px;
}
.cal-rsvp-label { font-size: 13px; color: var(--text-tertiary); margin-right: 4px; }

@media (max-width: 768px) {
    .cal-toolbar { padding: 8px 12px; }
    .cal-view-toggle button { padding: 4px 8px; font-size: 11px; }
    .cal-period-label { font-size: 14px; }
    .cal-week-gutter { width: 40px; }
    .cal-hour-label { font-size: 10px; padding: 0 4px; }
    .form-row { flex-direction: column; }
    .cal-modal { max-width: 100%; }
}

/* ========================================
   AI Assistant
   ======================================== */

.ai-layout { display: flex; height: calc(100% - var(--header-height)); overflow: hidden; }
.ai-sidebar {
    width: 240px; flex-shrink: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}
.ai-sidebar-header {
    padding: 12px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-tertiary); border-bottom: 1px solid var(--border);
}
.ai-conversation-list { overflow-y: auto; flex: 1; }
.ai-conversation-item {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer;
    transition: background var(--duration-fast); position: relative;
}
.ai-conversation-item:hover { background: var(--surface-2); }
.ai-conversation-item.active { background: var(--accent-dim); }
.ai-conversation-title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-conversation-date { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.ai-delete-btn {
    opacity: 0; background: none; border: none; color: var(--text-tertiary); cursor: pointer;
    padding: 2px; border-radius: var(--radius-sm); transition: all var(--duration-fast);
}
.ai-conversation-item:hover .ai-delete-btn { opacity: 1; }
.ai-delete-btn:hover { color: var(--danger); }
.ai-empty-sidebar { padding: 20px 16px; font-size: 13px; color: var(--text-tertiary); text-align: center; }

.ai-chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Welcome */
.ai-welcome {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 40px 20px; text-align: center;
}
.ai-welcome-icon {
    width: 56px; height: 56px; border-radius: 50%; background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center;
}
.ai-welcome h2 { font-size: 20px; font-weight: 600; margin: 0; }
.ai-welcome p { font-size: 14px; color: var(--text-secondary); max-width: 400px; }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; justify-content: center; }
.ai-suggestion {
    padding: 8px 14px; font-size: 13px; border-radius: var(--radius-lg); background: var(--surface-2);
    border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer;
    transition: all var(--duration-fast);
}
.ai-suggestion:hover { background: var(--surface-3); color: var(--text); border-color: var(--accent); }

/* Messages */
.ai-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.ai-message { display: flex; gap: 10px; max-width: 85%; animation: fadeIn 200ms var(--ease); }
.ai-message.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-message.assistant { align-self: flex-start; }
.ai-message-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--accent-dim);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: var(--accent);
}
.ai-message-content { display: flex; flex-direction: column; gap: 4px; }
.ai-message-text {
    padding: 10px 14px; border-radius: var(--radius-lg); font-size: 14px; line-height: 1.6;
}
.ai-message.user .ai-message-text { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.ai-message.assistant .ai-message-text { background: var(--surface-2); border-bottom-left-radius: 4px; }
.ai-message-text pre { background: var(--surface-3); padding: 8px 12px; border-radius: var(--radius-md); overflow-x: auto; margin: 8px 0; font-size: 13px; }
.ai-message-text code { background: var(--surface-3); padding: 1px 5px; border-radius: 3px; font-size: 13px; }
.ai-message-text pre code { background: none; padding: 0; }
.ai-message-time { font-size: 11px; color: var(--text-tertiary); padding: 0 4px; }
.ai-message.user .ai-message-time { text-align: right; }

/* Typing indicator */
.ai-typing-indicator { display: flex; gap: 4px; padding: 12px 14px; }
.ai-typing-indicator span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary);
    animation: aiBounce 1.4s infinite ease-in-out;
}
.ai-typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aiBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Tool actions */
.ai-tool-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px; }
.ai-tool-chip {
    display: flex; align-items: center; gap: 4px; padding: 4px 10px; font-size: 11px;
    border-radius: var(--radius-md); font-weight: 500;
}
.ai-tool-chip.success { background: var(--success-dim); color: var(--success); }
.ai-tool-chip.error { background: var(--danger-dim); color: var(--danger); }

/* Input area */
.ai-input-area { padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ai-composer { display: flex; align-items: flex-end; gap: 8px; }
.ai-input {
    flex: 1; padding: 10px 14px; font-size: 14px; border-radius: var(--radius-lg);
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    resize: none; font-family: inherit; line-height: 1.5; min-height: 42px; max-height: 120px;
}
.ai-input:focus { outline: none; border-color: var(--accent); }
.ai-send-btn { padding: 10px; border-radius: var(--radius-lg); min-width: 42px; height: 42px; }
.ai-setup-prompt {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 12px; background: var(--surface-2); border-radius: var(--radius-lg);
    font-size: 14px; color: var(--text-secondary);
}

/* Settings */
.settings-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; max-width: 600px;
}
.settings-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.settings-description { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.settings-actions { margin-top: 16px; display: flex; gap: 8px; }
.settings-info-grid { display: flex; flex-direction: column; gap: 12px; }
.settings-info-item { display: flex; flex-direction: column; gap: 2px; }
.settings-info-label { font-size: 13px; font-weight: 600; }
.settings-info-value { font-size: 13px; color: var(--text-secondary); }
.form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

@media (max-width: 768px) {
    .ai-sidebar { display: none; }
    .ai-messages { padding: 12px; }
    .ai-input-area { padding: 8px 12px; }
    .ai-message { max-width: 95%; }
}

/* ========================================
   Repositories
   ======================================== */

.repo-list { display: flex; flex-direction: column; gap: 8px; }
.repo-item {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    padding: 12px; background: var(--surface-2); border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.repo-info { flex: 1; min-width: 0; }
.repo-name { font-size: 14px; font-weight: 600; }
.repo-path { font-size: 12px; color: var(--text-tertiary); font-family: monospace; margin-top: 2px; }
.repo-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.repo-analyzed { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.repo-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.repo-docs { display: flex; gap: 4px; flex-wrap: wrap; }
.repo-doc-link {
    font-size: 11px; padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--accent-dim); color: var(--accent-light); text-decoration: none;
}
.repo-doc-link:hover { background: var(--accent-glow); }

/* ========================================
   Video Calls
   ======================================== */

/* Incoming call toast */
.call-toast {
    position: fixed; top: 16px; right: 16px; z-index: 10000;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-xl); animation: slideDown 300ms var(--ease);
    min-width: 300px;
}
.call-toast-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.call-toast-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3);
    display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600;
    overflow: hidden; flex-shrink: 0;
}
.call-toast-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-toast-name { font-size: 14px; font-weight: 600; }
.call-toast-label { font-size: 12px; color: var(--text-tertiary); }
.call-toast-actions { display: flex; gap: 8px; }
.call-btn {
    width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--duration);
}
.call-btn-accept { background: var(--success); color: white; }
.call-btn-accept:hover { background: #16a34a; }
.call-btn-reject { background: var(--danger); color: white; }
.call-btn-reject:hover { background: var(--danger-hover); }

/* Active call overlay — compact (PIP) mode */
.call-overlay {
    position: fixed; bottom: 16px; right: 16px; z-index: 9999;
    width: 360px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); overflow: hidden;
    animation: slideUp 300ms var(--ease);
    transition: all 300ms var(--ease);
}
/* Expanded mode */
.call-overlay.call-expanded {
    width: calc(100vw - 80px); height: calc(100vh - 80px);
    top: 40px; left: 40px; right: 40px; bottom: 40px;
    border-radius: var(--radius-xl);
}
.call-video-area {
    position: relative; width: 100%; height: 240px; background: #111; overflow: hidden;
}
.call-expanded .call-video-area {
    height: calc(100% - 60px); /* leave room for controls */
}
/* Solo call — local video fills the area */
.call-local-video-main {
    width: 100%; height: 100%; object-fit: cover; background: #111;
    transform: scaleX(-1); /* mirror so it feels natural */
}
/* PIP local video when remote peers are present */
.call-local-video-pip {
    position: absolute; bottom: 12px; right: 12px;
    width: 120px; height: 90px; border-radius: var(--radius-md);
    object-fit: cover; border: 2px solid rgba(255,255,255,0.2);
    background: #111; z-index: 2; transform: scaleX(-1);
}
.call-expanded .call-local-video-pip {
    width: 200px; height: 150px; bottom: 16px; right: 16px;
}
/* Grid for remote videos */
.call-video-grid {
    width: 100%; height: 100%; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4px;
}
.call-grid-video {
    width: 100%; height: 100%; object-fit: cover; background: #111;
}
/* Solo label overlay */
.call-solo-label {
    position: absolute; bottom: 16px; left: 16px;
    display: flex; flex-direction: column; gap: 2px; z-index: 2;
}
.call-solo-label span {
    color: rgba(255,255,255,0.9); font-size: 13px; font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.call-solo-waiting {
    color: rgba(255,255,255,0.6) !important; font-size: 12px !important; font-weight: 400 !important;
}

.call-controls {
    display: flex; justify-content: center; gap: 12px; padding: 10px;
    background: var(--surface);
}
.call-expanded .call-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 16px;
}
.call-control-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--surface-2); color: var(--text); display: flex;
    align-items: center; justify-content: center; transition: all var(--duration);
}
.call-expanded .call-control-btn {
    background: rgba(255,255,255,0.15); color: white;
    backdrop-filter: blur(8px);
}
.call-control-btn:hover { background: var(--surface-3); }
.call-expanded .call-control-btn:hover { background: rgba(255,255,255,0.25); }
.call-control-btn.active { background: var(--warning-dim); color: var(--warning); }
.call-expanded .call-control-btn.active { background: rgba(234,179,8,0.3); color: #facc15; }
.call-btn-hangup { background: var(--danger) !important; color: white !important; }
.call-btn-hangup:hover { background: var(--danger-hover) !important; }

.call-participants-bar {
    display: flex; gap: 4px; padding: 8px 12px;
    justify-content: center;
}
.call-expanded .call-participants-bar {
    position: absolute; top: 12px; left: 12px; right: 12px;
    justify-content: flex-start; z-index: 2;
}
.call-participant-chip {
    width: 28px; height: 28px; border-radius: 50%; background: var(--accent-dim);
    color: var(--accent); display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.call-expanded .call-participant-chip {
    background: rgba(255,255,255,0.15); color: white;
    backdrop-filter: blur(8px);
}

/* Screen sharing — border around viewport */
.screen-share-border {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    border: 3px solid var(--accent); border-radius: 0;
    z-index: 10001; pointer-events: none;
    animation: screenSharePulse 2s ease-in-out infinite;
}
@keyframes screenSharePulse {
    0%, 100% { border-color: var(--accent); }
    50% { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
}
.screen-share-indicator {
    position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
    z-index: 10002; display: flex; align-items: center; gap: 8px;
    background: var(--danger); color: white; padding: 6px 12px 6px 10px;
    border-radius: var(--radius-full); font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-lg); animation: shareIndicatorIn 300ms var(--ease);
}
@keyframes shareIndicatorIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.screen-share-stop-btn {
    background: rgba(255,255,255,0.2); color: white; border: none;
    padding: 2px 10px; border-radius: var(--radius-full); font-size: 12px;
    font-weight: 600; cursor: pointer; transition: background var(--duration);
}
.screen-share-stop-btn:hover { background: rgba(255,255,255,0.35); }

/* Screen sharing mode — call overlay becomes compact thumbnail strip */
.call-overlay.call-screen-sharing {
    width: auto; min-width: 0; bottom: 16px; right: 16px;
    background: transparent; border: none; box-shadow: none;
}
.call-overlay.call-screen-sharing.call-expanded {
    width: auto; height: auto; top: auto; left: auto;
    background: transparent; border: none;
}
.call-screen-sharing .call-video-area {
    height: auto; background: transparent;
}
.call-screenshare-thumbs {
    display: flex; gap: 8px; padding: 4px;
}
.call-thumb-video {
    width: 120px; height: 90px; border-radius: var(--radius-md);
    object-fit: cover; background: #111;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: var(--shadow-lg);
}
.call-thumb-video:first-child {
    transform: scaleX(-1); /* mirror local video */
}
.call-screen-sharing .call-controls {
    background: rgba(0,0,0,0.6); border-radius: var(--radius-full);
    padding: 6px 12px; gap: 8px; margin-top: 8px;
    backdrop-filter: blur(8px);
}
.call-screen-sharing .call-control-btn {
    width: 36px; height: 36px; background: rgba(255,255,255,0.15); color: white;
}
.call-screen-sharing .call-control-btn:hover { background: rgba(255,255,255,0.25); }
.call-screen-sharing .call-control-btn.active { background: rgba(234,179,8,0.3); color: #facc15; }
.call-screen-sharing .call-participants-bar { display: none; }

@media (max-width: 768px) {
    .call-overlay { width: calc(100% - 32px); left: 16px; right: 16px; bottom: 80px; }
    .call-overlay.call-expanded { width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; border-radius: 0; }
    .call-toast { left: 16px; right: 16px; min-width: auto; }
    .call-overlay.call-screen-sharing { right: 8px; bottom: 80px; }
    .call-thumb-video { width: 80px; height: 60px; }
}
