:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --accent: #10b981;
  --danger: #ef4444;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============ 顶部导航 ============ */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.brand-text h1 { font-size: 17px; font-weight: 700; }
.brand-text p { font-size: 12px; color: var(--text-light); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.status {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-light);
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f59e0b; animation: pulse 1.5s infinite;
}
.status.online .dot { background: var(--accent); animation: none; }
.status.error .dot { background: var(--danger); animation: none; }
@keyframes pulse { 50% { opacity: .4; } }

.settings-btn {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); cursor: pointer;
  font-size: 13px; transition: all .2s;
}
.settings-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ============ 主体布局 ============ */
.layout {
  flex: 1; display: flex; gap: 0; min-height: 0;
}
.chat-panel {
  width: 420px; min-width: 340px;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
}
.result-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* ============ 对话面板 ============ */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--text-light); padding: 4px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg); }

.quick-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.chip {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg); color: var(--text); font-size: 12.5px; cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); color: var(--text);
}
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #a0a6b0;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.input-area { padding: 12px 16px; border-top: 1px solid var(--border); }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; font-family: inherit; outline: none;
  max-height: 100px; line-height: 1.5; transition: border-color .2s;
}
.input-row textarea:focus { border-color: var(--primary); }
.send-btn {
  width: 42px; height: 42px; border: none; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 18px; cursor: pointer;
  transition: all .2s; flex-shrink: 0;
}
.send-btn:hover { background: var(--primary-dark); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }
.input-hint { font-size: 11px; color: var(--text-light); margin-top: 6px; }

/* ============ 结果面板 ============ */
.result-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--text-light); gap: 8px;
}
.result-placeholder .ph-icon { font-size: 56px; }
.result-placeholder p { font-size: 14px; }
.result-placeholder .ph-sub { font-size: 12px; color: #9ca3af; }

.result-card {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--panel); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .3s ease; z-index: 10;
}
.result-card.show { transform: translateX(0); }
.result-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px;
}
.result-card-body { flex: 1; overflow-y: auto; padding: 20px; }

/* POI 列表 */
.poi-list { display: flex; flex-direction: column; gap: 10px; }
.poi-item {
  display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: all .2s; align-items: center;
}
.poi-item:hover { border-color: var(--primary); background: #f8faff; }
.poi-idx {
  width: 28px; height: 28px; border-radius: 50%; background: #eff6ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.poi-info { flex: 1; min-width: 0; }
.poi-name { font-size: 14px; font-weight: 600; }
.poi-addr { font-size: 12px; color: var(--text-light); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-tag {
  font-size: 11px; color: var(--accent); background: #ecfdf5;
  padding: 2px 8px; border-radius: 10px; flex-shrink: 0;
}

.map-preview { margin-bottom: 16px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.map-preview img { width: 100%; display: block; cursor: zoom-in; }

/* 天气 */
.weather-info { display: flex; flex-direction: column; gap: 16px; }
.weather-now {
  display: flex; align-items: center; gap: 20px; padding: 20px;
  background: linear-gradient(135deg, #eff6ff, #e0f2fe); border-radius: 14px;
}
.weather-now .temp { font-size: 44px; font-weight: 700; color: var(--primary); }
.weather-now .cond { font-size: 14px; color: var(--text-light); line-height: 1.6; }
.weather-forecast { display: flex; gap: 8px; flex-wrap: wrap; }
.weather-day {
  flex: 1; min-width: 90px; text-align: center; padding: 12px 8px;
  border: 1px solid var(--border); border-radius: 10px;
}
.weather-day .d { font-size: 12px; color: var(--text-light); }
.weather-day .t { font-size: 15px; font-weight: 700; margin: 6px 0; }
.weather-day .w { font-size: 12px; }

/* 路线 / 通用信息 */
.info-box {
  background: var(--bg); border-radius: 12px; padding: 16px; font-size: 14px; line-height: 1.8;
}
.info-box .strong { color: var(--primary); font-weight: 700; }
.info-box .label { color: var(--text-light); }

/* ============ 弹窗 ============ */
.modal { display: none; }
.modal.show { display: block; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100;
}
.modal-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #fff; border-radius: 16px; z-index: 101; width: 90%;
  max-width: 480px; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.modal-body { padding: 20px; overflow-y: auto; }
.img-box { max-width: 780px; }

.settings-tip {
  font-size: 12.5px; color: var(--text-light); line-height: 1.6;
  background: #fff8e6; border: 1px solid #ffecb3; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group .req { color: var(--danger); }
.form-group input {
  width: 100%; padding: 10px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 10px; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.form-group input:focus { border-color: var(--primary); }
.form-link { font-size: 12px; color: var(--primary); text-decoration: none; margin-top: 5px; display: inline-block; }
.form-link:hover { text-decoration: underline; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-primary, .btn-secondary {
  flex: 1; padding: 11px; border: none; border-radius: 10px; font-size: 14px; cursor: pointer; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e8ebf0; }
.settings-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.settings-msg.ok { color: var(--accent); }
.settings-msg.err { color: var(--danger); }

.static-map-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: center; }
.static-map-actions button {
  padding: 9px 18px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); cursor: pointer; font-size: 13px; transition: all .2s;
}
.static-map-actions button:hover { border-color: var(--primary); color: var(--primary); }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .chat-panel { width: 100%; min-width: 0; height: 55%; border-right: none; border-bottom: 1px solid var(--border); }
  .result-panel { height: 45%; }
}
