/* 顶部导航栏 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(92, 84, 80, 0.08);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.current-character {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 14px;
}

.current-char-avatar {
  font-size: 16px;
}

.current-char-name {
  color: var(--ink);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* 对话容器 */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}

.welcome-message h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--ink);
}

/* 消息气泡 */
.message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--rose);
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--ink);
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(92, 84, 80, 0.08);
}

.message.user .message-bubble {
  background: var(--rose);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.message.ai .message-bubble {
  border-radius: 16px 16px 16px 4px;
}

.message-emoji {
  font-size: 48px;
  padding: 8px;
}

/* 输入区域 */
.input-area {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(92, 84, 80, 0.08);
}

#messageInput {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
}

.send-btn {
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--rose-deep);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(178, 134, 132, 0.3);
}

.send-btn:active {
  transform: scale(0.95);
}

/* 抽屉组件 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(92, 84, 80, 0.25);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 85%;
  max-width: 380px;
  background: rgba(251, 248, 245, 0.95);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: -12px 0 40px rgba(92, 84, 80, 0.2);
  border-left: 1px solid rgba(255, 255, 255, 0.5);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
}

.drawer-mask.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 设置项 */
.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.setting-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.4;
}

.model-select-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-select-wrapper select {
  flex: 1;
}

.btn-refresh-models {
  width: 40px;
  height: 40px;
  background: var(--sage-deep);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-refresh-models:hover {
  background: var(--sage);
  transform: scale(1.05);
}

.btn-refresh-models:active {
  transform: scale(0.95);
}

.setting-group input,
.setting-group select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
}

.save-btn,
.add-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--rose-deep);
  color: #fff;
  font-weight: 500;
  margin-top: 12px;
  box-shadow: 0 4px 12px rgba(178, 134, 132, 0.3);
}

.add-btn {
  background: var(--sage-deep);
  box-shadow: 0 4px 12px rgba(138, 154, 124, 0.3);
}

/* 世界书条目 */
.worldbook-entry {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
}

.worldbook-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.worldbook-entry-title {
  font-weight: 600;
  color: var(--ink);
}

.worldbook-entry-content {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* 表情选择器 */
.emoji-picker {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  width: 90%;
  max-width: 440px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(92, 84, 80, 0.25);
  border: 1px solid var(--line);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 40;
}

.emoji-picker.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-item {
  font-size: 32px;
  padding: 8px;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.emoji-item:hover {
  background: var(--bg);
}

.emoji-item:active {
  transform: scale(0.9);
}

/* 加载动画 */
.loading-dots {
  display: flex;
  gap: 6px;
  padding: 12px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: loadingBounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

/* 角色卡片 */
.character-card {
  background: var(--bg);
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
  border: 2px solid var(--line);
  transition: all 0.2s ease;
}

.character-card.active {
  border-color: var(--rose);
  background: rgba(201, 162, 160, 0.08);
}

.character-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.character-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  border: 2px solid var(--line);
}

.character-info {
  flex: 1;
}

.character-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.character-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-soft);
}

.character-meta span {
  padding: 2px 8px;
  background: var(--paper);
  border-radius: 6px;
}

.character-trait {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--paper);
  border-radius: 8px;
}

.character-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background: var(--line);
}

.btn-small.btn-active {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.btn-small.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-small.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(92, 84, 80, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(92, 84, 80, 0.3);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

/* 角色编辑器 */
.character-editor {
  max-width: 640px;
}

.editor-section {
  margin-bottom: 24px;
}

.editor-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  resize: vertical;
}

.form-group textarea {
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.btn-primary {
  padding: 12px 32px;
  border-radius: 12px;
  background: var(--rose-deep);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(178, 134, 132, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(178, 134, 132, 0.4);
  transform: translateY(-2px);
}

.btn-secondary {
  padding: 12px 32px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--line);
}

/* 头像选择器 */
.avatar-selector {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-options {
  flex: 1;
}

.avatar-type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-toggle {
  flex: 1;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-toggle.active {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

#emojiAvatarInput input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 32px;
  text-align: center;
}

.btn-upload {
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--sage-deep);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-upload:hover {
  background: var(--sage);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(138, 154, 124, 0.3);
}

/* 设置页面样式 */
.settings-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
}

/* 数据统计 */
.data-stats {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--ink-soft);
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

/* 数据操作按钮 */
.data-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-data {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-data.export {
  background: var(--sage-deep);
  color: #fff;
  box-shadow: 0 4px 12px rgba(138, 154, 124, 0.3);
}

.btn-data.export:hover {
  background: var(--sage);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(138, 154, 124, 0.4);
}

.btn-data.import {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(166, 183, 191, 0.3);
}

.btn-data.import:hover {
  background: #95a8b3;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(166, 183, 191, 0.4);
}

.btn-data.clear {
  background: var(--bg);
  color: var(--danger);
  border: 2px solid var(--danger);
}

.btn-data.clear:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-2px);
}

.data-note {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
  padding: 12px;
  background: rgba(168, 179, 156, 0.1);
  border-radius: 8px;
  border-left: 3px solid var(--sage-deep);
}

/* 关于信息 */
.about-info {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
}

.about-info p {
  margin: 4px 0;
  color: var(--ink);
}

/* 记忆系统样式 */
.memory-info-card {
  background: rgba(168, 179, 156, 0.1);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  border-left: 4px solid var(--sage-deep);
}

.memory-info-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

.memory-info-card p {
  color: var(--ink-soft);
  margin-bottom: 12px;
  line-height: 1.6;
}

.memory-info-card ul {
  list-style: none;
  padding: 0;
  margin-bottom: 16px;
}

.memory-info-card ul li {
  padding: 6px 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.memory-info-card ul li:before {
  content: "• ";
  color: var(--sage-deep);
  font-weight: bold;
  margin-right: 8px;
}

.memory-actions-top {
  display: flex;
  gap: 12px;
}

.memory-actions-top button {
  flex: 1;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border: 2px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-2px);
}

.memory-card {
  background: var(--paper);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.memory-card:hover {
  box-shadow: 0 4px 16px rgba(92, 84, 80, 0.1);
  transform: translateY(-2px);
}

.memory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.memory-time {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

.memory-content {
  color: var(--ink);
  line-height: 1.7;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.memory-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-soft);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
