/* ===== 解锁包裹 ===== */
.ad-unlock-wrap {
    margin: 24px 0;
}

/* ===== 预览内容 —— 无背景无边框，原生融入页面 ===== */
.ad-unlock-preview {
    line-height: 1.8;
    font-size: 16px;
    color: inherit;
    margin-bottom: 24px;
}

.ad-unlock-preview p {
    margin: 0 0 18px 0;
}

.ad-unlock-preview > :first-child {
    margin-top: 0;
}

.ad-unlock-preview > :last-child {
    margin-bottom: 0;
}

.ad-unlock-preview img,
.ad-unlock-preview video {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.ad-unlock-preview figure {
    margin: 0 0 18px 0;
}

/* ===== 解锁卡片 ===== */
.ad-unlock-card {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

/* ===== 全局兜底：切断主题的 transform / animation 继承 =====
   🔴 用户反馈"文字还在旋转"。真正的原因不是本插件的 CSS
      （我自己的样式里确实没有 rotate），而是**子比主题给 button
      加了全局 transform 过渡**，本插件的按钮继承后，
      在 hover / loading / 聚焦时与自身样式叠加，看起来像在转圈或抖动。

      之前的修法是「逐个状态改掉 translateY」，治标 —— 主题还有
      其它状态没覆盖到。这次直接用 `transform: none` 兜底并限制
      transition 属性白名单，一劳永逸。 */
.ad-unlock-container *,
.unlock-action-box *,
.mp-unlock-section *,
.mp-unlock-popup,
.mp-unlock-popup * {
    transform: none;
    animation: none;
}

/* 过渡只允许颜色/阴影/透明度，不允许任何会动的东西
   text-decoration-color 也放开：「检查解锁状态」是纯文字+下划线按钮，
   悬停下划线要跟着变色。 */
.ad-unlock-container *,
.unlock-action-box *,
.mp-unlock-section *,
.mp-unlock-popup,
.mp-unlock-popup *,
.mp-unlock-section * {
    transition-property: color, background-color, border-color, box-shadow, opacity, text-decoration-color !important;
    transition-duration: 0.15s !important;
    transition-timing-function: ease !important;
}

/* ===== 解锁按钮 ===== */
.ad-unlock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #5B9BD5;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    min-height: 44px;

    /* 🔴 文字变化时（「生成解锁码解锁」→「生成中」）不许换行。
       之前没加时，文章标题窄的地方按钮会把文字竖排成一行一个字。 */
    white-space: nowrap;
    max-width: 100%;
}

/* 🔴 悬停/按下只改背景和阴影，不做 translateY 位移。
    位移会和主题按钮自带的 transform 打架，看起来像在抖或转圈。 */
.ad-unlock-btn:hover {
    background: #4A89C2;
    box-shadow: 0 3px 10px rgba(91, 155, 213, 0.22);
}

.ad-unlock-btn:active {
    background: #4079AF;
    box-shadow: none;
}

.ad-unlock-btn:disabled,
.ad-unlock-btn.loading {
    background: #9BBBD6;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.85;
}

.btn-text {
    line-height: 1.4;
}

.btn-hint {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.85;
    line-height: 1.4;
    margin-left: 8px;
    /* 小尾巴也保持一行，它不能把主按钮文字挤断 */
    white-space: nowrap;
}

/* 加载中：只靠按钮内的文案说明，不要 ::after 的省略号动画 */
.ad-unlock-btn.loading .btn-text::after {
    content: none;
}

/* 成功消息 */
.ad-unlock-msg {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
    color: #52c41a;
}

/* ===== 弹窗（参照老插件 zib-ad-unlock 蓝色系）===== */
.mp-unlock-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.mp-unlock-popup {
    background: #fff;
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #a6b0ba;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.popup-close:hover {
    background: #f0f2f5;
    color: #5a6570;
}

.popup-content {
    padding: 22px 20px 20px;
}

/* 解锁码下方的小按钮组：复制 / 重新生成
   两个是完全对等的操作，所以尺寸、样式、权重都一样，
   不做主次之分。反馈只靠文字变化和浅底色，不做位移/缩放动画。 */
.xys-code-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.xys-mini-btn {
    background: #fff;
    color: #4a7fa8;
    border: 1px solid #d5e3f0;
    border-radius: 4px;
    padding: 5px 14px;
    font-size: 12px;
    line-height: 1.6;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;

    /* 🔴 文字变化时（如「重新生成」→「生成中」→4字变3字）按钮会收缩，
       窄到一定程度文字就竖排换行。锁定最小宽度 + 禁止换行，
       按钮宽度恒定，文字始终横排。 */
    min-width: 84px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.xys-mini-btn:hover {
    background: #f5f9fd;
    border-color: #b9d4ea;
    color: #357abd;
}

.xys-mini-btn:disabled,
.xys-mini-btn.loading {
    color: #a8b0b8;
    border-color: #e3e8ed;
    background: #fafbfc;
    cursor: not-allowed;
}

/* 复制成功的临时反馈：只变文字和颜色 */
.xys-mini-btn.is-done {
    color: #3a9a4d;
    border-color: #b7e0c2;
    background: #f2fbf5;
}

/* 「检查解锁状态」那一行
   按用户规范：次要操作用纯文字按钮，不要白底描边大按钮。
   它是给「在小程序解锁完回来」的用户用的兜底入口，
   不该和「复制」「重新生成」抢视觉权重，所以只用灰色小字。 */
.xys-status-actions {
    margin-top: 10px;
    text-align: center;
}

.xys-status-btn {
    background: none;
    border: 0;
    padding: 4px 6px;
    color: #9aa5ae;
    font-size: 12px;
    line-height: 1.6;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: #cfd6dc;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.xys-status-btn:hover {
    color: #4a90e2;
    text-decoration-color: currentColor;
}

.xys-status-btn:disabled,
.xys-status-btn.loading {
    color: #bcc4cb;
    cursor: not-allowed;
    text-decoration: none;
}

/* 检测到已解锁：按钮文字变绿，页面马上自动刷新 */
.xys-status-btn.is-unlocked {
    color: #3a9a4d;
    font-weight: 500;
}

.xys-popup-footnote {
    text-align: center;
    color: #a6b0ba;
    font-size: 12px;
    line-height: 1.6;
    margin: 12px 0 0;
}

/* 内联面板的刷新按钮（原来完全没有样式，是裸按钮） */
.refresh-code-btn {
    display: inline-block;
    background: none;
    color: #4a90e2;
    border: 1px solid #d5e3f0;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    /* 同上：文案变化时不许换行 */
    white-space: nowrap;
    min-width: 110px;
}

.refresh-code-btn:hover {
    background: #f5f9fd;
    border-color: #b9d4ea;
    color: #357abd;
}

.refresh-code-btn:disabled {
    color: #b0b8c0;
    border-color: #e6eaee;
    cursor: not-allowed;
}

.popup-desc {
    color: #888;
    font-size: 13px;
    line-height: 1.6;
    margin: 0 0 18px 0;
}

/* ===== 内联操作面板（弹窗的降级路径）===== */
.unlock-action-box {
    margin-top: 16px;
    padding: 18px 16px;
    background: #f7fafc;
    border: 1px solid #e3eaf0;
    border-radius: 8px;
    text-align: center;
}

.unlock-code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.unlock-code-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 5px;
    text-indent: 5px;
    color: #2c3e50;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    line-height: 1.3;
}

/* 复制 / 刷新 两个次要操作并排 */
.unlock-code-display > div {
    display: flex;
    gap: 4px;
    align-items: center;
}

.unlock-tip {
    margin-top: 12px;
}

.unlock-tip p {
    margin: 0 0 4px 0;
    color: #6b7c8f;
    font-size: 13px;
    line-height: 1.6;
}

.unlock-tip p:last-child {
    color: #9aa5b1;
    font-size: 12px;
    margin-bottom: 0;
}

/* 解锁码区域 —— 去掉渐变和虚线框，改成干净的浅底卡片 */
.unlock-code-box {
    background: #f7fafc;
    border: 1px solid #e3eaf0;
    border-radius: 8px;
    padding: 20px 18px;
    text-align: center;
    margin-bottom: 18px;
}

.unlock-code-label {
    font-size: 13px;
    color: #6b7c8f;
    margin: 0 0 10px 0;
    font-weight: 400;
}

.unlock-code {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: 6px;
    text-indent: 6px;
    color: #2c3e50;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    line-height: 1.3;
}

/* 复制按钮：文字型次要操作，不再是大块描边按钮 */
.copy-code-btn {
    background: none;
    color: #4a90e2;
    border: none;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
    /* 同上：文案在「复制」↔「已复制」间变化时不许换行 */
    white-space: nowrap;
    min-width: 76px;
}

.copy-code-btn:hover {
    background: rgba(74, 144, 226, 0.08);
    color: #357abd;
}

.copy-code-btn.copied {
    background: none;
    color: #3a9a4d;
    cursor: default;
}

.qrcode-section {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.qrcode-item {
    text-align: center;
    flex: 0 0 auto;
}

.qrcode-item img {
    width: 120px;
    height: 120px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 4px;
    background: #fff;
    display: block;
}

.qrcode-item span {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #888;
}

/* 有效期 / 状态说明 —— 中性灰，不抢视觉焦点 */
.unlock-status {
    text-align: center;
    padding: 0;
    background: none;
    border: none;
    color: #8a94a0;
    font-size: 12px;
    line-height: 1.6;
    margin-top: 10px;
    min-height: 18px;
}

/* 失败态：就地说明原因，不弹顶部提示条 */
.unlock-status.is-error {
    color: #c0392b;
    font-size: 13px;
    line-height: 1.7;
}

.xys-retry-hint {
    display: block;
    color: #8a94a0;
    font-size: 12px;
    margin-top: 2px;
}

/* =============================================
   暗黑模式（完全对齐老插件）
   ============================================= */
html.dark .ad-unlock-preview,
body.dark .ad-unlock-preview,
.dark .ad-unlock-preview,
[data-theme="dark"] .ad-unlock-preview {
    color: #ccc;
}

html.dark .ad-unlock-preview h1,
html.dark .ad-unlock-preview h2,
html.dark .ad-unlock-preview h3,
html.dark .ad-unlock-preview h4,
html.dark .ad-unlock-preview h5,
html.dark .ad-unlock-preview h6,
body.dark .ad-unlock-preview h1,
body.dark .ad-unlock-preview h2,
body.dark .ad-unlock-preview h3,
body.dark .ad-unlock-preview h4,
body.dark .ad-unlock-preview h5,
body.dark .ad-unlock-preview h6,
.dark .ad-unlock-preview h1,
.dark .ad-unlock-preview h2,
.dark .ad-unlock-preview h3,
.dark .ad-unlock-preview h4,
.dark .ad-unlock-preview h5,
.dark .ad-unlock-preview h6,
[data-theme="dark"] .ad-unlock-preview h1,
[data-theme="dark"] .ad-unlock-preview h2,
[data-theme="dark"] .ad-unlock-preview h3,
[data-theme="dark"] .ad-unlock-preview h4,
[data-theme="dark"] .ad-unlock-preview h5,
[data-theme="dark"] .ad-unlock-preview h6 {
    color: #ddd;
}

/* 按钮暗黑模式 */
html.dark .ad-unlock-btn,
body.dark .ad-unlock-btn,
.dark .ad-unlock-btn,
[data-theme="dark"] .ad-unlock-btn {
    background: #5a9fd4;
}

html.dark .ad-unlock-btn:hover,
body.dark .ad-unlock-btn:hover,
.dark .ad-unlock-btn:hover,
[data-theme="dark"] .ad-unlock-btn:hover {
    background: #4a90e2;
    box-shadow: 0 4px 12px rgba(90, 159, 212, 0.3);
}

html.dark .ad-unlock-btn:disabled,
body.dark .ad-unlock-btn:disabled,
.dark .ad-unlock-btn:disabled,
[data-theme="dark"] .ad-unlock-btn:disabled {
    background: #555;
}

html.dark .ad-unlock-btn.loading,
body.dark .ad-unlock-btn.loading,
.dark .ad-unlock-btn.loading,
[data-theme="dark"] .ad-unlock-btn.loading {
    background: #6ab0e5;
}

/* 弹窗暗黑模式 */
html.dark .mp-unlock-popup,
body.dark .mp-unlock-popup,
.dark .mp-unlock-popup,
[data-theme="dark"] .mp-unlock-popup {
    background: #2a2a2a;
}

html.dark .popup-header,
body.dark .popup-header,
.dark .popup-header,
[data-theme="dark"] .popup-header {
    border-bottom-color: #3a3a3a;
}

html.dark .popup-title,
body.dark .popup-title,
.dark .popup-title,
[data-theme="dark"] .popup-title {
    color: #ddd;
}

html.dark .popup-close,
body.dark .popup-close,
.dark .popup-close,
[data-theme="dark"] .popup-close {
    background: #3a3a3a;
    color: #999;
}

html.dark .popup-close:hover,
body.dark .popup-close:hover,
.dark .popup-close:hover,
[data-theme="dark"] .popup-close:hover {
    background: #4a4a4a;
    color: #ccc;
}

html.dark .popup-desc,
body.dark .popup-desc,
.dark .popup-desc,
[data-theme="dark"] .popup-desc {
    color: #aaa;
}

html.dark .unlock-action-box,
body.dark .unlock-action-box,
.dark .unlock-action-box,
[data-theme="dark"] .unlock-action-box {
    background: #23262b;
    border-color: #34383e;
}

html.dark .unlock-code-value,
body.dark .unlock-code-value,
.dark .unlock-code-value,
[data-theme="dark"] .unlock-code-value {
    color: #e4e7eb;
}

html.dark .unlock-tip p,
body.dark .unlock-tip p,
.dark .unlock-tip p,
[data-theme="dark"] .unlock-tip p {
    color: #8a929c;
}

html.dark .unlock-tip p:last-child,
body.dark .unlock-tip p:last-child,
.dark .unlock-tip p:last-child,
[data-theme="dark"] .unlock-tip p:last-child {
    color: #6b727b;
}

/* 解锁码区域暗黑模式 */
html.dark .unlock-code-box,
body.dark .unlock-code-box,
.dark .unlock-code-box,
[data-theme="dark"] .unlock-code-box {
    background: #23262b;
    border-color: #34383e;
}

html.dark .unlock-code-label,
body.dark .unlock-code-label,
.dark .unlock-code-label,
[data-theme="dark"] .unlock-code-label {
    color: #8a929c;
}

html.dark .unlock-code,
body.dark .unlock-code,
.dark .unlock-code,
[data-theme="dark"] .unlock-code {
    background: none;
    border: none;
    color: #e4e7eb;
}

html.dark .copy-code-btn,
body.dark .copy-code-btn,
.dark .copy-code-btn,
[data-theme="dark"] .copy-code-btn {
    background: none;
    color: #7ab8e0;
    border: none;
}

html.dark .copy-code-btn:hover,
body.dark .copy-code-btn:hover,
.dark .copy-code-btn:hover,
[data-theme="dark"] .copy-code-btn:hover {
    background: rgba(122, 184, 224, 0.12);
    border: none;
}

html.dark .copy-code-btn.copied,
body.dark .copy-code-btn.copied,
.dark .copy-code-btn.copied,
[data-theme="dark"] .copy-code-btn.copied {
    background: none;
    border: none;
    color: #6fbf7f;
}

html.dark .unlock-status,
body.dark .unlock-status,
.dark .unlock-status,
[data-theme="dark"] .unlock-status {
    background: none;
    border: none;
    color: #767e88;
}

html.dark .refresh-code-btn,
body.dark .refresh-code-btn,
.dark .refresh-code-btn,
[data-theme="dark"] .refresh-code-btn {
    background: none;
    color: #7ab8e0;
    border-color: #3a4550;
}

html.dark .refresh-code-btn:hover,
body.dark .refresh-code-btn:hover,
.dark .refresh-code-btn:hover,
[data-theme="dark"] .refresh-code-btn:hover {
    background: #2a2f36;
    border-color: #4a5a68;
}

html.dark .xys-mini-btn,
body.dark .xys-mini-btn,
.dark .xys-mini-btn,
[data-theme="dark"] .xys-mini-btn {
    background: #2a2f36;
    color: #7ab8e0;
    border-color: #3a4550;
}

html.dark .xys-mini-btn:hover,
body.dark .xys-mini-btn:hover,
.dark .xys-mini-btn:hover,
[data-theme="dark"] .xys-mini-btn:hover {
    background: #333a42;
    border-color: #4a5a68;
    color: #9ccbec;
}

html.dark .xys-mini-btn:disabled,
body.dark .xys-mini-btn:disabled,
.dark .xys-mini-btn:disabled,
[data-theme="dark"] .xys-mini-btn:disabled {
    background: #24282d;
    color: #5f6a73;
    border-color: #33383e;
}

html.dark .xys-mini-btn.is-done,
body.dark .xys-mini-btn.is-done,
.dark .xys-mini-btn.is-done,
[data-theme="dark"] .xys-mini-btn.is-done {
    background: #243026;
    color: #6fbf7f;
    border-color: #3d5a44;
}

html.dark .xys-code-actions,
body.dark .xys-code-actions,
.dark .xys-code-actions,
[data-theme="dark"] .xys-code-actions {
    display: flex;
}

html.dark .xys-popup-footnote,
body.dark .xys-popup-footnote,
.dark .xys-popup-footnote,
[data-theme="dark"] .xys-popup-footnote {
    color: #6b727b;
}

html.dark .qrcode-item img,
body.dark .qrcode-item img,
.dark .qrcode-item img,
[data-theme="dark"] .qrcode-item img {
    border-color: #444;
    background: #2a2a2a;
}

html.dark .qrcode-item span,
body.dark .qrcode-item span,
.dark .qrcode-item span,
[data-theme="dark"] .qrcode-item span {
    color: #aaa;
}

/* 解锁状态暗黑模式 */
html.dark .unlock-status,
body.dark .unlock-status,
.dark .unlock-status,
[data-theme="dark"] .unlock-status {
    background: #1a3020;
    border-color: #3a6030;
    color: #6ddb6d;
}

/* 成功消息暗黑模式 */
html.dark .ad-unlock-msg,
body.dark .ad-unlock-msg,
.dark .ad-unlock-msg,
[data-theme="dark"] .ad-unlock-msg {
    color: #6ddb6d;
}

/* =============================================
   响应式（完全对齐老插件）
   ============================================= */
@media (max-width: 768px) {
    .ad-unlock-wrap {
        margin: 20px 0;
    }

    .ad-unlock-card {
        max-width: 100%;
        padding: 0 8px;
    }

    .ad-unlock-preview {
        font-size: 15px;
        line-height: 1.7;
        margin-bottom: 20px;
    }

    .ad-unlock-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }

    .mp-unlock-popup {
        max-width: 100%;
        width: calc(100% - 24px);
    }

    .unlock-code {
        font-size: 24px;
        letter-spacing: 2px;
        padding: 12px;
    }

    .qrcode-item img {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .ad-unlock-wrap {
        margin: 16px 0;
    }

    .ad-unlock-preview {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 16px;
    }

    .ad-unlock-btn {
        width: 100%;
        padding: 13px 16px;
        font-size: 14px;
        border-radius: 6px;
    }

    .ad-unlock-card {
        padding: 0 4px;
    }

    .btn-hint {
        font-size: 10px;
        padding: 2px 4px;
    }

    .mp-unlock-section {
        align-items: flex-end;
        padding: 0;
    }

    .mp-unlock-popup {
        width: 100%;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        max-width: 100%;
    }

    .popup-header {
        padding: 14px 16px;
    }

    .popup-content {
        padding: 16px;
    }

    .unlock-code {
        font-size: 22px;
        letter-spacing: 2px;
        padding: 10px;
    }

    .copy-code-btn {
        width: 100%;
        min-height: 44px;
    }

    .qrcode-item img {
        width: 80px;
        height: 80px;
    }
}
