/* ─────────────────────────────────────────────────────────────────────
   天机 — 对话界面 chat.css
   依赖 style.css 之 design tokens；本文件只追加 chat 专用样式。
   ───────────────────────────────────────────────────────────────────── */

body.chat-page {
    /* 对话页主调：深玉绿 + 暗金 */
    --accent:       var(--jade-bright);
    --accent-glow:  rgba(92, 184, 138, 0.45);
    --accent-deep:  var(--jade);

    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 把首页的星空收得淡一些，对话页要更宁静 */
.chat-page .bg-glow {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(92, 184, 138, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(212, 175, 55, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-obsidian) 0%, var(--bg-deep) 100%);
}
.chat-page .bg-stars { opacity: 0.4; }

/* ─── 顶部条 ────────────────────────────────────────────── */

.chat-nav {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--stroke);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(7,7,13,0.6);
    flex-shrink: 0;
}
.chat-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s var(--ease);
}
.chat-back:hover { color: var(--accent); }

.ai-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}
.ai-status .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--jade-bright);
    box-shadow: 0 0 12px var(--accent-glow);
    animation: pulseDot 2.4s ease-in-out infinite;
}
@keyframes pulseDot {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

/* ─── 对话区 ────────────────────────────────────────────── */

.chat-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 32px 0 24px;
    scroll-behavior: smooth;
}
.chat-thread::-webkit-scrollbar { width: 8px; }
.chat-thread::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }
.chat-thread::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.thread-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ─── 欢迎态 ────────────────────────────────────────────── */

.welcome {
    text-align: center;
    padding: 48px 0;
    animation: fadeUp 0.6s var(--ease);
}
.welcome.hidden { display: none; }

.welcome-greeting {
    font-family: var(--font-zh-display);
    font-size: 30px;
    color: var(--text);
    letter-spacing: 0.2em;
    margin: 32px 0 12px;
}
.welcome-sub {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.8;
    max-width: 460px;
    margin: 0 auto 36px;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 太极头像 — 大尺寸（欢迎区） */
.taichi {
    display: inline-block;
    position: relative;
}
.taichi-large {
    width: 140px; height: 140px;
}
.taichi-small {
    width: 36px; height: 36px;
    flex-shrink: 0;
}
.taichi svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}
.taichi-large::before,
.taichi-large::after {
    content: "";
    position: absolute;
    inset: -20%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
    animation: aura 4s ease-in-out infinite;
}
.taichi-large::after { animation-delay: 2s; }
@keyframes aura {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50%      { opacity: 0.9; transform: scale(1.15); }
}
.taichi svg .yin-yang {
    transform-box: fill-box;   /* Safari：否则绕视口原点公转、图形飞出裁切 */
    transform-origin: center;
    animation: spinSlow 24s linear infinite;
}

/* ─── 建议提问 chips ────────────────────────────────────── */

.suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
}
.chip-suggest {
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(20, 26, 46, 0.5);
    border: 1px solid var(--stroke-soft);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text);
    font-size: 14px;
    text-align: left;
    line-height: 1.6;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    font-family: var(--font-zh-display);
    letter-spacing: 0.04em;
}
.chip-suggest:hover {
    border-color: var(--accent);
    background: rgba(20, 40, 32, 0.55);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 16px var(--accent-glow);
}
.chip-suggest .arrow { color: var(--accent); margin-right: 8px; }

/* ─── 消息气泡 ──────────────────────────────────────────── */

.msg {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeUp 0.45s var(--ease);
}
.msg-user {
    flex-direction: row-reverse;
}

.bubble {
    max-width: 82%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 15.5px;
    line-height: 1.85;
    letter-spacing: 0.02em;
    position: relative;
    word-wrap: break-word;
}

.msg-user .bubble {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
    color: var(--bg-obsidian);
    border-radius: 18px 18px 6px 18px;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.25);
    font-weight: 500;
}

.msg-ai .bubble {
    background: linear-gradient(135deg, rgba(20, 40, 32, 0.7) 0%, rgba(13, 27, 42, 0.6) 100%);
    border: 1px solid rgba(92, 184, 138, 0.2);
    color: var(--text);
    border-radius: 18px 18px 18px 6px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    font-family: var(--font-zh-display);
}

/* AI 气泡内的祥云水印（轻 SVG 背景） */
.msg-ai .bubble::before {
    content: "";
    position: absolute;
    top: -10px; right: -10px;
    width: 80px; height: 80px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'><path d='M20 50 Q15 40 22 36 Q25 28 35 32 Q42 24 52 30 Q62 28 60 38 Q68 42 60 50 Q55 58 45 54 Q38 60 30 56 Q20 58 20 50 Z' fill='none' stroke='rgba(92,184,138,0.18)' stroke-width='1.5'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    opacity: 0.6;
}

/* 思考中态 — 三个跳动小点 */
.thinking {
    display: inline-flex;
    gap: 6px;
    padding: 4px 0;
}
.thinking span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: think 1.2s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes think {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* 引用标签 */
.citations {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cite-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(92, 184, 138, 0.12);
    border: 1px solid rgba(92, 184, 138, 0.25);
    color: var(--jade-bright);
    font-size: 11.5px;
    font-family: var(--font-en);
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.cite-chip:hover {
    background: rgba(92, 184, 138, 0.2);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.cite-chip .num {
    font-weight: 700;
    color: var(--gold-bright);
}

/* 引用标记内嵌于正文 */
.bubble .cite-mark {
    display: inline-block;
    color: var(--gold-bright);
    font-size: 0.85em;
    font-weight: 600;
    margin: 0 2px;
    cursor: pointer;
    transition: opacity 0.2s var(--ease);
    vertical-align: super;
    line-height: 1;
}
.bubble .cite-mark:hover { opacity: 0.7; }

/* ─── 八字 pinned 标签 ─────────────────────────────────── */

.pin-bazi {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0 auto 24px;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(20, 26, 46, 0.7);
    border: 1px solid var(--stroke);
    font-size: 13px;
    color: var(--text-muted);
}
.pin-bazi .pillars {
    display: flex;
    gap: 4px;
    font-family: var(--font-zh-display);
    color: var(--gold-bright);
    letter-spacing: 0.1em;
    font-size: 14px;
}
.pin-bazi.hidden { display: none; }

/* ─── 输入栏 ────────────────────────────────────────────── */

.chat-input {
    flex-shrink: 0;
    padding: 16px 24px 28px;
    background: linear-gradient(180deg, transparent 0%, rgba(7,7,13,0.85) 30%);
    z-index: 5;
}

.input-row {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px;
    border-radius: 22px;
    background: rgba(20, 26, 46, 0.7);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 24px var(--accent-glow);
}

.icon-btn {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s var(--ease);
    background: rgba(255,255,255,0.04);
}
.icon-btn:hover { color: var(--accent); background: rgba(92,184,138,0.1); }
.icon-btn svg { width: 18px; height: 18px; }

.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    padding: 8px 4px;
    min-height: 24px;
    max-height: 160px;
    font-family: var(--font-zh-display);
    letter-spacing: 0.02em;
}
.chat-textarea::placeholder {
    color: var(--text-dim);
    font-family: var(--font-zh-display);
}

.send-btn {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--jade-bright) 0%, var(--accent-deep) 100%);
    color: var(--bg-obsidian);
    transition: all 0.2s var(--ease);
    box-shadow: 0 0 16px var(--accent-glow);
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 0 24px var(--accent-glow); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; transform: none; }
.send-btn svg { width: 18px; height: 18px; }

.input-hint {
    max-width: 760px;
    margin: 8px auto 0;
    padding: 0 12px;
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 0.15em;
}

/* ─── 八字录入弹窗 ─────────────────────────────────────── */

.bazi-modal {
    position: fixed;
    inset: 0;
    background: rgba(7,7,13,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}
.bazi-modal.open { display: flex; animation: fadeUp 0.3s var(--ease); }
.bazi-modal-inner {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(20,40,32,0.95) 0%, rgba(13,27,42,0.95) 100%);
    border: 1px solid var(--stroke);
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.bazi-modal h3 {
    font-family: var(--font-zh-display);
    font-size: 22px;
    color: var(--text);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}
.bazi-modal p.sub {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}
.bazi-modal label {
    display: block;
    margin-bottom: 16px;
}
.bazi-modal label span {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.2em;
    margin-bottom: 6px;
}
.bazi-modal input,
.bazi-modal select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--stroke);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s var(--ease);
}
.bazi-modal input:focus { border-color: var(--accent); }
.bazi-modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.bazi-modal .btn { flex: 1; justify-content: center; padding: 12px 0; font-size: 14px; }

/* ─── 移动适配 ──────────────────────────────────────────── */

@media (max-width: 720px) {
    .chat-nav { padding: 12px 16px; }
    .ai-status { font-size: 11px; letter-spacing: 0.1em; }
    .thread-inner { padding: 0 16px; }
    .chat-input { padding: 12px 16px 20px; }
    .input-row { padding: 10px; gap: 8px; }
    .bubble { font-size: 14.5px; max-width: 88%; }
    .welcome-greeting { font-size: 24px; }
    .taichi-large { width: 110px; height: 110px; }
    .suggestions { grid-template-columns: 1fr; }
    .input-hint { display: none; }
}
