:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(16, 24, 40, 0.08);
  --line-strong: rgba(16, 24, 40, 0.14);
  --text: #16202f;
  --text-2: #55627a;
  --text-3: #8b96ab;
  --brand: #3155f5;
  --brand-2: #12b8a6;
  --brand-soft: rgba(49, 85, 245, 0.1);
  --danger: #e04057;
  --warn: #c8811a;
  --ok: #178f6b;
  --radius: 16px;
  --shadow: 0 12px 34px rgba(22, 32, 47, 0.08);
  --shadow-sm: 0 4px 14px rgba(22, 32, 47, 0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 8% -10%, rgba(49, 85, 245, 0.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(18, 184, 166, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 18px 18px;
  gap: 12px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 4px;
}

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

.logo {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), #6b8bff 55%, var(--brand-2));
  box-shadow: 0 8px 20px rgba(49, 85, 245, 0.32);
}

.brand-text h1 { font-size: 18px; letter-spacing: 0.2px; }
.brand-text p { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.status { display: flex; gap: 6px; margin-right: 4px; }

.chip {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.05);
  color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.ok { background: rgba(23, 143, 107, 0.1); color: var(--ok); border-color: rgba(23, 143, 107, 0.2); }
.chip.bad { background: rgba(224, 64, 87, 0.09); color: var(--danger); border-color: rgba(224, 64, 87, 0.18); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 11px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), #4f74ff);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(49, 85, 245, 0.25);
}
.btn.ghost { background: rgba(255, 255, 255, 0.7); color: var(--text-2); }
.btn.tiny { padding: 5px 9px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.disabled { opacity: 0.45; pointer-events: none; }

.icon-btn {
  border: none; background: rgba(16, 24, 40, 0.05);
  width: 30px; height: 30px; border-radius: 9px;
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--text-2);
}

/* ---------- layout ---------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 14px;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar, .side-pane::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .side-pane::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 40, 0.14);
  border-radius: 99px;
}

/* ---------- welcome ---------- */
.welcome {
  margin: auto 0;
  text-align: center;
  padding: 20px 10px;
}
.welcome h2 { font-size: 24px; letter-spacing: 0.3px; }
.welcome > p { margin-top: 10px; color: var(--text-2); font-size: 14px; }
.examples {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}
.example {
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.16s ease;
}
.example:hover {
  border-style: solid;
  border-color: rgba(49, 85, 245, 0.4);
  color: var(--brand);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---------- message bubbles ---------- */
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .avatar {
  flex: 0 0 30px;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  background: rgba(16, 24, 40, 0.06);
  color: var(--text-2);
}
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: linear-gradient(135deg, var(--brand), #6b8bff); color: #fff; }
.msg.assistant .avatar { background: linear-gradient(135deg, var(--brand-2), #47d7c4); color: #fff; }

.bubble {
  max-width: min(100%, 720px);
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  line-height: 1.72;
  word-break: break-word;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--brand), #4f74ff);
  color: #fff;
  border-color: transparent;
}
.msg.user .bubble a { color: #fff; text-decoration: underline; }

.bubble p + p { margin-top: 8px; }
.bubble .md-list { margin: 6px 0 0; padding-left: 18px; }
.bubble code {
  background: rgba(16, 24, 40, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
}

.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* ---------- tool cards ---------- */
.tool-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.tool-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
  overflow: hidden;
}
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  background: rgba(49, 85, 245, 0.05);
  border-bottom: 1px solid var(--line);
}
.tool-head .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.tool-head.fail .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(224, 64, 87, 0.14); }
.tool-head b { color: var(--text); font-weight: 600; }
.tool-head .spin {
  margin-left: auto; font-size: 11px; color: var(--text-3);
}
.tool-body { padding: 10px 12px; font-size: 13px; color: var(--text-2); }

.poi-list { display: flex; flex-direction: column; gap: 8px; }
.poi {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
}
.poi:first-child { border-top: none; padding-top: 0; }
.poi .idx {
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11px; display: grid; place-items: center; font-weight: 600;
}
.poi .name { color: var(--text); font-weight: 600; font-size: 13.5px; }
.poi .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.55; }

.kv { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.kv span {
  background: rgba(16, 24, 40, 0.045);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12px;
  color: var(--text-2);
}
.kv span b { color: var(--text); font-weight: 600; }

.tool-body .meta { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.6; }

.reason-list { margin-top: 8px; padding-left: 16px; font-size: 12.5px; line-height: 1.7; }

.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.weather-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
.weather-cell .d { font-size: 11.5px; color: var(--text-3); }
.weather-cell .w { font-size: 13px; font-weight: 600; margin: 3px 0; color: var(--text); }
.weather-cell .t { font-size: 12px; color: var(--text-2); }

.err-text { color: var(--danger); font-size: 12.5px; line-height: 1.6; }

/* ---------- composer ---------- */
.composer {
  border-top: 1px solid var(--line);
  padding: 10px 16px 12px;
  background: rgba(255, 255, 255, 0.72);
}
.quick-row {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }
.quick {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.quick:hover { color: var(--brand); border-color: rgba(49, 85, 245, 0.35); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 7px 8px 7px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.input-row:focus-within {
  border-color: rgba(49, 85, 245, 0.5);
  box-shadow: 0 0 0 4px rgba(49, 85, 245, 0.08);
}
#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.6;
  max-height: 132px;
  padding: 5px 0;
}
#input::placeholder { color: var(--text-3); }
.send { padding: 9px 18px; }

.composer-tip { margin-top: 6px; font-size: 11px; color: var(--text-3); text-align: center; }

/* ---------- side pane ---------- */
.side-pane {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; overflow-y: auto;
  padding-right: 2px;
}

.card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.card-head h2 { font-size: 14px; }
.card-actions { display: flex; gap: 6px; }
.muted { color: var(--text-3); font-size: 11.5px; margin-top: 3px; }

.map-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #eef2fb, #e6f6f3);
  aspect-ratio: 750 / 460;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
#map-img { width: 100%; height: 100%; object-fit: cover; display: none; }
#map-img.show { display: block; }
.map-placeholder { text-align: center; color: var(--text-3); padding: 12px; }
.map-placeholder p { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.map-placeholder span { font-size: 11.5px; }
.pulse {
  width: 34px; height: 34px; margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(49, 85, 245, 0.35);
  position: relative;
}
.pulse::after {
  content: ""; position: absolute; inset: 8px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.6s infinite ease-out;
}
@keyframes pulse { 0% { transform: scale(0.7); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0.15; } }

.map-loading {
  position: absolute; inset: auto 0 0 0;
  padding: 6px 10px;
  font-size: 11.5px;
  color: #fff;
  background: rgba(16, 24, 40, 0.62);
  text-align: center;
  display: none;
}
.map-loading.show { display: block; }

.map-caption { margin-top: 8px; font-size: 11.5px; color: var(--text-3); line-height: 1.6; min-height: 16px; }

.loc-body { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.loc-city { font-size: 17px; font-weight: 600; color: var(--text); }
.loc-addr { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.loc-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.loc-meta span {
  font-size: 11.5px; color: var(--text-3);
  background: rgba(16, 24, 40, 0.045);
  border-radius: 7px; padding: 3px 8px;
}

.cap-list { list-style: none; padding: 0; margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.cap-list li { display: flex; gap: 10px; font-size: 12.5px; align-items: baseline; }
.cap-list b { color: var(--text); font-weight: 600; min-width: 70px; }
.cap-list span { color: var(--text-3); }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(12, 18, 30, 0.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal-mask.hidden { display: none; }
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(12, 18, 30, 0.3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 6px 18px 4px; }
.form-section { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.form-section:last-child { border-bottom: none; }
.form-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-3); margin-bottom: 10px; font-weight: 600;
}
.form-section label { display: block; margin-bottom: 10px; }
.form-section label span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.form-section input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  background: #fbfcff;
}
.form-section input:focus { border-color: rgba(49, 85, 245, 0.5); box-shadow: 0 0 0 3px rgba(49, 85, 245, 0.08); }
.hint { font-size: 11.5px; color: var(--text-3); line-height: 1.65; margin-top: 2px; }
.hint code { background: rgba(16, 24, 40, 0.06); padding: 1px 4px; border-radius: 4px; font-size: 11px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: #fff;
}

@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .side-pane { display: none; }
}

@media (max-width: 640px) {
  .app { padding: 10px 10px 12px; }
  .brand-text p { display: none; }
  .examples { grid-template-columns: minmax(0, 1fr); }
  .status { display: none; }
  .messages { padding: 14px 14px 8px; }
  .composer { padding: 8px 10px 10px; }
}
