.turn-message-actions {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}

/* Phase D1：通话结束卡只留时间戳，不要分隔线和空动作排 */
.turn-message-actions.is-call-record {
    border-top: 0;
    justify-content: flex-end;
}

/* 主题模式：旧的气泡内朗读/翻译入口让位给统一操作栏；时间落到分隔线下，和动作同层。 */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .chat-tts-play-btn,
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .chat-translate-btn {
    display: none !important;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .turn-message-actions .turn-message-time {
    display: block !important;
    flex: 0 0 auto;
    margin: 0 2px 0 auto !important;
    padding-left: 10px;
    color: inherit;
    font-size: .72rem !important;
    line-height: 26px;
    text-align: right !important;
    white-space: nowrap;
    opacity: .52 !important;
}

.turn-message-action {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: inherit;
    opacity: .6;
    cursor: pointer;
    touch-action: manipulation;
    transition: opacity .15s, background .15s;
}

.turn-message-action:hover,
.turn-message-action:focus-visible,
.turn-message-action[aria-expanded="true"] {
    opacity: .92;
    background: color-mix(in srgb, var(--text) 7%, transparent);
    outline: none;
}

.turn-message-action svg {
    width: 1em;
    height: 1em;
    pointer-events: none;
}

.turn-snapshot-panel {
    margin-top: 8px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--card-bg) 94%, var(--accent) 6%);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    overflow: hidden;
}

.turn-snapshot-panel[hidden] { display: none !important; }

/* Claude 是独立皮肤：蒸馏纪固定继承 Claude 米白纸面，不接受世界主题的全局色变量染色。 */
.chat-ui-mode-claude .turn-snapshot-panel {
    --text: var(--cl-text);
    --card-bg: var(--cl-surface);
    --accent: var(--cl-accent);
    --bg: var(--cl-bg);
    color: var(--cl-text);
    background: var(--cl-surface);
    border-color: var(--cl-border-strong);
    box-shadow: 0 8px 24px rgba(31, 30, 29, .06);
}

/* 锈湖气泡使用浅色纸面，诊断文字也使用纸面的墨色。 */
[data-theme="roots"] #character-chat-screen:not(.chat-ui-mode-claude):not(.chat-ui-mode-chatgpt) .turn-snapshot-panel {
    --text: var(--rl-ink, #2b2119);
    --card-bg: var(--rl-paper, #e7dcc4);
    --accent: var(--rl-ox, #8c3b3b);
    color: var(--text);
    background: var(--card-bg);
}
[data-theme="roots"] #character-chat-screen:not(.chat-ui-mode-claude):not(.chat-ui-mode-chatgpt) .turn-snapshot-panel :is(.turn-snapshot-key, .turn-snapshot-section h4, .turn-snapshot-header span) {
    opacity: .78;
}

.turn-snapshot-panel.is-open {
    animation: turn-snapshot-open .18s ease-out both;
}

@keyframes turn-snapshot-open {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.turn-snapshot-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}

.turn-snapshot-header strong { font-size: 14px; letter-spacing: .08em; }
.turn-snapshot-header span { opacity: .58; font-size: 11px; }

.turn-snapshot-section { margin-top: 12px; }
.turn-snapshot-section h4 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .08em;
    opacity: .58;
}

.turn-snapshot-row {
    display: grid;
    grid-template-columns: minmax(68px, 86px) minmax(0, 1fr);
    gap: 10px;
    padding: 2px 0;
}

.turn-snapshot-key { opacity: .62; }
.turn-snapshot-value { overflow-wrap: anywhere; }
.turn-snapshot-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.turn-snapshot-chip {
    display: inline-flex;
    padding: 1px 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
    border-radius: 999px;
    font-size: 11px;
}

.turn-trace-list { display: grid; gap: 6px; }
.turn-trace-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 9px;
    color: inherit;
    background: color-mix(in srgb, var(--text) 4%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 13%, transparent);
    border-radius: 9px;
    text-align: left;
}
.turn-trace-item:hover,
.turn-trace-item:focus-visible { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.turn-trace-id { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-trace-badge {
    flex: 0 0 auto;
    padding: 1px 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
    border-radius: 999px;
    font-size: 10px;
}
.turn-trace-empty { opacity: .58; font-size: 12px; }

.turn-scope-activation {
    display: grid;
    grid-template-columns: minmax(68px, 86px) minmax(72px, 1fr) 18px;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.turn-scope-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-scope-track {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 11%, transparent);
}
.turn-scope-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}
.turn-scope-score { text-align: right; font-variant-numeric: tabular-nums; opacity: .7; }

.turn-snapshot-diagnostics {
    margin-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}

.turn-snapshot-diagnostics > summary {
    min-height: 44px;
    display: block;
    padding: 12px 0;
    cursor: pointer;
    color: inherit;
    font-size: 11px;
    opacity: 1;
    user-select: none;
}

.turn-runtime-toggle { float: right; opacity: .7; font-size: 10px; }
.turn-runtime-toggle::after { content: ' ＋'; }
.turn-snapshot-diagnostics[open] .turn-runtime-toggle::after { content: ' −'; }
.turn-runtime-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 9px;
}
.turn-runtime-metric { display: grid; gap: 3px; min-width: 0; }
.turn-runtime-metric > span { font-size: 10px; opacity: .72; }
.turn-runtime-metric strong { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.turn-runtime-note { margin: 6px 0 10px; font-size: 11px; line-height: 1.65; opacity: .75; }
.turn-composition-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 9px 0; font-size: 11px; }
.turn-composition-row > span:nth-child(2) { text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.turn-composition-track { grid-column: 1 / -1; height: 4px; border-radius: 3px; overflow: hidden; background: color-mix(in srgb, var(--text) 10%, transparent); }
.turn-composition-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.turn-prompt-sections { margin-top: 12px; }
.turn-prompt-sections > summary { min-height: 36px; display: flex; align-items: center; cursor: pointer; font-size: 11px; }
.turn-prompt-sections > summary::after { content: ' ＋'; margin-left: auto; }
.turn-prompt-sections[open] > summary::after { content: ' −'; }

.turn-snapshot-diagnostics > summary:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
    outline-offset: 2px;
}

.chat-ui-mode-chatgpt .turn-message-actions {
    border-top: 0;
    padding-top: 2px;
    margin-left: -5px;
    gap: 4px;
}

.chat-ui-mode-chatgpt .turn-message-action {
    color: #555;
    opacity: .7;
    width: 28px;
    height: 28px;
}

.chat-ui-mode-chatgpt .turn-message-action:hover,
.chat-ui-mode-chatgpt .turn-message-action:focus-visible {
    opacity: 1;
    color: #222;
    background: rgba(0, 0, 0, .06);
}

.chat-ui-mode-chatgpt .turn-message-action svg {
    width: 18px;
    height: 18px;
}

/* 塔拉 7-22：暗皮（锈湖 roots / 七日谈 qirituan / 夜读残篇 midnight / dark）下动作栏跟随字色 #ececec，
   原 #555 深灰在暗底看不清（与暗皮正文 #ececec 同口径）。 */
html[data-theme="midnight"] #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action,
html:is([data-theme="dark"], [data-theme="qirituan"], [data-theme="roots"]) #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action {
    color: #ececec;
}
html[data-theme="midnight"] #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action:hover,
html[data-theme="midnight"] #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action:focus-visible,
html:is([data-theme="dark"], [data-theme="qirituan"], [data-theme="roots"]) #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action:hover,
html:is([data-theme="dark"], [data-theme="qirituan"], [data-theme="roots"]) #character-chat-screen.chat-ui-mode-chatgpt .turn-message-action:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

/* 塔拉 7-22：已收藏 → thumbup 转实心 + 满不透明（区分收藏过的消息）。turn-transparency.js 挂 .turn-fav-active。
   保持 currentColor 填充（跟随各皮/明暗字色），不额外上强调色以免主题冲突。 */
.turn-message-action.turn-fav-active {
    opacity: 1;
}
.turn-message-action.turn-fav-active svg {
    fill: currentColor;
}

.chat-ui-mode-chatgpt .turn-snapshot-panel {
    background: var(--bg);
    border-color: color-mix(in srgb, var(--text) 14%, transparent);
    box-shadow: none;
}

@media (max-width: 520px) {
    .turn-snapshot-panel { width: min(92vw, 420px); max-width: 100%; padding: 12px; }
    .turn-snapshot-header { align-items: flex-start; flex-direction: column; gap: 2px; }
    /* 通用动作排保持原来的 26/28px 横向节奏；Claude 的独立热区策略由 claude-theme.css 管理。 */
}

@media (prefers-reduced-motion: reduce) {
    .turn-snapshot-panel.is-open { animation: none; }
}

/* ===== 视觉重构刀（2026-08-06）：AZOTH 主题 full/split 展示 =====
   全部规则都锁在 AZOTH 专属作用域内（:not 双排除 = 既不是 Claude 也不是 ChatGPT），
   Claude / ChatGPT 两套主题不被这些规则触碰。 */

/* full AI：气泡外 footer 的内容列 wrapper（气泡 + footer 同宽对齐） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-message-stack {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    max-width: 95%;
    box-sizing: border-box;
    /* footer 绝对定位占位：让下一轮消息不被 footer 重叠 */
    padding-bottom: 28px;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-message-stack > .chat-message-bubble {
    width: 100%;
    max-width: none !important;
    box-sizing: border-box;
}

/* thinking 同源 wrap 内：stack 不再二次限宽（wrap 已按 95%/84% 控宽） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .thinking-bubble-wrap > .azoth-message-stack {
    max-width: 100% !important;
    width: 100% !important;
}

/* full AI footer：左动作排 / 右时间戳，一条消息只有一套。
   绝对定位在 stack 内（宽 = 气泡宽）：短消息按钮行可以比气泡宽（仍左对齐气泡左缘），
   长消息时时间戳右缘正好对齐气泡右缘。 */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-full-footer {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 27px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1px;
}

/* footer 里的动作排去掉旧的内部分界线（气泡里不再有横线） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-full-footer .turn-message-actions {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-full-footer .azoth-footer-time {
    display: block !important;
    flex: 0 0 auto;
    margin: 0 2px 0 auto !important;
    padding: 0;
    font-size: 11px !important;
    line-height: 26px;
    text-align: right !important;
    white-space: nowrap;
    opacity: .52 !important;
}

/* Telegram 末行时间：隐藏 reserve 只占最终文本块末尾的真实宽度（前 N-1 行不受影响） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-time-reserve {
    display: inline-block;
    visibility: hidden;
    white-space: nowrap;
    margin-left: 0.45em;
    font-size: 11px;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-inline-time {
    position: absolute;
    right: 10px;
    bottom: 7px;
    white-space: nowrap;
    font-size: 11px;
    opacity: .52;
    pointer-events: none;
}

/* code/table/图片/语音/工具卡等特殊尾块的 fallback：气泡内独立右对齐小行，不覆盖内容 */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-time-fallback {
    display: block;
    text-align: right;
    margin-top: 4px;
    font-size: 11px;
    opacity: .52;
    white-space: nowrap;
}

/* split 同一轮回复组内段之间紧凑（流式追加 + 历史渲染同构；塔拉真机：2px） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) #character-chat-messages {
    gap: 0 !important;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-same-response-segment {
    margin-bottom: 2px !important;
}

/* split 连续 user 气泡之间紧凑（full + split 都生效；2px，塔拉真机 2026-08-06） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .azoth-consecutive-user {
    margin-bottom: 2px !important;
}

/* Lysander 2026-08-07：split 语音卡时间戳（az-voice-card 专属，不进通用 fallback 契约）
   collapsed：summary 横排内靠右；expanded：absolute 沉转写正文右下（reserve 占最后一行） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .az-voice-card .azoth-voice-time {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .52;
    white-space: nowrap;
}

/* 转写正文是 expanded 时间的定位锚（Lysander P2：time 贴 transcript 自身右下，不是整个 bubble） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .az-voice-card .az-voice-transcript-text {
    position: relative;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .az-voice-card .azoth-voice-time--expanded {
    position: absolute;
    right: 0;
    bottom: 0;
    margin-left: 0;
}

/* Lysander 2026-08-07（塔拉 F12 取证）：AI TTS 语音卡 .chat-voice-message 专属时间戳——
   collapsed：summary 横排内靠右；expanded：absolute 沉转写最后一个 <p> 右下（reserve 占最后一行） */
#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .chat-voice-message .azoth-tts-time {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .52;
    white-space: nowrap;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .chat-voice-message .chat-voice-transcript p:last-child {
    position: relative;
}

#character-chat-screen:not(.chat-ui-mode-chatgpt):not(.chat-ui-mode-claude) .chat-voice-message .azoth-voice-time--expanded {
    position: absolute;
    right: 0;
    bottom: 0;
    margin-left: 0;
}
