/* モバイルファースト。地図を全画面にして、UIは上バー+フローティングボタン+パネルで重ねる */

:root {
  --brand: #1a6b52;
  --brand-dark: #12503d;
  --bar: #3d434b;      /* ヘッダー。本文より一段濃いグレー */
  --bar-dark: #2c3138;
  --danger: #c93b3b;
  --ink: #222;
  --panel-bg: #fff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

/* .panelなどのdisplay指定がhidden属性(UAのdisplay:none)に勝ってしまうのを防ぐ */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Zen Maru Gothic", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink);
}

#map {
  position: fixed;
  inset: 56px 0 0 0;
  z-index: 0;
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---- 上バー ---- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: var(--bar);
  color: #fff;
  z-index: 1000;
}

/* タイトルは丸ゴシックの太字。手書き風は読みづらいのでやめた */
.topbar h1 {
  flex: 1;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 20px;
  margin: 0 0 0 4px;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.topbar-actions { display: flex; gap: 4px; }

/* トップバーのアイコンボタン */
.bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.bar-btn:active { background: var(--brand-dark); }
.bar-btn .icon { width: 22px; height: 22px; }

.icon-btn {
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 6px 8px;
  cursor: pointer;
  color: inherit;
  border-radius: 8px;
}
.topbar .icon-btn:active { background: var(--bar-dark); }

/* ---- 地域検索 ---- */

.searchbar {
  position: fixed;
  top: 66px;
  left: 12px;
  width: min(360px, calc(100vw - 24px));
  z-index: 950;
}

.searchbar form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 24px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.searchbar .search-icon { color: #888; width: 18px; height: 18px; }

/* 普段は虫眼鏡の丸ボタンだけ(右下のFABと同じ白丸) */
.search-open {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #444;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.searchbar:not(.collapsed) .search-open { display: none; }
.searchbar.collapsed { width: auto; }
.searchbar.collapsed form,
.searchbar.collapsed #search-results { display: none; }
.search-close {
  border: none;
  background: transparent;
  color: #888;
  padding: 0;
  display: flex;
  cursor: pointer;
}
.search-close .icon { width: 18px; height: 18px; }
.search-open .icon { width: 22px; height: 22px; }
.searchbar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px; /* iOSのズーム防止 */
  background: transparent;
  min-width: 0;
}

#search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 40dvh;
  overflow-y: auto;
}
#search-results li {
  padding: 11px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
#search-results li:last-child { border-bottom: none; }
#search-results li:active { background: #f5f5f5; }

/* ---- フローティングボタン ---- */

.fab-stack {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 900;
}

.fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #444;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab .icon { width: 22px; height: 22px; }

.fab-primary { background: var(--brand); color: #fff; }
.fab-primary .icon { width: 22px; height: 22px; }
.fab.active { outline: 3px solid #ffb43a; }

/* ---- パネル ---- */

/* パネルは画面の右半分まで。左半分は常に地図が見えている状態を保つ。 */
.panel {
  position: fixed;
  top: 56px; right: 0;
  width: min(50vw, 340px);
  max-height: calc(100dvh - 56px);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  z-index: 1100;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e5e5;
}
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-head .icon-btn { color: #666; }

.panel-body { padding: 10px 12px; overflow-y: auto; }

.field { margin-bottom: 12px; }
.field-label { display: block; font-size: 12px; color: #666; margin-bottom: 6px; }
.field label { margin-right: 12px; font-size: 14px; }

.hazard-toggle {
  display: block;
  padding: 6px 2px;
  font-size: 12px;
  line-height: 1.3;
}

.note { font-size: 12px; color: #777; line-height: 1.7; }
.note a { color: var(--brand); }

/* ---- ページ(メニュー・一覧・共有・設定は全画面の1ページ) ---- */

.page {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 1300;
  display: flex;
  flex-direction: column;
}
.page-head {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--bar);
  color: #fff;
}
.page-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.page-head .icon-btn { color: #fff; }
.page-body { flex: 1; overflow-y: auto; padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }

.menu-body { padding-top: 8px; }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 8px;
  border: none;
  border-bottom: 1px solid #eee;
  background: none;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.menu-item span { flex: 1; }
.menu-item .icon { width: 22px; height: 22px; color: #555; }
.menu-item .chev { width: 18px; height: 18px; color: #bbb; }

/* ---- とち一覧 ---- */

.sort-chips { margin-bottom: 10px; }
.land-list { list-style: none; margin: 0; padding: 0; }
.land-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  background: #fff;
  touch-action: pan-y;
}
.land-row .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.land-main { flex: 1; min-width: 0; }
.land-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.land-sub { font-size: 12px; color: #777; margin-top: 2px; }
.land-sub .warn { color: var(--danger); font-weight: 700; }
.land-stars { color: #ffb43a; font-size: 13px; flex-shrink: 0; letter-spacing: -1px; }
.grip {
  width: 28px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #c5c5c5;
  flex-shrink: 0;
  touch-action: none; /* 縦スクロールを奪ってドラッグに使う */
  cursor: grab;
}
.grip .icon { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.land-row.dragging {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  opacity: 0.95;
  z-index: 5;
}
.land-row.placeholder { background: #f3f4f6; border-bottom: none; border-radius: 10px; }

/* ---- 地点一覧(基準地点・ゴミ箱で使う旧スタイル) ---- */

.spot-list { list-style: none; margin: 0; padding: 0; }
.spot-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 4px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.spot-list .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.spot-list .spot-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-list .spot-sub { font-size: 12px; color: #888; flex-shrink: 0; }

/* ゴミ箱: 一覧の下に畳んでおく */
.trash-box { margin-top: 12px; border-top: 1px solid #e5e5e5; padding-top: 8px; }
.trash-toggle {
  width: 100%; text-align: left; background: none; border: none;
  font-size: 13px; color: #666; padding: 6px 0; cursor: pointer;
}
.trash-list li { flex-wrap: wrap; }
.trash-list .spot-name { color: #888; }
.trash-list .mini-chip { flex-shrink: 0; }
.wide-btn.danger-text { color: var(--danger); margin-top: 8px; }

/* ---- 共有パネル ---- */

.wide-btn {
  display: block;
  width: 100%;
  padding: 10px 8px;
  margin-bottom: 10px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.wide-btn.ghost { background: #f0f0f0; color: var(--ink); }
.file-label { cursor: pointer; }

/* ---- ボトムシート(地点フォーム) ---- */

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  z-index: 1200;
  max-height: 80dvh;
  overflow-y: auto;
}

.diag-note {
  margin: 6px 0 8px;
}

.carry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: #555;
}

.diag-id { cursor: pointer; }

/* 詳細シート: 地図の上半分を残す高さに抑え、中身はスクロール */
.sheet-detail {
  max-height: 60dvh;
  padding: 16px 22px calc(20px + env(safe-area-inset-bottom)) 22px; /* 左右は余白を残して詰めない */
}
.detail-close {
  position: absolute;
  top: 8px; right: 8px;
}
.sheet-detail .popup { min-width: 0; font-size: 15px; padding-right: 30px; }
.sheet-detail .popup strong { font-size: 18px; }
.sheet-detail .popup-meta { margin: 10px 0 12px; }
.sheet-detail .popup-info { font-size: 15px; line-height: 1.55; }
.sheet-detail .pi-row { margin: 9px 0; gap: 10px; }
.sheet-detail .pi-ic { width: 17px; height: 17px; margin-top: 4px; }
.sheet-detail .popup-memo { font-size: 15px; line-height: 1.7; margin: 12px 0; }
.sheet-detail .popup-links { margin: 14px 0; gap: 16px; font-size: 15px; }
.sheet-detail .popup-photos { margin: 12px 0; }
/* 補足(小さい灰色の注記)は値と同じ行に流さず、次の行に置く */
.sheet-detail .pi-text .hz-note { display: block; margin-top: 2px; font-size: 12px; color: #888; }

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; min-width: 0; }
.field-row input, .field-row select { width: 100%; box-sizing: border-box; }
.sheet select {
  font: inherit; padding: 9px 10px; border: 1px solid #d9d9d9; border-radius: 10px; background: #fff;
}
.zone-warn { color: var(--danger); font-weight: 700; }

/* 登録・編集シートは地図を上に4割残す。接道の方角をピンを見ながら選べるように */
#sheet-spot { max-height: 60dvh; }

.sheet-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
}

/* 許可の戻し方は「順に押す」ものなので番号付きで見せる */
.geo-steps {
  margin: 10px 0;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.8;
}
.geo-steps li { margin-bottom: 2px; }
.geo-diag { font-size: 11px; color: #999; }

.sheet input[type="text"], .sheet textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px; /* iOSのズーム防止 */
  font-family: inherit;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px;
  border-radius: 16px;
  border: 1.5px solid var(--chip-color);
  background: #fff;
  color: var(--chip-color);
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--chip-color); color: #fff; }

.star-row button {
  font-size: 28px;
  border: none;
  background: none;
  color: #ccc;
  cursor: pointer;
  padding: 0 4px;
}
.star-row button.active { color: #ffb43a; }

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.sheet-actions button {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}
.sheet-actions .primary { background: var(--brand); color: #fff; }
.sheet-actions .ghost { background: #f0f0f0; }
.sheet-actions .danger { color: var(--danger); margin-right: auto; }

/* ---- バナー / トースト ---- */

.banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 420px);
  background: #fff8e6;
  border: 1px solid #e8c96a;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  z-index: 1300;
  box-shadow: var(--shadow);
}
.banner span { flex: 1; }
.banner button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.banner button.ghost { background: #eee; color: var(--ink); }

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 13px;
  z-index: 1400;
  white-space: nowrap;
}

/* ---- マーカーとポップアップ ---- */

.spot-pin {
  width: 22px;
  height: 22px;
  background: var(--pin-color);
  border: 2.5px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.4);
}

.popup { min-width: 180px; font-size: 13px; }
.popup strong { font-size: 14px; }
.popup-meta { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.popup-status {
  color: #fff;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
}
.popup-stars { color: #ffb43a; }
.popup-memo { margin: 6px 0; white-space: pre-wrap; color: #444; }
.popup-links { display: flex; gap: 12px; margin: 8px 0; }
.popup-links a { color: var(--brand); font-weight: 600; }
.popup-edit {
  width: 100%;
  padding: 7px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
}

/* ---- 学区 ---- */

.school-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
}

.popup-sub { color: #888; font-size: 11px; }

/* ---- 写真 ---- */

.photo-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.photo-thumb { position: relative; }
.photo-thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.photo-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}

.photo-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1.5px dashed #aaa;
  border-radius: 10px;
  color: #555;
  font-size: 13px;
  cursor: pointer;
}
.photo-add-btn .icon { width: 16px; height: 16px; }

.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
}
/* 横に並べてscroll-snapで1枚ずつ止める。スワイプはブラウザ標準のスクロール */
.pv-track {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pv-track::-webkit-scrollbar { display: none; }
.pv-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always; /* 強く弾いても1枚ずつ */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.pv-slide img {
  max-width: 96vw;
  max-height: 86dvh;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.pv-count {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}
.pv-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 8px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
/* 矢印はマウス操作の端末だけ。スマホはスワイプ */
.pv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}
.pv-prev { left: 8px; }
.pv-next { right: 8px; }
@media (hover: none) {
  .pv-nav { display: none; }
}

.popup-photos {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 6px 0;
}
.popup-photos:empty { display: none; }
.popup-photos img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.popup-listing.ghost { color: #777; font-weight: 500; }
.popup-listing {
  display: block;
  margin: 6px 0;
  color: var(--brand);
  font-weight: 600;
}

.school-label-wrap { pointer-events: none; }
.school-label {
  display: inline-block;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 4px #fff, 0 0 5px #fff;
  opacity: 0.85;
}

/* 出典表記が長くなるとスマホ幅でズームボタンに被るので、左下の操作類を持ち上げる */
.leaflet-bottom.leaflet-left { bottom: 36px; }
.leaflet-control-attribution { font-size: 10px; }

/* 表示パネルのセクション区切り */
.section-divider {
  border-top: 1px solid #eee;
  padding-top: 12px;
}
.section-divider > .field-label { font-weight: 700; color: #444; }
.sub-field { margin-top: 8px; }

.popup-dists {
  margin: 12px 0;
  padding: 10px 12px;
  background: #f4f5f7;
  border-radius: 10px;
  font-size: 14px;
  color: #444;
  line-height: 1.6;
}
/* 名前 | 距離 | 時間 | 車ルート を列で揃える。数字は等幅で桁を合わせる */
.dist-grid {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  column-gap: 14px;
  row-gap: 8px;
  align-items: baseline;
}
.dist-grid .d-name { font-weight: 700; white-space: nowrap; }
.dist-grid .d-km { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.dist-grid .d-time { font-variant-numeric: tabular-nums; color: #666; white-space: nowrap; }
.dist-grid .popup-drive { margin-left: 0; white-space: nowrap; }

/* ---- 登録確認ポップアップ / 土地情報 ---- */

/* タップした場所の登録確認バー(地図の上に重ならない位置に出す) */
.confirm-bar #confirm-text { white-space: pre-line; }
.confirm-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 1150;
}
.confirm-bar span { flex: 1; font-size: 14px; }
.confirm-bar button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}
.confirm-bar .primary { background: var(--brand); color: #fff; }
.confirm-bar .ghost {
  background: #f0f0f0;
  color: #555;
  display: flex;
  align-items: center;
  padding: 10px;
}

/* 登録前の仮マーカー */
.pending-pin {
  width: 22px;
  height: 22px;
  background: #fff;
  border: 3px solid var(--brand);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.4);
  animation: pending-pop 0.18s ease-out;
}
@keyframes pending-pop { from { transform: rotate(-45deg) scale(0.5); } }

.land-info {
  background: #f4f7f6;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.land-info-row {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  line-height: 1.5;
}
.land-info-label {
  flex-shrink: 0;
  width: 58px;
  color: #777;
  font-size: 12px;
  padding-top: 1px;
}
.land-info a { color: var(--brand); }

.popup-info {
  margin: 6px 0;
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}

/* 土地情報の1行 = アイコン + 本文。本文は折り返してもアイコンの右に揃える */
.pi-row { display: flex; align-items: flex-start; gap: 7px; margin: 3px 0; }
.pi-ic { width: 14px; height: 14px; flex-shrink: 0; margin-top: 3px; color: #8a8a8a; stroke-width: 2.2; }
.pi-text { flex: 1; min-width: 0; }

.photo-btn-row { display: flex; gap: 8px; margin-bottom: 8px; }

/* ---- コンパス ---- */

.compass {
  position: fixed;
  top: 66px;
  right: 12px;
  width: 44px;
  height: 44px;
  z-index: 900;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* ---- ハザードチップ / 凡例 ---- */

.hz-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  vertical-align: -1px;
  margin-right: 4px;
  flex-shrink: 0;
}

.hz-item { display: block; padding: 1px 0; }
.hz-item .hz-note { display: block; margin-left: 17px; color: #888; font-size: 11px; }
.hz-safe { color: #1a9e50; font-weight: 600; }

.legend-box { margin-top: 10px; font-size: 12px; }
.legend-box summary { color: var(--brand); cursor: pointer; padding: 4px 0; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.legend-row b { min-width: 62px; font-weight: 600; }
.legend-row span { color: #777; }
.legend-note { display: block; line-height: 1.8; color: #555; }

.road-chip { --chip-color: #555; }

.popup-hz { display: block; margin-top: 2px; }

/* ---- 設定パネル ---- */

#panel-settings input[type="text"], #panel-settings input[type="search"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px; /* iOSのズーム防止のため16pxは維持 */
  margin-bottom: 6px;
  font-family: inherit;
  min-width: 0;
}
.ref-search { display: flex; gap: 8px; }
.ref-search input { flex: 1; margin-bottom: 0; }
.ref-search-btn {
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0 10px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.ref-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid #eee;
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.ref-results li { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.ref-results li:last-child { border-bottom: none; }
.ref-del {
  border: none;
  background: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 6px;
}
.popup-drive { color: var(--brand); font-weight: 600; margin-left: 6px; }

/* 同期状態のバッジ */
.sync-state {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  vertical-align: 2px;
}
.sync-state.on { background: rgba(255, 255, 255, 0.25); }
.sync-state.off { background: #b3541e; }
.sync-state.warn { background: #c77700; }

.diag-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.diag-row span { color: #777; }
.diag-id { font-size: 11px; word-break: break-all; text-align: right; }

/* 基準地点を地図で選んでいる最中の案内 */
.pick-hint {
  position: fixed;
  top: 120px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--brand);
  color: #fff;
  border-radius: 12px;
  font-size: 13px;
  z-index: 960;
  box-shadow: var(--shadow);
}
.pick-hint span { flex: 1; }
.pick-hint button {
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  padding: 2px;
  cursor: pointer;
}

/* ---- 表示パネル(コンパクト・半透明) ---- */
/* 地図の上に重なるので、必要最小限の高さと透過で下の地図を隠さない */

.panel-compact {
  position: fixed;
  top: 62px;
  right: 10px;
  width: fit-content;
  max-width: min(calc(50vw - 10px), 260px);
  padding: 7px 9px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 1100;
}

.compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: #444;
  text-shadow: 0 0 3px #fff;
  margin-bottom: 5px;
}
.compact-head .icon-btn { padding: 2px; color: #666; }
.compact-head .icon-btn .icon { width: 16px; height: 16px; }

.chip-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.mini-chip {
  --chip-on: var(--brand);
  padding: 5px 9px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.55);
  color: #444;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}
.mini-chip.active {
  background: var(--chip-on);
  border-color: var(--chip-on);
  color: #fff;
  font-weight: 600;
}

.panel-compact .legend-box { margin-top: 2px; font-size: 11px; text-shadow: 0 0 3px #fff; }
.panel-compact .legend-box summary { padding: 2px 0; }
.panel-compact .note { font-size: 11px; }
