:root{
  --bg: #0f1115;
  --panel: #141826;
  --panel2: #0b0d11;
  --text: #e8e8e8;
  --muted: rgba(255,255,255,0.68);
  --faint: rgba(255,255,255,0.46);
  --border: rgba(255,255,255,0.10);
  --shadow: 0 12px 30px rgba(0,0,0,0.35);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Noto Sans CJK SC", "Microsoft Yahei", sans-serif;
}

*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app{
  height: 100vh;
  display: flex;
}

#mapPanel{
  flex: 1 1 auto;
  display:flex;
  flex-direction: column;
  min-width: 0;
}

#topBar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
}

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

.logo{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.brandText{ line-height: 1.1; }
.productName{
  font-weight: 700;
  letter-spacing: 0.2px;
}
.productTagline{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.topBarRight{ display:flex; align-items:center; gap: 8px; }
.ghostBtn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.ghostBtn:hover{ background: rgba(255,255,255,0.06); }

#mapContainer{
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: radial-gradient(1000px 600px at 30% 30%, rgba(255,255,255,0.035), rgba(255,255,255,0) 55%) , var(--panel2);
  overflow: hidden;
}

#mapSvg{
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

.land{
  fill: rgba(255,255,255,0.06);
  stroke: rgba(255,255,255,0.14);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  fill-rule: evenodd;
}

.event-marker{
  cursor: pointer;
  --c: rgba(120, 190, 255, 1);
}

.event-marker .heat{
  fill: var(--c);
  fill-opacity: 0.10;
  stroke: var(--c);
  stroke-opacity: 0.26;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.event-marker .pulse{
  fill: none;
  stroke: var(--c);
  stroke-opacity: 0.55;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse 2.2s ease-out infinite;
}

@keyframes pulse{
  0%{ transform: scale(0.55); opacity: 0.65; }
  70%{ transform: scale(1.6); opacity: 0; }
  100%{ transform: scale(1.6); opacity: 0; }
}

.event-marker .pin{
  fill: rgba(15,17,21,0.86);
  stroke: var(--c);
  stroke-opacity: 0.7;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.event-marker .icon{
  font-size: 16px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.35));
}

.event-marker.isSelected .pin{
  stroke-width: 2.2;
  stroke-opacity: 0.95;
}

.event-marker.isHover .pin{
  stroke-width: 2.2;
}

.cat-conflict{ --c: rgba(255, 110, 110, 1); }
.cat-politics{ --c: rgba(120, 190, 255, 1); }
.cat-economy{ --c: rgba(110, 235, 175, 1); }
.cat-science{ --c: rgba(230, 190, 110, 1); }
.cat-disaster{ --c: rgba(255, 155, 95, 1); }
.cat-culture{ --c: rgba(190, 150, 255, 1); }
.cat-sports{ --c: rgba(130, 220, 255, 1); }

.tooltip{
  position: absolute;
  left: 20px;
  top: 20px;
  min-width: 220px;
  max-width: 320px;
  background: rgba(20,24,38,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.tooltip.hidden{ display:none; }

.ttTitle{
  font-weight: 750;
  letter-spacing: 0.2px;
  display:flex;
  align-items:center;
  gap: 8px;
}

.ttMeta{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.ttDesc{
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.86);
  line-height: 1.35;
}

.ttPop{
  margin-top: 10px;
  display:flex;
  align-items:center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.popBar{
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
}
.popFill{
  height: 100%;
  width: 50%;
  background: rgba(255,255,255,0.55);
}

#bottomBar{
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

#sidePanel{
  width: 360px;
  max-width: 42vw;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display:flex;
  flex-direction: column;
}

.controls{
  padding: 14px;
  overflow: auto;
  border-bottom: 1px solid var(--border);
}

.controlRow{
  display:grid;
  grid-template-columns: 1fr auto;
  grid-auto-rows: min-content;
  gap: 10px;
  align-items:center;
  margin-bottom: 12px;
}

.controlLabel{
  font-size: 12px;
  color: var(--muted);
}

.pillBtn{
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
}
.pillBtn:hover{ background: rgba(255,255,255,0.06); }

.yearRow{
  grid-column: 1 / -1;
  display:flex;
  gap: 10px;
  align-items:center;
}
#yearSlider{
  width: 100%;
}
.yearValue{
  min-width: 52px;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  font-variant-numeric: tabular-nums;
}

.switch{
  justify-self: end;
  position: relative;
  width: 44px;
  height: 24px;
  display:inline-block;
}
.switch input{ display:none; }
.slider{
  position:absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--border);
  transition: 0.2s ease;
}
.slider:before{
  content:"";
  position:absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255,255,255,0.85);
  transition: 0.2s ease;
}
.switch input:checked + .slider{
  background: rgba(110,235,175,0.22);
}
.switch input:checked + .slider:before{
  transform: translate(20px, -50%);
}

.modeText{
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--faint);
  margin-top: -6px;
}

.filters{
  grid-column: 1 / -1;
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filterItem{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  user-select: none;
}
.filterItem:hover{ background: rgba(255,255,255,0.06); }
.filterItem input{ margin: 0; }
.filterIcon{ width: 18px; text-align:center; }
.filterText{ font-size: 12px; color: rgba(255,255,255,0.86); }

.select{
  width: 100%;
  grid-column: 1 / -1;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}

.search{
  width: 100%;
  grid-column: 1 / -1;
  padding: 9px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
}
.search::placeholder{ color: rgba(255,255,255,0.35); }

.listHeader{
  padding: 10px 14px;
  display:flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.resultCount{
  font-size: 12px;
  color: var(--muted);
}
.dataNote{
  font-size: 11px;
  color: rgba(255,255,255,0.36);
}

.eventList{
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px 12px 14px 12px;
}

.eventItem{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  padding: 10px 10px;
  display:flex;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 10px;
}
.eventItem:hover{
  background: rgba(255,255,255,0.05);
}
.eventItem.selected{
  border-color: rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
}

.eventIcon{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,0.06);
  flex: 0 0 auto;
}

.eventBody{ flex: 1 1 auto; min-width: 0; }
.eventTitle{
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eventMeta{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

.eventRight{
  flex: 0 0 auto;
  display:flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.eventPop{
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: rgba(255,255,255,0.78);
}
.eventPopBar{
  width: 70px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow:hidden;
}
.eventPopFill{
  height: 100%;
  background: rgba(255,255,255,0.55);
  width: 50%;
}

@media (max-width: 980px){
  #sidePanel{ width: 320px; }
}
@media (max-width: 780px){
  #app{ flex-direction: column; }
  #sidePanel{
    width: 100%;
    max-width: none;
    height: 42vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  #mapPanel{ height: 58vh; }
}
