:root {
    color-scheme: dark;
    --bg-1: #07111d;
    --bg-2: #0d1c2d;
    --panel: rgba(8, 16, 27, 0.78);
    --panel-strong: rgba(12, 24, 39, 0.92);
    --line: rgba(154, 192, 224, 0.18);
    --text: #edf4ff;
    --muted: #8fa4be;
    --accent: #62d2ff;
    --accent-strong: #00a8e8;
    --danger: #ff6b6b;
    --success: #57d39b;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background:
        radial-gradient(circle at top left, rgba(0, 168, 232, 0.24), transparent 30%),
        radial-gradient(circle at 85% 10%, rgba(98, 210, 255, 0.18), transparent 24%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, #050b12);
    color: var(--text);
    font-family: "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
}

body {
    height: 100dvh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.app-shell {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #c9f4ff);
    color: #04131f;
    font-weight: 800;
    font-size: 1.25rem;
}

.brand-block h1 {
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.brand-block p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.icon-button {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-button:hover,
.icon-button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(98, 210, 255, 0.5);
    background: rgba(98, 210, 255, 0.12);
}

.icon-button.active {
    border-color: rgba(87, 211, 155, 0.55);
    background: rgba(87, 211, 155, 0.14);
}

.icon-button.danger {
    border-color: rgba(255, 107, 107, 0.3);
}

.main-container {
    min-height: 0;
    overflow: hidden;
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 24px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 30px;
    background: var(--panel);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow);
    min-height: 0;
    height: 100%;
    align-items: center;
}

.eyebrow,
.card-label,
.metric-label {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--muted);
}

.hero-copy h2 {
    margin: 14px 0 14px;
    font-size: clamp(2.1rem, 5vw, 4rem);
    line-height: 1.02;
    max-width: 12ch;
}

.hero-copy p {
    margin: 0;
    max-width: 56ch;
    color: #c9d7ea;
    font-size: 1rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.button-primary,
.button-secondary {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    font-size: 0.96rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #04131f;
    font-weight: 700;
    box-shadow: 0 12px 32px rgba(0, 168, 232, 0.3);
}

.button-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: var(--line);
}

.button-danger {
    background: linear-gradient(135deg, #ff9b9b, var(--danger));
    color: #260808;
}

.button-full {
    width: 100%;
}

.button-primary:hover,
.button-secondary:hover,
.button-primary:focus-visible,
.button-secondary:focus-visible {
    transform: translateY(-1px);
}

.hero-panel {
    display: grid;
    gap: 16px;
}

.metric-tile,
.sidebar-card,
.modal-content {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    box-shadow: var(--shadow);
}

.metric-tile {
    border-radius: 22px;
    padding: 18px 18px 20px;
}

.metric-tile strong {
    display: block;
    margin-top: 8px;
    font-size: 1.35rem;
}

.session-view {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    height: 100%;
    min-height: 0;
}

.session-sidebar {
    display: grid;
    align-content: start;
    gap: 16px;
    min-height: 0;
    overflow: auto;
}

.sidebar-card {
    border-radius: 22px;
    padding: 18px;
}

.sidebar-card strong {
    display: block;
    margin-top: 10px;
    font-size: 1.1rem;
}

.sidebar-card p {
    color: var(--muted);
    line-height: 1.5;
}

.sidebar-card.compact p {
    margin-bottom: 16px;
}

.option-row,
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
    color: #d9e7f8;
}

.toggle-row input {
    width: 18px;
    height: 18px;
}

select,
input[type="url"] {
    width: 100%;
    min-height: 42px;
    margin-top: 8px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(154, 192, 224, 0.24);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

select:disabled,
input:disabled,
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.option-row select {
    margin-top: 0;
    max-width: 150px;
}

.viewport-wrap {
    position: relative;
    height: 100%;
    min-height: 0;
    display: grid;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    background: rgba(3, 8, 14, 0.92);
    box-shadow: var(--shadow);
}

.stats-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 15;
    display: flex;
    gap: 10px;
}

.stats-overlay span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(4, 11, 20, 0.72);
    border: 1px solid rgba(154, 192, 224, 0.18);
    font-size: 0.82rem;
}

.vnc-container,
#vnc-canvas {
    width: 100%;
    height: 100%;
    min-height: 0;
}

#vnc-canvas {
    position: relative;
    overflow: hidden;
    background: #02060c;
}

#local-video-preview {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 12;
    width: min(23vw, 260px);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
    display: none;
}

#local-video-preview.visible {
    display: block;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #718096;
    box-shadow: 0 0 0 6px rgba(113, 128, 150, 0.18);
}

.status-dot[data-state="Active"] {
    background: var(--success);
    box-shadow: 0 0 0 6px rgba(87, 211, 155, 0.18);
}

.status-dot[data-state="Starting"] {
    background: #ffd166;
    box-shadow: 0 0 0 6px rgba(255, 209, 102, 0.18);
}

.status-dot[data-state="Disconnected"] {
    background: var(--danger);
    box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.18);
}

.bridge-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(3, 7, 12, 0.62);
    backdrop-filter: blur(12px);
    z-index: 1000;
    padding: 18px;
}

.modal-content {
    position: relative;
    width: min(100%, 560px);
    border-radius: 24px;
    padding: 22px;
}

.modal-content.wide {
    width: min(100%, 880px);
}

.modal-content h3,
.modal-content h4 {
    margin-top: 0;
}

.close-button {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
}

.info {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.5;
}

.form-group {
    margin-top: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.status-message {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.status-message.success {
    background: rgba(87, 211, 155, 0.12);
    color: #c7ffe3;
}

.status-message.error {
    background: rgba(255, 107, 107, 0.12);
    color: #ffd7d7;
}

.inline-status {
    margin: 6px 0 14px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(154, 192, 224, 0.18);
    font-size: 0.88rem;
    line-height: 1.45;
}

.inline-status.neutral {
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
}

.inline-status.success {
    background: rgba(87, 211, 155, 0.12);
    color: #c7ffe3;
}

.inline-status.error {
    background: rgba(255, 107, 107, 0.12);
    color: #ffd7d7;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.media-column {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(154, 192, 224, 0.18);
    background: rgba(255, 255, 255, 0.03);
}

#file-list-container {
    margin-top: 18px;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(154, 192, 224, 0.18);
    background: rgba(255, 255, 255, 0.03);
}

#file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#file-list li + li {
    margin-top: 10px;
}

#file-list a {
    color: #9ddfff;
    text-decoration: none;
}

#remote-audio {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 1080px) {
    .hero-card,
    .session-view,
    .media-grid {
        grid-template-columns: 1fr;
    }

    .session-view {
        height: 100%;
    }

    .viewport-wrap {
        min-height: 0;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 12px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .hero-card,
    .sidebar-card,
    .modal-content {
        border-radius: 20px;
    }

    .hero-copy h2 {
        font-size: 2.2rem;
    }

    .stats-overlay {
        left: 12px;
        right: 12px;
        top: 12px;
        justify-content: space-between;
    }

    #local-video-preview {
        width: min(42vw, 180px);
    }
}
