:root {
  --bg: #ffffff;
  --surface: #f5f8fc;
  --line: #e2e9f1;
  --text: #1b2733;
  --muted: #6b7a8a;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.topbar {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 6;
}
.brand { font-size: 15px; font-weight: 600; margin-right: 6px; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
select, input[type="text"], input[type="search"] {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13px; outline: none;
}
select:focus, input:focus { border-color: var(--accent); }
#nameSelect { max-width: 190px; }
#searchInput { width: 190px; }
.search-box { position: relative; }
#searchResults {
  position: absolute; top: 40px; left: 0; width: 260px; max-height: 320px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20, 40, 70, 0.12); z-index: 30; padding: 6px;
}
#searchResults .result {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 13px;
}
#searchResults .result:hover, #searchResults .result:focus-visible { background: var(--accent-soft); }
#searchResults .result em { font-style: normal; font-size: 11px; color: var(--muted); }
.no-result { padding: 12px; font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: #fff; padding: 8px 12px; font-size: 12px; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn { height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12px; }
.btn:hover { border-color: #b9cde3; }
.btn.active { background: var(--accent-soft); color: var(--accent); border-color: #a9c9ea; }
#countBadge { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

.stage { flex: 1 1 auto; display: flex; min-height: 0; }
#mapWrap { position: relative; flex: 1 1 auto; min-width: 0; background: #fbfdff; }
#atlas { display: block; width: 100%; height: 100%; cursor: grab; }
#tooltip {
  position: absolute; z-index: 5; pointer-events: none; padding: 6px 10px;
  background: #102f4d; color: #fff; border-radius: 7px; font-size: 12px; white-space: nowrap;
}
#side {
  flex: 0 0 306px; width: 306px; border-left: 1px solid var(--line);
  background: var(--surface); padding: 18px; overflow: auto;
}
.side-empty h3 { margin: 0 0 10px; font-size: 15px; }
.side-empty p { margin: 0 0 14px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.tips { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.side-kicker { font-size: 11px; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; }
.side-card h3 { margin: 8px 0 2px; font-size: 22px; }
.side-en { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.side-desc { font-size: 13px; line-height: 1.7; color: #3c4b5a; margin: 0 0 16px; }
.primary { width: 100%; height: 36px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; }
.primary:hover { background: #0f4b87; }

footer {
  flex: 0 0 auto; padding: 8px 16px; border-top: 1px solid var(--line);
  background: #fff; font-size: 11px; line-height: 1.6; color: var(--muted);
}
footer b { color: #41556b; font-weight: 600; }
footer .compliance-inline { color: #8a5a12; }

#detail { position: absolute; inset: 0; z-index: 20; background: #fff; overflow: auto; padding: 22px max(24px, 6vw) 48px; }
#detail[hidden] { display: none; }
.detail-inner { max-width: 900px; margin: 0 auto; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.ghost { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 12px; }
.ghost:hover { border-color: #b9cde3; }
.crumb { font-size: 12px; color: var(--muted); }
.detail-title h2 { margin: 0 0 4px; font-size: 30px; letter-spacing: .01em; }
.detail-title p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chips span { padding: 4px 10px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.detail-sec { border-top: 1px solid var(--line); padding: 20px 0; }
.detail-sec h3 { margin: 0 0 12px; font-size: 16px; }
.lead { font-size: 14px; line-height: 1.85; color: #3c4b5a; margin: 0 0 18px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.fact { background: var(--surface); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.fact span { font-size: 11px; color: var(--muted); }
.fact strong { font-size: 14px; font-weight: 600; line-height: 1.5; }
.sec-note { margin: -4px 0 14px; font-size: 12px; color: var(--muted); }
.country-map { display: block; width: 100%; height: 260px; border: 1px solid var(--line); border-radius: var(--radius); background: #e4f1fa; }
.map-sec { padding-bottom: 22px; }
.species-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.species { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.species-icon { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.species-icon svg { width: 32px; height: 32px; }
.species h4 { margin: 1px 0 5px; font-size: 14px; }
.species p { margin: 0; font-size: 12px; line-height: 1.65; color: var(--muted); }
.sources { margin: 0 0 14px; padding-left: 18px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.compliance { font-size: 12px; line-height: 1.8; color: #8a5a12; background: #fdf6e8; border-radius: 8px; padding: 12px 14px; margin: 0; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.detail-actions .primary { width: auto; padding: 0 20px; }

@media (max-width: 900px) {
  #side { display: none; }
  .brand span { display: none; }
  #countBadge { display: none; }
  #searchInput, #nameSelect { width: 150px; max-width: 150px; }
  .topbar { padding: 8px 10px; gap: 6px; }
  #detail { padding: 16px 18px 40px; }
  .detail-title h2 { font-size: 24px; }
  .country-map { height: 200px; }
  .species-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  #searchInput { width: 130px; }
  #nameSelect { max-width: 130px; }
  .seg button { padding: 8px 9px; }
  footer { max-height: 58px; overflow: auto; }
}
