html,body{
    height:100%;
    margin:0;
    background:#000;
    font:16px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Noto Sans",sans-serif
}
.stage{
    position:fixed;
    inset:0;
    overflow:hidden;
    background:#000
}
video#preview{
    position:absolute;
    inset:0;
    width:100vw;
    height:100vh;
    object-fit:cover;
    background:#000
}
#overlay{
    position:absolute;
    inset:0;
    pointer-events:none
}
.topbar{
    position:fixed; 
    left:0; 
    right:0; 
    top:0; 
    z-index:7;
    padding:calc(10px + env(safe-area-inset-top)) 10px 10px 10px;
    display:flex; 
    align-items:center; 
    gap:10px; 
    justify-content:flex-start;
    background:linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,.25), rgba(0,0,0,0));
}
select#cameras{
    color:#fff; 
    background:rgba(0,0,0,.45);
    border:1px solid rgba(255,255,255,.25); 
    border-radius:10px; 
    padding:8px 10px;
    max-width:70vw;
}
#torch{
    position:fixed;
    right:10px;
    top:calc(10px + env(safe-area-inset-top));
    z-index:8; 
    width:50px; 
    height:50px;
    display:grid; 
    place-items:center; 
    border-radius:10px;
    cursor:pointer;
    background:rgba(0,0,0,.45); 
    border:1px solid rgba(255,255,255,.25);
}
#torch[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.4);
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}
#torch svg{
    width:32px;
    height:32px
}
.qrs-miras{
    position:absolute; 
    z-index:4; 
    left:50%; 
    top:50%; 
    transform:translate(-50%,-50%);
    pointer-events:none;
}
.qrs-miras img{
    display:block;
    width:clamp(220px,82vw,720px); 
    height:auto; 
    opacity:.9
}
@media (min-width: 768px)
{ 
    .qrs-miras img{ 
        width:min(55vh,55vw); 
    } 
}
#content-result{
    position: fixed;
    inset: 0px;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    color: rgb(255, 255, 255);
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
   overflow-x: hidden;
}
#content-result-children{
    text-align: center;
    width: 100%;
    height: auto;
    padding: 3% 0;
}
#count{
    position:fixed; 
    left:0; 
    right:0; 
    bottom:calc(8px + env(safe-area-inset-bottom));
    display:flex; 
    justify-content:center; 
    z-index:7;
    font-weight:600; 
    color:#fff;
    display: none;
}
#count .pill{
    background:rgba(0,0,0,.45);
    border:1px solid rgba(255,255,255,.18);
    padding:6px 10px; 
    border-radius:999px; 
    min-width:44px;
    text-align:center;
}
.result-table {
    width: 100%;
    max-width: min(90vw, 600px);
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    margin: 0 auto 16px;
    font-size: clamp(12px, 3.5vw, 14px);
}
.result-table th, .result-table td {
    padding: clamp(6px, 2vw, 8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: left;
    word-break: break-word;
    min-width: 100px;
}
.result-table th {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}
.result-image {
    width: 150px;
    max-height: 50vh;
    object-fit: contain;
    margin-bottom: 16px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}
.result-image.loaded { 
    opacity: 1; 
}
.image-container { 
    position: relative; 
    display: inline-block; 
}
.image-loading {
    position: absolute; 
    bottom: 0; 
    left: 0; 
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex; 
    align-items: center; 
    justify-content: center;
    padding: 8px; 
    color: #fff; 
    font-size: clamp(10px, 2.5vw, 12px); 
    z-index: 1;
}
.image-loading .spinner {
    width: 20px; 
    height: 20px; 
    border: 2px solid #fff;
    border-top-color: transparent; 
    border-radius: 50%;
    animation: spin 1s linear infinite; 
    margin-right: 8px;
}
.loading-overlay {
    position: fixed; 
    inset: 0; 
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: grid; 
    place-items: center; 
    color: #fff; 
    font-size: 1.2em;
}
.spinner {
    width: 40px; 
    height: 40px; 
    border: 4px solid #fff;
    border-top-color: transparent; 
    border-radius: 50%;
    animation: spin 1s linear infinite; 
    margin-bottom: 16px;
}
@keyframes spin { 
    to{ 
        transform: rotate(360deg); 
    } 
}
