/* ========== reset ========== */
body, div, p, ul, li, table, tbody, tr, td, textarea, form, input, h1, h2, h3, h4, h5,
dl, dt, dd, img, iframe, header, nav, section, article, footer, figure, figcaption, menu {
    margin: 0;
    padding: 0;
    list-style: none;
}
body { -webkit-text-size-adjust: none; font-size: 0.24rem; }
header, nav, section, article, footer, figure, figcaption { display: block; }
h1, h2, h3, h4, h5, h6 { font-weight: normal; font-size: 100%; }
ol, ul { margin: 0; padding: 0; }
fieldset { border: none; margin: 0; padding: 0; }
a, li, ul, [onclick] {
    -webkit-tap-highlight-color: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
table { border-collapse: collapse; border-spacing: 0; }
em, strong { font-weight: normal; font-style: normal; }
a { text-decoration: none; }
* { margin: 0; padding: 0; box-sizing: border-box; }

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #1f2937;
    /* 柔和的渐变背景，比纯白更有质感 */
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #eef7f6 100%);
}

/* ========== 页面主容器 ========== */
.wrap {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ========== 页面标题 ========== */
.page-title {
    font-size: 0.34rem;
    font-weight: 700;
    margin-bottom: 0.36rem;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.02rem;
}

/* ========== 上传卡片 ========== */
.upload-form {
    width: 6.40rem;
    max-width: 92vw;          /* 防止窄屏溢出：最宽不超过视口的 92% */
    height: auto;
    min-height: 3.00rem;
    padding: 0.40rem 0.30rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 0.20rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0.12rem 0.50rem rgba(31, 41, 55, 0.12) !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.row-box {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-start;
}

/* ========== 单个上传项 ========== */
.upload-form .upload-item {
    width: 1.20rem;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.upload-item .name {
    width: 100%;
    height: 0.30rem;
    line-height: 0.30rem;
    margin-bottom: 0.12rem;
    text-align: center;
    font-size: 0.20rem;
    font-weight: 500;
    color: #6b7280;
}

/* 上传框：虚线占位 + hover 高亮 */
.upload-item .upload-dom {
    width: 1.20rem;
    height: 1.20rem;
    box-sizing: border-box;
    border-radius: 0.14rem;
    background: linear-gradient(135deg, #f9fafb, #f1f5f9);
    border: 0.02rem dashed #cbd5e1;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    position: relative;
}

.upload-item .upload-dom:hover {
    border-color: #6366f1;
    box-shadow: 0 0.06rem 0.20rem rgba(99, 102, 241, 0.18);
    transform: translateY(-0.02rem);
}

.upload-item .upload-dom img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 裁剪完成后展示的图片层 */
.upload-item .up_img {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}
.upload-item .up_img .btn-text {
    position: absolute;
    bottom: -0.56rem;
    left: 50%;
    transform: translateX(-50%);
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

/* 添加图片按钮（点击区域覆盖整框） */
.upload-item .btn_add {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-item .btn-text {
    padding: 0.08rem 0.14rem;
    border-radius: 0.10rem;
    text-align: center;
    font-size: 0.18rem;
    font-weight: 500;
    color: #4f46e5;
    background-color: #eef2ff;
    position: absolute;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.upload-item .btn_add .file {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

/* 第三个上传项为宽幅（2.4 x 1.2） */
.upload-form .upload-item-2 {
    width: 2.40rem;
    height: auto;
}
.upload-form .upload-item-2 .upload-dom {
    width: 2.40rem;
    height: 1.20rem;
}

/* ========== 裁剪弹窗 ========== */
.pop { display: none; position: relative; }

/* 图片裁剪 - 触屏设备全屏遮罩 */
.pop_clip {
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: #0b1020;
    position: absolute;
    left: 0;
    top: 0;
    z-index: -99999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.pop_clip.show {
    z-index: 999;
    opacity: 1;
}

/* 弹窗内通用操作按钮 */
.pop_clip .btn {
    width: 0.50rem;
    height: 1.50rem;
    line-height: 0.50rem;
    text-align: center;
    border: 0;
    outline: none;
    color: #fff;
    background: #e2a54c;
    text-shadow: 0 0 .03rem #8b530e, 0 0 .03rem #8b530e, 0 0 .03rem #8b530e, 0 0 .03rem #8b530e;
    font-size: 0.28rem;
    z-index: 999;
}

/* 关闭按钮（右上角 X） */
.pop_clip .btn_back {
    position: absolute;
    right: 0.30rem;
    top: 0.30rem;
    width: 0.56rem;
    height: 0.56rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    z-index: 999;
    transition: background 0.2s ease;
}
.pop_clip .btn_back:hover { background: rgba(255, 255, 255, 0.24); }
.pop_clip .btn_back::before,
.pop_clip .btn_back::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.28rem;
    height: 0.03rem;
    background: #fff;
    border-radius: 0.02rem;
}
.pop_clip .btn_back::before { transform: translate(-50%, -50%) rotate(45deg); }
.pop_clip .btn_back::after { transform: translate(-50%, -50%) rotate(-45deg); }

.clipper_box {
    height: 90%;
    position: relative;
    overflow: hidden;
    z-index: 0;
}
.clipper_canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 0;
}

.clipper canvas { z-index: 9 !important; }

.clipper {
    width: 100%;
    height: 100%;
    /* PC 端提示可拖动：抓手光标 */
    cursor: grab;
}
.clipper:active {
    cursor: grabbing;
}

/* ========== 底部操作栏 ========== */
.foot-use {
    width: 90%;
    height: 0.70rem;
    position: absolute;
    left: 5%;
    bottom: 0.30rem;
    z-index: 999;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.uploader {
    position: absolute;
    width: 54%;
    height: 0.8rem;
    left: 23%;
    cursor: default;
    height: 100%;
    float: left;
}

.filename {
    position: absolute;
    outline: 0 none;
    line-height: 0.15rem;
    font-size: 0.15rem;
    color: #999;
    width: 100%;
    margin: 0;
    overflow: hidden;
    cursor: default;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 0;
    top: 0.92rem;
    text-align: center;
}

.uploader input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    border: 0;
    padding: 0;
    margin: 0;
    height: 0.8rem;
    width: 100%;
    cursor: pointer;
    border: solid 0.01rem #ddd;
    opacity: 0;
}

input[type=button]::-moz-focus-inner { padding: 0; border: 0 none; -moz-box-sizing: content-box; }
input[type=button]::-webkit-focus-inner { padding: 0; border: 0 none; -webkit-box-sizing: content-box; }
input[type=text]::-moz-focus-inner { padding: 0; border: 0 none; -moz-box-sizing: content-box; }
input[type=text]::-webkit-focus-inner { padding: 0; border: 0 none; -webkit-box-sizing: content-box; }

/* 底部主按钮（选择图片 / 裁剪） */
.foot-use .btn-text {
    min-width: 1.40rem;
    height: 0.62rem;
    line-height: 0.62rem;
    padding: 0 0.24rem;
    border-radius: 0.31rem;
    text-align: center;
    font-size: 0.22rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 0.06rem 0.18rem rgba(79, 70, 229, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}
.foot-use .btn-text:active {
    transform: translateY(0.02rem);
    box-shadow: 0 0.03rem 0.10rem rgba(79, 70, 229, 0.4);
}

.foot-use .btn-text .file {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ========== 缩放控制条 ========== */
.btn-scale {
    position: absolute;
    top: 0.20rem;
    left: 0.20rem;
    width: 2.80rem;
    height: 0.56rem;
    line-height: 0.56rem;
    border-radius: 0.12rem;
    text-align: left;
    font-size: 0.18rem;
    color: #1f2937;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0.04rem 0.16rem rgba(0, 0, 0, 0.25);
    padding: 0 0.16rem;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.10rem;
}
.btn-scale input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 1.80rem;
    height: 0.06rem;
    border-radius: 0.03rem;
    background: linear-gradient(90deg, #6366f1, #a5b4fc);
    outline: none;
}
.btn-scale input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 0.24rem;
    height: 0.24rem;
    border-radius: 50%;
    background: #fff;
    border: 0.03rem solid #4f46e5;
    box-shadow: 0 0.02rem 0.06rem rgba(0, 0, 0, 0.3);
    cursor: pointer;
}
.btn-scale .text {
    width: auto;
    height: 0.32rem;
    line-height: 0.30rem;
    font-size: 0.16rem;
    text-align: right;
    color: #4f46e5;
    font-weight: 600;
}
.btn-scale .text[value] {
    width: 0.56rem;
    margin-left: 0.06rem;
    padding: 0 0.04rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.06rem;
    background: #fff;
    text-align: center;
}

/* ========== 旋转按钮 ========== */
.btn-rotate {
    position: absolute;
    top: 0.20rem;
    right: 0.20rem;
    width: 1.10rem;
    height: 0.56rem;
    line-height: 0.56rem;
    border-radius: 0.12rem;
    text-align: center;
    font-size: 0.20rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}
.btn-rotate:active { background: rgba(255, 255, 255, 0.3); }

/* ========== 防溢出兜底 ========== */
/* 杜绝任何子元素把页面撑出横向滚动条 */
html, body { max-width: 100%; overflow-x: hidden; }
.wrap { max-width: 100vw; overflow-x: hidden; }
/* 弹窗内的裁剪舞台与操作区限制在视口内 */
.pop_clip { max-width: 100vw; }
.clipper_box { max-width: 100vw; }

/* ---------- 窄屏（手机）适配 ---------- */
@media screen and (max-width: 540px) {
    /* 顶部缩放条与旋转按钮上下错开，避免在窄屏挤到一起 */
    .btn-scale {
        width: auto;
        max-width: 60vw;
    }
    .btn-scale input[type=range] {
        width: 1.40rem;
    }
    .btn-rotate {
        width: 0.96rem;
    }
    /* 底部按钮收窄，保证一行放得下 */
    .foot-use .btn-text {
        min-width: 1.20rem;
        padding: 0 0.16rem;
        font-size: 0.20rem;
    }
}
