:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --text: #1f2430;
  --muted: #8a92a6;
  --border: #e6e9f0;
  --user-bubble: #4f46e5;
  --ai-bubble: #ffffff;
  --shadow: 0 8px 30px rgba(30, 40, 90, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 820px;
  height: min(90vh, 860px);
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #fafaff 100%);
}

.logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.title { font-size: 17px; font-weight: 700; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 11px;
  border-radius: 999px;
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 12px; max-width: 88%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.ai { align-self: flex-start; }

.avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.msg.user .avatar { background: #cbd0dd; color: #4a5164; }
.msg.ai .avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.7;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.ai .bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble code {
  background: #f0f2f8; padding: 1px 5px; border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px;
}
.msg.user .bubble code { background: rgba(255,255,255,0.2); }
.bubble pre {
  background: #1e2233; color: #e6e9f5; padding: 12px 14px;
  border-radius: 8px; overflow-x: auto; margin: 8px 0;
}
.bubble pre code { background: transparent; padding: 0; color: inherit; }

.cursor::after {
  content: '';
  display: inline-block;
  width: 7px; height: 15px;
  background: var(--primary);
  vertical-align: text-bottom;
  margin-left: 3px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.quick-prompts {
  padding: 0 24px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-prompts button {
  border: 1px solid var(--border);
  background: #fff;
  color: #5b6275;
  font-size: 12px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.quick-prompts button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.composer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 160px;
  min-height: 46px;
  outline: none;
  transition: border-color 0.15s;
}
.composer textarea:focus { border-color: var(--primary); }
.send-btn {
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  width: 46px; height: 46px;
  border-radius: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn:not(:disabled):active { transform: scale(0.94); }

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
}
.empty .big {
  font-size: 40px;
  margin-bottom: 12px;
}
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 8px; }
.empty p { font-size: 14px; margin: 0; }

.note {
  padding: 8px 24px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
  background: #fafbfe;
}
