/* --- 1. 全局配置 --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background-color: #000; font-family: -apple-system, sans-serif; height: 100vh; overflow: hidden; color: #fff; }

/* --- 2. 菜单层 --- */
.menu-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 200; background: #f5f5f5; overflow-y: auto; color: #333; }
.header { padding: 15px; background: white; text-align: center; font-weight: bold; border-bottom: 1px solid #ddd; position: sticky; top: 0; }
.task-list { padding: 15px; padding-bottom: 200px; }
.task-item { 
    background: white; padding: 15px; margin-bottom: 12px; border-radius: 12px; 
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); cursor: pointer;
}
.task-item.done { border: 1px solid #00c853; background: #e8f5e9; }
.task-status { width: 44px; height: 44px; background: #eee; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 20px; }
.preview-img { width: 100%; height: 100%; object-fit: cover; }

/* --- 3. 拍摄层 --- */
.camera-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 100; display: none; flex-direction: column; }
.viewport { flex: 1; position: relative; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
canvas { position: absolute; max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; z-index: 10; opacity: 0.6; }
.camera-front video, .camera-front canvas { transform: scaleX(-1); }

/* --- 4. HUD UI（全屏模式）--- */
.hud-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; }

.top-bar {
    position: absolute; top: 0; left: 0; right: 0;
    padding: 20px 20px; display: flex; justify-content: space-between;
    pointer-events: auto; z-index: 30;
    background: transparent;
}
.btn-glass {
    padding: 10px 18px;
    background: rgba(0,0,0,0.5);
    color: white;
    border-radius: 25px;
    font-size: 14px;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.scan-wrapper {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
}

.scan-box {
    position: relative; transition: all 0.3s;
    border: 3px solid rgba(255,255,255,0.5);
}
.mode-palm .scan-box {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}
.mode-thumb .scan-box {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

.scan-box.qualified { border-color: #00ff00; }
.scan-box.warning { border-color: #ffcc00; }
.scan-box.error { border-color: #ff3333; }

/* 底部（悬浮模式）*/
.bottom-bar {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 30;
    padding: 15px 20px 30px; pointer-events: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}

.status-pill { 
    color: #fff; font-size: 16px; font-weight: 600; margin-bottom: 25px; 
    background: rgba(255,255,255,0.1); padding: 8px 24px; border-radius: 30px;
    backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.1); transition: all 0.3s;
}
.status-pill.green { color: #00ff00; background: rgba(0,50,0,0.8); border-color: rgba(0,255,0,0.3); }
.status-pill.yellow { color: #ffcc00; background: rgba(50,50,0,0.8); border-color: rgba(255,200,0,0.3); }
.status-pill.red { color: #ff3333; background: rgba(50,0,0,0.8); border-color: rgba(255,0,0,0.3); }

.button-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shutter-btn { 
    width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.8); 
    background: rgba(255,255,255,0.1); position: relative; transition: all 0.2s;
}
.shutter-inner { 
    width: 60px; height: 60px; background: #fff; border-radius: 50%; 
    position: absolute; top: 3px; left: 3px; opacity: 0.8; transition: all 0.2s; 
}
.shutter-btn.active { transform: scale(1.1); border-color: #00ff00; }
.shutter-btn.active .shutter-inner { background: #00ff00; opacity: 1; }

.redetect-btn { 
    position: absolute;
    left: calc(50% + 36px + 80px);  /* 快门按钮中心(50%) + 快门半径(36px) + 更大间距(80px) */
    width: 60px; 
    height: 60px; 
    border-radius: 50%; 
    background: rgba(0,255,0,0.9); 
    color: white; 
    border: 3px solid rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; 
    pointer-events: none; 
    transition: all 0.3s;
    transform: translateX(-50%) scale(0.8);
}
.redetect-btn.show { 
    opacity: 1; 
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}
.redetect-btn:active {
    transform: translateX(-50%) scale(0.9);
    background: rgba(0,255,0,1);
}
.redetect-btn svg {
    width: 32px;
    height: 32px;
}

.force-link { margin-top: 15px; color: #888; font-size: 12px; text-decoration: underline; opacity: 0; pointer-events: none; transition: opacity 0.5s; }
.force-link.show { opacity: 1; pointer-events: auto; }

/* 调试信息显示 */
.debug-info {
    position: absolute; top: 80px; left: 10px;
    width: 180px; min-height: 80px; max-height: 60vh;
    color: #0f0; font-size: 9px; font-family: 'Courier New', monospace;
    text-align: left;
    background: rgba(0,0,0,0.15);
    padding: 10px; z-index: 30; pointer-events: auto;
    text-shadow: 0 0 3px rgba(0,255,0,0.8), 0 0 6px rgba(0,0,0,0.8);
    border: 1px solid rgba(0,255,0,0.2);
    border-radius: 8px;
    backdrop-filter: blur(15px);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15),
                inset 0 0 15px rgba(0,255,0,0.01);
    cursor: pointer;
    transition: all 0.3s ease;
}

.debug-info:hover {
    background: rgba(0,0,0,0.3);
    border-color: rgba(0,255,0,0.35);
    box-shadow: 0 3px 12px rgba(0,0,0,0.25),
                inset 0 0 20px rgba(0,255,0,0.03);
}

/* 调试信息滚动条样式 */
.debug-info::-webkit-scrollbar {
    width: 4px;
}

.debug-info::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 2px;
}

.debug-info::-webkit-scrollbar-thumb {
    background: rgba(0,255,0,0.3);
    border-radius: 2px;
}

.debug-info::-webkit-scrollbar-thumb:hover {
    background: rgba(0,255,0,0.5);
}

/* 图片预览区域 */
.debug-preview {
    position: absolute; top: 90px; right: 10px;
    width: 120px; background: rgba(0,0,0,0.8);
    border-radius: 8px; padding: 8px;
    z-index: 30; pointer-events: auto;
    border: 1px solid rgba(255,255,255,0.2);
}

.preview-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; font-size: 10px; color: #0f0;
}

.btn-toggle {
    background: rgba(255,255,255,0.2); color: #fff;
    border: none; border-radius: 4px; padding: 4px 8px;
    font-size: 10px; cursor: pointer;
}

.btn-toggle.paused {
    background: rgba(0,255,0,0.3); color: #0f0;
}

#previewImage {
    width: 100%; border-radius: 4px; cursor: pointer;
    display: block; background: #333;
    min-height: 80px; object-fit: contain;
    border: 1px solid rgba(255,255,255,0.1);
}

/* 图片放大查看 */
.image-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 1000;
    display: none; align-items: center; justify-content: center;
    pointer-events: auto;
}

.image-modal.show {
    display: flex;
}

.image-modal img {
    max-width: 90%; max-height: 90%; object-fit: contain;
}

.image-modal-close {
    position: absolute; top: 20px; right: 20px;
    color: #fff; font-size: 32px; cursor: pointer;
    background: rgba(0,0,0,0.5); width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center;
    justify-content: center; border: 1px solid rgba(255,255,255,0.3);
}
