.server-rail {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.server-rail::-webkit-scrollbar {
    display: none;
}

.server-rail-link {
    position: relative;
    display: block;
    flex: 0 0 auto;
    border-radius: 18px;
    text-decoration: none;
}

.server-rail-link.active::before,
.server-rail-link:hover::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    width: 4px;
    height: 24px;
    border-radius: 0 5px 5px 0;
    background: var(--text);
    transform: translateY(-50%);
}

.server-rail-link .server-icon {
    overflow: hidden;
}

.server-rail-link .server-icon-image,
.server-icon.home-logo img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
}

.server-icon.home-logo {
    padding: 4px;
    background: #080a14;
    box-sizing: border-box;
}

.server-icon.join {
    color: var(--accent-2);
}

.persistent-sidebar {
    min-height: 100vh;
    overflow: hidden;
}

.persistent-nav .nav-item,
.sidebar-nav .nav-item,
.sidebar-nav button.nav-item {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
}

.persistent-nav .nav-item:hover,
.persistent-nav .nav-item.active,
.sidebar-nav button.nav-item:hover,
.sidebar-nav button.nav-item.active {
    color: var(--text);
    background: var(--panel-3);
}

.nav-notification-badge,
.sidebar-dm-unread,
.server-shortcut-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #121721;
    border-radius: 999px;
    color: #fff;
    background: #ed4c66;
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1;
}

.nav-notification-badge[hidden],
.sidebar-dm-unread[hidden],
.server-shortcut-badge[hidden] {
    display: none !important;
}

.sidebar-dm-label {
    margin-top: 24px;
}

.sidebar-dm-list {
    height: calc(100vh - 285px);
    min-height: 120px;
    display: grid;
    align-content: start;
    gap: 5px;
    overflow-y: auto;
    padding-right: 3px;
    scrollbar-width: thin;
}

.sidebar-dm-row {
    min-width: 0;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border-radius: 11px;
    color: var(--text);
    text-decoration: none;
}

.sidebar-dm-row:hover,
.sidebar-dm-row.active {
    background: var(--panel-3);
}

.sidebar-dm-row.unread strong,
.sidebar-dm-row.unread .sidebar-dm-copy > span {
    color: var(--text);
    font-weight: 800;
}

.sidebar-dm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    object-fit: cover;
    display: grid;
    place-items: center;
    color: #071019;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-weight: 900;
}

.sidebar-dm-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.sidebar-dm-name-line {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.sidebar-dm-name-line strong,
.sidebar-dm-copy > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-dm-name-line time {
    flex: 0 0 auto;
    color: #77849a;
    font-size: 0.62rem;
}

.sidebar-dm-copy > span {
    color: var(--muted);
    font-size: 0.73rem;
}

.sidebar-dm-unread {
    border-color: #121721;
}

.sidebar-dm-empty {
    padding: 14px 10px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.server-shortcuts a {
    position: relative;
}

.server-shortcut-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    border-color: #121721;
}

@media (max-width: 900px) {
    .sidebar-dm-list {
        height: calc(100vh - 260px);
    }
}


/*
 * Sidebar footer repair
 * The Direct Messages list must consume only the remaining space. The user
 * panel stays inside the viewport instead of being pushed below it.
 */
.persistent-sidebar {
    height: 100vh;
    height: 100dvh;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    padding: 22px 16px 0 !important;
}

.persistent-sidebar > .sidebar-title,
.persistent-sidebar > .sidebar-nav,
.persistent-sidebar > .channel-label {
    flex: 0 0 auto;
}

.persistent-sidebar > .sidebar-dm-list {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0;
    margin-bottom: 10px;
    overscroll-behavior: contain;
}

.persistent-sidebar > .profile-bar {
    position: relative !important;
    inset: auto !important;
    bottom: auto !important;
    width: auto;
    min-height: 76px;
    flex: 0 0 auto;
    margin: 0 -16px;
    padding: 12px 14px;
    z-index: 5;
}

.persistent-sidebar > .profile-bar form {
    display: flex;
    align-items: center;
    margin: 0;
}

.persistent-sidebar > .profile-bar .profile-avatar {
    object-fit: cover;
}

@supports not (height: 100dvh) {
    .persistent-sidebar {
        height: 100vh;
    }
}
