*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --user-bubble: #0d9488;
  --bot-bubble: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---- 主容器 ---- */
.app {
  width: 520px;
  max-width: 100vw;
  height: 94vh;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- 顶栏 ---- */
.header {
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.header h1 { font-size: 16px; font-weight: 600; }
.header .actions { display: flex; align-items: center; gap: 8px; }
.header label { font-size: 12px; }
.header select {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.header select option { color: #333; background: #fff; }
.header button {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s;
}
.header button:hover { background: rgba(255,255,255,.3); }

/* ---- 会话信息栏 ---- */
.session-bar {
  padding: 8px 20px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.session-bar button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-light);
}
.session-bar button:hover { background: var(--border); }

/* ---- 消息区 ---- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.msg { max-width: 85%; line-height: 1.6; font-size: 14px; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot  { align-self: flex-start; }
.msg.bot  .bubble { background: var(--bot-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.msg .label { font-size: 11px; color: var(--text-light); margin-bottom: 3px; padding: 0 4px; }
.msg.user .label { text-align: right; }

.typing .bubble { color: var(--text-light); font-style: italic; }

/* ---- 系统提示 ---- */
.system-msg {
  align-self: center;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  padding: 4px 14px;
  border-radius: 12px;
}

/* ---- 用户画像面板 ---- */
.profile-panel {
  align-self: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  max-width: 90%;
}
.profile-panel h4 { font-size: 13px; margin-bottom: 4px; color: #166534; }
.profile-panel ul { margin: 0; padding-left: 18px; }
.profile-panel li { margin: 2px 0; }

/* ---- 输入区 ---- */
.input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
.input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  min-height: 42px;
  max-height: 120px;
}
.input-area textarea:focus { border-color: var(--primary); }
.input-area button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.input-area button:hover { background: var(--primary-hover); }
.input-area button:disabled { opacity: .5; cursor: not-allowed; }
