:root {
  --bg: #0f1117;
  --panel: #181a22;
  --panel-2: #20232d;
  --border: #2c2f3a;
  --text: #e6e6e6;
  --muted: #8a8f9c;
  --user: #2563eb;
  --assistant: #20232d;
  --accent: #3b82f6;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar .title { font-weight: 600; }
.topbar .actions { display: flex; gap: 8px; }

/* 按钮 */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { padding: 2px 10px; font-size: 18px; line-height: 1; }

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-hint {
  text-align: center;
  color: var(--muted);
  margin-top: 40px;
  padding: 0 20px;
  font-size: 14px;
}

.bubble {
  max-width: 760px;
  width: 100%;
  align-self: flex-start;
}
.bubble.user { align-self: flex-end; }
.bubble-content {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--assistant);
  border: 1px solid var(--border);
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bubble.user .bubble-content {
  background: var(--user);
  border-color: var(--user);
  color: #fff;
  white-space: pre-wrap;
}
.bubble-content.streaming .cursor { opacity: 0.6; }

.bubble-content p { margin: 0 0 8px; }
.bubble-content p:last-child { margin-bottom: 0; }
.bubble-content ul, .bubble-content ol { margin: 6px 0 8px; padding-left: 22px; }
.bubble-content code {
  background: #0d0f14;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}
.bubble-content pre {
  position: relative;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.bubble-content pre code { background: none; padding: 0; }
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
}
.bubble-content blockquote {
  border-left: 3px solid var(--danger);
  margin: 8px 0;
  padding: 2px 10px;
  color: var(--muted);
}
.muted { color: var(--muted); }

/* 输入区 */
.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field small { font-size: 12px; color: var(--muted); }
.radio-row { display: flex; gap: 16px; }
.radio-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

@media (max-width: 600px) {
  .bubble { max-width: 100%; }
  .topbar .title { font-size: 15px; }
}
