/* 02 聊天（不显示底栏）+ 上下文面板 + 语音通话 */
.chat {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
}

/* 顶栏 */
.chat-head {
  flex: none; display: flex; align-items: flex-end; gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 44px) 8px 10px 4px;
  background: rgba(238, 244, 251, .94); border-bottom: 1px dashed rgba(92, 132, 177, .35);
  position: relative; z-index: 3;
}
.icon-btn { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.icon-btn svg { stroke: var(--c-ink); }
.chat-avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--c-paper); border: 2px solid var(--c-blue); object-fit: cover;
  display: flex; align-items: center; justify-content: center;
}
.chat-who { flex: 1; min-width: 0; margin-left: 6px; }
.chat-who b { display: block; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c-ink-2); margin-top: 2px; }
.chat-who span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-blue); }
.ctx-chip {
  height: 32px; margin-bottom: 6px; padding: 0 10px 0 6px; border-radius: 16px;
  background: var(--c-paper); box-shadow: 0 2px 6px rgba(var(--c-shadow), .12);
  display: flex; align-items: center; gap: 6px; font-family: var(--f-mono); font-size: 12px;
}
.ctx-chip .ring-bg { stroke: var(--c-paper-blue); }
.ctx-chip .ring { stroke: var(--c-accent); transition: stroke-dasharray .4s ease; }
.ctx-chip.warn .ring { stroke: var(--c-pink); }

/* 消息区 */
.msgs {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 12px;
}
.msgs .older { align-self: center; font-size: 12px; color: var(--c-ink-2); height: 32px; padding: 0 12px; }
.day-tape {
  align-self: center; background: var(--c-paper-pink); padding: 3px 14px;
  font-family: var(--f-mono); font-size: 11px; color: var(--c-pink-ink); transform: rotate(-1deg);
}
.row { display: flex; flex-direction: column; gap: 8px; max-width: 84%; align-items: flex-start; }
.row.her { align-self: flex-end; align-items: flex-end; }
.row.sys { align-self: center; max-width: 100%; }
.time { font-family: var(--f-mono); font-size: 11px; color: var(--c-ink-2); }

.bubble {
  position: relative; padding: 11px 14px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 4px 10px rgba(var(--c-shadow), .10), 0 1px 2px rgba(var(--c-shadow), .08);
}
.row.him .bubble { background: var(--bub-him); border-radius: var(--bub-him-radius); }
.row.her .bubble { background: var(--bub-her); border-radius: var(--bub-her-radius); }
.row.him.first .bubble::before {   /* 每段第一条贴一小截胶带 */
  content: ""; position: absolute; left: -8px; top: -6px; width: 30px; height: 16px; transform: rotate(-30deg);
  background: repeating-linear-gradient(90deg, var(--tape-blue-a) 0 6px, var(--tape-blue-b) 6px 12px);
}
.bubble.pending { color: var(--c-ink-2); }
.dots { display: flex; gap: 5px; padding: 4px 2px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-blue); animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* 思考 */
.think { border: 1.5px dashed rgba(92, 132, 177, .5); border-radius: 15px; background: rgba(255, 253, 248, .6); max-width: 280px; }
.think > button { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; font-size: 12px; color: var(--c-ink-2); }
.think > button svg { stroke: var(--c-ink-2); transition: transform .2s ease; }
.think[data-open] { border-radius: 10px; }
.think[data-open] > button .chev { transform: rotate(180deg); }
.think .think-body { display: none; padding: 0 12px 10px; font-size: 13px; line-height: 1.7; color: var(--c-ink-2); font-style: italic; white-space: pre-wrap; }
.think[data-open] .think-body { display: block; }

/* 命令行 */
.term { width: 290px; max-width: 100%; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 10px rgba(var(--c-shadow), .12); }
.term > button { width: 100%; height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--c-term-bar); font-size: 12px; text-align: left; }
.term .lights { display: flex; gap: 4px; }
.term .lights i { width: 7px; height: 7px; border-radius: 50%; display: block; background: var(--dot-1); }
.term .lights i:nth-child(2) { background: var(--dot-2); } .term .lights i:nth-child(3) { background: var(--dot-3); }
.term .state { margin-left: auto; color: var(--c-ok); }
.term .state.fail { color: var(--c-fail); }
.term .state.run { color: var(--c-ink-2); }
.term pre {
  margin: 0; background: var(--c-paper); padding: 10px 12px; font-family: var(--f-mono); font-size: 12px; line-height: 1.7;
  color: var(--c-ink); white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto;
}
.term pre .pr { color: var(--c-pink-ink); }
.term pre .out { color: var(--c-ink-2); }
.term[data-closed] pre { display: none; }

/* 语音条 */
.voice {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-width: 150px;
  box-shadow: 0 4px 10px rgba(var(--c-shadow), .10);
}
.row.him .voice { background: var(--bub-him); border-radius: var(--bub-him-radius); }
.row.her .voice { background: var(--bub-her); border-radius: var(--bub-her-radius); flex-direction: row-reverse; }
.voice .play { width: 30px; height: 30px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.row.him .voice .play { background: var(--c-paper-blue); }
.row.her .voice .play { background: var(--c-paper); }
.voice .play svg { fill: var(--c-ink); }
.voice .wave { display: flex; align-items: center; gap: 2px; height: 22px; }
.voice .wave i { width: 3px; border-radius: 2px; display: block; opacity: .45; }
.row.him .voice .wave i { background: var(--wave-him); }
.row.her .voice .wave i { background: var(--wave-her); }
.voice .wave i.on { opacity: 1; }
.voice .dur { font-family: var(--f-mono); font-size: 11px; }
.transcript { font-size: 12px; color: var(--c-ink-2); max-width: 240px; }
.row.her .transcript { text-align: right; }

/* 图片：拍立得 */
.photo { background: var(--c-paper); padding: 6px 6px 18px; box-shadow: 0 5px 12px rgba(var(--c-shadow), .14); position: relative; transform: rotate(3deg); }
.row.him .photo { transform: rotate(-3deg); }
.photo::before {
  content: ""; position: absolute; left: 50%; top: -8px; width: 42px; height: 16px; margin-left: -21px; transform: rotate(-4deg);
  background: repeating-linear-gradient(135deg, var(--tape-pink-a) 0 5px, var(--tape-pink-b) 5px 10px);
}
.photo img { width: 140px; max-height: 180px; object-fit: cover; }

/* 文件 */
.file {
  width: 232px; max-width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  box-shadow: 0 4px 10px rgba(var(--c-shadow), .10);
}
.row.him .file { background: var(--bub-him); border-radius: 4px 12px 12px 12px; }
.row.her .file { background: var(--bub-her); border-radius: 12px 4px 12px 12px; }
.file .ext {
  width: 36px; height: 44px; flex: none; border-radius: 4px; position: relative;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px;
  font-family: var(--f-mono); font-size: 10px; font-weight: 700; color: var(--c-pink-ink); background: var(--c-paper);
}
.row.him .file .ext { background: var(--c-paper-blue); color: var(--c-ink); }
.file .meta { min-width: 0; flex: 1; }
.file .meta b { display: block; font-size: 14px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .meta span { font-family: var(--f-mono); font-size: 11px; color: var(--c-ink-2); }
.file svg { stroke: var(--c-accent); }

/* 通话记录 */
.call-rec {
  display: flex; align-items: center; gap: 6px; background: var(--c-paper); padding: 5px 12px; border-radius: 14px;
  font-size: 12px; color: var(--c-ink-2); box-shadow: 0 2px 6px rgba(var(--c-shadow), .10);
}
.call-rec svg { stroke: var(--c-ink-2); }

/* 输入栏 */
.composer {
  flex: none; position: relative; margin: 0 10px calc(env(safe-area-inset-bottom, 0px) + 14px);
  height: 58px; background: var(--c-paper); border-radius: 14px; box-shadow: 0 6px 16px rgba(var(--c-shadow), .14);
  display: flex; align-items: center; gap: 2px; padding: 0 6px; z-index: 2;
}
.composer::before {
  content: ""; position: absolute; left: 24px; top: -8px; width: 44px; height: 16px; transform: rotate(-5deg);
  background: repeating-linear-gradient(90deg, var(--tape-blue-a) 0 6px, var(--tape-blue-b) 6px 12px);
}
.composer .icon-btn svg { stroke: var(--c-accent); }
.composer [data-plus] svg { transition: transform .2s ease; }
.chat[data-plus-open] .composer [data-plus] { background: var(--c-paper-blue); }
.chat[data-plus-open] .composer [data-plus] svg { transform: rotate(45deg); stroke: var(--c-ink); }
.composer textarea {
  flex: 1; min-width: 0; height: 40px; max-height: 40px; resize: none; border: 0; outline: none; background: transparent;
  border-bottom: 1.5px dashed rgba(92, 132, 177, .45); font: inherit; font-size: 16px; color: var(--c-ink); padding: 9px 0 0; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--c-ink-2); }
.composer .send { background: var(--c-blue); }
.composer .send svg { stroke: var(--c-paper); }
.composer .send:disabled { opacity: .5; }
.hold {
  flex: 1; height: 40px; border-radius: 20px; background: var(--c-paper-blue); font-size: 14px;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.hold[data-recording] { background: var(--c-paper-pink); color: var(--c-pink-ink); }

/* 加号菜单 */
.plus-panel {
  flex: none; display: none; background: var(--c-paper-blue); border-radius: 22px 22px 0 0;
  padding: 24px 18px calc(env(safe-area-inset-bottom, 0px) + 24px); margin-top: -2px;
  grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.chat[data-plus-open] .plus-panel { display: grid; }
.chat[data-plus-open] .composer { margin-bottom: 12px; }
.plus-panel button { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; }
.plus-panel button:nth-child(odd) { transform: rotate(-2deg); }
.plus-panel button:nth-child(even) { transform: rotate(2deg); }
.plus-panel .tile {
  width: 62px; height: 62px; border-radius: 16px; background: var(--c-paper);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(var(--c-shadow), .12);
}
.plus-panel .tile svg { stroke: var(--c-accent); }
.plus-panel .tile.pink { background: var(--c-paper-pink); }
.plus-panel .tile.pink svg { stroke: var(--c-pink-ink); }

/* 录音时的提示 */
.rec-tip {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 4;
  background: var(--c-paper); border-radius: 16px; padding: 14px 20px; text-align: center;
  box-shadow: 0 8px 20px rgba(var(--c-shadow), .2); font-size: 13px; display: none;
}
.chat[data-recording] .rec-tip { display: block; }
.rec-tip b { display: block; font-family: var(--f-mono); font-size: 22px; margin-bottom: 4px; }
.rec-tip.cancel { color: var(--c-pink-ink); }

/* 弹层（上下文） */
.sheet-layer { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-layer .scrim { position: absolute; inset: 0; background: var(--c-scrim); }
.sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--c-paper); border-radius: 24px 24px 0 0; padding: 12px 22px calc(env(safe-area-inset-bottom, 0px) + 24px);
  box-shadow: 0 -8px 24px rgba(var(--c-shadow), .18); animation: up .24s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--c-paper-blue); margin: 0 auto; }
.sheet h2 { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 0; font-size: 17px; }
.sheet h2 .script { font-size: 30px; }
.model-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; position: relative; }
.model-chip { height: 34px; padding: 0 12px; border-radius: 17px; background: var(--c-paper-blue); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.model-chip b { font-family: var(--f-mono); }
.model-chip svg { stroke: var(--c-ink); }
.model-row a { font-size: 12px; color: var(--c-ink-2); height: 34px; display: flex; align-items: center; }
.model-list {
  position: absolute; left: 0; top: 40px; z-index: 2; min-width: 220px; background: var(--c-paper); border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 20px rgba(var(--c-shadow), .2);
}
.model-list button { display: flex; width: 100%; height: 40px; align-items: center; gap: 8px; padding: 0 10px; border-radius: 8px; font-family: var(--f-mono); font-size: 13px; }
.model-list button[aria-checked="true"] { background: var(--c-paper-blue); font-weight: 700; }
.ctx-total { display: flex; align-items: baseline; justify-content: space-between; margin-top: 12px; }
.ctx-total .mono b { font-size: 30px; }
.ctx-total .mono span { font-size: 14px; color: var(--c-ink-2); }
.ctx-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--c-grid-bg); margin-top: 10px; }
.ctx-bar i { display: block; height: 100%; }
.ctx-parts { margin-top: 12px; }
.ctx-parts div { display: flex; align-items: center; gap: 10px; height: 46px; border-bottom: 1px dashed rgba(92, 132, 177, .3); }
.ctx-parts .sq { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.ctx-parts .nm { flex: 1; min-width: 0; font-size: 14px; }
.ctx-parts .nm small { display: block; font-size: 11px; color: var(--c-ink-2); }
.ctx-parts .sz { font-family: var(--f-mono); font-size: 13px; }
.ctx-note { font-size: 12px; color: var(--c-ink-2); margin-top: 12px; line-height: 1.6; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.btn { height: 48px; border-radius: 24px; font-size: 16px; background: var(--c-paper); border: 1.5px solid var(--c-blue); }
.btn.primary { background: var(--c-blue); color: var(--c-paper); font-weight: 600; border: 0; }
.btn:disabled { opacity: .55; }

/* 小提示条 */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 110px); transform: translateX(-50%); z-index: 40;
  background: var(--c-paper); padding: 10px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 6px 16px rgba(var(--c-shadow), .2);
  animation: up .2s ease;
}

/* 语音通话 */
.call {
  height: 100vh; height: 100dvh; position: relative; overflow: hidden; text-align: center;
  background-color: var(--c-grid-bg);
}
.call::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle 260px at 50% 300px, rgba(255, 253, 248, .85), transparent 70%); pointer-events: none; }
.call-top { position: relative; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 44px) 8px 0; }
.call-top .script { font-size: 28px; }
.halo { position: relative; width: 250px; height: 250px; margin: 40px auto 0; display: flex; align-items: center; justify-content: center; }
.halo i { position: absolute; border-radius: 50%; }
.halo i:nth-child(1) { inset: 0; border: 1.5px dashed rgba(92, 132, 177, .35); }
.halo i:nth-child(2) { inset: 22px; border: 2px solid rgba(143, 185, 226, .45); transition: transform .12s ease; }
.halo i:nth-child(3) { inset: 44px; background: rgba(221, 235, 247, .9); transition: transform .12s ease; }
.halo .face {
  position: relative; width: 132px; height: 132px; border-radius: 50%; background: var(--c-paper); border: 4px solid var(--c-paper);
  box-shadow: 0 8px 20px rgba(var(--c-shadow), .18); display: flex; align-items: center; justify-content: center; object-fit: cover;
}
.call-name { position: relative; font-size: 22px; font-weight: 600; margin-top: 16px; }
.call-state { position: relative; font-family: var(--f-mono); font-size: 14px; color: var(--c-ink-2); margin-top: 6px; }
.captions {
  position: relative; margin: 26px 26px 0; height: 112px; overflow: hidden; text-align: left;
  border-radius: 6px; padding: 0 16px; font-size: 14px; line-height: 28px; transform: rotate(-.8deg);
  background-color: var(--c-paper); background-image: repeating-linear-gradient(transparent 0 27px, var(--c-line-blue) 27px 28px);
  box-shadow: 0 6px 16px rgba(var(--c-shadow), .14);
  display: flex; flex-direction: column; justify-content: flex-start;
}
.captions .me { color: var(--c-ink-2); }
.captions .live { color: var(--c-blue); }
.call-btns { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 48px); display: flex; justify-content: center; gap: 34px; align-items: flex-start; }
.call-btns button { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--c-ink-2); }
.call-btns .c { width: 62px; height: 62px; border-radius: 50%; background: var(--c-paper); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(var(--c-shadow), .14); }
.call-btns .c svg { stroke: var(--c-ink); }
.call-btns button[aria-pressed="true"] .c { background: var(--c-paper-blue); }
.call-btns .hang .c { width: 74px; height: 74px; background: var(--c-hangup); box-shadow: 0 6px 14px rgba(184, 106, 124, .35); }
.call-btns .hang .c svg { stroke: var(--c-paper); transform: rotate(135deg); }
.call-btns .hang { color: var(--c-pink-ink); }

@media (prefers-reduced-motion: reduce) {
  .dots i { animation: none; opacity: .7; }
}


/* 气泡操作栏与编辑弹层 */
.message-actions {
  position: absolute; z-index: 8; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 142px);
  display: flex; align-items: center; gap: 8px; padding: 9px;
  background: var(--c-paper); border: 1px solid rgba(92,132,177,.28); border-radius: 18px;
  box-shadow: 0 8px 24px rgba(var(--c-shadow),.2);
}
.message-actions[hidden] { display: none; }
.message-actions button { flex: 1; min-height: 42px; border-radius: 12px; background: var(--c-paper-blue); font-size: 14px; }
.message-actions button:disabled { opacity: .42; }
.message-actions .danger { color: var(--c-pink-ink); background: var(--c-paper-pink); }
.message-actions .action-close { flex: 0 0 38px; font-size: 22px; background: transparent; }
.row[data-selected] .bubble { outline: 2px solid rgba(92,132,177,.7); outline-offset: 2px; }
.message-edit-layer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; }
.message-edit-scrim { position: absolute; inset: 0; background: rgba(20,30,45,.38); }
.message-edit-dialog { position: relative; width: min(100%, 440px); padding: 18px; border-radius: 20px; background: var(--c-paper); box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.message-edit-dialog h3 { margin: 0 0 12px; font-size: 17px; }
.message-edit-dialog textarea { box-sizing: border-box; width: 100%; min-height: 130px; resize: vertical; padding: 11px; border: 1px solid rgba(92,132,177,.38); border-radius: 12px; background: var(--c-paper-blue); color: var(--c-ink); font: inherit; line-height: 1.5; }
.message-edit-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.message-edit-buttons button { min-width: 76px; min-height: 40px; padding: 0 12px; border-radius: 12px; background: var(--c-paper-blue); }
.message-edit-buttons [data-edit-save] { background: var(--c-blue); color: white; }

/* 附件暂存预览条 */
.composer-wrap {
  flex: none; position: relative; margin: 0 10px calc(env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 2; display: flex; flex-direction: column; gap: 6px;
}
.composer-wrap .composer {
  margin: 0;
}
.composer-preview {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--c-paper); border-radius: 12px; box-shadow: 0 4px 12px rgba(var(--c-shadow), .1);
  width: fit-content; max-width: 100%; box-sizing: border-box;
}
.composer-preview[hidden] { display: none !important; }
.prev-item {
  position: relative; display: flex; align-items: center; gap: 6px;
}
.prev-item img {
  width: 50px; height: 50px; object-fit: cover; border-radius: 8px; border: 1px solid rgba(92, 132, 177, .3);
}
.prev-file {
  background: rgba(92, 132, 177, .1); padding: 4px 8px; border-radius: 6px; font-size: 13px; color: var(--c-ink);
}
.prev-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff;
  border: none; font-size: 12px; cursor: pointer; margin-left: 4px;
}
