/* ============================================
   FRIENDS PANEL PREMIUM REDESIGN v2
   Enhanced visual design for Home/DM/Friends UI
   ============================================ */

/* Main Panel - Darker, more premium feel */
.friends-panel {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    color: #e6e9ee;
}

/* Top Bar - Sleek header with subtle gradient */
.friends-topbar {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(200px, 1.2fr) auto;
    gap: 20px;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(88, 101, 242, 0.08) 0%, transparent 100%);
    position: sticky;
    top: 0;
    z-index: 2;
}

.friends-topbar-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.friends-title {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.friends-title::before {
    content: '👥';
    font-size: 18px;
}

.friends-subtitle {
    font-size: 12px;
    color: rgba(230, 233, 238, 0.6);
}

/* Search Box - Modern pill design */
.friends-topbar-search {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 21px;
    padding: 0 16px;
    transition: all 0.2s ease;
}

.friends-topbar-search:focus-within {
    border-color: rgba(88, 101, 242, 0.6);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

.friends-topbar-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 14px;
}

.friends-topbar-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.friends-search-icon {
    color: rgba(255, 255, 255, 0.5);
}

/* Action Buttons */
.friends-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.friends-add-btn {
    height: 40px;
    padding: 0 20px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

.friends-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 101, 242, 0.4);
}

.friends-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.friends-close-btn:hover {
    background: rgba(237, 66, 69, 0.2);
    border-color: rgba(237, 66, 69, 0.5);
    color: #ed4245;
}

/* Main Shell Layout */
.friends-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 340px;
    gap: 20px;
    padding: 20px 24px 24px;
    height: calc(100% - 76px);
    overflow: hidden;
}

/* Left Navigation Sidebar */
.friends-nav {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    height: 100%;
    overflow-y: auto;
}

.friends-nav-title {
    font-weight: 700;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}

/* Tab Buttons - Modern pill style */
.friends-nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.friends-tab {
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.friends-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.friends-tab.active {
    background: linear-gradient(90deg, rgba(88, 101, 242, 0.25), rgba(88, 101, 242, 0.1));
    color: #ffffff;
    font-weight: 600;
    border-left: 3px solid #5865f2;
    padding-left: 11px;
}

.friends-tab[data-tab="online"]::before {
    content: '🟢';
    font-size: 10px;
}

.friends-tab[data-tab="all"]::before {
    content: '📋';
    font-size: 12px;
}

.friends-tab[data-tab="pending"]::before {
    content: '⏳';
    font-size: 12px;
}

/* Search in sidebar */
.friends-nav-search input {
    width: 100%;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    padding: 0 12px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.friends-nav-search input:focus {
    border-color: rgba(88, 101, 242, 0.5);
    outline: none;
}

.friends-nav-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* DM Section */
.friends-dm-section {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.friends-dm-title {
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    padding: 0 4px;
}

.friends-dm-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

/* DM Item - Clean Discord style */
.friends-dm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.friends-dm-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.friends-dm-item.active {
    background: rgba(88, 101, 242, 0.15);
    border-color: rgba(88, 101, 242, 0.3);
}

.friends-dm-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.friends-dm-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.friends-dm-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 3px solid #1a1a2e;
}

.friends-dm-status.online {
    background: #3ba55c;
}

.friends-dm-status.offline {
    background: #747f8d;
}

.friends-dm-meta {
    flex: 1;
    min-width: 0;
}

.friends-dm-name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friends-dm-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* Main Content Area */
.friends-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.friends-main-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
}

.friends-main-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.friends-main-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* Friends List Container */
.friends-main .friends-list,
.friends-main .friends-grid {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

/* Friend Row - Discord style list item */
.friend-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.friend-row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.friend-row.selected {
    background: rgba(88, 101, 242, 0.15);
    border-color: rgba(88, 101, 242, 0.4);
}

/* Friend Card (alternative grid style) */
.friend-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    transition: all 0.15s ease;
    cursor: pointer;
}

.friend-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.friend-card.selected {
    background: rgba(88, 101, 242, 0.15);
    border-color: rgba(88, 101, 242, 0.5);
    box-shadow: 0 0 20px rgba(88, 101, 242, 0.2);
}

/* Friend Avatar */
.friend-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.friend-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.friend-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid #1a1a2e;
}

.friend-status.online {
    background: #3ba55c;
}

.friend-status.offline {
    background: #747f8d;
}

.friend-status.idle {
    background: #faa61a;
}

.friend-status.dnd {
    background: #ed4245;
}

.friend-meta {
    flex: 1;
    min-width: 0;
}

.friend-name {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-presence {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* Friend Action Buttons */
.friend-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.friend-row:hover .friend-actions,
.friend-card:hover .friend-actions {
    opacity: 1;
}

.friend-actions button {
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.friend-actions .message-btn,
.friend-actions .profile-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.friend-actions .message-btn:hover,
.friend-actions .profile-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.friend-actions .accept-btn {
    background: linear-gradient(135deg, #3ba55c 0%, #2d8c4e 100%);
    color: #ffffff;
}

.friend-actions .accept-btn:hover {
    transform: scale(1.05);
}

.friend-actions .reject-btn {
    background: rgba(237, 66, 69, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(237, 66, 69, 0.3);
}

.friend-actions .reject-btn:hover {
    background: rgba(237, 66, 69, 0.3);
}

/* Right Preview Panel */
.friends-preview {
    position: relative;
}

.friends-preview-inner {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 20px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Empty Preview State */
.friends-preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.friends-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(88, 101, 242, 0.15);
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.friends-empty-icon svg {
    color: #7289da;
}

.friends-empty-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
}

.friends-empty-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
    max-width: 200px;
}

/* Profile Preview Panel */
.friends-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.friends-preview-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.friends-preview-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 24px;
    overflow: hidden;
    flex-shrink: 0;
}

.friends-preview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.friends-preview-info {
    flex: 1;
}

.friends-preview-name {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.friends-preview-status {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
}

.friends-preview-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #747f8d;
}

.friends-preview-status.online::before {
    background: #3ba55c;
}

.friends-preview-status.offline::before {
    background: #747f8d;
}

/* Action Buttons in Preview */
.friends-preview-actions {
    display: flex;
    gap: 10px;
}

.friends-preview-dm {
    flex: 1;
    height: 42px;
    padding: 0 20px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.friends-preview-dm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

/* Meta Info Grid */
.friends-preview-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.friends-preview-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.friends-preview-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

.friends-preview-value {
    font-size: 14px;
    color: #ffffff;
}

/* DM Chat Preview */
.friends-preview-chat {
    display: none;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.friends-preview-panel.mode-dm .friends-preview-chat {
    display: flex;
}

.friends-preview-messages {
    flex: 1;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.friends-preview-message {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.friends-preview-message:last-child {
    border-bottom: none;
}

.friends-preview-author {
    font-size: 12px;
    font-weight: 600;
    color: #7289da;
    margin-bottom: 4px;
}

.friends-preview-text {
    font-size: 14px;
    color: #ffffff;
    line-height: 1.4;
}

/* Message Input */
.friends-preview-input {
    display: flex;
    gap: 10px;
}

.friends-preview-input input {
    flex: 1;
    height: 42px;
    border-radius: 21px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    padding: 0 16px;
    font-size: 14px;
}

.friends-preview-input input:focus {
    border-color: rgba(88, 101, 242, 0.5);
    outline: none;
}

.friends-preview-input button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.2s ease;
}

.friends-preview-input button:hover {
    transform: scale(1.1);
}

/* Add Friend Modal */
.friends-add-section {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.friends-add-section.open {
    display: flex;
}

.friends-add-card {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.friends-add-title {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
}

.friends-add-desc {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
    line-height: 1.5;
}

.friends-add-row {
    display: flex;
    gap: 12px;
}

.friends-add-row input {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    padding: 0 16px;
    font-size: 15px;
}

.friends-add-row input:focus {
    border-color: rgba(88, 101, 242, 0.5);
    outline: none;
}

.friends-add-row button {
    height: 48px;
    padding: 0 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.friends-add-row button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}

/* Empty States */
.friends-empty,
.friends-dm-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
}

.friends-empty-cta {
    margin-top: 16px;
    height: 40px;
    padding: 0 24px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #5865f2 0%, #7289da 100%);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

/* Skeleton Loading */
.friends-skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-row.skeleton {
    background: rgba(255, 255, 255, 0.05);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }
}

.skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.skeleton-text {
    height: 14px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.full {
    width: 100%;
}

/* ============================================
   RESPONSIVE — Mobile-first Premium Friends UI
   ============================================ */

/* Tablet — Hide preview, compact nav */
@media (max-width: 1200px) {
    .friends-shell {
        grid-template-columns: 220px 1fr 280px;
    }
}

@media (max-width: 1024px) {
    .friends-shell {
        grid-template-columns: 200px 1fr;
    }

    .friends-preview {
        display: none;
    }

    .friends-panel.preview-open .friends-preview {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.9);
        z-index: 100;
        padding: 20px;
    }
}

/* ============================================
   MOBILE (≤768px) — Full redesign
   ============================================ */
@media (max-width: 768px) {

    /* --- Friends Panel — full screen --- */
    .friends-panel {
        position: fixed !important;
        inset: 0 !important;
        z-index: 9999 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* --- Top Bar — stacked, mobile friendly --- */
    .friends-topbar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 14px 16px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        background: linear-gradient(180deg, rgba(88, 101, 242, 0.1) 0%, transparent 100%) !important;
    }

    .friends-topbar-title {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .friends-title {
        font-size: 18px !important;
    }

    .friends-subtitle {
        font-size: 11px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .friends-topbar-search {
        display: none !important;
    }

    .friends-topbar-actions {
        gap: 8px !important;
        flex-shrink: 0 !important;
    }

    .friends-add-btn {
        height: 38px !important;
        padding: 0 16px !important;
        font-size: 13px !important;
        border-radius: 19px !important;
        min-height: 38px !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .friends-close-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 20px !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* --- Shell — single column, fill remaining space --- */
    .friends-shell {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        padding: 0 !important;
        gap: 0 !important;
        height: auto !important;
        flex: 1 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* --- Nav — Horizontal scrollable tabs (not hidden!) --- */
    .friends-nav {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        background: rgba(0, 0, 0, 0.2) !important;
        border: none !important;
        border-radius: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
    }

    .friends-nav-title,
    .friends-nav-search,
    .friends-dm-section {
        display: none !important;
    }

    .friends-nav-tabs {
        display: flex !important;
        flex-direction: row !important;
        gap: 0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding: 0 12px !important;
    }

    .friends-nav-tabs::-webkit-scrollbar {
        display: none !important;
    }

    .friends-tab {
        flex-shrink: 0 !important;
        height: 44px !important;
        padding: 0 16px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-bottom: 3px solid transparent !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        -webkit-tap-highlight-color: transparent !important;
        text-transform: uppercase !important;
        letter-spacing: 0.3px !important;
    }

    .friends-tab.active {
        border-left: none !important;
        padding-left: 16px !important;
        border-bottom-color: #5865f2 !important;
        background: rgba(88, 101, 242, 0.1) !important;
        color: #fff !important;
    }

    .friends-tab:hover {
        background: rgba(255, 255, 255, 0.05) !important;
    }

    /* --- Main content — scrollable --- */
    .friends-main {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 12px !important;
        gap: 12px !important;
    }

    .friends-main-header {
        padding: 4px 4px 0 !important;
    }

    .friends-main-title {
        font-size: 16px !important;
    }

    .friends-main-subtitle {
        font-size: 12px !important;
    }

    .friends-main .friends-list,
    .friends-main .friends-grid {
        padding-right: 0 !important;
    }

    /* --- Friend Row — touch optimized --- */
    .friend-row {
        padding: 12px !important;
        gap: 12px !important;
        border-radius: 14px !important;
        margin-bottom: 8px !important;
        background: rgba(0, 0, 0, 0.25) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    .friend-row:hover,
    .friend-card:hover {
        transform: none !important;
    }

    .friend-row:active,
    .friend-card:active {
        background: rgba(88, 101, 242, 0.12) !important;
    }

    .friend-avatar {
        width: 42px !important;
        height: 42px !important;
        font-size: 16px !important;
    }

    .friend-name {
        font-size: 15px !important;
    }

    .friend-presence {
        font-size: 12px !important;
    }

    /* Always visible actions on mobile (no hover) */
    .friend-actions {
        opacity: 1 !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
    }

    .friend-actions button {
        min-height: 38px !important;
        padding: 0 14px !important;
        font-size: 13px !important;
        border-radius: 10px !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* --- Empty State — centered, premium look --- */
    .friends-empty,
    .friends-dm-empty {
        padding: 48px 24px !important;
        text-align: center !important;
    }

    .friends-empty-icon {
        width: 72px !important;
        height: 72px !important;
        margin-bottom: 20px !important;
    }

    .friends-empty-title {
        font-size: 18px !important;
    }

    .friends-empty-desc {
        font-size: 14px !important;
        max-width: 260px !important;
        margin: 0 auto !important;
        line-height: 1.6 !important;
    }

    .friends-empty-cta {
        margin-top: 20px !important;
        height: 44px !important;
        padding: 0 28px !important;
        font-size: 15px !important;
        border-radius: 22px !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    /* --- Add Friend Modal — bottom sheet style --- */
    .friends-add-section {
        align-items: flex-end !important;
    }

    .friends-add-card {
        max-width: 100vw !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 24px 20px !important;
        padding-bottom: 28px !important;
        animation: slideUpFriends 0.25s ease !important;
    }

    .friends-add-title {
        font-size: 18px !important;
    }

    .friends-add-desc {
        font-size: 14px !important;
    }

    .friends-add-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .friends-add-row input,
    .friends-add-row button {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 16px !important;
        border-radius: 14px !important;
    }

    /* --- Preview panel on mobile — bottom sheet --- */
    .friends-preview {
        display: none !important;
    }

    .friends-panel.preview-open .friends-preview {
        display: flex !important;
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        max-height: 70vh !important;
        background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%) !important;
        border-radius: 20px 20px 0 0 !important;
        z-index: 10001 !important;
        padding: 24px 20px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        animation: slideUpFriends 0.25s ease !important;
    }

    .friends-preview-inner {
        min-height: auto !important;
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
    }

    /* --- Context menu on mobile --- */
    .friend-context-menu {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .friend-context-menu-item {
        min-height: 48px !important;
        padding: 12px 20px !important;
        font-size: 15px !important;
        -webkit-tap-highlight-color: transparent !important;
    }
}

@keyframes slideUpFriends {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   EXTRA SMALL (≤480px)
   ============================================ */
@media (max-width: 480px) {
    .friends-topbar {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    .friends-title {
        font-size: 16px !important;
    }

    .friends-title::before {
        font-size: 14px !important;
    }

    .friends-add-btn {
        height: 34px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
    }

    .friends-close-btn {
        width: 34px !important;
        height: 34px !important;
    }

    .friends-tab {
        height: 40px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
    }

    .friends-main {
        padding: 8px !important;
    }

    .friend-row {
        padding: 10px !important;
        gap: 10px !important;
    }

    .friend-avatar {
        width: 38px !important;
        height: 38px !important;
        font-size: 14px !important;
    }

    .friend-name {
        font-size: 14px !important;
    }

    .friend-presence {
        font-size: 11px !important;
    }

    .friend-actions button {
        font-size: 12px !important;
        padding: 0 10px !important;
        min-height: 34px !important;
    }
}

/* ============================================
   iOS Safe Area
   ============================================ */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .friends-topbar {
            padding-top: calc(14px + env(safe-area-inset-top)) !important;
        }

        .friends-add-card {
            padding-bottom: calc(28px + env(safe-area-inset-bottom)) !important;
        }
    }
}