/* ============================================================
   modal.css · 模态框 + 选择角色列表 + 通用菜单 + 场景事件弹窗
   ------------------------------------------------------------
   含：通用 modal-box / 场景事件弹窗（小事件·大事件两套氛围）/
       通话弹窗（call-modal-box）/ 一键生成 / 记忆整理设置 /
       记忆整理对比 / 时间弹窗提示
   ============================================================ */

/* ===== 模态框 ===== */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 10, 20, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    /* 必须高于手机抽屉（70），否则弹窗会被盖住 */
    z-index: 90;
    border-radius: inherit;
    padding: 12px;
}
.modal-overlay.active {
    display: flex;
}
.modal-box {
    background: rgba(30, 20, 45, 0.92);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(212, 106, 147, 0.22);
    border-radius: 20px;
    padding: 20px 24px;
    width: 100%;
    max-width: 400px;
    max-height: 90%;
    overflow-y: auto;
    color: var(--text);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(212, 106, 147, 0.08);
}
.modal-box h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
    text-shadow: 0 0 20px rgba(212, 106, 147, 0.35);
}
.modal-box label {
    display: block;
    font-size: 14px;
    color: var(--text-dim);
    margin: 12px 0 4px;
}
.modal-box input[type="date"],
.modal-box input[type="time"],
.modal-box input[type="text"],
.modal-box input[type="number"],
.modal-box input[type="password"],
.modal-box textarea,
.modal-box select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(212, 106, 147, 0.22);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-box input:focus,
.modal-box textarea:focus,
.modal-box select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 106, 147, 0.18);
}
.modal-box textarea {
    resize: vertical;
    min-height: 50px;
}
.modal-box select option {
    background: #1a0e2e;
    color: #fff;
}
.modal-box .avatar-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.modal-box .avatar-preview .circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(212, 106, 147, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    font-weight: bold;
    color: var(--text);
    flex-shrink: 0;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-box .avatar-preview .circle:hover {
    border-color: var(--primary);
    box-shadow: 0 0 14px rgba(212, 106, 147, 0.4);
}
.modal-box .avatar-preview .url-input {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    border: 1px solid rgba(212, 106, 147, 0.22);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    outline: none;
}
.modal-box .checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 15px;
    color: var(--text);
}
.modal-box .checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}
.modal-box .btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.modal-box .btn-row button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
}
.modal-box .btn-row .btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.modal-box .btn-row .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.14);
}
.modal-box .btn-row .btn-save {
    background: #D46A93;
    color: #fff;
    box-shadow: 0 4px 16px rgba(212, 106, 147, 0.35);
}
.modal-box .btn-row .btn-save:hover {
    box-shadow: 0 4px 22px rgba(201, 166, 107, 0.55);
    transform: translateY(-1px);
}
.modal-box .btn-row .btn-inject {
    background: #D46A93;
    color: #fff;
    box-shadow: 0 4px 16px rgba(212, 106, 147, 0.35);
}
.modal-box .btn-row .btn-inject:hover {
    box-shadow: 0 4px 22px rgba(201, 166, 107, 0.55);
    transform: translateY(-1px);
}
.modal-box .note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    border-top: 1px solid rgba(212, 106, 147, 0.15);
    padding-top: 10px;
}

/* ===== 选择角色列表 ===== */
.character-select-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}
.character-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 106, 147, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s;
}
.character-select-item:hover {
    background: rgba(212, 106, 147, 0.12);
    border-color: rgba(212, 106, 147, 0.4);
}
.character-select-item .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: #333;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}
.character-select-item .name {
    font-weight: 600;
    color: var(--primary);
}
.character-select-item .desc {
    font-size: 13px;
    color: #888;
}
.character-select-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px 0;
    font-size: 15px;
}

/* ===== 通用弹窗菜单（长按/右键） ===== */
.item-popup-menu {
    position: fixed;
    background: rgba(30, 20, 45, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(212, 106, 147, 0.22);
    border-radius: 14px;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.6),
        0 0 20px rgba(212, 106, 147, 0.1);
    z-index: 200;
    padding: 6px 0;
    min-width: 140px;
    display: none;
    animation: popupFade .15s ease-out;
}
.item-popup-menu.show {
    display: block;
}
@keyframes popupFade {
    from { opacity: 0; transform: scale(.95); }
    to { opacity: 1; transform: scale(1); }
}
.item-popup-item {
    padding: 12px 20px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    transition: background .15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    display: block;
    white-space: nowrap;
    font-family: inherit;
}
.item-popup-item:hover {
    background: rgba(212, 106, 147, 0.15);
}
.item-popup-item:active {
    background: rgba(212, 106, 147, 0.25);
}
.item-popup-item.danger {
    color: #fca5a5;
}
.item-popup-item:first-child {
    border-radius: 14px 14px 0 0;
}
.item-popup-item:last-child {
    border-radius: 0 0 14px 14px;
}

/* 以下弹窗需要脱离手机壳，铺满整个视口 */
#sceneEventModal,
#callCharacterModal,
#callDialogModal,
#standeeFootprintModal,
#emotionEditorModal {
    position: fixed;
    inset: 0;
    border-radius: 0;
}

/* 情绪编辑要盖在视频通话之上 */
#emotionEditorModal {
    z-index: 9500;
}

/* ===== 通话中弹窗 ===== */
.call-modal-box {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    min-height: 400px;
}
.call-dialog {
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 106, 147, 0.15);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.call-line {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    word-break: break-word;
}
.call-line.user {
    text-align: right;
}
.call-line.assistant {
    text-align: left;
}
.call-speaker {
    font-weight: 600;
    color: var(--primary);
    margin-right: 4px;
}
.call-line.user .call-speaker {
    color: var(--accent);
}
.call-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    padding: 30px 0;
}
.call-input-area {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.call-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(212, 106, 147, 0.22);
    border-radius: 20px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.call-input-area input::placeholder {
    color: var(--text-dim);
}
.call-input-area input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 106, 147, 0.18);
}
.call-input-area input:disabled {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-dim);
    cursor: not-allowed;
}
.call-input-area .btn-save {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #D46A93;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(212, 106, 147, 0.35);
    transition: all .2s;
}
.call-input-area .btn-save:hover {
    box-shadow: 0 4px 20px rgba(201, 166, 107, 0.55);
    transform: translateY(-1px);
}
.call-input-area .btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 场景事件文本 */
.scene-event-type {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}
.scene-event-type.big {
    color: var(--accent);
    text-shadow: 0 0 12px rgba(201, 166, 107, 0.6);
}
.scene-event-type.small {
    color: var(--primary);
    text-shadow: 0 0 12px rgba(212, 106, 147, 0.6);
}
.scene-event-type.medium {
    color: #f0a35e;
    text-shadow: 0 0 12px rgba(240, 163, 94, 0.55);
}
.scene-event-text {
    font-size: 15px;
    color: var(--text);
    line-height: 1.7;
    text-align: center;
    margin: 8px 0 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 场景事件弹窗 · 三层 */
.scene-stage {
    text-align: center;
}
.scene-stage-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    text-align: center;
    text-shadow: 0 0 20px rgba(212, 106, 147, 0.35);
}
.scene-loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px 0 8px;
}
.scene-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(212, 106, 147, 0.7);
    animation: sceneDotPulse 1.2s infinite ease-in-out;
}
.scene-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.scene-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sceneDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ===== 一键生成弹窗 ===== */
.inject-note {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
    margin-bottom: 8px;
}
.inject-list {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.8;
    padding-left: 20px;
    margin-bottom: 12px;
}
.inject-warn {
    font-size: 13px;
    color: var(--accent);
    line-height: 1.6;
    margin-bottom: 12px;
}
.inject-status {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    padding: 10px 0;
    min-height: 20px;
}

/* ===== 记忆总结设置弹窗 ===== */
#settingsPendingInfo {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
}
#settingsRunProgress {
    margin-top: 8px;
    font-size: 13px;
    color: var(--primary);
    text-align: center;
}

/* ===== 时间弹窗底部提示 ===== */
.modal-box .hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    border-top: 1px solid rgba(212, 106, 147, 0.15);
    padding-top: 10px;
}

/* ===== 场景事件弹窗氛围 ===== */
.scene-modal-small {
    border-color: rgba(212, 106, 147, 0.28) !important;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(212, 106, 147, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}
.scene-modal-big {
    border-color: rgba(201, 166, 107, 0.45) !important;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.65),
        0 0 60px rgba(201, 166, 107, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}
.scene-modal-medium {
    border-color: rgba(240, 163, 94, 0.4) !important;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.62),
        0 0 50px rgba(240, 163, 94, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}
/* ===== 记忆恢复 / 日志浮层 · Dark Stage 局部 ===== */
#memoryRestoreModal, #memoryLogModal {
    background: rgba(12, 8, 16, .78);
}
#memoryRestoreModal .modal-box, #memoryLogModal .modal-box {
    background: var(--surface, #18111F);
    border: 1px solid var(--line, #2A2033);
    border-radius: 14px;
    box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.35));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#memoryRestoreModal h3, #memoryLogModal h3 {
    font-family: var(--serif, "Noto Serif SC", Georgia, serif);
    font-size: 20px;
    color: var(--ink, #F6F0F4);
    text-shadow: none;
}
#memoryRestoreModal .btn-save, #memoryLogModal .btn-save {
    background: var(--stage, #D46A93);
    color: var(--stage-ink, #1A0C14);
    border: none;
    border-radius: 10px;
}
#memoryRestoreModal .btn-save:hover, #memoryLogModal .btn-save:hover {
    background: var(--stage-hi, #E783A8);
}
#memoryRestoreModal .btn-cancel, #memoryLogModal .btn-cancel {
    background: transparent;
    border: 1px solid rgba(201, 166, 107, .55);
    color: var(--champagne, #C9A66B);
    border-radius: 10px;
}
#memoryRestoreModal input, #memoryLogModal input {
    background: var(--bg2, #120D17);
    border: 1px solid var(--line2, #4A3A58);
    border-radius: 10px;
    color: var(--ink, #F6F0F4);
}
#memoryRestoreModal input:focus, #memoryLogModal input:focus {
    outline: none;
    border-color: var(--stage, #D46A93);
    box-shadow: 0 0 0 2px rgba(233, 179, 200, .35);
}
.memory-mode-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: #18111F;
    background-image:
        linear-gradient(45deg, transparent 50%, #C9A66B 50%),
        linear-gradient(135deg, #C9A66B 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    border: 1px solid #2A2033;
    border-radius: 10px;
    color: #F6F0F4;
    font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    padding: 10px 36px 10px 12px;
    margin: 4px 0 10px;
}
.memory-mode-select:focus {
    outline: none;
    border-color: #D46A93;
    box-shadow: 0 0 0 2px rgba(233,179,200,.28);
}
/* 人设精华生成 · Dark Stage 次按钮 */
.essence-gen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 34px;
    margin-top: 8px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid rgba(201, 166, 107, .55);
    border-radius: 10px;
    color: #C8BCCB;
    font-size: 12px;
    cursor: pointer;
}
.essence-gen-btn:hover { border-color: #C9A66B; color: #F6F0F4; }
.essence-gen-btn:disabled { opacity: .5; cursor: default; }