:root {
  --bg: #f5f7fa;
  --panel-bg: #ffffff;
  --text: #1f2933;
  --text-2: #616e7c;
  --text-3: #9aa5b1;
  --line: #e4e7eb;
  --brand: #1a6ce8;
  --brand-soft: #e8f0fe;
  --primary: #c0392b;
  --primary-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  flex: 0 0 auto;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

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

.logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a6ce8, #4f9bff);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px;
}

.brand-title { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.tabs { display: flex; gap: 4px; flex: 1; }

.tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.tab:hover { background: #f0f2f5; color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

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

.engine-badge {
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}
.engine-badge.ok { color: #1a7f37; border-color: #b7e0c3; background: #f0fbf4; }
.engine-badge.warn { color: #9a6700; border-color: #f0d9a8; background: #fffaf0; }

/* ------------------------------------------------------------------ 布局 */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

.panel {
  flex: 0 0 360px;
  width: 360px;
  background: var(--panel-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 10;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  padding: 14px 14px 0;
  gap: 10px;
}
.view[hidden] { display: none; }

.map-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
.map { position: absolute; inset: 0; background: #e8edf2; }

/* ------------------------------------------------------------------ 控件 */
.seg {
  display: flex;
  background: #f0f2f5;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 0;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.seg-btn.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }

.switch-row { display: flex; gap: 6px; }
.switch-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  padding: 7px 4px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.switch-btn:hover { border-color: #c9d4e0; }
.switch-btn.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { opacity: .65; margin-left: 3px; font-size: 11px; }

.search { position: relative; display: flex; }
.search input {
  flex: 1;
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 8px;
  padding: 9px 32px 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--brand); background: #fff; }
.search .clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: #dfe3e8; color: #667;
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
  display: none;
}
.search .clear.show { display: block; }

/* ------------------------------------------------------------------ 列表 */
.list {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0 -14px;
  padding: 0 14px 14px;
  min-height: 0;
}
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: #d5dae0; border-radius: 4px; }
.list::-webkit-scrollbar-track { background: transparent; }

.list-item {
  padding: 10px 11px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
  margin-bottom: 3px;
}
.list-item:hover { background: #f7f9fb; }
.list-item.active { background: var(--brand-soft); border-color: #c7dbfc; }
.list-item .name { font-size: 13.5px; font-weight: 550; line-height: 1.4; }
.list-item .meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.list-item .badges { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #eef1f5;
  color: var(--text-2);
  white-space: nowrap;
}
.badge.primary { background: #e8f0fe; color: #1958c0; }
.badge.middle { background: #eae7fd; color: #5b46c0; }

.empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.8;
}
.result-count {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 2px 0 6px;
}

/* ------------------------------------------------------------------ 详情 */
.detail {
  border-top: 1px solid var(--line);
  margin: 0 -14px;
  padding: 12px 14px 14px;
  max-height: 46%;
  overflow-y: auto;
  background: #fcfcfd;
  flex: 0 0 auto;
}
.detail h3 { margin: 0 0 4px; font-size: 14.5px; }
.detail .sub { font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; line-height: 1.6; }
.detail .desc {
  font-size: 12.5px; line-height: 1.75; color: #374151;
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; margin-bottom: 9px;
  white-space: pre-wrap;
}
.detail .sec-title {
  font-size: 12px; color: var(--text-2); font-weight: 600;
  margin: 10px 0 6px; display: flex; justify-content: space-between;
}
.detail .loupan-list { display: flex; flex-wrap: wrap; gap: 5px; }
.detail .loupan-tag {
  font-size: 11.5px; padding: 4px 9px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 20px; cursor: pointer; color: var(--text-2);
}
.detail .loupan-tag:hover { border-color: var(--brand); color: var(--brand); }
.detail .close-detail {
  float: right; border: 0; background: transparent; cursor: pointer;
  color: var(--text-3); font-size: 18px; line-height: 1; padding: 0 2px;
}

/* ------------------------------------------------------------------ 筛选 */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-2); }
.field select, .field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #f9fafb;
  color: var(--text);
  outline: none;
}
.field select:focus, .field input:focus { border-color: var(--brand); background: #fff; }
.filter-actions { display: flex; gap: 8px; }
.primary-btn {
  flex: 1; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff;
  padding: 10px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.primary-btn:hover { background: #1559c7; }
.ghost-btn {
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text-2);
  padding: 10px 16px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.hint { margin: 0; font-size: 12px; color: var(--text-3); line-height: 1.7; }

/* ------------------------------------------------------------------ 地图浮层 */
.map-hint {
  position: absolute;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  background: rgba(31, 41, 51, .88);
  color: #fff;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
  z-index: 6;
  max-width: 70%;
  text-align: center;
}
.map-hint.show { opacity: 1; }

.legend {
  position: absolute;
  right: 14px; bottom: 26px;
  background: rgba(255, 255, 255, .96);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.9;
  z-index: 5;
  max-width: 220px;
}
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }

.footer {
  flex: 0 0 auto;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 20;
}
.footer .dot { opacity: .5; }

/* ------------------------------------------------------------------ 回退地图 */
.mm-root { position: absolute; inset: 0; overflow: hidden; cursor: grab; background: #dfe6ee; }
.mm-root.dragging { cursor: grabbing; }
.mm-tile { position: absolute; width: 256px; height: 256px; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.mm-overlay { position: absolute; inset: 0; pointer-events: none; }
.mm-controls {
  position: absolute; right: 14px; top: 14px;
  display: flex; flex-direction: column; gap: 1px;
  border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-lg); z-index: 5;
}
.mm-controls button {
  width: 34px; height: 34px; border: 0; background: #fff;
  font-size: 17px; color: #444; cursor: pointer; line-height: 1;
  font-family: inherit;
}
.mm-controls button:hover { background: #f2f5f8; }
.mm-attrib {
  position: absolute; left: 0; bottom: 0;
  font-size: 10px; color: #667; background: rgba(255,255,255,.75);
  padding: 2px 6px; z-index: 4;
}
.mm-tip {
  position: absolute; z-index: 7; pointer-events: none;
  background: rgba(31,41,51,.92); color: #fff;
  font-size: 11.5px; padding: 4px 9px; border-radius: 5px;
  white-space: nowrap; transform: translate(-50%, -140%);
  opacity: 0; transition: opacity .1s;
}
.mm-tip.show { opacity: 1; }

/* 点选查询模式：覆盖物完全不拦截鼠标（含子元素） */
.mm-root.pick-through .mm-overlay,
.mm-root.pick-through .mm-overlay * {
  pointer-events: none !important;
}

@media (max-width: 900px) {
  .panel { flex-basis: 300px; width: 300px; }
  .brand-sub { display: none; }
}
