/* ============================================================
   Base16 / Gruvbox-like dark theme (default: snakkis)
   ============================================================ */
:root {
    --c0: #282828; /* bg */
    --c1: #3c3836; /* bg1 */
    --c2: #504945; /* bg2 */
    --c3: #665c54; /* bg3 */
    --c4: #7c6f64; /* bg4 */
    --c5: #928374; /* gray */
    --c6: #a89984; /* fg4 */
    --c7: #d5c4a1; /* fg2 */
    --c8: #ebdbb2; /* fg1 */
    --c9: #fb4934; /* red */
    --c10: #b8bb26; /* green */
    --c11: #fabd2f; /* yellow */
    --c12: #83a598; /* blue */
    --c13: #d3869b; /* purple */
    --c14: #8ec07c; /* aqua */
    --c15: #fe8019; /* orange */

    --bg: var(--c0);
    --bg-alt: var(--c1);
    --bg-sel: var(--c2);
    --bg-hl: var(--c3);
    --fg: var(--c8);
    --fg-alt: var(--c6);
    --fg-dim: var(--c5);
    --accent: var(--c12);
    --accent-alt: var(--c14);
    --danger: var(--c9);
    --success: var(--c10);
    --warning: var(--c11);
    --border: var(--c2);

    --sidebar-w: 260px;
    --header-h: 52px;
    --composer-h: 60px;
    --radius: 0px;
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
}

[data-theme="light"] {
    --c0: #fbf1c7;
    --c1: #ebdbb2;
    --c2: #d5c4a1;
    --c3: #bdae93;
    --c4: #a89984;
    --c5: #928374;
    --c6: #7c6f64;
    --c7: #665c54;
    --c8: #3c3836;
    --c9: #9d0006;
    --c10: #79740e;
    --c11: #b57614;
    --c12: #076678;
    --c13: #8f3f71;
    --c14: #427b58;
    --c15: #af3a03;
}

[data-theme="dracula"] {
    --c0: #282a36;
    --c1: #343746;
    --c2: #44475a;
    --c3: #6272a4;
    --c4: #7b8db4;
    --c5: #8896ba;
    --c6: #999fab;
    --c7: #b0b8cb;
    --c8: #f8f8f2;
    --c9: #ff5555;
    --c10: #50fa7b;
    --c11: #f1fa8c;
    --c12: #8be9fd;
    --c13: #ff79c6;
    --c14: #bd93f9;
    --c15: #ffb86c;
}

[data-theme="nord"] {
    --c0: #2e3440;
    --c1: #3b4252;
    --c2: #434c5e;
    --c3: #4c566a;
    --c4: #616e88;
    --c5: #7b88a1;
    --c6: #8a96a9;
    --c7: #adb8c8;
    --c8: #d8dee9;
    --c9: #bf616a;
    --c10: #a3be8c;
    --c11: #ebcb8b;
    --c12: #81a1c1;
    --c13: #b48ead;
    --c14: #88c0d0;
    --c15: #d08770;
}

[data-theme="solarized-dark"] {
    --c0: #002b36;
    --c1: #073642;
    --c2: #004052;
    --c3: #005065;
    --c4: #5f8598;
    --c5: #657b83;
    --c6: #839496;
    --c7: #93a1a1;
    --c8: #fdf6e3;
    --c9: #dc322f;
    --c10: #859900;
    --c11: #b58900;
    --c12: #268bd2;
    --c13: #d33682;
    --c14: #2aa198;
    --c15: #cb4b16;
}

[data-theme="one-dark"] {
    --c0: #282c34;
    --c1: #2c313a;
    --c2: #353b45;
    --c3: #3e4451;
    --c4: #5c6370;
    --c5: #636d83;
    --c6: #828997;
    --c7: #abb2bf;
    --c8: #eff0f1;
    --c9: #e06c75;
    --c10: #98c379;
    --c11: #e5c07b;
    --c12: #61afef;
    --c13: #c678dd;
    --c14: #56b6c2;
    --c15: #d19a66;
}

[data-theme="tokyo-night"] {
    --c0: #1a1b2e;
    --c1: #1f2335;
    --c2: #292e42;
    --c3: #343b58;
    --c4: #3b4261;
    --c5: #545c7e;
    --c6: #737aa2;
    --c7: #a9b1d6;
    --c8: #c0caf5;
    --c9: #f7768e;
    --c10: #9ece6a;
    --c11: #e0af68;
    --c12: #7aa2f7;
    --c13: #bb9af7;
    --c14: #7dcfff;
    --c15: #ff9e64;
}

/* ============================================================
   Name color classes (8 semantic colors)
   ============================================================ */
.message-sender.name-color-red {
    color: var(--c9);
}
.message-sender.name-color-green {
    color: var(--c10);
}
.message-sender.name-color-yellow {
    color: var(--c11);
}
.message-sender.name-color-blue {
    color: var(--c12);
}
.message-sender.name-color-purple {
    color: var(--c13);
}
.message-sender.name-color-aqua {
    color: var(--c14);
}
.message-sender.name-color-orange {
    color: var(--c15);
}
.message-sender.name-color-gray {
    color: var(--c5);
}

/* ============================================================
   Theme picker UI
   ============================================================ */
.theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.theme-btn {
    padding: 0.3rem 0.7rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    font-size: 0.8rem;
    transition: border-color 0.15s;
}

.theme-btn:hover {
    border-color: var(--accent);
}
.theme-btn.active {
    border-color: var(--accent);
    background: var(--bg-sel);
}

.name-color-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.name-color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition:
        border-color 0.15s,
        transform 0.1s;
}

.name-color-btn:hover {
    transform: scale(1.15);
}
.name-color-btn.active {
    border-color: var(--fg);
}
.name-color-btn[data-color=""] {
    background: var(--fg-dim);
}

.custom-theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.custom-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: var(--fg-dim);
}

.custom-color-item input[type="color"] {
    width: 36px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 1px;
    background: var(--bg);
}

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

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    font-size: 15px;
    line-height: 1.5;
}

/* ============================================================
   Utility
   ============================================================ */
.hidden {
    display: none !important;
}
.mobile-only {
    display: none;
}

@media (max-width: 640px) {
    .mobile-only {
        display: flex;
    }
}

/* ============================================================
   Overlay / Login
   ============================================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-wide {
    max-width: 700px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--fg-alt);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--bg-sel);
    color: var(--fg);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.logo {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    letter-spacing: -1px;
}

.tagline {
    text-align: center;
    color: var(--fg-dim);
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}

.login-modal {
    max-width: 360px;
}

.login-alt {
    margin-top: 1rem;
    text-align: center;
    color: var(--fg-alt);
    font-size: 0.9rem;
}

/* ============================================================
   Forms
   ============================================================ */
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 1rem;
}

.field label {
    font-size: 0.85rem;
    color: var(--fg-alt);
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    background: var(--bg-sel);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 0.95rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

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

.checkbox-field label {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    padding: 6px 10px;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-radius: var(--radius);
    border-left: 3px solid var(--danger);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition:
        background 0.12s,
        opacity 0.12s;
    text-decoration: none;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    color: var(--bg);
}
.btn-primary:hover {
    opacity: 0.85;
}
.btn-secondary {
    background: var(--bg-sel);
    color: var(--fg);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg-hl);
}
.btn-danger {
    background: var(--danger);
    color: var(--bg);
}
.btn-danger:hover {
    opacity: 0.85;
}
.btn-link {
    background: none;
    color: var(--accent);
    padding: 0;
}
.btn-link:hover {
    text-decoration: underline;
}
.btn-full {
    width: 100%;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--fg-alt);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 1.1rem;
    line-height: 1;
}
.icon-btn:hover {
    background: var(--bg-sel);
    color: var(--fg);
}

.icon-btn-sm {
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 1rem;
}
.icon-btn-sm:hover {
    color: var(--fg);
    background: var(--bg-sel);
}

/* ============================================================
   App Layout
   ============================================================ */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-alt);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    height: var(--header-h);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-section {
    flex-shrink: 0;
    padding: 8px 0;
}

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

.sidebar-users {
    flex-shrink: 0;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.conv-list {
    list-style: none;
}

.conv-item {
    display: flex;
    align-items: center;
    padding: 5px 16px;
    cursor: pointer;
    border-radius: 0;
    gap: 8px;
    position: relative;
    transition: background 0.1s;
}

.conv-item:hover {
    background: var(--bg-sel);
}
.conv-item.active {
    background: var(--bg);
    color: var(--accent);
}
.conv-item.active .conv-name {
    color: var(--accent);
}

.conv-name {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-badge {
    background: var(--danger);
    color: var(--bg);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius);
    min-width: 18px;
    text-align: center;
}

.conv-star {
    color: var(--warning);
    font-size: 0.8rem;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hl);
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    position: relative;
}

.user-menu-popup {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 8px;
    right: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 4px;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.user-menu-item {
    background: none;
    border: none;
    color: var(--fg);
    text-align: left;
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
}

.user-menu-item:hover {
    background: var(--bg-sel);
}

.user-menu-item--danger {
    color: var(--danger);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.user-menu-status-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.user-menu-status-row.hidden {
    display: none;
}

.user-menu-status-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 3px 6px;
    font-size: 0.85em;
    border-radius: var(--radius);
    min-width: 0;
}

.user-menu-status-btn {
    background: var(--bg-sel);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 3px 8px;
    font-size: 0.85em;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}

.user-menu-status-btn:hover {
    background: var(--accent, var(--c12));
    color: var(--bg);
}

.sidebar-me {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-me--clickable {
    cursor: pointer;
    border-radius: var(--radius);
    padding: 4px;
    margin: -4px;
    transition: background 0.1s;
}

.sidebar-me--clickable:hover {
    background: var(--bg-sel);
}

.sidebar-me-chevron {
    font-size: 1.1rem;
    color: var(--fg-dim);
    flex-shrink: 0;
}

.sidebar-me-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-username {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-status {
    font-size: 0.75rem;
    color: var(--fg-dim);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Message Area
   ============================================================ */
.message-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
    text-align: center;
    padding: 2rem;
    position: relative;
}

.welcome-screen .btn-toggle-sidebar {
    position: absolute;
    top: 8px;
    left: 8px;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    color: var(--fg-alt);
    margin-bottom: 0.5rem;
}

.chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: var(--header-h);
    gap: 12px;
    background: var(--bg-alt);
    flex-shrink: 0;
    position: relative;
}

.chat-header-info {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 60%;
    pointer-events: none;
}

.chat-title {
    font-weight: 600;
    font-size: 1rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-subtitle {
    font-size: 0.75rem;
    color: var(--fg-dim);
    display: block;
}

.chat-header-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* ============================================================
   Messages
   ============================================================ */
.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#load-more-btn-wrap {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    margin-bottom: 8px;
}

.message-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.message {
    display: flex;
    gap: 10px;
    padding: 2px 0;
    transition: background 0.1s;
    border-radius: var(--radius);
}

.message:hover {
    background: var(--bg-alt);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-hl);
    margin-top: 2px;
}

.message-avatar-placeholder {
    width: 36px;
    flex-shrink: 0;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.message-sender {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-alt);
}

.message-time {
    font-size: 0.72rem;
    color: var(--fg-dim);
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.message-image {
    max-width: 400px;
    max-height: 300px;
    border-radius: var(--radius);
    margin-top: 6px;
    cursor: pointer;
    transition: opacity 0.1s;
}

.message-image:hover {
    opacity: 0.9;
}

/* Link preview card */
.link-preview {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    background: var(--bg-sel);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
    padding: 10px 12px;
    max-width: 480px;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.link-preview:hover {
    background: var(--bg-hl);
}

.link-preview-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.link-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.link-preview-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-desc {
    font-size: 0.8rem;
    color: var(--fg-alt);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-preview-url {
    font-size: 0.75rem;
    color: var(--fg-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Composer
   ============================================================ */
.composer {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    background: var(--bg-alt);
    flex-shrink: 0;
}

.composer-attach-btn {
    color: var(--fg-dim);
    background-color: var(--bg-alt);
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition:
        color 0.1s,
        background 0.1s;
    flex-shrink: 0;
    line-height: 1;
}

.composer-attach-btn:hover {
    color: var(--fg);
    background: var(--bg-sel);
}

.composer-input {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.95rem;
    padding: 9px 12px;
    background: var(--bg-sel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-family: var(--font);
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s;
}

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

/* ============================================================
   User list (for modals)
   ============================================================ */
.user-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.user-list-item:hover {
    background: var(--bg-sel);
}
.user-list-item.selected {
    background: var(--bg-hl);
}

.avatar-md {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hl);
    flex-shrink: 0;
}

.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hl);
}

.user-info {
    flex: 1;
}

.user-displayname {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-username {
    font-size: 0.8rem;
    color: var(--fg-dim);
}

/* Selected members chips */
.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-sel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 1.1rem;
}

.member-chip-remove {
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    padding: 0 2px;
    font-size: 0.9rem;
    line-height: 1;
}

.member-chip-remove:hover {
    color: var(--danger);
}

/* ============================================================
   Avatar upload
   ============================================================ */
.avatar-upload {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 1rem;
}

/* ============================================================
   Admin Tables
   ============================================================ */
.admin-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    padding-bottom: 8px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--fg-alt);
    cursor: pointer;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
}

.tab-btn.active,
.tab-btn:hover {
    background: var(--bg-sel);
    color: var(--fg);
}

.tab-btn.active {
    font-weight: 600;
    color: var(--accent);
}

.tab-content {
    display: block;
}
.tab-content.hidden {
    display: none;
}

.admin-actions {
    margin-bottom: 1rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th {
    text-align: left;
    padding: 6px 10px;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table tr:hover td {
    background: var(--bg-sel);
}

code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--bg-sel);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ============================================================
   Date dividers
   ============================================================ */
.date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 6px;
    color: var(--fg-dim);
    font-size: 0.75rem;
    font-weight: 500;
}

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

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-hl);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--fg-dim);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 200;
        width: 85vw;
        transition: left 0.2s;
        height: 100vh;
        height: 100dvh;
    }

    .sidebar.open {
        left: 0;
    }

    .message-area {
        width: 100%;
    }
}

/* ─── Online users list ────────────────────────────────────────────────────── */
.online-list {
    list-style: none;
}
.avatar-xs {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.online-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.online-user-name {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.online-user-status {
    font-size: 0.72rem;
    color: var(--fg-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.online-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    color: var(--c5);
}
.online-item.is-online {
    color: var(--fg);
}
.online-item.is-online .online-user-name {
    font-weight: 600;
}
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c11);
    flex-shrink: 0;
}
.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c3);
    opacity: 0.4;
    flex-shrink: 0;
}
.unread-star {
    font-size: 0.75rem;
    color: var(--c11);
    flex-shrink: 0;
    line-height: 1;
}

.conv-item-unjoined {
    opacity: 0.6;
}
.conv-item-unjoined:hover {
    opacity: 1;
}
.conv-join-hint {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 0.3rem;
    font-style: italic;
}
