* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    --bg-1: #eef4ff;
    --bg-2: #edf2ff;
    --bg-3: #f7f8fc;
    --panel: rgba(255, 255, 255, 0.52);
    --panel-strong: #f8fafc;
    --sidebar: linear-gradient(180deg, #f8fafc 0%, #edf3ff 100%);
    --sidebar-border: rgba(148, 163, 184, 0.2);
    --chat-bg: linear-gradient(180deg, #f9fbff 0%, #f3f6fc 100%);
    --chat-header: rgba(255, 255, 255, 0.38);
    --message-bg: rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255,255,255,0.72);
    --text: #152033;
    --muted: #64748b;
    --muted-strong: #334155;
    --border: rgba(148, 163, 184, 0.2);
    --shadow: rgba(15, 23, 42, 0.08);
    --accent-1: #4f46e5;
    --accent-2: #2563eb;
    --success: #1db954;
    --button-text: #ffffff;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.14), transparent 18%),
        radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.12), transparent 22%),
        linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 30%, var(--bg-3) 100%);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    transition: background 0.2s ease, color 0.2s ease;
}

body.dark-mode {
    --bg-1: #0b1020;
    --bg-2: #111827;
    --bg-3: #0f172a;
    --panel: rgba(15, 23, 42, 0.72);
    --panel-strong: #111827;
    --sidebar: linear-gradient(180deg, #101827 0%, #0d1627 100%);
    --sidebar-border: rgba(148, 163, 184, 0.18);
    --chat-bg: linear-gradient(180deg, rgba(10, 16, 27, 0.96), rgba(10, 14, 22, 0.92));
    --chat-header: rgba(15, 23, 42, 0.78);
    --message-bg: rgba(17, 24, 39, 0.82);
    --input-bg: rgba(15, 23, 42, 0.7);
    --text: #e5edf9;
    --muted: #8ea0bc;
    --muted-strong: #c9d4ea;
    --border: rgba(148, 163, 184, 0.16);
    --shadow: rgba(2, 6, 23, 0.45);
    --accent-1: #8b5cf6;
    --accent-2: #22d3ee;
    --success: #2dd65c;
    --button-text: #f8fafc;
    background:
        radial-gradient(circle at top left, rgba(139, 92, 246, 0.18), transparent 18%),
        radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.14), transparent 22%),
        linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 35%, var(--bg-3) 100%);
    color: var(--text);
}

button {
    font-family: inherit;
}

.app {
    display: flex;
    height: calc(100vh - 86px);
    gap: 14px;
    padding: 0 24px 24px;
    background: transparent;
}

.app-login-entry .top-nav {
    animation: login-nav-arrival 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-login-entry .servers {
    animation: login-rail-arrival 0.8s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-login-entry .channels {
    animation: login-panel-arrival 0.75s 0.15s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-login-entry .chat {
    animation: login-chat-arrival 0.9s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-login-entry .members {
    animation: login-panel-arrival 0.75s 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.welcome-banner {
    position: fixed;
    top: 102px;
    left: 50%;
    z-index: 30;
    padding: 12px 18px;
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.3), 0 0 28px rgba(34, 211, 238, 0.12);
    transform: translateX(-50%);
    animation: welcome-banner-arrival 2.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes welcome-banner-arrival {
    0% { opacity: 0; transform: translate(-50%, -18px) scale(0.92); }
    14%, 78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -8px) scale(0.98); }
}

@keyframes login-nav-arrival {
    from { opacity: 0; transform: translateY(-18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes login-rail-arrival {
    from { opacity: 0; transform: translateX(-24px) scale(0.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes login-panel-arrival {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes login-chat-arrival {
    0% { opacity: 0; transform: scale(0.975); box-shadow: 0 0 0 rgba(34, 211, 238, 0); }
    55% { opacity: 1; transform: scale(1.005); box-shadow: 0 0 42px rgba(34, 211, 238, 0.14); }
    100% { opacity: 1; transform: scale(1); box-shadow: 0 14px 26px var(--shadow); }
}

.top-nav {
    height: 86px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 30px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.28);
    backdrop-filter: blur(20px);
}

.top-nav__brand,
.top-nav__actions,
.top-nav__links,
.top-nav__brand > div:last-child {
    display: flex;
    align-items: center;
}

.top-nav__brand {
    gap: 11px;
    min-width: 180px;
}

.top-nav__brand > div:last-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.nav-presence {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
}

.nav-presence select {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    padding: 0 2px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    max-width: 110px;
}

.nav-presence select:focus-visible { outline: 2px solid var(--accent, #4f46e5); border-radius: 4px; }

.nav-presence__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #23a55a;
    flex: none;
}
.nav-presence__dot[data-status="idle"] { background: #f0b232; }
.nav-presence__dot[data-status="dnd"] { background: #f23f43; }
.nav-presence__dot[data-status="invisible"] { background: #80848e; }

@media (max-width: 720px) {
    .top-nav__brand > div:last-child > .nav-presence { display: inline-flex; }
}

.top-nav__brand strong {
    color: var(--text);
    font-size: 17px;
    letter-spacing: -0.02em;
}

.top-nav__brand span {
    color: var(--muted);
    font-size: 11px;
}

.top-nav__mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
}

.top-nav__home {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
    -webkit-tap-highlight-color: transparent;
}

.top-nav__links {
    gap: 8px;
    height: 100%;
}

.top-nav__link {
    height: 100%;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0 14px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.top-nav__link:hover,
.top-nav__link.active {
    color: var(--text);
}

.top-nav__link.active {
    border-bottom-color: var(--accent-2);
}

.top-nav__actions {
    justify-content: flex-end;
    gap: 14px;
    min-width: 270px;
}

.top-nav__status {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.top-nav__status i {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(45, 214, 92, 0.1);
}

.top-nav__profile {
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--message-bg);
    color: var(--text);
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    overflow: hidden;
}

.top-nav__profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-sidebar-toggle,
.mobile-members-toggle,
.mobile-sidebar-backdrop {
    display: none;
}

[hidden] {
    display: none !important;
}

/* =========================
   SERVER SIDEBAR
========================= */

.servers {
    width: 72px;
    flex: 0 0 72px;
    align-self: flex-start;
    height: calc(100% - 4px);
    background: var(--sidebar);
    border: 1px solid var(--sidebar-border);
    border-radius: 22px;
    padding: 14px 9px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow-y: auto;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 32px var(--shadow);
}

.logo,
.server {
    width: 50px;
    height: 50px;
    min-height: 50px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #e2e8f0, #dbeafe);
    color: #102033;
    font-size: 19px;
    cursor: pointer;
    transition: transform 0.16s ease, border-radius 0.16s ease, box-shadow 0.16s ease;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    position: relative;
}

.server-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 18px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #4338ca, #0ea5e9);
    color: white;
    font-weight: 800;
    box-shadow: 0 12px 22px rgba(79, 70, 229, 0.28);
}

.home-button {
    flex: 0 0 50px;
    padding: 0;
}

.server:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

.server.active {
    background: linear-gradient(135deg, #4f46e5, #2563eb);
    color: white;
    border-radius: 16px;
    box-shadow: 0 12px 22px rgba(79, 70, 229, 0.28);
}

.add-server {
    color: #0f172a;
    font-size: 32px;
    background: linear-gradient(135deg, #e2e8f0, #dbeafe);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* =========================
   CHANNEL SIDEBAR
========================= */

.channels {
    width: 240px;
    background: var(--sidebar);
    border: 1px solid var(--sidebar-border);
    border-radius: 18px;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), 0 18px 32px var(--shadow);
}

.server-header {
    min-height: 64px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
    margin-bottom: 4px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
}

.server-header > strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-header__actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.server-visibility,
.server-invite {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 5px 6px;
    background: var(--message-bg);
    color: var(--muted-strong);
    font: inherit;
    font-size: 10px;
    white-space: nowrap;
}

.server-banner-upload {
    cursor: pointer;
}

.server-visibility input {
    margin: 0;
    accent-color: var(--accent-1);
}

.server-invite {
    cursor: pointer;
}

.channel-category-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.channel-category-heading .category {
    margin-bottom: 8px;
}

.channel-add {
    width: 24px;
    height: 24px;
    margin: -3px 4px 5px 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
}

.channel-add:hover {
    background: var(--message-bg);
    color: var(--text);
}

.presence-setting {
    display: grid;
    gap: 6px;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.presence-setting select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 9px;
    background: var(--panel-strong);
    color: var(--text);
    font: inherit;
}

section {
    padding: 14px 4px 0;
}

.category {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0 8px 8px;
    opacity: 0.9;
}

.channel {
    width: calc(100% - 8px);
    margin: 3px 4px;
    border: none;
    background: transparent;
    color: var(--muted-strong);
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    letter-spacing: 0.01em;
}

.channel:hover,
.channel.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.08), rgba(59, 130, 246, 0.05));
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.direct-messages__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.direct-messages__heading button {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--message-bg);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.dm-channel {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 2px 0;
    border: 0;
    border-radius: 8px;
    padding: 9px 10px;
    background: transparent;
    color: var(--muted-strong);
    text-align: left;
    cursor: pointer;
}

.dm-channel:hover,
.dm-channel.active {
    background: var(--message-bg);
    color: var(--text);
}

.dm-channel__avatar {
    display: grid;
    place-items: center;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(34, 197, 94, 0.18);
    color: var(--success);
    font-size: 11px;
    font-weight: 800;
    overflow: hidden;
}

.member__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dm-channel__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================
   CHAT
========================= */

.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--chat-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 14px 26px var(--shadow);
}

.app.is-home .channels,
.app.is-home .members,
.app.is-discover .channels,
.app.is-discover .members,
.app.is-direct-message .channels,
.app.is-direct-message .members {
    display: none;
}

.app.is-home .chat > :not(.home-view) {
    display: none !important;
}

.app.is-discover .chat > :not(#discoverView) {
    display: none !important;
}

.discover-view {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 22px;
    min-height: 0;
    padding: clamp(18px, 3vw, 36px);
    overflow-y: auto;
}

.discover-view__header,
.discover-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.discover-view__header h1 {
    margin-top: 7px;
    color: var(--text);
    font-size: clamp(24px, 3vw, 34px);
}

.discover-view__header p {
    margin-top: 6px;
    color: var(--muted);
}

.discover-refresh,
.weather-search button {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 14px;
    background: var(--message-bg);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.discover-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.85fr);
    align-items: start;
    gap: 16px;
}

.discover-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
}

.discover-card h2 {
    margin-top: 5px;
    color: var(--text);
    font-size: 17px;
}

.discover-updated,
.discover-status,
.discover-attribution {
    color: var(--muted);
    font-size: 12px;
}

.discover-status {
    margin-top: 12px;
}

.discover-news-list {
    display: grid;
    margin-top: 8px;
}

.discover-news-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 14px;
}

.discover-news-filter {
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 11px;
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.discover-news-filter:hover,
.discover-news-filter.active {
    border-color: var(--accent-1);
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-1);
}

.discover-news-filter:focus-visible {
    outline: 2px solid var(--accent-1);
    outline-offset: 2px;
}

.discover-story {
    display: grid;
    gap: 7px;
    padding: 14px 2px;
    border-bottom: 1px solid var(--border);
}

.discover-story:last-child {
    border-bottom: 0;
}

.discover-story__breaking {
    width: fit-content;
    border-radius: 4px;
    padding: 4px 7px;
    background: #b42318;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.discover-story__title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    text-decoration: none;
}

.discover-story__title:hover {
    color: var(--accent-2);
}

.discover-story__details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
}

.discover-story__category {
    border-radius: 999px;
    padding: 3px 8px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-1);
    font-weight: 700;
}

.weather-search {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.weather-search input {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 11px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.weather-result {
    display: grid;
    gap: 16px;
    margin-top: 14px;
}

.weather-current {
    display: grid;
    gap: 10px;
}

.weather-current__summary {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted-strong);
}

.weather-current__temperature {
    color: var(--text);
    font-size: 48px;
    line-height: 1;
}

.weather-current__place {
    display: grid;
    gap: 4px;
}

.weather-current__place strong {
    color: var(--text);
    font-size: 14px;
}

.weather-current__place span {
    color: var(--muted);
    font-size: 12px;
}

.weather-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.weather-stat {
    display: grid;
    gap: 5px;
    padding: 9px 7px;
    border-radius: 9px;
    background: var(--message-bg);
}

.weather-stat span,
.weather-forecast__day span {
    color: var(--muted);
    font-size: 10px;
}

.weather-stat strong {
    color: var(--text);
    font-size: 12px;
}

.weather-forecast {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.weather-forecast__day {
    display: grid;
    gap: 6px;
    padding: 10px 7px;
    border-top: 1px solid var(--border);
}

.weather-forecast__day strong {
    color: var(--text);
    font-size: 12px;
}

.discover-attribution {
    margin-top: auto;
}

.weather-search #weatherLocateButton,
.weather-search #weatherUnitButton {
    flex: 0 0 auto;
    padding: 0 10px;
}

.weather-saved {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.weather-chip {
    min-height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--message-bg);
    color: var(--muted-strong);
    font-size: 12px;
    box-shadow: none;
}

.weather-alert {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border-left: 4px solid #f59e0b;
    border-radius: 9px;
    background: rgba(245, 158, 11, .14);
    color: var(--text);
    font-size: 12px;
}

.weather-alert--severe,
.weather-alert--extreme {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, .16);
}

.weather-section-title {
    margin: 0;
    color: var(--muted-strong);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.weather-hourly {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.weather-hourly__slot {
    display: grid;
    flex: 0 0 74px;
    gap: 4px;
    padding: 8px 6px;
    border-radius: 9px;
    background: var(--message-bg);
    text-align: center;
}

.weather-hourly__slot span {
    color: var(--muted);
    font-size: 10px;
}

.weather-hourly__slot strong {
    color: var(--text);
    font-size: 14px;
}

.discover-sports {
    grid-column: 1 / -1;
}

.sports-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sports-controls select {
    min-height: 38px;
    max-width: min(48vw, 260px);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 10px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.sports-events-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
    gap: 10px;
    margin-top: 12px;
}

.sports-event {
    display: grid;
    align-content: start;
    gap: 11px;
    min-width: 0;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--message-bg);
}

.sports-event__header,
.sports-event__team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sports-event__league {
    color: var(--accent-1);
    font-size: 11px;
    font-weight: 800;
}

.sports-event__status {
    color: var(--muted);
    font-size: 11px;
    text-align: right;
}

.sports-event__status.is-live {
    color: #ef4444;
    font-weight: 800;
}

.sports-event__teams {
    display: grid;
    gap: 7px;
}

.sports-event__team {
    color: var(--text);
    font-size: 13px;
}

.sports-event__team > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sports-event__team small {
    color: var(--muted);
    font-size: 10px;
}

.sports-event__team strong {
    color: var(--muted-strong);
    font-size: 15px;
}

.sports-event__team strong.is-winner {
    color: var(--success);
}

.sports-event__name {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.sports-event__details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding-top: 9px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 10px;
}

.sports-event__details a {
    color: var(--accent-2);
    text-decoration: none;
}

.sports-event__details a:hover {
    text-decoration: underline;
}

.sports-empty {
    grid-column: 1 / -1;
    padding: 12px 0;
    color: var(--muted);
    font-size: 13px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.home-view {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    padding: clamp(20px, 4vw, 44px);
    overflow-y: auto;
}

.home-view__header h1 {
    margin-top: 8px;
    color: var(--text);
    font-size: clamp(24px, 3vw, 34px);
}

.home-view__header p {
    margin-top: 6px;
    color: var(--muted);
}

.home-view__columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
}

.home-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
}

.home-card h2 {
    color: var(--text);
    font-size: 16px;
}

.home-card__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.home-card__heading button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--message-bg);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
}

.public-server-directory .home-card__heading {
    margin-bottom: 0;
}

.public-server-directory .home-card__heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.public-server-directory .home-card__heading button,
.public-server button {
    width: auto;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 11px;
    background: var(--message-bg);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.public-servers-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.public-server {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--message-bg);
}

.public-server > div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.public-server strong {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.public-server span {
    color: var(--muted);
    font-size: 11px;
}

.public-server button:hover,
.public-server-directory .home-card__heading button:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.home-dm-list {
    display: grid;
    gap: 4px;
}

.home-dm-list:empty::after {
    content: "No conversations yet. Start a direct message to connect.";
    padding: 10px;
    color: var(--muted);
    font-size: 13px;
}

#groupList:empty::after {
    content: "No group chats yet. Tap + to start one with your friends.";
}

.home-friend-requests .friend-request-list {
    padding: 12px 0 0;
}

.home-friend-requests .friend-request-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.chat-header {
    height: 68px;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    position: relative;
}

.chat-header::before {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.3), rgba(59, 130, 246, 0.12), transparent);
}

.chat-header__title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header strong {
    font-size: 18px;
    color: var(--text);
}

.chat-header span {
    color: var(--muted);
    font-size: 14px;
}

.voice-call {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--message-bg);
}

.voice-call__toolbar,
.voice-call__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.voice-call__toolbar > span {
    color: var(--muted);
    font-size: 13px;
}

.voice-call__actions button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    background: var(--chat-bg);
    color: var(--text);
    cursor: pointer;
}

.voice-call__actions button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.voice-call__participants {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 10px;
    margin-top: 12px;
}

.voice-participant {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #10151e;
    color: #f8fafc;
}

.voice-participant video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.voice-participant__name {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 1;
    border-radius: 4px;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.65);
    font-size: 12px;
}

.voice-call.hidden {
    display: none;
}

.livestream-sidebar {
    max-height: 180px;
    overflow-y: auto;
}

.livestream-start {
    color: #ef4444;
    font-weight: 700;
}

.livestream-list {
    display: grid;
    gap: 4px;
}

.livestream-list__status {
    padding: 0 10px;
    color: var(--muted);
    font-size: 11px;
}

.livestream-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.7fr);
    grid-template-rows: auto minmax(160px, 1fr);
    gap: 10px;
    flex: 0 1 48vh;
    min-height: 250px;
    max-height: 540px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--message-bg);
}

.livestream-stage.hidden {
    display: none;
}

.livestream-stage__header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.livestream-stage__header > div:first-child,
.livestream-stage__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.livestream-stage__header > div:first-child > strong {
    color: var(--text);
    font-size: 14px;
}

.livestream-stage__header > div:first-child > span:last-child,
.livestream-stage__actions > span {
    color: var(--muted);
    font-size: 12px;
}

.livestream-live-badge {
    border-radius: 5px;
    padding: 3px 6px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.livestream-stage__actions button,
.livestream-chat__form button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    background: var(--chat-bg);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}

.livestream-stage__video {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #080b12;
    color: #fff;
}

.livestream-stage__video::before {
    content: "Waiting for the host video...";
    color: #cbd5e1;
    font-size: 13px;
}

.livestream-stage__video:has(video)::before {
    display: none;
}

.livestream-stage__video video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.livestream-stage__video video.livestream-video--overlay {
    inset: auto 12px 12px auto;
    width: 24%;
    min-width: 120px;
    height: auto;
    aspect-ratio: 16 / 9;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    background: #000;
    object-fit: cover;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.livestream-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--chat-bg);
}

.livestream-chat__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    min-height: 0;
    overflow-y: auto;
    padding: 9px;
}

.livestream-chat__message {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 12px;
    line-height: 1.4;
}

.livestream-chat__message strong {
    margin-right: 5px;
    color: var(--accent-2);
}

.livestream-chat__form {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid var(--border);
}

.livestream-chat__form input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    font-size: 12px;
}

.livestream-chat__form button {
    background: var(--accent-1);
    color: #fff;
}

.app-dialog {
    width: min(420px, calc(100% - 32px));
    margin: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0;
    background: var(--panel-strong);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
}

.app-dialog::backdrop {
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(3px);
}

.app-dialog__form {
    display: grid;
    gap: 12px;
    padding: 22px;
}

.app-dialog__form h2 {
    font-size: 20px;
}

.app-dialog__form label {
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 700;
}

.app-dialog__form .dialog-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.app-dialog__form .dialog-checkbox input {
    width: auto;
    margin: 0;
    accent-color: var(--accent-1);
}

.app-dialog__form input,
.app-dialog__form select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.app-dialog__form [role="status"] {
    min-height: 18px;
    color: var(--muted);
    font-size: 13px;
}

.app-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.app-dialog__actions button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--chat-bg);
    color: var(--text);
    cursor: pointer;
}

.bot-management-dialog {
    width: min(700px, calc(100% - 32px));
    max-height: 90vh;
    overflow-y: auto;
}

.community-rules-dialog {
    width: min(560px, calc(100% - 32px));
    max-height: 90vh;
    overflow-y: auto;
}

.community-rule {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--message-bg);
}

.community-rule h3 {
    font-size: 15px;
}

.community-rule p,
.community-rules-consequences {
    color: var(--muted-strong);
    font-size: 13px;
    line-height: 1.55;
}

.community-rule--urgent {
    border-color: rgba(220, 38, 38, 0.5);
}

.community-rule--urgent h3 {
    color: #dc2626;
}

.community-rules-consequences {
    font-weight: 700;
}

.community-rules-link {
    justify-self: start;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent-2);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.bot-management-note,
.bot-settings-intro {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.bot-settings-button,
.bot-application-form button,
.bot-review-item button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--chat-bg);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.bot-settings-button {
    width: 100%;
    margin-top: 8px;
}

.bot-application-form {
    display: grid;
    gap: 9px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.bot-application-form label {
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 700;
}

.bot-application-form input,
.bot-application-form select,
.bot-application-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.bot-application-form [role="status"] {
    min-height: 18px;
    color: var(--muted);
    font-size: 13px;
}

.bot-token-notice {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--accent-2);
    border-radius: 10px;
    overflow-wrap: anywhere;
}

.bot-token-notice[hidden] {
    display: none;
}

.bot-token-notice code {
    color: var(--text);
}

.bot-token-notice p {
    color: var(--muted);
    font-size: 12px;
}

.bot-list-section {
    display: grid;
    gap: 8px;
    padding-top: 12px;
}

.bot-list-section[hidden] {
    display: none;
}

.bot-list-section h3 {
    font-size: 15px;
}

.bot-review-list {
    display: grid;
    gap: 8px;
}

.bot-review-item {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--message-bg);
    overflow-wrap: anywhere;
}

.bot-review-item__meta,
.bot-review-item__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.bot-review-item__meta {
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.bot-review-item__actions button {
    padding: 6px 9px;
    font-size: 12px;
}

.bot-review-empty {
    color: var(--muted);
    font-size: 13px;
}

.channel-empty-state {
    padding: 8px 10px;
    color: var(--muted);
    font-size: 13px;
}

.profile-dialog {
    position: fixed;
    width: min(420px, calc(100% - 32px));
    max-height: min(90vh, 720px);
    margin: auto;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0;
    background: var(--panel-strong);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
}

.profile-dialog::backdrop {
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(3px);
}

.profile-dialog__banner {
    height: 100px;
    background: linear-gradient(125deg, #5865f2, #9b59b6 55%, #22c3a6);
    background-size: cover;
    background-position: center;
}

.profile-dialog__close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: rgba(15, 23, 42, 0.35);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 22px;
    cursor: pointer;
}

.profile-dialog__content {
    padding: 0 20px 20px;
}

.profile-dialog__avatar {
    display: grid;
    place-items: center;
    position: relative;
    width: 88px;
    height: 88px;
    margin-top: -42px;
    border: 6px solid var(--panel-strong);
    border-radius: 50%;
    background: linear-gradient(135deg, #5865f2, #22c3a6);
    color: white;
    font-size: 25px;
    font-weight: 800;
    overflow: hidden;
}

.profile-dialog__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-dialog__identity {
    display: grid;
    gap: 3px;
    padding: 8px 0 16px;
}

.profile-dialog__identity strong {
    font-size: 20px;
}

.profile-dialog__identity span,
.profile-dialog__about p {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.profile-dialog__about {
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.profile-dialog__about h2 {
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
}

.profile-dialog__about p {
    min-height: 22px;
    white-space: pre-wrap;
}

.profile-dialog__edit,
.profile-dialog__actions button {
    margin-top: 16px;
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--accent-1);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.profile-dialog__form {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.profile-dialog__form label {
    margin-top: 8px;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
}

.profile-dialog__form input,
.profile-dialog__form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.profile-dialog__form textarea {
    resize: vertical;
}

.profile-dialog__form [role="status"] {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
}

.profile-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.profile-dialog__actions button {
    margin: 0;
}

.profile-dialog__actions button:first-child {
    background: var(--message-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    background: var(--message-bg);
    color: var(--text);
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.theme-toggle__icon {
    font-size: 14px;
}

/* =========================
   MEMBER SIDEBAR
========================= */

.members {
    width: 238px;
    flex: 0 0 238px;
    padding: 20px 16px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.16);
}

.members__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 20px;
}

.members__header > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.members__header strong {
    color: var(--text);
    font-size: 17px;
    letter-spacing: -0.02em;
}

.eyebrow,
.member-group__label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.members__count {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent-2);
    font-size: 11px;
    font-weight: 800;
}

.member-group {
    padding: 14px 4px 18px;
    border-top: 1px solid var(--border);
}

.member-group__label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.member-group__label span:last-child {
    opacity: 0.65;
}

.member-list {
    display: grid;
    gap: 4px;
}

.member {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px 4px;
    border-radius: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.member:hover {
    background: var(--message-bg);
}

.member > span:nth-child(2) {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 3px;
}

.member strong,
.member small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member strong {
    color: var(--text);
    font-size: 12px;
}

.member small {
    color: var(--muted);
    font-size: 10px;
}

.member__avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.14);
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
}

.member__avatar--violet { background: linear-gradient(135deg, #8b5cf6, #ec4899); color: #fff; }
.member__avatar--blue { background: linear-gradient(135deg, #2563eb, #22d3ee); color: #fff; }
.member__avatar--green { background: linear-gradient(135deg, #059669, #a3e635); color: #fff; }

.presence {
    position: absolute;
    left: 26px;
    top: 31px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--bg-3);
    border-radius: 50%;
    background: #64748b;
}

.presence--online {
    background: var(--success);
}

.presence--idle {
    background: #f59e0b;
}

.presence--dnd {
    background: #ef4444;
}

.member-group--offline {
    opacity: 0.68;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 20px 14px;
    background: transparent;
}

/* =========================
   MESSAGES
========================= */

.message {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    padding: 12px 12px 10px;
    border-radius: 18px;
    background: var(--message-bg);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 6px 16px var(--shadow);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.message-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.message-menu-wrapper {
    position: relative;
}

.avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c5cff, #4cc9f0, #3fe7d6);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    box-shadow: 0 10px 18px rgba(124, 92, 255, 0.28), inset 0 1px 0 rgba(255,255,255,0.2);
}

.username {
    font-weight: 700;
    color: var(--text);
}

.bot-badge {
    display: inline-block;
    margin-left: 6px;
    border-radius: 4px;
    padding: 2px 4px;
    background: var(--accent-1);
    color: #fff;
    font-size: 9px;
    letter-spacing: 0.06em;
    vertical-align: 2px;
}

.message-time,
.message-date {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.message-more {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 8px;
}

.message-more:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}

.message-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    display: none;
    min-width: 140px;
    background: #111827;
    border: 1px solid #334155;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.35);
    padding: 8px 0;
    z-index: 10;
}

.message-dropdown.show {
    display: block;
}

.message-dropdown button {
    width: 100%;
    border: none;
    background: transparent;
    color: #f8fafc;
    text-align: left;
    padding: 9px 12px;
    cursor: pointer;
    font-size: 14px;
}

.message-dropdown button:hover {
    background: #263449;
}

.friend-requests {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.friend-requests summary {
    padding: 7px 9px;
    cursor: pointer;
}

.friend-request-list {
    display: grid;
    gap: 6px;
    padding: 4px 8px 8px;
}

.friend-request-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.friend-request-item button {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 7px;
    background: var(--message-bg);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.friend-request-empty {
    color: var(--muted);
    font-size: 11px;
}

.text {
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.custom-emoji {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    margin: 0 1px;
    object-fit: contain;
    vertical-align: middle;
}

/* =========================
   MESSAGE INPUT
========================= */

.message-box {
    position: relative;
    display: grid;
    grid-template-columns: auto auto auto auto minmax(0, 1fr) auto;
    padding: 18px 20px 22px;
    gap: 12px;
    background: rgba(255, 255, 255, 0.45);
    border-top: 1px solid var(--border);
}

.message-box input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    outline: none;
    color: var(--text);
    padding: 15px 16px;
    font-size: 15px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 8px 18px var(--shadow);
}

.message-box input:focus {
    border-color: rgba(79, 70, 229, 0.32);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.message-box button {
    border: none;
    border-radius: 14px;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: var(--button-text);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.22), inset 0 1px 0 rgba(255,255,255,0.18);
}

.message-box button:hover {
    filter: brightness(1.08);
}

.message-pip-button {
    display: inline-block;
    width: fit-content;
    margin-top: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--message-bg);
    color: var(--muted-strong);
    font-size: 12px;
    cursor: pointer;
    box-shadow: none;
}

.message-audio {
    display: grid;
    gap: 6px;
    width: min(100%, 420px);
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--message-bg);
}

.message-audio__title {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-audio audio,
.link-audio {
    width: 100%;
    max-width: 100%;
}

.message-audio__download {
    color: var(--muted);
    font-size: 12px;
}

.text a {
    color: #2563eb;
    overflow-wrap: anywhere;
}

.link-embed {
    display: block;
    width: min(100%, 520px);
    margin-top: 10px;
    border: 0;
    border-radius: 12px;
    background: #10151e;
}

.link-embed--video {
    aspect-ratio: 16 / 9;
}

.link-embed--spotify {
    height: 152px;
}

.link-embed--spotify-tall {
    height: 352px;
}

.link-card {
    display: grid;
    gap: 4px;
    width: min(100%, 460px);
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 4px solid #2563eb;
    border-radius: 10px;
    background: var(--message-bg);
    color: var(--text);
    text-decoration: none;
}

.link-card:hover {
    background: var(--panel-strong);
}

.link-card__site {
    color: var(--muted);
    font-size: 12px;
}

.link-card__title {
    color: #2563eb;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.link-card__description {
    display: -webkit-box;
    overflow: hidden;
    color: var(--muted-strong);
    font-size: 13px;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.link-card__image {
    width: 100%;
    max-height: 240px;
    margin-top: 6px;
    border-radius: 8px;
    object-fit: cover;
}

.message-video {
    display: block;
    width: min(100%, 640px);
    max-height: 420px;
    margin-top: 10px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    background: #10151e;
    object-fit: contain;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.bsettings {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    background: var(--panel-strong);
    color: var(--text);
}

.bsettings__nav {
    flex: 0 0 240px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 60px 12px 24px 24px;
    overflow-y: auto;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
}

.bsettings__group {
    margin: 14px 10px 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.bsettings__nav button {
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.bsettings__nav button:hover { background: rgba(148, 163, 184, 0.16); }
.bsettings__nav button.active { background: rgba(99, 102, 241, 0.22); color: var(--text); font-weight: 600; }

.bsettings__main {
    position: relative;
    flex: 1;
    min-width: 0;
}

.bsettings__content {
    height: 100%;
    max-width: 740px;
    padding: 60px 40px 80px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.bsettings__pane h2 { margin: 0 0 20px; font-size: 20px; }
.bsettings__pane h3 { margin: 24px 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.bsettings__pane .settings-panel__section { margin-bottom: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.bsettings__pane .presence-setting { display: flex; align-items: center; gap: 12px; }
.bsettings__muted { color: var(--muted); font-size: 14px; }

.bsettings__card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
}

.bsettings__card > :nth-child(2) { flex: 1; min-width: 0; }

.bsettings__avatar {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    font-size: 26px;
    font-weight: 700;
}

.bsettings__pane button:not(.bsettings__danger) {
    padding: 8px 14px;
    margin: 4px 6px 4px 0;
    border: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.bsettings__pane input[type="file"] { display: block; margin: 8px 0; color: var(--muted-strong); }
.bsettings__nav { scrollbar-width: none; }
.bsettings__nav::-webkit-scrollbar { display: none; }

.bsettings__danger { border-color: #ed4245 !important; background: #ed4245 !important; color: #fff !important; }

.bsettings__close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 40px;
    height: 40px;
    border: 2px solid var(--muted);
    border-radius: 50%;
    background: transparent;
    color: var(--muted-strong);
    font-size: 16px;
    cursor: pointer;
}

@media (max-width: 760px) {
    .bsettings { flex-direction: column; }
    .bsettings__nav {
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        padding: calc(env(safe-area-inset-top) + 12px) 56px 10px 12px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--sidebar-border);
    }
    .bsettings__group { display: none; }
    .bsettings__nav button { flex: 0 0 auto; white-space: nowrap; }
    .bsettings__content { padding: 20px 16px calc(env(safe-area-inset-bottom) + 60px); }
    .bsettings__close { top: calc(env(safe-area-inset-top) + 6px); right: 10px; width: 36px; height: 36px; }
}

.message-video-error {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.message-video-error a {
    color: var(--accent-1);
}

.message-image {
    display: block;
    width: min(100%, 640px);
    max-height: 520px;
    margin-top: 10px;
    border-radius: 8px;
    object-fit: contain;
    background: #10151e;
}

.message-box #attachVideoButton {
    width: 48px;
    min-height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--message-bg);
    color: var(--text);
    font-size: 24px;
    box-shadow: none;
}

.message-box #emojiPickerButton {
    width: 48px;
    min-height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--message-bg);
    color: var(--text);
    font-size: 22px;
    box-shadow: none;
}

.message-box #stickerPickerButton {
    width: 48px;
    min-height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--message-bg);
    color: var(--text);
    font-size: 20px;
    box-shadow: none;
}

.sticker-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.sticker-picker__item {
    position: relative;
}

.sticker-picker__item > button:first-child {
    width: 100%;
    min-height: 84px;
    padding: 4px;
    border: 1px solid var(--border);
    background: var(--message-bg);
    box-shadow: none;
}

.sticker-picker__item img {
    width: 100%;
    height: 76px;
    object-fit: contain;
}

.sticker-picker__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    min-height: 22px !important;
    padding: 0 !important;
    border-radius: 50% !important;
}

.message-sticker {
    display: block;
    width: 160px;
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
}

.message-box #gifPickerButton {
    min-height: 48px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: var(--message-bg);
    color: var(--text);
    font-size: 13px;
    box-shadow: none;
}

.gif-picker {
    position: absolute;
    right: 20px;
    bottom: calc(100% - 8px);
    z-index: 21;
    width: min(390px, calc(100vw - 40px));
    max-height: min(470px, 70vh);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--panel-strong);
    color: var(--text);
    box-shadow: 0 14px 38px var(--shadow);
}

.gif-picker.hidden {
    display: none;
}

.gif-picker__header,
.gif-picker__search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gif-picker__header {
    justify-content: space-between;
    margin-bottom: 10px;
}

.gif-picker__header button,
.gif-picker__search button,
.gif-picker__saved-toggle {
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 9px;
    background: var(--message-bg);
    color: var(--text);
    cursor: pointer;
}

.gif-picker__search input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.gif-picker__saved-toggle {
    margin-top: 8px;
}

.gif-picker__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.gif-picker__item {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.gif-picker__choose,
.gif-picker__save {
    width: 100%;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    box-shadow: none;
}

.gif-picker__choose img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
}

.gif-picker__save {
    padding: 6px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.gif-picker__save:disabled {
    color: var(--muted);
    cursor: default;
}

.message-gif {
    display: inline-block;
    vertical-align: middle;
}

.notifications-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.notifications-button__label {
    display: inline;
}

.notification-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.notifications-list {
    display: grid;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
}

.notification-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: var(--message-bg);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.emoji-picker {
    position: absolute;
    right: 20px;
    bottom: calc(100% - 8px);
    z-index: 20;
    width: min(340px, calc(100vw - 40px));
    max-height: min(390px, 65vh);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--panel-strong);
    color: var(--text);
    box-shadow: 0 14px 38px var(--shadow);
}

.emoji-picker.hidden {
    display: none;
}

.emoji-picker__header,
.emoji-picker__upload {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.emoji-picker__header {
    margin-bottom: 10px;
}

.emoji-picker__header strong {
    font-size: 13px;
}

.emoji-picker__header button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
}

.emoji-picker__grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    max-height: 190px;
    overflow-y: auto;
}

.emoji-picker__hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.emoji-picker__item {
    display: grid;
    place-items: center;
    min-width: 0;
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--message-bg);
    cursor: pointer;
}

.emoji-picker__item:hover {
    border-color: var(--accent-2);
}

.emoji-picker__item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.emoji-picker__item span {
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
}

.emoji-picker__upload {
    margin-top: 10px;
}

.emoji-picker__upload input {
    min-width: 0;
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.emoji-picker__upload button {
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--accent-2);
    color: white;
    font-size: 11px;
    cursor: pointer;
}

#emojiStatus {
    display: block;
    min-height: 16px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}

.message-box #attachmentStatus {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
}

.settings-block {
    margin-top: auto;
    padding: 10px 10px 14px;
}

.settings-toggle {
    width: 100%;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.1), rgba(76, 201, 240, 0.08));
    color: #edf2ff;
    padding: 11px 12px;
    text-align: left;
    cursor: pointer;
    font-weight: 700;
    border: 1px solid rgba(124, 92, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.settings-panel {
    margin-top: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(124, 92, 255, 0.03));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.settings-panel.hidden {
    display: none;
}

.settings-panel__section {
    margin-bottom: 12px;
}

.blocked-users-list {
    display: grid;
    gap: 6px;
}

.blocked-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text);
    font-size: 12px;
}

.blocked-user-item button {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 5px 8px;
    background: var(--chat-bg);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.blocked-user-item button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.blocked-users-empty,
.blocked-users-status {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.settings-panel__title {
    color: #8da0ba;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.spotify-connect {
    margin-top: 4px;
}

.youtube-connect {
    display: grid;
    gap: 8px;
}

#youtubeConnectButton,
#youtubeDisconnectButton {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--chat-bg);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

#youtubeConnectButton:disabled,
#youtubeDisconnectButton:disabled {
    opacity: 0.7;
    cursor: wait;
}

.youtube-status,
.youtube-setup-help {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.youtube-channel-link {
    color: var(--accent-2);
    font-size: 12px;
    overflow-wrap: anywhere;
}

#spotifyButton {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1db954, #2dd65c);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 10px 20px rgba(29, 185, 84, 0.2);
}

#spotifyButton:hover:not(:disabled) {
    transform: translateY(-1px);
    opacity: 0.96;
}

#spotifyButton:disabled {
    opacity: 0.7;
    cursor: wait;
}

.spotify-status {
    min-height: 20px;
    margin-top: 8px;
    color: #b5bfd9;
    font-size: 13px;
}

.spotify-status.error {
    color: #ff9ea9;
}

.spotify-redirect-help {
    margin-top: 10px;
    color: #b5bfd9;
    font-size: 11px;
    line-height: 1.5;
}

.spotify-redirect-help code {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
    color: #e5edf9;
    user-select: all;
}

.spotify-profile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 8px 0;
    padding: 12px 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.06), rgba(76, 201, 240, 0.04));
    border: 1px solid rgba(124, 92, 255, 0.12);
}

.spotify-profile.hidden {
    display: none;
}

.spotify-profile__top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spotify-profile__image {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, #1db954, #2dd65c);
    border: 2px solid rgba(255,255,255,0.15);
}

.spotify-profile__meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.spotify-profile__label,
.spotify-now-playing__label {
    font-size: 11px;
    color: #8da0ba;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#spotifyProfileName {
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-profile__email {
    color: #b6c3e1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-disconnect {
    border: none;
    border-radius: 10px;

.spotify-connect__service {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}
    background: rgba(255,255,255,0.06);
    color: #fff;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: 700;
}

.spotify-disconnect:hover {
    background: rgba(255,255,255,0.1);
}

.spotify-now-playing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.spotify-now-playing.hidden {
    display: none;
}

.spotify-now-playing__image {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(29, 185, 84, 0.24);
}

.spotify-now-playing__meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

#spotifyTrackName {
    color: white;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#spotifyTrackArtist {
    color: #b6c3e1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 720px) {

    body {
        height: 100vh;
        height: 100dvh;
    }

    .top-nav {
        position: relative;
        z-index: 22;
        height: 60px;
        padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
        gap: 12px;
    }

    .top-nav__brand {
        position: relative;
        flex: 0 0 auto;
        min-width: 0;
        gap: 0;
    }

    .top-nav__brand > div:last-child,
    .top-nav__brand strong {
        display: none;
    }

    /* Presence stays reachable: a status dot on the logo with an invisible select over it. */
    .top-nav__brand > div:last-child {
        display: block;
    }

    .nav-presence {
        position: absolute;
        right: -4px;
        bottom: -4px;
        width: 16px;
        height: 16px;
        padding: 0;
        border-radius: 50%;
        background: var(--sidebar, #10151e);
        display: grid;
        place-items: center;
        justify-content: center;
    }

    .nav-presence__dot {
        width: 10px;
        height: 10px;
    }

    .nav-presence select {
        position: absolute;
        inset: -8px;
        width: calc(100% + 16px);
        height: calc(100% + 16px);
        max-width: none;
        opacity: 0;
        font-size: 16px;
    }

    .top-nav__status {
        display: none;
    }

    .top-nav__links {
        display: flex;
        flex: 1 1 auto;
        justify-content: center;
        gap: 6px;
        min-width: 0;
    }

    .top-nav__link {
        padding: 0 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    .top-nav__actions {
        flex: 0 0 auto;
        min-width: 0;
        gap: 10px;
    }

    .notifications-button {
        position: relative;
        display: grid;
        place-items: center;
        width: 34px;
        padding: 0;
    }

    .notifications-button .notification-count {
        position: absolute;
        top: 8px;
        right: -2px;
    }

    .notifications-button__label {
        display: none;
    }

    .notifications-button::before {
        content: "🔔";
        font-size: 15px;
    }

    .top-nav__profile {
        display: grid;
        flex: 0 0 32px;
    }

    .theme-toggle {
        padding: 7px 9px;
    }

    .theme-toggle__label {
        display: none;
    }

    .app {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 56px minmax(0, 1fr);
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        min-height: 0;
        padding: 0;
        gap: 0;
    }

    .servers {
        grid-row: 1;
        width: 100%;
        height: 56px;
        min-height: 56px;
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 6px 10px;
        border: 0;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
    }

    .servers > .logo:not(.home-button) {
        display: none;
    }

    #serverList {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        gap: 8px;
    }

    .server,
    .logo {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        border-radius: 12px;
    }

    .home-button {
        flex-basis: 40px;
    }

    .server.active {
        border-radius: 12px;
    }

    .add-server {
        flex: 0 0 40px;
        font-size: 28px;
    }

    .channels {
        position: fixed;
        z-index: 21;
        top: 60px;
        bottom: 0;
        left: 0;
        width: min(320px, 88vw);
        padding: 10px 12px max(12px, env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 0 16px 16px 0;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    body.mobile-sidebar-open .channels {
        transform: translateX(0);
    }

    .mobile-sidebar-backdrop {
        position: fixed;
        z-index: 20;
        inset: 60px 0 0;
        width: 100%;
        height: calc(100dvh - 60px);
        border: 0;
        background: rgba(2, 6, 23, 0.55);
    }

    body.mobile-sidebar-open .mobile-sidebar-backdrop,
    body.mobile-members-open .mobile-sidebar-backdrop {
        display: block;
    }

    .chat {
        grid-row: 2;
        width: 100%;
        min-height: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-header {
        flex: 0 0 58px;
        height: 58px;
        padding: 0 12px;
    }

    .chat-header__title {
        min-width: 0;
        gap: 10px;
    }

    .chat-header__title strong {
        min-width: 0;
        flex: 0 1 auto;
    }

    .mobile-sidebar-toggle {
        display: grid;
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
        place-items: center;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: var(--message-bg);
        color: var(--text);
        font-size: 18px;
        cursor: pointer;
        touch-action: manipulation;
    }

    .mobile-members-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-width: 42px;
        min-height: 40px;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: var(--message-bg);
        color: var(--text);
        font: inherit;
        font-size: 13px;
        cursor: pointer;
        touch-action: manipulation;
    }

    .chat-header strong {
        overflow: hidden;
        font-size: 16px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-header span {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .messages {
        min-height: 0;
        padding: 12px 10px 8px;
        overscroll-behavior: contain;
    }

    .message {
        gap: 9px;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 14px;
    }

    .avatar {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 11px;
    }

    .message-meta {
        align-items: flex-start;
        gap: 6px;
    }

    .message-user-row {
        gap: 5px;
    }

    .message-date {
        display: none;
    }

    .message-video,
    .message-image {
        width: 100%;
        max-height: min(55dvh, 420px);
    }

    .message-box {
        grid-template-columns: 40px 40px 40px 40px minmax(0, 1fr) 52px auto;
        gap: 6px;
        padding: 9px 8px max(9px, env(safe-area-inset-bottom));
    }

    .message-box input {
        min-width: 0;
        padding: 11px 10px;
        border-radius: 12px;
        font-size: 16px;
    }

    .message-box button {
        min-height: 44px;
        padding: 0 10px;
        border-radius: 12px;
        touch-action: manipulation;
    }

    .message-box #attachVideoButton,
    .message-box #emojiPickerButton,
    .message-box #gifPickerButton,
    .message-box #stickerPickerButton {
        width: 44px;
        min-height: 44px;
    }

    .emoji-picker {
        right: 6px;
        bottom: calc(100% + 6px);
        width: min(340px, calc(100vw - 20px));
    }

    .livestream-stage {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(150px, 1fr) minmax(120px, 0.8fr);
        flex-basis: 55dvh;
        min-height: 280px;
        max-height: 55dvh;
        padding: 10px;
    }

    .livestream-stage__header {
        align-items: flex-start;
        flex-direction: column;
    }

    .voice-call {
        padding: 10px;
    }

    .voice-call__toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .voice-call__actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .voice-call__actions button {
        min-height: 40px;
    }

    .members {
        display: none;
    }

    .home-view {
        padding: 20px 14px max(20px, env(safe-area-inset-bottom));
    }

    .home-view__columns {
        grid-template-columns: minmax(0, 1fr);
    }

    .discover-view {
        padding: 20px 14px max(20px, env(safe-area-inset-bottom));
    }

    .discover-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .discover-view__header {
        align-items: flex-start;
    }

    .discover-card__header {
        align-items: flex-start;
    }

    .sports-controls {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .app.is-home .mobile-sidebar-toggle,
    .app.is-home .mobile-members-toggle,
    .app.is-direct-message .mobile-sidebar-toggle,
    .app.is-direct-message .mobile-members-toggle {
        display: none;
    }

    .members[aria-label="Server members"] {
        position: fixed;
        z-index: 21;
        top: 60px;
        right: 0;
        bottom: 0;
        display: block;
        width: min(300px, 88vw);
        padding: 18px 14px max(14px, env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        border-left: 1px solid var(--border);
        background: var(--panel-strong);
        box-shadow: -12px 0 30px var(--shadow);
        transform: translateX(105%);
        transition: transform 0.2s ease;
    }

    body.mobile-members-open .members[aria-label="Server members"] {
        transform: translateX(0);
    }

    .app-dialog {
        width: calc(100% - 24px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }

    .auth-page {
        min-height: 100vh;
        min-height: 100dvh;
        padding: 16px;
    }

    .auth-card,
    .auth-container {
        width: 100%;
        max-width: 440px;
        padding: 24px 20px;
    }
}

@media (max-width: 380px) {
    .top-nav {
        padding-right: 8px;
        padding-left: 8px;
    }

    .top-nav__brand strong {
        font-size: 15px;
    }

    .message-box {
        grid-template-columns: 36px 36px 36px 36px minmax(0, 1fr) 46px auto;
        gap: 5px;
        padding-right: 6px;
        padding-left: 6px;
    }

    .message-box #attachVideoButton,
    .message-box #emojiPickerButton,
    .message-box #gifPickerButton,
    .message-box #stickerPickerButton {
        width: 36px;
    }

    .chat-header {
        padding-right: 7px;
        padding-left: 7px;
        gap: 6px;
    }

    .chat-header__title {
        gap: 6px;
    }

    .mobile-sidebar-toggle {
        flex-basis: 36px;
        width: 36px;
        height: 38px;
    }

    .mobile-members-toggle {
        min-width: 38px;
        min-height: 38px;
    }
}

/* =========================
   AUTHENTICATION
========================= */

.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: auto;
    padding: 24px;
    overflow: auto;
    background: #1e1f22;
}

.auth-card,
.auth-container {
    width: 420px;
    max-width: 90%;
    padding: 32px;
    border-radius: 8px;
    background: #313338;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.auth-mark {
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
    border-radius: 12px;
    object-fit: cover;
}

.top-nav__mark {
    object-fit: cover;
}

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.auth-card h1,
.auth-container h1 {
    color: #f2f3f5;
    text-align: center;
    margin-bottom: 8px;
}

.auth-card > p,
.auth-container > p {
    text-align: center;
    color: #b5bac1;
    margin-bottom: 24px;
}

.auth-card .auth-eyebrow {
    color: #8ea1ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.auth-card label,
.auth-container label {
    display: block;
    color: #b5bac1;
    font-size: 12px;
    font-weight: bold;
    margin: 16px 0 8px;
    text-transform: uppercase;
}

.auth-card input,
.auth-container input {
    width: 100%;
    padding: 12px;
    border: none;
    outline: none;
    border-radius: 4px;
    background: #1e1f22;
    color: white;
    font-size: 15px;
}

.auth-card input:focus,
.auth-container input:focus {
    box-shadow: 0 0 0 2px #5865f2;
}

.auth-appeal {
    display: grid;
    gap: 12px;
    margin-top: 20px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: left;
}

.auth-appeal summary {
    color: var(--muted-strong);
    font-weight: 700;
    cursor: pointer;
}

.auth-appeal > p:first-of-type {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.auth-appeal form {
    display: grid;
    gap: 9px;
}

.auth-appeal label {
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 700;
}

.auth-appeal select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #1e1f22;
    color: white;
    font-size: 15px;
}

.auth-appeal form button {
    margin-top: 8px;
}

.auth-card form button,
.auth-container form button {
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border: none;
    border-radius: 4px;
    background: #5865f2;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.auth-card form button:hover,
.auth-container form button:hover {
    opacity: 0.9;
}

.login-success {
    animation: login-form-launch 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes login-form-launch {
    45% { transform: scale(1.015); }
    100% { opacity: 0.15; transform: translateY(-14px) scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
    .app-login-entry .top-nav,
    .app-login-entry .servers,
    .app-login-entry .channels,
    .app-login-entry .chat,
    .app-login-entry .members,
    .login-success {
        animation: none;
    }
}

.auth-message,
#loginMessage {
    min-height: 20px;
    margin-top: 16px;
    margin-bottom: 0;
    text-align: center;
}

.auth-message--error {
    color: #f23f42;
}

.auth-message--success {
    color: #23a559;
}

.auth-footer {
    margin-top: 18px;
}

.auth-footer a {
    color: #00aff4;
    text-decoration: none;
}

.auth-forgot {
    margin: 10px 0 0;
    text-align: right;
    font-size: 13px;
}

.auth-forgot a {
    color: #00aff4;
    text-decoration: none;
}

.auth-reset-link {
    display: block;
    overflow-wrap: anywhere;
    margin-top: 10px;
    color: #00aff4;
    text-align: center;
    font-size: 13px;
}

.group-dialog { background: #1e1f22; color: #f2f3f5; border: 1px solid #3f4147; border-radius: 12px; padding: 20px; width: min(420px, 92vw); }
.group-dialog form { display: grid; gap: 10px; }
.group-dialog input[type=text] { padding: 10px; border-radius: 8px; border: 1px solid #3f4147; background: #111214; color: inherit; }
.group-dialog__friends { max-height: 220px; overflow: auto; display: grid; gap: 6px; }
.server-accent { width: 32px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; }

.message-image {
    cursor: zoom-in;
}

.media-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    padding: 16px;
}

.media-viewer__content {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: contain;
    background: #000;
}

.media-viewer__close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.connection-card {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(127, 127, 160, 0.12);
}

.connection-help,
.connection-status {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.85;
}

.connection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.connection-danger {
    background: #b3261e;
    color: #fff;
}

.connection-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
}

.connection-toggle input {
    width: auto;
}

.connection-channel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.connection-channel-row select {
    max-width: 55%;
}

.profile-connection {
    display: block;
    margin-top: 6px;
    color: inherit;
    font-size: 14px;
    text-decoration: none;
}

a.profile-connection:hover {
    text-decoration: underline;
}

.profile-connection--playing {
    opacity: 0.85;
    font-size: 13px;
}

/* Discord-style extras */
.chat-header .chat-tools {
    display: flex;
    gap: 6px;
    margin-left: auto;
    margin-right: 8px;
    color: inherit;
    font-size: inherit;
}

.chat-tool {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
}

.chat-tool:hover {
    border-color: var(--accent-1);
}

.reply-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 16px;
    padding: 6px 12px;
    border-radius: 8px 8px 0 0;
    background: var(--panel-strong);
    border: 1px solid var(--border);
    color: var(--muted-strong);
    font-size: 13px;
}

.reply-banner[hidden] {
    display: none;
}

.reply-banner button {
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.message-reply {
    margin-bottom: 2px;
    padding-left: 8px;
    border-left: 3px solid var(--accent-1);
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-pin {
    margin-left: 6px;
    font-size: 12px;
}

.reaction-bar {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-chip,
.reaction-add {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-strong);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.reaction-chip--mine {
    border-color: var(--accent-1);
    background: rgba(79, 70, 229, 0.15);
}

.reaction-add {
    opacity: 0.55;
}

.reaction-bar:hover .reaction-add,
.reaction-add:focus {
    opacity: 1;
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 20;
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-strong);
    box-shadow: 0 6px 20px var(--shadow);
}

.reaction-picker button {
    padding: 4px 6px;
    border: 0;
    background: none;
    font-size: 18px;
    cursor: pointer;
}

.typing-indicator {
    min-height: 18px;
    padding: 0 20px 2px;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

.channel--unread {
    font-weight: 700;
}

.unread-badge {
    float: right;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.server--unread {
    position: relative;
}

.server--unread::after {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: var(--text);
}

.info-dialog {
    width: min(560px, 92vw);
    max-height: 80vh;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-strong);
    color: var(--text);
}

.info-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.info-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.info-dialog__head h3 {
    margin: 0;
}

.info-dialog__head button {
    border: 0;
    background: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
}

.info-dialog__body {
    display: grid;
    gap: 8px;
    max-height: calc(80vh - 56px);
    padding: 14px 16px;
    overflow-y: auto;
}

.info-row {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--panel);
    overflow-wrap: anywhere;
}

.info-row span {
    color: var(--muted-strong);
    font-size: 14px;
}

.info-row--clickable {
    cursor: pointer;
}

.info-row--clickable:hover {
    outline: 1px solid var(--accent-1);
}

.info-search,
.manage-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-search input,
.manage-row input:not([type="color"]),
.manage-section > input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.manage-section {
    display: grid;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.manage-section h4 {
    margin: 0;
}

.manage-row > span {
    flex: 1;
}

.manage-member {
    display: grid;
    gap: 4px;
}

.manage-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.info-dialog button.danger {
    background: #b3261e;
    color: #fff;
}

.info-dialog button.chip--on {
    background: var(--accent-1);
    color: #fff;
}


/* Square profile pictures everywhere */
.member__avatar,
.dm-channel__avatar,
.avatar,
.profile-dialog__avatar,
.top-nav__profile,
.bsettings__avatar,
.friend-request-item img,
.manage-member img,
.livestream-chat-avatar,
img.avatar,
.avatar img,
.member__avatar img,
.dm-channel__avatar img,
.top-nav__profile img,
.profile-dialog__avatar img {
    border-radius: 6px !important;
    overflow: hidden;
}

@media (max-width: 760px) {
    .avatar { border-radius: 6px !important; }
}
.channel-group { margin-top: 8px; }
.channel-group__toggle { background: none; border: 0; cursor: pointer; text-align: left; flex: 1; padding: 0; }
.channel-group__heading { display: flex; align-items: center; gap: 4px; }

.media-grid { display: grid; gap: 4px; max-width: 480px; margin-top: 6px; grid-template-columns: repeat(2, 1fr); }
.media-grid--3, .media-grid--5, .media-grid--6, .media-grid--9, .media-grid--10 { grid-template-columns: repeat(3, 1fr); }
.media-grid--1 { grid-template-columns: 1fr; }
.media-grid__cell { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: #000; }
.media-grid__cell img, .media-grid__cell video { width: 100%; height: 100%; object-fit: cover; max-width: none; max-height: none; cursor: pointer; }
/* Mentions, threads */
.message--mention {
    border-left: 3px solid #f0b232;
    background: rgba(240, 178, 50, 0.1);
    padding-left: 8px;
    border-radius: 4px;
}

.unread-badge--mention {
    background: #f0b232;
    color: #1b1b1b;
    font-weight: 700;
}

.server--mention::after {
    background: #f0b232;
}

.thread-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-strong);
    color: var(--accent-2);
    font-size: 13px;
    cursor: pointer;
}

.thread-messages {
    display: grid;
    gap: 6px;
    max-height: 45vh;
    margin: 10px 0;
    overflow-y: auto;
}

.thread-message {
    display: grid;
    gap: 2px;
    padding: 4px 6px;
    overflow-wrap: anywhere;
}

.thread-form {
    display: flex;
    gap: 6px;
}

.thread-form input {
    flex: 1;
}

.thread-status {
    min-height: 16px;
    color: var(--muted);
    font-size: 12px;
}

.message-download {
    display: inline-block;
    width: fit-content;
    margin: 6px 0 0 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--message-bg);
    color: var(--muted-strong);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.message-download:hover {
    border-color: var(--accent-1);
}

.message-download--overlay {
    position: absolute;
    top: 6px;
    right: 6px;
    margin: 0;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-color: transparent;
}

/* Custom video player */
.video-player {
    position: relative;
    width: min(100%, 640px);
    margin-top: 10px;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
    outline: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.video-player:focus-visible {
    box-shadow: 0 0 0 2px var(--accent-1);
}

.video-player > video {
    display: block;
    width: 100%;
    max-height: 420px;
    margin: 0;
    aspect-ratio: 16 / 9;
    border-radius: 0;
    background: #000;
    object-fit: contain;
    cursor: pointer;
}

.vp--idle > video {
    cursor: none;
}

.vp__big {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.vp__big:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.vp--playing .vp__big,
.vp--loading .vp__big,
.vp--error .vp__big {
    opacity: 0;
    pointer-events: none;
}

.vp__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: vp-spin 0.8s linear infinite;
}

.vp--loading .vp__spinner {
    opacity: 1;
}

@keyframes vp-spin {
    to { transform: rotate(360deg); }
}

.vp__flash {
    position: absolute;
    top: 50%;
    padding: 8px 14px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
}

.vp__flash--left { left: 12%; }
.vp__flash--right { right: 12%; }
.vp__flash--show { opacity: 1; }

.vp__controls {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 22px 10px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
    transition: opacity 0.2s;
}

.vp--idle .vp__controls {
    opacity: 0;
    pointer-events: none;
}

.vp__seek {
    --progress: 0%;
    --buffered: 0%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    margin: 0 0 2px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.vp__seek::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--accent-1) var(--progress), rgba(255, 255, 255, 0.55) var(--progress), rgba(255, 255, 255, 0.55) var(--buffered), rgba(255, 255, 255, 0.22) var(--buffered));
}

.vp__seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -4px;
    border-radius: 50%;
    background: #fff;
}

.vp__seek::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
}

.vp__seek::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--accent-1);
}

.vp__seek::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 50%;
    background: #fff;
}

.vp__row {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
}

.vp__btn {
    display: inline-grid;
    min-width: 32px;
    height: 32px;
    place-items: center;
    padding: 0 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.vp__btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.vp__btn[hidden] {
    display: none;
}

.vp__time {
    margin-left: 4px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.vp__spacer {
    flex: 1;
}

.vp__volume {
    width: 70px;
    height: 16px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    accent-color: var(--accent-1);
    cursor: pointer;
}

.video-player--compact .vp__speed,
.video-player--compact .vp__mute,
.video-player--compact .vp__volume,
.video-player--compact .vp__pip {
    display: none;
}

.video-player--compact .vp__big {
    width: 44px;
    height: 44px;
    font-size: 18px;
}

.media-grid__cell .video-player {
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
}

.media-grid__cell .video-player > video {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    object-fit: cover;
}

.video-player--viewer {
    width: min(100%, 1280px);
    margin: 0;
}

.video-player--viewer > video {
    max-height: 85vh;
    aspect-ratio: auto;
}

.video-player:fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
}

.video-player:fullscreen > video {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
}

.video-player:-webkit-full-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
}

.video-player:-webkit-full-screen > video {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
}

@media (max-width: 720px) {
    .video-player {
        width: 100%;
    }

    .video-player > video {
        max-height: min(55dvh, 420px);
    }

    .vp__btn {
        min-width: 40px;
        height: 40px;
    }

    .vp__volume {
        display: none;
    }
}

/* Custom music player */
.music-player {
    display: grid;
    gap: 8px;
    width: min(100%, 440px);
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-strong);
    box-shadow: 0 6px 18px var(--shadow);
}

.music-player--playing {
    border-color: var(--accent-1);
}

.music-player__top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.music-player__art {
    display: grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    font-size: 22px;
}

.music-player--playing .music-player__art {
    animation: music-pulse 1.4s ease-in-out infinite;
}

@keyframes music-pulse {
    50% { transform: scale(1.07); }
}

.music-player__info {
    min-width: 0;
    flex: 1;
}

.music-player__title {
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.music-player__sub {
    color: var(--muted);
    font-size: 12px;
}

.music-player--error .music-player__sub {
    color: #ef4444;
}

.music-player--loading .music-player__play {
    opacity: 0.6;
}

.music-player__bar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.music-player__time {
    min-width: 34px;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.music-player__controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.music-player__btn {
    display: inline-grid;
    min-width: 36px;
    height: 36px;
    place-items: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--message-bg);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}

.music-player__btn:hover {
    border-color: var(--accent-1);
}

.music-player__play {
    min-width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    font-size: 16px;
}

.music-player__volume {
    flex: 1 1 60px;
    min-width: 40px;
    max-width: 110px;
}

.music-player input[type="range"] {
    height: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    accent-color: var(--accent-1);
    cursor: pointer;
}

.music-player__seek {
    width: 100%;
    min-width: 0;
}

@media (max-width: 720px) {
    .music-player__controls {
        flex-wrap: wrap;
    }

    .music-player__btn {
        min-width: 40px;
        height: 40px;
    }

    .music-player__volume {
        display: none;
    }
}

/* Mobile fixes */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (max-width: 720px) {
    input,
    select,
    textarea,
    .app-dialog__form input,
    .app-dialog__form select,
    .thread-form input {
        font-size: 16px;
    }

    .message-box .attachment-status {
        grid-column: 1 / -1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .message-box button[type="submit"] {
        min-width: 52px;
    }

    .message,
    .message-content,
    .message-text {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .messages {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .message-more {
        min-width: 40px;
        min-height: 36px;
        font-size: 24px;
    }

    .message-dropdown {
        max-width: calc(100vw - 32px);
        min-width: 180px;
    }

    .message-dropdown button {
        padding: 13px 14px;
        font-size: 15px;
    }

    .reaction-add {
        opacity: 1;
    }

    .reaction-chip,
    .reaction-add,
    .thread-chip {
        min-height: 32px;
    }

    .reaction-picker {
        max-width: calc(100vw - 32px);
        flex-wrap: wrap;
    }

    .reply-banner {
        margin: 0 8px;
    }

    .media-grid {
        max-width: 100%;
    }

    .thread-messages {
        max-height: 40dvh;
    }

    .thread-form {
        flex-wrap: wrap;
    }

    .chat-tool {
        width: 40px;
        height: 40px;
    }

    .app-dialog__actions {
        flex-wrap: wrap;
    }

    .top-nav__links {
        min-width: 0;
        overflow: hidden;
    }
}

@media (hover: none) {
    .reaction-bar .reaction-add {
        opacity: 1;
    }
}

/* Discord-style channel list */
.channel { position: relative; display: flex; align-items: center; gap: 6px; padding-right: 30px; }
.channel .channel__gear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    opacity: 0; font-size: 14px; line-height: 1; padding: 4px; border-radius: 6px; cursor: pointer; color: var(--muted);
}
.channel:hover .channel__gear, .channel.active .channel__gear, .channel__gear:focus { opacity: 1; }
.channel .channel__gear:hover { color: var(--text); background: rgba(127,127,127,0.18); }
@media (hover: none) { .channel .channel__gear { opacity: 0.8; } }
.channel[draggable="true"] { cursor: grab; }
.channel.dragging { opacity: 0.4; }
.channel.drop-before { box-shadow: 0 -2px 0 0 #5865f2; }
.channel-group__heading.drop-before { box-shadow: 0 -2px 0 0 #5865f2; }
.channel-group__heading.drop-into { background: rgba(88,101,242,0.18); border-radius: 6px; }
.channel-menu {
    position: fixed; z-index: 10000; min-width: 170px; padding: 6px;
    background: var(--panel-strong, #1e1f22); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    display: grid; gap: 2px;
}
.channel-menu button {
    background: none; border: 0; color: inherit; text-align: left; padding: 8px 10px;
    border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer;
}
.channel-menu button:hover { background: rgba(88,101,242,0.2); }
.channel-menu button.danger { color: #f23f43; }
