/* ==================== 图片转扫描件 ==================== */
.scan-card { padding: 20px; }

.scan-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 16px;
    align-items: start;
}

.scan-stage-wrap { min-width: 0; }
.scan-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    background: #eef0f3;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    touch-action: none;
}
.scan-stage img {
    display: block;
    max-width: 100%;
    max-height: 68vh;
    width: auto;
    height: auto;
}
.scan-stage canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}
.scan-tip {
    margin: 8px 0 0;
    font-size: .76rem;
    color: var(--text-dim);
    line-height: 1.6;
}

/* 四角识别状态条 */
.scan-stage-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.scan-detect-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: .22rem .6rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--accent);
    background: #fff1ec;
    border: 1px solid #ffd9cb;
    border-radius: 999px;
}
.scan-detect-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.scan-detect-badge.is-fallback {
    color: #8a6d3b;
    background: #fff8e5;
    border-color: #f0e0b8;
}
.scan-stage-tools { display: flex; gap: 6px; margin-left: auto; }
.scan-mini {
    padding: .24rem .62rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.scan-mini:hover { border-color: var(--accent); color: var(--accent); }
.scan-mini:disabled { color: var(--text-dim); border-color: var(--border); cursor: default; }

/* 预览 */
.scan-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 148px;
    margin-bottom: 12px;
    padding: 8px;
    background: #fff;
    background-image:
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%),
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%);
    background-size: 14px 14px;
    background-position: 0 0, 7px 7px;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    cursor: zoom-in;
    overflow: hidden;
}
.scan-preview img {
    display: block;
    max-width: 100%;
    max-height: 260px;
    background: #fff;
    box-shadow: 0 1px 6px rgba(15, 23, 42, .14);
    transition: opacity .15s ease;
}
.scan-preview img.is-loading { opacity: .45; }
.scan-preview-ph {
    font-size: .76rem;
    color: var(--text-dim);
    text-align: center;
    padding: 10px;
    line-height: 1.6;
}
.scan-preview-loading {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: .3rem .7rem;
    font-size: .74rem;
    color: #fff;
    background: rgba(23, 32, 48, .78);
    border-radius: 999px;
    pointer-events: none;
}

/* 预览大图 */
.scan-zoom {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(12, 18, 28, .82);
    cursor: zoom-out;
}
.scan-zoom img {
    max-width: 92vw;
    max-height: 90vh;
    background: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}

.scan-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfbfc;
    padding: 14px;
}
.scan-panel h4 {
    margin: 0 0 10px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
}
.scan-panel h4:not(:first-child) {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.scan-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.scan-filter {
    padding: .42rem .3rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.scan-filter:hover { border-color: var(--accent); color: var(--accent); }
.scan-filter.active {
    border-color: var(--accent);
    background: #fff1ec;
    color: var(--accent);
}
.scan-filter-hint {
    margin: 9px 0 12px;
    font-size: .74rem;
    line-height: 1.55;
    color: var(--text-dim);
    min-height: 34px;
}

/* 矩形比例矫正 */
.scan-aspect { display: flex; flex-direction: column; gap: 6px; }
.scan-aspect-label { font-size: .74rem; color: var(--text-dim); }
.scan-aspect select { width: 100%; font-size: .8rem; }
.scan-aspect-custom { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: .8rem; }
.scan-aspect-custom[hidden] { display: none !important; }
.scan-aspect-custom input { flex: 1 1 0; min-width: 0; font-size: .8rem; padding: .3rem .5rem; }
.scan-aspect-hint {
    margin: 2px 0 0;
    font-size: .72rem;
    line-height: 1.55;
    color: var(--text-dim);
}
.scan-ratio-meta {
    margin: -6px 0 10px;
    font-size: .72rem;
    line-height: 1.5;
    color: var(--text-dim);
}
.scan-ratio-meta[hidden] { display: none !important; }

.scan-actions { display: flex; flex-direction: column; gap: 8px; }

/* 结果 */
.scan-result-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.scan-result-head h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.scan-result-img {
    text-align: center;
    background: #eef0f3;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}
.scan-result-img img {
    max-width: 100%;
    max-height: 70vh;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
}
.scan-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

@media (max-width: 860px) {
    .scan-grid { grid-template-columns: minmax(0, 1fr); }
    .scan-stage { display: block; }
    .scan-stage img { max-height: 52vh; margin: 0 auto; }
    .scan-filters { grid-template-columns: repeat(3, 1fr); }
    .scan-preview { min-height: 120px; }
    .scan-preview img { max-height: 200px; }
}
