/* ===== base ===== */
*{margin:0;padding:0;box-sizing:border-box}

body{
  font-family:-apple-system,"Microsoft YaHei","PingFang SC",sans-serif;
  background:linear-gradient(160deg,#f0f9ff 0%,#ecfeff 40%,#f0fdf4 100%);
  min-height:100vh;display:flex;justify-content:center;align-items:center;
  padding:12px;
}

#vue-app{
  width:100%;max-width:900px;height:92vh;max-height:900px;
  background:#fff;
  border-radius:24px;display:flex;flex-direction:row;overflow:hidden;
  box-shadow:0 4px 24px rgba(0,0,0,0.06),0 1px 3px rgba(0,0,0,0.04);
}

/* ===== sidebar ===== */
.sidebar{
  width:240px;flex-shrink:0;display:flex;flex-direction:column;
  border-right:1px solid #e8f4f8;
  background:#f8fdfe;
}
.sidebar-header{
  padding:16px 14px;border-bottom:1px solid #e8f4f8;
  display:flex;justify-content:space-between;align-items:center;
}
.sidebar-header span{ font-size:14px;font-weight:600;color:#0f766e; }
.sidebar-new-btn{
  margin:10px 14px;padding:8px 0;border-radius:10px;
  border:1px dashed #5eead4;background:#f0fdfa;
  color:#0d9488;font-size:12px;cursor:pointer;text-align:center;
  transition:all .15s;
}
.sidebar-new-btn:hover{ background:#ccfbf1; }
.sidebar-list{
  flex:1;overflow-y:auto;padding:0 8px 8px;
}
.sidebar-list::-webkit-scrollbar{ width:3px; }
.sidebar-list::-webkit-scrollbar-thumb{ background:#cbd5e1;border-radius:3px; }
.sidebar-item{
  display:flex;align-items:center;padding:10px 10px;border-radius:10px;
  cursor:pointer;margin-bottom:2px;transition:background .15s;
  gap:8px;
}
.sidebar-item:hover{ background:#e8f4f8; }
.sidebar-item.active{ background:#e6f7f5; }
.sidebar-item .conv-info{ flex:1;min-width:0; }
.sidebar-item .conv-title{
  font-size:12px;color:#334155;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;
}
.sidebar-item .conv-time{
  font-size:10px;color:#94a3b8;margin-top:2px;
}
.sidebar-item .conv-del{
  font-size:14px;color:#cbd5e1;cursor:pointer;padding:2px 4px;
  border-radius:4px;flex-shrink:0;
}
.sidebar-item .conv-del:hover{ color:#ef4444;background:#fee2e2; }

.empty-conv{
  text-align:center;color:#94a3b8;font-size:11px;
  padding:30px 10px;
}

/* ===== main area ===== */
.main-area{
  flex:1;display:flex;flex-direction:column;min-width:0;
}

/* ===== header ===== */
.app-header{
  padding:22px 20px 14px;text-align:center;
  background:linear-gradient(180deg,#f8fdfe 0%,#fff 100%);
  border-bottom:1px solid #e8f4f8;
}
.app-header .user-bar{
  display:flex;justify-content:flex-end;align-items:center;
  padding:0 0 10px;
}
.app-header .user-name{
  font-size:12px;color:#64748b;margin-right:auto;
}
.app-header .logout-btn{
  font-size:11px;color:#94a3b8;cursor:pointer;background:none;
  border:none;padding:2px 8px;border-radius:6px;
}
.app-header .logout-btn:hover{ background:#fee2e2;color:#dc2626; }
.app-header h1{
  font-size:17px;font-weight:700;color:#0f766e;
  letter-spacing:0.5px;display:flex;align-items:center;
  justify-content:center;gap:8px;
}
.app-header h1 .icon{
  display:inline-flex;width:32px;height:32px;border-radius:10px;
  background:linear-gradient(135deg,#14b8a6,#0d9488);
  align-items:center;justify-content:center;font-size:17px;color:#fff;
}
.app-header .subtitle{
  font-size:11px;color:#94a3b8;margin-top:4px;
}

/* ===== mode bar ===== */
.mode-bar{
  display:flex;gap:6px;padding:6px 16px 14px;justify-content:center;
}
.mode-btn{
  flex:1;max-width:120px;padding:7px 0;border-radius:10px;
  border:1px solid #d1e7e0;background:#f8fdfe;
  color:#64748b;font-size:11px;cursor:pointer;transition:all .2s;
  text-align:center;user-select:none;-webkit-user-select:none;
}
.mode-btn:hover{background:#f0f9f6;color:#33404d}
.mode-btn.active{
  background:linear-gradient(135deg,#e6f7f5,#ccfbf1);border-color:#5eead4;
  color:#0f766e;font-weight:600;
}

/* ===== chat ===== */
.chat-container{flex:1;overflow-y:auto;padding:10px 14px 16px;}
.chat-container::-webkit-scrollbar{width:4px}
.chat-container::-webkit-scrollbar-track{background:transparent}
.chat-container::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}

.msg-list{display:flex;flex-direction:column;gap:8px;}

.msg{
  max-width:85%;padding:10px 14px;border-radius:14px;font-size:13.5px;
  line-height:1.7;word-break:break-word;
  animation:msgIn .25s ease;
}
@keyframes msgIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}

.msg.system{
  align-self:center;background:#f1f5f9;color:#94a3b8;
  font-size:11px;max-width:90%;border-radius:8px;text-align:center;
  padding:6px 16px;
}

.msg.asr-final{
  align-self:flex-end;background:#e6f7f5;color:#0c4a6e;
  border-bottom-right-radius:4px;
}
.msg.asr-final .asr-label{font-size:10px;color:#94a3b8;margin-bottom:2px;display:block}

.msg.bot{
  align-self:flex-start;background:#f8fafc;color:#334155;
  border-bottom-left-radius:4px;border:1px solid #e2e8f0;
}

.msg.llm-token,.msg.bot{
  position:relative;
}
.msg.has-play-btn{padding-bottom:22px}
.msg.llm-token{
  align-self:flex-start;background:#f8fafc;color:#475569;
  border-bottom-left-radius:4px;border:1px solid #e2e8f0;
  transition:none;animation:none;
}
.msg.llm-token .bot-label{font-size:10px;color:#94a3b8;margin-bottom:2px;display:block}
.msg-play-btn{
  position:absolute;bottom:1px;right:4px;
  width:32px;height:32px;border-radius:50%;
  border:1.5px solid #99f6e4;background:#f0fdfa;color:#0d9488;
  font-size:16px;cursor:pointer;display:flex;
  align-items:center;justify-content:center;
  user-select:none;-webkit-user-select:none;
  opacity:.7;transition:opacity .15s;z-index:1;
}
.msg-play-btn:hover{opacity:1}
.msg-play-btn.paused{background:#fef3c7;border-color:#fcd34d;color:#b45309}

.msg.asr-partial{
  align-self:flex-end;background:#f0f9ff;color:#94a3b8;
  font-style:italic;font-size:12px;border-bottom-right-radius:4px;
}

.msg.security{
  align-self:flex-start;background:#fff7ed;color:#c2410c;
  border:1px solid #fed7aa;border-bottom-left-radius:4px;
}

/* ===== bottom bar ===== */
.bottom-bar{
  padding:12px 20px 20px;display:flex;flex-direction:column;
  align-items:center;gap:8px;
  border-top:1px solid #e8f4f8;
  background:linear-gradient(0deg,#f8fdfe,transparent);
}

.text-input-bar{
  display:flex;gap:8px;padding:8px 16px 0;
}
.text-input-bar input{
  flex:1;padding:10px 14px;border-radius:12px;
  border:1px solid #d1e7e0;background:#f8fdfe;
  color:#334155;font-size:13px;outline:none;
  font-family:inherit;transition:border-color .2s;
}
.text-input-bar input:focus{border-color:#5eead4}
.text-input-bar input::placeholder{color:#cbd5e1}
.text-input-bar button{
  padding:10px 16px;border-radius:12px;border:none;
  background:linear-gradient(135deg,#14b8a6,#0d9488);
  color:#fff;font-size:13px;cursor:pointer;
  white-space:nowrap;transition:opacity .2s;
  font-family:inherit;
}
.text-input-bar button:hover{opacity:.85}
.text-input-bar button:disabled{opacity:.4;cursor:not-allowed}

.record-btn{
  width:64px;height:64px;border-radius:50%;
  border:2px solid #99f6e4;background:#f0fdfa;color:#0d9488;
  font-size:22px;cursor:pointer;transition:all .2s;
  display:flex;align-items:center;justify-content:center;
  user-select:none;-webkit-user-select:none;position:relative;
}
.record-btn:hover{background:#ccfbf1;transform:scale(1.04)}
.record-btn:active{transform:scale(.94)}

.record-btn.recording{
  background:#fef2f2;border-color:#fca5a5;color:#dc2626;
  animation:pulse 1.5s infinite;
}
@keyframes pulse{
  0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,0.3)}
  50%{box-shadow:0 0 0 14px rgba(239,68,68,0)}
}

.record-btn.disabled{
  background:#f8fafc;border-color:#e2e8f0;
  color:#cbd5e1;cursor:not-allowed;
}

.audio-controls{display:flex;align-items:center;gap:12px}

.status-line{display:flex;align-items:center;gap:7px;font-size:12px;color:#64748b}
.status-dot{width:7px;height:7px;border-radius:50%;display:inline-block}
.status-dot.idle{background:#10b981;box-shadow:0 0 6px rgba(16,185,129,0.3)}
.status-dot.recording{background:#ef4444;animation:dotBlink .6s infinite}
.status-dot.processing{background:#f59e0b;animation:dotBlink .8s infinite}
.status-dot.disconnected{background:#94a3b8}
@keyframes dotBlink{50%{opacity:.25}}

.hint-text{font-size:11px;color:#94a3b8;text-align:center}

/* ===== RAG ===== */
.msg.rag{
  max-width:95%;padding:0;border-radius:10px;overflow:hidden;
  background:#f8fdfe;border:1px solid #d1e7e0;align-self:flex-start;
  font-size:12px;line-height:1.5;
}
.msg.rag .rag-toggle-bar{
  display:flex;align-items:center;gap:6px;padding:8px 12px;
  cursor:pointer;user-select:none;color:#64748b;
  font-size:11px;transition:background .15s;
}
.msg.rag .rag-toggle-bar:hover{background:#e6f7f5}
.msg.rag .rag-toggle-bar .rag-arrow{
  transition:transform .2s;font-size:10px;
}
.msg.rag .rag-toggle-bar .rag-badge{
  font-size:10px;background:#0d9488;color:#fff;
  border-radius:8px;padding:1px 6px;margin-left:auto;
}
.msg.rag .rag-body{
  max-height:0;overflow:hidden;transition:max-height .3s ease;
}
.msg.rag.expanded .rag-body{max-height:350px;overflow-y:auto}
.msg.rag.expanded .rag-toggle-bar .rag-arrow{transform:rotate(90deg)}
.msg.rag .rag-body::-webkit-scrollbar{width:3px}
.msg.rag .rag-body::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}
.msg.rag .rag-item{
  padding:7px 12px;border-top:1px solid #e8f4f8;
}
.msg.rag .rag-item .rag-score{
  display:inline-block;font-size:10px;background:#e6f7f5;color:#0d9488;
  padding:1px 6px;border-radius:6px;margin-bottom:3px;
}
.msg.rag .rag-item .rag-q{color:#475569}
.msg.rag .rag-item .rag-q::before{content:'Q: ';color:#94a3b8;font-weight:600}
.msg.rag .rag-item .rag-a{color:#64748b;font-size:11px;line-height:1.5}
.msg.rag .rag-item .rag-a::before{content:'A: ';color:#94a3b8;font-weight:600}

.toast{
  position:fixed;top:20px;left:50%;transform:translateX(-50%);
  padding:10px 24px;border-radius:10px;font-size:13px;z-index:9999;
  transition:all .3s;pointer-events:none;max-width:90%;
}
.toast.success{background:#d1fae5;color:#065f46}
.toast.error{background:#fee2e2;color:#991b1b}
.toast.warn{background:#fef3c7;color:#92400e}
