.camera-test-component {
    padding: 1%;
    background: var(--container-bg, #f8f9fa);
    border-radius: 8px;
    border: 1px solid var(--container-border, #dee2e6);
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-size: clamp(0.6rem, 1.5vw, 0.9rem);
    overflow: hidden;
    container-type: inline-size;
    position: relative;
}
.camera-enable-all {
    align-self: flex-start;
    flex-shrink: 0;
    margin: 0 0 8px 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #4a5568;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.camera-enable-all input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.camera-switch {
    position: relative;
    width: 34px;
    height: 18px;
    border-radius: 999px;
    background: #b8c2cc;
    transition: background 0.2s;
    flex-shrink: 0;
}
.camera-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.camera-enable-all input:checked + .camera-switch {
    background: #3498db;
}
.camera-enable-all input:checked + .camera-switch::after {
    transform: translateX(16px);
}
.camera-enable-all input:focus-visible + .camera-switch {
    outline: 2px solid #2c3e50;
    outline-offset: 2px;
}
.camera-controls {
    margin-bottom: 1%;
    display: flex;
    gap: 1%;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    justify-content: center;
}
.camera-controls h3 {
    margin: 0 0 0.35rem 0;
    font-size: 1.2em;
    font-weight: 600;
    line-height: 1.2;
    color: #2c3e50;
    text-align: center;
}
.camera-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
}
.camera-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    width: 100%;
}
/* One camera: centered, full width up to the max-width the layout script sets
   from the panel height. */
.camera-grid.camera-grid-single .camera-item {
    width: 100%;
    align-self: center;
    justify-self: center;
}
.camera-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.camera-item.camera-item-collapsed {
    aspect-ratio: auto;
    justify-content: flex-start;
    background: linear-gradient(180deg, #ffffff 0%, #f5f8fb 100%);
    border: 1px solid rgba(52, 73, 94, 0.16);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
}
.camera-item.camera-item-collapsed:hover {
    border-color: rgba(52, 152, 219, 0.45);
}
.camera-item.camera-item-collapsed .camera-video,
.camera-item.camera-item-collapsed .camera-fullscreen-btn {
    display: none;
}
.camera-item.camera-item-collapsed .camera-label {
    position: static;
    flex: 1;
    min-width: 0;
    background: none;
    color: #1f2d3d;
    font-size: 0.95em;
    font-weight: 600;
    padding: 0;
    text-align: left;
}
.camera-item.camera-item-collapsed .camera-label::after {
    content: ' \2013 click to enable';
    color: #6b7280;
    font-weight: 400;
}
.camera-grid.camera-grid-list .camera-item:not(.camera-item-collapsed) .camera-label {
    cursor: pointer;
}
.camera-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 4px;
    font-size: 0.7em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.camera-error {
    color: #dc3545;
    font-size: 0.8em;
    text-align: center;
    padding: 10px;
    grid-column: 1 / -1;
}
.camera-permission {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    grid-column: 1 / -1;
    padding: 10px;
}
.camera-permission .camera-error {
    padding: 0;
}
.camera-permission-btn {
    min-height: 38px;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: #3498db;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}
.camera-permission-btn:hover {
    opacity: 0.8;
}
.camera-loading {
    color: #6c757d;
    font-size: 0.8em;
    text-align: center;
    padding: 10px;
    grid-column: 1 / -1;
}
.camera-fullscreen-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.camera-fullscreen-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.9);
}
.camera-fullscreen-btn svg {
    width: 16px;
    height: 16px;
}

@container (min-width: 500px) {
    .camera-grid {
        display: grid;
        grid-template-columns: repeat(var(--camera-grid-columns, 2), minmax(0, 1fr));
        align-content: start;
        align-items: stretch;
    }

    .camera-item {
        width: auto;
    }

    .camera-grid.camera-grid-has-orphan .camera-item.camera-item-last {
        grid-column: 1 / -1;
        justify-self: center;
        width: min(100%, 520px);
    }
}

@media (pointer: coarse) and (hover: none) and (max-width: 1024px) {
    .camera-test-component .camera-grid {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
    }

    .camera-test-component .camera-item,
    .camera-test-component .camera-grid.camera-grid-has-orphan .camera-item.camera-item-last {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        grid-column: auto;
        justify-self: stretch;
    }

    .camera-test-component .camera-label {
        left: 0;
        right: 0;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
}