* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: #000;
    user-select: none;
    -webkit-user-select: none;
}

.hidden {
    display: none !important;
}

/* ---------- 摄像头预览 ---------- */
#video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    background: #000;
}

/* ---------- 扫码UI（扫描框+扫描线） ---------- */
.scanner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70vw;
    height: 70vw;
    max-width: 280px;
    max-height: 280px;
    transform: translate(-50%, -58%);
}

.scan-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    clip-path: inset(0);
}

.scan-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 4px solid #00e5a0;
}

.corner-tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 6px;
}

.corner-tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 6px;
}

.corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 6px;
}

.corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 6px;
}

.scan-line {
    position: absolute;
    left: 4%;
    right: 4%;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00e5a0, transparent);
    box-shadow: 0 0 12px 2px rgba(0, 229, 160, 0.6);
    animation: scanMove 2.2s ease-in-out infinite;
}

@keyframes scanMove {
    0% {
        top: 0;
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

.scan-tip {
    position: absolute;
    bottom: 16%;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ---------- 顶部工具栏 ---------- */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}

.toolbar-title {
    color: #fff;
    font-size: 17px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    font-size: 18px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.2s;
}

.tool-btn:active {
    opacity: 0.6;
}

.tool-btn.active {
    background: rgba(0, 229, 160, 0.6);
}

/* ---------- 权限遮罩 ---------- */
.permission-mask {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.permission-card {
    width: 100%;
    max-width: 320px;
    background: #1c1c1e;
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.permission-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.permission-title {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
}

.permission-desc {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.permission-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- 通用按钮 ---------- */
.btn {
    border: none;
    border-radius: 10px;
    font-size: 15px;
    padding: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.7;
}

.btn-primary {
    background: #00e5a0;
    color: #003322;
    font-weight: 600;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.btn-light {
    background: #f2f2f7;
    color: #111;
}

.btn-blue {
    background: #f2f2f7;
    color: #007aff;
}

.btn-block {
    width: 100%;
}

/* ---------- 加载动画 ---------- */
.loading-mask {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #00e5a0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* ---------- 结果面板 ---------- */
.result-panel {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.25s ease;
}

.result-content {
    width: 100%;
    background: #fff;
    border-radius: 20px 20px 0 0;
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

.result-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #e5e5ea;
    margin: 10px auto 0;
}

.result-body {
    padding: 18px 20px 0;
}

.result-icon {
    width: 52px;
    height: 52px;
    margin: 4px auto 10px;
    border-radius: 50%;
    background: #00e5a0;
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-title {
    text-align: center;
    font-size: 18px;
    color: #111;
    margin-bottom: 16px;
}

.result-group {
    margin-bottom: 12px;
}

.result-label {
    display: block;
    font-size: 12px;
    color: #8e8e93;
    margin-bottom: 6px;
}

.result-text {
    font-size: 15px;
    color: #111;
    line-height: 1.5;
    word-break: break-all;
    background: #f2f2f7;
    border-radius: 8px;
    padding: 12px;
    max-height: 120px;
    overflow-y: auto;
}

.result-divider {
    height: 1px;
    background: #f2f2f7;
    margin: 14px 0;
}

.result-type-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.result-type {
    font-size: 13px;
    color: #007aff;
    background: rgba(0, 122, 255, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- 动画 ---------- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}