:root {
    /* Theme color variables updated to match styles.css */
    --accent-cyan: #ffffff1f;
    --accent-cyan-2: #f5f5f5;
    --accent-cyan-light: #ffffff;
    
    --bg-dark-1: #090909;
    --bg-dark-2: #171717;
    --bg-dark-3: #090909;
    --bg-dark-4: #131313;
    
    --text-primary: #f5f5f5;
    --text-secondary: #ffffff;
    --text-muted: #b2b2b2;
    --border-color: #ffffff1f;
    --focus-ring: #ffffff;

    --status-online: #96eb56;
    --status-offline: #777777;
    --status-connecting: #ffc107;

    --ease-out-expo: cubic-bezier(0.2, 0.8, 0.2, 1);
    
    /* Radial background gradient matching styles.css body::before */
    --body-bg: radial-gradient(
        ellipse at 78% 12%,
        #363636 0%,
        #181818 37%,
        #090909 76%
    );
}

*,
*::before,
*::after {
    box-sizing: border-box;
    touch-action: manipulation;
    transition: background-color 0.22s var(--ease-out-expo),
                color 0.22s var(--ease-out-expo),
                transform 0.3s var(--ease-out-expo),
                box-shadow 0.3s var(--ease-out-expo),
                border-color 0.22s var(--ease-out-expo);
}

body {
    margin: 0;
    padding-top: env(safe-area-inset-top);
    background: var(--bg-dark-1);
    color: var(--text-primary);
    min-height: 100dvh;
    font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
    font-size: 1rem;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--body-bg);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

html.stream,
body.stream {
    overscroll-behavior: none !important;
}

.root:not(input) {
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
}

img {
    max-width: 100%;
    -webkit-user-drag: none;
}

h1, h2, h3, p {
    margin: 0;
}

h2 {
    font-size: 1.12rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.4rem;
    font-weight: 550;
}

button,
input,
select,
textarea {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

/* Buttons */
.file-button,
button {
    cursor: pointer;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    background-color: var(--bg-dark-2);
    border-radius: 5px;
    padding: 12px 19px;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.file-button:hover:not(:disabled),
button:hover:not(:disabled) {
    background-color: #ffffff15;
    border-color: #ffffff30;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 5px;
}

button:disabled {
    opacity: 0.5;
    cursor: wait;
    background-color: var(--bg-dark-2);
    border-color: var(--border-color);
}

.button-fit-content {
    height: fit-content;
}

/* Checkboxes */
input[type="checkbox"] {
    appearance: none;
    vertical-align: middle;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    display: inline-block;
    background: #0d0d0d;
}

input[type="checkbox"]:hover {
    border-color: #ffffff50;
}

input[type="checkbox"]::after {
    content: "✓";
    color: #151515;
    font-size: 14px;
    font-weight: bold;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.18s var(--ease-out-expo), opacity 0.18s var(--ease-out-expo);
}

input[type="checkbox"]:checked {
    background: #f3f3f3;
    border-color: #f3f3f3;
}

input[type="checkbox"]:checked::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Range Input */
input[type="range"] {
    accent-color: var(--text-primary);
    width: 200px;
    height: 24px;
    margin: 8px 0;
    cursor: grab;
}

input[type="range"]:active {
    cursor: grabbing;
}

/* Form Controls & Inputs */
.textlike,
textarea,
select,
.select-polyfill-display,
input[type=text],
input[type=password],
input[type=number] {
    display: block;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    background: #0d0d0d;
    border: 1px solid #ffffff30;
    color: var(--text-primary);
    border-radius: 5px;
    padding: 12px 13px;
    font-size: 1rem;
}

.textlike:hover:enabled,
textarea:hover:enabled,
select:hover:enabled,
.select-polyfill-display:hover,
input[type=text]:hover:enabled,
input[type=password]:hover:enabled,
input[type="number"]:hover:enabled {
    border-color: #ffffff60;
    background: #0d0d0d;
}

.textlike:focus,
textarea:focus,
select:focus,
input[type=text]:focus,
input[type=password]:focus,
input[type=number]:focus {
    border-color: var(--text-secondary);
    outline: none;
}

textarea:disabled,
select:disabled,
input[type=text]:disabled,
input[type=password]:disabled,
input[type=number]:disabled,
input[type=range]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select option {
    background-color: var(--bg-dark-2);
    color: var(--text-primary);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.list-like {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

/* Modal Overlay & Card */
.modal-background {
    display: block;
    position: fixed;
    z-index: 5000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    visibility: visible;
    opacity: 1;
    transition: opacity 0.26s var(--ease-out-expo), visibility 0.26s var(--ease-out-expo);
}

.modal-content {
    position: relative;
    z-index: 5001;
    background: var(--bg-dark-2);
    border: 1px solid #ffffff2b;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    width: min(460px, calc(100% - 32px));
    margin: 10% auto;
    max-height: calc(100dvh - 32px);
    overflow: auto;
    animation: surface-in 0.26s var(--ease-out-expo);
}

@keyframes surface-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal-disabled {
    visibility: hidden;
    background-color: rgba(0, 0, 0, 0);
    opacity: 0;
    pointer-events: none;
}

/* Context Menu */
.context-menu-background {
    display: block;
    position: fixed;
    z-index: 5002;
    border-radius: 8px;
    background: var(--bg-dark-2);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 55px rgba(0, 0, 0, 0.6);
    scale: 1;
    opacity: 1;
    transition: opacity 0.15s var(--ease-out-expo), scale 0.15s var(--ease-out-expo);
}

.context-menu-element {
    margin: 0;
    padding: 12px 16px;
    min-width: 140px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.context-menu-element:hover {
    background: #ffffff15;
}

.context-menu-element-red {
    color: #efb0b0;
}

.context-menu-element-red:hover {
    background: #672d2d;
    color: #ffffff;
}

.context-menu-disabled {
    visibility: hidden;
    opacity: 0;
    scale: 0.95;
    pointer-events: none;
}

/* Host List & Elements */
.host-list {
    list-style-type: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    padding: 0;
    margin: 0;
}

.host-element {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    padding: 22px;
    background: linear-gradient(130deg, #272727d9, #171717eb);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 166px;
}

.host-element:hover {
    transform: translateY(-4px) scale(1.012);
    box-shadow: 0 0 0 3px #0d0d0d, 0 0 0 5px #f5f5f5, 0 20px 40px rgba(0, 0, 0, 0.3);
    border-color: #ffffff50;
    z-index: 1;
}

.host-image {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: cover;
    border-radius: 5px;
}

.host-name {
    margin-top: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

.host-status-indicator {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.host-status-indicator.online {
    background-color: var(--status-online);
}

.host-status-indicator.offline {
    background-color: var(--status-offline);
}

.host-status-indicator.connecting {
    background-color: var(--status-connecting);
}

/* Toast Notifications */
.toast-container,
.notification-list {
    position: fixed;
    right: max(24px, env(safe-area-inset-right));
    bottom: max(28px, env(safe-area-inset-bottom));
    width: min(400px, calc(100vw - 32px));
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast,
.notification-element {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: #eee;
    color: #171717;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-size: 0.875rem;
    line-height: 1.5;
    pointer-events: auto;
    animation: notification-in 0.45s var(--ease-out-expo);
}

@keyframes notification-in {
    from {
        opacity: 0;
        transform: translateX(55px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.toast.error,
.notification-element {
    background: #292929;
    color: #f3c9c9;
    border: 1px solid #f0838345;
}

/* Video Player Canvas */
.video-stream {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    outline: none;
}

canvas.video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-stats {
    position: relative;
    z-index: 1;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}