:root {
    --bg-color: #111827;
    --card-color: #1F2937;
    --primary-color: #38BDF8;
    --primary-color-dark: #0EA5E9;
    --secondary-color: #F43F5E;
    --accent-color: #374151;
    --text-color: #F9FAFB;
    --text-color-muted: #9CA3AF;
    --success-color: #22C55E;
    --warning-color: #F59E0B;
    --font-family: 'Inter', sans-serif;
}
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font-family); background: var(--bg-color); color: var(--text-color);
    margin: 0; display: flex; justify-content: center; align-items: center; padding: 1rem; box-sizing: border-box;
}
.app-container {
    width: 100%; max-width: 450px; height: 100%; max-height: 850px;
    background: var(--card-color); border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1); padding: 0;
    overflow: hidden;
}
.header {
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0; padding: 1rem 1.5rem; border-bottom: 1px solid var(--accent-color);
}
.header h1 {
    margin: 0; font-size: 1.5rem; font-weight: 700;
    display: flex; align-items: center; gap: 0.75rem; color: var(--primary-color);
}
.header-buttons { display: flex; gap: 10px; align-items: center; }
.header-buttons button, .header-buttons div {
    background-color: var(--accent-color); color: var(--text-color-muted);
    width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; border: none; cursor: pointer;
}
.header-buttons button:hover, .header-buttons div:hover { background-color: var(--primary-color); color: white; }
.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }
#name-view { justify-content: center; text-align: center; padding: 1.5rem; gap: 1rem; }
#name-view .logo { font-size: 3rem; color: var(--primary-color); margin-bottom: 0.5rem; }
#name-view h2 { font-size: 1.8rem; margin: 0 0 2rem 0; }
.input-group { position: relative; display: flex; width: 100%; }
.input-group i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-color-muted); }
input[type="text"] {
    width: 100%; padding: 14px 14px 14px 45px; background: var(--accent-color);
    border: 2px solid transparent; border-radius: 12px; color: var(--text-color);
    font-family: var(--font-family); font-size: 1rem; box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="text"]:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3); }
button {
    padding: 14px 20px; border: none; border-radius: 12px; font-family: var(--font-family);
    font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
    display: flex; justify-content: center; align-items: center; gap: 10px;
}
button.btn-primary { background: linear-gradient(45deg, var(--primary-color), var(--primary-color-dark)); color: white; box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2); }
button.btn-danger { background-color: var(--secondary-color); color: white; }
#quick-join-container { width: 100%; margin-top: 1.5rem; }
#quick-join-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.quick-join-btn { padding: 10px; font-weight: 600; background-color: var(--accent-color); color: var(--text-color-muted); }
.quick-join-btn:hover { background-color: var(--primary-color); color: white; }

#broadcast-selector-container {
    flex-shrink: 0; background: rgba(0,0,0,0.2);
    border-radius: 12px; padding: 10px; text-align: left;
    display: flex; align-items: center; gap: 10px;
}
#broadcast-selector-container label { font-weight: 500; color: var(--primary-color); white-space: nowrap; }
#broadcast-selector-container select {
    flex-grow: 1; padding: 8px; background: var(--accent-color); color: var(--text-color);
    border: 1px solid transparent; border-radius: 8px; font-family: var(--font-family);
}
#shareChannelBtn { padding: 0; min-width: 40px; height: 40px; flex-shrink: 0; }
#channel-filter-container { flex-shrink: 0; }

#filter-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex-shrink: 1;
    padding-right: 5px;
    margin-right: -5px;
}

.filter-item {
    display: flex; align-items: center;
    background: var(--accent-color); padding: 5px 10px;
    border-radius: 8px; font-size: 0.9rem; cursor: pointer;
}
.filter-item label { width: 100%; cursor: pointer; }

#user-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    align-content: start;
}
.user-card {
    background-color: var(--accent-color);
    border-radius: 12px;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease-in-out;
    word-break: break-word;
}
.user-card.is-talking {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    transform: translateY(-3px);
}
.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.2;
}
.user-channel {
    font-size: 0.8rem;
    color: var(--text-color-muted);
    margin-top: 4px;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.footer-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    flex-grow: 1;
}

.footer-options-menu {
    position: relative;
    display: flex;
}

.footer-icon-btn {
    background-color: var(--accent-color);
    color: var(--text-color-muted);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.footer-icon-btn:hover {
    background-color: #4B5563;
    color: var(--text-color);
}
.footer-icon-btn.active {
     background-color: var(--primary-color);
     color: white;
     transform: rotate(45deg);
}

.options-popup {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    width: 300px;
    max-width: 90vw;
    background: var(--card-color);
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    z-index: 10;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 60vh;
}
.options-popup h4 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.options-popup hr {
    margin: 0.25rem 0;
}
.device-controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
#ptt-button {
    width: 70px; height: 70px; border-radius: 50%;
    background: linear-gradient(145deg, var(--primary-color), var(--primary-color-dark));
    color: white; font-size: 2.2rem; cursor: pointer; user-select: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3); animation: pulse-blue 2.5s infinite;
}
#ptt-button.live {
    background: linear-gradient(145deg, #F43F5E, #BE123C);
    box-shadow: 0 0 25px var(--secondary-color); transform: scale(1.1);
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-blue { 0%, 100% { box-shadow: 0 0 15px rgba(56, 189, 248, 0.2); } 50% { box-shadow: 0 0 25px rgba(56, 189, 248, 0.4); } }
@keyframes pulse-red { 0%, 100% { transform: scale(1.1); box-shadow: 0 0 25px var(--secondary-color); } 50% { transform: scale(1.15); box-shadow: 0 0 35px var(--secondary-color); } }
#status-bar { padding: 0.5rem 1.5rem; font-size: 0.85rem; color: var(--text-color-muted); text-align: center; background: var(--bg-color); flex-shrink: 0;}
#local-video-preview { width: 100%; height: 100%; border-radius: 8px; background-color: black; object-fit: cover; transform: scaleX(-1); }
.video-control-btn { position: absolute; background: rgba(0,0,0,0.5); color: white; border: none; border-radius: 50%; width: 30px; height: 30px; padding: 0; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 1rem; box-sizing: border-box; }
.modal-content { background: var(--card-color); padding: 1.5rem; border-radius: 16px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 1rem; max-height: 90vh; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 1rem; }
#saved-private-channels-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.saved-channel-item { display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 5px; }
#generate-code-btn { flex-shrink: 0; margin-left: 5px; padding: 12px; }
hr { width: 100%; border-color: var(--accent-color); margin: 0.5rem 0; border-style: solid;}
#device-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1; 
    justify-content: flex-start;
    flex-wrap: wrap;
}
.device-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background-color: var(--accent-color);
    color: var(--text-color-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.device-btn:hover {
    background-color: #4B5563;
    color: var(--text-color);
}
.device-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}
#current-mic-name {
    font-size: 0.75rem;
    color: var(--text-color-muted);
    margin-bottom: 0;
    text-align: center;
    min-height: 1em;
    width: 100%;
}
.ptt-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--accent-color);
    background-color: var(--card-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between; /* <-- ADD THIS LINE */
}
.clickable-user {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.2s ease;
}
.clickable-user:hover {
    color: var(--warning-color);
}

/* Styling for the new welcome heading */
.welcome-heading {
    margin-bottom: 2rem;
    line-height: 1.2;
}
.welcome-heading h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: 700;
}
.welcome-heading p {
    font-size: 1.1rem;
    color: var(--text-color-muted);
    margin: 0.25rem 0 0 0;
}

/* This rule can be removed or ignored as we are no longer using an h2 in that spot */
#name-view h2 { 
    font-size: 1.8rem; 
    margin: 0 0 2rem 0; 
}