:root {
  --bg: #f4f6fb;
  --bg-grad: linear-gradient(160deg, #eef3ff 0%, #f6f7fb 45%, #eef8f4 100%);
  --card: #ffffff;
  --border: #e6e9f2;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #8a92a3;
  --primary: #3b6cff;
  --primary-2: #5b8cff;
  --accent: #00b578;
  --accent-2: #00c48c;
  --danger: #ff4d6a;
  --shadow: 0 8px 30px rgba(60, 80, 150, 0.10);
  --shadow-sm: 0 2px 10px rgba(60, 80, 150, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; max-width: 1280px; margin: 0 auto; }

/* 侧边栏 */
.sidebar {
  width: 288px; min-width: 288px;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 8px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(59,108,255,0.35); flex-shrink: 0;
}
.brand h1 { font-size: 17px; font-weight: 700; line-height: 1.2; }
.brand p { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
}
.panel h3 { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.quick-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 10px; cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: all .15s; border: 1px solid transparent;
}
.quick-item:hover { background: #f0f4ff; color: var(--primary); border-color: #dce5ff; }
.quick-item .ico { font-size: 16px; }

.loc-card .loc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.loc-city { font-size: 14px; font-weight: 600; }
.loc-detail { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.loc-weather { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }

.btn {
  border: none; cursor: pointer; border-radius: 10px; font-size: 13px; font-weight: 500;
  padding: 9px 12px; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: #f2f4fa; color: var(--text-2); }
.btn-ghost:hover { background: #e8ecf6; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.model-select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: #f7f8fc; font-size: 13px; color: var(--text); outline: none;
}
.model-select:focus { border-color: var(--primary); }

/* 主区域 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.5); backdrop-filter: blur(10px);
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

.chat { flex: 1; overflow-y: auto; padding: 24px 22px 12px; scroll-behavior: smooth; }
.chat-inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.msg { display: flex; gap: 10px; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.msg.user .avatar { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.msg.ai .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.avatar svg { width: 18px; height: 18px; }

.bubble { max-width: 78%; padding: 12px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.7; word-break: break-word; }
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-sm); border-bottom-left-radius: 4px; }
.bubble code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.msg.user .bubble code { background: rgba(255,255,255,0.22); }
.bubble a { color: var(--primary); text-decoration: none; }
.msg.user .bubble a { color: #fff; text-decoration: underline; }
.bubble .map-img { display: block; width: 100%; max-width: 480px; border-radius: 12px; margin: 10px 0; border: 1px solid var(--border); }

.citations { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 12px; }
.citations .cite-title { color: var(--text-3); margin-bottom: 6px; font-weight: 600; }
.citations a { display: block; color: var(--primary); margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citations a:hover { text-decoration: underline; }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); padding: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: .4; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }

/* 输入区 */
.input-wrap { padding: 12px 22px 18px; }
.input-box {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 10px 12px; box-shadow: var(--shadow);
}
.input-box:focus-within { border-color: var(--primary); box-shadow: 0 8px 30px rgba(59,108,255,0.18); }
textarea { flex: 1; border: none; outline: none; resize: none; font-size: 15px; line-height: 1.5; color: var(--text); font-family: inherit; max-height: 140px; background: transparent; }
.send-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59,108,255,0.4); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.send-btn svg { width: 20px; height: 20px; }
.hint { text-align: center; font-size: 11.5px; color: var(--text-3); margin-top: 8px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,25,40,0.4);
  display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(3px);
}
.modal-mask.show { display: flex; }
.modal {
  width: 92%; max-width: 440px; background: #fff; border-radius: 20px;
  padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: fadeIn .2s ease;
}
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .m-sub { font-size: 13px; color: var(--text-3); margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; }
.field input:focus { border-color: var(--primary); }
.field .desc { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.modal .btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.warn { background: #fff7f0; border: 1px solid #ffe0c7; color: #b45309; font-size: 12px; line-height: 1.6; padding: 10px 12px; border-radius: 10px; margin-top: 14px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .bubble { max-width: 90%; }
  .topbar { padding: 12px 16px; }
  .chat { padding: 16px 12px 8px; }
  .input-wrap { padding: 10px 12px 14px; }
}
