/* ---------- Friends rail ---------- */
.rail-friends {
    background: #1b1d29;
    color: #b7b3c7;
}

.rail-friends .icon {
    width: 21px;
    height: 21px;
}

.rail-friends:hover {
    color: #fff;
    background: #252838;
}

.rail-friends.is-active {
    color: #fff;
    background: linear-gradient(145deg, rgba(139, 109, 255, .28), rgba(139, 109, 255, .14));
    border-color: rgba(139, 109, 255, .22);
}

.rail-count-badge {
    position: absolute;
    top: -3px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-strong);
    border: 2px solid var(--bg-rail);
    color: #fff;
    font-size: 8px;
    font-weight: 750;
    line-height: 1;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .35);
}

/* ---------- Friends view ---------- */
.friends-view {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    background: var(--bg-chat);
}

.friends-sidebar {
    width: 280px;
    flex: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid rgba(255, 255, 255, .045);
    z-index: 20;
}

.friends-sidebar-header {
    height: 64px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid rgba(0, 0, 0, .18);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .025);
}

.friends-sidebar-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.friends-sidebar-mark {
    display: grid;
    place-items: center;
    width: 31px;
    height: 31px;
    border-radius: 9px;
    background: rgba(139, 109, 255, .12);
    border: 1px solid rgba(139, 109, 255, .14);
    color: #bfb0ff;
    flex: none;
}

.friends-sidebar-mark .icon {
    width: 16px;
    height: 16px;
}

.friends-sidebar-title > div {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.friends-sidebar-title strong {
    color: #e7e3ee;
    font-size: 13px;
    font-weight: 680;
    letter-spacing: -.02em;
}

.friends-sidebar-title .eyebrow {
    font-size: 7.5px;
}

.friends-sidebar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.friends-sidebar-close {
    display: none;
}

.friends-sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 10px 16px;
}

.friends-nav-button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    height: 39px;
    padding: 0 9px;
    border-radius: 9px;
    color: #a6a3b6;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}

.friends-nav-button:hover {
    color: #e3dfec;
    background: rgba(255, 255, 255, .045);
}

.friends-nav-button.is-active {
    color: #f2eef9;
    background: rgba(139, 109, 255, .12);
}

.friends-nav-icon {
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    color: #86889b;
    flex: none;
}

.friends-nav-button.is-active .friends-nav-icon {
    color: #c4b5ff;
}

.friends-nav-icon .icon {
    width: 16px;
    height: 16px;
}

.friends-nav-label {
    flex: 1;
}

.friends-count-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .08);
    color: #c9c5d8;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
}

.friends-nav-button .friends-count-badge {
    background: var(--accent-strong);
    color: #fff;
}

.friends-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 9px 7px;
    color: #707286;
    font-size: 8.5px;
    font-weight: 750;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.friends-section-label span:last-child {
    color: #555768;
    font-weight: 600;
    letter-spacing: 0;
}

.friends-dm-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dm-conversation {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 8px;
    border-radius: 8px;
    text-align: left;
    color: #a8a5b8;
    transition: background var(--transition), color var(--transition);
}

.dm-conversation:hover {
    background: rgba(255, 255, 255, .04);
    color: #e1ddea;
}

.dm-conversation.is-active {
    background: rgba(139, 109, 255, .11);
    color: #f3eff9;
}

.dm-conversation .avatar-wrap {
    flex: none;
}

.dm-conversation-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.dm-conversation-top {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.dm-conversation-name {
    font-size: 11px;
    font-weight: 620;
    color: #cfccd9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.dm-conversation.is-active .dm-conversation-name {
    color: #fff;
}

.dm-conversation-preview {
    color: #67697b;
    font-size: 8.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dm-conversation-unread {
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-strong);
    color: #fff;
    font-size: 7.5px;
    font-weight: 750;
    flex: none;
}

.friends-dm-empty {
    padding: 8px 9px 3px;
    color: #656779;
    font-size: 9px;
    line-height: 1.5;
}

.friends-sidebar-note {
    flex: none;
    margin: 0;
    padding: 12px 18px 14px;
    color: #535566;
    border-top: 1px solid rgba(0, 0, 0, .16);
    font-size: 8px;
    line-height: 1.45;
}

/* ---------- Friends main / header ---------- */
.friends-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 72% -10%, rgba(139, 109, 255, .055), transparent 36%),
        var(--bg-chat);
}

.friends-main-header {
    height: 64px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 0 24px;
    border-bottom: 1px solid rgba(0, 0, 0, .22);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .025);
    position: relative;
    z-index: 10;
}

.friends-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.friends-header-content .avatar {
    width: 34px;
    height: 34px;
    font-size: 10px;
}

.friends-header-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.friends-header-copy h2 {
    color: #f2eff8;
    font-size: 14px;
    font-weight: 680;
    letter-spacing: -.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friends-header-copy span {
    color: #717386;
    font-size: 9px;
}

.friends-header-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.friends-header-icon {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 8px;
    background: rgba(139, 109, 255, .11);
    color: #b8a8fc;
}

.friends-header-icon .icon {
    width: 16px;
    height: 16px;
}

.friends-header-title h2 {
    font-size: 14px;
    font-weight: 690;
    letter-spacing: -.015em;
}

.friends-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
}

.friends-header-actions .button {
    min-height: 32px;
    padding: 0 11px;
    font-size: 10.5px;
    border-radius: 8px;
}

.friends-back-button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #8b8da0;
    flex: none;
}

.friends-back-button:hover {
    background: rgba(255, 255, 255, .055);
    color: #ddd9e8;
}

.friends-back-button .icon {
    width: 17px;
    height: 17px;
}

.friends-main-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Friends page ---------- */
.friends-page {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.friends-tabs {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 28px 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.friends-tabs::-webkit-scrollbar {
    display: none;
}

.friends-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px 13px;
    color: #828497;
    font-size: 11px;
    font-weight: 620;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}

.friends-tab:hover {
    color: #c4c0d1;
}

.friends-tab.is-active {
    color: #f2eef9;
    border-bottom-color: var(--accent);
}

.friends-tab-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .07);
    color: #aaa6b8;
    font-size: 7.5px;
}

.friends-tab.is-active .friends-tab-count {
    background: var(--accent-strong);
    color: #fff;
}

.friends-page-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 30px 36px;
}

.friends-page-inner {
    width: min(920px, 100%);
    margin: 0 auto;
}

.friends-page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.friends-page-heading h3 {
    font-size: 18px;
    font-weight: 670;
    letter-spacing: -.03em;
}

.friends-page-heading p {
    margin-top: 4px;
    color: #7b7d90;
    font-size: 10.5px;
}

.friends-page-count {
    color: #6a6c7e;
    font-size: 9px;
}

.friends-list-group + .friends-list-group {
    margin-top: 24px;
}

.friends-group-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 5px 7px;
    color: #6e7083;
    font-size: 8.5px;
    font-weight: 750;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.friends-group-label span {
    color: #505263;
    font-weight: 600;
    letter-spacing: 0;
}

.friend-row {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 61px;
    padding: 8px 10px;
    border-radius: 11px;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}

.friend-row:hover {
    background: rgba(255, 255, 255, .028);
    border-color: rgba(255, 255, 255, .045);
}

.friend-row-main {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 1;
    min-width: 0;
    text-align: left;
}

.friend-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.friend-copy strong {
    color: #d4d0de;
    font-size: 12px;
    font-weight: 620;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-copy span {
    color: #6d6f82;
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: none;
}

.friend-actions .button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 9.5px;
    border-radius: 7px;
}

.friend-action-icon {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 7px;
    color: #77798c;
    transition: background var(--transition), color var(--transition);
}

.friend-action-icon:hover {
    background: rgba(255, 255, 255, .06);
    color: #d5d1df;
}

.friend-action-icon .icon {
    width: 15px;
    height: 15px;
}

.friends-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 330px;
    padding: 40px 20px;
    text-align: center;
}

.friends-empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 19px;
    border: 1px solid rgba(139, 109, 255, .15);
    background: rgba(139, 109, 255, .08);
    color: #b5a4f4;
}

.friends-empty-icon .icon {
    width: 27px;
    height: 27px;
}

.friends-empty h3 {
    margin-top: 16px;
    font-size: 17px;
    font-weight: 660;
    letter-spacing: -.025em;
}

.friends-empty p {
    margin-top: 5px;
    max-width: 330px;
    color: #7a7c8f;
    font-size: 11px;
    line-height: 1.55;
}

.friend-request-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .018);
    border: 1px solid var(--line);
}

.friend-request-row + .friend-request-row {
    margin-top: 4px;
}

.friend-request-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.friend-request-copy strong {
    color: #d0ccdb;
    font-size: 11.5px;
    font-weight: 620;
}

.friend-request-copy span {
    color: #686a7c;
    font-size: 9px;
}

.friend-request-actions {
    display: flex;
    gap: 5px;
    flex: none;
}

.friend-request-actions .button {
    min-height: 29px;
    font-size: 9px;
    padding: 0 8px;
    border-radius: 6px;
}

.friends-pending-section + .friends-pending-section {
    margin-top: 27px;
}

.add-friend-card {
    padding: 22px;
    border-radius: 16px;
    background:
        radial-gradient(circle at 95% 0%, rgba(139, 109, 255, .09), transparent 38%),
        rgba(255, 255, 255, .02);
    border: 1px solid var(--line);
}

.add-friend-card h3 {
    font-size: 15px;
    font-weight: 660;
    letter-spacing: -.02em;
}

.add-friend-card > p {
    margin-top: 5px;
    max-width: 520px;
    color: #818396;
    font-size: 10.5px;
    line-height: 1.55;
}

.add-friend-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.add-friend-form .input-wrap {
    flex: 1;
    max-width: 460px;
}

.add-friend-form .button {
    flex: none;
    min-height: 44px;
}

.add-friend-tip {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 14px;
    color: #5f6173;
    font-size: 8.5px;
    line-height: 1.5;
}

.add-friend-tip .icon {
    width: 13px;
    height: 13px;
    flex: none;
    margin-top: 1px;
}

/* ---------- Direct messages ---------- */
.dm-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.dm-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 0 12px;
}

.dm-intro {
    padding: 38px 28px 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
}

.dm-intro .avatar {
    width: 64px;
    height: 64px;
    font-size: 18px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .2);
}

.dm-intro h3 {
    margin-top: 14px;
    font-size: 23px;
    font-weight: 670;
    letter-spacing: -.04em;
}

.dm-intro p {
    margin-top: 5px;
    color: #7d7f92;
    font-size: 11.5px;
    line-height: 1.5;
}

.dm-intro-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: #66687a;
    font-size: 9px;
}

.dm-intro-meta .presence-dot {
    position: static;
    width: 7px;
    height: 7px;
    border: 0;
    box-sizing: border-box;
}

.dm-message-list {
    padding: 0 10px;
}

.dm-message {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0;
    padding: 5px 18px 5px 10px;
    border-radius: 10px;
}

.dm-message:hover {
    background: rgba(255, 255, 255, .016);
}

.dm-message-avatar {
    display: flex;
    justify-content: center;
    padding-top: 2px;
}

.dm-message-avatar .avatar {
    width: 36px;
    height: 36px;
    font-size: 10px;
}

.dm-message-body {
    min-width: 0;
}

.dm-message-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 20px;
}

.dm-message-author {
    color: #e4e0ed;
    font-size: 12.5px;
    font-weight: 650;
}

.dm-message-time {
    color: #606274;
    font-size: 8.5px;
    font-variant-numeric: tabular-nums;
}

.dm-message .message-content {
    font-size: 13px;
    color: #cfccd9;
    line-height: 1.5;
}

.dm-message + .dm-message {
    margin-top: 1px;
}

.dm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 170px;
    padding: 24px;
    color: #6f7184;
    text-align: center;
    font-size: 10px;
}

.dm-empty .icon {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
    color: #5e6073;
}

.dm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: #707285;
    font-size: 10px;
}

.dm-composer {
    flex: none;
    padding: 0 18px 17px;
}

.dm-composer .composer-shell {
    min-height: 49px;
}

.dm-composer .composer-meta {
    display: flex;
}

.dm-typing {
    /* reserved for future direct-message typing support */
    display: none;
}

/* ---------- Responsive friends ---------- */
@media (max-width: 840px) {
    .friends-sidebar {
        position: fixed;
        left: 68px;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(calc(-100% - 80px));
        transition: transform .24s cubic-bezier(.2, .8, .2, 1);
        box-shadow: 18px 0 50px rgba(0, 0, 0, .35);
        z-index: 60;
    }

    .friends-sidebar.is-open {
        transform: translateX(0);
    }

    .friends-sidebar-close {
        display: grid;
    }

    .friends-main-header {
        padding-left: 14px;
    }

    .friends-page-scroll {
        padding: 20px 18px 32px;
    }

    .friends-tabs {
        padding-left: 18px;
        padding-right: 18px;
    }

    .dm-intro {
        padding: 28px 20px 18px;
    }

    .dm-message-list {
        padding: 0 4px;
    }

    .dm-message {
        grid-template-columns: 44px minmax(0, 1fr);
        padding-right: 12px;
    }

    .dm-composer {
        padding: 0 12px calc(12px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 600px) {
    .friends-sidebar {
        left: 62px;
        width: min(286px, calc(100vw - 62px));
    }

    .friends-main-header {
        height: 57px;
        padding-left: 8px;
        padding-right: 12px;
    }

    .friends-header-content {
        gap: 8px;
    }

    .friends-header-content .avatar {
        width: 31px;
        height: 31px;
    }

    .friends-header-copy h2 {
        font-size: 13px;
    }

    .friends-header-actions .button {
        min-height: 29px;
        padding: 0 9px;
        font-size: 9px;
    }

    .friends-header-title h2 {
        font-size: 13px;
    }

    .friends-tabs {
        padding: 11px 12px 0;
    }

    .friends-tab {
        padding-left: 8px;
        padding-right: 8px;
        padding-bottom: 11px;
        font-size: 10px;
    }

    .friends-page-scroll {
        padding: 18px 12px 30px;
    }

    .friends-page-heading {
        gap: 10px;
    }

    .friends-page-heading h3 {
        font-size: 16px;
    }

    .friend-row {
        gap: 7px;
        padding: 7px 6px;
        min-height: 56px;
    }

    .friend-actions .button {
        padding: 0 8px;
    }

    .friend-actions .button span {
        display: none;
    }

    .friend-actions .button .dm-conversation-unread {
        display: inline-flex;
    }

    .friend-request-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .friend-request-actions {
        margin-left: auto;
    }

    .add-friend-form {
        align-items: stretch;
        flex-direction: column;
    }

    .add-friend-form .input-wrap {
        max-width: none;
    }

    .dm-intro {
        padding: 22px 16px 16px;
    }

    .dm-intro .avatar {
        width: 52px;
        height: 52px;
        font-size: 15px;
    }

    .dm-intro h3 {
        margin-top: 11px;
        font-size: 20px;
    }

    .dm-message {
        padding: 4px 8px 4px 3px;
    }

    .dm-message-avatar .avatar {
        width: 33px;
        height: 33px;
        font-size: 9px;
    }

    .dm-message .message-content {
        font-size: 12.5px;
    }

    .dm-message-author {
        font-size: 12px;
    }

    .friends-sidebar-note {
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 420px) {
    .friends-sidebar {
        left: 58px;
        width: calc(100vw - 58px);
    }
}
