/* ══════════════════════════════════════════════════════
   高湾线上交流 · 悬浮对话组件（全站）
   启动器（右下角头像）→ 对话框式浮层面板；/talk 页为聚焦浮窗模式
   设计语言：奶油底、纸白卡片、棕橙点缀，与全站一致
   ══════════════════════════════════════════════════════ */

/* ── 悬浮启动器 ── */
.gw-launcher {
    position: fixed; right: 22px; bottom: 24px; z-index: 900;
    width: 58px; height: 58px; padding: 0; border: none; border-radius: 50%;
    cursor: pointer; background: transparent;
    transition: transform .25s ease, opacity .2s ease;
}
.gw-launcher img {
    width: 58px; height: 58px; border-radius: 50%; display: block;
    border: 2px solid var(--orange); object-fit: cover;
    box-shadow: 0 6px 22px rgba(232, 96, 12, .28), var(--shadow-card);
}
.gw-launcher:hover { transform: scale(1.07); }
.gw-launcher-pulse {
    position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid rgba(232, 96, 12, .45);
    animation: gw-pulse 2.4s ease-out infinite; pointer-events: none;
}
@keyframes gw-pulse {
    0%   { transform: scale(.92); opacity: .9; }
    70%  { transform: scale(1.28); opacity: 0; }
    100% { transform: scale(1.28); opacity: 0; }
}
.gw-launcher-label {
    position: absolute; right: 68px; top: 50%; transform: translateY(-50%) translateX(6px);
    white-space: nowrap; padding: 7px 14px;
    background: var(--brown); color: #FBF6EC; font-size: .8rem; letter-spacing: .06em;
    border-radius: 6px; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.gw-launcher:hover .gw-launcher-label { opacity: 1; transform: translateY(-50%) translateX(0); }
.gw-launcher.gw-hidden { opacity: 0; pointer-events: none; transform: scale(.6); }

/* ── 浮层面板 ── */
.gw-panel {
    position: fixed; right: 22px; bottom: 94px; z-index: 901;
    width: 386px; max-width: calc(100vw - 28px);
    height: min(640px, calc(100vh - 130px));
    display: flex; flex-direction: column;
    background: var(--bg); border: 1px solid var(--hairline-strong);
    border-radius: 14px; overflow: hidden;
    box-shadow: 0 24px 70px rgba(42, 33, 27, .22);
    transform-origin: bottom right;
    transform: scale(.9) translateY(14px); opacity: 0; pointer-events: none;
    transition: transform .3s cubic-bezier(.2, .9, .3, 1.15), opacity .22s ease;
}
#gwChat.gw-open .gw-panel { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }

/* 聚焦模式（/talk 页或 ?talk=1）：居中对话框 + 背景压暗 */
.gw-backdrop {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(42, 33, 27, .38); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
body.gw-focus .gw-backdrop { opacity: 1; pointer-events: auto; }
body.gw-focus .gw-panel {
    right: auto; bottom: auto; top: 50%; left: 50%;
    transform: translate(-50%, -46%) scale(.94);
    width: min(720px, calc(100vw - 32px));
    height: min(760px, calc(100vh - 48px));
    transform-origin: center center;
}
body.gw-focus #gwChat.gw-open .gw-panel { transform: translate(-50%, -50%) scale(1); }
body.gw-focus { overflow: hidden; }
.gw-focus-page { min-height: 60vh; }

/* ── 面板头部 ── */
.gw-head {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px;
    background: linear-gradient(135deg, var(--paper-warm), var(--paper));
    border-bottom: 1px solid var(--hairline);
}
.gw-avatar {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--orange-line); flex-shrink: 0;
}
.gw-head-info { flex: 1; min-width: 0; }
.gw-head-info strong {
    display: block; font-size: .98rem; color: var(--brown);
    letter-spacing: .04em; font-family: var(--font-serif);
}
.gw-head-info em {
    display: block; font-style: normal; font-size: .72rem; color: var(--muted); margin-top: 2px;
}
.gw-ai-badge {
    display: inline-block; margin-left: 7px; padding: 1px 7px; vertical-align: 2px;
    font-size: .64rem; letter-spacing: .1em; font-family: var(--font-sans);
    color: var(--orange-deep); background: var(--orange-soft);
    border: 1px solid var(--orange-line); border-radius: 2px;
}
.gw-online-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #6B7A5A; margin-right: 5px; vertical-align: 1px;
    box-shadow: 0 0 0 2px rgba(107, 122, 90, .2);
}
.gw-close {
    flex-shrink: 0; width: 30px; height: 30px; border: none; border-radius: 50%;
    background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1;
    cursor: pointer; transition: background .2s, color .2s;
}
.gw-close:hover { background: var(--bg-alt); color: var(--brown); }

/* ── 消息区 ── */
.gw-messages {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    display: flex; flex-direction: column; gap: 12px;
    background:
        radial-gradient(circle at 12% 8%, rgba(232, 96, 12, .035), transparent 42%),
        var(--bg);
}
.talk-msg { display: flex; gap: 9px; max-width: 90%; }
.talk-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.talk-msg.bot  { align-self: flex-start; }
.talk-bubble {
    padding: 10px 14px; border-radius: 12px;
    font-size: .9rem; line-height: 1.85; white-space: pre-wrap; word-break: break-word;
}
.talk-msg.bot .talk-bubble {
    background: var(--paper); border: 1px solid var(--hairline);
    color: var(--ink); border-top-left-radius: 3px; box-shadow: var(--shadow-card);
}
.talk-msg.bot .talk-bubble strong { color: var(--brown); }
.talk-msg.user .talk-bubble {
    background: var(--brown); color: #FBF6EC; border-top-right-radius: 3px;
}
.talk-msg-dot {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    font-size: .78rem; font-weight: 700; font-family: var(--font-serif);
}
.talk-msg.bot .talk-msg-dot {
    background: var(--orange-soft); border: 1px solid var(--orange-line); color: var(--orange-deep);
}
.talk-msg.bot .talk-msg-dot img { width: 100%; height: 100%; object-fit: cover; }
.talk-msg.user .talk-msg-dot {
    background: var(--bg-alt); border: 1px solid var(--hairline-strong); color: var(--brown);
}
.talk-msg.sys { align-self: center; max-width: 100%; }
.talk-msg.sys .talk-bubble {
    background: transparent; border: none; box-shadow: none;
    color: var(--faint); font-size: .72rem; text-align: center; padding: 2px 8px; line-height: 1.7;
}
.talk-msg.err .talk-bubble { background: #FDF3F0; border: 1px solid #E8C4B8; color: #A65E4E; }

/* 输入中动画 */
.talk-typing .talk-bubble { display: flex; gap: 5px; align-items: center; padding: 13px 16px; }
.talk-typing i {
    width: 6px; height: 6px; border-radius: 50%; background: var(--faint);
    animation: gw-blink 1.2s infinite ease-in-out;
}
.talk-typing i:nth-child(2) { animation-delay: .2s; }
.talk-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes gw-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── 快捷方向 ── */
.gw-chips {
    display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px 10px;
    background: var(--bg);
}
.gw-chips.gw-hidden { display: none; }
.talk-chip {
    padding: 6px 13px; cursor: pointer; user-select: none;
    background: var(--paper-warm); border: 1px solid var(--hairline-strong);
    border-radius: 16px; font-size: .76rem; color: var(--brown); transition: all .2s;
}
.talk-chip:hover { border-color: var(--orange-line); color: var(--orange-deep); background: var(--orange-soft); }

/* ── 输入区 ── */
.gw-foot {
    display: flex; gap: 9px; align-items: flex-end;
    padding: 11px 12px; background: var(--paper); border-top: 1px solid var(--hairline);
}
.gw-input {
    flex: 1; resize: none; border: none; outline: none; background: transparent;
    font-family: var(--font-sans); font-size: .9rem; line-height: 1.65; color: var(--ink);
    max-height: 110px; min-height: 24px; padding: 3px 2px;
}
.gw-input::placeholder { color: var(--faint); }
.gw-send {
    flex-shrink: 0; padding: 8px 20px; border: none; border-radius: 3px;
    background: var(--orange); color: #fff; font-size: .82rem; letter-spacing: .1em;
    font-weight: 600; cursor: pointer; transition: background .25s; font-family: var(--font-sans);
}
.gw-send:hover { background: var(--orange-deep); }
.gw-send:disabled { background: var(--hairline-strong); color: var(--faint); cursor: not-allowed; }

/* ── 轮次硬收尾：留资 CTA（替换输入区） ── */
.gw-wrapup {
    display: flex; flex-direction: column; gap: 9px; align-items: center;
    padding: 14px 16px; background: var(--paper); border-top: 1px solid var(--hairline);
    text-align: center;
}
.gw-wrapup.gw-hidden { display: none; }
.gw-wrapup p { margin: 0; font-size: .8rem; line-height: 1.7; color: var(--muted, #6B7280); }
.gw-wrapup-btn {
    display: inline-block; padding: 8px 22px; border-radius: 3px;
    background: var(--orange); color: #fff; font-size: .82rem; letter-spacing: .1em;
    font-weight: 600; text-decoration: none; transition: background .25s;
}
.gw-wrapup-btn:hover { background: var(--orange-deep); color: #fff; }

/* ── 移动端：面板铺满 ── */
@media (max-width: 640px) {
    .gw-panel {
        right: 8px; left: 8px; bottom: 8px; width: auto;
        height: calc(100vh - 96px); max-width: none;
    }
    body.gw-focus .gw-panel { width: calc(100vw - 16px); height: calc(100vh - 24px); }
    .gw-launcher { right: 14px; bottom: 16px; }
    .gw-launcher-label { display: none; }
}
