/* ─────────────────────────────────────────
   基础 reset & 变量
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f11;
  --surface:   #1a1a1f;
  --surface2:  #242429;
  --border:    #2e2e35;
  --accent:    #a78bfa;
  --accent2:   #7c3aed;
  --user-bg:   #1e1b2e;
  --ai-bg:     #1a1a1f;
  --text:      #e8e8f0;
  --text-muted:#8888a0;
  --radius:    14px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }

/* ─────────────────────────────────────────
   布局
───────────────────────────────────────── */
.app {
  display: flex; flex-direction: column;
  height: 100vh; max-width: 760px;
  margin: 0 auto;
}

/* ─────────────────────────────────────────
   顶栏
───────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; flex-shrink: 0;
}
.title-main { font-size: 15px; font-weight: 600; color: var(--text); display: block; }
.title-sub  { font-size: 12px; color: var(--text-muted); display: block; margin-top: 1px; }
.header-right { display: flex; gap: 8px; }
.lang-btn, .reset-btn, .pin-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.lang-btn:hover, .reset-btn:hover, .pin-btn:hover { color: var(--accent); border-color: var(--accent); }

/* PIN 面板 */
.header { position: relative; }
.pin-panel {
  position: absolute; top: calc(100% + 8px); right: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; z-index: 100;
  width: 280px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.pin-panel-inner { display: flex; flex-direction: column; gap: 10px; }
.pin-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
#pin-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 12px;
  font-size: 18px; letter-spacing: 4px; text-align: center;
  outline: none; width: 100%;
}
#pin-input:focus { border-color: var(--accent); }
.pin-actions { display: flex; gap: 8px; }
.pin-actions button {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; cursor: pointer; transition: color .15s, border-color .15s;
}
.pin-actions button:hover { color: var(--accent); border-color: var(--accent); }
#pin-close-btn { flex: 0 0 36px; }
.pin-hint { font-size: 12px; min-height: 16px; text-align: center; }


/* ─────────────────────────────────────────
   消息区
───────────────────────────────────────── */
.messages {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* 消息气泡 */
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.msg.ai   .msg-avatar { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }
.msg.user .msg-avatar { background: var(--surface2); color: var(--text-muted); }

.msg-bubble {
  max-width: calc(100% - 50px);
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.7; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.ai   .msg-bubble { background: var(--ai-bg); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.user .msg-bubble { background: var(--user-bg); border: 1px solid #2d2245; border-top-right-radius: 4px; }

/* 打字光标 */
.cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent); margin-left: 1px;
  animation: blink .8s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

/* 加载点点 */
.typing-dots { display: flex; gap: 5px; align-items: center; padding: 8px 4px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted);
  animation: dot-bounce .9s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes dot-bounce { 0%,80%,100% { transform: scale(.8); opacity:.4; } 40% { transform: scale(1.1); opacity:1; } }

/* ─────────────────────────────────────────
   输入区
───────────────────────────────────────── */
.input-area {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
#input {
  flex: 1; resize: none; overflow-y: hidden;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 10px 14px; font-size: 14.5px; font-family: var(--font);
  line-height: 1.5; outline: none;
  transition: border-color .15s;
  max-height: 160px; overflow-y: auto;
}
#input:focus { border-color: var(--accent); }
#input::placeholder { color: var(--text-muted); }

.send-btn {
  background: var(--accent2); color: #fff; border: none;
  border-radius: 10px; padding: 10px 18px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s; flex-shrink: 0;
  height: 40px;
}
.send-btn:hover:not(:disabled) { background: var(--accent); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─────────────────────────────────────────
   响应式
───────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 12px 14px; }
  .messages { padding: 16px 12px; }
  .input-area { padding: 10px 12px 16px; }
  .title-sub { display: none; }
}
