:root {
  --brand: #1E6FE8;
  --brand-dark: #1558bf;
  --free: #2E9E5B;
  --paid: #1E6FE8;
  --unknown: #8a8a8a;
  --bg: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --card-radius: 18px;
  --shadow: 0 6px 24px rgba(0,0,0,0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  background: #e9eef3;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

#map { position: absolute; inset: 0; }

/* ---- 上部フィルターバー ---- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 12px) 10px calc(var(--safe-left) + 12px);
  pointer-events: none;
  z-index: 5;
}
.filters { display: flex; gap: 8px; pointer-events: auto; flex-wrap: wrap; }
.chip {
  min-height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.chip.active { background: var(--brand); color: #fff; }

/* ---- 右下ボタン ---- */
#side-controls {
  position: absolute;
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 5;
}
.fab {
  width: 48px; height: 48px;
  border: none;
  border-radius: 24px;
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { background: #f0f0f2; }

/* ---- インフォカード ---- */
.card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  box-shadow: var(--shadow);
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  z-index: 10;
  padding-bottom: var(--safe-bottom);
  touch-action: none;
}
.card.open { transform: translateY(0); }
.card-handle {
  width: 40px; height: 5px;
  background: #d0d0d5;
  border-radius: 3px;
  margin: 8px auto 4px;
}
.card-body { padding: 6px 18px 18px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
#card-name { font-size: 19px; margin: 6px 0 12px; flex: 1; line-height: 1.3; }
.fav-btn {
  border: none; background: none;
  font-size: 30px; line-height: 1;
  color: #f5b400; padding: 0;
  min-width: 44px; min-height: 44px;
}
.card-meta { margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.card-meta > div { display: flex; }
.card-meta dt { width: 56px; color: var(--muted); font-size: 14px; margin: 0; }
.card-meta dd { margin: 0; font-size: 15px; font-weight: 500; }
.card-nav { display: flex; gap: 10px; }
.navbtn {
  flex: 1;
  text-align: center;
  min-height: 46px;
  line-height: 46px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  border: none;
}
.navbtn:active { background: var(--brand-dark); }
#nav-google { background: #34a853; }
#nav-google:active { background: #2c8c46; }
.card-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }

/* ---- シート(about) ---- */
.sheet {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 20;
  display: none;
  align-items: flex-end;
}
.sheet.open { display: flex; }
.sheet-inner {
  width: 100%;
  background: #fff;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  padding: 20px 18px calc(var(--safe-bottom) + 20px);
  max-height: 82%;
  overflow-y: auto;
}
.sheet-inner h2 { margin: 4px 0 12px; font-size: 20px; }
.sheet-inner h3 { margin: 18px 0 6px; font-size: 15px; }
.sheet-inner p { margin: 8px 0; font-size: 14px; line-height: 1.6; }
.sheet-inner ul { margin: 6px 0; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.muted { color: var(--muted); }
.warn { color: #b23c3c; font-weight: 500; }
#about-close { margin-top: 16px; display: block; }

/* ---- ダウンロードオーバーレイ ---- */
.overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.96);
  z-index: 50;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
}
.overlay.open { display: flex; }
.overlay-inner { text-align: center; max-width: 320px; width: 100%; }
.overlay-icon { margin-bottom: 14px; }
#dl-msg { font-size: 15px; font-weight: 600; margin: 0 0 16px; }
.progress {
  width: 100%; height: 10px;
  background: #e3e8ee;
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  background: var(--brand);
  border-radius: 5px;
  transition: width 0.2s ease;
}
#dl-pct { font-size: 13px; margin: 8px 0 0; }

/* ---- トースト ---- */
.toast {
  position: absolute;
  left: 50%; bottom: calc(var(--safe-bottom) + 30px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(28,28,30,0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* MapLibre attribution 位置調整（下部カードと被らないよう左寄せ小さめ） */
.maplibregl-ctrl-bottom-right { margin-bottom: calc(var(--safe-bottom) + 4px); }
.maplibregl-ctrl-attrib { font-size: 10px; }
