.rp-sync-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    color: #111827;
}

.rp-sync-modal.is-open {
    display: block;
}

.rp-sync-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.32);
    backdrop-filter: blur(5px);
}

.rp-sync-modal__panel {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(92vw, 420px);
    max-height: min(86vh, 640px);
    max-height: min(86dvh, 640px);   /* 手机地址栏会吃掉 vh 的一截，可见高度用 dvh；旧浏览器回退上一行 */
    overflow-y: auto;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 70px -34px rgba(15, 23, 42, 0.55);
    padding: 18px;
}

.rp-sync-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.rp-sync-modal__eyebrow {
    color: #2563eb;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rp-sync-modal__title {
    margin: 0;
    color: #111827;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 800;
}

.rp-sync-modal__title-main {
    display: block;
    color: #111827;
    font-size: 18px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 0;
}

.rp-sync-modal__title-sub {
    display: block;
    margin-bottom: 3px;
    color: #2563eb;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rp-sync-modal__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: 999px;
    background: #fff;
    color: #6b7280;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.rp-sync-modal__close:hover {
    color: #111827;
    border-color: rgba(156, 163, 175, 0.9);
}

.rp-sync-main-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.rp-sync-action-button {
    min-width: 0;
    height: 42px;
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: 12px;
    background: #fff;
    color: #374151;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.rp-sync-action-button:hover {
    border-color: rgba(59, 130, 246, 0.35);
    background: #f8fafc;
    color: #1d4ed8;
}

.rp-sync-action-button.is-primary {
    border-color: rgba(37, 99, 235, 0.25);
    background: #eff6ff;
    color: #1d4ed8;
}

.rp-sync-action-button:disabled,
.rp-sync-modal__button:disabled {
    opacity: 0.62;
    cursor: wait;
}

.rp-sync-modal__status {
    min-height: 22px;
    margin: 14px 0 10px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.55;
}

.rp-sync-progress {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.rp-sync-progress__bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
    transition: width 0.28s ease;
}

.rp-sync-progress__value {
    margin-top: 6px;
    text-align: right;
    color: #2563eb;
    font-size: 12px;
    font-weight: 800;
}

.rp-sync-modal__intro {
    margin: 0 0 10px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.55;
}

.rp-sync-password-field {
    display: grid;
    gap: 7px;
    margin-top: 14px;
    color: #475569;
    font-size: 13px;
    font-weight: 800;
}

.rp-sync-modal__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.rp-sync-modal__button {
    min-width: 78px;
    border: 1px solid rgba(209, 213, 219, 0.95);
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 12px;
    cursor: pointer;
}

.rp-sync-modal__button:hover {
    border-color: rgba(59, 130, 246, 0.35);
    color: #1d4ed8;
}

.rp-sync-modal__button.is-primary {
    border-color: rgba(37, 99, 235, 0.25);
    background: #eff6ff;
    color: #1d4ed8;
}

.rp-sync-password-field input {
    width: 100%;
    border: 1px solid rgba(209, 213, 219, 0.95);
    border-radius: 12px;
    background: #fff;
    color: #111827;
    font-size: 15px;
    line-height: 1.4;
    padding: 11px 12px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.rp-sync-password-field input:focus {
    border-color: rgba(37, 99, 235, 0.52);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}

.rp-sync-password-status {
    min-height: 20px;
    margin: 10px 0 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .rp-sync-modal__backdrop {
        background: rgba(17, 24, 39, 0.36);
    }
    .rp-sync-modal__panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-height: min(82vh, 620px);
        max-height: min(82dvh, 620px);   /* 同上：手机可见高度用 dvh */
        transform: none;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 20px 20px 0 0;
        padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    }

    .rp-sync-modal__header {
        margin-bottom: 12px;
    }

    .rp-sync-modal__title {
        font-size: 18px;
    }

    .rp-sync-modal__title-main {
        font-size: 17px;
    }

    .rp-sync-modal__title-sub {
        font-size: 10px;
    }

    .rp-sync-main-actions {
        gap: 8px;
    }

    .rp-sync-action-button {
        height: 42px;
        font-size: 14px;
        border-radius: 12px;
    }

}

/* 夜间模式：云同步弹窗是魔改自带 UI，作者的主题规则不覆盖它，这里按作者变量补齐 */
:root[data-app-theme="dark"] .rp-sync-modal { color: var(--night-text); }
:root[data-app-theme="dark"] .rp-sync-modal__backdrop { background: rgba(0, 0, 0, 0.62); }
:root[data-app-theme="dark"] .rp-sync-modal__panel {
    border-color: var(--night-border);
    background: var(--night-raised);
    box-shadow: 0 24px 70px -34px rgba(0, 0, 0, 0.85);
}
:root[data-app-theme="dark"] .rp-sync-modal__title,
:root[data-app-theme="dark"] .rp-sync-modal__title-main { color: var(--night-text); }
:root[data-app-theme="dark"] .rp-sync-modal__eyebrow,
:root[data-app-theme="dark"] .rp-sync-modal__title-sub,
:root[data-app-theme="dark"] .rp-sync-progress__value { color: #93c5fd; }
:root[data-app-theme="dark"] .rp-sync-modal__close,
:root[data-app-theme="dark"] .rp-sync-modal__button,
:root[data-app-theme="dark"] .rp-sync-action-button {
    border-color: var(--night-border);
    background: var(--night-field);
    color: var(--night-text);
}
:root[data-app-theme="dark"] .rp-sync-modal__close:hover,
:root[data-app-theme="dark"] .rp-sync-modal__button:hover,
:root[data-app-theme="dark"] .rp-sync-action-button:hover {
    border-color: rgba(134, 173, 244, 0.5);
    background: rgba(30, 58, 138, 0.28);
    color: #dbeafe;
}
:root[data-app-theme="dark"] .rp-sync-modal__button.is-primary,
:root[data-app-theme="dark"] .rp-sync-action-button.is-primary {
    border-color: rgba(99, 102, 241, 0.55);
    background: rgba(30, 58, 138, 0.42);
    color: #bfdbfe;
}
:root[data-app-theme="dark"] .rp-sync-modal__status,
:root[data-app-theme="dark"] .rp-sync-modal__intro,
:root[data-app-theme="dark"] .rp-sync-password-field,
:root[data-app-theme="dark"] .rp-sync-password-status { color: #a1a1aa; }
:root[data-app-theme="dark"] .rp-sync-progress { background: #3f3f46; }
:root[data-app-theme="dark"] .rp-sync-progress__bar { background: #60a5fa; }
:root[data-app-theme="dark"] .rp-sync-password-field input {
    border-color: var(--night-border);
    background: var(--night-field);
    color: var(--night-text);
}
:root[data-app-theme="dark"] .rp-sync-password-field input:focus {
    border-color: #86adf4;
    box-shadow: 0 0 0 3px rgba(120, 166, 244, 0.16);
}

/* ===== 更新角色卡弹窗（补丁：build_card_update.mjs） =====
   面板/头部/表格底色走作者的 bg-white + border-gray-* 工具类，夜间由作者主题接管；
   这里只补自建类：状态色、表格强调、下拉、按钮与撤销浮条，并给这些自造色配夜间版本。 */
.rph-update-version {
    flex: none;
    font-size: 11px;
    font-weight: 600;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 2px 9px;
}

.rph-update-close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: #9ca3af;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s ease;
}

.rph-update-close:hover {
    color: #374151;
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.rph-update-keep {
    border: 1px solid rgba(16, 185, 129, .26);
    background: rgba(16, 185, 129, .06);
    border-radius: 14px;
    padding: 12px;
}

.rph-update-keep-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #047857;
}

.rph-update-keep-head svg { width: 15px; height: 15px; }

.rph-update-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .72);
    border: 1px solid rgba(16, 185, 129, .16);
}

.rph-update-stat-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}

.rph-update-stat b {
    font-size: 22px;
    line-height: 1.1;
    font-weight: 800;
    color: #065f46;
    font-variant-numeric: tabular-nums;
}

.rph-update-stat span { font-size: 12px; color: #059669; }

.rph-update-stat em {
    font-style: normal;
    font-size: 10px;
    line-height: 1.3;
    margin-top: 2px;
    color: rgba(5, 150, 105, .8);
    text-align: center;
}

.rph-update-label {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #6b7280;
}

.rph-update-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.rph-update-table th {
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    padding: 0 8px 6px;
}

.rph-update-table th:first-child { text-align: left; }

.rph-update-table td {
    padding: 7px 8px;
    border-top: 1px solid #f3f4f6;
    color: #6b7280;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rph-update-table td:first-child {
    text-align: left;
    color: #374151;
    font-weight: 500;
}

.rph-update-table tr.is-changed td { background: rgba(59, 130, 246, .055); }
.rph-update-table tr.is-changed td:first-child { color: #1e40af; }
.rph-update-table tr.is-changed td:last-child { color: #1d4ed8; font-weight: 700; }

.rph-update-tpl {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.rph-update-tpl-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
    color: #374151;
}

.rph-update-select {
    flex: 0 1 auto;
    max-width: 62%;
    font-size: 12px;
    color: #374151;
    background: #fff;
    border: 1px solid #e6edf7;
    border-radius: 10px;
    padding: 7px 9px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rph-update-select:focus-visible {
    border-color: #5281ec;
    box-shadow: 0 0 0 3px rgba(120, 166, 244, .18);
}

.rph-update-warn {
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.65;
    color: #92400e;
    background: rgba(245, 158, 11, .09);
    border: 1px solid rgba(245, 158, 11, .26);
}

.rph-update-cover > span { font-size: 13px; font-weight: 500; color: #4b5563; }

.rph-update-btn {
    min-width: 88px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all .15s ease;
}

.rph-update-btn:hover { color: #111827; border-color: #d1d5db; background: #f9fafb; }
.rph-update-btn:active { transform: scale(.97); }

.rph-update-btn--primary {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .7);
}

.rph-update-btn--primary:hover { color: #fff; background: #1d4ed8; border-color: #1d4ed8; }

.rph-update-undo-chip {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    color: #374151;
    background: rgba(255, 255, 255, .93);
    border: 1px solid #e5e7eb;
    backdrop-filter: blur(12px);
    box-shadow: 0 18px 30px -14px rgba(15, 23, 42, .38);
    animation: rphUpdateChipIn .22s ease-out;
}

@keyframes rphUpdateChipIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.rph-update-undo-btn {
    flex: none;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    cursor: pointer;
}

.rph-update-undo-btn:hover { background: #dbeafe; }

.rph-update-undo-close {
    flex: none;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #9ca3af;
    background: transparent;
    border: none;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.rph-update-undo-close:hover { color: #374151; background: #f3f4f6; }

/* —— 夜间：工具类由作者主题接管，这几处自造色要自己跟上 —— */
:root[data-app-theme="dark"] .rph-update-version { color: #bfdbfe; background: rgba(37, 99, 235, .22); border-color: rgba(96, 165, 250, .3); }
:root[data-app-theme="dark"] .rph-update-close { color: #8f8f96; }
:root[data-app-theme="dark"] .rph-update-close:hover { color: #e4e4e7; background: var(--night-raised); border-color: var(--night-border); }
:root[data-app-theme="dark"] .rph-update-keep { border-color: rgba(16, 185, 129, .34); background: rgba(6, 95, 70, .18); }
:root[data-app-theme="dark"] .rph-update-keep-head { color: #6ee7b7; }
:root[data-app-theme="dark"] .rph-update-stat { background: rgba(32, 32, 32, .7); border-color: rgba(16, 185, 129, .22); }
:root[data-app-theme="dark"] .rph-update-stat b { color: #6ee7b7; }
:root[data-app-theme="dark"] .rph-update-stat span { color: #34d399; }
:root[data-app-theme="dark"] .rph-update-stat em { color: rgba(52, 211, 153, .75); }
:root[data-app-theme="dark"] .rph-update-label { color: #a1a1aa; }
:root[data-app-theme="dark"] .rph-update-table th { color: #8f8f96; }
:root[data-app-theme="dark"] .rph-update-table td { border-top-color: var(--night-border); color: #a1a1aa; }
:root[data-app-theme="dark"] .rph-update-table td:first-child { color: #d4d4d8; }
:root[data-app-theme="dark"] .rph-update-table tr.is-changed td { background: rgba(59, 130, 246, .12); }
:root[data-app-theme="dark"] .rph-update-table tr.is-changed td:first-child { color: #bfdbfe; }
:root[data-app-theme="dark"] .rph-update-table tr.is-changed td:last-child { color: #dbeafe; }
:root[data-app-theme="dark"] .rph-update-tpl-name { color: #e4e4e7; }
:root[data-app-theme="dark"] .rph-update-select { background: var(--night-field); border-color: var(--night-border); color: var(--night-text); }
:root[data-app-theme="dark"] .rph-update-warn { color: #fcd34d; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .28); }
:root[data-app-theme="dark"] .rph-update-cover > span { color: #a1a1aa; }
:root[data-app-theme="dark"] .rph-update-btn { background: var(--night-field); border-color: var(--night-border); color: #d4d4d8; }
:root[data-app-theme="dark"] .rph-update-btn:hover { background: var(--night-raised); border-color: #52525b; color: #f4f4f5; }
:root[data-app-theme="dark"] .rph-update-btn--primary { background: #2563eb; border-color: #3b82f6; color: #fff; box-shadow: 0 8px 18px -10px rgba(59, 130, 246, .8); }
:root[data-app-theme="dark"] .rph-update-btn--primary:hover { background: #1d4ed8; border-color: #60a5fa; }
:root[data-app-theme="dark"] .rph-update-undo-chip { background: rgba(32, 32, 32, .94); border-color: var(--night-border); color: #d4d4d8; box-shadow: 0 18px 30px -16px rgba(0, 0, 0, .7); }
:root[data-app-theme="dark"] .rph-update-undo-btn { background: rgba(37, 99, 235, .22); border-color: rgba(96, 165, 250, .34); color: #bfdbfe; }
:root[data-app-theme="dark"] .rph-update-undo-btn:hover { background: rgba(37, 99, 235, .34); }
:root[data-app-theme="dark"] .rph-update-undo-close { color: #8f8f96; }
:root[data-app-theme="dark"] .rph-update-undo-close:hover { color: #e4e4e7; background: var(--night-raised); }
/* —— 手机端（<640px）：弹窗改底部抽屉 ——
   不用垂直居中：内容超高时 flex 居中会把顶部裁掉且滚不回来；
   高度用 dvh（随地址栏伸缩），vh 由模板上的类做旧浏览器兜底。 */
@media (max-width: 639.98px) {
    .rph-update-panel {
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -18px 40px -20px rgba(15, 23, 42, .45);
    }

    .rph-update-panel::before {
        content: "";
        position: absolute;
        top: 7px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: rgba(148, 163, 184, .5);
    }

    .rph-update-panel > header { padding: 16px 14px 10px; }
    .rph-update-panel > header > div > div:last-child { font-size: 15px; gap: 6px; }
    .rph-update-panel > div { padding: 12px 14px; }
    .rph-update-panel > footer { padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
    .rph-update-panel footer .rph-update-btn { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 12px 16px; }
    .rph-update-stat b { font-size: 18px; }
    .rph-update-table { font-size: 12px; }
    .rph-update-table td { padding: 6px 6px; }

    /* 面板配对在窄屏改成上下排，下拉框整行可点，避免长名字被挤掉 */
    .rph-update-tpl { flex-direction: column; align-items: stretch; gap: 5px; padding: 7px 0; }
    .rph-update-select { max-width: none; width: 100%; }
}

:root[data-app-theme="dark"] .rph-update-panel::before { background: rgba(148, 163, 184, .35); }
