:root {
  --bg: #10141b;
  --panel: rgba(18, 23, 32, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8edf5;
  --muted: #96a2b5;
  --accent: #5fb0ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

#app { position: relative; width: 100%; height: 100%; }

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

/* CSS2DRenderer が生成するレイヤー。ラベル自体だけクリックできるようにする */
#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 290px;
  height: 100%;
  padding: 18px 18px 24px;
  overflow-y: auto;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  transition: transform 0.2s ease;
}

#sidebar.hidden { transform: translateX(-100%); }

#sidebar h1 { margin: 0 0 4px; font-size: 16px; letter-spacing: 0.04em; }
#sidebar h2 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#sidebar section { margin-top: 22px; }
#model-meta { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

#model-select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0c1017;
  color: var(--text);
  font-size: 13px;
}

#marker-list { list-style: none; margin: 0; padding: 0; }

#marker-list li { margin-bottom: 6px; }

#marker-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

#marker-list button:hover { background: rgba(95, 176, 255, 0.16); border-color: var(--accent); }
#marker-list button.active { border-color: var(--accent); background: rgba(95, 176, 255, 0.22); }

#marker-list .swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
#marker-list .coords { margin-left: auto; font-size: 11px; color: var(--muted); }

.hint { font-size: 11px; color: var(--muted); line-height: 1.7; }
.keys { list-style: none; margin: 0; padding: 0; }

#sidebar-toggle {
  position: absolute;
  top: 12px;
  left: 302px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: left 0.2s ease;
}

#sidebar.hidden ~ #sidebar-toggle { left: 12px; }

/* 3D 空間に浮かぶ旗のラベル */
.marker-label {
  pointer-events: auto;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 16, 23, 0.82);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  transform: translateY(-6px);
  user-select: none;
}

.marker-label.active { border-color: var(--accent); background: rgba(30, 74, 118, 0.95); box-shadow: 0 0 0 3px rgba(95, 176, 255, 0.18); }
.marker-label:hover { border-color: var(--accent); background: rgba(24, 44, 68, 0.92); }
.marker-label .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 13, 18, 0.82);
  font-size: 14px;
}

#overlay.hidden { display: none; }
#overlay .box { text-align: center; max-width: 70%; }
#overlay p { margin: 14px 0 0; white-space: pre-wrap; line-height: 1.7; }
#overlay.error .spinner { display: none; }
#overlay.error p { color: #ff9d9d; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  #sidebar { width: 240px; }
  #sidebar-toggle { left: 252px; }
}
