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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans CN", sans-serif;
  color: #e8eef5;
  background: #0d1b2a;
  user-select: none;
}

#app {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 220px 1fr 340px;
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar canvas info";
  width: 100vw;
  height: 100vh;
}

/* === Top bar === */
#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: linear-gradient(180deg, #162b43 0%, #102238 100%);
  border-bottom: 1px solid #1e3654;
  gap: 20px;
}

#topbar h1 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  color: #e8eef5;
}

#topbar h1 .accent {
  color: #7ab8ea;
  font-weight: 600;
}

.topbar-spacer { flex: 1; }

.view-switch {
  display: flex;
  gap: 4px;
  background: #0a1726;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #1e3654;
}

.view-btn {
  background: transparent;
  color: #9fb4cc;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
}

.view-btn:hover {
  color: #e8eef5;
  background: #162b43;
}

.view-btn.active {
  background: #2563a5;
  color: white;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9fb4cc;
  font-size: 13px;
  cursor: pointer;
}

.toggle-wrap input {
  cursor: pointer;
  accent-color: #2563a5;
}

/* === Sidebar === */
#sidebar {
  grid-area: sidebar;
  background: #0f1f33;
  border-right: 1px solid #1e3654;
  padding: 16px 10px;
  overflow-y: auto;
}

#sidebar h2 {
  font-size: 12px;
  color: #6a8aac;
  letter-spacing: 2px;
  margin-bottom: 12px;
  padding-left: 8px;
}

#landform-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.landform-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c4d4e6;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  transition: all 0.18s;
  width: 100%;
}

.landform-item:hover {
  background: #162b43;
  border-color: #284a70;
  transform: translateX(2px);
}

.landform-item.active {
  background: linear-gradient(90deg, #1e5a8a, #2563a5);
  border-color: #3b86d1;
  color: white;
}

.landform-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* === Canvas === */
#canvas-wrap {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1a3050 0%, #0d1b2a 100%);
}

#canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === Info panel === */
#info-panel {
  grid-area: info;
  background: #0f1f33;
  border-left: 1px solid #1e3654;
  padding: 20px;
  overflow-y: auto;
}

#info-panel h2 {
  font-size: 22px;
  font-weight: 600;
  color: #e8eef5;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid #2563a5;
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-grid section h3 {
  font-size: 13px;
  color: #7ab8ea;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-weight: 500;
}

.info-grid section h3::before {
  content: '▎';
  margin-right: 2px;
  color: #2563a5;
}

.info-grid section p {
  font-size: 14px;
  line-height: 1.7;
  color: #c4d4e6;
}

.info-grid section ul {
  padding-left: 4px;
  list-style: none;
}

.info-grid section li {
  font-size: 14px;
  line-height: 1.7;
  color: #c4d4e6;
  position: relative;
  padding-left: 16px;
}

.info-grid section li::before {
  content: '•';
  position: absolute;
  left: 2px;
  color: #7ab8ea;
  font-weight: bold;
}

/* === 3D labels === */
.terrain-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -100%);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.label-pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #7ac6ff 0%, #2563a5 100%);
  border: 2px solid white;
  box-shadow: 0 0 12px rgba(122, 198, 255, 0.8);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(122, 198, 255, 0.6); }
  50% { box-shadow: 0 0 18px rgba(122, 198, 255, 1); }
}

.label-text {
  margin-top: 4px;
  padding: 3px 10px;
  background: rgba(15, 31, 51, 0.92);
  color: #e8eef5;
  font-size: 13px;
  border-radius: 12px;
  border: 1px solid #3b86d1;
  white-space: nowrap;
}

.terrain-label:hover .label-text {
  background: #2563a5;
  color: white;
}

/* === Note popup === */
#note-popup {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 31, 51, 0.96);
  border: 1px solid #3b86d1;
  border-radius: 10px;
  padding: 14px 40px 14px 18px;
  min-width: 280px;
  max-width: 420px;
  color: #e8eef5;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 100;
}

#note-popup.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#note-popup strong {
  color: #7ab8ea;
  font-size: 15px;
  display: block;
  margin-bottom: 6px;
}

#note-popup p {
  line-height: 1.6;
  color: #c4d4e6;
}

#note-popup .close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: #6a8aac;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}

#note-popup .close:hover {
  color: #e8eef5;
}

/* === Scrollbars === */
#sidebar::-webkit-scrollbar,
#info-panel::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-track,
#info-panel::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb,
#info-panel::-webkit-scrollbar-thumb { background: #284a70; border-radius: 3px; }

/* === Responsive === */
@media (max-width: 1100px) {
  #app {
    grid-template-columns: 180px 1fr 280px;
  }
}

@media (max-width: 900px) {
  #app {
    grid-template-rows: 56px 160px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "canvas";
  }
  #info-panel { display: none; }
  #sidebar { padding: 8px; }
  #landform-list {
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .landform-item { flex-shrink: 0; }
}
