:root {
    color-scheme: dark;
    --bg: #090d12;
    --panel: #111821;
    --panel2: #151f2b;
    --line: #263444;
    --text: #eaf2fb;
    --muted: #7e91a7;
    --accent: #2d91ff;
    --danger: #ff5364;
    --ok: #43d17a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
}

header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: #0c1219;
    position: sticky;
    top: 0;
    z-index: 5;
}

header > div {
    font-size: 22px;
    letter-spacing: 0.2px;
}

header strong {
    color: var(--accent);
}

.subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-left: 10px;
    font-weight: 400;
}

button {
    border: 1px solid var(--line);
    background: var(--panel2);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 9px;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.12);
}

button.primary {
    border-color: #297ee0;
    background: var(--accent);
    color: white;
    font-weight: 600;
}

main {
    padding: 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 14px;
    align-items: start;
}

.camera {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    min-width: 0;
}

.video-wrap {
    position: relative;
    background: #030506;
    aspect-ratio: 16 / 9;
    cursor: zoom-in;
}

/*
 * ВАЖНО:
 * iframe не должен перехватывать клики мыши.
 * Иначе двойной клик в полноэкранном режиме
 * не доходит до .video-wrap.
 */
.video-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    pointer-events: none;
}

.camera.fullscreen .video-wrap iframe {
    pointer-events: none;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 10px;
    pointer-events: none;
}

.badge {
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 999px;
    background: #122117;
    color: var(--ok);
    border: 1px solid #204e30;
}

.meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px;
}

.name {
    font-weight: 650;
}

.host {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

.tools {
    display: flex;
    gap: 7px;
}

.tools button {
    padding: 7px 9px;
    font-size: 12px;
}

.danger {
    color: #ff8490;
}

.disabled .video-wrap {
    opacity: 0.35;
}

.disabled .badge {
    color: #aaa;
    background: #222;
    border-color: #444;
}

.empty {
    display: grid;
    place-items: center;
    min-height: 60vh;
    color: var(--muted);
    font-size: 18px;
}

.hidden {
    display: none !important;
}

dialog {
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #0f161f;
    color: var(--text);
    width: min(680px, calc(100vw - 30px));
    padding: 0;
    box-shadow: 0 20px 80px #000b;
}

dialog::backdrop {
    background: #000a;
    backdrop-filter: blur(4px);
}

form {
    padding: 22px;
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.dialog-head h2 {
    margin: 0 0 4px;
}

.dialog-head p {
    margin: 0;
    color: var(--muted);
}

.icon {
    font-size: 24px;
    padding: 0;
    width: 38px;
    height: 38px;
}

.steps {
    display: flex;
    align-items: center;
    margin: 22px 0;
}

.steps span {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    font-size: 12px;
}

.steps span.active {
    background: var(--accent);
    border-color: var(--accent);
}

.steps i {
    height: 1px;
    background: var(--line);
    flex: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: #bdd0e3;
}

input,
select {
    width: 100%;
    background: #0a1017;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.toggle input {
    width: auto;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 18px;
}

.test-result {
    min-height: 18px;
    font-size: 12px;
    color: var(--muted);
}

/* FULLSCREEN */

.camera.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 50;
    border: 0;
    border-radius: 0;
    background: #000;
}

.camera.fullscreen .video-wrap {
    height: 100vh;
    aspect-ratio: auto;
    cursor: zoom-out;
}

.camera.fullscreen .meta {
    position: absolute;
    left: 16px;
    bottom: 16px;
    background: #0c1219e8;
    border: 1px solid var(--line);
    border-radius: 10px;
    z-index: 60;
}

.camera.fullscreen .overlay {
    z-index: 55;
}

.camera.fullscreen iframe {
    background: #000;
}

/* MOBILE */

@media (max-width: 700px) {
    header {
        padding: 0 12px;
    }

    .subtitle {
        display: none;
    }

    main {
        padding: 10px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}