/* ============================================================
   chatWS — social.css
   All social feature styles: profiles, PMs, friends,
   user cards, toasts, and login extras.
   Replaces: profile.css + profile_edit.css + profile-modals.css
             + user_card.css + pms.css + friends.css + login_additions.css
============================================================ */


/* ========================================================
   ── PROFILE PAGE
======================================================== */

/* =======================================================
   chatWS — Profile Modal (Avatar + Cover Support)
======================================================= */

/* HIDE STATE */
.profileBox {
    display: none;
}

.profileBox.visible {
    display: flex;
}

/* -------------------------------------------------------
   Modal Root
------------------------------------------------------- */
.profileBox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.65);
    padding: 0 1rem;
}

/* -------------------------------------------------------
   Modal Dialog (Now with scroll container)
------------------------------------------------------- */
.profileBoxInner {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    /* prevents overflow */
    background: #0b0b0b;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    color: #f5f5f5;
    animation: popIn 0.18s ease-out;

    display: flex;
    flex-direction: column;
}

/* Scrollable inner content */
.profileScrollArea {
    overflow-y: auto;
    padding-bottom: 10px;
    max-height: calc(92vh - 70px);
    /* subtract footer height */
}

/* Smooth animation */
@keyframes popIn {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* -------------------------------------------------------
   HEADER (Banner + Avatar)
------------------------------------------------------- */
.profileHeaderArea {
    position: relative;
    width: 100%;
    height: 140px;
    overflow: hidden;
}

.profileBanner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.boxAvatar {
    position: absolute;
    bottom: -35px;
    left: 1rem;
    width: 90px;
    height: 90px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid #0b0b0b;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}

/* -------------------------------------------------------
   Text Content
------------------------------------------------------- */
.boxUsername,
.boxRank,
.boxGender,
.boxBio,
.boxLastActive {
    padding-left: 1.2rem;
    padding-right: 1.2rem;
}

.boxUsername {
    margin-top: 48px;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.boxRank {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 4px;
}

.boxGender {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-bottom: 10px;
}

.boxBio {
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 12px;
    white-space: pre-wrap;
    opacity: 0.9;
}

.boxLastActive {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 14px;
}

/* -------------------------------------------------------
   Action Buttons (Always visible)
------------------------------------------------------- */
.boxControls {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.75rem 1.2rem;
    background: #050505;
    border-top: 1px solid rgba(255, 255, 255, 0.07);

    /* FIXED FOOTER */
    position: sticky;
    bottom: 0;
}

.boxControls .btn {
    flex: 1;
    padding: 0.55rem 0;
    background: #141414;
    border-radius: 8px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: 0.15s ease;
    font-size: 0.85rem;
}

.boxControls .btn:hover {
    background: #1f1f1f;
}

.closeBtn {
    background: #aa2e2e;
    border-color: rgba(255, 255, 255, 0.1);
}

.closeBtn:hover {
    background: #c03939;
}

/* -------------------------------------------------------
   Mobile Responsive
------------------------------------------------------- */
@media (max-width: 600px) {
    .profileBoxInner {
        max-width: 92%;
        border-radius: 14px;
    }

    .profileHeaderArea {
        height: 120px;
    }

    .boxAvatar {
        width: 78px;
        height: 78px;
        bottom: -32px;
        left: 0.9rem;
    }

    .boxUsername {
        margin-top: 40px;
    }
}

/* ========================================================
   ── PROFILE EDIT BOX
======================================================== */

/* ==========================================================
   PROFILE PANEL WRAPPER
   (Mobile-safe padding + auto width)
========================================================== */
.profile-panel {
    padding: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Section titles */
.profile-section-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
}

/* ==========================================================
   AVATAR + COVER (RESPONSIVE)
========================================================== */
.profile-avatar-box,
.profile-cover-box {
    text-align: center;
    width: 100%;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 10px;
    object-fit: cover;
}

/* Scale properly on phones */
.profile-cover {
    width: 100%;
    height: 28vw;
    /* dynamic — ~80px on desktop, scales on mobile */
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

/* ==========================================================
   INPUTS / TEXTAREAS
========================================================== */
.profile-label {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: 14px;
    color: #ddd;
}

.profile-input,
.profile-textarea,
.profile-file-input {
    width: 100%;
    box-sizing: border-box;
}

.profile-textarea {
    padding: 8px;
    border-radius: 6px;
    resize: vertical;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================
   SAVE BUTTON
========================================================== */
.profile-save-btn {
    margin-top: 16px;
    width: 100%;
}

/* ==========================================================
   MOBILE BREAKPOINTS
========================================================== */
@media (max-width: 480px) {

    .profile-panel {
        padding: 12px;
    }

    .profile-avatar {
        width: 75px;
        height: 75px;
    }

    .profile-section-title {
        font-size: 16px;
    }

    .profile-cover {
        height: 32vw;
        /* slightly taller on small screens */
    }

    /* Make text areas easier to tap */
    .profile-textarea {
        font-size: 14px;
    }
}

/* ========================================================
   ── PROFILE MODAL
======================================================== */

/* ==========================================================
   chatWS — Profile Modals & User Cards
   Compact user card + Full profile modal styles
========================================================== */

/* ==========================================================
   COMPACT USER CARD (Quick Popup)
========================================================== */
.user-card-compact {
    position: fixed;
    z-index: 5000;
    background: var(--bg-secondary, #0b0b0b);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.4));
    min-width: 260px;
    max-width: 320px;
    overflow: hidden;
    display: none;
    animation: cardPopIn 0.2s ease-out;
}

.user-card-compact.visible {
    display: block;
}

@keyframes cardPopIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Card Header */
.user-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md, 10px);
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-rank {
    font-size: 12px;
    color: var(--text-muted, #a3a3a3);
    margin-top: 2px;
}

/* Card Actions */
.user-card-actions {
    padding: 8px 0;
}

.user-card-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #e5e5e5);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.user-card-btn:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #fff);
}

.user-card-btn i {
    width: 20px;
    text-align: center;
    color: var(--text-muted, #a3a3a3);
}

.user-card-btn:hover i {
    color: var(--accent-blue, #b8964f);
}

.user-card-btn.primary i {
    color: var(--accent-blue, #b8964f);
}

.user-card-btn.danger i {
    color: #ff6b6b;
}

/* ==========================================================
   FULL PROFILE MODAL
========================================================== */
.profile-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.profile-modal-overlay.visible {
    display: flex;
    animation: overlayFadeIn 0.2s ease;
}

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

.profile-modal {
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: var(--bg-secondary, #0b0b0b);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.4));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalPopIn 0.25s ease-out;
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Header */
.profile-modal-header {
    position: relative;
    height: 160px;
    background: linear-gradient(135deg, var(--accent-blue, #b8964f), var(--accent-orange, #ff8a4a));
    flex-shrink: 0;
}

.profile-modal-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-modal-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.profile-modal-close {
    position: relative;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.profile-modal-close:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* Modal Avatar */
.profile-modal-avatar-wrap {
    position: relative;
    margin-top: -50px;
    padding: 0 20px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.profile-modal-avatar {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-lg, 14px);
    object-fit: cover;
    border: 4px solid var(--bg-secondary, #0b0b0b);
    box-shadow: var(--shadow-md, 0 4px 16px rgba(0, 0, 0, 0.3));
    flex-shrink: 0;
}

.profile-modal-title {
    flex: 1;
    padding-bottom: 8px;
}

.profile-modal-username {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
}

.profile-modal-meta {
    font-size: 13px;
    color: var(--text-muted, #a3a3a3);
}

/* Modal Content */
.profile-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Stats Grid */
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.profile-stat {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-tertiary, #141414);
    border-radius: var(--radius-md, 10px);
}

.profile-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-blue, #b8964f);
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 11px;
    color: var(--text-muted, #a3a3a3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Info Rows */
.profile-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

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

.profile-info-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md, 10px);
    background: var(--bg-tertiary, #141414);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #a3a3a3);
    font-size: 14px;
    flex-shrink: 0;
}

.profile-info-content {
    flex: 1;
}

.profile-info-label {
    font-size: 12px;
    color: var(--text-muted, #a3a3a3);
    margin-bottom: 2px;
}

.profile-info-value {
    font-size: 14px;
    color: var(--text-primary, #fff);
}

/* Bio Section */
.profile-bio-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary, #141414);
    border-radius: var(--radius-md, 10px);
}

.profile-bio-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted, #a3a3a3);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.profile-bio-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary, #e5e5e5);
    white-space: pre-wrap;
}

.profile-bio-empty {
    font-size: 14px;
    color: var(--text-muted, #a3a3a3);
    font-style: italic;
}


/* ==========================================================
   PROFILE EDIT MODAL
========================================================== */
.profile-edit-modal {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    background: var(--bg-secondary, #0b0b0b);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0, 0, 0, 0.4));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.profile-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-tertiary, #141414);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.profile-edit-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.profile-edit-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted, #a3a3a3);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.profile-edit-close:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #fff);
}

.profile-edit-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Image Upload Section */
.profile-image-uploads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-upload-box {
    text-align: center;
}

.profile-upload-preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md, 10px);
    object-fit: cover;
    margin-bottom: 8px;
    background: var(--bg-tertiary, #141414);
    border: 2px dashed var(--border-medium, rgba(255, 255, 255, 0.1));
}

.profile-upload-label {
    font-size: 12px;
    color: var(--text-muted, #a3a3a3);
    margin-bottom: 8px;
}

.profile-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary, #141414);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-md, 10px);
    color: var(--text-secondary, #e5e5e5);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.profile-upload-btn:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
    border-color: var(--border-medium, rgba(255, 255, 255, 0.1));
}

.profile-upload-btn input {
    display: none;
}

/* Form Groups */
.profile-form-group {
    margin-bottom: 16px;
}

.profile-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #e5e5e5);
    margin-bottom: 6px;
}

.profile-form-input,
.profile-form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-md, 10px);
    background: var(--bg-tertiary, #141414);
    color: var(--text-primary, #fff);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.profile-form-input:focus,
.profile-form-textarea:focus {
    border-color: var(--accent-blue, #b8964f);
}

.profile-form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Password Section */
.profile-password-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.profile-password-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 12px;
}

/* Footer Actions */
.profile-edit-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-tertiary, #141414);
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

/* ==========================================================
   MOBILE STYLES
========================================================== */
@media (max-width: 767px) {
    /* Compact card - bottom sheet on mobile */
    .user-card-compact {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: auto;
        max-width: none;
        border-radius: var(--radius-lg, 14px) var(--radius-lg, 14px) 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .user-card-compact.visible {
        transform: translateY(0);
    }

    /* Full profile modal - full screen on mobile */
    .profile-modal-overlay {
        padding: 0;
    }

    .profile-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: modalSlideUp 0.25s ease-out;
    }

    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .profile-modal-header {
        height: 140px;
    }

    .profile-modal-avatar {
        width: 80px;
        height: 80px;
    }

    .profile-modal-username {
        font-size: 20px;
    }

    .profile-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .profile-stat {
        padding: 10px 6px;
    }

    .profile-stat-value {
        font-size: 16px;
    }

    /* Edit modal full screen */
    .profile-edit-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .profile-stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .profile-stat {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: 10px 12px;
    }

    .profile-image-uploads {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   MESSAGE ACTIONS (Delete buttons)
========================================================== */
.message {
    position: relative;
}

.message-actions {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    gap: 4px;
}

/* Desktop: show on hover */
@media (hover: hover) {
    .message:hover .message-actions {
        display: flex;
    }
}

/* Mobile: always show for own messages */
@media (hover: none) {
    .message.own .message-actions {
        display: flex;
        opacity: 0.7;
    }
    .message.own:hover .message-actions {
        opacity: 1;
    }
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.message-action-btn:hover {
    background: rgba(255, 107, 107, 0.8);
    transform: scale(1.1);
}

.message-action-btn.delete {
    color: #ff6b6b;
}

.message-action-btn.delete:hover {
    background: #ff6b6b;
    color: #fff;
}

.user-card-btn.danger i {
    color: #ff6b6b;
}

.user-card-btn.danger:hover {
    background: #ff6b6b;
    color: #fff;
}

/* Staff/Moderation button */
.user-card-btn.staff i {
    color: #ffc857;
}

.user-card-btn.staff:hover {
    background: rgba(255, 200, 87, 0.15);
}

/* Touch-friendly on mobile */
@media (max-width: 767px) {
    .message-action-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* Pending message state (optimistic UI) */
.message.pending {
    opacity: 0.7;
}

.message.pending::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #b8964f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ========================================================
   ── USER CARD (hover card)
======================================================== */

/* =========================================================
   chatWS — Modern User Card
   Floating popover with rank-colored design
   ========================================================= */

/* ── Card container ──────────────────────────────────────── */
#cwsUserCard {
    position:     fixed;
    z-index:      9500;
    width:        290px;
    background:   #0f0f0f;
    border:       1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    box-shadow:   0 24px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
    overflow:     hidden;
    pointer-events: none;
    opacity:      0;
    transform:    scale(0.92) translateY(-6px);
    transition:   opacity .15s ease, transform .15s ease;
}
#cwsUserCard.visible {
    opacity:        1;
    transform:      scale(1) translateY(0);
    pointer-events: all;
}
#cwsUserCard.loading #cwsCardBtns { opacity: .4; pointer-events: none; }

/* ── Banner ──────────────────────────────────────────────── */
#cwsCardBanner {
    height:     80px;
    width:      100%;
    flex-shrink: 0;
}

/* ── Body ────────────────────────────────────────────────── */
#cwsCardBody {
    padding: 0 16px 18px;
}

/* ── Avatar ──────────────────────────────────────────────── */
#cwsCardAvatarWrap {
    --rc: #6b7280;
    position: relative;
    display:  inline-block;
    margin-top: -32px;
    margin-bottom: 8px;
}
#cwsCardAvatar {
    width:         64px;
    height:        64px;
    border-radius: 50%;
    object-fit:    cover;
    border:        3px solid var(--rc, #6b7280);
    background:    #222222;
    display:       block;
}

/* ── Online dot ──────────────────────────────────────────── */
.cws-dot {
    position:      absolute;
    bottom:        2px;
    right:         2px;
    width:         13px;
    height:        13px;
    border-radius: 50%;
    border:        2.5px solid #0f0f0f;
    background:    #6b7280;
}
.cws-dot.on  { background: #22c55e; }
.cws-dot.off { background: #6b7280; }

/* ── Name + badge ────────────────────────────────────────── */
#cwsCardMeta {
    display:     flex;
    align-items: center;
    gap:         8px;
    flex-wrap:   wrap;
    margin-bottom: 4px;
}
#cwsCardName {
    font-size:   16px;
    font-weight: 700;
    color:       #f5f5f5;
    line-height: 1.2;
}
#cwsCardBadge {
    display:       inline-block;
    font-size:     10px;
    font-weight:   700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding:       2px 7px;
    border-radius: 20px;
    white-space:   nowrap;
}

/* ── Bio ─────────────────────────────────────────────────── */
#cwsCardBio {
    font-size:   12px;
    color:       #a3a3a3;
    line-height: 1.5;
    margin:      6px 0 10px;
    word-break:  break-word;
}

/* ── Stats ───────────────────────────────────────────────── */
#cwsCardStats {
    display:       flex;
    gap:           16px;
    margin-bottom: 14px;
    padding:       10px 12px;
    background:    rgba(255,255,255,0.04);
    border-radius: 10px;
    border:        1px solid rgba(255,255,255,0.05);
}
.cws-stat {
    display:     flex;
    flex-direction: column;
    align-items: flex-start;
    gap:         1px;
}
.cws-stat b {
    font-size:   15px;
    font-weight: 700;
    color:       #f5f5f5;
}
.cws-stat span {
    font-size: 10px;
    color:     #737373;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ── Action buttons ──────────────────────────────────────── */
#cwsCardBtns {
    display:   flex;
    flex-wrap: wrap;
    gap:       7px;
}
.cws-card-btn {
    display:       inline-flex;
    align-items:   center;
    gap:           5px;
    padding:       7px 13px;
    border-radius: 10px;
    font-size:     12px;
    font-weight:   600;
    cursor:        pointer;
    border:        none;
    transition:    background .15s, transform .1s;
    line-height:   1;
}
.cws-card-btn:hover  { transform: translateY(-1px); }
.cws-card-btn:active { transform: translateY(0); }

.cws-card-btn.primary {
    background: #b8964f;
    color: #fff;
    flex: 1;
}
.cws-card-btn.primary:hover { background: #957637; }

.cws-card-btn.ghost {
    background: rgba(255,255,255,0.07);
    color: #d4d4d4;
    border: 1px solid rgba(255,255,255,0.1);
    flex: 1;
}
.cws-card-btn.ghost:hover { background: rgba(255,255,255,0.12); }

.cws-card-btn.icon-btn {
    background: rgba(255,255,255,0.07);
    color: #a3a3a3;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 7px 11px;
}
.cws-card-btn.icon-btn:hover { background: rgba(16,185,129,0.15); color: #34d399; border-color: rgba(16,185,129,0.3); }

.cws-card-btn.mod {
    background: rgba(239,68,68,0.1);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.25);
    flex: 1;
}
.cws-card-btn.mod:hover { background: rgba(239,68,68,0.2); }

/* ── Connection / blocking overlay ──────────────────────── */
#cwsBlockOverlay {
    position:   fixed;
    inset:      0;
    z-index:    99000;
    background: rgba(14,14,14,0.85);
    backdrop-filter: blur(6px);
    display:    none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap:        16px;
    color:      #f5f5f5;
    font-family: inherit;
}
#cwsBlockOverlay.visible { display: flex; }
#cwsBlockOverlay .cws-block-icon { font-size: 48px; }
#cwsBlockOverlay h2 { font-size: 22px; font-weight: 700; margin: 0; }
#cwsBlockOverlay p  { font-size: 14px; color: #a3a3a3; margin: 0; text-align: center; max-width: 320px; }
#cwsBlockOverlay .cws-block-btn {
    padding: 11px 28px;
    background: #b8964f;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
}
#cwsBlockOverlay .cws-block-btn:hover { background: #957637; }

/* ── Actions button (visible to all users) ────────────────── */
.cws-card-btn.actions {
    background: linear-gradient(135deg, #b8964f 0%, #957637 100%);
    color: #fff;
    border: none;
    font-weight: 700;
}
.cws-card-btn.actions:hover {
    opacity: .88;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(184,150,79,.4);
}


/* ========================================================
   ── PRIVATE MESSAGES
======================================================== */

/* ================================================================
   chatWS — pms.css  (full fixed version)
   PM inbox panel + PM chat box
   ================================================================ */

/* ── PM INBOX PANEL ─────────────────────────────────────────── */
.pm-inbox-panel,
#pmInboxPanel {
    position:       fixed;
    bottom:         12px;
    right:          360px;      /* sits left of the chat box on desktop */
    width:          300px;
    max-height:     calc(100vh - 80px);
    background:     var(--bg-panel, #0f0f0f);
    border-radius:  12px;
    box-shadow:     0 8px 32px rgba(0,0,0,.45);
    z-index:        1150;
    display:        none;       /* shown via openPmInbox() → style.display='flex' */
    flex-direction: column;
    overflow:       hidden;
    border:         1px solid rgba(255,255,255,.08);
}

/* ── PM inbox: mobile — stay on screen ───────────────────── */
@media (max-width: 768px) {
    .pm-inbox-panel,
    #pmInboxPanel {
        right:      8px;
        left:       8px;
        width:      auto;           /* stretch edge-to-edge with 8px gutters */
        bottom:     60px;           /* clear footer bar */
        max-height: calc(100vh - 80px);
    }
}

/* ── Inbox: header ────────────────────────────────────────── */
.pm-inbox-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         12px 14px;
    border-bottom:   1px solid rgba(255,255,255,.06);
    flex-shrink:     0;
    background:      rgba(255,255,255,.02);
}
.pm-inbox-title {
    font-size:   14px;
    font-weight: 700;
    color:       #f5f5f5;
    display:     flex;
    align-items: center;
    gap:         6px;
}
.pm-close-btn {
    background:    none;
    border:        none;
    cursor:        pointer;
    color:         #737373;
    font-size:     16px;
    padding:       4px 8px;
    border-radius: 6px;
    transition:    background .15s, color .15s;
    line-height:   1;
}
.pm-close-btn:hover { background: rgba(255,255,255,.08); color: #ddd; }

/* ── Inbox: search ────────────────────────────────────────── */
.pm-inbox-search {
    padding:      8px 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink:  0;
}
.pm-search-input {
    width:         100%;
    box-sizing:    border-box;
    padding:       7px 10px;
    border:        1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    font-size:     13px;
    outline:       none;
    background:    rgba(255,255,255,.06);
    color:         #f5f5f5;
}
.pm-search-input::placeholder { color: #525252; }

/* ── Inbox: conversation list ─────────────────────────────── */
.pm-list {
    flex:       1;
    min-height: 0;          /* critical for flex children to scroll correctly */
    overflow-y: auto;
    overflow-x: hidden;
    padding:    4px 0;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

/* Each conversation row */
.pmRow {
    display:      flex;
    align-items:  center;
    padding:      10px 14px;
    gap:          12px;
    cursor:       pointer;
    transition:   background .15s;
    border-bottom: 1px solid rgba(255,255,255,.04);
    min-height:   60px;
}
.pmRow:hover  { background: rgba(255,255,255,.05); }
.pmRow.unread { background: rgba(184,150,79,.08);  }

/* ── Avatar in conversation list ──────────────────────────── */
.pm-avatar-wrap {
    position:   relative;
    flex-shrink: 0;
}

/* Constrain ALL images in the avatar wrapper —
   pms.js renders <img> with NO class so .pmAvatar alone isn't enough */
.pm-avatar-wrap img,
.pm-avatar-wrap .pmAvatar,
.pmAvatar {
    width:         48px !important;
    height:        48px !important;
    min-width:     48px !important;
    max-width:     48px !important;
    border-radius: 50%;
    object-fit:    cover;
    display:       block;
    flex-shrink:   0;
}

/* Online dot */
.pm-online-dot {
    position:      absolute;
    bottom:        2px;
    right:         2px;
    width:         10px;
    height:        10px;
    border-radius: 50%;
    border:        2.5px solid #0f0f0f;
    background:    #525252;
}
.pm-online-dot.online { background: #22c55e; }

/* Row text (name + preview) */
.pmInfo {
    flex:       1;
    min-width:  0;
    overflow:   hidden;
}
.pmName {
    font-size:     13px;
    font-weight:   600;
    color:         #f5f5f5;
    display:       flex;
    align-items:   center;
    gap:           6px;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
}
.pm-unread-badge {
    background:    #b8964f;
    color:         #fff;
    font-size:     10px;
    padding:       1px 5px;
    border-radius: 8px;
    flex-shrink:   0;
}
.pmPreview {
    font-size:     12px;
    color:         #737373;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    margin-top:    2px;
}
.pmPreview i { color: #525252; }

/* ── Inbox: footer ────────────────────────────────────────── */
.pm-inbox-footer {
    padding:     8px 12px;
    border-top:  1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.pm-load-more {
    width:      100%;
    text-align: center;
    font-size:  12px;
    color:      #737373;
    cursor:     pointer;
}
.pm-load-more:hover { color: #a3a3a3; }

/* ── State messages ───────────────────────────────────────── */
.pm-empty,
.pm-error,
.pm-loading {
    text-align: center;
    padding:    20px 16px;
    color:      #737373;
    font-size:  13px;
}
.pm-error { color: #f87171; }

/* ================================================================
   PM CHAT BOX
   ================================================================ */
#pmBox {
    position:       fixed;
    bottom:         12px;
    right:          12px;
    width:          340px;
    max-width:      calc(100vw - 16px);
    height:         480px;
    max-height:     calc(100vh - 24px);
    background:     var(--bg-chat, #0c0c0c);
    border-radius:  12px;
    border:         1px solid rgba(255,255,255,.09);
    box-shadow:     0 8px 32px rgba(0,0,0,.5);
    z-index:        1160;   /* above inbox panel */
    display:        none;
    flex-direction: column;
    overflow:       hidden;
}
#pmBox.visible { display: flex; }

/* ── Box: header ──────────────────────────────────────────── */
.pm-box-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         0 14px;
    height:          50px;
    background:      rgba(255,255,255,.03);
    border-bottom:   1px solid rgba(255,255,255,.06);
    flex-shrink:     0;
    cursor:          grab;
}
.pm-box-header:active { cursor: grabbing; }

.pm-box-user    { display: flex; align-items: center; gap: 8px; }
.pm-status-dot  { width: 8px; height: 8px; border-radius: 50%; background: #525252; flex-shrink: 0; }
.pm-status-dot.online { background: #22c55e; }
.pm-box-name    { font-weight: 600; color: #f5f5f5; font-size: 14px; }
.pm-box-status  { font-size: 11px; color: #737373; }

.pm-box-controls { display: flex; gap: 2px; }
.pm-ctrl-btn {
    background:    none;
    border:        none;
    color:         #737373;
    font-size:     16px;
    cursor:        pointer;
    padding:       4px 7px;
    border-radius: 5px;
    transition:    color .15s, background .15s;
    line-height:   1;
}
.pm-ctrl-btn:hover            { color: #ddd;     background: rgba(255,255,255,.08); }
.pm-ctrl-btn.close:hover      { color: #f87171;  }

/* Collapsed: hide messages + input */
#pmBox.collapsed .pm-messages,
#pmBox.collapsed .pm-box-input { display: none; }

/* ── Box: messages area ───────────────────────────────────── */
#pmMessages,
.pm-messages {
    flex:           1;
    min-height:     0;
    overflow-y:     auto;
    padding:        12px;
    display:        flex;
    flex-direction: column;
    gap:            8px;
    scrollbar-width: thin;
}

.pm-msg         { display: flex; flex-direction: column; max-width: 80%; }
.pm-msg.mine    { align-self: flex-end;   align-items: flex-end;   }
.pm-msg.theirs  { align-self: flex-start; align-items: flex-start; }

.pm-msg-text {
    padding:       8px 12px;
    border-radius: 12px;
    font-size:     13px;
    line-height:   1.5;
    word-break:    break-word;
    color:         #f5f5f5;
}
.pm-msg.mine   .pm-msg-text { background: #957637; border-bottom-right-radius: 3px; }
.pm-msg.theirs .pm-msg-text { background: rgba(255,255,255,.09); border-bottom-left-radius: 3px; }

.pm-msg-meta {
    font-size:  10px;
    color:      #525252;
    margin-top: 3px;
    padding:    0 2px;
}
.pm-msg-seen { font-size: 10px; color: #b8964f; }

/* ── Box: input bar ───────────────────────────────────────── */
.pm-box-input {
    display:      flex;
    align-items:  flex-end;
    padding:      8px 10px;
    gap:          8px;
    background:   rgba(255,255,255,.02);
    border-top:   1px solid rgba(255,255,255,.06);
    flex-shrink:  0;
}

#pmInput,
.pm-input-field {
    flex:         1;
    min-height:   36px;
    max-height:   100px;
    padding:      8px 10px;
    border-radius: 8px;
    border:       1px solid rgba(255,255,255,.12);
    background:   rgba(255,255,255,.06);
    color:        #f5f5f5;
    font-size:    13px;
    resize:       none;
    outline:      none;
    font-family:  inherit;
    line-height:  1.4;
    overflow-y:   auto;
}
#pmInput:focus,
.pm-input-field:focus       { border-color: rgba(184,150,79,.5); }
#pmInput::placeholder,
.pm-input-field::placeholder { color: #525252; }

.pm-send-btn {
    width:         36px;
    height:        36px;
    flex-shrink:   0;
    background:    #b8964f;
    border:        none;
    border-radius: 8px;
    color:         #fff;
    cursor:        pointer;
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-size:     14px;
    transition:    background .15s;
}
.pm-send-btn:hover { background: #957637; }

/* ── Box: avatar inside thread ────────────────────────────── */
.pm-avatar-wrap { position: relative; flex-shrink: 0; }
.pm-msg-avatar  {
    width:         28px;
    height:        28px;
    border-radius: 50%;
    object-fit:    cover;
    display:       block;
}

/* ================================================================
   MOBILE  ≤ 768px
   Both panels become full-screen overlays above EVERYTHING,
   including the dropdown menu (z-index 1100)
   ================================================================ */
@media (max-width: 768px) {

    /* ── Full-screen backdrop behind panels ───────────────── */
    .pm-inbox-panel::before,
    #pmInboxPanel::before {
        content:    '';
        position:   fixed;
        inset:      0;
        background: rgba(0,0,0,.5);
        z-index:    -1;
    }

    /* ── Inbox panel — full screen ────────────────────────── */
    .pm-inbox-panel,
    #pmInboxPanel {
        position:      fixed   !important;
        top:           0       !important;
        right:         0       !important;
        bottom:        0       !important;
        left:          0       !important;
        width:         100%    !important;
        max-width:     100%    !important;
        /* Was a plain 100%/100vh pair. On phones with a bottom gesture
           bar / home indicator, "100%" of the viewport runs UNDER that
           OS chrome, so the last conversation row (and the "Load More"
           footer) rendered partly hidden behind it — exactly what the
           screenshot shows. dvh tracks the real visible viewport where
           supported. The padding below adds a flat 14px cushion ON TOP
           of whatever safe-area inset the browser reports — Android
           Chrome typically reports env(safe-area-inset-bottom) as a
           flat 0px even while its own gesture pill floats over the
           page, so relying on env() alone left this identical on
           Android; the fixed 14px is what actually creates clearance
           there, while iOS's real inset still adds on top of it. */
        height:        100vh   !important;
        height:        100dvh  !important;
        max-height:    100vh   !important;
        max-height:    100dvh  !important;
        padding-top:    env(safe-area-inset-top, 0px)             !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing:    border-box !important;
        border-radius: 0       !important;
        z-index:       1300    !important; /* above dropdown (1100) + avatar menu */
        display:       none;               /* still toggled by JS */
    }

    /* ── PM chat box — full screen, slides from right ─────── */
    #pmBox {
        position:      fixed   !important;
        top:           0       !important;
        right:         0       !important;
        bottom:        0       !important;
        left:          0       !important;
        width:         100%    !important;
        /* Same dvh + safe-area fix as the inbox panel above, so the
           header isn't crowded by the status/URL bar and the message
           input isn't hidden behind the home-indicator / gesture bar
           (see the fuller explanation on the inbox panel rule above —
           same Android-reports-0 caveat applies here). */
        height:        100vh   !important;
        height:        100dvh  !important;
        max-width:     100%    !important;
        max-height:    100vh   !important;
        max-height:    100dvh  !important;
        padding-top:    env(safe-area-inset-top, 0px)             !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing:    border-box !important;
        border-radius: 0       !important;
        z-index:       1310    !important;
        border:        none    !important;
    }

    /* Slide-in animation */
    #pmBox.visible {
        display:   flex;
        animation: pmSlideIn .2s ease both;
    }
    @keyframes pmSlideIn {
        from { transform: translateX(100%); opacity: 0; }
        to   { transform: translateX(0);    opacity: 1; }
    }

    /* Bigger header touch targets */
    .pm-box-header,
    .pm-inbox-header { padding: 0 16px; height: 56px; cursor: default; }
    .pm-inbox-header  { height: auto; padding: 14px 16px; }
    .pm-box-name,
    .pm-inbox-title   { font-size: 16px; }

    /* Larger avatar in inbox on mobile */
    .pm-avatar-wrap img,
    .pm-avatar-wrap .pmAvatar,
    .pmAvatar {
        width:     48px !important;
        height:    48px !important;
        min-width: 48px !important;
    }

    /* Rows taller for touch */
    .pmRow { padding: 12px 16px; min-height: 68px; }

    /* Messages fill available height */
    #pmMessages,
    .pm-messages {
        flex:       1;
        max-height: none;
        min-height: 0;
    }

    /* Input bar taller on mobile */
    .pm-box-input { padding: 10px 12px; }
    #pmInput,
    .pm-input-field { font-size: 15px; min-height: 40px; }
    .pm-send-btn    { width: 42px; height: 40px; }

    /* Collapse button hidden on mobile (doesn't make sense full-screen) */
    .pm-ctrl-btn[title="Collapse"],
    #pmCollapseBtn { display: none; }
}


/* ========================================================
   ── FRIENDS PANEL + TOASTS
======================================================== */

/* ============================================================
   chatWS — friends.css
   Friends panel, requests, add-friend search, toasts
============================================================ */

/* ── FRIENDS PANEL ──────────────────────────────────────────── */
.friends-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 80px);
    background: var(--bg-panel, #fff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border, #e5e7eb);
}

.friends-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}
.friends-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #111);
}
.friends-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #888);
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.friends-close-btn:hover { background: var(--bg-hover, #f3f4f6); }

/* ── TABS ────────────────────────────────────────────────────── */
.friends-tabs {
    display: flex;
    gap: 0;
    padding: 8px 12px 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}
.friends-tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #888);
    transition: color .15s, border-color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.friends-tab-btn.active {
    color: var(--accent, #b8964f);
    border-bottom-color: var(--accent, #b8964f);
}

/* ── FRIENDS LIST ────────────────────────────────────────────── */
.friends-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}
.friends-tab-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.friend-item, .friend-request-item {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 10px;
    cursor: pointer;
    transition: background .15s;
}
.friend-item:hover { background: var(--bg-hover, #f9fafb); }

.friend-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.friend-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.friend-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-panel, #fff);
    background: var(--text-muted, #bbb);
}
.friend-online-dot.online { background: #22c55e; }

.friend-info {
    flex: 1;
    min-width: 0;
}
.friend-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.friend-status {
    font-size: 11px;
    color: var(--text-muted, #888);
}
.friend-item.online .friend-status { color: #22c55e; }

.friend-actions, .friend-req-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.friend-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.friend-btn.pm     { background: #ede9fe; color: #b8964f; }
.friend-btn.pm:hover { background: #b8964f; color: #fff; }
.friend-btn.view   { background: #e0f2fe; color: #0ea5e9; }
.friend-btn.view:hover { background: #0ea5e9; color: #fff; }
.friend-btn.remove { background: #fee2e2; color: #ef4444; }
.friend-btn.remove:hover { background: #ef4444; color: #fff; }
.friend-btn.accept { background: #dcfce7; color: #22c55e; }
.friend-btn.accept:hover { background: #22c55e; color: #fff; }
.friend-btn.decline { background: #fee2e2; color: #ef4444; }
.friend-btn.decline:hover { background: #ef4444; color: #fff; }
.friend-btn.add    { background: #ede9fe; color: #b8964f; font-size: 12px; width: auto; padding: 0 10px; }
.friend-btn.add:hover { background: #b8964f; color: #fff; }

.friends-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted, #888);
    font-size: 13px;
}

/* ── ADD FRIEND SEARCH ───────────────────────────────────────── */
.add-friend-search {
    padding: 10px 14px 0;
}
.add-friend-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: var(--bg-input, #f9fafb);
}
.add-friend-results {
    padding: 8px 0;
    overflow-y: auto;
    max-height: 300px;
}
.fr-search-row {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 10px;
}
.fr-search-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}
.fr-search-info { flex: 1; }
.fr-search-name  { font-size: 13px; font-weight: 600; color: var(--text-primary, #111); }
.fr-search-rank  { font-size: 11px; color: var(--text-muted, #888); }
.fr-search-empty { padding: 16px; text-align: center; color: var(--text-muted, #888); font-size: 13px; }

/* ── TOASTS ──────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    background: #1f1f1f;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: all;
    min-width: 220px;
    max-width: 360px;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast-success { background: #166534; }
.toast-error   { background: #991b1b; }
.toast-info    { background: #262626; }

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* ── PM BOX ONLINE DOT ───────────────────────────────────────── */
.pm-online-dot, .pm-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
    display: inline-block;
    flex-shrink: 0;
}
.pm-online-dot.online, .pm-status-dot.online { background: #22c55e; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .friends-panel {
        right: 0;
        left: 0;
        top: 56px;
        width: 100%;
        max-height: calc(100vh - 56px);
        border-radius: 0;
    }
    .toast-container { left: 12px; top: 12px; }
}


/* ========================================================
   ── LOGIN PAGE ADDITIONS
======================================================== */

/* ============================================================
   chatWS — login additions (append to chat.css)
   Covers: login page, popups, form elements, error states
============================================================ */

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 24px 16px;
    text-align: center;
}

.login-logo {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent, #b8964f);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.login-logo i { font-size: 36px; }

.login-tagline {
    color: var(--text-muted, #888);
    font-size: 14px;
    margin: 0 0 28px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 24px;
}

.login-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.login-buttons .btn {
    min-width: 120px;
}

/* ── POPUPS ──────────────────────────────────────────────── */
.popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.popup.hidden { display: none; }

.popup-content {
    background: var(--bg-card, #111111);
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 380px;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.popup-content h3 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 700;
}

.popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ── FORM ELEMENTS ───────────────────────────────────────── */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #aaa);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.05);
    color: var(--text-primary, #fafafa);
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent, #b8964f);
}

.form-error {
    color: #ef4444;
    font-size: 12px;
    margin: 6px 0 8px;
    display: none;
    padding: 8px 10px;
    background: rgba(239,68,68,.1);
    border-radius: 6px;
    border: 1px solid rgba(239,68,68,.2);
}

.field-hint {
    font-weight: 400;
    text-transform: none;
    opacity: .7;
    font-size: 11px;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.07);
    color: var(--text-primary, #fafafa);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
    background: var(--accent, #b8964f);
    border-color: var(--accent, #b8964f);
    color: #fff;
}
.btn.primary:hover { background: var(--accent-dark, #957637); }

.btn.ghost {
    background: transparent;
    border-color: rgba(255,255,255,.2);
}
.btn.ghost:hover { background: rgba(255,255,255,.06); }

.btn.danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn.danger:hover { background: #dc2626; }

.btn.secondary { background: rgba(255,255,255,.08); }

.btn.small { padding: 6px 12px; font-size: 12px; }

.full-width { width: 100%; margin-top: 6px; }

/* ── ELEMENT BOX (modal overlay) ─────────────────────────── */
.element-box {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.element-box.visible { display: flex; }

.element-box-backdrop {
    position: absolute;
    inset: 0;
}

.element-box-inner {
    position: relative;
    background: var(--bg-card, #111111);
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.element-close {
    position: absolute;
    top: 12px; right: 12px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 4px;
    transition: color .15s;
}
.element-close:hover { color: #fff; }

/* ── REQUIRED INDICATOR ──────────────────────────────────── */
.required { color: #ef4444; }