:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --brand: #2f6bff;
  --brand-soft: #eaf1ff;
  --text: #1f2430;
  --text-2: #5b6472;
  --line: #e7ebf2;
  --user-bubble: #2f6bff;
  --bot-bubble: #ffffff;
  --shadow: 0 6px 24px rgba(31, 36, 48, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand);
  color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.new-chat-btn {
  width: 100%; padding: 11px; border: none; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .15s;
}
.new-chat-btn:hover { filter: brightness(1.05); }
.conv-list { flex: 1; overflow-y: auto; margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.conv-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px;
  color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar-foot { font-size: 11px; color: #9aa3b2; padding: 10px 6px 0; line-height: 1.5; }

/* ---------- 主区 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px);
}
.top-title { font-weight: 700; font-size: 15px; }
.top-sub { color: var(--text-2); font-size: 12.5px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  width: 34px; height: 34px; cursor: pointer; font-size: 16px; color: var(--text-2);
  display: none;
}

.messages { flex: 1; overflow-y: auto; padding: 22px 0; }
.msg-row { display: flex; padding: 6px 20px; gap: 12px; }
.msg-row.user { flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.avatar.bot { background: linear-gradient(135deg, #2f6bff, #5b8bff); }
.avatar.user { background: #20a779; }
.bubble {
  max-width: min(720px, 78%); padding: 12px 15px; border-radius: 14px; line-height: 1.7;
  font-size: 14.5px; word-wrap: break-word; box-shadow: var(--shadow);
}
.msg-row.bot .bubble { background: var(--bot-bubble); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg-row.user .bubble { background: var(--user-bubble); color: #fff; border-top-right-radius: 4px; }
.bubble pre {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; font-size: 13px; line-height: 1.5;
}
.bubble code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.bubble :not(pre) > code { background: var(--brand-soft); color: #1d4ed8; padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.bubble a { color: var(--brand); }
.bubble ul, .bubble ol { padding-left: 20px; margin: 6px 0; }
.bubble p { margin: 6px 0; }
.typing span {
  display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%;
  background: var(--text-2); animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

/* ---------- 欢迎页 ---------- */
.welcome { text-align: center; padding: 40px 20px; max-width: 640px; margin: 0 auto; }
.welcome-emoji { font-size: 46px; }
.welcome h1 { font-size: 24px; margin: 12px 0 6px; }
.welcome p { color: var(--text-2); margin: 0 0 22px; }
.suggests { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.suggest {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 14px;
  cursor: pointer; font-size: 14px; color: var(--text); text-align: left; transition: .15s;
}
.suggest:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- 输入框 ---------- */
#composer { padding: 14px 20px 18px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
}
#input {
  flex: 1; border: none; outline: none; resize: none; font-size: 15px; line-height: 1.6;
  max-height: 160px; background: transparent; color: var(--text); font-family: inherit;
}
.send-btn {
  border: none; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 12px; cursor: pointer; transition: filter .15s;
}
.send-btn:hover { filter: brightness(1.05); }
.send-btn:disabled { opacity: .5; cursor: default; }
.composer-tip { text-align: center; font-size: 11.5px; color: #9aa3b2; margin-top: 8px; }

/* ---------- 响应式（手机） ---------- */
@media (max-width: 768px) {
  #sidebar {
    position: absolute; z-index: 30; height: 100%; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  .icon-btn { display: grid; place-items: center; }
  .bubble { max-width: 86%; }
  .suggests { grid-template-columns: 1fr; }
  .msg-row { padding: 6px 12px; }
}
