*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%}
body{
    font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
    background:#f7f7f8;
    color:#1a1a1a;
    display:flex;
    height:100vh;
    overflow:hidden;
}

.login-mask{
    position:fixed;inset:0;
    background:rgba(42,31,74,.55);
    backdrop-filter:blur(6px);
    -webkit-backdrop-filter:blur(6px);
    z-index:2000;
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
}
.login-mask.on{display:flex}

.login-box{
    width:100%;max-width:340px;background:#fff;
    border-radius:22px;padding:28px 22px 22px;
    box-shadow:0 30px 80px -20px rgba(139,92,246,.5);
    text-align:center;position:relative;
}
.login-box .close{
    position:absolute;top:12px;right:14px;
    width:28px;height:28px;border-radius:50%;
    border:0;background:#f0f0f4;color:#888;font-size:12px;cursor:pointer;
}
.login-box h2{
    font-size:18px;font-weight:800;margin-bottom:18px;
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    -webkit-background-clip:text;background-clip:text;
    -webkit-text-fill-color:transparent;
}
.login-box input{
    width:100%;padding:12px 14px;
    border:1px solid #e2e2e8;border-radius:12px;
    font-size:15px;font-family:inherit;outline:none;
    text-align:center;letter-spacing:1px;
}
.login-box input:focus{border-color:#8b5cf6;box-shadow:0 0 0 3px rgba(139,92,246,.15)}
.login-box button.submit{
    width:100%;margin-top:12px;padding:12px;
    border:0;border-radius:12px;
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;font-size:15px;font-weight:700;
    font-family:inherit;cursor:pointer;
}
.login-box button.submit:disabled{opacity:.5}
.login-err{color:#d32f2f;font-size:12.5px;margin-top:10px;min-height:16px}

.sidebar{
    width:260px;background:#fff;color:#333;
    display:flex;flex-direction:column;flex-shrink:0;
    border-right:1px solid #ececf0;
    transition:margin-left .25s ease;z-index:100;
}
.sidebar.hide{margin-left:-260px}

.side-top{padding:14px 14px 6px}
.new-chat{
    width:100%;padding:10px 14px;
    border-radius:10px;border:1px solid #e2e2e8;
    background:#f7f7f8;color:#333;
    font-size:13.5px;font-family:inherit;
    cursor:pointer;display:flex;align-items:center;gap:8px;
    transition:.15s;font-weight:600;
}
.new-chat:hover{background:#ececf0;border-color:#d0d0d8}
.new-chat svg{width:16px;height:16px;stroke:currentColor;stroke-width:2;stroke-linecap:round;fill:none}

.side-label{padding:14px 18px 6px;font-size:11px;color:#999;font-weight:700;letter-spacing:1px}

.side-list{flex:1;overflow-y:auto;padding:0 10px 16px}
.side-list::-webkit-scrollbar{width:5px}
.side-list::-webkit-scrollbar-thumb{background:#d0d0d8;border-radius:3px}

.side-item{
    display:flex;align-items:center;gap:6px;
    padding:10px 10px 10px 12px;border-radius:8px;
    font-size:13px;color:#555;cursor:pointer;
    margin-bottom:2px;transition:.15s;position:relative;
    -webkit-touch-callout:none;
    -webkit-user-select:none;
    user-select:none;
}
.side-item:hover{background:#f5f5f7;color:#1a1a1a}
.side-item.active{background:#ececf0;color:#1a1a1a;font-weight:600}

.side-item .t{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}

.side-bottom{
    padding:12px 16px;border-top:1px solid #ececf0;
    font-size:12px;color:#888;
    display:flex;align-items:center;justify-content:space-between;gap:8px;
}
.side-bottom .user-info{display:flex;align-items:center;gap:8px;min-width:0;flex:1}
.side-bottom .user-avatar{
    width:28px;height:28px;border-radius:50%;
    object-fit:cover;flex-shrink:0;
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;display:flex;align-items:center;justify-content:center;
    font-size:12px;font-weight:700;overflow:hidden;
}
.side-bottom .user-avatar img{width:100%;height:100%;object-fit:cover}
.side-bottom .phone{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#555}
.side-bottom .logout{
    font-size:11px;color:#999;cursor:pointer;
    padding:3px 6px;border-radius:5px;flex-shrink:0;
}
.side-bottom .logout:hover{background:#f0f0f4;color:#d32f2f}

.main{flex:1;display:flex;flex-direction:column;min-width:0;background:#fff;position:relative}

.topbar{
    height:56px;border-bottom:1px solid #ececf0;
    display:flex;align-items:center;padding:0 16px;
    gap:10px;flex-shrink:0;background:#fff;z-index:10;
}
.menu-btn{
    width:34px;height:34px;border-radius:8px;
    border:0;background:transparent;color:#555;
    font-size:16px;cursor:pointer;
    display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.menu-btn:hover{background:#f0f0f4}
.menu-btn svg{width:18px;height:18px;stroke:currentColor;stroke-width:2;stroke-linecap:round;fill:none}

.topbar .title{
    font-size:15px;font-weight:700;color:#1a1a1a;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;
}
.topbar .spacer{flex:1}

.top-btn{
    width:34px;height:34px;border-radius:8px;
    border:0;background:transparent;color:#666;
    cursor:pointer;display:flex;align-items:center;justify-content:center;
    flex-shrink:0;transition:.15s;padding:0;position:relative;
}
.top-btn:hover{background:#f0f0f4}
.top-btn svg{width:18px;height:18px;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none}

.top-btn.voice-off{color:#999}
.top-btn.voice-off::after{
    content:'';position:absolute;
    left:8px;right:8px;top:50%;height:1.5px;
    background:#999;transform:rotate(-45deg);border-radius:2px;
}
.top-btn.voice-on{color:#8b5cf6}
.top-btn.new-btn{color:#8b5cf6}
.top-btn.new-btn:hover{background:#f3eeff}

.chat-scroll{flex:1;overflow-y:auto;padding:24px 16px 120px}
.chat-inner{max-width:760px;margin:0 auto}

.welcome{text-align:center;padding:60px 20px 30px;color:#666}
.welcome .logo{
    width:64px;height:64px;border-radius:50%;
    margin:0 auto 18px;object-fit:cover;display:block;
}
.welcome h2{font-size:22px;font-weight:800;color:#1a1a1a;margin-bottom:10px}
.welcome p{font-size:13.5px;color:#888;line-height:1.7}

.suggest{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:26px}
.suggest button{
    padding:10px 16px;border-radius:12px;
    border:1px solid #e2e2e8;background:#fff;
    color:#444;font-size:13px;font-family:inherit;
    cursor:pointer;transition:.15s;text-align:left;
}
.suggest button:hover{
    border-color:#b8a8f0;background:#faf7ff;
    color:#6b4fc4;transform:translateY(-1px);
}

.row{
    display:flex;gap:12px;margin-bottom:22px;
    animation:fadeUp .3s ease;width:100%;
}
@keyframes fadeUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.row.user{flex-direction:row-reverse;justify-content:flex-start}

.avatar{
    width:32px;height:32px;border-radius:50%;
    flex-shrink:0;object-fit:cover;overflow:hidden;
}
.avatar.user{
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;display:flex;align-items:center;justify-content:center;
    font-size:14px;font-weight:700;
}
.avatar.user img{width:100%;height:100%;object-fit:cover}

.bubble-wrap{
    max-width:calc(100% - 60px);
    display:flex;flex-direction:column;min-width:0;
}
.row.user .bubble-wrap{align-items:flex-end}
.row.ai .bubble-wrap{align-items:flex-start}

.bubble{
    padding:12px 16px;border-radius:16px;
    font-size:14.5px;line-height:1.75;
    word-break:break-word;max-width:100%;
    -webkit-touch-callout:none;
    -webkit-user-select:none;
    user-select:none;
}
.row.user .bubble{
    background:#f0f0f4;color:#1a1a1a;
    border-top-right-radius:4px;white-space:pre-wrap;
}
.row.ai .bubble{
    background:#fafafa;color:#1a1a1a;
    border-top-left-radius:4px;
}
.bubble.err{background:#fff3f3;color:#d32f2f;font-size:13px}

.bubble p{margin:0 0 10px}
.bubble p:last-child{margin-bottom:0}
.bubble strong{font-weight:800}
.bubble em{font-style:italic}
.bubble ul,.bubble ol{margin:6px 0 10px 22px}
.bubble li{margin-bottom:4px}
.bubble a{color:#7c3aed;text-decoration:none}
.bubble a:hover{text-decoration:underline}
.bubble code.inline{
    background:#ececf0;color:#c7254e;padding:2px 6px;
    border-radius:5px;font-family:ui-monospace,Menlo,Consolas,monospace;
    font-size:13px;
}

.code-block{
    margin:10px 0;border-radius:12px;overflow:hidden;
    background:#1e1e24;border:1px solid #2a2a33;
}
.code-head{
    display:flex;align-items:center;justify-content:space-between;
    padding:8px 14px;background:#16161c;border-bottom:1px solid #2a2a33;
}
.code-lang{
    font-size:12px;color:#9a9aac;
    font-family:ui-monospace,Menlo,Consolas,monospace;text-transform:lowercase;
}
.copy-btn{
    display:flex;align-items:center;gap:5px;
    padding:5px 10px;border-radius:6px;
    border:1px solid #3a3a44;background:#2a2a33;
    color:#c9c9d4;font-size:12px;font-family:inherit;
    cursor:pointer;transition:.15s;
}
.copy-btn:hover{background:#35353f;color:#fff}
.copy-btn svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:2}
.copy-btn.done{background:#2f7d4f;border-color:#3d9a63;color:#fff}

.code-block pre{
    margin:0;padding:14px;overflow-x:auto;
    font-family:ui-monospace,Menlo,Consolas,monospace;
    font-size:13px;line-height:1.65;color:#e8e8ee;
}
.code-block pre::-webkit-scrollbar{height:8px}
.code-block pre::-webkit-scrollbar-thumb{background:#3a3a44;border-radius:4px}

.bubble-actions{
    display:flex;gap:2px;margin-top:8px;padding:0 2px;
}
.act-btn{
    width:32px;height:32px;border-radius:8px;
    border:0;background:transparent;
    color:#999;cursor:pointer;
    display:flex;align-items:center;justify-content:center;
    transition:.15s;padding:0;position:relative;
}
.act-btn:hover{background:#f0f0f4;color:#555}
.act-btn.active{color:#6b4fc4}
.act-btn.speaking{color:#6b4fc4}
.act-btn svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

.voice-bars{display:inline-flex;align-items:flex-end;gap:2px;height:14px}
.voice-bars span{
    display:inline-block;width:2px;background:currentColor;
    border-radius:1px;animation:voiceBar .9s ease-in-out infinite;
}
.voice-bars span:nth-child(1){height:40%;animation-delay:0s}
.voice-bars span:nth-child(2){height:90%;animation-delay:.15s}
.voice-bars span:nth-child(3){height:60%;animation-delay:.3s}
.voice-bars span:nth-child(4){height:100%;animation-delay:.45s}
@keyframes voiceBar{0%,100%{transform:scaleY(.4)}50%{transform:scaleY(1)}}

.typing span{
    display:inline-block;width:7px;height:7px;
    border-radius:50%;background:#b8a8f0;
    margin-right:5px;animation:bounce 1.2s infinite;
}
.typing span:nth-child(2){animation-delay:.2s}
.typing span:nth-child(3){animation-delay:.4s}
@keyframes bounce{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-6px);opacity:1}}

.input-area{
    position:absolute;left:0;right:0;bottom:0;
    padding:16px;background:linear-gradient(to top,#fff 70%,transparent);
    pointer-events:none;z-index:20;
}
.input-inner{
    max-width:760px;margin:0 auto;pointer-events:auto;
    display:flex;gap:10px;align-items:flex-end;
    background:#fff;border:1px solid #e2e2e8;
    border-radius:18px;padding:10px 10px 10px 18px;
    box-shadow:0 8px 30px -12px rgba(0,0,0,.12);
    transition:border-color .15s,box-shadow .15s;
}
.input-inner:focus-within{border-color:#b8a8f0;box-shadow:0 8px 30px -12px rgba(139,92,246,.35)}
.input-inner textarea{
    flex:1;border:0;outline:0;resize:none;
    font-family:inherit;font-size:15px;line-height:1.5;
    color:#1a1a1a;background:transparent;
    max-height:180px;padding:6px 0;
}
.input-inner textarea::placeholder{color:#aaa}

.send-btn{
    width:38px;height:38px;border-radius:50%;border:0;
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;font-size:15px;cursor:pointer;flex-shrink:0;
    display:flex;align-items:center;justify-content:center;transition:.15s;
}
.send-btn:hover:not(:disabled){transform:scale(1.06)}
.send-btn:disabled{background:#e2e2e8;color:#aaa;cursor:not-allowed;transform:none}
.send-btn svg{width:18px;height:18px;fill:currentColor}

.overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:90}
.overlay.on{display:block}

.toast{
    position:fixed;left:50%;top:50%;
    transform:translate(-50%,-50%) scale(.9);
    background:rgba(30,30,36,.9);
    color:#fff;font-size:13.5px;
    padding:10px 18px;border-radius:10px;
    z-index:3000;opacity:0;pointer-events:none;
    transition:.2s;
}
.toast.on{opacity:1;transform:translate(-50%,-50%) scale(1)}

.msg-menu{
    position:fixed;
    background:#fff;
    border-radius:12px;
    box-shadow:0 10px 30px -10px rgba(0,0,0,.25);
    padding:6px 0;
    z-index:3000;
    display:none;
    min-width:140px;
    overflow:hidden;
    border:1px solid #ececf0;
}
.msg-menu.on{display:block}
.msg-menu button{
    display:flex;
    align-items:center;
    gap:8px;
    width:100%;
    padding:10px 16px;
    border:0;
    background:transparent;
    color:#333;
    font-size:13.5px;
    font-family:inherit;
    text-align:left;
    cursor:pointer;
    transition:.15s;
}
.msg-menu button:hover{background:#f5f5f7}
.msg-menu button.danger{color:#e53935}
.msg-menu button.danger:hover{background:#ffe0e0}

.side-menu{
    position:fixed;
    background:#fff;
    border-radius:12px;
    box-shadow:0 10px 30px -10px rgba(0,0,0,.25);
    padding:6px 0;
    z-index:3000;
    display:none;
    min-width:130px;
    overflow:hidden;
    border:1px solid #ececf0;
}
.side-menu.on{display:block}
.side-menu button{
    display:flex;
    align-items:center;
    gap:8px;
    width:100%;
    padding:10px 16px;
    border:0;
    background:transparent;
    color:#333;
    font-size:13.5px;
    font-family:inherit;
    text-align:left;
    cursor:pointer;
    transition:.15s;
}
.side-menu button:hover{background:#f5f5f7}
.side-menu button.danger{color:#e53935}
.side-menu button.danger:hover{background:#ffe0e0}

.avatar-edit{
    display:none;position:fixed;inset:0;
    background:rgba(42,31,74,.55);
    backdrop-filter:blur(6px);
    z-index:2100;align-items:center;justify-content:center;padding:20px;
}
.avatar-edit.on{display:flex}
.avatar-edit .box{width:100%;max-width:340px;background:#fff;border-radius:20px;padding:22px;text-align:center}
.avatar-edit h3{font-size:16px;margin-bottom:16px}
.avatar-edit .preview{
    width:80px;height:80px;border-radius:50%;
    margin:0 auto 16px;overflow:hidden;
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    display:flex;align-items:center;justify-content:center;
    color:#fff;font-size:28px;font-weight:700;
}
.avatar-edit .preview img{width:100%;height:100%;object-fit:cover}
.avatar-edit input{
    width:100%;padding:11px 14px;border:1px solid #e2e2e8;
    border-radius:10px;font-size:14px;font-family:inherit;outline:none;
    margin-bottom:12px;
}
.avatar-edit input:focus{border-color:#8b5cf6}
.avatar-edit .btns{display:flex;gap:10px;margin-top:8px}
.avatar-edit .btns button{
    flex:1;padding:11px;border:0;border-radius:10px;
    font-family:inherit;font-size:14px;font-weight:700;cursor:pointer;
}
.avatar-edit .btn-cancel{background:#f0f0f4;color:#444}
.avatar-edit .btn-save{background:linear-gradient(135deg,#8b5cf6,#d946ef);color:#fff}
.avatar-edit .btn-pick{
    width:100%;padding:11px;border:0;border-radius:10px;
    background:#f0f0f4;color:#444;font-size:14px;font-family:inherit;
    font-weight:700;cursor:pointer;margin-bottom:10px;
}

@media(min-width:769px){
    .menu-btn{display:none}
    .sidebar.hide{margin-left:0}
    .overlay{display:none !important}
}
@media(max-width:768px){
    .sidebar{position:fixed;left:0;top:0;bottom:0}
    .sidebar.hide{margin-left:-260px}
}

.confirm-mask{
    position:fixed;inset:0;
    background:rgba(42,31,74,.55);
    backdrop-filter:blur(6px);
    z-index:4000;
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
}
.confirm-mask.on{display:flex}
.confirm-box{
    width:100%;max-width:320px;
    background:#fff;border-radius:20px;
    padding:24px 22px 18px;
    text-align:center;
    box-shadow:0 30px 80px -20px rgba(139,92,246,.5);
}
.confirm-box h3{
    font-size:16px;font-weight:800;
    color:#1a1a1a;margin-bottom:8px;
}
.confirm-box .confirm-msg{
    font-size:13.5px;color:#666;
    line-height:1.6;margin-bottom:20px;
}
.confirm-box .confirm-actions{
    display:flex;gap:10px;
}
.confirm-box .confirm-actions button{
    flex:1;padding:11px;border:0;border-radius:12px;
    font-family:inherit;font-size:14px;font-weight:700;
    cursor:pointer;
}
.confirm-box .confirm-cancel{
    background:#f0f0f4;color:#444;
}
.confirm-box .confirm-ok{
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;
}
.confirm-box .confirm-ok.danger{
    background:linear-gradient(135deg,#fb7185,#e11d48);
}

.confirm-mask{
    position:fixed;inset:0;
    background:rgba(42,31,74,.55);
    backdrop-filter:blur(6px);
    z-index:4000;
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
}
.confirm-mask.on{display:flex}
.confirm-box{
    width:100%;max-width:320px;
    background:#fff;border-radius:20px;
    padding:24px 22px 18px;
    text-align:center;
    box-shadow:0 30px 80px -20px rgba(139,92,246,.5);
}
.confirm-box h3{
    font-size:16px;font-weight:800;
    color:#1a1a1a;margin-bottom:8px;
}
.confirm-box .confirm-msg{
    font-size:13.5px;color:#666;
    line-height:1.6;margin-bottom:20px;
}
.confirm-box .confirm-actions{
    display:flex;gap:10px;
}
.confirm-box .confirm-actions button{
    flex:1;padding:11px;border:0;border-radius:12px;
    font-family:inherit;font-size:14px;font-weight:700;
    cursor:pointer;
}
.confirm-box .confirm-cancel{
    background:#f0f0f4;color:#444;
}
.confirm-box .confirm-ok{
    background:linear-gradient(135deg,#8b5cf6,#d946ef);
    color:#fff;
}
.confirm-box .confirm-ok.danger{
    background:linear-gradient(135deg,#fb7185,#e11d48);
}
.img-btn{
    width:38px;height:38px;border-radius:50%;border:0;
    background:transparent;color:#888;cursor:pointer;
    display:flex;align-items:center;justify-content:center;
    flex-shrink:0;transition:.15s;padding:0;
}
.img-btn:hover{background:#f0f0f4;color:#8b5cf6}
.img-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

.img-preview{
    display:none;
    max-width:760px;
    margin:0 auto 8px;
    position:relative;
    padding:0 4px;
}
.img-preview.on{display:block}
.img-preview img{
    max-width:80px;
    max-height:80px;
    border-radius:10px;
    border:1px solid #ececf0;
    display:block;
}
.img-preview-del{
    position:absolute;
    left:66px;
    top:-6px;
    width:20px;height:20px;
    border-radius:50%;
    border:0;
    background:rgba(0,0,0,.6);
    color:#fff;
    font-size:12px;
    line-height:1;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
}
.img-preview-del:hover{background:#e53935}

.avatar-edit .set-row{
    margin-bottom:14px;
    text-align:left;
}
.avatar-edit .set-row label{
    display:block;
    font-size:13px;
    color:#666;
    margin-bottom:6px;
}
.avatar-edit .set-row select{
    width:100%;
    padding:10px 12px;
    border:1px solid #e2e2e8;
    border-radius:10px;
    font-size:14px;
    font-family:inherit;
    color:#1a1a1a;
    background:#fff;
    outline:none;
    cursor:pointer;
}
.avatar-edit .set-row select:focus{
    border-color:#8b5cf6;
}