/* =============================================================
   AI 陪伴聊天系统 · 用户端样式
   移动优先 / 最大宽 480 居中 / 毛玻璃 / 8px 网格
   ============================================================= */

:root {
    --p: #FF8FA3;
    --p-deep: #FF7A95;
    --p-soft: #FFF5F7;
    --p-soft-2: #FFE9EF;

    --bg: #FFFFFF;
    --bg-2: #FFF9FB;
    --bg-3: #F7F1F3;
    --glass: rgba(255, 255, 255, .65);
    --glass-strong: rgba(255, 255, 255, .82);
    --bubble-ai: #FFFFFF;
    --bubble-user: linear-gradient(135deg, #FFA3B4 0%, #FF8FA3 55%, #FF8098 100%);

    --ink: #2B2226;
    --ink-2: #5E5057;
    --muted: #9C8C94;
    --line: rgba(43, 34, 38, .07);
    --line-strong: rgba(43, 34, 38, .12);

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .04);
    --shadow: 0 8px 30px rgba(0, 0, 0, .06);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .12);

    --r-card: 20px;
    --r-bubble: 18px;
    --r-btn: 14px;

    --ease: cubic-bezier(.4, 0, .2, 1);
    --t: 240ms;

    --nav-h: 62px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
    --bg: #141013;
    --bg-2: #1A1518;
    --bg-3: #221B1F;
    --glass: rgba(38, 30, 34, .62);
    --glass-strong: rgba(38, 30, 34, .86);
    --bubble-ai: #241D21;
    --ink: #F4EBEF;
    --ink-2: #CDBCC4;
    --muted: #8E7D86;
    --line: rgba(255, 255, 255, .08);
    --line-strong: rgba(255, 255, 255, .14);
    --p-soft: #2A1E22;
    --p-soft-2: #34232A;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --bg: #141013;
        --bg-2: #1A1518;
        --bg-3: #221B1F;
        --glass: rgba(38, 30, 34, .62);
        --glass-strong: rgba(38, 30, 34, .86);
        --bubble-ai: #241D21;
        --ink: #F4EBEF;
        --ink-2: #CDBCC4;
        --muted: #8E7D86;
        --line: rgba(255, 255, 255, .08);
        --line-strong: rgba(255, 255, 255, .14);
        --p-soft: #2A1E22;
        --p-soft-2: #34232A;
        --shadow: 0 8px 30px rgba(0, 0, 0, .35);
        --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background: var(--bg-3);
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    overflow: hidden;
}

button, input, textarea { font-family: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--p-deep); }
[hidden] { display: none !important; }

.ic { display: inline-block; vertical-align: middle; flex: 0 0 auto; }

/* ---------------- 手机画布 ---------------- */
.stage {
    position: relative;
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background var(--t) var(--ease);
}

@media (min-width: 560px) {
    body {
        background:
            radial-gradient(1200px 600px at 15% 10%, #FFE7EE 0%, transparent 60%),
            radial-gradient(900px 500px at 85% 90%, #F3E8FF 0%, transparent 60%),
            #F6EFF2;
        padding: 24px 0;
        align-items: center;
    }
    html[data-theme="dark"] body {
        background:
            radial-gradient(1200px 600px at 15% 10%, #2A1A20 0%, transparent 60%),
            radial-gradient(900px 500px at 85% 90%, #1E1A2A 0%, transparent 60%),
            #0E0B0D;
    }
    .stage {
        height: min(880px, calc(100dvh - 48px));
        min-height: 0;
        border-radius: 32px;
        box-shadow: 0 30px 80px rgba(80, 40, 55, .18), 0 0 0 1px rgba(255, 255, 255, .5) inset;
    }
}

/* ---------------- 登录 ---------------- */
.login {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px calc(32px + var(--safe-b));
    background: linear-gradient(165deg, #FFF6F9 0%, #FFEFF4 45%, #FDE7EE 100%);
    overflow: hidden;
}
html[data-theme="dark"] .login,
html[data-theme="auto"] .login { background: var(--bg); }
@media (prefers-color-scheme: light) {
    html[data-theme="auto"] .login { background: linear-gradient(165deg, #FFF6F9 0%, #FFEFF4 45%, #FDE7EE 100%); }
}

.login-bg {
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(45% 35% at 20% 20%, rgba(255, 143, 163, .38), transparent 70%),
        radial-gradient(40% 30% at 85% 30%, rgba(255, 199, 214, .5), transparent 70%),
        radial-gradient(50% 40% at 60% 90%, rgba(214, 196, 255, .35), transparent 70%);
    filter: blur(8px);
    animation: floatBg 14s var(--ease) infinite alternate;
}
@keyframes floatBg {
    from { transform: translate3d(-2%, -1%, 0) scale(1); }
    to { transform: translate3d(2%, 2%, 0) scale(1.05); }
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 340px;
    padding: 32px 26px 26px;
    border-radius: 26px;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, .7);
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: rise 460ms var(--ease) both;
}
html[data-theme="dark"] .login-card { border-color: rgba(255, 255, 255, .08); }
@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(140deg, #FFB3C1, #FF8FA3 60%, #FF7A95);
    box-shadow: 0 12px 30px rgba(255, 143, 163, .45);
}
.login-title { font-size: 24px; margin: 0 0 4px; letter-spacing: .5px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

.field { display: block; text-align: left; margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--ink);
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-btn);
    outline: none;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.field input:focus {
    border-color: var(--p);
    box-shadow: 0 0 0 3px rgba(255, 143, 163, .18);
}

.form-error {
    margin: 0 0 12px;
    padding: 9px 12px;
    font-size: 13px;
    color: #B4232B;
    background: rgba(255, 99, 99, .1);
    border-radius: 10px;
    text-align: left;
}

.btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 15.5px;
    font-weight: 600;
    color: #fff;
    border-radius: var(--r-btn);
    background: linear-gradient(135deg, #FFA0B3, var(--p-deep));
    box-shadow: 0 10px 26px rgba(255, 122, 149, .38);
    transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.btn-primary:active { transform: scale(.975); }
.btn-primary[disabled] { opacity: .6; pointer-events: none; }
.login-foot { margin: 16px 0 0; font-size: 12px; color: var(--muted); }

/* ---------------- 主框架 ---------------- */
.app {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--nav-h) + 26px + var(--safe-b));
}

.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--line);
    z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-avatar .avatar, .topbar-avatar svg { width: 36px; height: 36px; border-radius: 50%; }
.topbar-text { min-width: 0; }
.topbar-title {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-sub {
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.dot-online {
    width: 6px; height: 6px; border-radius: 50%;
    background: #4BC48A;
    box-shadow: 0 0 0 3px rgba(75, 196, 138, .18);
}
.topbar-right { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--ink-2);
    transition: background var(--t) var(--ease), transform var(--t) var(--ease), color var(--t) var(--ease);
}
.icon-btn:active { transform: scale(.92); background: var(--p-soft-2); color: var(--p-deep); }

/* ---------------- 视图 ---------------- */
.views { position: relative; flex: 1 1 auto; min-height: 0; }
.view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    min-height: 0;
}
.view.is-active { display: flex; animation: fadeUp 260ms var(--ease) both; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 24px;
}

.view-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 4px;
}
.view-head h2 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.btn-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--p-deep);
    background: var(--p-soft);
    border-radius: 12px;
    transition: transform var(--t) var(--ease), background var(--t) var(--ease);
}
.btn-mini:active { transform: scale(.95); background: var(--p-soft-2); }

/* ---------------- 聊天区 ---------------- */
.view-chat { overflow: hidden; }
.chat-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--chat-bg, linear-gradient(160deg, #FFF1F4 0%, #FFE3EA 45%, #FFD3DF 100%));
    background-size: cover;
    background-position: center;
    scroll-behavior: smooth;
}
html[data-theme="dark"] .chat-scroll { background: var(--chat-bg-dark, #141013); }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .chat-scroll { background: var(--chat-bg-dark, #141013); }
}
.chat-inner {
    min-height: 100%;
    padding: 12px 14px 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.msg-list { display: flex; flex-direction: column; gap: 14px; }

.load-more {
    align-self: center;
    margin: 4px 0 12px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--ink-2);
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

.msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: msgIn 240ms var(--ease) both;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: none; }
}
.msg.user { flex-direction: row-reverse; }
.msg-avatar { flex: 0 0 auto; padding-top: 2px; }
.msg-avatar .avatar, .msg-avatar svg, .msg-avatar img { width: 36px; height: 36px; border-radius: 50%; }
.msg-body { max-width: 78%; min-width: 0; display: flex; flex-direction: column; }
.msg.user .msg-body { align-items: flex-end; }

.bubble {
    position: relative;
    padding: 10px 13px;
    font-size: 15px;
    line-height: 1.62;
    color: var(--ink);
    background: var(--bubble-ai);
    border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) 6px;
    box-shadow: var(--shadow-sm);
    word-break: break-word;
    overflow-wrap: anywhere;
    transition: transform var(--t) var(--ease);
    cursor: pointer;
}
.bubble:active { transform: scale(.99); }
.msg.user .bubble {
    color: #fff;
    background: var(--bubble-user);
    border-radius: var(--r-bubble) var(--r-bubble) 6px var(--r-bubble);
    box-shadow: 0 6px 18px rgba(255, 122, 149, .3);
}
.bubble .md > :first-child { margin-top: 0; }
.bubble .md > :last-child { margin-bottom: 0; }
.bubble .md p { margin: 0 0 8px; }
.bubble .md ul, .bubble .md ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble .md li { margin: 2px 0; }
.bubble .md h2, .bubble .md h3, .bubble .md h4 { margin: 8px 0 6px; font-size: 16px; }
.bubble .md code {
    padding: 1px 5px;
    font-size: 13px;
    background: rgba(255, 143, 163, .14);
    border-radius: 6px;
}
.bubble .md pre {
    margin: 6px 0;
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.55;
    background: rgba(0, 0, 0, .06);
    border-radius: 10px;
}
html[data-theme="dark"] .bubble .md pre { background: rgba(255, 255, 255, .07); }
.msg.user .bubble .md pre { background: rgba(255, 255, 255, .18); }
.bubble .md a { text-decoration: underline; text-underline-offset: 2px; }
.msg.user .bubble .md a { color: #fff; }

.bubble-images {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 8px;
}
.bubble-images:only-child { margin-bottom: 0; }
.bubble-images img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    background: rgba(0, 0, 0, .04);
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    padding: 0 4px;
    font-size: 10.5px;
    color: var(--muted);
    opacity: .9;
}
.msg-model {
    padding: 0 5px;
    border-radius: 6px;
    background: rgba(255, 143, 163, .12);
    color: var(--p-deep);
    font-size: 10px;
}

.msg-actions { display: none; gap: 6px; margin-top: 6px; }
.msg.show-actions .msg-actions { display: flex; }
.msg-actions button {
    padding: 4px 10px;
    font-size: 11.5px;
    color: var(--ink-2);
    background: var(--glass-strong);
    border: 1px solid var(--line);
    border-radius: 999px;
    backdrop-filter: blur(10px);
}
.msg-actions button:active { transform: scale(.94); }

/* 正在输入 */
.typing { display: flex; gap: 8px; align-items: flex-end; padding: 4px 2px 0; }
.typing-avatar .avatar { width: 34px; height: 34px; border-radius: 50%; }
.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bubble-ai);
    border-radius: 18px 18px 18px 6px;
    box-shadow: var(--shadow-sm);
}
.typing-bubble i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--p);
    opacity: .45;
    animation: blink 1.2s infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .18s; }
.typing-bubble i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* 空会话 */
.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
}
.empty-avatar .avatar, .empty-avatar svg { width: 76px; height: 76px; border-radius: 50%; box-shadow: var(--shadow); }
.empty-name { font-size: 17px; font-weight: 650; }
.empty-greeting {
    max-width: 280px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--ink-2);
    background: var(--glass);
    backdrop-filter: blur(14px);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

/* ---------------- 输入区 ---------------- */
.composer {
    flex: 0 0 auto;
    padding: 8px 12px 10px;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--line);
}
.quick-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }
.quick-row:empty { display: none; }
.quick-chip {
    flex: 0 0 auto;
    padding: 7px 13px;
    font-size: 12.5px;
    color: var(--ink-2);
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: transform var(--t) var(--ease), background var(--t) var(--ease);
    white-space: nowrap;
}
.quick-chip:active { transform: scale(.95); background: var(--p-soft-2); color: var(--p-deep); }

.preview-row { display: flex; gap: 8px; padding: 0 2px 8px; flex-wrap: wrap; }
.preview-item { position: relative; width: 62px; height: 62px; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow-sm); }
.preview-remove {
    position: absolute;
    top: -5px; right: -5px;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    background: rgba(30, 20, 24, .72);
    border-radius: 50%;
    backdrop-filter: blur(6px);
}
.preview-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .35);
    border-radius: 12px;
    color: #fff;
}

.composer-box {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 5px 6px 5px 8px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.composer-box:focus-within {
    border-color: rgba(255, 143, 163, .55);
    box-shadow: 0 0 0 3px rgba(255, 143, 163, .12);
}
#chatInput {
    flex: 1;
    max-height: 120px;
    padding: 8px 2px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: none;
    resize: none;
    scrollbar-width: none;
}
#chatInput::-webkit-scrollbar { display: none; }
#chatInput::placeholder { color: var(--muted); }

.send-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #FFA6B7, var(--p-deep));
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(255, 122, 149, .35);
    transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.send-btn:active { transform: scale(.9); }
.send-btn[disabled] { opacity: .4; box-shadow: none; pointer-events: none; }

/* ---------------- 底部胶囊导航 ---------------- */
.tabbar {
    position: fixed;
    left: 50%;
    bottom: calc(12px + var(--safe-b));
    transform: translateX(-50%);
    width: min(456px, calc(100% - 24px));
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 999px;
    box-shadow: 0 10px 34px rgba(90, 50, 65, .16);
    z-index: 50;
}
html[data-theme="dark"] .tabbar { border-color: rgba(255, 255, 255, .08); }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .tabbar { border-color: rgba(255, 255, 255, .08); }
}
.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 48px;
    font-size: 10.5px;
    color: var(--muted);
    border-radius: 999px;
    transition: color var(--t) var(--ease), transform var(--t) var(--ease), background var(--t) var(--ease);
}
.tab:active { transform: scale(.93); }
.tab.is-active { color: var(--p-deep); background: rgba(255, 143, 163, .12); }
.tab.is-active .ic { filter: drop-shadow(0 2px 6px rgba(255, 122, 149, .4)); }

/* ---------------- 会话 / 人格卡片 ---------------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.conv-item, .persona-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-sm);
    transition: transform var(--t) var(--ease), background var(--t) var(--ease), border-color var(--t) var(--ease);
    cursor: pointer;
}
.conv-item:active, .persona-item:active { transform: scale(.985); background: var(--p-soft); }
.conv-item .avatar, .persona-item .avatar,
.conv-item svg.avatar, .persona-item svg.avatar { width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto; }
.conv-main, .persona-main { flex: 1; min-width: 0; }
.conv-title, .persona-name {
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-last {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.conv-time { font-size: 11px; color: var(--muted); }
.conv-del {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
    border-radius: 8px;
}
.conv-del:active { background: rgba(214, 69, 69, .1); color: #D64545; }

.persona-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tag {
    padding: 1px 8px;
    font-size: 10.5px;
    color: var(--p-deep);
    background: rgba(255, 143, 163, .13);
    border-radius: 999px;
}
.persona-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.persona-actions button {
    padding: 5px 10px;
    font-size: 11.5px;
    color: var(--ink-2);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.persona-actions button.primary { color: #fff; background: var(--p); border-color: transparent; }
.persona-actions button:active { transform: scale(.94); }
.badge-current {
    padding: 1px 7px;
    font-size: 10px;
    color: #2E9E6B;
    background: rgba(75, 196, 138, .14);
    border-radius: 999px;
    margin-left: 6px;
}

.empty-tip, .hint-text {
    margin: 24px 4px;
    text-align: center;
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------------- 我的 ---------------- */
.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    margin: 4px 0 14px;
    background: linear-gradient(140deg, rgba(255, 143, 163, .16), rgba(255, 213, 224, .28));
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
}
html[data-theme="dark"] .profile-card {
    background: linear-gradient(140deg, rgba(255, 143, 163, .16), rgba(255, 143, 163, .05));
    border-color: rgba(255, 255, 255, .06);
}
.profile-avatar .avatar, .profile-avatar svg, .profile-avatar img { width: 56px; height: 56px; border-radius: 50%; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 17px; font-weight: 650; }
.profile-id { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section-card {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-sm);
}
.section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 12px;
}
.section-title .ic { color: var(--p-deep); }

.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-3);
    border-radius: 14px;
}
.segmented button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 4px;
    font-size: 12.5px;
    color: var(--ink-2);
    border-radius: 11px;
    transition: all var(--t) var(--ease);
}
.segmented button.is-active {
    color: var(--p-deep);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.bg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.bg-item {
    position: relative;
    height: 58px;
    border-radius: 12px;
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t) var(--ease), border-color var(--t) var(--ease);
    background-size: cover;
    background-position: center;
}
.bg-item:active { transform: scale(.96); }
.bg-item.is-active { border-color: var(--p-deep); }
.bg-item.is-active::after {
    content: "";
    position: absolute;
    right: 5px; bottom: 5px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--p-deep)
        url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5l5 5 10-11'/%3E%3C/svg%3E")
        center/12px no-repeat;
}
.color-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.color-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--line-strong);
    transition: transform var(--t) var(--ease), border-color var(--t) var(--ease);
}
.color-dot:active { transform: scale(.9); }
.color-dot.is-active { border-color: var(--p-deep); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--ink-2);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-btn);
    transition: transform var(--t) var(--ease), background var(--t) var(--ease);
}
.btn-ghost:active { transform: scale(.97); background: var(--p-soft); }
.btn-ghost.full { width: 100%; }

.row-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 2px;
    font-size: 14px;
    color: var(--ink);
}
.row-btn > span { display: flex; align-items: center; gap: 8px; }
.row-btn .ic { color: var(--muted); }

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px;
    margin-top: 4px;
    font-size: 14px;
    color: #D64545;
    background: rgba(214, 69, 69, .07);
    border-radius: var(--r-btn);
    transition: transform var(--t) var(--ease);
}
.btn-logout:active { transform: scale(.98); }
.version-text { text-align: center; font-size: 11.5px; color: var(--muted); margin: 16px 0 8px; }

/* ---------------- 底部弹层 ---------------- */
.sheet-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(20, 12, 16, .38);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--t) var(--ease);
}
.sheet-mask.show { opacity: 1; }
.sheet {
    width: 100%;
    max-width: 480px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    padding: 16px 18px calc(18px + var(--safe-b));
    background: var(--bg);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
    transform: translateY(24px);
    transition: transform 280ms var(--ease);
}
.sheet-mask.show .sheet { transform: translateY(0); }
@media (min-width: 560px) {
    .sheet { margin-bottom: 12px; border-radius: 24px; }
    .sheet-mask { align-items: center; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-title { font-size: 16px; font-weight: 650; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; }

.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, .select {
    width: 100%;
    padding: 11px 13px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-btn);
    outline: none;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--p);
    box-shadow: 0 0 0 3px rgba(255, 143, 163, .15);
}
.textarea { min-height: 110px; line-height: 1.6; resize: vertical; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.avatar-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-option {
    width: 48px; height: 48px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    overflow: hidden;
    transition: transform var(--t) var(--ease), border-color var(--t) var(--ease);
}
.avatar-option svg, .avatar-option img { width: 100%; height: 100%; display: block; }
.avatar-option.is-active { border-color: var(--p-deep); }
.avatar-option:active { transform: scale(.93); }

.chip-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--r-btn); }
.chip-input input { flex: 1; min-width: 90px; padding: 4px; font-size: 13.5px; color: var(--ink); background: none; border: 0; outline: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 12px;
    color: var(--p-deep);
    background: rgba(255, 143, 163, .14);
    border-radius: 999px;
}
.chip button { display: flex; color: inherit; opacity: .7; }

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn-primary { flex: 1; }
.sheet-actions .btn-ghost { flex: 0 0 auto; }

/* ---------------- 图片查看器 ---------------- */
.viewer {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
    animation: fadeIn 200ms var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.viewer img { max-width: 94vw; max-height: 88vh; border-radius: 10px; object-fit: contain; }

/* ---------------- Toast ---------------- */
.toast {
    position: fixed;
    left: 50%;
    top: 18px;
    transform: translate(-50%, -16px);
    max-width: min(420px, calc(100% - 32px));
    padding: 10px 16px;
    font-size: 13.5px;
    color: #fff;
    background: rgba(38, 28, 33, .9);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
    z-index: 300;
    text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: rgba(190, 46, 54, .94); }

/* 头像通用 */
.avatar { border-radius: 50%; object-fit: cover; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(140deg, #C9B8BF, #A9949D);
    border-radius: 50%;
}

/* 滚动条（桌面） */
@media (min-width: 560px) {
    .chat-scroll::-webkit-scrollbar, .scroll-area::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { width: 6px; }
    .chat-scroll::-webkit-scrollbar-thumb, .scroll-area::-webkit-scrollbar-thumb, .sheet-body::-webkit-scrollbar-thumb {
        background: rgba(150, 120, 135, .25);
        border-radius: 99px;
    }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
