/* ============================================================
   Base16 / Gruvbox-like dark theme
   ============================================================ */
:root {
    --avatar-radius: 50%;
    --c0: #181818; /* 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="default"] {
    --c0: #181818; /* bg */
    --c1: #141414; /* bg1 */
    --c2: #282828; /* bg2 */
    --c3: #3c3836; /* bg3 */
    --c4: #504945; /* bg4 */
    --c5: #665c54; /* gray */
    --c6: #7c6f64; /* fg4 */
    --c7: #a89984; /* fg2 */
    --c8: #d5c4a1; /* fg1 */
    --c9: #fb4934; /* red */
    --c10: #b8bb26; /* green */
    --c11: #fabd2f; /* yellow */
    --c12: #83a598; /* blue */
    --c13: #ff79c6; /* 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);
}

[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;
}

[data-theme="srcery"] {
    --c0: #1c1b19; /* bg */
    --c1: #262421; /* bg1 */
    --c2: #3e3b32; /* bg2 */
    --c3: #504945; /* bg3 */
    --c4: #7c6f64; /* bg4 */
    --c5: #918175; /* gray */
    --c6: #a89070; /* fg4 */
    --c7: #d5b896; /* fg2 */
    --c8: #fce8c3; /* fg */
    --c9: #ef2f27; /* red */
    --c10: #519f50; /* green */
    --c11: #fbb829; /* yellow */
    --c12: #2c78bf; /* blue */
    --c13: #e02c6d; /* magenta */
    --c14: #0aaeb3; /* cyan */
    --c15: #ff5f00; /* orange */
}

[data-theme="noctis"] {
    --c0: #1b2932; /* bg */
    --c1: #1f3040; /* bg1 */
    --c2: #253848; /* bg2 */
    --c3: #2e4455; /* bg3 */
    --c4: #3d5670; /* bg4 */
    --c5: #5e8095; /* gray */
    --c6: #7ca0b5; /* fg4 */
    --c7: #a8c4d4; /* fg2 */
    --c8: #d6e8f0; /* fg */
    --c9: #fb3f62; /* red */
    --c10: #49d6a8; /* green */
    --c11: #ffd380; /* yellow */
    --c12: #82b8e0; /* blue */
    --c13: #d39bdb; /* purple */
    --c14: #5ab2ca; /* aqua */
    --c15: #e88c5b; /* orange */
}

[data-theme="everforest"] {
    --c0: #1e2326; /* bg_dim */
    --c1: #272e33; /* bg0 */
    --c2: #2e383c; /* bg1 */
    --c3: #374145; /* bg2 */
    --c4: #414b50; /* bg3 */
    --c5: #7a8478; /* grey0 */
    --c6: #859289; /* grey1 */
    --c7: #9da9a0; /* grey2 */
    --c8: #d3c6aa; /* fg */
    --c9: #e67e80; /* red */
    --c10: #a7c080; /* green */
    --c11: #dbbc7f; /* yellow */
    --c12: #7fbbb3; /* blue */
    --c13: #d699b6; /* purple */
    --c14: #83c092; /* aqua */
    --c15: #e69875; /* orange */
}

[data-theme="base16-pop"] {
    --c0: #000000; /* bg */
    --c1: #000000; /* bg1 */
    --c2: #0d0d0d; /* bg2 */
    --c3: #303030; /* bg3 */
    --c4: #505050; /* bg4 */
    --c5: #b0b0b0; /* gray */
    --c6: #c0c0c0; /* fg4 */
    --c7: #d0d0d0; /* fg2 */
    --c8: #e0e0e0; /* fg1 */
    --c9: #eb008a; /* red */
    --c10: #37b349; /* green */
    --c11: #f8ca12; /* yellow */
    --c12: #0e5a94; /* blue */
    --c13: #b31e8d; /* purple */
    --c14: #00aabb; /* aqua */
    --c15: #f29333; /* orange */
}

[data-theme="macos-dark"] {
    --c0: #1c1c1e; --c1: #161618; --c2: #2c2c2e; --c3: #3a3a3c;
    --c4: #48484a; --c5: #636366; --c6: #8e8e93; --c7: #aeaeb2;
    --c8: #f2f2f7; --c9: #ff453a; --c10: #32d74b; --c11: #ffd60a;
    --c12: #0a84ff; --c13: #bf5af2; --c14: #5ac8fa; --c15: #ff9f0a;
}

[data-theme="windows-dark"] {
    --c0: #202020; --c1: #1a1a1a; --c2: #2b2b2b; --c3: #323232;
    --c4: #3d3d3d; --c5: #898989; --c6: #a0a0a0; --c7: #c0c0c0;
    --c8: #e4e4e4; --c9: #f85149; --c10: #3fb950; --c11: #e3b341;
    --c12: #0078d4; --c13: #c084fc; --c14: #40c8e0; --c15: #e8a838;
}

[data-theme="macos-light"] {
    --c0: #f5f5f7; --c1: #ffffff; --c2: #e5e5ea; --c3: #d1d1d6;
    --c4: #c7c7cc; --c5: #8e8e93; --c6: #636366; --c7: #3a3a3c;
    --c8: #1c1c1e; --c9: #ff3b30; --c10: #34c759; --c11: #ff9500;
    --c12: #007aff; --c13: #af52de; --c14: #5ac8fa; --c15: #ff9500;
}

/* ============================================================
   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);
}
.chat-title.name-color-red {
    color: var(--c9);
}
.chat-title.name-color-green {
    color: var(--c10);
}
.chat-title.name-color-yellow {
    color: var(--c11);
}
.chat-title.name-color-blue {
    color: var(--c12);
}
.chat-title.name-color-purple {
    color: var(--c13);
}
.chat-title.name-color-aqua {
    color: var(--c14);
}
.chat-title.name-color-orange {
    color: var(--c15);
}
.chat-title.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: var(--radius);
    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
   ============================================================ */
.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-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

.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: #56b6c2;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}
.tagline2 {
    color: #f1fa8c;
}

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

.field label,
.field .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;
}

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-sel);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        border-color 0.15s;
    vertical-align: middle;
    position: relative;
}

input[type="checkbox"]:hover {
    border-color: var(--accent);
    background: var(--bg-hl);
}

input[type="checkbox"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
    content: "";
    display: block;
    width: 4px;
    height: 8px;
    border: 2px solid var(--bg);
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.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-send {
    color: var(--fg-dim);
    background-color: var(--bg-alt);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition:
        color 0.1s,
        background 0.1s;
    flex-shrink: 0;
    line-height: 1;
}
.btn-send:hover {
    color: var(--fg);
    background: var(--bg-sel);
}
.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);
}
.btn-save {
    max-width: fit-content;
}
.icon-btn-sm {
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius);
    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-resizer {
    width: 0px;
    flex-shrink: 0;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 10;
}

.sidebar-resizer-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 3rem 0.6rem;
    color: var(--fg-dim);
    font-size: 1.1rem;
    line-height: 1;
    border-radius: 4px;
    cursor: col-resize;
    user-select: none;
    opacity: 0;
    transition:
        opacity 0.15s,
        color 0.15s;
}

.sidebar:hover ~ .sidebar-resizer .sidebar-resizer-handle,
.sidebar-resizer.dragging .sidebar-resizer-handle {
    width: 6px;
    opacity: 1;
    transition: widht 0.15s;
}

.sidebar-resizer:hover .sidebar-resizer-handle,
.sidebar-resizer.dragging .sidebar-resizer-handle {
    width: 6px;
    color: var(--accent);
    opacity: 1;
}

.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-title--clickable {
    cursor: pointer;
    user-select: none;
}

.sidebar-title--clickable:hover {
    opacity: 0.8;
}

.modal-narrow {
    width: 320px;
}

.stats-list {
    margin: 0;
    padding: 0;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-row dt {
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.stats-row dd {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
}

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

.sidebar-convs {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-top: 0px;
    padding-bottom: 0px;
    margin-top: 0px;
    margin-bottom: 0px;
}

.sidebar-users {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
}

.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;
    cursor: pointer;
    user-select: none;
}

.collapse-arrow {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
    color: var(--c5);
}

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

.sidebar-section.collapsed .online-list {
    display: none;
}

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

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

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

body.ui-rounded .conv-item {
    margin: 1px 8px;
}

.conv-item.active {
    background: var(--bg);
    color: var(--accent);
    z-index: 20;
}
.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: var(--avatar-radius);
    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;
    height: calc(var(--composer-h) + 1px);
    box-sizing: border-box;
}

.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-item--admin {
    color: var(--c11);
}
.user-menu-item--settings {
    color: var(--c14);
}
.user-menu-item--status {
    color: var(--c10);
}
.user-menu-item--notes {
    color: var(--c12);
}
.conv-name--notes {
    color: var(--c12);
}
.conv-item--notes-fav {
    margin-bottom: 8px;
}
.notes-welcome-warn {
    color: var(--c15);
}
.notes-welcome-hint {
    color: var(--fg-dim);
    font-size: 0.78rem;
    margin-top: 4px;
}

.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);
    flex-shrink: 0;
    position: relative;
}

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

.chat-header-avatar {
    height: var(--header-h);
    width: var(--header-h);
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    pointer-events: all;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    min-width: 0;
}

.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;
    opacity: 0;
    transition: opacity 0.15s;
}

.chat-header:hover .chat-header-actions {
    opacity: 1;
}

/* ============================================================
   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);
    position: relative;
}

.message:hover {
    background-color: color-mix(in srgb, var(--bg-alt) 25%, transparent);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--avatar-radius);
    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-content code {
    background: var(--bg-alt);
    border: 1px solid var(--bg-sel);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 0.9em;
    cursor: pointer;
}

.message-content code:not(pre code):hover {
    border-color: var(--accent, #7c6af7);
}

.message-content code:not(pre code).copied {
    border-color: #4caf50;
    outline: 1px solid #4caf50;
}

.message-content pre:hover {
    border-color: var(--accent, #7c6af7);
    cursor: pointer;
}

.message-content pre.copied {
    border-color: #4caf50;
    outline: 1px solid #4caf50;
}

.message-content pre {
    background: var(--bg-alt);
    border: 1px solid var(--bg-sel);
    border-radius: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    margin: 4px auto;
    white-space: pre;
    width: fit-content;
    min-width: 200px;
    max-width: 100%;
}

.message-content pre code {
    border: none;
    padding: 0;
    background: none;
}

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

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

.message-audio {
    margin-top: 6px;
}

.message-audio audio {
    max-width: 360px;
    width: 100%;
}

.message-file-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    max-width: 360px;
}

.file-card-icon {
    font-size: 1.4em;
    flex-shrink: 0;
}

.file-card-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9em;
}

.file-card-download {
    flex-shrink: 0;
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.file-card-download:hover {
    opacity: 0.85;
}

/* Emote messages (/me, /slap) */
.message-emote {
    justify-content: center;
    align-items: baseline;
    gap: 6px;
    padding: 1px 0;
    color: var(--fg-dim);
}

.message-emote-text {
    font-style: italic;
    font-size: 0.9rem;
}

/* Link preview card */
.link-preview {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    background: var(--bg-alt);
    border-radius: var(--radius);
    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: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-desc {
    font-size: 0.9rem;
    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-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-family: var(--font);
    text-align: left;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s;
}

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

.composer--drag-over .composer-input {
    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 {
    font-weight: 700;
}

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

.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: var(--avatar-radius);
    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: var(--radius);
    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-settings-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem 0 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.admin-settings-heading {
    width: 100%;
    margin: 0 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted, var(--fg));
    opacity: 0.6;
}

.admin-setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--fg);
}

.admin-branding-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 420px;
    padding-top: 0.5rem;
}

.admin-branding-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--fg);
}

.admin-branding-field small {
    color: var(--fg2);
    font-size: 0.75rem;
}

.admin-branding-field input {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
    width: 100%;
}

.admin-tabs,
.settings-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    padding-bottom: 8px;
}

.tab-btn,
.settings-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,
.settings-tab-btn.active,
.settings-tab-btn:hover {
    background: var(--bg-sel);
    color: var(--fg);
}

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

.tab-content {
    display: block;
}

.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);
}

.audit-log-list {
    overflow-y: auto;
    max-height: 420px;
    font-size: 0.85rem;
}

.audit-log-row {
    display: flex;
    gap: 12px;
    padding: 5px 2px;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}

.audit-log-row:last-child {
    border-bottom: none;
}

.audit-log-ts {
    color: var(--fg-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 140px;
}

.audit-log-actor {
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 100px;
}

.audit-log-action {
    color: var(--fg);
}

.audit-log-footer {
    padding: 8px 0 0;
    text-align: center;
}

.admin-images-scroll {
    overflow-y: auto;
    max-height: 420px;
}

.admin-images-footer {
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--fg-muted);
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.image-admin-link {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}
.image-admin-link:hover {
    text-decoration: underline;
}

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
   ============================================================ */
@supports selector(::-webkit-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-resizer {
        display: none;
    }

    .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%;
    }

    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 199;
    }

    #sidebar-overlay.active {
        display: block;
    }
}

/* ─── Online users list ────────────────────────────────────────────────────── */
.online-list {
    list-style: none;
}
.avatar-xs {
    width: 26px;
    height: 26px;
    border-radius: var(--avatar-radius);
    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);
    cursor: pointer;
}
.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;
}

/* ============================================================
   Modal hint text
   ============================================================ */
.modal-hint {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* ============================================================
   Reactions
   ============================================================ */
.reaction-add-btn {
    display: none;
    position: absolute;
    top: 2px;
    right: 4px;
    background: var(--bg-sel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1px 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--fg);
    line-height: 1.4;
}
.reaction-add-btn:hover {
    border-color: var(--accent-alt);
}
.message:hover .reaction-add-btn {
    display: inline-block;
}
.msg-actions {
    display: none;
    position: absolute;
    top: 2px;
    right: 34px;
    flex-direction: row;
    gap: 2px;
}
.message:hover .msg-actions {
    display: flex;
}
.msg-action-btn {
    background: var(--bg-sel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1px 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--fg);
    line-height: 1.4;
}
.msg-action-btn:hover {
    border-color: var(--accent-alt);
}
.msg-edited {
    font-size: 11px;
    color: var(--fg-dim);
    margin-left: 4px;
}
.edit-textarea {
    width: 100%;
    min-height: 60px;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--fg);
    padding: 4px 8px;
    font-size: inherit;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
.edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.edit-save-btn,
.edit-cancel-btn {
    background-color: color-mix(in srgb, var(--bg-sel) 25%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--fg);
}
.edit-save-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.edit-cancel-btn:hover {
    border-color: var(--accent-alt);
}
.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    padding-left: 44px;
}
.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-sel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1px 8px;
    cursor: pointer;
    font-size: 16px;
    color: var(--fg);
    transition: border-color 0.1s;
}
.reaction-pill:hover {
    border-color: var(--accent);
}
.reaction-pill.reacted {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent-alt) 15%, transparent);
}
.reaction-pill img {
    width: auto;
    height: 1.4em;
    vertical-align: middle;
}

/* ============================================================
   Emoji picker & admin
   ============================================================ */
.emoji-picker {
    position: fixed;
    z-index: 1000;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    width: 300px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.emoji-search {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    margin-bottom: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 13px;
}
.emoji-section {
    margin-bottom: 6px;
}
.emoji-section-label {
    font-size: 11px;
    opacity: 0.6;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.emoji-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    font-size: 20px;
    line-height: 1;
    transition: background 0.1s;
}
.emoji-btn:hover {
    background: var(--bg-hl);
}
.emoji-btn img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}
.emoji-upload-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.emoji-upload-form input[type="text"] {
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 13px;
}
.emoji-filename {
    font-size: 12px;
    opacity: 0.7;
}
.emoji-admin-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}
.emoji-admin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--bg-sel);
    border-radius: var(--radius);
    min-width: 64px;
}
.emoji-admin-item img {
    width: 32px;
    height: 32px;
}
.emoji-admin-item span {
    font-size: 11px;
    opacity: 0.8;
    text-align: center;
    word-break: break-all;
}

/* ============================================================
   Login screen
   ============================================================ */
#login-overlay {
    background: #000000;
}

.seo-texture {
    position: absolute;
    top: 0;
    right: 0;
    width: 45%;
    max-width: 520px;
    font-size: 6.5px;
    line-height: 1.3;
    color: #181818;
    user-select: none;
    pointer-events: none;
    overflow: hidden;
    -webkit-mask-image: radial-gradient(
        ellipse 100% 100% at 100% 0%,
        black 30%,
        transparent 72%
    );
    mask-image: radial-gradient(
        ellipse 100% 100% at 100% 0%,
        black 30%,
        transparent 72%
    );
    z-index: 0;
}

.login-modal {
    background-color: #000000;
    border: none;
    color: #918175;
    text-align: center;
    max-width: 360px;
}

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

.login-text {
    font-family: monospace;
    font-size: 4em;
    font-weight: 700;
    line-height: 90%;
    color: #cc241d;
    text-shadow:
        1px 1px 1px #852117,
        1px 2px 1px #6e1e15,
        1px 3px 1px #6e1e15,
        1px 4px 1px #6e1e15,
        1px 5px 1px #581b12,
        1px 6px 1px #581b12,
        1px 7px 1px #581b12,
        1px 8px 1px #43180f,
        1px 9px 1px #43180f,
        1px 10px 1px #43180f,
        1px 18px 6px rgba(16, 16, 16, 0.4),
        1px 22px 10px rgba(16, 16, 16, 0.2),
        1px 25px 35px rgba(16, 16, 16, 0.2),
        1px 30px 60px rgba(16, 16, 16, 0.4);
}
@keyframes float {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}
.login-text:hover {
    cursor: pointer;
    animation: float 5s ease 0s infinite normal both;
}
.login-text a.login-link {
    color: inherit;
    text-decoration: none;
}

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

.intro label {
    font-size: 0.85rem;
    color: #a89984;
    font-weight: 500;
}

.intro input[type="text"] {
    text-align: center;
    background: #000000;
    color: #2aa198;
    border: 0;
    border-bottom: 1px solid #2aa198;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 0.95rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.intro input[type="password"],
.intro textarea,
.intro select {
    text-align: center;
    background: #000000;
    color: #2aa198;
    border: 0;
    border-bottom: 1px solid #2aa198;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 0.95rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

.intro input:focus,
.intro textarea:focus {
    border: 0;
    border-bottom: 1px solid #cc241d;
}
.btn-intro {
    background: #000000;
    color: #918175;
}
.btn-intro:hover {
    color: #ebdbb2;
    font-weight: 700;
}

/* ─── Lightbox ─────────────────────────────────────────────────────────────── */
#lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#lightbox.hidden {
    display: none;
}

#lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0.85;
}

#lightbox-toolbar {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    display: flex;
    gap: 6px;
}

#lightbox-toolbar .composer-attach-btn {
    font-size: 1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    position: relative;
    z-index: 1;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    cursor: zoom-in;
    user-select: none;
}

#lightbox-img.zoomed {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

#lightbox-img.no-zoom {
    cursor: default;
}

#lightbox.zoomed {
    overflow: auto;
    align-items: flex-start;
    justify-content: flex-start;
}

/* ============================================================
   @mentions
   ============================================================ */

/* Inline mention span in message content */
.mention {
    font-weight: 600;
}
.mention.name-color-red {
    color: var(--c9);
}
.mention.name-color-green {
    color: var(--c10);
}
.mention.name-color-yellow {
    color: var(--c11);
}
.mention.name-color-blue {
    color: var(--c12);
}
.mention.name-color-purple {
    color: var(--c13);
}
.mention.name-color-aqua {
    color: var(--c14);
}
.mention.name-color-orange {
    color: var(--c15);
}
.mention.name-color-gray {
    color: var(--c5);
}

/* Self-mention highlight */
.mention-self {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-radius: 3px;
    padding: 0 2px;
}

/* Sidebar mention badge */
.conv-mention-badge {
    background: var(--c10);
    color: var(--bg);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
    flex-shrink: 0;
    line-height: 1.6;
}

/* Autocomplete dropdown */
.mention-dropdown {
    position: fixed;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    z-index: 200;
    overflow: hidden;
    max-width: 400px;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    user-select: none;
}

.mention-item:hover,
.mention-item.selected {
    background: var(--bg-sel);
}

.mention-item-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--avatar-radius);
    flex-shrink: 0;
    object-fit: cover;
}

.mention-item-name {
    font-weight: 600;
    flex-shrink: 0;
}
.mention-item-name.name-color-red {
    color: var(--c9);
}
.mention-item-name.name-color-green {
    color: var(--c10);
}
.mention-item-name.name-color-yellow {
    color: var(--c11);
}
.mention-item-name.name-color-blue {
    color: var(--c12);
}
.mention-item-name.name-color-purple {
    color: var(--c13);
}
.mention-item-name.name-color-aqua {
    color: var(--c14);
}
.mention-item-name.name-color-orange {
    color: var(--c15);
}
.mention-item-name.name-color-gray {
    color: var(--c5);
}

.mention-item-username {
    color: var(--fg-dim);
    font-size: 0.82em;
}

/* ── Avatar tooltip ──────────────────────────────────────────────────────── */
.avatar-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    min-width: 240px;
    max-width: 340px;
}
.avatar-tooltip-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.avatar-tooltip-avatar {
    width: 96px;
    height: 96px;
    border-radius: var(--avatar-radius);
    object-fit: cover;
}
.avatar-tooltip-joined {
    font-size: 0.75em;
    color: var(--fg-dim);
    text-align: center;
}
.avatar-tooltip-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
}
.avatar-tooltip-name {
    font-weight: bold;
    font-size: 1em;
    margin-bottom: 4px;
    word-break: break-word;
    color: var(--fg);
}
.avatar-tooltip-name.name-color-red {
    color: var(--c9);
}
.avatar-tooltip-name.name-color-green {
    color: var(--c10);
}
.avatar-tooltip-name.name-color-yellow {
    color: var(--c11);
}
.avatar-tooltip-name.name-color-blue {
    color: var(--c12);
}
.avatar-tooltip-name.name-color-purple {
    color: var(--c13);
}
.avatar-tooltip-name.name-color-aqua {
    color: var(--c14);
}
.avatar-tooltip-name.name-color-orange {
    color: var(--c15);
}
.avatar-tooltip-name.name-color-gray {
    color: var(--c5);
}
.avatar-tooltip-current-status {
    font-size: 0.85em;
    color: var(--c10);
    margin-bottom: 6px;
    word-break: break-word;
}
.avatar-tooltip-statuses {
    border-top: 1px solid var(--bg-hl);
    padding-top: 5px;
}
.avatar-tooltip-status {
    font-size: 0.82em;
    font-family: monospace;
    line-height: 1;
    color: var(--fg-dim);
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   Reply-to feature
   ============================================================ */

/* Generic name-color helpers (allow use outside .message-sender) */
.name-color-red {
    color: var(--c9);
}
.name-color-green {
    color: var(--c10);
}
.name-color-yellow {
    color: var(--c11);
}
.name-color-blue {
    color: var(--c12);
}
.name-color-purple {
    color: var(--c13);
}
.name-color-aqua {
    color: var(--c14);
}
.name-color-orange {
    color: var(--c15);
}
.name-color-gray {
    color: var(--c5);
}

/* Reply bar above the composer */
#reply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    font-size: 0.83em;
    color: var(--fg-dim);
    flex-shrink: 0;
}
.reply-bar-label {
    white-space: nowrap;
    flex-shrink: 0;
}
.reply-bar-name {
    font-weight: 600;
}
.reply-bar-snippet {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
    color: var(--fg-alt);
}
#reply-bar-cancel {
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 0.95em;
    padding: 0 4px;
    flex-shrink: 0;
}
#reply-bar-cancel:hover {
    color: var(--fg);
}
#pending-attachment-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    font-size: 0.83em;
    color: var(--fg-dim);
    flex-shrink: 0;
}
#pending-attachment-cancel {
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 0.95em;
    padding: 0 4px;
    flex-shrink: 0;
    margin-left: auto;
}
#pending-attachment-cancel:hover {
    color: var(--fg);
}

/* Reply quote block inside a message */
.reply-quote {
    /* border-left: 3px solid var(--accent); */
    padding: 3px 8px;
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 0 2px 2px 0;
    background: transparent;
    transition: background 0.1s;
}
.reply-quote:hover {
    background: var(--bg-hl);
}
.reply-quote-header-line {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8em;
    color: var(--fg-dim);
    line-height: 1.4;
}
.reply-sender-avatar {
    width: 16px !important;
    height: 16px !important;
    border-radius: var(--avatar-radius);
    object-fit: cover;
    flex-shrink: 0;
}
.reply-quote-time {
    font-size: 0.9em;
    opacity: 0.7;
}
.reply-quote-body {
    font-style: italic;
    font-size: 0.88em;
    color: var(--fg-alt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-quote-text {
    cursor: pointer;
}
.reply-quote-image {
    cursor: pointer;
    color: var(--accent);
}
.reply-quote-deleted {
    font-size: 0.8em;
    color: var(--fg-dim);
}
.reply-quote-deleted-body {
    color: var(--fg-dim);
}

/* Flash highlight when jumping to a message */
@keyframes msg-flash {
    0%,
    100% {
        background: transparent;
    }
    30%,
    70% {
        background: var(--bg-sel);
    }
}
.msg-highlight {
    animation: msg-flash 1.5s ease;
    border-radius: var(--radius);
}

/* Message popup overlay (for out-of-view message jump) */
.msg-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.35);
}
.msg-popup {
    position: absolute;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
    max-width: 480px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-height: 80vh;
    overflow-y: auto;
}
.msg-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
