/* ========================================
   Adult Chat SPA - Professional v1.1.5
   Dark Premium Adult Theme (Pink / Black)
   ======================================== */

:root {
    --red: #ff2d6a;
    --dark-red: #b01040;
    --pink: #ff6b9d;
    --pink-soft: #ff8ab0;
    --black: #0a0508;
    --dark: #12080c;
    --gray: #1a0a12;
    --light-gray: #241018;
    --white: #ffeeee;
    --yellow: #ff6b9d;
    --yellow-dim: #ff4d8d;
    --text: #ffeeee;
    --text-muted: #cc8899;
    --success: #2ecc71;
    --danger: #ff4757;
    --sidebar-w: 260px;
    --right-w: 280px;
    --header-h: 54px;
    --footer-h: 38px;
    --radius: 12px;
}

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

body, .spa-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #0a0508 !important;
    color: var(--white);
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.45;
    overflow-x: hidden;
}

a { color: var(--pink); text-decoration: none; }
a:hover { color: #ffb0c8; }

/* ========== AUTH PAGES ========== */
.auth-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-footer { margin-top: 16px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ========== HEADER ========== */
.header, .spa-header {
    background: var(--black);
    height: var(--header-h);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--yellow);
    position: sticky;
    top: 0;
    z-index: 200;
}
.spa-header { gap: 10px; }

.logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}
.logo span { color: var(--yellow); }

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.header-center {
    flex: 1;
    text-align: center;
    font-weight: 600;
    color: var(--yellow);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav a {
    color: #fff;
    margin-left: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}
.nav a:hover { color: var(--yellow); }

.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); color: var(--yellow); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.08);
    padding: 3px 10px 3px 3px;
    border-radius: 20px;
    font-size: 0.85rem;
}
.user-chip img, .user-chip .av-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}
.user-chip .av-letter {
    background: var(--dark-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.user-chip .uname { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== SPA LAYOUT ========== */
.spa-layout {
    display: flex;
    height: calc(100vh - var(--header-h) - var(--footer-h));
    position: relative;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--black);
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    z-index: 150;
}

.side-nav { padding: 10px 8px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: var(--text);
    border-radius: 8px;
    margin-bottom: 2px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-item i { width: 20px; text-align: center; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
    background: linear-gradient(90deg, var(--dark-red), rgba(200,16,46,0.4));
    color: var(--yellow);
    border-left: 3px solid var(--yellow);
}
.nav-item.admin-link { color: #ff8a80; }
.nav-item.admin-link.active { color: var(--yellow); }

.side-section {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.side-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--yellow);
    margin-bottom: 8px;
    font-weight: 600;
}

.user-list-mini, .room-list-mini { max-height: 180px; overflow-y: auto; }
.mini-user, .mini-room {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
}
.mini-user:hover, .mini-room:hover { background: rgba(255,255,255,0.07); }
.mini-user .dot {
    width: 8px; height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    flex-shrink: 0;
}
.mini-user img, .mini-user .letter {
    width: 26px; height: 26px;
    border-radius: 50%;
    object-fit: cover;
}
.mini-user .letter {
    background: var(--light-gray);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}

/* Main content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: #0a0508 !important;
    padding: 14px;
    position: relative;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 1.1rem;
    color: #ff6b9d;
    gap: 10px;
}

/* Right panel */
.right-panel {
    width: var(--right-w);
    background: var(--black);
    border-left: 1px solid rgba(255,255,255,0.08);
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 140;
}
.right-panel.open { display: flex; }
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-weight: 600;
    color: var(--yellow);
}
.panel-body { padding: 12px; overflow-y: auto; flex: 1; }

/* ========== FOOTER ========== */
.spa-footer {
    height: var(--footer-h);
    min-height: var(--footer-h);
    background: linear-gradient(90deg, #0a0508 0%, #14080e 50%, #0a0508 100%);
    border-top: 1px solid rgba(255,77,141,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #cc8899;
    box-shadow: 0 -4px 20px rgba(255,45,106,0.08);
    z-index: 150;
}
.footer-inner {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 12px;
}
.footer-brand { font-weight: 600; color: #ffb0c8; letter-spacing: 0.3px; }
.footer-tag { color: #ff6b9d; font-weight: 500; font-size: 0.72rem; }
.footer-status { color: #88cc88; font-weight: 500; }
.footer-sep { opacity: 0.35; color: #ff6b9d; }

/* ========== CARDS ========== */
.card {
    background: rgba(0,0,0,0.32);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    backdrop-filter: blur(4px);
}
.card h2, .card h3 {
    color: var(--yellow);
    margin-bottom: 12px;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255,204,0,0.25);
    padding-bottom: 6px;
}

/* ========== FORMS ========== */
label {
    display: block;
    margin: 10px 0 4px;
    font-size: 0.88rem;
    color: var(--text-muted);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="file"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border 0.15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--yellow);
}
textarea { resize: vertical; min-height: 80px; }

.btn, button[type="submit"], .btn-block {
    display: inline-block;
    background: linear-gradient(180deg, var(--yellow), var(--yellow-dim));
    color: var(--black);
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
}
.btn:hover, button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,204,0,0.3); }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-danger { background: linear-gradient(180deg, #ff6b6b, #e74c3c); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--yellow);
    color: var(--yellow);
}

/* ========== ALERTS ========== */
.alert {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.alert-success { background: #1a472a; border: 1px solid #28a745; }
.alert-error { background: #5c1a1a; border: 1px solid #ff6b6b; }
.alert-info { background: #1a2a47; border: 1px solid #3a7bd5; }

/* ========== ROLE BADGES ========== */
.role-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
}
.badge-owner { background: linear-gradient(90deg,#ff4d8d,#ff2d6a); color: #fff; }
.badge-superadmin { background: #9b59b6; color: #fff; }
.badge-admin { background: #e74c3c; color: #fff; }
.badge-mod { background: #3498db; color: #fff; }
.badge-roommod { background: #1abc9c; color: #fff; }
.badge-member { background: #555; color: #ddd; }

/* ========== CHAT UI ========== */
.chat-layout {
    display: flex;
    height: calc(100vh - var(--header-h) - var(--footer-h) - 28px);
    gap: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
}

.chat-list-panel {
    width: 240px;
    background: rgba(0,0,0,0.45);
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.chat-list-header {
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 6px;
}
.chat-list-header .tab {
    flex: 1;
    text-align: center;
    padding: 7px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-muted);
}
.chat-list-header .tab.active {
    background: var(--dark-red);
    color: var(--yellow);
}
.chat-list-body { flex: 1; overflow-y: auto; padding: 6px; }

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}
.chat-item:hover { background: rgba(255,255,255,0.07); }
.chat-item.active { background: rgba(200,16,46,0.5); }
.chat-item img, .chat-item .letter {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-item .letter {
    background: var(--light-gray);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
}
.chat-item .info { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .preview { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-top {
    padding: 10px 14px;
    background: rgba(0,0,0,0.35);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.chat-top .title { font-weight: 700; color: var(--yellow); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 12px;
    word-wrap: break-word;
    position: relative;
    animation: msgIn 0.15s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.me {
    align-self: flex-end;
    background: linear-gradient(135deg, #1a1a1a, #2a1a1a);
    border: 1px solid rgba(255,204,0,0.35);
    border-bottom-right-radius: 4px;
}
.msg.other {
    align-self: flex-start;
    background: rgba(255,255,255,0.1);
    border-bottom-left-radius: 4px;
}
.msg .author {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--yellow);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.msg .time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
    text-align: right;
}
.msg .img-msg {
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    margin-top: 4px;
    cursor: pointer;
    display: block;
}
.msg .text { white-space: pre-wrap; }

.chat-input-bar {
    padding: 10px 12px;
    background: rgba(0,0,0,0.4);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-input-bar textarea {
    flex: 1;
    min-height: 40px;
    max-height: 100px;
    padding: 10px 12px;
    border-radius: 20px;
    resize: none;
    border: 1px solid rgba(255,255,255,0.15);
}
.chat-tools { display: flex; gap: 4px; }
.tool-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.tool-btn:hover { background: var(--dark-red); color: var(--yellow); }
.tool-btn.send { background: var(--yellow); color: #000; }
.tool-btn.send:hover { background: var(--yellow-dim); }

/* Empty state */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 10px;
}
.chat-empty i { font-size: 2.5rem; opacity: 0.4; }

/* ========== EMOJI PICKER ========== */
.emoji-picker {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--black);
    border: 1px solid rgba(255,204,0,0.3);
    border-radius: 12px;
    padding: 10px;
    width: 320px;
    max-width: 95vw;
    z-index: 300;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.emoji-picker.hidden { display: none; }
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}
.emoji-grid span {
    font-size: 1.4rem;
    text-align: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}
.emoji-grid span:hover { background: rgba(255,255,255,0.12); }

/* ========== MEMBER / ROOM GRIDS ========== */
.grid-members {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.member-card {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}
.member-card:hover {
    transform: translateY(-2px);
    border-color: var(--yellow);
}
.member-card .avatar, .member-card .letter {
    width: 56px; height: 56px;
    border-radius: 50%;
    margin: 0 auto 8px;
    object-fit: cover;
}
.member-card .letter {
    background: var(--light-gray);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 700;
}
.member-card .name { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; }

.room-card {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.12s;
}
.room-card:hover { border-color: var(--yellow); }
.room-card .rname { font-weight: 700; color: var(--yellow); }
.room-card .rdesc { font-size: 0.82rem; color: var(--text-muted); }

/* ========== ADMIN ========== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.admin-table th, .admin-table td {
    padding: 9px 8px;
    border: 1px solid rgba(255,255,255,0.12);
    text-align: left;
}
.admin-table th {
    background: var(--black);
    color: var(--yellow);
    font-weight: 600;
}
.admin-table tr:hover td { background: rgba(255,255,255,0.04); }
.admin-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.admin-tabs .tab {
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
}
.admin-tabs .tab.active { background: var(--dark-red); color: var(--yellow); }

/* ========== PROFILE ========== */
.profile-header {
    text-align: center;
    margin-bottom: 16px;
}
.profile-header .avatar, .profile-header .letter {
    width: 90px; height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
    border: 3px solid var(--yellow);
}
.profile-header .letter {
    background: var(--light-gray);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem; font-weight: 700;
}

/* ========== MOBILE ========== */
@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0; top: var(--header-h); bottom: var(--footer-h);
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.4);
    }
    .sidebar.open { transform: translateX(0); }
    .right-panel {
        position: fixed;
        right: 0; top: var(--header-h); bottom: var(--footer-h);
        width: 85%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform 0.25s;
        display: flex;
    }
    .right-panel.open { transform: translateX(0); }
    .chat-list-panel { width: 100%; }
    .chat-layout { flex-direction: column; height: auto; min-height: 60vh; }
    .chat-main { min-height: 50vh; }
    .user-chip .uname { display: none; }
}

@media (max-width: 520px) {
    .header-center { display: none; }
    .main-content { padding: 10px; }
    .msg { max-width: 88%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,204,0,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,204,0,0.5); }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.mt-10 { margin-top: 10px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.online-dot { width: 8px; height: 8px; background: #2ecc71; border-radius: 50%; display: inline-block; }
.offline-dot { width: 8px; height: 8px; background: #777; border-radius: 50%; display: inline-block; }

/* ========== PUSH / TOAST NOTIFICATIONS ========== */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    right: 14px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    width: calc(100% - 28px);
    pointer-events: none;
}

.toast {
    background: var(--black);
    border: 1px solid rgba(255, 204, 0, 0.4);
    border-left: 4px solid var(--yellow);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.45);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    transition: opacity 0.25s, transform 0.25s;
}
.toast.hiding {
    opacity: 0;
    transform: translateX(40px);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast .toast-av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}
.toast .toast-body { flex: 1; min-width: 0; }
.toast .toast-title {
    font-weight: 700;
    color: var(--yellow);
    font-size: 0.9rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast .toast-text {
    font-size: 0.84rem;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.toast .toast-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
}
.toast .toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.toast .toast-close:hover { color: #fff; }

/* Nav badge */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--yellow);
    color: #000;
    font-size: 0.68rem;
    font-weight: 800;
    margin-left: auto;
    line-height: 1;
}
.nav-item { position: relative; }
.nav-item .nav-badge { margin-left: auto; }

/* Header notification bell */
.notif-bell {
    position: relative;
}
.notif-bell .bell-count {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 16px;
    height: 16px;
    background: var(--yellow);
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    transform: translate(25%, -25%);
}
.notif-bell .bell-count.hidden { display: none; }

/* Permission prompt */
.notif-prompt {
    position: fixed;
    bottom: calc(var(--footer-h) + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--black);
    border: 1px solid var(--yellow);
    border-radius: 12px;
    padding: 14px 18px;
    z-index: 9000;
    max-width: 360px;
    width: calc(100% - 32px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    text-align: center;
}
.notif-prompt p {
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.notif-prompt .btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ========== ONLINE CORNER WIDGET ========== */
.online-corner {
    position: fixed;
    bottom: calc(var(--footer-h) + 12px);
    right: 14px;
    z-index: 500;
    background: rgba(10,5,8,0.92);
    border: 1px solid rgba(255,80,130,0.3);
    border-radius: 12px;
    min-width: 160px;
    max-width: 220px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    font-size: 0.85rem;
}
.oc-header {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffb0c8;
    font-weight: 600;
}
.oc-header:hover { color: #fff; }
.oc-body {
    border-top: 1px solid rgba(255,255,255,0.08);
    max-height: 220px;
    overflow-y: auto;
    padding: 6px 0;
}
.oc-body .oc-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    color: #eee;
}
.oc-body .oc-user:hover { background: rgba(255,80,130,0.12); }
.oc-body .oc-user img, .oc-body .oc-user .letter {
    width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
}
.oc-body .oc-user .letter {
    background: #333; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700;
}
.oc-link {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 0.78rem;
    color: #ff6b9d;
    border-top: 1px solid rgba(255,255,255,0.06);
}
#oc-chevron { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s; }
.online-corner.open #oc-chevron { transform: rotate(180deg); }

/* System messages in chat */
.msg.system {
    align-self: center;
    max-width: 90%;
    background: transparent;
    border: none;
    color: #ff8ab0;
    font-size: 0.82rem;
    font-style: italic;
    text-align: center;
    padding: 4px 10px;
}
.msg.system .text { color: #ff8ab0; }

/* Typing indicator */
.typing-bar {
    padding: 4px 14px;
    font-size: 0.78rem;
    color: #ff8ab0;
    min-height: 22px;
    font-style: italic;
}

/* Adult theme tweaks for main SPA */
.spa-body {
    background: #1a0a10;
}
.main-content {
    background: linear-gradient(180deg, #2a0e18 0%, #1a0a10 40%, #220c14 100%) !important;
}
.spa-header {
    background: #0d0608;
    border-bottom-color: #ff4d8d;
}
.sidebar {
    background: #0d0608;
}
.logo span { color: #ff4d8d !important; }
.header-center { color: #ff6b9d !important; }
.nav-item.active {
    background: linear-gradient(90deg, #8b0a2e, rgba(255,45,106,0.35)) !important;
    color: #ff6b9d !important;
    border-left-color: #ff4d8d !important;
}
.btn, button[type="submit"] {
    background: linear-gradient(180deg, #ff4d8d, #e63d7a) !important;
    color: #fff !important;
}
.card h2, .card h3 { color: #ff6b9d !important; border-bottom-color: rgba(255,77,141,0.3) !important; }
a { color: #ff6b9d; }
.role-badge.badge-owner { background: linear-gradient(90deg,#ff4d8d,#ff2d6a); color:#fff; }

/* Mod action buttons */
.mod-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.mod-actions .btn-sm {
    font-size: 0.72rem;
    padding: 3px 8px;
    background: rgba(255,255,255,0.1) !important;
    color: #ffb0c8 !important;
    border: 1px solid rgba(255,80,130,0.3);
}
.mod-actions .btn-sm:hover { background: rgba(255,45,106,0.3) !important; color: #fff !important; }

/* Toast reply button */
.toast .toast-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.toast .toast-actions button {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,204,0,0.4);
    background: rgba(255,204,0,0.15);
    color: var(--yellow);
    cursor: pointer;
}
.toast .toast-actions button.reply-btn {
    border-color: rgba(255,77,141,0.5);
    background: rgba(255,77,141,0.2);
    color: #ff6b9d;
}

@media (max-width: 600px) {
    .online-corner { right: 8px; bottom: calc(var(--footer-h) + 8px); min-width: 140px; }
}

/* ========== HEADER BEAUTY ========== */
.spa-header {
    background: linear-gradient(90deg, #0d0608 0%, #1a0a12 50%, #0d0608 100%) !important;
    border-bottom: 3px solid transparent !important;
    border-image: linear-gradient(90deg, #ff2d6a, #ff6b9d, #ff2d6a) 1 !important;
    box-shadow: 0 4px 20px rgba(255,45,106,0.15);
}
.spa-header .logo {
    font-size: 1.2rem;
    background: linear-gradient(90deg, #fff, #ffb0c8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.spa-footer {
    background: linear-gradient(90deg, #0a0508 0%, #160a10 50%, #0a0508 100%) !important;
    border-top: 1px solid rgba(255,77,141,0.3) !important;
    color: #cc8899 !important;
}
.nick-click:hover { color: #fff !important; }

/* Speed: reduce heavy blur on mobile */
@media (max-width: 600px) {
    .card { backdrop-filter: none; }
    .online-corner { backdrop-filter: none; }
}

/* ========== POPUP MODAL ========== */
.popup-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.popup-modal.hidden { display: none !important; }
.popup-modal-inner {
    width: 100%;
    max-width: 380px;
    background: linear-gradient(165deg, #1a0a12, #0d0608);
    border: 1px solid rgba(255,77,141,0.4);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(255,0,80,0.2);
    overflow: hidden;
}
.popup-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: rgba(255,45,106,0.15);
    color: #ff6b9d;
    font-weight: 700;
}
.popup-modal-body {
    padding: 16px;
    min-height: 60px;
    color: #ffeeee;
    font-size: 0.95rem;
    line-height: 1.45;
    word-break: break-word;
}
.popup-modal-reply {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.popup-modal-reply input {
    flex: 1;
    border-radius: 20px;
    padding: 8px 14px;
}
#send-popup-modal textarea {
    width: calc(100% - 28px);
    margin: 14px;
    border-radius: 10px;
}


/* ========== LIGHT MODE ========== */
body.light-mode {
    background: #f0e6ea !important;
    color: #221018 !important;
}
body.light-mode .spa-header,
body.light-mode .sidebar,
body.light-mode .spa-footer,
body.light-mode .right-panel {
    background: #fff5f8 !important;
    color: #221018 !important;
}
body.light-mode .main-content {
    background: linear-gradient(180deg, #ffe8f0 0%, #f5e0e8 100%) !important;
}
body.light-mode .card {
    background: rgba(255,255,255,0.85) !important;
    border-color: rgba(200,50,100,0.2) !important;
    color: #221018 !important;
}
body.light-mode .card h2,
body.light-mode .card h3,
body.light-mode .header-center,
body.light-mode .side-title {
    color: #c8102e !important;
}
body.light-mode .nav-item { color: #442233 !important; }
body.light-mode .nav-item.active {
    background: linear-gradient(90deg, #ffb0c8, #ffe0ea) !important;
    color: #8b0a2e !important;
}
body.light-mode input, body.light-mode textarea, body.light-mode select {
    background: #fff !important;
    color: #221018 !important;
    border-color: rgba(200,50,100,0.25) !important;
}
body.light-mode .chat-layout,
body.light-mode .chat-list-panel,
body.light-mode .chat-top,
body.light-mode .chat-input-bar {
    background: rgba(255,255,255,0.7) !important;
}
body.light-mode .msg.other { background: rgba(0,0,0,0.06) !important; color: #221018; }
body.light-mode .msg.me { background: #fff0f5 !important; border-color: #ff6b9d !important; color: #221018; }
body.light-mode .logo {
    background: none !important;
    -webkit-text-fill-color: #c8102e !important;
    color: #c8102e !important;
}
body.light-mode .user-chip { background: rgba(200,50,100,0.1); color: #221018; }
body.light-mode .online-corner {
    background: rgba(255,255,255,0.95) !important;
    border-color: rgba(200,50,100,0.3);
}
body.light-mode .oc-header { color: #c8102e; }
body.light-mode a { color: #c8102e; }
body.light-mode .text-muted { color: #886677 !important; }
body.light-mode .admin-table th { background: #ffe0ea !important; color: #8b0a2e !important; }
body.light-mode .admin-table td { border-color: rgba(0,0,0,0.1); color: #221018; }


/* Staff panel corner link */
.staff-corner {
    position: fixed;
    bottom: calc(var(--footer-h) + 12px);
    left: 14px;
    z-index: 500;
}
.staff-corner a {
    display: inline-block;
    background: linear-gradient(90deg, #b01040, #ff2d6a);
    color: #fff !important;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,204,0,0.35);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.staff-corner a:hover { filter: brightness(1.1); }
body.light-mode .staff-corner a {
    background: linear-gradient(90deg, #ff6b9d, #ff2d6a);
    color: #fff !important;
}
@media (max-width: 600px) {
    .staff-corner { left: 8px; bottom: calc(var(--footer-h) + 56px); }
}

/* ========== ROOM TOOLS / MEMBERS ========== */
.room-tools-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.room-member-list {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.room-member-row {
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.room-member-row .rm-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.room-member-row .rm-info img,
.room-member-row .rm-info .letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.room-member-row .rm-info .letter {
    background: var(--light-gray, #333);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.room-member-row .rm-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.room-member-row .rm-badges {
    margin-top: 2px;
}
.room-member-row .rm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding-left: 42px;
}
.room-member-row .rm-actions .btn-sm {
    font-size: 0.72rem;
    padding: 4px 8px;
    background: rgba(255,255,255,0.1) !important;
    color: #ffb0c8 !important;
    border: 1px solid rgba(255,80,130,0.3);
    border-radius: 6px;
    cursor: pointer;
}
.room-member-row .rm-actions .btn-sm:hover {
    background: rgba(255,45,106,0.3) !important;
    color: #fff !important;
}
body.light-mode .room-member-row .rm-actions .btn-sm {
    background: rgba(200,50,100,0.1) !important;
    color: #c8102e !important;
}

/* Verified Owner tick */
.verified-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1da1f2, #0d8bf0);
    color: #fff !important;
    font-size: 0.7rem;
    font-weight: 900;
    vertical-align: middle;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(29,161,242,0.3);
}
.badge-owner {
    background: linear-gradient(90deg, #ff4d8d, #ff2d6a) !important;
    color: #1a0a10 !important;
}
.room-rules-msg {
    background: rgba(29, 161, 242, 0.12) !important;
    border: 1px solid rgba(29, 161, 242, 0.35) !important;
    border-radius: 10px;
    margin: 8px 0 !important;
}
.room-rules-msg .text {
    color: #cce8ff !important;
    font-size: 0.9rem;
    line-height: 1.45;
}
body.light-mode .room-rules-msg {
    background: rgba(29, 161, 242, 0.1) !important;
}
body.light-mode .room-rules-msg .text { color: #0a3d66 !important; }

/* Ad slots */
.site-ad {
    margin: 10px 0;
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    background: rgba(255, 107, 157, 0.08);
    border: 1px dashed rgba(255, 107, 157, 0.3);
    overflow: hidden;
    max-width: 100%;
}
.site-ad img, .site-ad iframe {
    max-width: 100%;
    height: auto;
}

/* =========================================================
   ADULT CHAT THEME + MOBILE APP LAYOUT FIX (login match)
   ========================================================= */
:root {
    --red: #ff2d6a;
    --dark-red: #c41a4a;
    --black: #0d0d0d;
    --dark: #12080c;
    --gray: #1a0a10;
    --light-gray: #241018;
    --white: #ffeeee;
    --yellow: #ff6b9d;
    --pink: #ff6b9d;
    --text: #ffeeee;
    --text-muted: #ccaaaa;
    --header-h: 56px;
    --footer-h: 34px;
    --sidebar-w: 270px;
    --right-w: 280px;
}

html, body, .spa-body {
    background: radial-gradient(ellipse at top, #2a0a14 0%, #0d0d0d 55%, #080508 100%) !important;
    color: var(--text) !important;
    min-height: 100%;
    height: 100%;
    overflow: hidden !important; /* app shell — only panels scroll */
}

.spa-header {
    background: linear-gradient(180deg, #1a0a10 0%, #12080c 100%) !important;
    border-bottom: 2px solid rgba(255, 107, 157, 0.45) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
.spa-header .logo {
    color: #fff !important;
    font-size: 1.05rem;
}
.spa-header .logo span { color: var(--pink) !important; }
.header-center { color: var(--pink) !important; }

.spa-footer {
    background: linear-gradient(90deg, #0a0508 0%, #160a10 50%, #0a0508 100%) !important;
    border-top: 1px solid rgba(255,107,157,0.3) !important;
    color: #cc8899 !important;
}

/* Layout: header + flex row; only main scrolls */
.spa-layout {
    display: flex !important;
    height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
    max-height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
    overflow: hidden !important;
    position: relative;
}

.sidebar {
    background: linear-gradient(180deg, #14080c, #0d0d0d) !important;
    border-right: 1px solid rgba(255,107,157,0.2) !important;
}

.nav-item { color: #ffdddd !important; }
.nav-item:hover { background: rgba(255,107,157,0.12) !important; color: #fff !important; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(255,45,106,0.35), rgba(255,107,157,0.12)) !important;
    color: var(--yellow) !important;
    border-left: 3px solid var(--pink) !important;
}
.side-title { color: var(--pink) !important; }

.main-content {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: transparent !important;
    padding: 12px !important;
    -webkit-overflow-scrolling: touch;
}

.right-panel {
    background: linear-gradient(180deg, #14080c, #0d0d0d) !important;
    border-left: 1px solid rgba(255,107,157,0.2) !important;
}

/* Cards / chat */
.card {
    background: linear-gradient(160deg, rgba(26,10,16,0.95), rgba(13,13,13,0.95)) !important;
    border: 1px solid rgba(255,107,157,0.28) !important;
    border-radius: 14px !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.card h2, .card h3 { color: var(--pink) !important; }

.chat-layout, .chat-main, .chat-list-panel {
    background: rgba(13, 8, 12, 0.55) !important;
    border-color: rgba(255,107,157,0.2) !important;
}
.chat-top, .chat-input-bar {
    background: rgba(18, 8, 12, 0.9) !important;
    border-color: rgba(255,107,157,0.25) !important;
}
.msg.me {
    background: linear-gradient(135deg, rgba(255,45,106,0.25), rgba(255,107,157,0.15)) !important;
    border: 1px solid rgba(255,107,157,0.35) !important;
}
.msg.other {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
}
.msg.system, .room-rules-msg {
    background: rgba(29,161,242,0.1) !important;
    border: 1px solid rgba(29,161,242,0.3) !important;
}

input, textarea, select {
    background: #1a0a10 !important;
    border: 1px solid rgba(255,107,157,0.35) !important;
    color: #ffeeee !important;
    border-radius: 10px !important;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--pink) !important;
    box-shadow: 0 0 0 2px rgba(255,107,157,0.2);
}

.btn, button.btn {
    background: linear-gradient(90deg, #ff2d6a, #ff6b9d) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
}
.btn-outline {
    background: transparent !important;
    border: 1px solid rgba(255,107,157,0.5) !important;
    color: var(--pink) !important;
}
.btn-danger {
    background: linear-gradient(90deg, #c0392b, #e74c3c) !important;
}
.icon-btn {
    background: #1a0a10 !important;
    border: 1px solid rgba(255,204,0,0.45) !important;
    color: var(--yellow) !important;
    border-radius: 10px !important;
}
.icon-btn:hover { background: rgba(255,107,157,0.2) !important; }

/* Emoji picker — floating panel, not full page */
.emoji-picker {
    position: fixed !important;
    left: 50% !important;
    bottom: 70px !important;
    transform: translateX(-50%) !important;
    width: min(340px, 92vw) !important;
    max-height: 220px !important;
    overflow-y: auto !important;
    background: #1a0a10 !important;
    border: 1px solid rgba(255,107,157,0.45) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55) !important;
    z-index: 5000 !important;
    padding: 10px !important;
}
.emoji-picker.hidden { display: none !important; }
.emoji-grid {
    display: grid !important;
    grid-template-columns: repeat(8, 1fr) !important;
    gap: 4px !important;
}

/* Modals — only one layer, full overlay */
.popup-modal,
#chat-settings-modal,
#room-tools-modal,
.settings-modal {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.65) !important;
    z-index: 4000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
}
.popup-modal.hidden,
#chat-settings-modal.hidden,
#room-tools-modal.hidden,
.settings-modal.hidden {
    display: none !important;
}
.popup-modal-inner,
.settings-modal-inner,
.room-tools-inner {
    background: linear-gradient(160deg, #1a0a10, #0d0d0d) !important;
    border: 1px solid rgba(255,107,157,0.4) !important;
    border-radius: 16px !important;
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 16px !important;
    color: var(--text);
}

/* Mobile: sidebar as drawer */
@media (max-width: 900px) {
    .spa-layout {
        display: flex !important;
        flex-direction: row !important;
        height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
        max-height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
        overflow: hidden !important;
    }
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: var(--header-h) !important;
        bottom: var(--footer-h) !important;
        width: min(82vw, 280px) !important;
        transform: translateX(-105%) !important;
        z-index: 300 !important;
        transition: transform 0.25s ease !important;
        box-shadow: 8px 0 30px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0) !important; }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-h);
        background: rgba(0,0,0,0.5);
        z-index: 250;
    }
    .sidebar-backdrop.show { display: block; }
    .main-content {
        width: 100% !important;
        height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
        max-height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
    }
    .right-panel {
        position: fixed !important;
        right: 0 !important;
        top: var(--header-h) !important;
        bottom: var(--footer-h) !important;
        width: min(88vw, 300px) !important;
        transform: translateX(105%) !important;
        z-index: 300 !important;
        transition: transform 0.25s ease !important;
    }
    .right-panel.open { transform: translateX(0) !important; }
    .user-chip .uname { display: none !important; }
    .header-center { display: none !important; }
}

/* Online corner */
.online-corner {
    background: rgba(18,8,12,0.92) !important;
    border: 1px solid rgba(255,107,157,0.35) !important;
}


/* When a chat is open on mobile — hide the list so "Loading" doesn't stick on top */
@media (max-width: 900px) {
    .chat-list-panel.hidden-on-chat { display: none !important; }
    .chat-layout.conversation-open {
        flex-direction: column;
        height: calc(100vh - var(--header-h) - var(--footer-h) - 20px) !important;
        min-height: 0 !important;
    }
    .chat-layout.conversation-open .chat-main {
        min-height: 0 !important;
        flex: 1;
        height: 100%;
    }
}


/* ===== Header action badges ===== */
.header-right .icon-btn { position: relative; }
.header-right .bell-count {
    position: absolute; top: -2px; right: -2px;
    background: #ff2d6a; color: #fff;
    font-size: 0.62rem; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; line-height: 1;
}

/* ===== Online dropdown from header ===== */
.online-dropdown {
    position: fixed;
    top: calc(var(--header-h) + 6px);
    right: 12px;
    width: min(280px, 92vw);
    max-height: 60vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #1a0a12, #0d080c);
    border: 1px solid rgba(255,77,141,0.35);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
    z-index: 500;
    padding: 0 0 8px;
}
.online-dropdown.hidden { display: none !important; }
.od-head {
    padding: 12px 14px;
    font-weight: 700;
    color: #ffb0c8;
    border-bottom: 1px solid rgba(255,77,141,0.2);
    display: flex; align-items: center; gap: 8px;
}
.od-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    color: #ffeef4;
}
.od-user:hover { background: rgba(255,77,141,0.12); }
.od-user img, .od-user .letter {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover;
}
.od-user .letter {
    background: #ff4d8d; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.od-link {
    display: block; text-align: center;
    padding: 10px; color: #ff6b9d; font-size: 0.85rem;
}

/* Hide old floating corners if still in DOM */
.staff-corner, .online-corner { display: none !important; }

/* Popup reply + actions */
.popup-modal-reply {
    display: flex; gap: 8px; padding: 10px 14px 6px;
    border-top: 1px solid rgba(255,77,141,0.2);
}
.popup-modal-reply input {
    flex: 1; padding: 10px 12px;
}
.popup-modal-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 6px 14px 14px;
}
.popup-modal-actions .btn-outline {
    background: transparent;
    border: 1px solid rgba(255,107,157,0.4);
    color: #ffb0c8;
}
.popup-modal-actions .btn-danger {
    background: linear-gradient(180deg, #ff6b6b, #c0392b);
    border: none; color: #fff;
}

/* Chat input always at bottom of chat area */
.chat-main {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0;
}
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}
.chat-input-bar {
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

/* Light mode basics */
body.light-mode {
    background: #f5eef1 !important;
    color: #2a1520 !important;
}
body.light-mode .spa-header {
    background: #fff !important;
    border-bottom-color: #ff6b9d !important;
}
body.light-mode .spa-footer {
    background: #fff !important;
    color: #884466 !important;
}
body.light-mode .sidebar {
    background: #fff5f8 !important;
}
body.light-mode .main-content,
body.light-mode .card {
    background: #fff !important;
    color: #2a1520 !important;
}


/* =========================================================
   v1.1.5 FORCE ADULT DARK-PINK THEME (overrides all old red/yellow)
   ========================================================= */
body.spa-body,
body {
    background: #0a0508 !important;
    color: #ffeeee !important;
}
.spa-header {
    background: linear-gradient(180deg, #1a0a12 0%, #10060c 100%) !important;
    border-bottom: 2px solid rgba(255, 77, 141, 0.45) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}
.spa-header .logo,
.spa-header .logo span {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: none !important;
}
.spa-header .logo span { color: #ff6b9d !important; -webkit-text-fill-color: #ff6b9d !important; }
.header-center { color: #ff6b9d !important; }
.icon-btn { color: #ffb0c8 !important; }
.icon-btn:hover { background: rgba(255,77,141,0.2) !important; color: #fff !important; }

.spa-footer {
    background: linear-gradient(90deg, #0a0508, #160a10, #0a0508) !important;
    border-top: 1px solid rgba(255,77,141,0.3) !important;
    color: #cc8899 !important;
}

.sidebar {
    background: linear-gradient(180deg, #14080c, #0d0d0d) !important;
    border-right: 1px solid rgba(255,107,157,0.25) !important;
}
.nav-item { color: #e8c0d0 !important; }
.nav-item:hover, .nav-item.active {
    background: rgba(255,45,106,0.15) !important;
    color: #ff6b9d !important;
    border-left-color: #ff4d8d !important;
}
.nav-item.admin-link { color: #ffcc66 !important; }
.side-title { color: #ff6b9d !important; }

.main-content {
    background: #0a0508 !important;
}
.card {
    background: linear-gradient(160deg, rgba(26,10,16,0.97), rgba(12,6,10,0.98)) !important;
    border: 1px solid rgba(255,107,157,0.28) !important;
    border-radius: 14px !important;
}
.card h2, .card h3 { color: #ff6b9d !important; }

.btn, button.btn {
    background: linear-gradient(135deg, #ff2d6a, #ff5a9a) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
}
.btn:hover { filter: brightness(1.08); }

.chat-layout, .chat-main, .chat-list-panel {
    background: rgba(10, 5, 8, 0.9) !important;
    border-color: rgba(255,107,157,0.22) !important;
}
.chat-list-header .tab.active {
    background: linear-gradient(135deg, #ff2d6a, #ff5a9a) !important;
    color: #fff !important;
}
.chat-top, .chat-input-bar {
    background: rgba(18, 8, 12, 0.95) !important;
    border-color: rgba(255,107,157,0.25) !important;
}
.chat-top .title { color: #ff6b9d !important; }
.tool-btn.send {
    background: #ff4d8d !important;
    color: #fff !important;
}
.msg.me {
    background: linear-gradient(135deg, rgba(255,45,106,0.28), rgba(255,107,157,0.15)) !important;
    border: 1px solid rgba(255,107,157,0.35) !important;
}
.msg.other {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
}

input, textarea, select {
    background: #1a0a10 !important;
    border: 1px solid rgba(255,107,157,0.35) !important;
    color: #ffeeee !important;
    border-radius: 10px !important;
}

.user-chip { color: #ffeeee !important; }
.role-badge.badge-owner {
    background: linear-gradient(90deg, #ff4d8d, #ff2d6a) !important;
    color: #fff !important;
}

/* Kill leftover pure yellow accents */
.tool-btn.send,
.btn-primary,
.online-dot { }


/* =========================================================
   v1.1.5 LAYOUT FIX — no stacking, clean mobile SPA
   ========================================================= */
html, body.spa-body {
    height: 100% !important;
    height: 100dvh !important;
    overflow: hidden !important;
}
body.spa-body {
    display: flex !important;
    flex-direction: column !important;
    background: #0a0508 !important;
}
.spa-header {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 200 !important;
}
.spa-footer {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 200 !important;
}
.spa-layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    overflow: hidden !important;
    height: auto !important;
    max-height: none !important;
}
.main-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 8px !important;
    background: #0a0508 !important;
}
.sidebar {
    flex-shrink: 0 !important;
}

/* Chat fills main area cleanly */
.main-content > .chat-layout {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}
.chat-layout.conversation-open .chat-list-panel {
    display: none !important;
}
.chat-layout.conversation-open .chat-main {
    width: 100% !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}
.chat-messages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}
.chat-input-bar {
    flex-shrink: 0 !important;
}

@media (max-width: 900px) {
    .spa-layout {
        display: flex !important;
        flex-direction: row !important;
    }
    .main-content {
        width: 100% !important;
        padding: 6px !important;
    }
    /* On mobile list view: only list, hide empty main placeholder */
    .chat-layout:not(.conversation-open) {
        flex-direction: column !important;
        height: 100% !important;
    }
    .chat-layout:not(.conversation-open) .chat-list-panel {
        width: 100% !important;
        flex: 1 !important;
        border-right: none !important;
    }
    .chat-layout:not(.conversation-open) .chat-main {
        display: none !important;
    }
    .chat-layout.conversation-open {
        height: 100% !important;
        min-height: 0 !important;
    }
    .chat-layout.conversation-open .chat-list-panel {
        display: none !important;
    }
    .chat-layout.conversation-open .chat-main {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        min-height: 0 !important;
    }
}

/* Hide broken floating leftovers */
.staff-corner, .online-corner { display: none !important; }


/* v1.1.6 — typing box always visible */
.chat-main, #chat-main-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
}
.chat-input-bar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 60 !important;
    min-height: 56px !important;
    width: 100% !important;
    background: #160a10 !important;
    border-top: 1px solid rgba(255, 107, 157, 0.4) !important;
    padding: 10px 12px !important;
    gap: 8px !important;
    align-items: center !important;
    box-sizing: border-box !important;
}
.chat-input-bar textarea,
#chat-input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1 !important;
    min-height: 42px !important;
    font-size: 16px !important;
    background: #1a0a10 !important;
    color: #ffeeee !important;
    border: 1px solid rgba(255, 107, 157, 0.45) !important;
    border-radius: 12px !important;
    padding: 12px 14px !important;
}
.chat-messages, #chat-messages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}
@media (max-width: 900px) {
    .chat-layout.conversation-open,
    .chat-layout.conversation-open .chat-main,
    .chat-layout.conversation-open #chat-main-area {
        height: 100% !important;
        max-height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .chat-input-bar {
        position: sticky !important;
        bottom: 0 !important;
    }
}


/* v1.1.8 — chat input fixed above footer, always visible */
.chat-input-bar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 36px !important;
    z-index: 180 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 56px !important;
    background: #160a10 !important;
    border-top: 1px solid rgba(255, 107, 157, 0.45) !important;
    padding: 10px 12px !important;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.45) !important;
}
#chat-messages, .chat-messages {
    padding-bottom: 90px !important;
}
.spa-footer {
    z-index: 190 !important;
}


/* PM unread + seen */
.pm-unread {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ff2d6a !important;
    color: #fff !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    margin-left: 6px;
}
.chat-item.has-unread {
    background: rgba(255, 45, 106, 0.12) !important;
    border-left: 3px solid #ff4d8d;
}
.msg-seen { color: #4fc3f7; letter-spacing: -2px; font-size: 0.85rem; }
.msg-sent { color: #888; letter-spacing: -2px; font-size: 0.85rem; }


/* v1.2.6 layout polish */
.spa-footer {
    height: 40px !important;
    min-height: 40px !important;
    background: linear-gradient(90deg, #0a0508, #14080e, #0a0508) !important;
    border-top: 1px solid rgba(255,77,141,0.35) !important;
    font-size: 0.78rem !important;
}
.footer-brand { color: #ffb0c8 !important; font-weight: 600 !important; }
.footer-status { color: #6fdd8b !important; }

/* Private PM: never show room list on the side */
.chat-layout.conversation-open .chat-list-panel,
body.pm-mode .chat-list-panel {
    display: none !important;
}
.chat-layout.conversation-open .chat-main {
    width: 100% !important;
    flex: 1 !important;
}

@media (min-width: 901px) {
    .main-content { padding: 14px 18px !important; }
    .chat-layout { min-height: calc(100vh - 100px); }
    .sidebar { width: 280px !important; }
}

@media (max-width: 900px) {
    .main-content { padding: 6px !important; }
    .chat-top .title { font-size: 1rem !important; }
}

#spa-confirm-modal:not(.hidden) {
    display: flex !important;
}


/* =========================================================
   LIGHT MODE — Premium Soft Pink / White (v1.2.7)
   ========================================================= */
body.light-mode {
    --lm-bg: #faf5f7;
    --lm-surface: #ffffff;
    --lm-surface-2: #fff7fa;
    --lm-border: rgba(255, 77, 141, 0.18);
    --lm-text: #2a1520;
    --lm-muted: #8a6575;
    --lm-pink: #e91e63;
    --lm-pink-soft: #ff5a9a;
    --lm-header: #ffffff;
    background: var(--lm-bg) !important;
    color: var(--lm-text) !important;
}

body.light-mode .spa-header {
    background: linear-gradient(180deg, #ffffff 0%, #fff5f8 100%) !important;
    border-bottom: 2px solid rgba(233, 30, 99, 0.28) !important;
    box-shadow: 0 2px 12px rgba(233, 30, 99, 0.08) !important;
}
body.light-mode .header-center,
body.light-mode .header-center#header-title {
    color: var(--lm-pink) !important;
}
body.light-mode .icon-btn {
    background: rgba(233, 30, 99, 0.06) !important;
    border: 1px solid rgba(233, 30, 99, 0.2) !important;
    color: #c2185b !important;
}
body.light-mode .icon-btn:hover {
    background: rgba(233, 30, 99, 0.14) !important;
    color: #ad1457 !important;
}
body.light-mode .bell-count {
    background: #e91e63 !important;
    color: #fff !important;
}
body.light-mode .header-avatar {
    border-color: rgba(233, 30, 99, 0.45) !important;
    background: #ffe0ec !important;
}
body.light-mode .header-avatar .av-letter {
    color: #ad1457 !important;
}

/* Sidebar */
body.light-mode .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #fff8fb 100%) !important;
    border-right: 1px solid var(--lm-border) !important;
    box-shadow: 4px 0 20px rgba(233, 30, 99, 0.05) !important;
}
body.light-mode .nav-item {
    color: #4a2a38 !important;
}
body.light-mode .nav-item:hover {
    background: rgba(233, 30, 99, 0.08) !important;
    color: var(--lm-pink) !important;
}
body.light-mode .nav-item.active {
    background: linear-gradient(90deg, rgba(233, 30, 99, 0.14), rgba(255, 90, 154, 0.08)) !important;
    color: var(--lm-pink) !important;
    border-left: 3px solid var(--lm-pink) !important;
}
body.light-mode .nav-item.admin-link {
    color: #c62828 !important;
}
body.light-mode .side-title {
    color: var(--lm-pink) !important;
}
body.light-mode .sidebar-backdrop.show {
    background: rgba(42, 21, 32, 0.35) !important;
}

/* Main */
body.light-mode .main-content {
    background: var(--lm-bg) !important;
}
body.light-mode .card,
body.light-mode .profile-card {
    background: var(--lm-surface) !important;
    border: 1px solid var(--lm-border) !important;
    box-shadow: 0 4px 18px rgba(233, 30, 99, 0.06) !important;
    color: var(--lm-text) !important;
}
body.light-mode .card h2,
body.light-mode .card h3 {
    color: var(--lm-pink) !important;
    border-bottom-color: rgba(233, 30, 99, 0.15) !important;
}
body.light-mode .text-muted {
    color: var(--lm-muted) !important;
}
body.light-mode a {
    color: var(--lm-pink) !important;
}
body.light-mode a:hover {
    color: #ad1457 !important;
}

/* Forms */
body.light-mode label {
    color: var(--lm-muted) !important;
}
body.light-mode input[type="text"],
body.light-mode input[type="email"],
body.light-mode input[type="password"],
body.light-mode input[type="file"],
body.light-mode textarea,
body.light-mode select {
    background: #fff !important;
    border: 1px solid rgba(233, 30, 99, 0.22) !important;
    color: var(--lm-text) !important;
}
body.light-mode input:focus,
body.light-mode textarea:focus,
body.light-mode select:focus {
    border-color: var(--lm-pink) !important;
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.12) !important;
}
body.light-mode .btn,
body.light-mode button[type="submit"] {
    background: linear-gradient(135deg, #e91e63, #ff5a9a) !important;
    color: #fff !important;
    border: none !important;
}
body.light-mode .btn-outline {
    background: transparent !important;
    border: 1px solid var(--lm-pink) !important;
    color: var(--lm-pink) !important;
}
body.light-mode .btn-danger {
    background: linear-gradient(135deg, #e53935, #ef5350) !important;
    color: #fff !important;
}

/* Chat */
body.light-mode .chat-layout {
    background: var(--lm-surface) !important;
    border: 1px solid var(--lm-border) !important;
    box-shadow: 0 4px 20px rgba(233, 30, 99, 0.06) !important;
}
body.light-mode .chat-list-panel {
    background: var(--lm-surface-2) !important;
    border-right: 1px solid var(--lm-border) !important;
}
body.light-mode .chat-list-header .tab {
    color: var(--lm-muted) !important;
}
body.light-mode .chat-list-header .tab.active {
    background: linear-gradient(135deg, #e91e63, #ff5a9a) !important;
    color: #fff !important;
}
body.light-mode .chat-item:hover {
    background: rgba(233, 30, 99, 0.06) !important;
}
body.light-mode .chat-item.active,
body.light-mode .chat-item.has-unread {
    background: rgba(233, 30, 99, 0.1) !important;
}
body.light-mode .chat-item .name {
    color: var(--lm-text) !important;
}
body.light-mode .chat-item .preview {
    color: var(--lm-muted) !important;
}
body.light-mode .chat-item .letter {
    background: #ffe0ec !important;
    color: #ad1457 !important;
}
body.light-mode .chat-top {
    background: #fff !important;
    border-bottom: 1px solid var(--lm-border) !important;
}
body.light-mode .chat-top .title {
    color: var(--lm-pink) !important;
}
body.light-mode .chat-messages {
    background: var(--lm-bg) !important;
}
body.light-mode .msg.other {
    background: #fff !important;
    color: var(--lm-text) !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
}
body.light-mode .msg.me {
    background: linear-gradient(135deg, #ffe4ee, #fff0f5) !important;
    border: 1px solid rgba(233, 30, 99, 0.25) !important;
    color: var(--lm-text) !important;
}
body.light-mode .msg.system {
    background: rgba(233, 30, 99, 0.06) !important;
    color: var(--lm-muted) !important;
}
body.light-mode .msg .author {
    color: var(--lm-pink) !important;
}
body.light-mode .msg .time {
    color: var(--lm-muted) !important;
}
body.light-mode .chat-input-bar {
    background: #ffffff !important;
    border-top: 1px solid var(--lm-border) !important;
    box-shadow: 0 -4px 16px rgba(233, 30, 99, 0.06) !important;
}
body.light-mode .chat-input-bar textarea,
body.light-mode #chat-input {
    background: #faf5f7 !important;
    border: 1px solid rgba(233, 30, 99, 0.25) !important;
    color: var(--lm-text) !important;
}
body.light-mode .tool-btn {
    background: rgba(233, 30, 99, 0.08) !important;
    color: #c2185b !important;
}
body.light-mode .tool-btn.send,
body.light-mode #btn-send {
    background: linear-gradient(135deg, #e91e63, #ff5a9a) !important;
    color: #fff !important;
}

/* Footer */
body.light-mode .spa-footer {
    background: linear-gradient(90deg, #ffffff, #fff5f8, #ffffff) !important;
    border-top: 1px solid var(--lm-border) !important;
    color: var(--lm-muted) !important;
}
body.light-mode .footer-brand {
    color: var(--lm-pink) !important;
}
body.light-mode .footer-status {
    color: #2e7d32 !important;
}

/* Modals / popups / toasts */
body.light-mode .popup-modal {
    background: rgba(42, 21, 32, 0.45) !important;
}
body.light-mode .popup-modal-inner,
body.light-mode #spa-confirm-modal .popup-modal-inner {
    background: #ffffff !important;
    border: 1px solid var(--lm-border) !important;
    color: var(--lm-text) !important;
    box-shadow: 0 20px 50px rgba(233, 30, 99, 0.15) !important;
}
body.light-mode .toast {
    background: #ffffff !important;
    border: 1px solid var(--lm-border) !important;
    color: var(--lm-text) !important;
    box-shadow: 0 8px 28px rgba(233, 30, 99, 0.15) !important;
}
body.light-mode .toast-title {
    color: var(--lm-pink) !important;
}

/* Tables / admin */
body.light-mode .admin-table th {
    background: #ffe4ee !important;
    color: #ad1457 !important;
}
body.light-mode .admin-table td {
    border-color: rgba(233, 30, 99, 0.1) !important;
    color: var(--lm-text) !important;
}
body.light-mode .admin-tabs .tab {
    color: var(--lm-muted) !important;
}
body.light-mode .admin-tabs .tab.active {
    background: linear-gradient(135deg, #e91e63, #ff5a9a) !important;
    color: #fff !important;
}

/* Profile stats */
body.light-mode .profile-stats > div {
    background: #fff7fa !important;
    border: 1px solid var(--lm-border) !important;
}
body.light-mode .member-card {
    background: #fff !important;
    border: 1px solid var(--lm-border) !important;
}
body.light-mode .member-card .letter {
    background: #ffe0ec !important;
    color: #ad1457 !important;
}

/* Online dropdown */
body.light-mode .online-dropdown {
    background: #ffffff !important;
    border: 1px solid var(--lm-border) !important;
    box-shadow: 0 12px 32px rgba(233, 30, 99, 0.12) !important;
    color: var(--lm-text) !important;
}
body.light-mode .od-head {
    color: var(--lm-pink) !important;
    border-bottom: 1px solid var(--lm-border) !important;
}

/* Right panel */
body.light-mode .right-panel {
    background: #ffffff !important;
    border-left: 1px solid var(--lm-border) !important;
}
body.light-mode .panel-header {
    color: var(--lm-pink) !important;
    border-bottom: 1px solid var(--lm-border) !important;
}

/* Loading */
body.light-mode .loading-spinner {
    color: var(--lm-pink) !important;
}

/* Room rules */
body.light-mode .room-rules-msg {
    background: #e3f2fd !important;
    border: 1px solid #90caf9 !important;
}
body.light-mode .room-rules-msg .text {
    color: #0d47a1 !important;
}

/* Critical inline overrides when light */
body.light-mode.spa-body {
    background: var(--lm-bg) !important;
    color: var(--lm-text) !important;
}


/* ===== v1.2.8 MODERN UI BOOST ===== */
.spa-header {
    backdrop-filter: blur(12px) !important;
}
.card, .profile-card, .chat-layout {
    border-radius: 16px !important;
}
.btn, .icon-btn, .tool-btn {
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease !important;
}
.btn:active, .icon-btn:active, .tool-btn:active {
    transform: scale(0.96) !important;
}
.chat-item, .nav-item, .member-card {
    transition: background 0.15s ease, transform 0.12s ease !important;
    border-radius: 12px !important;
}
.msg {
    border-radius: 14px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}
.popup-modal-inner {
    border-radius: 18px !important;
    box-shadow: 0 24px 60px rgba(255,45,106,0.2) !important;
}
.chat-list-header .tab.active {
    border-radius: 10px !important;
}
#chat-input, .chat-input-bar textarea {
    border-radius: 14px !important;
}
.popup-modal:not(.hidden) {
    display: flex !important;
}


/* ===== v1.3.0 APP-STYLE DESIGN ===== */
:root {
    --pink: #ff3d7f !important;
    --pink-soft: #ff6b9d !important;
    --black: #0c0610 !important;
}
body.spa-body, body {
    background: #0c0610 !important;
}
.spa-header {
    background: linear-gradient(135deg, #1a0a18, #2d1235, #1a0a18) !important;
    border-bottom: 2px solid #ff2d6a !important;
    box-shadow: 0 4px 24px rgba(255,45,106,0.22) !important;
}
.card, .profile-card {
    background: linear-gradient(165deg, rgba(30,12,24,0.98), rgba(14,8,16,0.99)) !important;
    border: 1px solid rgba(255,61,127,0.28) !important;
    border-radius: 18px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
}
.btn {
    background: linear-gradient(135deg, #ff2d6a, #ff5a9a) !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 14px rgba(255,45,106,0.3) !important;
}
.chat-layout {
    border-radius: 18px !important;
    border: 1px solid rgba(255,61,127,0.25) !important;
    overflow: hidden !important;
}
.chat-list-header .tab.active {
    background: linear-gradient(135deg, #ff2d6a, #ff5a9a) !important;
    border-radius: 12px !important;
}
.msg.me {
    background: linear-gradient(135deg, #ff2d6a, #e91e63) !important;
    color: #fff !important;
    border: none !important;
}
.msg.other {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
}
.sidebar {
    background: linear-gradient(180deg, #140a12, #0c0610) !important;
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(255,45,106,0.25), transparent) !important;
    color: #ff6b9d !important;
    border-left: 3px solid #ff2d6a !important;
}
.spa-footer {
    background: linear-gradient(90deg, #0c0610, #1a0c14, #0c0610) !important;
    border-top: 1px solid rgba(255,45,106,0.35) !important;
}
.popup-modal-inner {
    background: linear-gradient(165deg, #1e0c18, #120810) !important;
    border: 1px solid rgba(255,61,127,0.4) !important;
    border-radius: 20px !important;
}


/* Ad slots */
.site-ad, [data-ad-slot] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 8px 0 !important;
    overflow: hidden !important;
    text-align: center !important;
}
.site-ad img, [data-ad-slot] img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 10px !important;
}
#chat-main-area [data-ad-slot="chat_top"],
#chat-main-area [data-ad-slot="chat_bottom"] {
    flex-shrink: 0 !important;
    padding: 4px 6px !important;
}

@media (max-width:900px){
  .chat-input-bar{position:sticky;bottom:0;z-index:40;}
  .msg{max-width:90%;}
  .site-ad,[data-ad-slot]{padding:0 4px;}
}

/* v1.3.3 visible redesign */
.spa-header { border-bottom-color: #00e5ff !important; }
.logo span { color: #00e5ff !important; }
.nav-item.active { border-left-color: #00e5ff !important; color: #7df9ff !important; }
.btn { background: linear-gradient(135deg, #ff2d6a, #c026ff) !important; }


/* ========== v1.3.6 MODERN APP UI ========== */
html, body.spa-body {
  font-size: 16px !important;
}
.spa-header {
  height: 60px !important;
  padding: 0 16px !important;
}
.logo {
  font-size: 1.25rem !important;
  letter-spacing: -0.02em !important;
}
.icon-btn {
  width: 42px !important;
  height: 42px !important;
  border-radius: 14px !important;
}
.header-avatar {
  width: 40px !important;
  height: 40px !important;
}
.sidebar {
  width: 300px !important;
}
.nav-item {
  padding: 14px 16px !important;
  font-size: 1rem !important;
  border-radius: 12px !important;
  margin: 2px 8px !important;
}
.main-content {
  padding: 16px !important;
}
.card {
  border-radius: 20px !important;
  padding: 20px !important;
  margin-bottom: 16px !important;
}
.card h2 {
  font-size: 1.35rem !important;
  margin-bottom: 14px !important;
}

/* Full-height modern chat */
.chat-layout {
  height: calc(100vh - 100px) !important;
  height: calc(100dvh - 100px) !important;
  border-radius: 20px !important;
  overflow: hidden !important;
  display: flex !important;
}
.chat-list-panel {
  width: 320px !important;
  max-width: 40% !important;
}
.chat-main, #chat-main-area {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  min-height: 0 !important;
}
.chat-top {
  padding: 14px 16px !important;
  font-size: 1.05rem !important;
  flex-shrink: 0 !important;
}
.chat-messages, #chat-messages {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  padding: 16px !important;
  gap: 10px !important;
  display: flex !important;
  flex-direction: column !important;
}
.msg {
  max-width: 75% !important;
  padding: 12px 16px !important;
  border-radius: 18px !important;
  font-size: 1rem !important;
  line-height: 1.45 !important;
  margin-bottom: 6px !important;
}
.msg.me {
  align-self: flex-end !important;
  border-bottom-right-radius: 6px !important;
}
.msg.other {
  align-self: flex-start !important;
  border-bottom-left-radius: 6px !important;
}
.msg .author {
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  margin-bottom: 4px !important;
}
.chat-input-bar {
  display: flex !important;
  align-items: flex-end !important;
  gap: 10px !important;
  padding: 12px 14px !important;
  flex-shrink: 0 !important;
  border-top: 1px solid rgba(255,77,141,0.2) !important;
}
#chat-input {
  flex: 1 !important;
  min-height: 48px !important;
  max-height: 120px !important;
  font-size: 1rem !important;
  padding: 12px 14px !important;
  border-radius: 16px !important;
}
.tool-btn, #btn-send {
  width: 48px !important;
  height: 48px !important;
  border-radius: 16px !important;
  font-size: 1.1rem !important;
}

/* PM / conversation: hide rooms list completely */
.chat-layout.conversation-open .chat-list-panel,
body.pm-mode .chat-list-panel,
body.room-mode .chat-list-panel {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
.chat-layout.conversation-open .chat-main,
body.pm-mode .chat-main,
body.room-mode #chat-main-area {
  width: 100% !important;
  flex: 1 1 100% !important;
  max-width: 100% !important;
}

@media (max-width: 900px) {
  .sidebar { width: 86vw !important; max-width: 320px !important; }
  .main-content { padding: 6px !important; }
  .chat-layout {
    height: calc(100dvh - 92px) !important;
    border-radius: 0 !important;
  }
  .msg { max-width: 88% !important; font-size: 0.98rem !important; }
  .chat-input-bar {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 80 !important;
  }
  #chat-input { font-size: 16px !important; min-height: 46px !important; }
}

/* Light mode modern */
body.light-mode .chat-layout {
  box-shadow: 0 8px 40px rgba(233,30,99,0.1) !important;
  border: 1px solid rgba(233,30,99,0.15) !important;
}
body.light-mode .msg.me {
  background: linear-gradient(135deg, #ff2d6a, #ff5a9a) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(255,45,106,0.25) !important;
}
body.light-mode .chat-input-bar {
  background: #fff !important;
}

/* ========================================
   v1.3.7 — Friendly redesign + message avatars
   Soft modern dark theme (teal + soft rose)
   ======================================== */
:root {
    --red: #ff4d8d;
    --dark-red: #c2185b;
    --pink: #ff7eb3;
    --pink-soft: #ffb3d1;
    --black: #0b0f1a;
    --dark: #12182a;
    --gray: #1a2238;
    --light-gray: #24304a;
    --white: #f0f4ff;
    --yellow: #5eead4;
    --yellow-dim: #2dd4bf;
    --text: #e8eefc;
    --text-muted: #94a3b8;
    --success: #34d399;
    --danger: #f87171;
    --accent: #5eead4;
    --accent2: #a78bfa;
    --msg-me-bg: linear-gradient(135deg, #1e3a5f 0%, #0f2744 100%);
    --msg-other-bg: rgba(30, 40, 65, 0.85);
    --sidebar-w: 260px;
    --right-w: 280px;
    --header-h: 56px;
    --footer-h: 38px;
    --radius: 14px;
}

body, .spa-body {
    background: #0b0f1a !important;
    color: var(--text) !important;
}

/* Header friendlier */
.spa-header, .header {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%) !important;
    border-bottom: 2px solid var(--accent) !important;
    box-shadow: 0 4px 20px rgba(94, 234, 212, 0.12) !important;
}
.logo span { color: var(--accent) !important; }
.header-center { color: var(--pink-soft) !important; }

/* Sidebar / Menu completely restyled */
.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%) !important;
    border-right: 1px solid rgba(94, 234, 212, 0.12) !important;
}
.nav-item {
    color: #cbd5e1 !important;
    border-radius: 12px !important;
    margin: 3px 8px !important;
    padding: 11px 14px !important;
    font-weight: 500 !important;
    transition: all 0.18s ease !important;
    border: 1px solid transparent !important;
}
.nav-item i {
    width: 22px !important;
    color: var(--accent) !important;
    opacity: 0.9 !important;
}
.nav-item:hover {
    background: rgba(94, 234, 212, 0.1) !important;
    color: #fff !important;
    border-color: rgba(94, 234, 212, 0.2) !important;
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(94, 234, 212, 0.18), rgba(167, 139, 250, 0.12)) !important;
    color: #fff !important;
    border-color: rgba(94, 234, 212, 0.35) !important;
    box-shadow: 0 2px 12px rgba(94, 234, 212, 0.15) !important;
}
.nav-item.admin-link { color: #fbbf24 !important; }
.nav-item.admin-link.active { color: #fde68a !important; }

/* Message with avatar row */
.msg {
    max-width: 82% !important;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}
.msg .msg-row {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
}
.msg.me .msg-row { flex-direction: row !important; justify-content: flex-end !important; }
.msg.other .msg-row { flex-direction: row !important; }
.msg-avatar {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    border: 2px solid rgba(94, 234, 212, 0.35) !important;
    background: #1e293b !important;
    cursor: pointer !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
}
.msg-avatar:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.35) !important;
}
.msg-avatar.letter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    color: #fff !important;
    background: linear-gradient(135deg, #6366f1, #a78bfa) !important;
}
.msg-body {
    max-width: calc(100% - 42px) !important;
    padding: 10px 14px !important;
    border-radius: 16px !important;
    line-height: 1.45 !important;
}
.msg.me .msg-body {
    background: var(--msg-me-bg) !important;
    border-bottom-right-radius: 4px !important;
    border: 1px solid rgba(94, 234, 212, 0.2) !important;
}
.msg.other .msg-body {
    background: var(--msg-other-bg) !important;
    border-bottom-left-radius: 4px !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
}
.msg .author {
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    margin-bottom: 3px !important;
    color: var(--accent) !important;
}
.msg .time {
    font-size: 0.72rem !important;
    opacity: 0.65 !important;
    margin-top: 4px !important;
}
.msg.system {
    align-self: center !important;
    max-width: 90% !important;
    background: rgba(167, 139, 250, 0.12) !important;
    border: 1px solid rgba(167, 139, 250, 0.25) !important;
    border-radius: 12px !important;
    padding: 8px 14px !important;
    text-align: center !important;
}

/* Chat input bar — always visible, friendly */
.chat-input-bar {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    flex-shrink: 0 !important;
    background: linear-gradient(180deg, #0f172a, #111827) !important;
    border-top: 1px solid rgba(94, 234, 212, 0.2) !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 60px !important;
    z-index: 50 !important;
}
#chat-input, .chat-input-bar textarea {
    flex: 1 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 44px !important;
    max-height: 110px !important;
    font-size: 0.98rem !important;
    padding: 11px 14px !important;
    border-radius: 14px !important;
    background: #1e293b !important;
    border: 1px solid rgba(94, 234, 212, 0.25) !important;
    color: #f1f5f9 !important;
    resize: none !important;
}
#chat-input:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.2) !important;
}
.tool-btn, #btn-send {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    background: rgba(94, 234, 212, 0.12) !important;
    border: 1px solid rgba(94, 234, 212, 0.3) !important;
    color: var(--accent) !important;
    flex-shrink: 0 !important;
}
#btn-send, .tool-btn.send {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: #fff !important;
    border: none !important;
}
#btn-send:hover { filter: brightness(1.1); }

/* Quick profile popup */
.qp-avatar {
    width: 88px !important;
    height: 88px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 3px solid var(--accent) !important;
    margin: 0 auto !important;
    display: block !important;
    background: #1e293b !important;
}
.qp-avatar.letter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 2rem !important;
    font-weight: 800 !important;
    color: #fff !important;
    background: linear-gradient(135deg, #6366f1, #a78bfa) !important;
}
.qp-card {
    background: linear-gradient(180deg, #1e1b4b, #0f172a) !important;
    border: 1px solid rgba(94, 234, 212, 0.25) !important;
    border-radius: 18px !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
}

/* Profile card best look */
.profile-card, .card.profile-card {
    background: linear-gradient(180deg, #1a2238 0%, #0f172a 100%) !important;
    border: 1px solid rgba(94, 234, 212, 0.2) !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
}
.profile-header {
    background: linear-gradient(135deg, rgba(94,234,212,0.12), rgba(167,139,250,0.1)) !important;
    padding: 24px 16px 16px !important;
}
.profile-header .avatar, .profile-header .letter {
    width: 100px !important;
    height: 100px !important;
    border-radius: 50% !important;
    border: 3px solid var(--accent) !important;
    box-shadow: 0 4px 20px rgba(94, 234, 212, 0.3) !important;
}
.profile-stats > div {
    background: rgba(15, 23, 42, 0.7) !important;
    border: 1px solid rgba(94, 234, 212, 0.15) !important;
    border-radius: 14px !important;
    transition: transform 0.15s !important;
}
.profile-stats > div:hover { transform: translateY(-2px); }

/* Buttons friendlier */
.btn {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    border: none !important;
    color: #fff !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
}
.btn-outline {
    background: transparent !important;
    border: 1px solid rgba(94, 234, 212, 0.4) !important;
    color: var(--accent) !important;
}
.btn-sm {
    border-radius: 8px !important;
    font-size: 0.8rem !important;
}

/* Chat top */
.chat-top {
    background: linear-gradient(90deg, #0f172a, #1e1b4b) !important;
    border-bottom: 1px solid rgba(94, 234, 212, 0.15) !important;
}
.chat-top .title { color: var(--accent) !important; }

/* Typing bar */
.typing-bar {
    font-size: 0.8rem !important;
    color: var(--accent) !important;
    padding: 4px 14px !important;
    min-height: 22px !important;
}

/* Links */
a { color: var(--accent) !important; }
a:hover { color: #99f6e4 !important; }

/* Ensure main chat area layout holds input */
#chat-main-area, .chat-main-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
}
.chat-messages, #chat-messages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

/* v1.3.8 — Who is Where avatars + room count + menu badge */
.where-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    border: 2px solid rgba(94, 234, 212, 0.35) !important;
    background: #1e293b !important;
}
.where-avatar.letter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    color: #fff !important;
    background: linear-gradient(135deg, #6366f1, #a78bfa) !important;
}
.where-av-link { display: inline-block; }
.where-table td { vertical-align: middle !important; }
.room-member-count {
    display: inline-block !important;
    margin-left: 8px !important;
    padding: 2px 10px !important;
    border-radius: 999px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    background: rgba(94, 234, 212, 0.15) !important;
    color: #5eead4 !important;
    border: 1px solid rgba(94, 234, 212, 0.3) !important;
    vertical-align: middle !important;
}
.nav-badge {
    margin-left: auto !important;
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: #fff !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    padding: 2px 7px !important;
    border-radius: 999px !important;
    min-width: 18px !important;
    text-align: center !important;
}
.nav-badge.hidden { display: none !important; }
.room-count-card {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(94, 234, 212, 0.2) !important;
    border-radius: 14px !important;
}

/* v1.3.9 — Post badges + profile edit toggle */
.post-badge { font-size: 0.72rem !important; margin-left: 4px !important; }
.post-new { background: #64748b !important; color: #fff !important; }
.post-newbie { background: #3b82f6 !important; color: #fff !important; }
.post-beginner { background: #22c55e !important; color: #fff !important; }
.post-regular { background: #a855f7 !important; color: #fff !important; }
.post-active { background: #f59e0b !important; color: #111 !important; }
.post-chatter { background: #ec4899 !important; color: #fff !important; }
.post-legend { background: linear-gradient(135deg,#fbbf24,#f59e0b) !important; color: #111 !important; font-weight: 800 !important; }
#profile-edit-panel { margin-top: 8px; }
#btn-edit-profile { min-width: 160px; }

/* ========================================
   v1.3.9b — Complete badge CSS class table
   Role badges + Activity (post-count) badges
   ======================================== */

/* Base pill */
.role-badge,
.post-badge {
    display: inline-block !important;
    padding: 2px 8px !important;
    border-radius: 999px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    letter-spacing: 0.02em !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
}

/* ---- Role badges ---- */
.badge-owner,
.role-badge.badge-owner {
    background: linear-gradient(90deg, #ff4d8d, #ff2d6a) !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(255, 45, 106, 0.35) !important;
}
.badge-superadmin,
.role-badge.badge-superadmin {
    background: linear-gradient(90deg, #a855f7, #7c3aed) !important;
    color: #fff !important;
}
.badge-admin,
.role-badge.badge-admin {
    background: linear-gradient(90deg, #ef4444, #dc2626) !important;
    color: #fff !important;
}
.badge-mod,
.role-badge.badge-mod {
    background: linear-gradient(90deg, #3b82f6, #2563eb) !important;
    color: #fff !important;
}
.badge-roommod,
.role-badge.badge-roommod {
    background: linear-gradient(90deg, #14b8a6, #0d9488) !important;
    color: #fff !important;
}
.badge-member,
.role-badge.badge-member {
    background: #475569 !important;
    color: #e2e8f0 !important;
}

/* ---- Activity / post-count badges (from postBadge()) ----
   0        → New
   1–99     → Newbie
   100–499  → Beginner
   500–999  → Regular
   1000–4999→ Active
   5000–9999→ Chatter
   10000+   → Legend
*/
.role-badge.post-badge,
.post-badge {
    margin-left: 4px !important;
}
.post-new,
.role-badge.post-new {
    background: #64748b !important;
    color: #f8fafc !important;
}
.post-newbie,
.role-badge.post-newbie {
    background: #3b82f6 !important;
    color: #fff !important;
}
.post-beginner,
.role-badge.post-beginner {
    background: #22c55e !important;
    color: #052e16 !important;
}
.post-regular,
.role-badge.post-regular {
    background: #a855f7 !important;
    color: #fff !important;
}
.post-active,
.role-badge.post-active {
    background: #f59e0b !important;
    color: #1c1917 !important;
}
.post-chatter,
.role-badge.post-chatter {
    background: #ec4899 !important;
    color: #fff !important;
}
.post-legend,
.role-badge.post-legend {
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #f97316) !important;
    color: #1c1917 !important;
    font-weight: 800 !important;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4) !important;
}

/* ========================================
   v1.4.0 — Best chatroom message list design
   ======================================== */

#chat-messages,
.chat-messages {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px 12px 18px !important;
    overflow-y: auto !important;
    scroll-behavior: smooth !important;
    background:
        radial-gradient(ellipse at top, rgba(94, 234, 212, 0.04), transparent 55%),
        linear-gradient(180deg, #0b0f1a 0%, #0f172a 100%) !important;
}

/* Single message wrapper */
.msg {
    max-width: 78% !important;
    width: fit-content !important;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    animation: msgIn 0.22s ease-out !important;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg.me { align-self: flex-end !important; }
.msg.other { align-self: flex-start !important; }

.msg-row {
    display: flex !important;
    align-items: flex-end !important;
    gap: 9px !important;
}
.msg.me .msg-row { flex-direction: row !important; justify-content: flex-end !important; }
.msg.other .msg-row { flex-direction: row !important; }

/* Avatar */
.msg-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    border: 2px solid rgba(94, 234, 212, 0.4) !important;
    background: #1e293b !important;
    cursor: pointer !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}
.msg-avatar:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.3) !important;
}
.msg-avatar.letter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 800 !important;
    font-size: 0.88rem !important;
    color: #fff !important;
    background: linear-gradient(135deg, #6366f1, #a78bfa) !important;
    border-color: rgba(167, 139, 250, 0.5) !important;
}

/* Bubble body */
.msg-body {
    max-width: 100% !important;
    padding: 9px 13px 7px !important;
    border-radius: 16px !important;
    line-height: 1.45 !important;
    position: relative !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
}

.msg.other .msg-body {
    background: linear-gradient(160deg, #1e293b 0%, #1a2235 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    border-bottom-left-radius: 5px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}
.msg.me .msg-body {
    background: linear-gradient(135deg, #134e4a 0%, #0f3d4a 50%, #1e3a5f 100%) !important;
    border: 1px solid rgba(94, 234, 212, 0.25) !important;
    border-bottom-right-radius: 5px !important;
    box-shadow: 0 2px 12px rgba(20, 184, 166, 0.12) !important;
}

/* Author line */
.msg .author {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
    margin-bottom: 3px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    color: #5eead4 !important;
}
.msg .author .nick-click {
    cursor: pointer !important;
    text-decoration: none !important;
}
.msg .author .nick-click:hover {
    text-decoration: underline !important;
    filter: brightness(1.15);
}
.msg .author-badges {
    display: inline-flex !important;
    gap: 3px !important;
    align-items: center !important;
}
.msg .author-badges .role-badge {
    font-size: 0.65rem !important;
    padding: 1px 6px !important;
}

/* Message text */
.msg .text {
    font-size: 0.95rem !important;
    color: #e8eefc !important;
    white-space: pre-wrap !important;
    line-height: 1.5 !important;
}
.msg .text a {
    color: #5eead4 !important;
    text-decoration: underline !important;
    word-break: break-all !important;
}

/* Meta: time + seen */
.msg-meta {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    margin-top: 4px !important;
}
.msg .time,
.msg-meta .time {
    font-size: 0.68rem !important;
    opacity: 0.55 !important;
    color: #94a3b8 !important;
    margin: 0 !important;
}
.msg.me .msg-meta .time { color: rgba(255,255,255,0.5) !important; }
.msg-seen {
    color: #5eead4 !important;
    letter-spacing: -1.5px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
}
.msg-sent {
    color: rgba(255,255,255,0.4) !important;
    letter-spacing: -1.5px !important;
    font-size: 0.78rem !important;
}

/* Image messages */
.msg .img-wrap {
    margin: 4px 0 2px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    max-width: 260px !important;
}
.msg .img-msg {
    display: block !important;
    max-width: 100% !important;
    max-height: 280px !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: transform 0.15s ease, opacity 0.15s !important;
}
.msg .img-msg:hover {
    opacity: 0.92 !important;
    transform: scale(1.02) !important;
}

/* System messages */
.msg.system {
    align-self: center !important;
    max-width: 92% !important;
    width: auto !important;
    margin: 4px 0 !important;
}
.msg.system .sys-inner {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 7px 14px !important;
    border-radius: 999px !important;
    background: rgba(167, 139, 250, 0.12) !important;
    border: 1px solid rgba(167, 139, 250, 0.28) !important;
    color: #c4b5fd !important;
    font-size: 0.82rem !important;
    text-align: center !important;
}
.msg.system .sys-inner i {
    opacity: 0.8 !important;
    font-size: 0.75rem !important;
}
.msg.system .text {
    color: #c4b5fd !important;
    font-size: 0.82rem !important;
    white-space: normal !important;
}

/* Room rules system variant */
.msg.system.room-rules-msg .sys-inner,
.msg.system.room-rules-msg {
    border-radius: 12px !important;
    max-width: 95% !important;
    background: rgba(94, 234, 212, 0.08) !important;
    border-color: rgba(94, 234, 212, 0.25) !important;
}
.msg.system.room-rules-msg .text {
    color: #99f6e4 !important;
    text-align: left !important;
}

/* Mobile */
@media (max-width: 640px) {
    .msg { max-width: 88% !important; }
    .msg-avatar { width: 32px !important; height: 32px !important; }
    .msg-body { padding: 8px 11px 6px !important; border-radius: 14px !important; }
    .msg .text { font-size: 0.92rem !important; }
    .msg .img-wrap { max-width: 220px !important; }
    #chat-messages, .chat-messages { padding: 10px 8px 14px !important; gap: 8px !important; }
}

/* ========================================
   v1.4.1 — Full Dark Mode Support
   Default theme is dark. Toggle via #btn-theme
   body.dark-mode / [data-theme="dark"]
   body.light-mode / [data-theme="light"]
   ======================================== */

:root,
[data-theme="dark"],
body.dark-mode {
    color-scheme: dark;
    --dm-bg: #0b0f1a;
    --dm-bg2: #0f172a;
    --dm-surface: #1a2238;
    --dm-surface2: #1e293b;
    --dm-border: rgba(94, 234, 212, 0.15);
    --dm-text: #e8eefc;
    --dm-muted: #94a3b8;
    --dm-accent: #5eead4;
    --dm-accent2: #a78bfa;
    --dm-pink: #ff7eb3;
    --dm-msg-me: linear-gradient(135deg, #134e4a 0%, #0f3d4a 50%, #1e3a5f 100%);
    --dm-msg-other: linear-gradient(160deg, #1e293b 0%, #1a2235 100%);
}

/* Dark is default — reinforce key surfaces */
body,
body.dark-mode,
body.spa-body.dark-mode,
html[data-theme="dark"] body {
    background: var(--dm-bg, #0b0f1a) !important;
    color: var(--dm-text, #e8eefc) !important;
}

body.dark-mode .spa-header,
html[data-theme="dark"] .spa-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%) !important;
    border-bottom-color: var(--dm-accent, #5eead4) !important;
}

body.dark-mode .sidebar,
html[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%) !important;
    border-right-color: var(--dm-border) !important;
}

body.dark-mode .main-content,
html[data-theme="dark"] .main-content {
    background: var(--dm-bg) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .card,
body.dark-mode .profile-card,
html[data-theme="dark"] .card {
    background: linear-gradient(180deg, #1a2238 0%, #0f172a 100%) !important;
    border-color: var(--dm-border) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .chat-top,
body.dark-mode .chat-input-bar,
html[data-theme="dark"] .chat-top,
html[data-theme="dark"] .chat-input-bar {
    background: linear-gradient(180deg, #0f172a, #111827) !important;
    border-color: var(--dm-border) !important;
    color: var(--dm-text) !important;
}

body.dark-mode #chat-messages,
body.dark-mode .chat-messages,
html[data-theme="dark"] #chat-messages {
    background:
        radial-gradient(ellipse at top, rgba(94, 234, 212, 0.04), transparent 55%),
        linear-gradient(180deg, #0b0f1a 0%, #0f172a 100%) !important;
}

body.dark-mode .msg.other .msg-body,
html[data-theme="dark"] .msg.other .msg-body {
    background: var(--dm-msg-other) !important;
    border-color: rgba(255,255,255,0.07) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .msg.me .msg-body,
html[data-theme="dark"] .msg.me .msg-body {
    background: var(--dm-msg-me) !important;
    border-color: rgba(94, 234, 212, 0.25) !important;
    color: #f0fdfa !important;
}

body.dark-mode .msg .text,
html[data-theme="dark"] .msg .text {
    color: #e8eefc !important;
}

body.dark-mode .msg .author,
html[data-theme="dark"] .msg .author {
    color: var(--dm-accent) !important;
}

body.dark-mode #chat-input,
body.dark-mode .chat-input-bar textarea,
html[data-theme="dark"] #chat-input {
    background: #1e293b !important;
    border-color: rgba(94, 234, 212, 0.25) !important;
    color: #f1f5f9 !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #1e293b !important;
    border: 1px solid rgba(94, 234, 212, 0.2) !important;
    color: #f1f5f9 !important;
}

body.dark-mode .text-muted,
html[data-theme="dark"] .text-muted {
    color: var(--dm-muted) !important;
}

body.dark-mode .nav-item,
html[data-theme="dark"] .nav-item {
    color: #cbd5e1 !important;
}

body.dark-mode .nav-item.active,
html[data-theme="dark"] .nav-item.active {
    color: #fff !important;
}

body.dark-mode .spa-footer,
html[data-theme="dark"] .spa-footer {
    background: #0a0e17 !important;
    border-top: 1px solid var(--dm-border) !important;
    color: var(--dm-muted) !important;
}

body.dark-mode .right-panel,
html[data-theme="dark"] .right-panel {
    background: #0f172a !important;
    border-left: 1px solid var(--dm-border) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .popup-modal-inner,
body.dark-mode .qp-card,
html[data-theme="dark"] .popup-modal-inner {
    background: linear-gradient(180deg, #1e1b4b, #0f172a) !important;
    border-color: rgba(94, 234, 212, 0.25) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .admin-table th,
html[data-theme="dark"] .admin-table th {
    background: #1e293b !important;
    color: var(--dm-accent) !important;
}

body.dark-mode .admin-table td,
html[data-theme="dark"] .admin-table td {
    border-color: rgba(255,255,255,0.06) !important;
    color: var(--dm-text) !important;
}

body.dark-mode .member-card,
html[data-theme="dark"] .member-card {
    background: var(--dm-surface) !important;
    border: 1px solid var(--dm-border) !important;
    color: var(--dm-text) !important;
}

/* ---- Light mode overrides for NEW message design ---- */
body.light-mode {
    color-scheme: light;
    --dm-bg: #f8fafc;
    --dm-bg2: #f1f5f9;
    --dm-surface: #ffffff;
    --dm-text: #1e293b;
    --dm-muted: #64748b;
    --dm-accent: #0d9488;
}

body.light-mode #chat-messages,
body.light-mode .chat-messages {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
}

body.light-mode .msg.other .msg-body {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
}

body.light-mode .msg.me .msg-body {
    background: linear-gradient(135deg, #ccfbf1, #99f6e4) !important;
    border: 1px solid #5eead4 !important;
    color: #134e4a !important;
}

body.light-mode .msg .text { color: #1e293b !important; }
body.light-mode .msg.me .text { color: #134e4a !important; }
body.light-mode .msg .author { color: #0d9488 !important; }
body.light-mode .msg-meta .time { color: #94a3b8 !important; }

body.light-mode .msg.system .sys-inner {
    background: #f3e8ff !important;
    border-color: #d8b4fe !important;
    color: #6b21a8 !important;
}
body.light-mode .msg.system .text { color: #6b21a8 !important; }

body.light-mode .msg-avatar {
    border-color: #99f6e4 !important;
}

body.light-mode .chat-input-bar {
    background: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
}
body.light-mode #chat-input {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
}

/* ========================================
   v1.4.2 — Sexy magenta/purple theme
   All messages left + alternating colors
   Bigger images, upload progress, avatars
   ======================================== */

:root {
    --red: #ff2d6a;
    --dark-red: #c01050;
    --pink: #ff4d9a;
    --pink-soft: #ff8ab8;
    --black: #0c0612;
    --dark: #14081c;
    --gray: #1c0e28;
    --light-gray: #2a1438;
    --white: #ffeef5;
    --yellow: #ff4d9a;
    --yellow-dim: #e91e8c;
    --text: #ffeef5;
    --text-muted: #c99bb0;
    --accent: #ff4d9a;
    --accent2: #c44dff;
    --success: #2ecc71;
    --danger: #ff4757;
}

body, .spa-body, body.dark-mode {
    background: #0c0612 !important;
    color: #ffeef5 !important;
}

.spa-header, .header {
    background: linear-gradient(135deg, #1a0828 0%, #2d0a3a 40%, #1a0828 100%) !important;
    border-bottom: 2px solid #ff4d9a !important;
    box-shadow: 0 4px 24px rgba(255, 45, 106, 0.3) !important;
}
.logo span { color: #ff4d9a !important; }
.header-center { color: #ff8ab8 !important; }

.sidebar {
    background: linear-gradient(180deg, #12081a 0%, #0c0612 100%) !important;
    border-right: 1px solid rgba(255, 77, 154, 0.15) !important;
}
.nav-item:hover {
    background: rgba(255, 77, 154, 0.12) !important;
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(255, 77, 154, 0.22), rgba(196, 77, 255, 0.15)) !important;
    border-color: rgba(255, 77, 154, 0.4) !important;
    box-shadow: 0 2px 12px rgba(255, 45, 106, 0.2) !important;
}
.nav-item i { color: #ff4d9a !important; }

.btn {
    background: linear-gradient(135deg, #ff2d6a, #c44dff) !important;
}
.btn-outline {
    border-color: rgba(255, 77, 154, 0.45) !important;
    color: #ff8ab8 !important;
}
#btn-send, .tool-btn.send {
    background: linear-gradient(135deg, #ff2d6a, #e91e8c) !important;
}

/* ---- All messages LEFT + alternating ---- */
#chat-messages, .chat-messages {
    background:
        radial-gradient(ellipse at top, rgba(255, 45, 106, 0.06), transparent 50%),
        linear-gradient(180deg, #0c0612 0%, #14081c 100%) !important;
}

.msg,
.msg.left-align,
.msg.me,
.msg.other {
    align-self: flex-start !important;
    max-width: 92% !important;
    width: 100% !important;
}

.msg .msg-row,
.msg.me .msg-row,
.msg.other .msg-row {
    flex-direction: row !important;
    justify-content: flex-start !important;
}

.msg-body {
    flex: 1 !important;
    max-width: calc(100% - 48px) !important;
}

/* Alternating message colors */
.msg.alt-a .msg-body {
    background: linear-gradient(160deg, #1c0e28 0%, #1a0c24 100%) !important;
    border: 1px solid rgba(255, 77, 154, 0.18) !important;
    border-bottom-left-radius: 5px !important;
    border-radius: 14px !important;
}
.msg.alt-b .msg-body {
    background: linear-gradient(160deg, #241038 0%, #1e0e30 100%) !important;
    border: 1px solid rgba(196, 77, 255, 0.22) !important;
    border-bottom-left-radius: 5px !important;
    border-radius: 14px !important;
}
.msg.me.alt-a .msg-body,
.msg.me.alt-b .msg-body {
    border-color: rgba(255, 45, 106, 0.35) !important;
}
.msg.me .me-tag {
    font-size: 0.65rem !important;
    background: rgba(255, 45, 106, 0.35) !important;
    color: #ffb0c8 !important;
    padding: 1px 6px !important;
    border-radius: 6px !important;
    margin-left: 4px !important;
    font-weight: 600 !important;
}

.msg .author { color: #ff8ab8 !important; }
.msg .text { color: #ffeef5 !important; }

/* Bigger chat images */
.msg .img-wrap {
    max-width: 320px !important;
    margin: 6px 0 4px !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    border: 1px solid rgba(255, 77, 154, 0.2) !important;
}
.msg .img-msg {
    max-width: 100% !important;
    max-height: 360px !important;
    width: auto !important;
    border-radius: 14px !important;
}

/* Avatars more visible */
.msg-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border: 2px solid rgba(255, 77, 154, 0.5) !important;
    box-shadow: 0 2px 8px rgba(255, 45, 106, 0.25) !important;
}
.msg-avatar.letter {
    background: linear-gradient(135deg, #ff2d6a, #c44dff) !important;
    font-size: 0.95rem !important;
}

.where-avatar, .member-card .avatar, .profile-header .avatar {
    border-color: rgba(255, 77, 154, 0.5) !important;
}

/* Upload progress bar */
.upload-progress {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(28, 14, 40, 0.95);
    border-top: 1px solid rgba(255, 77, 154, 0.25);
}
.upload-progress-bar {
    height: 6px;
    width: 0%;
    max-width: 100%;
    flex: 1;
    background: linear-gradient(90deg, #ff2d6a, #c44dff);
    border-radius: 4px;
    transition: width 0.15s ease;
}
.upload-progress-text {
    font-size: 0.8rem;
    color: #ff8ab8;
    font-weight: 700;
    min-width: 40px;
}
.upload-hint {
    font-size: 0.68rem !important;
    color: #c99bb0 !important;
    white-space: nowrap !important;
    align-self: center !important;
    opacity: 0.85 !important;
}

.chat-input-bar {
    background: linear-gradient(180deg, #12081a, #0c0612) !important;
    border-top: 1px solid rgba(255, 77, 154, 0.25) !important;
}
#chat-input, .chat-input-bar textarea {
    background: #1c0e28 !important;
    border: 1px solid rgba(255, 77, 154, 0.3) !important;
    color: #ffeef5 !important;
}
#chat-input:focus {
    border-color: #ff4d9a !important;
    box-shadow: 0 0 0 3px rgba(255, 45, 106, 0.2) !important;
}

.chat-top {
    background: linear-gradient(90deg, #12081a, #1a0828) !important;
    border-bottom: 1px solid rgba(255, 77, 154, 0.2) !important;
}
.chat-top .title, .room-member-count {
    color: #ff8ab8 !important;
}
.room-member-count {
    background: rgba(255, 77, 154, 0.15) !important;
    border-color: rgba(255, 77, 154, 0.35) !important;
}

.msg.system .sys-inner {
    background: rgba(196, 77, 255, 0.12) !important;
    border-color: rgba(196, 77, 255, 0.3) !important;
    color: #e0b0ff !important;
}

a { color: #ff8ab8 !important; }
a:hover { color: #ffb0d0 !important; }

.card, .profile-card {
    border-color: rgba(255, 77, 154, 0.2) !important;
}

/* Chat settings modal always on top */
#chat-settings-modal {
    z-index: 9999 !important;
}
#chat-settings-modal .popup-modal-inner {
    background: linear-gradient(180deg, #1c0e28, #0c0612) !important;
    border: 1px solid rgba(255, 77, 154, 0.3) !important;
    max-width: 380px !important;
}
#chat-settings-modal label {
    display: block !important;
    margin: 10px 0 4px !important;
    color: #ff8ab8 !important;
    font-size: 0.85rem !important;
}
#chat-settings-modal select,
#chat-settings-modal input[type="color"] {
    width: 100% !important;
    background: #1c0e28 !important;
    border: 1px solid rgba(255, 77, 154, 0.3) !important;
    color: #ffeef5 !important;
    border-radius: 8px !important;
    padding: 8px !important;
}

/* ========================================
   v1.4.3 — Best Mobile Responsive Chat Theme
   Phones, small tablets, safe-areas, touch
   ======================================== */

/* Base mobile-friendly shell */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.spa-body {
  height: 100vh !important;
  height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Touch-friendly icon buttons */
.icon-btn, .tool-btn, #btn-send {
  min-width: 44px !important;
  min-height: 44px !important;
  touch-action: manipulation !important;
}

/* ---------- Mobile / tablet (≤900px) ---------- */
@media (max-width: 900px) {
  :root {
    --header-h: 52px;
    --footer-h: 36px;
    --sidebar-w: min(86vw, 300px);
  }

  .spa-header, .header {
    height: var(--header-h) !important;
    padding: 0 8px !important;
    padding-top: env(safe-area-inset-top, 0) !important;
    gap: 4px !important;
  }
  .spa-header .logo { font-size: 0.95rem !important; }
  .header-center { font-size: 0.82rem !important; display: none !important; }
  .icon-btn {
    width: 42px !important;
    height: 42px !important;
    padding: 8px !important;
    font-size: 1.05rem !important;
  }
  .user-chip .uname { max-width: 64px !important; }

  .spa-layout {
    height: calc(100dvh - var(--header-h) - var(--footer-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    height: calc(100vh - var(--header-h) - var(--footer-h)) !important;
  }

  /* Sidebar as overlay drawer */
  .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: var(--header-h) !important;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px)) !important;
    bottom: var(--footer-h) !important;
    width: var(--sidebar-w) !important;
    z-index: 300 !important;
    transform: translateX(-105%) !important;
    transition: transform 0.25s ease !important;
    box-shadow: 8px 0 32px rgba(0,0,0,0.5) !important;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.55) !important;
    z-index: 290 !important;
    display: none !important;
  }
  .sidebar-backdrop.show { display: block !important; }

  .main-content {
    width: 100% !important;
    flex: 1 !important;
    min-width: 0 !important;
    padding: 0 !important;
  }

  .right-panel {
    position: fixed !important;
    right: 0 !important;
    top: var(--header-h) !important;
    bottom: var(--footer-h) !important;
    width: min(92vw, 340px) !important;
    z-index: 310 !important;
    transform: translateX(105%) !important;
    transition: transform 0.25s ease !important;
  }
  .right-panel.open {
    transform: translateX(0) !important;
    display: flex !important;
  }

  /* Chat layout: full width conversation */
  .chat-layout {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
  }
  .chat-list-panel {
    width: 100% !important;
    max-width: 100% !important;
    border-right: none !important;
  }
  /* When in a conversation, list can hide via JS class */
  body.chat-conversation .chat-list-panel,
  .chat-layout.conversation-mode .chat-list-panel {
    display: none !important;
  }
  body.chat-conversation #chat-main-area,
  .chat-layout.conversation-mode #chat-main-area,
  .chat-layout.conversation-mode .chat-main {
    display: flex !important;
    flex: 1 !important;
    width: 100% !important;
  }

  #chat-main-area, .chat-main-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
  }

  .chat-top {
    flex-shrink: 0 !important;
    padding: 8px 10px !important;
    gap: 6px !important;
    min-height: 48px !important;
  }
  .chat-top .title {
    font-size: 0.95rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 55vw !important;
  }
  .chat-top .icon-btn {
    width: 40px !important;
    height: 40px !important;
  }
  .room-member-count {
    font-size: 0.68rem !important;
    padding: 2px 7px !important;
  }

  /* Message list scrolls; input stays bottom */
  #chat-messages, .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 10px 8px 12px !important;
    gap: 8px !important;
  }

  .msg, .msg.left-align, .msg.me, .msg.other {
    max-width: 96% !important;
  }
  .msg-avatar {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
  }
  .msg-body {
    padding: 8px 11px 6px !important;
    border-radius: 14px !important;
  }
  .msg .text { font-size: 0.94rem !important; line-height: 1.45 !important; }
  .msg .author { font-size: 0.78rem !important; }
  .msg .img-wrap {
    max-width: min(88vw, 300px) !important;
  }
  .msg .img-msg {
    max-height: 300px !important;
  }

  /* Sticky input bar above footer + home indicator */
  .chat-input-bar {
    flex-shrink: 0 !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 50 !important;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 6px !important;
    min-height: 56px !important;
    align-items: flex-end !important;
  }
  #chat-input, .chat-input-bar textarea {
    font-size: 16px !important; /* prevents iOS zoom */
    min-height: 44px !important;
    max-height: 100px !important;
    padding: 10px 12px !important;
    border-radius: 12px !important;
  }
  .tool-btn, #btn-send {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
  }
  .upload-hint {
    display: none !important; /* save space; title still on icon */
  }
  .upload-progress {
    padding: 5px 10px !important;
  }

  .spa-footer {
    height: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    font-size: 0.75rem !important;
  }

  /* Cards / grids on mobile */
  .card { margin: 8px !important; border-radius: 14px !important; }
  .grid-members {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .member-card { padding: 12px 8px !important; }
  .profile-header .avatar,
  .profile-header .letter {
    width: 84px !important;
    height: 84px !important;
  }
  .profile-stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Modals full-friendly */
  .popup-modal-inner {
    max-width: calc(100vw - 24px) !important;
    max-height: 85dvh !important;
    overflow-y: auto !important;
    margin: 12px !important;
  }
  #chat-settings-modal .popup-modal-inner {
    width: calc(100vw - 24px) !important;
  }

  /* Chat list items */
  .chat-list-item, .mini-user {
    padding: 12px 10px !important;
    min-height: 52px !important;
  }
  .chat-list-header .tab {
    padding: 10px 14px !important;
    font-size: 0.9rem !important;
  }

  /* Tables (Who is Where) scroll */
  .where-table, .admin-table {
    font-size: 0.82rem !important;
  }
  .where-table .btn-sm {
    padding: 6px 8px !important;
  }
}

/* ---------- Small phones (≤400px) ---------- */
@media (max-width: 400px) {
  .grid-members {
    grid-template-columns: 1fr 1fr !important;
  }
  .spa-header .logo span { display: none !important; }
  .msg .img-wrap { max-width: 78vw !important; }
  .chat-top .title { max-width: 42vw !important; }
}

/* ---------- Landscape phones ---------- */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .spa-header { height: 44px !important; }
  .chat-top { min-height: 40px !important; padding: 4px 8px !important; }
  .chat-input-bar { min-height: 48px !important; padding: 4px 8px !important; }
  #chat-input { min-height: 36px !important; max-height: 64px !important; }
  .msg-avatar { width: 28px !important; height: 28px !important; min-width: 28px !important; }
}

/* Keyboard open: keep input visible (visualViewport helper class from JS optional) */
body.keyboard-open .spa-footer { display: none !important; }
body.keyboard-open .chat-input-bar {
  padding-bottom: 8px !important;
}

@media (max-width: 900px) {
  .chat-list-panel.hidden-on-chat,
  .chat-layout.conversation-open .chat-list-panel,
  .chat-layout.conversation-mode .chat-list-panel {
    display: none !important;
  }
  .chat-layout.conversation-open #chat-main-area,
  .chat-layout.conversation-mode #chat-main-area {
    display: flex !important;
    flex: 1 !important;
    width: 100% !important;
    min-height: 0 !important;
  }
}

/* ========================================
   v1.4.4 — Premium cyan-violet design
   Full-width msgs, typing bar, badges, menu
   ======================================== */

:root {
    --black: #070b14;
    --dark: #0c1220;
    --gray: #141c2e;
    --light-gray: #1a2438;
    --text: #e8eef8;
    --text-muted: #8b9bb4;
    --accent: #38bdf8;
    --accent2: #818cf8;
    --pink: #38bdf8;
    --pink-soft: #7dd3fc;
    --red: #38bdf8;
    --yellow: #38bdf8;
}

body, .spa-body, body.dark-mode {
    background: #070b14 !important;
    color: #e8eef8 !important;
}

.spa-header {
    background: linear-gradient(135deg, #0a1020 0%, #121a32 50%, #0a1020 100%) !important;
    border-bottom: 2px solid #38bdf8 !important;
    box-shadow: 0 4px 24px rgba(56, 189, 248, 0.15) !important;
}
.logo span { color: #38bdf8 !important; }

.sidebar {
    background: linear-gradient(180deg, #0a1020, #070b14) !important;
    border-right: 1px solid rgba(56, 189, 248, 0.12) !important;
}
.nav-item {
    margin: 4px 10px !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    color: #b6c2d6 !important;
    font-weight: 500 !important;
}
.nav-item i { color: #38bdf8 !important; width: 22px !important; }
.nav-item:hover {
    background: rgba(56, 189, 248, 0.1) !important;
    color: #fff !important;
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.15)) !important;
    color: #fff !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
    box-shadow: 0 2px 14px rgba(56, 189, 248, 0.12) !important;
}
.nav-badge {
    background: linear-gradient(135deg, #38bdf8, #818cf8) !important;
    color: #0a1020 !important;
}

.btn {
    background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
}
#btn-send, .tool-btn.send {
    background: linear-gradient(135deg, #0ea5e9, #38bdf8) !important;
}

/* Header unread badges — always visible when >0 */
.bell-count, #inbox-count, #bell-count, #popup-count {
    position: absolute !important;
    top: 2px !important;
    right: 2px !important;
    min-width: 16px !important;
    height: 16px !important;
    padding: 0 4px !important;
    border-radius: 999px !important;
    background: #f43f5e !important;
    color: #fff !important;
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    line-height: 16px !important;
    text-align: center !important;
    z-index: 2 !important;
}
.bell-count.hidden, #inbox-count.hidden, #bell-count.hidden { display: none !important; }
.icon-btn, .notif-bell { position: relative !important; }

/* Full-width messages, no gap waste */
.msg, .msg.left-align, .msg.me, .msg.other {
    max-width: 100% !important;
    width: 100% !important;
    align-self: stretch !important;
}
.msg-row {
    width: 100% !important;
    gap: 8px !important;
}
.msg-body {
    flex: 1 1 auto !important;
    max-width: none !important;
    width: 100% !important;
}
.msg.alt-a .msg-body {
    background: linear-gradient(160deg, #121a2e, #0e1628) !important;
    border: 1px solid rgba(56, 189, 248, 0.12) !important;
}
.msg.alt-b .msg-body {
    background: linear-gradient(160deg, #161e36, #101828) !important;
    border: 1px solid rgba(129, 140, 248, 0.14) !important;
}
.msg.me .msg-body {
    border-color: rgba(56, 189, 248, 0.28) !important;
}
.msg-avatar {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-color: rgba(56, 189, 248, 0.45) !important;
}
.msg-avatar.letter {
    background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
}
.nick-bold, .msg .author .nick-click {
    font-weight: 700 !important;
}
.msg .author { color: #7dd3fc !important; }
.me-tag {
    background: rgba(56, 189, 248, 0.25) !important;
    color: #7dd3fc !important;
}

/* Typing bar premium */
.typing-bar {
    min-height: 22px !important;
    padding: 4px 12px !important;
    font-size: 0.8rem !important;
    color: #94a3b8 !important;
    flex-shrink: 0 !important;
}
.typing-nick { font-weight: 700 !important; }
.typing-more { color: #64748b !important; font-weight: 600 !important; }

.chat-input-bar {
    background: linear-gradient(180deg, #0a1020, #070b14) !important;
    border-top: 1px solid rgba(56, 189, 248, 0.2) !important;
}
#chat-input {
    background: #121a2e !important;
    border-color: rgba(56, 189, 248, 0.25) !important;
    color: #e8eef8 !important;
}
.chat-top {
    background: linear-gradient(90deg, #0a1020, #121a32) !important;
    border-bottom: 1px solid rgba(56, 189, 248, 0.15) !important;
}
.chat-top .title, .room-member-count { color: #7dd3fc !important; }
.room-member-count {
    background: rgba(56, 189, 248, 0.12) !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

/* Profile: keep edit button visible */
#btn-edit-profile {
    position: sticky !important;
    bottom: 12px !important;
    z-index: 5 !important;
    margin: 16px auto !important;
    display: block !important;
}
.main-content {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}
.profile-card {
    padding-bottom: 80px !important;
}

/* Mobile full chat */
@media (max-width: 900px) {
  .msg, .msg.left-align { max-width: 100% !important; }
  #chat-main-area {
    position: absolute !important;
    inset: 0 !important;
    background: #070b14 !important;
  }
  .chat-layout.conversation-mode,
  body.chat-conversation .chat-layout {
    position: relative !important;
    height: 100% !important;
  }
}

a { color: #38bdf8 !important; }
a:hover { color: #7dd3fc !important; }

/* v1.4.5 — Force no-pink, tight msgs, visible input, single avatar */
html body.spa-body,
html body.dark-mode {
  background: #070b14 !important;
  color: #e8eef8 !important;
}
html .spa-header {
  border-bottom: 2px solid #38bdf8 !important;
  background: linear-gradient(135deg, #0a1020, #121a32, #0a1020) !important;
  box-shadow: 0 4px 20px rgba(14,165,233,0.15) !important;
}
html .logo span { color: #38bdf8 !important; }
html .chat-list-header .tab.active {
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  color: #fff !important;
}
html .btn, html #btn-send, html .tool-btn.send {
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  color: #fff !important;
  border: none !important;
}
html a { color: #38bdf8 !important; }

/* Single avatar — never show two */
.msg-row > .msg-avatar ~ .msg-avatar { display: none !important; }
.msg-avatar {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}
.msg-row {
  display: flex !important;
  align-items: flex-start !important;
  gap: 6px !important;
  width: 100% !important;
}
.msg-body {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: none !important;
  width: auto !important;
  margin: 0 !important;
}
.msg, .msg.me, .msg.other, .msg.left-align {
  max-width: 100% !important;
  width: 100% !important;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
/* Kill leftover pink strips on me messages */
.msg.me::before, .msg.me::after,
.msg.me .msg-row::before, .msg.me .msg-body::before {
  display: none !important;
  content: none !important;
  background: none !important;
}

/* FORCE typing box visible */
#chat-main-area {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0 !important;
  position: relative !important;
}
#chat-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
.chat-input-bar {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 80 !important;
  min-height: 56px !important;
  padding: 8px 10px !important;
  gap: 8px !important;
  background: #0a1020 !important;
  border-top: 1px solid rgba(56,189,248,0.25) !important;
}
#chat-input {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex: 1 !important;
  min-height: 44px !important;
  font-size: 16px !important;
  background: #121a2e !important;
  color: #e8eef8 !important;
  border: 1px solid rgba(56,189,248,0.3) !important;
  border-radius: 12px !important;
  padding: 10px 12px !important;
}
#typing-bar.typing-bar {
  display: block !important;
  flex-shrink: 0 !important;
  min-height: 20px !important;
  padding: 2px 12px !important;
}

/* Quick profile cyan buttons */
#quick-profile-modal .btn {
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
}
#quick-profile-modal .btn-outline {
  background: transparent !important;
  border: 1px solid rgba(56,189,248,0.4) !important;
  color: #7dd3fc !important;
}
.qp-card {
  background: linear-gradient(180deg, #121a32, #070b14) !important;
  border: 1px solid rgba(56,189,248,0.3) !important;
}

@media (max-width: 900px) {
  .chat-input-bar {
    display: flex !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .msg-row { gap: 6px !important; }
}

/* v1.4.6 — Modern numbered menu + auth polish */
.side-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 16px 14px 12px !important;
  border-bottom: 1px solid rgba(56,189,248,0.12) !important;
  margin-bottom: 8px !important;
}
.side-brand-icon {
  width: 40px !important; height: 40px !important;
  border-radius: 12px !important;
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  color: #fff !important; font-size: 1rem !important;
  box-shadow: 0 4px 14px rgba(14,165,233,0.3) !important;
  flex-shrink: 0 !important;
}
.side-brand-name {
  font-weight: 800 !important; font-size: 0.95rem !important; color: #f1f5f9 !important;
}
.side-brand-sub {
  font-size: 0.68rem !important; color: #64748b !important; text-transform: uppercase !important;
  letter-spacing: 0.8px !important; margin-top: 2px !important;
}

.modern-nav .nav-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 3px 8px !important;
  padding: 11px 12px !important;
  border-radius: 12px !important;
  border: 1px solid transparent !important;
  color: #b6c2d6 !important;
  font-weight: 500 !important;
  transition: all 0.18s ease !important;
}
.modern-nav .nav-num {
  font-size: 0.68rem !important;
  font-weight: 800 !important;
  color: #475569 !important;
  min-width: 22px !important;
  letter-spacing: 0.5px !important;
  font-variant-numeric: tabular-nums !important;
}
.modern-nav .nav-item i {
  width: 20px !important;
  color: #38bdf8 !important;
  opacity: 0.9 !important;
  text-align: center !important;
}
.modern-nav .nav-label {
  flex: 1 !important;
  font-size: 0.9rem !important;
}
.modern-nav .nav-item:hover {
  background: rgba(56,189,248,0.08) !important;
  color: #fff !important;
  border-color: rgba(56,189,248,0.15) !important;
}
.modern-nav .nav-item:hover .nav-num { color: #38bdf8 !important; }
.modern-nav .nav-item.active {
  background: linear-gradient(135deg, rgba(14,165,233,0.18), rgba(99,102,241,0.12)) !important;
  border-color: rgba(56,189,248,0.35) !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(14,165,233,0.12) !important;
}
.modern-nav .nav-item.active .nav-num {
  color: #38bdf8 !important;
}
.modern-nav .nav-item.admin-link {
  margin-top: 8px !important;
  border-top: 1px solid rgba(255,255,255,0.06) !important;
  padding-top: 14px !important;
}
.modern-nav .nav-item.admin-link .nav-num,
.modern-nav .nav-item.admin-link i { color: #fbbf24 !important; }

.modern-nav .nav-badge {
  margin-left: auto !important;
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  color: #fff !important;
  font-size: 0.65rem !important;
  font-weight: 800 !important;
  min-width: 18px !important;
  height: 18px !important;
  line-height: 18px !important;
  text-align: center !important;
  border-radius: 999px !important;
  padding: 0 5px !important;
}
