body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    color: #f8fafc;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.conn-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444; /* Red by default */
    margin-right: 0.5rem;
    transition: background-color 0.3s;
}

.conn-status.connected {
    background-color: #22c55e; /* Green */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

h1 {
    margin: 0;
    font-weight: 300;
    font-size: 1.25rem;
    background: linear-gradient(to right, #60a5fa, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status {
    padding: 0.3rem 0.8rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    transition: all 0.2s;
}

.status.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.menu-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-button {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #eab308; /* Yellow */
    color: #0f172a;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.badge.hidden {
    display: none;
    animation: none;
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.3;
    pointer-events: none;
}

.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: none;
    z-index: 200;
    min-width: 160px;
}

.show-block {
    display: block !important;
}

.show-flex {
    display: flex !important;
}

.cursor-pointer {
    cursor: pointer;
}

.icon-grey {
    color: #888 !important;
    opacity: 0.5 !important;
}

/* Network Health Badges for Text Output */
.badge-good {
    color: #4ade80; /* Green */
    font-weight: 600;
}

.badge-fair {
    color: #fbbf24; /* Yellow */
    font-weight: 600;
}

.badge-poor {
    color: #f87171; /* Red */
    font-weight: 600;
}

.dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.part-menu {
    position: fixed; /* Fixed relative to viewport for click coords */
    top: 0;
    left: 0;
    margin: 0;
    z-index: 900;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown button {
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.video-container {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    /* backdrop-filter: blur(4px); - removed as requested */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    visibility: visible;
}

.modal.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.5);
}

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
    color: #e2e8f0;
}

.modal-body {
    padding: 1.5rem;
}

/* Re-use dynamic controls styling inside modal */
.modal-body .control-item {
    margin-bottom: 1.5rem;
}

.label {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-panel {
    width: 320px;
    background: #1e293b;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-panel.hidden {
    display: none;
    /* margin-right: -320px; invalid in vertical flex */
    /* opacity: 0; insufficient for interaction */
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: #f8fafc;
}

.settings-content {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.dynamic-controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-bottom: 1rem;
}

.control-section h3 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.no-controls {
    font-size: 0.8rem;
    color: #475569;
    font-style: italic;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.control-header label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.control-value {
    font-size: 0.8rem;
    color: #cbd5e1;
    font-family: monospace;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #334155;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #60a5fa;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.5);
}

.field label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

select {
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid #334155;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover {
    border-color: #60a5fa;
}

#startButton {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

#startButton:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3);
}

#startButton:disabled {
    background: #334155;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

.join-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
}

.user-info .lws-login-status {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
}

.user-info .lws-login-identity {
    font-size: 0.85rem;
    color: #e2e8f0;
    font-weight: 500;
}

.user-info .lws-login-btn {
    font-size: 0.75rem;
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s;
}

.user-info .lws-login-btn:hover {
    color: #ef4444;
}

.join-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#nameInput {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    outline: none;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

#nameInput:focus {
    border-color: #60a5fa;
}

#nameInput:disabled {
    background: rgba(15, 23, 42, 0.3);
    color: #64748b;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
}

.sidebar {
    width: 300px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.participant-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.participant-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.participant-item {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    color: #e2e8f0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.participant-item.unjoined {
    justify-content: center;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.icon-user-silhouette {
    color: #f8fafc; /* White */
    width: 20px;
    height: 20px;
    opacity: 0.9;
}

.participant-item.unjoined .icon-user-silhouette {
    color: #94a3b8; /* Grey for inactive users */
    opacity: 0.7;
}

.overlay-container {
    position: absolute;
    top: var(--overlay-top, 0);
    left: var(--overlay-left, 0);
    width: var(--overlay-width, 100%);
    height: var(--overlay-height, 100%);
    pointer-events: none;
}

.name-overlay {
    position: absolute;
    left: var(--r-x, 0);
    top: var(--r-y, 0);
    max-width: var(--r-w, 100%);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    pointer-events: none;
    white-space: nowrap;
}
/* ... existing code ... */

.boolean-control {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.8rem;
    color: #cbd5e1;
    user-select: none;
    height: 25px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #334155;
    border-radius: 4px;
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: #475569;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: #60a5fa;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
/* ... existing code ... */

.control-select {
    width: 100%;
    background: #334155;
    color: #f1f5f9;
    border: 1px solid #475569;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    outline: none;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
}

.control-select:hover {
    border-color: #60a5fa;
    background-color: #3b4d63;
}

.control-select option {
    background: #1e293b;
    color: #f1f5f9;
}

.leave {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2) !important;
}

.leave:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(220, 38, 38, 0.3) !important;
}

.label {
    transition: opacity 1.5s ease-in-out;
}

.label.hidden {
    opacity: 0;
}

.sys-status {
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 0;
    font-family: monospace;
    white-space: nowrap;
    opacity: 0.8;
}
.sys-status.hidden {
    display: none;
}

/* Audio Controls */
.audio-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.audio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #22c55e;
    margin-left: 4px;
    opacity: 0.2; /* Default low opacity */
    transition: opacity 0.1s ease-out;
}

.icon-button.muted {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.icon-button.muted svg {
    stroke-width: 2.5;
}

.join-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chat Overlay */
.chat-overlay {
    position: absolute;
    top: 10px;
    right: 2rem; /* Align with header padding */
    width: 300px;
    bottom: 20px; /* Stretch to bottom with some padding */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: opacity 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chat-overlay.hidden {
    display: none;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-msg {
    color: #1e293b;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 10px;
    border-radius: 6px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-sender {
    font-weight: 700;
    margin-right: 6px;
    color: #059669; /* Darker green for light background */
    font-size: 0.9em;
}

.chat-text a {
    color: #2563eb;
    text-decoration: none;
}
.chat-text a:hover {
    text-decoration: underline;
}

#chatInput {
    background: #ffffff;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: #1e293b;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    outline: none;
    border-radius: 0 0 8px 8px;
}

#chatInput:focus {
    background: #f8fafc;
}
.settings-panel.remote .field > label,
.settings-panel.remote .field > select {
    display: none;
}

.settings-panel.remote .panel-header h2 {
    color: #60a5fa;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#remoteSettingsGroup {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.remote-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* CSP Refactor Classes */
.remote-control-header-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    margin-bottom: 1rem;
}
.remote-control-header-title {
    font-weight: 600;
    color: #fff;
}
.remote-control-header-name {
    font-size: 0.9em;
    font-weight: 400;
    color: #94a3b8;
}
.node-group-spaced {
    margin-bottom: 1.5rem;
}
.remote-node-header {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}
.overlay-name-span {
    font-weight: bold;
}
.overlay-stats-span {
    font-size: 0.8em;
    opacity: 0.8;
    white-space: pre-wrap;
}
.debug-modal-content {
    max-width: 800px;
    width: 90%;
}
.debug-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--danger, #ef4444);
}
.debug-modal-body {
    padding: 1.5rem;
}
.debug-modal-desc {
    margin-bottom: 1rem;
    color: #cbd5e1;
}
.debug-log-area {
    width: 100%;
    height: 300px;
    background: rgba(0,0,0,0.4);
    color: #10b981;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.85em;
    resize: vertical;
}
.debug-modal-footer {
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 16px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}
.debug-btn-primary {
    background: var(--danger, #ef4444);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.debug-btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.show-flex {
    display: flex !important;
}

@media (max-width: 900px), (orientation: portrait) {
    header {
        padding: 0.4rem 0.5rem;
        gap: 0.5rem;
    }
    .header-left {
        gap: 0.5rem;
    }
    h1 {
        font-size: 0.9rem;
        white-space: nowrap;
    }
    .status {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }
    #nameInput {
        width: 100px;
        font-size: 0.8rem;
        padding: 0.3rem;
    }
    #startButton {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        white-space: nowrap;
    }
    .icon-button {
        padding: 0.3rem;
    }
    .icon-button svg {
        width: 18px;
        height: 18px;
    }
    .title-group {
        gap: 0.2rem;
    }
    .join-input-group {
        gap: 0.2rem;
    }
    .join-controls {
        gap: 0.4rem;
    }
    .main-layout {
        flex-direction: column;
    }
    .video-container {
        flex: 1 1 60%;
        min-height: 50vh;
    }
    .sidebar {
        width: 100%;
        flex: 1 1 40%;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    .settings-panel {
        position: absolute;
        top: 0;
        right: 0;
        height: 100%;
        width: 100%;
        z-index: 100;
        border-left: none;
    }
}
