* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
}
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}
header {
  margin-bottom: 32px;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}
.subtitle {
  color: #666;
  font-size: 0.9rem;
  margin: 0;
}
main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}
.character-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.character-list li {
  min-width: 160px;
}
.character-card {
  display: block;
  padding: 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.character-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}
.character-card .name {
  font-weight: 600;
  margin-bottom: 4px;
}
.character-card .meta {
  font-size: 0.8rem;
  color: #6b7280;
}
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: #3b82f6;
  color: #fff;
}
.btn-primary:hover {
  background: #2563eb;
}
.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}
.btn-secondary:hover {
  background: #d1d5db;
}
.btn-ghost {
  background: transparent;
  color: #6b7280;
}
.btn-ghost:hover {
  color: #1a1a1a;
}
.detail-section {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 24px;
}
.detail-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}
.tab {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.tab:hover {
  color: #1a1a1a;
}
.tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  font-weight: 500;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-messages {
  min-height: 200px;
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  background: #f9fafb;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}
.chat-msg {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.chat-msg.user {
  align-items: flex-end;
}
.chat-msg .bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user .bubble {
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .bubble {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.chat-msg .bubble .chat-msg-img {
  max-width: 200px;
  max-height: 160px;
  border-radius: 6px;
  display: block;
  margin-top: 4px;
}
.chat-msg .role {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 4px;
}
.chat-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.chat-attach-preview .thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
}
.chat-attach-preview .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-attach-preview .thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-upload-btn {
  flex-shrink: 0;
  margin-bottom: 0;
}
.chat-input-row textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  min-height: 44px;
}
.chat-input-row .btn {
  flex-shrink: 0;
}

.hint {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0 0 12px 0;
}
.hint.warning {
  color: #b45309;
  background: #fffbeb;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #fcd34d;
}
.upload-row {
  margin-bottom: 16px;
}
.upload-row textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
}
.upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.conversation-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}
.conversation-list li {
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}
.conversation-list li .meta {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 4px;
}
.analyze-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status {
  font-size: 0.85rem;
  color: #6b7280;
}
.status.error {
  color: #dc2626;
}
.status.success {
  color: #059669;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: #374151;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}
.form-group select {
  cursor: pointer;
  background: #fff;
}
.form-group textarea {
  resize: vertical;
  min-height: 80px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] {
  display: none !important;
}
.modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  min-width: 320px;
  max-width: 90vw;
}
.modal-content h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
label.btn {
  cursor: pointer;
  display: inline-block;
}
