:root {
  --ink: #3d2e28;
  --paper: #F0ECEB;
  --card: #ffffff;
  --frost: #C4C0C1;
  --tea: #BA9B92;
  --branch: #987F74;
  --card-border: rgba(186,155,146,0.25);
}


:root {
  --font-size: 15px;
  --bubble-width: 80%;
  --bg-color: #1a1a2e;
  --chat-bg: #16213e;
  --user-bubble: var(--paper, #F0ECEB);
  --user-bubble-text: var(--ink, #3d2e28);
  --ai-bubble: var(--branch, #987F74);
  --ai-bubble-text: #ffffff;
  --text-color: var(--ink, #eee);
  --text-muted: var(--tea, #999);
  --border-color: var(--card-border, #333);
  --input-bg: var(--card, #ffffff);
  --topbar-bg: var(--card, #0f0f23);
}

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

body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--font-size);
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  background: var(--topbar-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  z-index: 200;
  border-bottom: 1px solid var(--border-color);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 16px; font-weight: bold; }
.char-display { font-size: 14px; color: var(--text-muted); }

.topbar-right { display: flex; gap: 6px; }
.topbar-right button {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.topbar-right button:hover { background: rgba(255,255,255,0.1); }

.chat-box {
  position: fixed;
  top: 50px;
  bottom: 60px;
  left: 0; right: 0;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  flex-direction: column;
  width: fit-content;
}

.message.user {
  align-self: flex-end;
  max-width: var(--bubble-width);
}

.message.assistant {
  align-self: flex-start;
  max-width: var(--bubble-width);
}

.msg-content {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--font-size);
}
  
.msg-content ul, .msg-content ol {
  padding-left: 1.5em;
}

.message.user .msg-content {
  background: var(--paper);
  color: var(--ink);
  border-bottom-right-radius: 4px;
}

.message.assistant .msg-content {
  background: var(--branch);
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.msg-actions {
  display: none;
  margin-top: 4px;
  gap: 4px;
}

.message.user .msg-actions {
  justify-content: flex-end;
}

.message.assistant .msg-actions {
  justify-content: flex-start;
}

.message:hover .msg-actions,
.message.touch-active .msg-actions {
  display: flex;
}

.msg-actions button {
  padding: 3px 8px;
  font-size: 12px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}
.msg-actions button:hover {
  background: rgba(255,255,255,0.2);
  color: var(--text-color);
}

.input-area {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  background: var(--topbar-bg);
  border-top: 1px solid var(--border-color);
  z-index: 200;
  gap: 8px;
}

.input-area textarea {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: var(--font-size);
  font-family: inherit;
  resize: none;
  line-height: 1.4;
  overflow-y: auto;
}
.input-area textarea:focus {
  outline: none;
  border-color: var(--user-bubble);
}

#btnSend {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--user-bubble);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#btnSend:hover { opacity: 0.85; }

.typing-indicator {
  position: fixed;
  bottom: 80px;
  left: 16px;
  color: var(--text-muted);
  font-size: 13px;
  z-index: 150;
}

.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  justify-content: center;
  align-items: center;
}
.modal.show { display: flex; }

.modal-content {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  color: var(--text-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; }
.modal-header button {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 20px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.tab.active {
  background: var(--user-bubble);
  color: #fff;
  border-color: var(--user-bubble);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.modal-content label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.modal-content input[type="text"],
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
  font-family: inherit;
}
.modal-content textarea { resize: vertical; }

.modal-content button {
  margin-top: 10px;
  padding: 8px 16px;
  border: none;
  background: var(--user-bubble);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.modal-content button:hover { opacity: 0.85; }

.api-item, .char-item, .conv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin: 4px 0;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
}
.api-item.active, .char-item.active, .conv-item.active {
  background: rgba(233,69,96,0.2);
  border: 1px solid var(--user-bubble);
}
.api-item button, .char-item button, .conv-item button {
  margin: 0 2px;
  padding: 4px 8px;
  font-size: 12px;
}


@media (max-width: 768px) {
  .topbar { padding: 0 8px; }
  .topbar-right button { padding: 5px 7px; font-size: 12px; }
  .logo { font-size: 14px; }
  .char-display { font-size: 12px; }
  .chat-box { padding: 12px 8px; }
  .msg-content { padding: 8px 12px; }
}

/* 时间戳 */
.msg-time {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 3px;
  padding: 0 4px;
}
.message.user .msg-time {
  text-align: right;
}
.message.assistant .msg-time {
  text-align: left;
}

/* 发送状态 */
.msg-status {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  padding: 0 4px;
}
.message.user .msg-status {
  text-align: right;
}

[data-theme="chuangsha"] {
  --ink: #3d3550;
  --paper: #F0EEF5;
  --card: #ffffff;
  --frost: #B6A9C8;
  --tea: #A09BC3;
  --branch: #7B6FA0;
  --card-border: rgba(182,169,200,0.25);
}

[data-theme="lenghui-warm"] {
  --ink: #F0EAE8;
  --paper: #393D3D;
  --card: #4a4f4f;
  --frost: #858989;
  --tea: #A09898;
  --branch: #774847;
  --card-border: rgba(133,137,137,0.25);
}

[data-theme="lenghui-cool"] {
  --ink: #3a3a3c;
  --paper: #F2E4E9;
  --card: #ffffff;
  --frost: #BFBB8E;
  --tea: #A0A0A3;
  --branch: #7a7a7d;
  --card-border: rgba(160,160,163,0.2);
}
