/* ===== 卢慧数字人 — 对话界面 ===== */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- 头部：像杂志署名 ------- */
.chat-header {
  padding: 28px 0 16px;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.chat-header .name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--accent);
  line-height: 1.3;
}

.chat-header .title {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  letter-spacing: 0.05em;
  font-family: var(--font-body);
}

.chat-header .status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.chat-header .dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 3s ease-in-out infinite;
}

/* ---- 头部装饰线 ---- */
.chat-header::after {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--border2);
  margin: 16px auto 0;
}

/* ---- 消息区域 ---- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ---- 欢迎语 ---- */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 0;
  min-height: 0;
  gap: 14px;
}

.welcome-line {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.9;
  max-width: 380px;
}

.welcome-line:first-child {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text);
}

/* ---- 消息气泡 ---- */
.msg {
  max-width: 92%;
  animation: fadeIn 0.4s var(--spring);
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant {
  align-self: flex-start;
}

.msg.user .msg-content {
  background: var(--accent-soft);
  border: 1px solid rgba(201, 169, 110, 0.15);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.7;
}

.msg.assistant .msg-content {
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant .msg-content p {
  margin-bottom: 0.8em;
}

.msg.assistant .msg-content p:last-child {
  margin-bottom: 0;
}

/* ---- 消息标签 ---- */
.msg-label {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.msg.user .msg-label {
  text-align: right;
  color: var(--text-tertiary);
}

.msg.assistant .msg-label {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.04em;
}

/* ---- 打字光标 ---- */
.typewriter-cursor {
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  background: var(--accent);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.9s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

/* ---- 输入区域 ---- */
.input-area {
  padding: 16px 0 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 30%);
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 18px;
  transition: border-color 0.25s var(--ease-out);
}

.input-wrapper:focus-within {
  border-color: var(--border2);
  background: var(--surface2);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  resize: none;
  min-height: 24px;
  max-height: 120px;
  line-height: 1.6;
  outline: none;
  padding: 8px 0;
}

.input-wrapper textarea::placeholder {
  color: var(--text-tertiary);
}

.send-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.send-btn:hover {
  color: var(--accent);
}

.send-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.send-btn.has-text {
  color: var(--accent);
}

.send-btn.stop {
  color: var(--red);
}

.input-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 8px;
  text-align: center;
  letter-spacing: 0.03em;
}

/* ---- 加载动画 ---- */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 8px 0;
  align-items: center;
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: loadingDot 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes loadingDot {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ---- 设置按钮 ---- */
.settings-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
}

.settings-btn:hover {
  color: var(--text);
  border-color: var(--border2);
}

/* ---- 设置面板 ---- */
.settings-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 20;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  width: 280px;
  display: none;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}

.settings-panel.show {
  display: block;
  animation: fadeIn 0.2s var(--ease-out);
}

.settings-panel label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  margin-top: 12px;
}

.settings-panel label:first-child { margin-top: 0; }

.settings-panel select,
.settings-panel input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}

.settings-panel select {
  font-family: var(--font-body);
  cursor: pointer;
}

.settings-panel select:focus,
.settings-panel input:focus {
  border-color: var(--accent);
}

.settings-panel .save-btn {
  width: 100%;
  margin-top: 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(201, 169, 110, 0.2);
  color: var(--accent);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  font-family: var(--font-body);
  transition: all 0.2s;
}

.settings-panel .save-btn:hover {
  background: rgba(201, 169, 110, 0.18);
}

.settings-panel .clear-btn {
  width: 100%;
  margin-top: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}

.settings-panel .clear-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  z-index: 9999;
  font-family: var(--font-body);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toastIn 0.3s var(--spring), toastOut 0.3s var(--ease-out) 2.1s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.96); }
}

/* ---- 遮罩 ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: none;
}

.overlay.show {
  display: block;
}
