* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; }

.hidden { display: none !important; }
.muted { color: #6b7280; font-size: 12px; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(255,255,255,.94); box-shadow: 0 1px 6px rgba(0,0,0,.15);
}
#topbar .title { font-weight: 700; font-size: 14px; white-space: nowrap; }
.stats { flex: 1; font-size: 11px; color: #374151; line-height: 1.3; }
.chip {
  border: 1px solid #d1d5db; background: #fff; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; white-space: nowrap;
}

.hint {
  position: fixed; top: 54px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: #1f2937; color: #fff; font-size: 13px;
  padding: 8px 14px; border-radius: 999px; max-width: 92vw; text-align: center;
}

#modebar {
  position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 20;
  display: flex; gap: 8px; background: rgba(255,255,255,.96);
  border-radius: 16px; padding: 6px; box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 76px; padding: 8px 10px; font-size: 18px;
  border: none; background: transparent; border-radius: 12px;
}
.mode-btn span { font-size: 11px; color: #374151; }
.mode-btn.active { background: #2563eb; }
.mode-btn.active span { color: #fff; }

.action-bar {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 21;
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  background: rgba(255,255,255,.97); border-radius: 14px; padding: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25); width: min(94vw, 420px);
}
.action-bar .row { display: flex; gap: 8px; flex-wrap: wrap; }
.action-bar button, .action-bar select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid #d1d5db;
  background: #fff; font-size: 14px; flex: 1;
}
button.primary { background: #2563eb; color: #fff; border: none; font-weight: 700; }
button.danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.route-summary { font-size: 13px; background: #eff6ff; border-radius: 10px; padding: 8px 10px; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  max-height: 62vh; overflow-y: auto;
}
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head b { flex: 1; font-size: 15px; }
.close { border: none; background: #f3f4f6; border-radius: 8px; padding: 6px 10px; }

.bld-body .row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.bld-body label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.bld-body input[type="number"] { width: 70px; padding: 8px; font-size: 16px; border: 1px solid #d1d5db; border-radius: 8px; }
.bld-body input[type="text"] { flex: 1; padding: 9px; font-size: 14px; border: 1px solid #d1d5db; border-radius: 8px; }
.bld-body button { padding: 9px 12px; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; font-size: 13px; }
.btn-row button.big { flex: 1; padding: 13px 8px; font-size: 15px; border-radius: 12px; white-space: nowrap; }
.bld-body button.primary { background: #2563eb; color: #fff; border: none; font-weight: 700; }
.bld-body button.danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #e5e7eb; white-space: nowrap; }
.badge.exact { background: #dcfce7; color: #166534; }
.badge.high { background: #dbeafe; color: #1e40af; }
.badge.low { background: #fef3c7; color: #92400e; }

.near-list { display: flex; flex-direction: column; gap: 8px; }
.near-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px;
}
.near-item.close-by { border-color: #2563eb; background: #eff6ff; }
.near-item .info { flex: 1; min-width: 0; }
.near-item .name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-item .sub { font-size: 12px; color: #6b7280; }
.near-item .check {
  border: none; background: #2563eb; color: #fff; font-size: 14px; font-weight: 700;
  border-radius: 10px; padding: 12px 14px; white-space: nowrap;
}

.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
