:root {
  /* --- Design System Variables --- */
  --bg-base: #f3f3f3;
  --bg-card: #ffffff;
  --text-main: #2c2c2c;
  --text-sub: #8a8a8a;
  --accent-color: #FF5722;

  --radius-XL: 36px;
  --radius-L: 24px;
  --radius-S: 8px;

  --gap-L: 24px;
  --gap-M: 12px;
  --gap-S: 6px;

  --shadow-soft: 0 0 24px rgba(44, 44, 44, 0.2);
  --shadow-marker: 0 4px 10px rgba(0, 0, 0, 0.25);

  --nav-height: 48px;
  --panel-width-pc: 400px;

  --fs-title: 24px;
  --fs-std: 14px;

  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--bg-base);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#map, #chartMap {
  height: 100vh;
  width: 100%;
  z-index: 1;
  touch-action: none;
}

/* ---------------------------------------------------
   [MAP VIEW] Markers
   既存のマップビュー用
--------------------------------------------------- */
.marker-wrap, .cluster-wrap {
  width: 44px;
  height: 44px;
  cursor: pointer;
}

/* ---------------------------------------------------
   [CIRCLE VIEW] Markers
   サークルビュー専用
--------------------------------------------------- */
.circle-marker-wrap {
  cursor: pointer;
}

/* Size S (厚み0-2) */
.circle-marker-wrap.pin-s {
  width: 44px;
  height: 44px;
  z-index: 30; /* 小さいものを手前に */
}

/* Size M (厚み3-4) */
.circle-marker-wrap.pin-m {
  width: 54px; /* 修正: 64px -> 54px */
  height: 54px; /* 修正: 64px -> 54px */
  z-index: 20;
}
/* 中身の枠線を少し太く */
.circle-marker-wrap.pin-m .custom-marker {
  border-width: 4px;
}

/* Size L (厚み5以上) */
.circle-marker-wrap.pin-l {
  width: 68px; /* 修正: 88px -> 68px */
  height: 68px; /* 修正: 88px -> 68px */
  z-index: 10; /* 大きいものを奥に */
}
/* 中身の枠線を太く */
.circle-marker-wrap.pin-l .custom-marker {
  border-width: 5px;
}


/* ---------------------------------------------------
   Shared Marker Content (Icon)
--------------------------------------------------- */
.custom-marker, .cluster-marker {
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: var(--shadow-marker);
  /* 滑らかなアニメーション */
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s;
  will-change: transform;
  box-sizing: border-box;
}

.custom-marker {
  background-size: 70%;
  background-repeat: no-repeat;
  background-position: center;
}

.cluster-marker {
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

/* Hover Effects */
/* hover時は z-index を最大にして最前面へ */
.marker-wrap:hover, .cluster-wrap:hover, .circle-marker-wrap:hover {
  z-index: 100 !important;
}

.marker-wrap:hover .custom-marker, 
.cluster-wrap:hover .cluster-marker,
.circle-marker-wrap:hover .custom-marker {
  transform: scale(1.15);
  /* 修正: border-color: var(--text-main); を削除しました */
}

.marker-wrap:active .custom-marker, 
.cluster-wrap:active .cluster-marker,
.circle-marker-wrap:active .custom-marker {
  transform: scale(0.95);
}


/* ---------------------------------------------------
   FAB (Floating Action Buttons)
--------------------------------------------------- */
.fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 100;
  align-items: center;
}

@media (min-width: 768px) {
  .fab-container {
    right: 32px;
  }
}

.fab-btn {
  width: var(--nav-height);
  height: var(--nav-height);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.1s, background-color 0.2s, color 0.2s;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: 24px;
  position: static; 
}

.fab-btn:active {
  transform: scale(0.9);
}

.fab-toggle {
  background-color: var(--bg-card); 
  color: var(--text-main);
}

.fab-toggle.is-active {
  background-color: var(--text-main);
  color: white;
}

.fab-primary {
  background-color: var(--text-main);
  color: white;
}


/* ---------------------------------------------------
   Info Panel & Others
--------------------------------------------------- */
.info-panel {
  position: fixed;
  background: var(--bg-card);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.panel-scroll-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .info-panel {
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius-XL) var(--radius-XL) 0 0;
    transform: translateY(110%);
    height: 55vh;
    max-height: 55vh;
  }
  .info-panel.active {
    transform: translateY(0);
  }
}

@media (min-width: 768px) {
  .info-panel {
    top: 24px;
    right: 24px;
    bottom: 24px;
    width: var(--panel-width-pc);
    border-radius: var(--radius-XL);
    transform: translateX(calc(100% + 40px));
  }
  .info-panel.active {
    transform: translateX(0);
  }
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
  transition: transform 0.1s;
}

.close-btn:active {
  transform: scale(0.9);
  background: #fff;
}

.panel-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  min-height: 200px;
  background: #eee;
  cursor: zoom-in;
}

.panel-header {
  padding: var(--gap-L);
  padding-bottom: 0;
}

.panel-title {
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-main);
  margin: 0 0 var(--gap-M) 0;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-S);
  margin-bottom: var(--gap-L);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-S);
  font-size: 13px;
  font-weight: 700;
}

.badge-cat {
  background: var(--text-main);
  color: #ffffff;
}

.badge-date {
  background: #e0e0e0;
  color: var(--text-main);
}

.recorder-info {
  font-size: 12px;
  color: var(--text-sub);
  margin-left: auto;
  font-weight: 500;
}

.panel-body {
  padding: 0 var(--gap-L) var(--gap-L) var(--gap-L);
}

.info-section {
  margin-bottom: var(--gap-L);
}
.info-section:last-child {
  margin-bottom: 0;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: var(--gap-S);
  display: block;
}

.section-text {
  font-size: var(--fs-std);
  line-height: 1.6;
  color: var(--text-main);
}

.multi-tag {
  display: inline-flex;
  align-items: center;
  height: 32px;
  background: var(--bg-base);
  padding: 0 12px;
  border-radius: var(--radius-S);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 var(--gap-S) var(--gap-S) 0;
}

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  color: white;
  font-size: 32px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 10px;
}

.filter-bar {
  position: fixed;
  top: 24px;
  left: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  justify-content: flex-start;
  pointer-events: none;
}

@media (min-width: 768px) {
  .filter-bar {
    justify-content: flex-end;
  }
}

.filter-scroll {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  pointer-events: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 32px;
  cursor: pointer;
  color: var(--text-main);
  background: var(--bg-base);
  box-shadow: 0 0 0 1px rgba(44, 44, 44, 0.06);
  white-space: nowrap;
  user-select: none;
  transition: transform 0.08s;
}

.filter-chip:active {
  transform: scale(0.98);
}

.filter-chip.is-active {
  background: var(--text-main);
  color: #fff;
  box-shadow: none;
}

.count-bar {
  position: fixed;
  top: 80px;
  left: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  justify-content: flex-start;
  pointer-events: none;
}

@media (min-width: 768px) {
  .count-bar {
    justify-content: flex-end;
  }
}

.count-card {
  pointer-events: auto;
  background: var(--bg-base);
  color: var(--text-main);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 0 0 1px rgba(44, 44, 44, 0.06);
  width: fit-content;
}

.count-number {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.count-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

/* Popup Style */
.maplibregl-popup-content {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-marker);
  font-family: var(--font-family);
  color: var(--text-main);
  min-width: 200px;
}

.maplibregl-popup-close-button {
  font-size: 16px;
  color: var(--text-sub);
  padding: 4px 8px;
  right: 4px;
  top: 4px;
  z-index: 10;
}

.coord-popup-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.coord-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coord-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  margin-left: 4px;
}

.coord-value-btn {
  appearance: none;
  border: none;
  background: #f5f5f5;
  color: var(--text-main);
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.coord-value-btn:hover {
  background: #e0e0e0;
}

.coord-value-btn:active {
  transform: scale(0.98);
  background: #d0d0d0;
}

.coord-value-btn.copied {
  background: var(--text-main);
  color: #fff;
}

.coord-value-btn.copied::after {
  content: "Copied!";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  opacity: 0.8;
}