/* ============================================================
   css/panels/panels-memory-context.css — 记忆上下文查看器（跑团风格重构）
   设计系统：暖米色底 · 玫瑰色点缀 · 金色细线分隔 · 卡片气泡
   ============================================================ */

#more-memory-context {
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 0 calc(16px + var(--kbd-h, 0px) + env(safe-area-inset-bottom, 0px));
    /* ★ 隐藏右侧滚动条：内容多了不再被 4px 滚动条挤窄页面（触摸滑动仍正常） */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#more-memory-context::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ===== Hero 区 ===== */
.mctx-hero { text-align: center; padding: 12px 14px 6px; }
.mctx-hero-en {
    font-family: var(--font-handwriting);
    font-size: 20px; line-height: 1.2; color: var(--accent-rose); opacity: 0.9;
}
.mctx-hero-zh {
    font-size: 18px; font-weight: 600; color: var(--text-primary);
    font-family: var(--font-body); letter-spacing: 1px;
}

/* ===== 信息提示 ===== */
.mctx-info {
    margin: 0 14px 10px;
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-solid);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.03);
    box-shadow: var(--shadow-xs);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    line-height: 1.6;
}

.mctx-info-text {
    flex: 1;
}

/* ===== 轮次翻页导航 ===== */
.mctx-round-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 0 8px;
}
.mctx-round-nav-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1px solid var(--rose);
    background: transparent;
    color: var(--rose);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-round-nav-btn:hover {
    background: var(--rose-light);
    box-shadow: var(--shadow-glow);
    transform: scale(1.08);
}
.mctx-round-nav-btn:active { transform: scale(0.92); }
.mctx-round-nav-btn.disabled {
    opacity: 0.3; pointer-events: none;
}
.mctx-round-nav-label {
    font-family: var(--font-decorative); font-style: italic;
    font-size: 12px; color: var(--text-secondary); letter-spacing: 0.5px;
}

/* ===== 轮次翻页视口（transform 平移，高度跟随当前轮内容，整页连续滚动）===== */
.mctx-round-viewport {
    overflow: hidden;
    touch-action: pan-y;
    /* ★ flex-shrink:0 防长轮被压缩裁剪：父容器是 flex column，
       缺这一条时长轮内容会被 flex 压缩到视口剩余高度 + overflow:hidden 裁剪，
       页面自身不溢出 → 上下滚动锁死、完整内容看不到 */
    flex-shrink: 0;
}
.mctx-round-track {
    display: flex;
    align-items: flex-start;
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ===== 轮次头部 ===== */
.mctx-round-label {
    font-family: var(--font-decorative); font-style: italic;
}
.mctx-round {
    flex: 0 0 100%;
    min-width: 100%;
    box-sizing: border-box;
    padding: 8px 12px 16px;
    margin: 0;
    border-bottom: none;
}
.mctx-round-header {
    font-family: var(--font-decorative); font-style: italic;
    font-size: 11px;
    color: var(--gold); opacity: 0.65;
    margin-bottom: 8px;
    padding-left: 2px;
    letter-spacing: 1px;
    display: flex; align-items: center; gap: 6px;
    position: relative;
}
.mctx-round-header::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent-rose);
    opacity: 0.5;
    flex-shrink: 0;
}
.mctx-round-header::after {
    content: ''; flex: 1; height: 1px; background: var(--gold); opacity: 0.15;
    margin-left: 2px;
    order: 1;
}

/* ===== 消息条目 — 卡片式 ===== */
.mctx-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-xs);
    border: 1px solid rgba(0,0,0,0.025);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.mctx-msg:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* User vs AI vs System 配色区分 */
.mctx-msg.user-msg {
    background: rgba(201,168,168,0.05);
    border-left: 2px solid var(--accent-rose);
}
.mctx-msg.ai-msg {
    background: var(--surface-solid);
    border-left: 2px solid var(--gold);
}
.mctx-msg.system-msg {
    background: rgba(168,184,160,0.04);
    border-left: 2px solid var(--sage);
}

.mctx-dot {
    width: 6px; height: 6px; border-radius: 50%;
    margin-top: 7px; flex-shrink: 0;
}
.user-dot { background: var(--accent-rose); box-shadow: 0 0 4px rgba(201,168,168,0.4); }
.ai-dot   { background: var(--gold); box-shadow: 0 0 4px rgba(196,168,106,0.3); }
.system-dot { background: var(--sage); box-shadow: 0 0 4px rgba(168,184,160,0.3); }

.mctx-msg-body {
    flex: 1; min-width: 0;
}
.mctx-msg-role {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 3px;
    letter-spacing: 0.3px;
}
.mctx-msg-content {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
    word-break: break-word;
    transition: opacity 0.2s ease;
}
/* ===== 跨场景来源小签（会客厅里发生的事，别跟私聊的混在一起看）=====
   只给带来源标签的系统行加；自绘、无线框默认外观、颜色走系统行同一族（sage）。 */
.mctx-msg-src { margin-bottom: 3px; }
.mctx-src-chip {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 10px;
    line-height: 1.5;
    letter-spacing: 0.3px;
    padding: 1px 7px;
    border-radius: 999px;
    color: var(--text-secondary);
    background: rgba(168,184,160,0.14);
}
.mctx-msg-time {
    font-family: var(--font-decorative); font-style: italic;
    font-size: 10px; color: var(--text-muted);
    margin-top: 4px; letter-spacing: 0.5px;
}

/* ===== 轮次统一操作按钮（编辑/删除/复制，右侧三图标）===== */
.mctx-round-actions {
    display: flex; align-items: center; gap: 2px;
    order: 2; flex-shrink: 0; margin-left: 6px;
}
.mctx-round-icon-btn {
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-round-icon-btn:hover {
    color: var(--rose);
    border-color: var(--rose);
    background: var(--rose-light);
    box-shadow: var(--shadow-glow);
    transform: scale(1.1);
}
.mctx-round-icon-btn:active { transform: scale(0.9); }

/* ===== 气泡内操作按钮（删除× / 保存✓）===== */
.mctx-msg-del-x {
    position: absolute;
    top: 6px; right: 6px;
    width: 24px; height: 24px; border-radius: 50%;
    border: none;
    background: rgba(201,168,168,0.18);
    color: var(--rose);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; z-index: 2;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    /* ★ 去掉入场 animation：删除/编辑模式切换或后台刷新时不再重放 → × 不闪动 */
}
.mctx-msg-del-x:hover {
    background: rgba(201,168,168,0.35);
    color: #B88080;
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(201,160,160,0.25);
}
.mctx-msg-del-x:active { transform: scale(0.9); }

/* ===== 轮次编辑/删除模式 ===== */
/* 编辑模式：轮次卡片撑高，显示保存按钮 */
.mctx-round.editing .mctx-msg {
    position: relative;
    box-shadow: 0 0 0 1px rgba(201,168,168,0.15);
}
.mctx-round.editing .mctx-msg-content {
    display: none;
}
.mctx-round.editing .mctx-edit-area {
    display: block !important;
    min-height: 60px;
}

/* 删除模式：轮次卡片玫瑰色蒙层，显示×按钮 */
.mctx-round.deleting .mctx-msg {
    position: relative;
    border-color: rgba(201,168,168,0.3);
    background: linear-gradient(135deg, var(--surface-solid) 0%, rgba(201,168,168,0.04) 100%);
}
.mctx-round.deleting .mctx-msg::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    background: rgba(201,168,168,0.03);
    pointer-events: none; z-index: 1;
}

/* 轮次级工具栏（编辑/删除模式切换按钮）*/
.mctx-round-toolbar {
    display: flex; align-items: center; gap: 4px;
    margin-left: auto; flex-shrink: 0;
    order: 2;   /* ★ 顶到圆头最右侧、与「编辑/删除」按钮同一位置，点起来顺手 */
    animation: mctxFadeIn 0.18s ease;
}

.mctx-edit-area {
    width: 100%; min-height: 72px; padding: 12px 14px;
    border: 1.5px solid var(--rose); border-radius: 12px;
    font-family: var(--font-body); font-size: 13px; line-height: 1.6;
    color: var(--text-primary); background: var(--bg-chat);
    resize: vertical; box-sizing: border-box;
    outline: none; opacity: 1;
    box-shadow: 0 0 0 3px rgba(201,168,168,0.08), var(--shadow-xs);
    transition: box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.2s ease;
}
.mctx-edit-area:focus {
    border-color: var(--rose-hover);
    box-shadow: 0 0 0 4px rgba(201,168,168,0.14), var(--shadow-glow);
}

/* ===== 空状态 ===== */
.mctx-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}
.mctx-empty-flourish {
    font-family: var(--font-handwriting);
    font-size: 40px;
    color: var(--gold);
    opacity: 0.35;
    margin-bottom: 4px;
    line-height: 1;
}
.mctx-empty-deco {
    font-family: var(--font-handwriting);
    font-size: 28px;
    color: var(--accent-rose);
    opacity: 0.45;
    margin-bottom: 12px;
}
.mctx-empty-text {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}
.mctx-empty-hint {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
    letter-spacing: 0.3px;
}

/* ===== Event Overview Cards（横向滑动） ===== */
.mctx-overview-section {
    margin: 0 14px 10px;
}
.mctx-overview-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-left: 2px;
}
.mctx-overview-deco {
    font-family: var(--font-display, 'Playfair Display', Georgia, serif);
    font-size: 11px;
    font-style: italic;
    color: var(--gold);
    opacity: 0.6;
    letter-spacing: 1px;
}
.mctx-overview-title {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    flex: 1;
}

/* ===== 统一工具栏 ===== */
.mctx-overview-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.mctx-ov-mode-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-ov-mode-btn:hover {
    color: var(--rose);
    border-color: var(--rose);
    background: var(--rose-light);
    box-shadow: var(--shadow-glow);
    transform: scale(1.1);
}
.mctx-ov-mode-btn:active { transform: scale(0.92); }
/* 保存按钮hover变绿色 */
.mctx-ov-done-btn:hover {
    color: var(--sage); border-color: var(--sage);
    background: var(--sage-light);
    box-shadow: 0 0 12px rgba(168,184,160,0.2);
}
/* 取消按钮hover变暖玫瑰 */
.mctx-ov-cancel-btn:hover {
    color: #C4A0A0; border-color: #C4A0A0;
    background: rgba(196,160,160,0.08);
    box-shadow: 0 0 12px rgba(196,160,160,0.15);
}
/* 删除模式激活态 */
.mctx-ov-mode-btn.active {
    color: #C4A0A0; border-color: #C4A0A0;
    background: rgba(196,160,160,0.12);
}
.mctx-overview-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.mctx-overview-track::-webkit-scrollbar { height: 0; }
.mctx-overview-card {
    flex: 0 0 auto;
    position: relative;
    width: 200px;
    padding: 12px 14px;
    background: var(--surface-solid);
    border: 1px solid rgba(196, 168, 106, 0.15);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
    scroll-snap-align: start;
    overflow: hidden;
    /* ★ 去背景/边框过渡：删除/编辑模式切换时卡片背景瞬间切换，不整体闪色 */
    transition: box-shadow 0.2s ease, transform 0.15s ease, opacity 0.25s ease, width 0.2s ease;
}
.mctx-overview-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.mctx-ov-time {
    font-family: var(--font-display, 'Playfair Display', Georgia, serif);
    font-size: 10px;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}
.mctx-ov-text {
    font-family: var(--font-body, 'Noto Serif SC', serif);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 事件概览正文：默认截断 3 行，点击展开全文（80 字内短文，不另生成摘要） */
.mctx-ov-content-wrap {
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.mctx-ov-content-wrap:hover { opacity: 0.88; }
.mctx-ov-content-wrap:active { opacity: 0.7; }
.mctx-ov-content {
    font-family: var(--font-body, 'Noto Serif SC', serif);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    word-break: break-word;
    position: relative;
    max-height: 4.5em;   /* 收起 = 3 行（line-height 1.5 × 3，相对自身字号，随字重自适应） */
    transition: max-height 0.32s ease;
}
.mctx-ov-content.expanded {
    /* ★ 用 max-height 平滑展开，替代 -webkit-line-clamp：
       切 line-clamp 会触发 WebKit 文字重渲染 → 字闪动；max-height 只加高不重排版，不闪 */
    max-height: 1000px;
}
/* 收起时的底部渐隐遮罩（替代省略号，韩系法式更优雅；展开后淡出） */
.mctx-ov-content .mctx-ov-fade {
    position: absolute; left: 0; right: 0; bottom: 0; height: 24px;
    background: linear-gradient(to top, var(--surface-solid) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.32s ease;
}
.mctx-ov-content.expanded .mctx-ov-fade { opacity: 0; }
.mctx-ov-toggle {
    display: inline-block;
    margin-top: 6px;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--rose);
    letter-spacing: 0.5px;
    user-select: none;
}

/* ===== 底部提示 ===== */
.mctx-footer {
    padding: 8px 16px;
    font-family: var(--font-decorative); font-style: italic;
    font-size: 9px; color: var(--text-muted);
    border-top: 1px solid rgba(196,168,106,0.15);
    text-align: center; letter-spacing: 0.5px;
}

/* ===== 骨架屏加载动画 ===== */
.mctx-skeleton-line {
    background: linear-gradient(90deg, var(--surface-solid) 25%, rgba(180,170,155,0.12) 50%, var(--surface-solid) 75%);
    background-size: 200% 100%;
    animation: mctx-shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes mctx-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== 消息元数据行（时间+已编辑标记） ===== */
.mctx-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.mctx-edited-tag {
    font-family: var(--font-decorative); font-style: italic;
    font-size: 9px; color: var(--gold); opacity: 0.7;
    letter-spacing: 0.3px;
}

/* ===== 复制按钮（已弃用，保留兼容）===== */
.mctx-copy-btn {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-copy-btn:hover {
    color: var(--sage); border-color: var(--sage); background: var(--sage-light);
    box-shadow: 0 0 12px rgba(168,184,160,0.2); transform: scale(1.08);
}
.mctx-copy-btn:active { transform: scale(0.94); }

/* ===== 帮助按钮 ===== */
.mctx-help-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 6px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); cursor: pointer; padding: 0; margin-left: 6px;
    vertical-align: middle;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-help-btn:hover {
    color: var(--gold); border-color: var(--gold);
    box-shadow: 0 0 8px rgba(196,168,106,0.2); transform: scale(1.1);
}

/* ===== 帮助提示气泡 ===== */
.mctx-help-bubble {
    margin: 0 14px 10px;
    padding: 12px 14px;
    background: var(--surface-solid);
    border: 1px solid rgba(196,168,106,0.2);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    animation: mctxFadeIn 0.25s ease;
}
@keyframes mctxFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.mctx-help-text {
    font-family: var(--font-body);
    font-size: 12px; color: var(--text-secondary);
    line-height: 1.6; margin-bottom: 8px;
}
.mctx-help-close {
    font-family: var(--font-body); font-size: 11px;
    color: var(--rose); background: var(--rose-light);
    border: none; border-radius: 6px; padding: 4px 12px; cursor: pointer;
    transition: all 0.2s ease;
}
.mctx-help-close:hover { background: rgba(201,168,168,0.2); }

/* ===== 重试按钮 ===== */
.mctx-retry-btn {
    margin-top: 14px;
    padding: 8px 20px;
    font-family: var(--font-body); font-size: 12px;
    color: var(--rose); background: var(--rose-light);
    border: 1px solid rgba(201,168,168,0.25);
    border-radius: 20px; cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mctx-retry-btn:hover {
    background: rgba(201,168,168,0.2);
    box-shadow: var(--shadow-glow); transform: translateY(-1px);
}
.mctx-retry-btn:active { transform: scale(0.96); }

/* ===== 事件概览编辑区域 ===== */
.mctx-ov-edit-area {
    margin-top: 4px; margin-bottom: 6px;
    min-height: 88px; font-size: 13px;   /* ★ 编辑框加高，好改内容 */
}

/* ===== 窄屏适配（<370px） ===== */
@media (max-width: 370px) {
    .mctx-overview-card {
        min-width: 140px; max-width: 170px; padding: 10px 12px;
    }
    .mctx-ov-content { font-size: 12px; max-height: 3em; }
    .mctx-msg { padding: 8px 10px; gap: 6px; }
    .mctx-msg-content { font-size: 12px; }
    .mctx-hero-en { font-size: 22px; }
    .mctx-info { padding: 8px 10px; font-size: 11px; }
}

/* ===== 事件概览删除×覆盖按钮 ===== */
.mctx-ov-delete-x {
    position: absolute;
    top: 6px; right: 6px;
    width: 24px; height: 24px; border-radius: 50%;
    border: none;
    background: rgba(201,168,168,0.18);
    color: var(--rose);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; z-index: 2;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    /* ★ 去掉入场 animation：删除/编辑模式切换或后台刷新时不再重放 → × 不闪动 */
}
@keyframes mctxDelXFadeIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}
.mctx-ov-delete-x:hover {
    background: rgba(201,168,168,0.35);
    color: #B88080;
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(201,160,160,0.25);
}
.mctx-ov-delete-x:active { transform: scale(0.9); }

/* ===== 卡片编辑/删除模式状态 ===== */
/* 编辑模式：卡片撑高，textarea全宽 */
.mctx-overview-card.editing {
    width: 240px; min-height: 100px;
}
.mctx-overview-card.editing .mctx-ov-time { display: none; }
.mctx-overview-card.editing .mctx-ov-content { display: none; }
.mctx-overview-card.editing .mctx-ov-content-wrap,
.mctx-overview-card.editing .mctx-ov-toggle { display: none; }
.mctx-overview-card.editing .mctx-ov-edit-area {
    display: block !important;
    min-height: 96px; font-size: 13px;   /* ★ 编辑框加高 */
}

/* 删除模式：玫瑰色蒙层 */
.mctx-overview-card.deleting {
    position: relative;
    border-color: rgba(201,168,168,0.3);
    background: linear-gradient(135deg, var(--surface-solid) 0%, rgba(201,168,168,0.06) 100%);
}
.mctx-overview-card.deleting::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    background: rgba(201,168,168,0.04);
    pointer-events: none; z-index: 1;
}

/* ===== 记忆整理健康提示条（三点→记忆上下文 顶部；复用 mem-health-banner，异常才出现）===== */
#mctx-health-strip .mem-health-banner { margin: 2px 14px 8px; }
