:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #e4e9f2;
  --brand: #1256d6;
  --brand-dark: #0b3a97;
  --brand-soft: #eef3ff;
  --teal: #0e9aa7;
  --ok: #0e7a4a;
  --err: #c03221;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(16, 40, 88, 0.08);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  background: var(--panel);
  overflow: hidden;
}

/* ---------- 侧栏 ---------- */
.side {
  background: linear-gradient(160deg, #0b2545 0%, #12386b 55%, #0e4f7a 100%);
  color: #eaf1fb;
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2f7bff, #14b8c8);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 12px;
  color: #9db8db;
  letter-spacing: 0.5px;
}

.side h1 {
  font-size: 24px;
  line-height: 1.4;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.side .lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: #b9cde8;
}

.facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 20px;
}

.facts li {
  font-size: 13px;
  color: #cfe0f5;
  padding-left: 16px;
  position: relative;
  line-height: 1.7;
}

.facts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4fc3d9;
}

.side-foot {
  margin-top: auto;
  font-size: 12px;
  color: #8aa6c9;
  line-height: 1.8;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 16px;
}

/* ---------- 聊天区 ---------- */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1256d6, #14b8c8);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  flex: none;
}

.who-text strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.who-text span {
  font-size: 12.5px;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 5px;
  vertical-align: middle;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-ghost:hover { border-color: #c3d0e6; color: var(--brand); }

/* ---------- 消息 ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 26px 26px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 760px;
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg .bubble {
  padding: 13px 17px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.8;
  word-break: break-word;
}

.msg.bot .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(16, 40, 88, 0.04);
  border-top-left-radius: 5px;
}

.msg.user .bubble {
  background: var(--brand);
  color: #fff;
  border-top-right-radius: 5px;
}

.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul { margin: 6px 0 8px; padding-left: 20px; }
.msg .bubble li { margin-bottom: 4px; }
.msg .bubble strong { font-weight: 600; }
.msg.bot .bubble strong { color: var(--brand-dark); }

.msg .bubble code {
  background: #eef2f9;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 13px;
}

/* 失败重试 */
.retry-bar { margin-top: 10px; }

.btn-retry {
  border: 1px solid #cddaf0;
  background: #f7faff;
  color: var(--brand);
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-retry:hover { background: var(--brand-soft); border-color: var(--brand); }

.tag {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.4px;
}

.msg-col { min-width: 0; }

/* 输入中动画 */
.thinking {
  font-size: 13px;
  color: var(--muted);
  margin-right: 8px;
  vertical-align: middle;
}

.dots { display: inline-flex; gap: 4px; padding: 3px 0; vertical-align: middle; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9aa8bf; display: block;
  animation: blink 1.3s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* 快捷问题 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 0 26px 16px;
  max-width: 860px;
}

.chip {
  border: 1px solid #d3ddef;
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---------- 输入区 ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 26px 20px;
  background: var(--bg);
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 86, 214, 0.1);
}

#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.65;
  max-height: 132px;
  padding: 6px 0;
  color: var(--ink);
  background: transparent;
  min-width: 0;
}

#input::placeholder { color: #9aa8bf; }

.btn-send {
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: 11px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  flex: none;
}

.btn-send:hover:not(:disabled) { background: var(--brand-dark); }
.btn-send:disabled { background: #b9c6dd; cursor: not-allowed; }

.btn-stop {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  flex: none;
}

.foot-note {
  text-align: center;
  font-size: 12px;
  color: #93a1b8;
  padding: 0 26px 14px;
  background: var(--bg);
}

/* ---------- 留资弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 28, 56, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
  backdrop-filter: blur(2px);
}

.overlay.on { display: flex; }

.modal {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(11, 37, 69, 0.28);
  animation: rise 0.22s ease;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.modal .sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field .req { color: var(--err); }

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--ink);
  background: #fbfcfe;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(18, 86, 214, 0.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: 11px;
  padding: 12px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { background: #b9c6dd; cursor: not-allowed; }

.form-msg {
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
  line-height: 1.6;
}

.form-msg.err { color: var(--err); }
.form-msg.ok { color: var(--ok); }

.privacy {
  font-size: 12px;
  color: #93a1b8;
  margin-top: 14px;
  line-height: 1.6;
}

/* ---------- 移动端 ---------- */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .side { padding: 22px 20px; gap: 16px; }
  .side h1 { font-size: 20px; }
  .facts { display: none; }
  .side-foot { border-top: none; padding-top: 0; }
  .chat { height: 100vh; }
  .messages, .chips, .composer, .foot-note { padding-left: 16px; padding-right: 16px; }
  .chat-head { padding: 12px 16px; }
}
