:root {
    color-scheme: dark;

    --bg: #111318;
    --sidebar: #171a21;
    --panel: #1d2129;
    --panel-2: #232832;
    --panel-3: #2b313c;

    --text: #f3f5f7;
    --muted: #9aa3af;
    --border: #303641;

    --accent: #6574ff;
    --accent-hover: #7582ff;

    --danger: #e96363;
    --success: #4fc38b;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}


/* LOGIN */

#loginView {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 34px;
}

.brand {
    font-size: 28px;
    font-weight: 750;
    letter-spacing: -0.5px;
}

.tagline {
    color: var(--muted);
    margin-top: 4px;
    margin-bottom: 30px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 7px;
}

.field input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    padding: 12px 13px;
    border-radius: 9px;
    outline: none;
}

.field input:focus {
    border-color: var(--accent);
}

.primary-btn {
    width: 100%;
    border: 0;
    border-radius: 9px;
    padding: 12px 16px;
    background: var(--accent);
    color: white;
    font-weight: 650;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

.error {
    color: var(--danger);
    min-height: 22px;
    margin-top: 13px;
    font-size: 14px;
}


/* APP */

#appView {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 72px 240px minmax(0, 1fr) 220px;
}

.communities {
    background: #0d0f13;
    border-right: 1px solid var(--border);
    padding: 12px 8px;
}

.community-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 10px;
    border-radius: 15px;
    border: 0;
    background: var(--panel-3);
    color: white;
    font-weight: 750;
}

.community-logo.active {
    background: var(--accent);
}

.channel-sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.community-header {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.channel-list {
    flex: 1;
    padding: 14px 9px;
    overflow-y: auto;
}

.section-label {
    padding: 10px 10px 6px;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .8px;
    font-weight: 700;
}

.channel {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;

    border: 0;
    background: transparent;
    color: var(--muted);

    padding: 9px 10px;
    border-radius: 7px;
    text-align: left;
}

.channel:hover,
.channel.active {
    color: var(--text);
    background: var(--panel-3);
}

.user-panel {
    border-top: 1px solid var(--border);
    background: var(--panel);
    padding: 10px;

    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 9px;
}

.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;

    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.user-name {
    font-size: 14px;
    font-weight: 650;
}

.username {
    color: var(--muted);
    font-size: 11px;
}

.icon-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 6px;
}

.icon-btn:hover {
    color: var(--text);
}


/* CHAT */

.main-panel {
    background: var(--bg);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.main-header {
    min-height: 57px;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;

    display: flex;
    align-items: center;
    gap: 9px;
}

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

.channel-description {
    color: var(--muted);
    font-size: 13px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.empty-state {
    color: var(--muted);
    padding: 40px 0;
}

.message {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 11px;
    padding: 8px 0;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;

    background: var(--panel-3);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.message-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.message-author {
    font-weight: 700;
}

.message-time {
    color: var(--muted);
    font-size: 11px;
}

.message-content {
    margin-top: 3px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.composer {
    padding: 12px 20px 20px;
}

.composer-inner {
    display: flex;
    align-items: center;

    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

#messageInput {
    flex: 1;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    padding: 13px 15px;
    min-width: 0;
}

.send-btn {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    padding: 11px 16px;
}


/* VOICE */

.voice-placeholder {
    padding: 34px;
}

.voice-card {
    max-width: 520px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 26px;
}

.voice-card h2 {
    margin-top: 0;
}

.voice-status {
    color: var(--muted);
    margin-bottom: 18px;
}

.voice-button {
    border: 0;
    background: var(--accent);
    color: white;
    border-radius: 9px;
    padding: 11px 18px;
    font-weight: 700;
}

.voice-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}


/* MEMBERS */

.members-panel {
    background: var(--sidebar);
    border-left: 1px solid var(--border);
    padding: 17px 12px;
}

.members-title {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .8px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 12px;
}

.member {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px;
    color: var(--muted);
}

.member .avatar {
    width: 30px;
    height: 30px;
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}


/* MOBILE */

@media (max-width: 950px) {
    #appView {
        grid-template-columns: 64px 220px minmax(0, 1fr);
    }

    .members-panel {
        display: none;
    }
}

@media (max-width: 700px) {
    #appView {
        grid-template-columns: 190px minmax(0, 1fr);
    }

    .communities {
        display: none;
    }
}


/* =========================================================
   VOXLY WORKSPACE v0.8.0
   ========================================================= */

#appView {
    grid-template-columns:
        72px
        270px
        minmax(420px, 1fr)
        240px;
}

.channel-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.channel-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.main-panel {
    min-width: 0;
}

#textChannelView {
    display: flex !important;
}

.voice-sidebar-panel {
    flex: 0 0 auto;
    padding: 10px;
    border-top: 1px solid #262c38;
    background: rgba(9, 11, 16, 0.45);
}

.voice-sidebar-panel .voice-card {
    margin: 0;
    padding: 11px;
    border-radius: 10px;
    background: #11141b;
    border: 1px solid #292f3b;
}

.voice-panel-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 5px;
}

.voice-sidebar-panel h2 {
    font-size: 14px;
    margin: 0 0 5px 0;
}

.voice-sidebar-panel .voice-status {
    font-size: 11px;
    margin-bottom: 9px;
}

.voice-sidebar-panel .voice-button {
    font-size: 11px;
    padding: 7px 9px;
}

.voice-sidebar-panel
#voxlyVoiceParticipants {
    margin-top: 9px !important;
    padding-top: 7px;
    border-top: 1px solid #252b35;
    font-size: 11px;
}

.voice-sidebar-panel
#voxlyVoiceParticipants > div {
    padding: 3px 0 !important;
}

.channel.voice-selected {
    background:
        rgba(124, 101, 255, 0.10);
}

.channel.voice-selected::before {
    content: "";
    width: 3px;
    align-self: stretch;
    border-radius: 3px;
    background: #7d6cff;
    margin-right: 5px;
}

.members-panel {
    min-width: 0;
}

.user-panel {
    flex: 0 0 auto;
}

@media (max-width: 1000px) {

    #appView {
        grid-template-columns:
            64px
            240px
            minmax(360px, 1fr);
    }

    .members-panel {
        display: none;
    }
}

@media (max-width: 720px) {

    #appView {
        grid-template-columns:
            220px
            minmax(0, 1fr);
    }

    .communities {
        display: none;
    }
}




/* =========================================================
   VOXLY COMPACT SIDEBAR CSS v0.8.1
   ========================================================= */

/*
 * The bottom-left box becomes a tiny voice-control bar.
 */

.voice-sidebar-panel {
    flex: 0 0 auto !important;
    padding: 7px 8px !important;
    border-top: 1px solid #282e39 !important;
    background: #0d1016 !important;
}

.voice-sidebar-panel .voice-card {
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
}


/*
 * Hide duplicate information.
 * Lounge already exists in the channel list.
 */

.voice-sidebar-panel .voice-panel-label,
.voice-sidebar-panel #voiceRoomTitle,
.voice-sidebar-panel .voice-status {
    display: none !important;
}


/*
 * Hide the old "In this voice channel" heading.
 */

.voxly-hide-participant-title {
    display: none !important;
}


/*
 * The actual roster now lives directly beneath Lounge.
 */

#voxlyVoiceParticipants.voxly-inline-roster {
    display: block;
    margin: 2px 8px 8px 29px !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 11px;
    color: var(--muted);
}

#voxlyVoiceParticipants.voxly-inline-roster > div {
    padding: 3px 3px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/*
 * Compact bottom buttons.
 */

#voxlyCompactVoiceControls {
    display: flex !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    margin: 0 !important;
}

#voxlyCompactVoiceControls .voice-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 5px !important;
    font-size: 10px !important;
    white-space: nowrap;
}


/*
 * Join Voice stays compact while disconnected.
 */

.voice-sidebar-panel > .voice-card > .voice-button {
    width: 100%;
    margin: 0;
    padding: 7px !important;
    font-size: 10px !important;
}


/*
 * We keep the old quality controls functional but
 * remove them from the sidebar.
 */

.voxly-hidden-share-settings {
    display: none !important;
}


/*
 * Stream viewing belongs in the CENTER column.
 */

#voxlyCenterStreamViewer {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none !important;
    margin: 12px 16px 0 !important;
    padding: 12px !important;

    background: #11141b;
    border: 1px solid #292f3b;
    border-radius: 12px;
}

#voxlyCenterStreamViewer #voxlyStreamContainer {
    max-height: 48vh;
}

#voxlyCenterStreamViewer video {
    max-height: 48vh !important;
}


/*
 * Do not let the compact controls increase sidebar width.
 */

.channel-sidebar {
    overflow: hidden;
}

.channel-list {
    overflow-y: auto;
}



/* =========================================================
   VOXLY SAFE SIDEBAR v0.8.4
   ========================================================= */

/*
 * Server-backed presence is now authoritative.
 * Never show the older local LiveKit roster.
 */
#voxlyVoiceParticipants {
    display: none !important;
}

/*
 * IMPORTANT: the actual voice JS sets this container to
 * display:none or display:flex depending on connection state.
 * These selectors preserve that state instead of overriding it.
 */
#voxlyCompactVoiceControls[style*="display: none"] {
    display: none !important;
}

#voxlyCompactVoiceControls[style*="display: flex"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 7px !important;
    width: 100% !important;
    margin: 0 !important;
}

#voxlyCompactVoiceControls[style*="display: flex"] .voice-button {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 8px 5px !important;
    font-size: 10px !important;
}

/* Share Screen gets its own full-width second row. */
#voxlyCompactVoiceControls[style*="display: flex"] #voxlyCompactShareButton {
    grid-column: 1 / -1 !important;
}

/*
 * When disconnected, the original Join Voice button is the
 * only control that should be visible.
 */
.voice-sidebar-panel .voice-card > .voice-button {
    width: 100% !important;
    margin: 0 !important;
    padding: 8px 6px !important;
    font-size: 10px !important;
}

/* Cleaner server-backed users beneath Lounge. */
.voxly-server-voice-roster {
    margin: 3px 8px 9px 29px !important;
    padding: 0 !important;
}

.voxly-server-voice-user {
    padding: 4px 2px !important;
    line-height: 1.25 !important;
}
