/* ── Screen reader only (SEO用h1など、視覚的には隠す) ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── 免責フッター ── */
#disclaimer {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 910;
  background: rgba(255,255,255,0.97);
  border-top: 1px solid #f3f4f6;
  padding: 4px 12px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  font-size: 10px; color: #6b7280; line-height: 1.5;
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  white-space: nowrap;
}
#disclaimer::-webkit-scrollbar { display: none; }
#disc-town { color: #111; flex-shrink: 0; }
@media (min-width: 601px) {
  /* PC は凡例ボックスに同文言を移したため重複を削除 */
  #disc-town { display: none; }
  #disc-service { font-size: 11px; }
}
#disc-service { flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
#disc-attrib  { margin-left: auto; flex-shrink: 0; display: flex; gap: 8px; }
#disc-sitemap { flex-shrink: 0; display: flex; gap: 8px; }
#disclaimer a { color: #6b7280; text-decoration: none; }
#disclaimer a[href*="reinfolib"] { text-decoration: underline; }

/* ── Attribution ── */
.leaflet-control-attribution { display: none !important; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Hiragino Sans', sans-serif; }

/* ── Header ── */
#hdr {
  position: fixed; top: 0; left: 0; right: 0;
  height: 48px; z-index: 900;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 10px;
}
#logo { font-size: 13px; font-weight: 800; color: #111; letter-spacing: -0.3px; flex-shrink: 0; line-height: 1.2; text-decoration: none; cursor: pointer; }
#logo-sub { font-size: 13px; font-weight: 500; color: #6b7280; letter-spacing: 0; margin: 0; display: inline; }
#hdr-search { display: flex; align-items: center; gap: 0; flex: 1; margin-left: 10px; margin-right: 8px; min-width: 0; border: 1px solid #2F910D; border-radius: 8px; overflow: hidden; background: #fff; }
#search-input {
  flex: 1; padding: 7px 12px; border: none; font-size: 14px; outline: none;
  -webkit-appearance: none; background: transparent; min-width: 0;
}
#search-input:focus { box-shadow: none; }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
#search-go {
  padding: 7px 16px; border-radius: 0;
  background: #2F910D;
  color: white; border: none;
  font-size: 16px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  text-shadow: none;
  min-height: 36px;
}
#search-go:active { background: #236e09; box-shadow: none; }
#search-go:focus-visible { outline: 3px solid #068BF1; outline-offset: 2px; }
#panel-close:focus-visible { outline: 2px solid #068BF1; outline-offset: 2px; }
.panel-fbtn:focus-visible { outline: 2px solid #068BF1; outline-offset: 2px; border-radius: 4px; }

/* ── Map ── */
#map {
  position: fixed;
  top: 48px; left: 0; right: 0;
  bottom: calc(23px + env(safe-area-inset-bottom, 0px));
  z-index: 0;
}

/* ── Loading ── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
#loading-box {
  text-align: center; background: white; border-radius: 20px;
  padding: 32px 44px; box-shadow: 0 8px 40px rgba(0,0,0,0.12); min-width: 200px;
}
#loading-spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 3px solid #f3f4f6; border-top-color: #f97316;
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: #111; font-weight: 600; margin-bottom: 4px; }
#loading-sub { font-size: 12px; color: #9ca3af; min-height: 16px; }

/* パネル内 過去期間データ取得中バナー（Lancers FB④対応） */
.panel-backfill {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 6px;
  padding: 7px 10px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #713f12;
  font-size: 11px;
  line-height: 1.4;
}
.panel-backfill::before {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid #fde68a; border-top-color: #b45309;
  border-radius: 50%; animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* パネル内ローディング（_pendingLoad中の進捗表示） */
.panel-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: #6b7280; font-size: 13px; padding: 24px 16px;
}
.panel-loading::before {
  content: '';
  width: 18px; height: 18px;
  border: 2px solid #e5e7eb; border-top-color: #f97316;
  border-radius: 50%; animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ── 初回モーダル ── */

/* ── Count badge ── */
#count-badge {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 800; background: rgba(17,17,17,0.72);
  color: white; font-size: 12px; font-weight: 600;
  padding: 5px 14px; border-radius: 20px;
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(4px);
  transition: top 0.2s;
}

/* ── マップ凡例 ── */
#map-legend {
  position: fixed;
  left: 10px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 800;
  background: rgba(255,255,255,0.95);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: #111;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  pointer-events: none;
  user-select: none;
}

/* ── Toast ── */
#toast {
  position: fixed; bottom: 112px; left: 50%; transform: translateX(-50%);
  z-index: 9000; background: rgba(239,68,68,0.92);
  color: white; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 20px;
  pointer-events: none; opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── エリアラベル ── */
.area-label {
  display: inline-block;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #4C8F1C;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.06);
  user-select: none;
  -webkit-font-smoothing: antialiased;
  contain: layout style;
}
.area-name { font-weight: 700; font-size: 13px; color: #111; line-height: 1.3; }
.area-stats { color: #374151; margin-top: 2px; font-weight: 500; }

/* 最大ズーム時に一回り大きく */
body.zoom-max .area-label { padding: 8px 14px; }
body.map-zooming .area-label { pointer-events: none; }
body.zoom-max .area-name  { font-size: 16px; }
body.zoom-max .area-stats { font-size: 13px; }

/* ── サイドパネル オーバーレイ ── */
#panel-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: transparent;
  pointer-events: none; /* デスクトップ：マップ操作を妨げない */
}

/* ── サイドパネル ── */
#side-panel {
  position: fixed; top: 48px; left: 0; bottom: 0;
  width: 340px; max-width: 100%;
  z-index: 1001;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
#side-panel.open { transform: translateX(0); }

#panel-filter {
  display: flex; gap: 12px; padding: 7px 14px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}
.panel-filter-label {
  font-size: 11px; font-weight: 600; color: #9ca3af;
  margin-right: 6px;
}
.panel-fbtn {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: #374151;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; user-select: none;
  background: none; border: none; padding: 2px 0;
}
.panel-fbtn-check {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1.5px solid #d1d5db; background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 9px; transition: all 0.15s;
}
.panel-fbtn.active .panel-fbtn-check {
  color: #fff;
}
.panel-fbtn:not(.active) { opacity: 0.45; }

#panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}
#panel-title {
  font-size: 14px; font-weight: 700; color: #111; line-height: 1.4;
  flex: 1; margin-right: 8px;
}
#panel-close {
  background: none; border: none; font-size: 20px; color: #9ca3af;
  cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0;
}
#panel-close:hover { color: #374151; }

#panel-notice {
  font-size: 12px; color: #111; padding: 6px 14px;
  border-bottom: 1px solid #f3f4f6;
}
#panel-list {
  flex: 1; overflow-y: auto; padding: 8px 0 80px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.panel-item {
  padding: 8px 16px;
  border-bottom: 1px solid #f9fafb;
}
.panel-item:last-child { border-bottom: none; }

.panel-item-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}
.panel-badge {
  font-size: 11px; font-weight: 700; color: white;
  padding: 2px 8px; border-radius: 12px; flex-shrink: 0;
}
.panel-price {
  font-size: 16px; font-weight: 800; color: #111;
  display: flex; flex-direction: row; align-items: baseline; gap: 6px;
}
.panel-tsubo {
  font-size: 11px; font-weight: 500; color: #6b7280;
}
.panel-item-detail {
  font-size: 12px; color: #6b7280; line-height: 1.4;
}

#panel-cta {
  display: block;
  padding: 4px 16px 10px;
  font-size: 12px;
  color: #2563eb;
  text-decoration: none;
  flex-shrink: 0;
}
#panel-cta:hover { text-decoration: underline; }

#panel-assess-cta {
  position: fixed;
  bottom: 12px; left: 50%; transform: translateX(-50%);
  width: 230px; max-width: calc(76% - 16px);
  display: none;
  padding: 11px 14px;
  background: #2F910D;
  color: #fff;
  font-size: 13px; font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(47,145,13,0.45), 0 2px 0 #236e09;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  -webkit-tap-highlight-color: transparent;
  z-index: 1002;
}
#panel-assess-cta:hover { background: #236e09; text-decoration: none; }

/* ── モバイル：パネルを下部シートに ── */
@media (max-width: 600px) {
  /* モバイル: ヘッダーは 2 行ロゴ + 検索ボックスが収まる 39px */
  #hdr { height: 39px; }
  /* モバイル: 免責フッター
     1行目: disc-town (全文) | disc-attrib (国土地理院 Leaflet、右寄せ)
     2行目: disc-service (全幅で wrap) の最終行右下にサイトマップを絶対配置 */
  #map { top: 39px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  #disclaimer {
    padding: 4px 10px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 2px;
    white-space: normal;
    overflow-x: visible;
  }
  #disc-town {
    grid-column: 1; grid-row: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    /* 省略記号なし: 通常の画面では全文表示 */
  }
  /* disc-attrib / disc-service / disc-sitemap はユーザー要望で 9px */
  #disc-attrib {
    grid-column: 2; grid-row: 1;
    margin-left: 0;
    justify-self: end;
    font-size: 9px;
  }
  #disc-service {
    grid-column: 1 / -1;   /* 2カラムまたいで全幅 */
    grid-row: 2;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.6;
    font-size: 9px;
  }
  /* disc-service 末尾にファントム空間を確保し、最終行右にサイトマップ+About 位置を空ける */
  #disc-service::after {
    content: "";
    display: inline-block;
    width: 104px;
    height: 1px;
    vertical-align: baseline;
  }
  #disc-sitemap {
    position: absolute;
    right: 10px;
    bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    font-size: 9px;
  }
  #panel-assess-cta {
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 80%;
  }
  #side-panel {
    top: 15%;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: auto;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #side-panel.open { transform: translateY(0); }
  #panel-overlay { background: rgba(0,0,0,0.3); pointer-events: auto; }
  #side-panel.open ~ #panel-overlay { display: block; }

  /* モバイル: 凡例はパネルフィルターのカラーチェックで代替するため非表示 */
  #map-legend { display: none; }

  /* モバイル: タップ領域拡大（最低 40px 目標） */
  #panel-close {
    width: 40px; height: 40px;
    font-size: 24px;
    margin: -8px -8px -8px 0;
    display: flex; align-items: center; justify-content: center;
  }
  .panel-fbtn {
    padding: 8px 4px;
    min-height: 36px;
  }
  .panel-fbtn-check {
    width: 18px; height: 18px; font-size: 11px;
  }
  #logo {
    padding: 4px 6px 4px 0;
  }
  #disc-sitemap a, #disc-attrib a, #disc-service a {
    padding: 2px 4px; margin: -2px -4px;
  }
  #panel-load-more { min-height: 44px; }
}

/* ── パネル「もっと見る」ボタン ─────────────────────────── */
#panel-load-more {
  display: block;
  width: calc(100% - 32px);
  margin: 8px 16px 16px;
  padding: 10px;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  text-align: center;
}
#panel-load-more:hover { background: #e5e7eb; }
