/**
 * lsggm_qrdl · 扫码转存下载弹窗样式
 * v1.0.1
 *
 * Apple 风格：毛玻璃遮罩、大圆角卡片、SF 系字体栈、#007aff 主色、
 * iOS 弹性曲线 cubic-bezier(0.32, 0.72, 0, 1)，支持暗黑模式。
 *
 * v1.0.1 改动：
 *   1) 把 z-index 显式写死（遮罩 0 / 卡片 1 / 关闭按钮 3）。
 *      v1.0.0 全靠「同层 positioned 元素按文档序绘制」这条隐式规则，
 *      一旦主题给卡片加了 transform/opacity 之外的属性或改了 DOM 顺序，
 *      关闭按钮就会掉到遮罩下面（用户观感：点不到 ×，关不掉）。
 *   2) 卡片改成 flex 列 + 内容区独立滚动，顶部 × 常驻不随内容滚走。
 *   3) 新增底部常驻「关闭」按钮（内容超高时的第二条关闭路径）。
 */

.qrdl-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC",
        "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

.qrdl-modal--open {
    display: flex;
}

/* ---- 遮罩：毛玻璃（z-index:0，永远在卡片之下） ---- */
.qrdl-modal__mask {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.42);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    opacity: 0;
    transition: opacity 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.qrdl-modal--open .qrdl-modal__mask {
    opacity: 1;
}

/* ---- 卡片：flex 列，顶部 × 常驻，内容区自己滚 ---- */
.qrdl-modal__card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow: hidden;
    background: #ffffff;
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32),
        0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    transition: opacity 0.28s cubic-bezier(0.32, 0.72, 0, 1),
        transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

.qrdl-modal--open .qrdl-modal__card {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* 内容滚动区（× 不在里面，所以永远滚不走） */
.qrdl-modal__scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 30px 28px 26px;
}

/* ---- 关闭按钮：z-index 高于遮罩与内容区 ---- */
.qrdl-modal__close {
    position: absolute;
    z-index: 3;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(118, 118, 128, 0.12);
    color: #3c3c43;
    font-family: inherit;
    font-size: 19px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.18s ease, transform 0.1s ease-out;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    will-change: transform;
}

.qrdl-modal__close:hover {
    background: rgba(118, 118, 128, 0.22);
}

.qrdl-modal__close:active {
    transform: scale(0.94);
}

.qrdl-modal__close:focus-visible {
    outline: 2px solid #007aff;
    outline-offset: 2px;
}

/* ---- 平台徽章 ---- */
.qrdl-modal__brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 5px 14px 5px 6px;
    border-radius: 999px;
    background: rgba(118, 118, 128, 0.08);
}

.qrdl-modal__brand-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #007aff;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.qrdl-modal__brand-name {
    font-size: 13px;
    font-weight: 600;
    color: #3c3c43;
    letter-spacing: 0.02em;
}

/* ---- 标题 / 提示 ---- */
.qrdl-modal__title {
    margin: 0 0 18px;
    font-size: 20px;
    font-weight: 700;
    color: #1d1d1f;
    letter-spacing: -0.01em;
}

.qrdl-modal__hint {
    margin: 16px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: #86868b;
}

.qrdl-modal__foot {
    margin: 6px 0 0;
    font-size: 11px;
    color: #aeaeb2;
}

/* ---- 底部常驻「关闭」（内容超高时顶部 × 会滚走，这条始终可见） ---- */
.qrdl-modal__foot-close {
    display: block;
    width: 100%;
    margin: 18px 0 0;
    padding: 11px 0;
    border: none;
    border-radius: 14px;
    background: rgba(118, 118, 128, 0.10);
    color: #007aff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.1s ease-out;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    will-change: transform;
}

.qrdl-modal__foot-close:hover {
    background: rgba(118, 118, 128, 0.18);
}

.qrdl-modal__foot-close:active {
    transform: scale(0.985);
}

.qrdl-modal__foot-close:focus-visible {
    outline: 2px solid #007aff;
    outline-offset: 2px;
}

/* ---- 二维码 ---- */
.qrdl-modal__qrbox {
    margin: 0 auto;
    padding: 14px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.qrdl-modal__qr {
    width: 100%;
    height: 100%;
}

.qrdl-modal__qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---- 暗黑模式 ---- */
@media (prefers-color-scheme: dark) {
    .qrdl-modal__card {
        background: #1c1c1e;
        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6),
            0 0 0 0.5px rgba(255, 255, 255, 0.1);
    }

    .qrdl-modal__close {
        background: rgba(118, 118, 128, 0.24);
        color: #ebebf5;
    }

    .qrdl-modal__close:hover {
        background: rgba(118, 118, 128, 0.38);
    }

    .qrdl-modal__brand {
        background: rgba(118, 118, 128, 0.18);
    }

    .qrdl-modal__brand-name {
        color: #ebebf5;
    }

    .qrdl-modal__title {
        color: #f5f5f7;
    }

    .qrdl-modal__hint {
        color: #98989d;
    }

    .qrdl-modal__foot {
        color: #636366;
    }

    .qrdl-modal__foot-close {
        background: rgba(118, 118, 128, 0.22);
        color: #0a84ff;
    }

    .qrdl-modal__foot-close:hover {
        background: rgba(118, 118, 128, 0.34);
    }

    .qrdl-modal__qrbox {
        background: #ffffff; /* 二维码必须保持白底，否则深色模式下扫不出 */
        border-color: rgba(255, 255, 255, 0.12);
    }
}

/* ---- 小屏（移动端 popup 模式或窄窗口） ---- */
@media (max-width: 480px) {
    .qrdl-modal {
        padding: 16px;
    }

    .qrdl-modal__card {
        width: 100%;
        border-radius: 24px;
    }

    .qrdl-modal__scroll {
        padding: 24px 20px 20px;
    }
}

/* ---- 动效偏好减弱 ---- */
@media (prefers-reduced-motion: reduce) {
    .qrdl-modal__mask,
    .qrdl-modal__card,
    .qrdl-modal__close,
    .qrdl-modal__foot-close {
        transition: none;
    }
}
