/* ============================================================================
   MITTA — "NEO TOKYO" 设计系统
   视觉灵感：Persona 3 冷调蓝灰 × Persona 5 高对比红黑几何
   设计语言：粗墨描边 + 硬投影（Neo-Brutalism）+ 锐利切角 + 斜纹纹理 + 按压动效
   主色：清新青蓝/薄荷，跳色：P5 珊瑚红 / 明黄。全部手写，无第三方组件库。
   ----------------------------------------------------------------------------
   【适配说明】本文件为全新 UI 层；类名与 app.js 中模板、renderMarkdown 生成
   的 DOM、document 委托（.user-menu-wrapper / .code-block-wrapper）严格对齐，
   业务 JS 未做任何改动。
   ============================================================================ */

/* ============================ 1. 设计 Token ============================ */
:root {
    /* 墨色与纸面 */
    --ink: #16181D;
    --ink-soft: #2A2F3A;
    --paper: #F4F7FB;
    --surface: #FFFFFF;
    --surface-2: #EEF2F8;

    /* 主色：青蓝（P3 冷调的清新化）+ 薄荷 */
    --brand: #12B8C9;
    --brand-deep: #0B8C99;
    --brand-soft: #DDF6F9;
    --mint: #22C99A;
    --mint-soft: #DDF7EE;

    /* 跳色 */
    --red: #FF3B4E;
    --red-deep: #E02438;
    --red-soft: #FFE4E7;
    --yellow: #FFD23F;
    --blue: #3B82F6;
    --violet: #8B5CF6;

    /* 文本 */
    --text: #16181D;
    --text-2: #565F6E;
    --text-3: #98A0AE;

    /* 线条 */
    --line: #16181D;
    --line-soft: #DFE5EE;

    /* 硬投影 */
    --shadow-hard: 4px 4px 0 var(--ink);
    --shadow-hard-sm: 2px 2px 0 var(--ink);
    --shadow-hard-lg: 6px 6px 0 var(--ink);
    --shadow-red: 4px 4px 0 var(--red-deep);

    /* 字体 */
    --font-display: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

    /* 几何 */
    --r-sm: 6px;
    --r-md: 12px;
    --r-lg: 18px;
    /* P5 式切角：切去右上、左下 */
    --clip-cut: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
    --clip-cut-sm: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
    --ease-pop: cubic-bezier(.2, .9, .3, 1.35);
    --ease-smooth: cubic-bezier(.4, 0, .2, 1);
}

/* 深色（P3 蓝黑夜色） */
[data-theme="dark"] {
    --ink: #E9EEF7;
    --ink-soft: #C2CAD8;
    --paper: #0B0F18;
    --surface: #141B28;
    --surface-2: #1B2333;
    --text: #E9EEF7;
    --text-2: #A6B0C2;
    --text-3: #6B7689;
    --line: #E9EEF7;
    --line-soft: #283144;
    --brand-soft: #103339;
    --mint-soft: #0E3328;
    --red-soft: #3A1620;
    --shadow-hard: 4px 4px 0 #000;
    --shadow-hard-sm: 2px 2px 0 #000;
}
[data-theme="ocean"]  { --brand:#2D9CFF; --brand-deep:#1A7AD6; --brand-soft:#E0F0FF; }
[data-theme="sunset"] { --brand:#FF5C9A; --brand-deep:#E03E7C; --brand-soft:#FFE7F0; }
[data-theme="forest"] { --brand:#1FC98C; --brand-deep:#12A06E; --brand-soft:#E0F8EF; }
[data-theme="lavender"]{ --brand:#9D7BFF; --brand-deep:#7C57E6; --brand-soft:#EFE9FF; }

/* ============================ 2. 基础重置 ============================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
#app, .app-root { height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; outline: none; }
a { color: var(--brand-deep); text-decoration: none; font-weight: 700; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--ink); border-radius: 0; border: 2px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

/* 斜纹纹理工具类（P5 标志性背景） */
.stripe-bg {
    background-image: repeating-linear-gradient(
        -45deg, transparent 0 10px, rgba(18,184,201,.05) 10px 12px);
}

/* ============================ 3. 通用按钮 ============================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 800; border-radius: var(--r-sm); transition: transform .12s var(--ease-pop), box-shadow .12s var(--ease-pop); }
.btn-primary {
    background: var(--red); color: #fff; border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard-sm); padding: 12px 20px; font-size: 15px;
    letter-spacing: 1px; text-transform: uppercase;
    clip-path: var(--clip-cut-sm);
}
.btn-primary:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary:active:not(:disabled) { transform: translate(2px,2px); box-shadow: 0 0 0 var(--ink); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost {
    background: var(--surface); color: var(--text); border: 2px solid var(--ink);
    padding: 8px 14px; font-size: 13px; font-weight: 700; border-radius: var(--r-sm);
    box-shadow: var(--shadow-hard-sm); transition: transform .12s var(--ease-pop), box-shadow .12s;
}
.btn-ghost:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.btn-ghost:active { transform: translate(2px,2px); box-shadow: none; }

/* ============================ 4. 认证页 ============================ */
.auth-layout {
    height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
    background: var(--paper);
}
/* 左侧品牌区：P3 深蓝灰 + 斜纹 + 几何装饰 */
.auth-brand {
    position: relative; overflow: hidden; color: #fff; padding: 56px;
    background: linear-gradient(150deg, #0E1A2E 0%, #132C46 55%, #0B8C99 140%);
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::before { /* 斜纹层 */
    content: ""; position: absolute; inset: 0;
    background-image: repeating-linear-gradient(-45deg, transparent 0 26px, rgba(255,255,255,.04) 26px 28px);
    pointer-events: none;
}
/* 原静态大圆已由 .auth-ring（SVG 动态装饰）替代，见“动态装饰圆环”段 */
.auth-logo { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.auth-logo-mark {
    width: 52px; height: 52px; background: var(--red); border: 3px solid #fff;
    display: grid; place-items: center; clip-path: var(--clip-cut-sm);
    box-shadow: 4px 4px 0 rgba(0,0,0,.4);
}
.auth-logo-mark img { width: 34px; height: 34px; object-fit: contain; }
.auth-logo span { font-size: 26px; font-weight: 900; letter-spacing: 2px; }
.auth-quote { position: relative; z-index: 1; max-width: 460px; }
.auth-quote h2 { font-size: 38px; line-height: 1.25; font-weight: 900; margin-bottom: 20px;
    text-transform: none; }
.auth-quote h2::after { content: ""; display: block; width: 64px; height: 6px; background: var(--yellow);
    margin-top: 16px; clip-path: polygon(0 0,100% 0,calc(100% - 8px) 100%,0 100%); }
.auth-quote p { font-size: 15px; line-height: 1.9; color: rgba(255,255,255,.82); }
.auth-footer { position: relative; z-index: 1; font-size: 12px; letter-spacing: 1px; color: rgba(255,255,255,.55); }

/* 右侧表单区（大字层定位上下文；z-index:1 形成独立堆叠层，保证 .auth-bg-word(z-index:5) 盖在卡片之上） */
.auth-form-wrapper {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: center; padding: 32px;
    overflow: hidden; background: var(--paper);
    background-image:
        radial-gradient(120% 90% at 100% 0%, rgba(255,59,78,.07), transparent 60%),
        radial-gradient(90% 80% at 0% 100%, rgba(18,184,201,.06), transparent 55%),
        linear-gradient(rgba(20,22,28,.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20,22,28,.045) 1px, transparent 1px);
    background-size: auto, auto, 26px 26px, 26px 26px;
}
/* 右模块顶部细弧：与左侧圆环同色，把左右区块"圈"成一体（静态细线，无滤镜动画） */
.auth-form-wrapper::before {
    content: ''; position: absolute; top: -150px; left: 50%; transform: translateX(-50%);
    width: 720px; height: 300px; pointer-events: none; z-index: 0;
    border: 2px solid rgba(122,180,242,.22); border-bottom: none;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    -webkit-mask: linear-gradient(180deg, #000 30%, transparent 92%);
            mask: linear-gradient(180deg, #000 30%, transparent 92%);
}
.auth-layout.ring-register .auth-form-wrapper::before { border-color: rgba(255,128,168,.22); }
.auth-layout.ring-recover .auth-form-wrapper::before { border-color: rgba(255,59,78,.20); }
}
/* ===== 卡片外背景大字（AuthLayout 统一管理；外层容器定位 + 内层 span 旋转；
        过渡由 Vue transition 方向类接管，滚轮式平滑切换） ===== */
.auth-layout { position: relative; }
.auth-bg-word {
    position: absolute; z-index: 5; pointer-events: none;
    font-weight: 900; letter-spacing: 6px; line-height: 1;
    color: transparent; -webkit-background-clip: text; background-clip: text;
    background-image: linear-gradient(180deg, rgba(28,30,36,.2), rgba(28,30,36,.06));
    user-select: none; will-change: transform, opacity;
}
/* 卡片内容盖在水印大字之上（大字仅作背景水印） */
.auth-card > * { position: relative; z-index: 3; }
.auth-bg-word span {
    display: inline-block; white-space: nowrap; word-break: keep-all;
    /* 旋转用内层 span 必须继承外层渐变并自行裁剪，否则 background-clip:text 无法穿透子元素 → 文字透明不可见 */
    background-image: inherit;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
/* 登录：SIGN IN 侧边竖排（深黑→灰渐变；纵向长度对齐卡片宽度；位置由 app.js 动态对齐右侧空白带中心） */
.word-login { font-size: 86px; letter-spacing: 10px;
    background-image: linear-gradient(180deg, #14161B 0%, #3A3E48 55%, rgba(28,30,36,.18) 100%);
}
.word-login span { transform: rotate(90deg); }
/* 注册：JOIN US 左侧空白带竖排（逆时针 90°，左进左出；纵向长度对齐卡片宽度；位置由 app.js 动态对齐左侧空白带中心） */
.word-register { font-size: 76px; letter-spacing: 14px; }
.word-register span { transform: rotate(-90deg); }
/* 找回：RESET 红字竖排，位于左侧空白带（逆时针 90°，纵向长度对齐卡片宽度，水印感淡红，缩放进出） */
.word-recover { font-size: 98px; letter-spacing: 18px;
    background-image: linear-gradient(180deg, rgba(255,59,78,.34), rgba(255,59,78,.10));
}
.word-recover span { transform: rotate(-90deg); }
/* ---- 滚轮式平滑过渡（固定 name="word"；方向由元素自身 .word-{mode} 类决定，
        旧元素离开时保留旧类 → 各自原有方向进出：SIGN IN 下进下出 / JOIN US 左进左出 / RESET 缩放进出） ---- */
.word-enter-active, .word-leave-active {
    transition: transform .5s var(--ease-smooth), opacity .5s var(--ease-smooth);
}
.word-enter-from, .word-leave-to { opacity: 0; }
.word-login.word-enter-from { transform: translateY(-80px); }
.word-login.word-leave-to { transform: translateY(80px); }
.word-register.word-enter-from { transform: translateX(90px); }
.word-register.word-leave-to { transform: translateX(-90px); }
.word-recover.word-enter-from { transform: scale(.7); }
.word-recover.word-leave-to { transform: scale(.7); }
/* 卡片盖在大字层上 */
.auth-card { position: relative; z-index: 1; }
.auth-card {
    width: 100%; max-width: 420px; background: var(--surface); border: 3px solid var(--ink);
    padding: 40px 36px; clip-path: var(--clip-cut); box-shadow: var(--shadow-hard-lg);
    animation: pop-in .45s var(--ease-pop) both;
}
.auth-card h1 { font-size: 30px; font-weight: 900; letter-spacing: -.5px; margin-bottom: 6px; }
.auth-subtitle { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--text-2); margin-bottom: 7px; }
.form-input, .modal .form-group input, .modal .form-group textarea, .mcp-json-editor {
    width: 100%; padding: 12px 14px; font-size: 14px; color: var(--text);
    background: var(--surface-2); border: 2px solid var(--ink); border-radius: var(--r-sm);
    transition: box-shadow .15s, background .15s, transform .12s;
}
.form-input:focus, .modal .form-group input:focus, .modal .form-group textarea:focus, .mcp-json-editor:focus {
    background: #fff; box-shadow: 3px 3px 0 var(--brand); transform: translate(-1px,-1px);
}
[data-theme="dark"] .form-input:focus, [data-theme="dark"] .modal .form-group input:focus { background: #0D1420; }
.form-error { color: var(--red-deep); font-size: 12px; font-weight: 700; margin-top: 6px; min-height: 14px; }
.auth-msg { margin-bottom: 14px; }
.auth-submit { width: 100%; margin-top: 6px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 22px; font-size: 13px; }
.auth-links a { position: relative; }
.auth-links a:hover { color: var(--red); }

/* ============================ 5. 聊天整体布局 ============================ */
.chat-layout { display: flex; height: 100vh; overflow: hidden; background: var(--paper); }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 272px; flex-shrink: 0; background: var(--ink); color: #D7DCE5;
    display: flex; flex-direction: column; position: relative; z-index: 40;
    border-right: 3px solid #000;
}
.sidebar-header { padding: 18px 16px 14px; display: flex; align-items: center; gap: 10px;
    border-bottom: 2px solid rgba(255,255,255,.08); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidebar-brand-mark { width: 38px; height: 38px; background: var(--red); flex-shrink: 0;
    display: grid; place-items: center; border: 2px solid #fff; clip-path: var(--clip-cut-sm); }
.sidebar-brand-mark img { width: 26px; height: 26px; }
.sidebar-brand span { font-weight: 900; font-size: 19px; letter-spacing: 1px; color: #fff; }
.new-chat-btn {
    width: 38px; height: 38px; flex-shrink: 0; background: var(--brand); color: var(--ink);
    border: 2px solid #fff; display: grid; place-items: center; clip-path: var(--clip-cut-sm);
    transition: transform .12s var(--ease-pop);
}
.new-chat-btn:hover { transform: rotate(90deg) scale(1.08); background: var(--yellow); }
.new-chat-btn:active { transform: rotate(90deg) scale(.95); }

.session-list { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.empty-state { text-align: center; color: rgba(255,255,255,.4); font-size: 13px; padding: 30px 10px; }
.session-item {
    position: relative; display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 11px 12px; color: #C6CCD7; text-align: left; font-size: 13.5px;
    border: 2px solid transparent; border-radius: var(--r-sm); transition: all .15s var(--ease-smooth);
    animation: slide-in-left .35s var(--ease-smooth) both;
}
.session-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.session-item.active { background: var(--brand); color: #082226; font-weight: 800; border-color: #fff;
    box-shadow: 3px 3px 0 rgba(0,0,0,.5); clip-path: var(--clip-cut-sm); }
.session-item.active::before { content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px;
    width: 5px; background: var(--red); }
.session-icon { flex-shrink: 0; opacity: .7; }
.session-item.active .session-icon { opacity: 1; }
.session-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-rename {
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    color: var(--text-3);
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.session-item:hover .session-rename {
    opacity: 1;
}
.session-rename:hover {
    background: var(--brand);
    color: #fff;
}
.session-rename-input {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--brand);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 13px;
    color: var(--text-1);
    outline: none;
    font-family: inherit;
}
.session-delete { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 4px; opacity: 0; transition: all .15s; color: inherit; }
.session-item:hover .session-delete { opacity: .7; }
.session-delete:hover { opacity: 1 !important; background: var(--red); color: #fff; }

.sidebar-footer { padding: 12px; border-top: 2px solid rgba(255,255,255,.08); }
.user-menu-wrapper { position: relative; }
.user-dropdown {
    position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; z-index: 50;
    background: var(--surface); color: var(--text); border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard); border-radius: var(--r-sm); overflow: hidden;
    animation: menu-pop .2s var(--ease-pop) both; transform-origin: bottom left;
}
.user-dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px;
    font-size: 13.5px; font-weight: 700; text-align: left; border-bottom: 2px solid var(--line-soft);
}
.user-dropdown-item:last-child { border-bottom: none; }
.user-dropdown-item svg { width: 16px; height: 16px; color: var(--brand-deep); }
.user-dropdown-item:hover { background: var(--brand-soft); }
.user-card { display: flex; align-items: center; gap: 8px; }
.user-avatar-btn { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; text-align: left; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; overflow: hidden;
    background: var(--brand); color: #082226; font-weight: 900; display: grid; place-items: center;
    font-size: 15px; flex-shrink: 0; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 800; color: #fff; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.logout-btn { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center;
    color: #C6CCD7; border: 2px solid rgba(255,255,255,.18); border-radius: var(--r-sm); transition: all .15s; }
.logout-btn:hover { color: #fff; background: var(--red); border-color: #fff; }
.health-status { display: flex; align-items: center; gap: 7px; margin-top: 10px;
    font-size: 11px; color: rgba(255,255,255,.5); padding: 0 2px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.health-dot.online { background: var(--mint); box-shadow: 0 0 0 3px rgba(34,201,154,.2); animation: pulse-dot 2s infinite; }
.health-dot.degraded { background: var(--yellow); }
.health-dot.offline { background: var(--red); }

/* 移动端遮罩 */
.overlay { position: fixed; inset: 0; background: rgba(10,15,25,.55); z-index: 35;
    opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(2px); }
.overlay.active { opacity: 1; pointer-events: auto; }

/* ---------- 主区域 ---------- */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative;
    background: var(--paper);
    background-image: repeating-linear-gradient(-45deg, transparent 0 30px, rgba(18,184,201,.025) 30px 32px);
}
.main-header { height: 62px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px; background: var(--surface); border-bottom: 3px solid var(--ink); z-index: 20; }
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-toggle { display: none; width: 40px; height: 40px; place-items: center;
    border: 2px solid var(--ink); background: var(--surface-2); border-radius: var(--r-sm); }
.menu-toggle:hover { background: var(--yellow); }
.current-session-title { font-size: 18px; font-weight: 900; letter-spacing: -.3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; color: var(--text-2);
    border: 2px solid transparent; border-radius: var(--r-sm); transition: all .15s; }
.icon-btn:hover { color: var(--red); border-color: var(--ink); background: var(--surface-2); }

/* ---------- 消息滚动区 ---------- */
.messages-container { flex: 1; overflow-y: auto; scroll-behavior: smooth; position: relative; }
.scroll-to-bottom-btn {
    position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 10; transform: translateX(-50%);
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--violet); color: #fff;
    border: 1px solid var(--ink);
    cursor: pointer;
    transition: transform .15s ease;
}
.scroll-to-bottom-btn:hover { transform: translateX(-50%) translateY(-2px); }
/* 输出中加载环：粗描边圆环围绕按钮旋转，贴合 Neo-Brutalism 主题 */
.scroll-to-bottom-btn.is-generating::after {
    content: ''; position: absolute; inset: -5px; border-radius: 50%;
    border: 3px solid var(--brand); border-top-color: transparent;
    animation: btn-spin .9s linear infinite; pointer-events: none;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.messages-wrapper { max-width: 920px; margin: 0 auto; padding: 28px 24px 12px; }

/* 欢迎态 */
.welcome-state { text-align: center; padding: 7vh 20px 4vh; animation: rise-in .5s var(--ease-smooth) both; }
.welcome-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 16px;
    background: var(--brand-soft); color: var(--brand-deep); border: 2px solid var(--ink);
    font-size: 12.5px; font-weight: 800; letter-spacing: 1px; border-radius: 100px; margin-bottom: 22px;
    box-shadow: var(--shadow-hard-sm); }
.welcome-state h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 900; letter-spacing: -1px;
    line-height: 1.2; margin-bottom: 12px; }
.welcome-state h1::selection, .welcome-state p::selection { background: var(--yellow); }
.welcome-state > p { color: var(--text-2); font-size: 15px; margin-bottom: 30px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 22px; }
.quick-action {
    padding: 11px 18px; background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 700;
    border: 2px solid var(--ink); box-shadow: var(--shadow-hard-sm); clip-path: var(--clip-cut-sm);
    transition: all .14s var(--ease-pop); animation: pop-in .4s var(--ease-pop) both;
}
.quick-action:nth-child(1){animation-delay:.05s}.quick-action:nth-child(2){animation-delay:.12s}
.quick-action:nth-child(3){animation-delay:.19s}.quick-action:nth-child(4){animation-delay:.26s}
.quick-action:hover { background: var(--yellow); transform: translate(-2px,-2px); box-shadow: 4px 4px 0 var(--ink); }
.quick-action:active { transform: translate(2px,2px); box-shadow: none; }
.refresh-questions-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px;
    font-size: 13px; font-weight: 700; color: var(--text-2); border: 2px dashed var(--text-3);
    border-radius: 100px; transition: all .15s; }
.refresh-questions-btn:hover { color: var(--brand-deep); border-color: var(--brand); background: var(--brand-soft); }
.refresh-questions-btn svg { transition: transform .5s var(--ease-pop); }
.refresh-questions-btn:hover svg { transform: rotate(180deg); }

/* ---------- 消息气泡 ---------- */
.message { display: flex; gap: 14px; margin-bottom: 26px; animation: pop-in .35s var(--ease-smooth) both; }
.message-avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--ink);
    overflow: hidden; display: grid; place-items: center; font-weight: 900; font-size: 15px; background: var(--brand); color:#082226; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message.user { flex-direction: row-reverse; }
.message.user .message-avatar { background: var(--red); color: #fff; }
.message-content-wrapper { max-width: calc(100% - 60px); min-width: 0; }
.message.user .message-content-wrapper { display: flex; flex-direction: column; align-items: flex-end; }
.message-meta { display: flex; gap: 6px; font-size: 12px; color: var(--text-3); font-weight: 700;
    margin-bottom: 7px; padding: 0 2px; }
.message-content { position: relative; padding: 14px 17px; background: var(--surface);
    border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard-sm);
    line-height: 1.75; font-size: 14.5px; word-break: break-word; clip-path: var(--clip-cut);
}
.message.user .message-content { background: var(--red); color: #fff; border-color: var(--ink);
    box-shadow: var(--shadow-red); }
.message.user .user-text { white-space: pre-wrap; line-height: 1.7; font-size: 14.5px; }

/* 深度思考块：独立折叠（同工具调用行内风格），流式中展开、结束后收起 */
.reasoning-inline {
    margin: 6px 0 10px;
    padding: 8px 12px;
    border-left: 3px solid var(--text-3);
    background: var(--surface-2);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
/* 收起态：只保留标题行，去掉内容区内边距感 */
.reasoning-inline.collapsed { padding: 6px 12px; }
.reasoning-inline-header {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; user-select: none;
    font-size: 12px; font-weight: 700; color: var(--text-3);
    transition: color .15s;
}
.reasoning-inline-header:hover { color: var(--brand-deep); }
.reasoning-inline-bulb { flex-shrink: 0; }
.reasoning-inline-title { letter-spacing: .5px; }
.reasoning-inline-arrow {
    margin-left: auto; transition: transform .2s var(--ease-pop);
    color: var(--text-3);
}
.reasoning-inline-arrow.expanded { transform: rotate(90deg); }
.reasoning-inline-text {
    margin-top: 6px;
    font-size: 12.5px; line-height: 1.75;
    color: var(--text-2); font-style: italic;
    white-space: pre-wrap; word-break: break-word;
    opacity: .85;
}
/* 正式回答（markdown-body）保持正常深色大字，自然比思考内容醒目 */

/* 工具调用卡片（豆包式穿插） */
.tool-call-item { margin: 10px 0; border: 2px solid var(--ink); border-radius: var(--r-sm);
    background: var(--surface-2); overflow: hidden; font-size: 13px; box-shadow: var(--shadow-hard-sm); }
.tool-call-item.running { border-color: var(--brand-deep); background: var(--brand-soft);
    animation: tool-glow 1.4s ease-in-out infinite; }
.tool-call-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
    font-weight: 700; user-select: none; }
.tool-call-icon { color: var(--brand-deep); flex-shrink: 0; }
.tool-call-name { flex: 1; }
.tool-call-status { display: inline-flex; align-items: center; }
.tool-call-done { color: var(--mint); font-weight: 900; }
.tool-call-spinner { width: 13px; height: 13px; border: 2px solid var(--brand-deep);
    border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.tool-call-arrow { transition: transform .2s var(--ease-pop); color: var(--text-3); }
.tool-call-arrow.expanded { transform: rotate(90deg); }
.tool-call-detail { padding: 0 12px 10px; border-top: 2px dashed var(--line-soft); }
.tool-call-section { margin-top: 9px; }
.tool-call-label { font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--text-3);
    text-transform: uppercase; margin-bottom: 4px; }
.tool-call-json, .tool-call-result {
    background: #10141C; color: #C8E1FF; font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
    padding: 9px 11px; border-radius: var(--r-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-word;
    max-height: 220px; overflow-y: auto;
}
.tool-call-result { color: #B9E8D4; }
.tool-call-empty { font-size: 12px; color: var(--text-3); padding: 6px 0; }

/* ===== 工具调用行内样式（豆包/OpenAI 风格） ===== */
.tool-call-inline {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 4px 0;
    padding: 3px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 13px;
    color: var(--text-2);
    cursor: default;
    width: 100%;
    flex-wrap: wrap;
    line-height: 1.6;
}
.tool-call-inline:hover { color: var(--text-1); }
.tool-call-inline.running { color: var(--brand-deep); animation: none; }
.tool-call-inline.done { color: var(--text-2); }
.tool-inline-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; flex-shrink: 0; color: inherit; opacity: .8;
}
.tool-inline-spinner {
    width: 12px; height: 12px; border: 2px solid var(--brand-deep);
    border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
.tool-inline-summary {
    font-weight: 700; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 500px;
}
.tool-inline-toggle {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 11px; font-weight: 600; color: var(--text-3);
    cursor: pointer; padding: 1px 4px; border-radius: 4px;
    transition: all .14s; opacity: .7;
}
.tool-inline-toggle:hover { opacity: 1; color: var(--text-1); }
.tool-inline-toggle svg { transition: transform .2s var(--ease-pop); width: 10px; height: 10px; }
.tool-inline-toggle svg.expanded { transform: rotate(90deg); }
.tool-inline-detail {
    flex-basis: 100%;
    margin-top: 4px; padding: 6px 10px;
    border-left: 2px solid var(--line-soft);
    background: var(--surface-2);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.tool-inline-label {
    font-size: 10px; font-weight: 700; letter-spacing: .5px;
    color: var(--text-3); text-transform: uppercase; margin: 4px 0 2px;
}
.tool-inline-json, .tool-inline-result {
    background: #10141C; color: #C8E1FF; font-family: var(--font-mono);
    font-size: 11px; line-height: 1.5; padding: 6px 8px;
    border-radius: 4px; overflow-x: auto; white-space: pre-wrap;
    word-break: break-word; max-height: 150px; overflow-y: auto; margin: 0;
}
.tool-inline-result { color: #B9E8D4; }

/* 工具结果引用块（DeepSeek 风格） */
.tool-inline-result-block {
    flex-basis: 100%;
    margin: 4px 0 4px 22px;
    padding: 8px 12px;
    border-left: 3px solid var(--brand);
    background: var(--surface-2);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.tool-inline-result-text {
    margin: 0; font-family: var(--font-mono); font-size: 12px;
    line-height: 1.6; color: var(--text-2); white-space: pre-wrap;
    word-break: break-word; max-height: 200px; overflow-y: auto;
}

/* 思考中 / 工具加载指示器 */
.thinking-indicator { display: flex; align-items: center; gap: 10px; padding: 4px 2px; color: var(--text-2); }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots span { width: 7px; height: 7px; background: var(--brand); border: 1.5px solid var(--ink);
    border-radius: 50%; animation: think-bounce 1.2s infinite; }
.thinking-dots span:nth-child(2){animation-delay:.18s;background:var(--red)}
.thinking-dots span:nth-child(3){animation-delay:.36s;background:var(--yellow)}
.thinking-text { font-size: 13px; font-weight: 700; }
.tool-call-indicator { display: flex; align-items: center; gap: 9px; margin-top: 10px; font-size: 12.5px;
    color: var(--brand-deep); font-weight: 700; }
.tool-call-text strong { color: var(--red); }
.tool-call-indicator .tool-call-spinner { width: 14px; height: 14px; }
.rag-thinking-indicator { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 4px 2px; color: var(--text-2); }
.rag-thinking-indicator .thinking-text { color: var(--brand-deep); }
.citations-block { margin-top: 10px; border: 1px solid var(--line-soft, #e4e3dd); border-radius: 10px; background: var(--surface, #fafafa); overflow: hidden; }
.citations-toggle { display: flex; align-items: center; gap: 6px; padding: 7px 11px; font-size: 12px; font-weight: 600; color: var(--text-2, #6b7280); cursor: pointer; user-select: none; }
.citations-toggle:hover { color: var(--brand-deep, #1a56db); }
.citations-icon { font-size: 13px; }
.citations-arrow { margin-left: auto; transition: transform .18s; color: var(--text-2, #6b7280); }
.citations-arrow.expanded { transform: rotate(180deg); }
.citations-list { padding: 4px 11px 9px; border-top: 1px dashed var(--line-soft, #e4e3dd); display: flex; flex-direction: column; gap: 7px; }
.citation-item { }
.citation-file { font-size: 12px; font-weight: 700; color: var(--ink, #1a1b1c); }
.citation-snippet { font-size: 11.5px; color: var(--text-2, #6b7280); line-height: 1.5; margin-top: 2px; }

/* 消息操作栏 */
.message-actions { display: flex; gap: 6px; margin-top: 8px; opacity: 0; transition: opacity .2s; }
.message:hover .message-actions { opacity: 1; }
.msg-action-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; font-size: 12px;
    font-weight: 700; color: var(--text-2); border: 1.5px solid var(--line-soft); border-radius: 100px;
    transition: all .14s; background: var(--surface); }
.msg-action-btn svg { width: 13px; height: 13px; }
.msg-action-btn:hover { color: var(--red-deep); border-color: var(--ink); transform: translateY(-1px); }

/* ---------- Markdown 正文 ---------- */
.markdown-body { font-size: 14.5px; line-height: 1.8; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body p { margin: 8px 0; }
.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4 { font-weight: 900; line-height: 1.35;
    margin: 16px 0 9px; letter-spacing: -.3px; }
.markdown-body h1 { font-size: 21px; padding-bottom: 6px; border-bottom: 3px solid var(--ink); }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 16px; }
.markdown-body ul,.markdown-body ol { margin: 8px 0; padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote { border-left: 5px solid var(--yellow); background: var(--surface-2);
    padding: 8px 14px; margin: 10px 0; color: var(--text-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.markdown-body a { color: var(--brand-deep); text-decoration: underline; text-decoration-thickness: 2px; }
.markdown-body code:not(pre code) { background: var(--ink); color: var(--yellow); font-family: var(--font-mono);
    font-size: .88em; padding: 2px 7px; border-radius: 4px; font-weight: 600; }
.message.user .markdown-body code:not(pre code) { background: rgba(0,0,0,.25); color: #FFF1A8; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px;
    border: 2px solid var(--ink); box-shadow: var(--shadow-hard-sm); }
.markdown-body th { background: var(--ink); color: #fff; padding: 9px 12px; text-align: left; font-weight: 800; }
.markdown-body td { padding: 8px 12px; border: 1.5px solid var(--line-soft); }
.markdown-body tr:nth-child(even) td { background: var(--surface-2); }
.markdown-body hr { border: none; border-top: 3px dotted var(--text-3); margin: 16px 0; }
.markdown-body strong { font-weight: 900; }

/* 代码块窗口（renderMarkdown 生成，类名不可改） */
.code-block-wrapper { margin: 12px 0; border: 2px solid var(--ink); border-radius: var(--r-sm);
    overflow: hidden; box-shadow: var(--shadow-hard-sm); background: #161B26; }
.code-block-header { display: flex; align-items: center; justify-content: space-between;
    background: #232A3A; padding: 7px 12px; border-bottom: 2px solid #000; }
.code-block-lang { font-family: var(--font-mono); font-size: 11px; font-weight: 800; letter-spacing: 1px;
    color: var(--brand); text-transform: uppercase; }
.code-block-lang::before { content: "● ● ●   "; color: #FF5F57; letter-spacing: 2px; }
.code-block-copy { display: inline-flex; align-items: center; color: #C6CCD7; padding: 3px 8px;
    border-radius: 4px; font-size: 11px; transition: all .15s; }
.code-block-copy:hover { background: var(--brand); color: #082226; }
.code-block-wrapper pre { margin: 0; padding: 14px 16px; overflow-x: auto; background: #161B26; }
.code-block-wrapper pre code { background: transparent !important; color: #DCE6F5 !important;
    font-family: var(--font-mono); font-size: 13px; line-height: 1.7; padding: 0; }

/* ---------- 输入区 ---------- */
.input-area { flex-shrink: 0; position: relative; padding: 12px 24px 18px; background: linear-gradient(to top, var(--paper) 70%, transparent); }
.uploaded-files { max-width: 920px; margin: 0 auto 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.uploaded-file-card { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 8px;
    background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-sm);
    box-shadow: var(--shadow-hard-sm); font-size: 12.5px; animation: pop-in .25s var(--ease-pop) both; }
.file-icon { width: 28px; height: 28px; display: grid; place-items: center; background: var(--brand-soft);
    color: var(--brand-deep); border-radius: var(--r-sm); }
.file-icon svg { width: 15px; height: 15px; }
.file-info { display: flex; flex-direction: column; }
.file-name { font-weight: 700; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-type { font-size: 10px; color: var(--text-3); letter-spacing: 1px; }
.uploaded-file-card .remove { width: 20px; height: 20px; display: grid; place-items: center; font-size: 16px;
    line-height: 1; border-radius: 4px; color: var(--text-2); }
.uploaded-file-card .remove:hover { background: var(--red); color: #fff; }
.input-card { max-width: 920px; margin: 0 auto; background: var(--surface); border: 3px solid var(--ink);
    border-radius: var(--r-md); box-shadow: var(--shadow-hard); padding: 10px 12px 8px; transition: box-shadow .15s; }
.input-card:focus-within { box-shadow: 6px 6px 0 var(--brand); }
.chat-input { width: 100%; resize: none; border: none; background: transparent; color: var(--text);
    font-size: 15px; line-height: 1.6; max-height: 180px; padding: 4px 4px; }
.chat-input::placeholder { color: var(--text-3); }
.input-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.thinking-toggle-wrapper { position: relative; }
.thinking-btn { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px;
    border: 2px solid var(--ink); border-radius: var(--r-sm); background: var(--surface-2);
    color: var(--text-2); font-weight: 800; font-size: 12.5px; transition: all .14s var(--ease-pop); }
.thinking-btn svg { width: 16px; height: 16px; }
.thinking-btn:hover { transform: translateY(-1px); }
.thinking-btn.active { background: var(--violet); color: #fff; border-color: var(--ink); box-shadow: var(--shadow-hard-sm); }
.thinking-label { background: rgba(0,0,0,.2); padding: 1px 7px; border-radius: 100px; font-size: 11px; }
.thinking-effort-panel { position: absolute; bottom: calc(100% + 8px); left: 0; display: flex; gap: 4px;
    padding: 6px; background: var(--surface); border: 2px solid var(--ink); box-shadow: var(--shadow-hard);
    border-radius: var(--r-sm); z-index: 30; animation: menu-pop .18s var(--ease-pop) both; }
.effort-option { padding: 5px 14px; font-size: 12.5px; font-weight: 800; border-radius: 4px; cursor: pointer;
    color: var(--text-2); transition: all .12s; text-transform: uppercase; }
.effort-option:hover { background: var(--surface-2); }
.effort-option.selected { background: var(--violet); color: #fff; }
.upload-dropdown { position: absolute; bottom: calc(100% + 8px); left: 0; padding: 6px; background: var(--surface);
    border: 2px solid var(--ink); box-shadow: var(--shadow-hard); border-radius: var(--r-sm); z-index: 30;
    animation: menu-pop .18s var(--ease-pop) both; }
.upload-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px;
    font-weight: 700; white-space: nowrap; border-radius: 4px; }
.upload-dropdown-item:hover { background: var(--brand-soft); }
.upload-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 2px solid var(--ink);
    border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); transition: all .14s; }
.upload-btn:hover { background: var(--yellow); color: var(--ink); transform: rotate(90deg); }
.send-btn { margin-left: auto; width: 42px; height: 36px; display: grid; place-items: center;
    background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: var(--r-sm);
    box-shadow: var(--shadow-hard-sm); transition: all .12s var(--ease-pop); }
.send-btn:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.send-btn:active:not(:disabled) { transform: translate(2px,2px); box-shadow: none; }
.send-btn:disabled { background: var(--surface-2); color: var(--text-3); border-color: var(--line-soft); box-shadow: none; cursor: not-allowed; }
.stop-btn { margin-left: auto; height: 36px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px;
    background: var(--ink); color: #fff; border: 2px solid var(--ink); border-radius: var(--r-sm);
    font-weight: 800; font-size: 13px; box-shadow: var(--shadow-hard-sm); }
.stop-btn svg { width: 15px; height: 15px; }
.stop-btn:hover { background: var(--red); }
.input-hint { max-width: 920px; margin: 8px auto 0; font-size: 11px; color: var(--text-3); text-align: center; }

/* ============================ 6. 弹窗 ============================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,15,25,.5); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px);
    animation: fade-in .2s ease both; }
.modal { width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; background: var(--surface);
    border: 3px solid var(--ink); box-shadow: var(--shadow-hard-lg); clip-path: var(--clip-cut);
    animation: modal-in .3s var(--ease-pop) both; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px;
    border-bottom: 3px solid var(--ink); background: var(--brand-soft); }
.modal-header h3 { font-size: 19px; font-weight: 900; letter-spacing: -.3px; }
.modal-close { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--ink);
    border-radius: var(--r-sm); background: var(--surface); transition: all .14s; }
.modal-close:hover { background: var(--red); color: #fff; transform: rotate(90deg); }
.modal-body { padding: 22px; }
.modal-body .form-group { margin-bottom: 18px; }
.modal-body .form-group label { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--text-2); margin-bottom: 7px; }
.form-hint { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-top: 6px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px;
    border-top: 2px solid var(--line-soft); background: var(--surface-2); }
.modal-footer .btn-primary { padding: 9px 18px; font-size: 13.5px; }
.avatar-selector { display: flex; align-items: center; gap: 16px; }
.avatar-preview { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--ink); overflow: hidden;
    background: var(--brand); color: #082226; display: grid; place-items: center; font-size: 26px; font-weight: 900;
    flex-shrink: 0; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-direction: column; gap: 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-option { border: 2px solid var(--line-soft); border-radius: var(--r-sm); padding: 6px; cursor: pointer;
    transition: all .14s var(--ease-pop); background: var(--surface); }
.theme-option:hover { transform: translateY(-2px); }
.theme-option.active { border-color: var(--ink); box-shadow: var(--shadow-hard-sm); }
.theme-preview { height: 38px; border-radius: 4px; border: 1.5px solid var(--ink); }
.theme-name { text-align: center; font-size: 12px; font-weight: 700; padding-top: 5px; }

/* ============================ 7. Toast ============================ */
.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 80px); z-index: 200;
    padding: 12px 22px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 700;
    border: 2px solid #fff; border-radius: var(--r-sm); box-shadow: var(--shadow-hard);
    opacity: 0; transition: all .3s var(--ease-pop); pointer-events: none; max-width: 90vw;
    clip-path: var(--clip-cut-sm); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: #0E7D5C; }
.toast.error { background: var(--red); }
.toast.info { background: var(--ink); }

/* ============================ 8. 动画关键帧 ============================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes menu-pop { from { opacity: 0; transform: scale(.92) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(26px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes think-bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 3px rgba(34,201,154,.2); } 50% { box-shadow: 0 0 0 6px rgba(34,201,154,0); } }
@keyframes tool-glow { 0%,100% { box-shadow: 2px 2px 0 var(--ink); } 50% { box-shadow: 2px 2px 0 var(--brand); } }

/* ============================ 9. 响应式 ============================ */
/* 背景大字是否显示由 app.js 按卡片两侧空白带实际宽度动态判断（放不下自动 display:none），无需断点一刀切 */
/* 单列断点收紧到 700px：桌面半屏（约 810px CSS 视口）仍保持双列，背景大字可见；仅手机单列 */
@media (max-width: 700px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-brand { display: none; }   /* 移动端只留表单，品牌区隐藏 */
    .auth-form-wrapper { padding: 20px; }
    .auth-bg-word { display: none; } /* 移动端隐藏背景大字，避免定位错位 */
}
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 82vw; max-width: 300px;
        transform: translateX(-100%); transition: transform .28s var(--ease-pop); }
    .sidebar.open { transform: translateX(0); box-shadow: 8px 0 0 rgba(0,0,0,.3); }
    .menu-toggle { display: grid; }
    .messages-wrapper { padding: 18px 14px 10px; }
    .message-content-wrapper { max-width: calc(100% - 52px); }
    .message-avatar { width: 34px; height: 34px; }
    .input-area { padding: 10px 12px 14px; }
    .main-header { padding: 0 14px; height: 56px; }
    .current-session-title { font-size: 16px; }
    .msg-action-btn span { display: none; }
    .msg-action-btn { padding: 6px 8px; }
    .theme-grid { grid-template-columns: repeat(2, 1fr); }
    .modal { clip-path: none; }
    .auth-card { clip-path: none; padding: 30px 24px; }
}
@media (max-width: 420px) {
    .quick-actions { flex-direction: column; align-items: stretch; }
    .quick-action { text-align: center; }
    .welcome-state h1 { font-size: 26px; }
    .message-content { padding: 11px 13px; }
}
/* 用户偏好：移动端登录页可滚动（修复之前无法滑动问题） */
@media (max-width: 768px) {
    body { overflow: auto; }
    .auth-layout { height: auto; min-height: 100vh; overflow-y: auto; }
}

/* ========== 全新 UI 追加：装饰元素 ========== */
/* 认证卡片编号标签（P5 式章节编号） */
.auth-tag {
    display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: 2.5px;
    color: #fff; background: var(--ink); padding: 4px 10px; margin-bottom: 16px;
    clip-path: polygon(0 0,100% 0,calc(100% - 7px) 100%,0 100%);
}
.auth-tag.tag-mint { background: var(--mint); color: #06281D; }
.tag-violet .auth-tag { background: var(--violet); }
/* 品牌区竖排装饰文字 */
.auth-side-deco {
    position: absolute; right: 18px; bottom: 46px; z-index: 1;
    writing-mode: vertical-rl; font-size: 12px; font-weight: 900; letter-spacing: 8px;
    color: rgba(255,255,255,.22);
}
.sidebar-vert-deco {
    position: absolute; right: 6px; top: 70px; writing-mode: vertical-rl;
    font-size: 10px; font-weight: 900; letter-spacing: 6px; color: rgba(255,255,255,.12);
    pointer-events: none;
}
/* MCP 路径输入框 */
.mcp-path-input {
    width: 100%; padding: 8px 12px; border: 2px solid var(--ink); border-radius: var(--r-sm);
    font-size: 13px; font-family: var(--font-mono); background: var(--surface-2); color: var(--text);
}
.mcp-path-input:focus { background: var(--surface); box-shadow: 3px 3px 0 var(--brand); outline: none; }
/* 重启提示图标 */
.restart-icon {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--yellow);
    border: 2px solid var(--ink); display: grid; place-items: center; font-size: 22px; font-weight: 900;
}
.inline-code {
    background: var(--surface-2); border: 1.5px solid var(--line-soft); padding: 2px 6px;
    border-radius: 4px; font-size: 12px; font-family: var(--font-mono);
}


/* ========== 认证页动态装饰圆环（路由联动平滑变形） ========== */
/* 登录=完整环 / 注册=双弧分裂 / 找回=3/4环+补弧；stroke-dasharray 可被 CSS 过渡 */
.auth-ring {
    position: absolute; right: -110px; top: -110px; width: 380px; height: 380px;
    z-index: 0; pointer-events: none; overflow: visible;
    opacity: .5;  /* 弧线降为氛围层，米塔为主体 */
}
.auth-ring circle { fill: none; stroke-width: 13; stroke-linecap: round; }
/* 三态配色：登录=淡蓝 / 注册=粉 / 找回=红；颜色 1s 平滑过渡 */
.ring-main { stroke: rgba(122,180,242,.95); transition: stroke .7s var(--ease-smooth), stroke-dasharray .7s cubic-bezier(.65,.05,.36,1), stroke-dashoffset .7s cubic-bezier(.65,.05,.36,1); }
.ring-sub { stroke: rgba(122,180,242,.42); stroke-width: 8; transition: stroke .7s var(--ease-smooth), stroke-dasharray .7s cubic-bezier(.65,.05,.36,1), stroke-dashoffset .7s cubic-bezier(.65,.05,.36,1); }
.ring-dot { fill: #9CC9F5; stroke: none; transition: fill .7s var(--ease-smooth); }
/* 圆点沿圆弧轨迹运动：圆点固定在 12 点，整组绕圆心(200,200)旋转，故切换时沿圆周滑动而非直线瞬移 */
.ring-dot-rot { transform-origin: 200px 200px; transition: transform 1s cubic-bezier(.65,.05,.36,1), opacity .8s ease; opacity: 1; }
/* 登录(主)态圆点隐藏；注册/找回态显示。随 .auth-layout.ring-{mode} 自动切换，过渡由上面 transition 负责 */
.auth-layout.ring-login .ring-dot-rot { opacity: 0; }
.ring-register .ring-main { stroke: rgba(255,128,168,.95); }
.ring-register .ring-sub { stroke: rgba(255,128,168,.42); }
.ring-register .ring-dot { fill: #FFA9C4; }
.ring-recover .ring-main { stroke: rgba(255,59,78,.92); }
.ring-recover .ring-sub { stroke: rgba(255,59,78,.42); }
.ring-recover .ring-dot { fill: #FF6B7D; }

/* 默认（登录）：完整圆环，副弧隐藏，圆点居顶 */
.auth-ring .ring-main { stroke-dasharray: 942.48 0; stroke-dashoffset: 0; }
.auth-ring .ring-sub { stroke-dasharray: 0 942.48; stroke-dashoffset: 0; }
/* 注册：双弧分裂（相对两个半环），圆点移至底部 */
.ring-register .ring-main { stroke-dasharray: 471.24 471.24; }
.ring-register .ring-sub { stroke-dasharray: 471.24 471.24; stroke-dashoffset: -471.24; }
/* 找回：3/4 环留缺口，补弧填充缺口，圆点移至缺口处（左侧） */
.ring-recover .ring-main { stroke-dasharray: 706.86 235.62; stroke-dashoffset: -117.81; }
.ring-recover .ring-sub { stroke-dasharray: 117.81 824.67; stroke-dashoffset: -117.81; }

/* 路由切换方向动画（由 app.js watch 注入一次性 class） */
@keyframes ring-wave {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-4deg); }
    50% { transform: scale(.96) rotate(3deg); }
    75% { transform: scale(1.06) rotate(-1deg); }
    100% { transform: scale(1) rotate(0deg); }
}
@keyframes ring-grow {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
/* 注册/找回 -> 登录：扇形扇出式覆盖——淡蓝扇形从右上角（-45°）张开铺满整圆，
   随后扇形淡出（环内内容变空），主弧经 CSS 过渡平滑回归完整环（非弧线生长） */
/* 覆盖圆盘：整圆淡蓝填充，从圆心原点 scale 扩张成固定圆（bloom） */
.ring-fan {
    fill: rgba(122,180,242,.30);
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}
.auth-ring.ring-wave { animation: ring-wave 1s var(--ease-smooth); }
.auth-ring.ring-grow { animation: ring-grow 1s var(--ease-smooth); }
.auth-ring.ring-cover .ring-fan {
    opacity: 1;
    animation: fan-bloom .75s cubic-bezier(.2,.75,.3,1), fan-fade .5s ease .95s forwards;
}
.auth-ring.ring-cover .ring-sub { stroke-dasharray: 0 942.48 !important; }
@keyframes fan-bloom {
    0% { transform: scale(0); }
    70% { transform: scale(1.08); }
    100% { transform: scale(1); }
}
@keyframes fan-fade {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 左侧品牌区文案滚轮过渡（方向感知，由 app.js 注入 quote-up/quote-down） */
.quote-up-enter-active, .quote-up-leave-active,
.quote-down-enter-active, .quote-down-leave-active {
    transition: opacity .55s var(--ease-smooth), transform .55s var(--ease-smooth);
}
/* 上滑：旧文案向上滚出，新文案从下方滚入 */
.quote-up-leave-to { opacity: 0; transform: translateY(-100%); }
.quote-up-enter-from { opacity: 0; transform: translateY(100%); }
/* 下滑：旧文案向下滚出，新文案从上方滚入 */
.quote-down-leave-to { opacity: 0; transform: translateY(100%); }
.quote-down-enter-from { opacity: 0; transform: translateY(-100%); }

/* ========== 认证页米塔形象（路由联动：容器位移缩放 + 换脸交叉淡化 + 待机微动） ========== */
.auth-mita {
    position: absolute; z-index: 0; pointer-events: none;
    width: 72%; aspect-ratio: 1 / 1; height: auto;
    /* 恢复三态位置/尺寸平滑过渡（渐大/滑动效果）；图片已压至 640px 且去掉 drop-shadow，
       0.65s 短过渡在 Edge 下重排成本可控 */
    transition: left .65s var(--ease-smooth), top .65s var(--ease-smooth),
                bottom .65s var(--ease-smooth), width .65s var(--ease-smooth), right .65s var(--ease-smooth);
}
.auth-mita img {
    position: absolute; left: 0; top: 0; width: 100%; height: 100%;
    object-fit: contain;
    /* drop-shadow 在 transform/尺寸动画期间逐帧重算滤镜，是 Edge 卡顿重要来源，已移除 */
    will-change: transform, opacity;
}
/* 登录：睡衣米塔，左下角，柔和呼吸（慵懒惬意） */
.auth-mita.mita-login { left: 6%; bottom: 36px; width: min(84%, 420px); }
.auth-mita.mita-login img { animation: mita-breathe 4.2s ease-in-out infinite; }
/* 注册：米塔，右缘对齐品牌区右边线，柔和呼吸（温柔） */
.auth-mita.mita-register { left: auto; right: 0; bottom: 36px; width: min(93%, 450px); }
.auth-mita.mita-register img { animation: mita-breathe 4.2s ease-in-out infinite; }
/* 找回：米塔，右缘对齐品牌区右边线，轻微摇摆 + 安抚感 */
.auth-mita.mita-recover { left: auto; right: 0; bottom: 36px; width: min(100%, 495px); }
.auth-mita.mita-recover img { animation: mita-sway 2.4s ease-in-out infinite; }

/* 换脸交叉淡化（Vue transition 默认并行模式：旧图淡出 + 新图淡入） */
.mita-fade-enter-active, .mita-fade-leave-active { transition: opacity .55s ease; }
.mita-fade-enter-from, .mita-fade-leave-to { opacity: 0; }

@keyframes mita-float {
    from { transform: translateY(0); }
    to { transform: translateY(-14px); }
}
@keyframes mita-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes mita-sway {
    0%, 100% { transform: rotate(-2deg) translateX(0); }
    45% { transform: rotate(2deg) translateX(6px); }
    50%, 54% { transform: rotate(-1.5deg) translateX(-4px); }  /* 病娇小抖动 */
}

/* 弱化动效偏好：关闭待机动画与位移过渡 */
@media (prefers-reduced-motion: reduce) {
    .auth-mita { transition: none; }
    .auth-ring.ring-wave, .auth-ring.ring-grow, .auth-ring.ring-cover .ring-fan { animation: none !important; opacity: 0 !important; }
    .auth-mita img { animation: none !important; }
    .mita-fade-enter-active, .mita-fade-leave-active { transition: opacity .2s linear; }
}

/* ── 人格手选 tab（H-20260919-01）── */
.persona-select-wrapper { position: relative; }
.persona-btn { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px;
    border: 2px solid var(--ink); border-radius: var(--r-sm); background: var(--surface-2);
    color: var(--text-2); font-weight: 800; font-size: 12.5px; transition: all .14s var(--ease-pop); }
.persona-btn svg { width: 16px; height: 16px; }
.persona-btn:hover { transform: translateY(-1px); }
.persona-btn.active { background: var(--violet); color: #fff; border-color: var(--ink); box-shadow: var(--shadow-hard-sm); }
.persona-menu { position: absolute; bottom: calc(100% + 8px); left: 0; display: flex; gap: 4px;
    padding: 6px; background: var(--surface); border: 2px solid var(--ink); box-shadow: var(--shadow-hard);
    border-radius: var(--r-sm); z-index: 30; animation: menu-pop .18s var(--ease-pop) both; }
.persona-option { padding: 5px 12px; font-size: 12.5px; font-weight: 800; border-radius: 4px; cursor: pointer;
    color: var(--text-2); transition: all .12s; white-space: nowrap;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.25; }
.persona-option-label { font-size: 12.5px; font-weight: 800; }
.persona-option-hint { font-size: 10px; font-weight: 500; opacity: .68; }
.persona-option:hover { background: var(--surface-2); }
.persona-option.selected { background: var(--violet); color: #fff; }
/* ── chibi 浮动气泡（H-20260919-01）── */
.chibi-dock { position: fixed; right: 16px; top: 96px; display: flex; flex-direction: column; gap: 10px; z-index: 80; pointer-events: none; max-width: 260px; }
.chibi-item { pointer-events: auto; display: flex; flex-direction: row; align-items: flex-end; justify-content: flex-end; gap: 8px; }
.chibi-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--ink); transform: scaleX(-1); flex-shrink: 0; }
.chibi-bubble-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 200px; padding: 8px 10px; background: var(--surface); border: 2px solid var(--ink); border-radius: 14px 14px 4px 14px; box-shadow: var(--shadow-hard); animation: menu-pop .22s var(--ease-pop) both; }
.chibi-text { font-size: 12.5px; line-height: 1.5; color: var(--text-2); font-weight: 600; }
.chibi-close { align-self: flex-end; width: 18px; height: 18px; display: grid; place-items: center; border: none; background: transparent; color: var(--text-3); font-size: 14px; cursor: pointer; line-height: 1; }
.chibi-close:hover { color: var(--ink); }
.ack-banner { font-size: 13px; color: var(--text-2); font-style: italic; margin-bottom: 10px; padding: 6px 10px; background: rgba(0,0,0,0.03); border-left: 3px solid var(--accent, #9BBBF4); border-radius: 0 8px 8px 0; }

/* 2026-09-19 P2: 引用角标 */
.cite-ref { color: #6b7cff; font-size: 0.75em; vertical-align: super; margin: 0 1px; cursor: pointer; }
