/* ===== イマココ地番マップ / 地図画面 ===== */
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  overflow: hidden;
}
#map { position: absolute; inset: 0; }

/* --- 上部バー --- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
}
#brand {
  display: flex; align-items: center; gap: 4px;
  text-decoration: none; color: #1a6b46; font-weight: 700; white-space: nowrap;
}
.brand-name { font-size: 15px; }
#searchbox { position: relative; flex: 1; max-width: 420px; display: flex; }
#search-input {
  flex: 1; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px 0 0 6px;
  font-size: 14px; outline: none; min-width: 0;
}
#search-input:focus { border-color: #1a6b46; }
#search-btn {
  border: 1px solid #1a6b46; background: #1a6b46; color: #fff;
  border-radius: 0 6px 6px 0; padding: 0 14px; cursor: pointer; font-size: 14px;
}
#search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin: 4px 0 0; padding: 0; list-style: none;
  background: #fff; border: 1px solid #ddd; border-radius: 6px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#search-results li { padding: 9px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
#search-results li:hover { background: #eef7f2; }

/* --- 地番パネル --- */
#chiban-panel {
  position: absolute; z-index: 15;
  top: 58px; left: 12px;
  background: rgba(255,255,255,.95);
  border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
  padding: 10px 14px; max-width: 320px;
}
#chiban-address { font-size: 11px; color: #666; }
#chiban-address .cross { color: #d33; font-weight: 700; }
#chiban-main { font-size: 20px; font-weight: 700; color: #143; line-height: 1.3; margin-top: 2px; }
#chiban-sub { font-size: 12px; color: #555; }
#copy-btn {
  margin-top: 6px; font-size: 12px; padding: 4px 10px;
  border: 1px solid #1a6b46; color: #1a6b46; background: #fff;
  border-radius: 999px; cursor: pointer;
}
#copy-btn:active { background: #1a6b46; color: #fff; }

/* --- アカウント --- */
#account-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid #ccc; background: #fff; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
#account-btn.signed-in { background: #1a6b46; border-color: #1a6b46; }
#auth-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center;
}
#auth-overlay[hidden] { display: none; }
#auth-modal {
  position: relative; background: #fff; border-radius: 14px;
  padding: 26px 24px; width: min(360px, 90vw); box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
#auth-modal h3 { margin: 0 0 14px; color: #1a6b46; }
#auth-close { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 15px; cursor: pointer; color: #999; }
#auth-modal input {
  width: 100%; box-sizing: border-box; margin-bottom: 10px;
  padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 14px;
}
#auth-msg { font-size: 12px; color: #c33; min-height: 16px; margin-bottom: 6px; }
.auth-primary {
  width: 100%; padding: 11px 0; border: none; border-radius: 999px;
  background: #1a6b46; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.auth-link {
  width: 100%; margin-top: 10px; border: none; background: none;
  color: #1a6b46; font-size: 13px; cursor: pointer; text-decoration: underline;
}
.auth-note { font-size: 11px; color: #999; margin: 12px 0 0; }
#auth-user-email { font-size: 14px; font-weight: 600; }

/* --- 中心十字 --- */
#crosshair {
  position: absolute; z-index: 10; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px; color: #d33; font-weight: 700;
  text-shadow: 0 0 3px #fff, 0 0 6px #fff;
  pointer-events: none;
}

/* --- レイヤー切替 --- */
#layer-ctrl {
  position: absolute; z-index: 15; bottom: 28px; left: 12px;
  display: flex; gap: 6px; align-items: center;
  background: rgba(255,255,255,.94); border-radius: 999px;
  padding: 6px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.base-btn {
  border: 1px solid #ccc; background: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.base-btn.active { background: #1a6b46; border-color: #1a6b46; color: #fff; font-weight: 700; }
.layer-toggle {
  font-size: 12px; display: flex; align-items: center; gap: 4px;
  padding-left: 6px; border-left: 1px solid #ddd; cursor: pointer; user-select: none;
}

/* --- ツールバー --- */
#toolbar {
  position: absolute; z-index: 15; top: 58px; right: 10px;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(255,255,255,.94); border-radius: 12px;
  padding: 8px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
  max-height: calc(100% - 160px); overflow-y: auto;
}
.tool-btn {
  width: 38px; height: 38px; border: 1px solid #ddd; border-radius: 9px;
  background: #fff; font-size: 17px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #444;
}
.tool-btn:hover { background: #eef7f2; }
.tool-btn.active { background: #1a6b46; border-color: #1a6b46; color: #fff; }

/* --- 計測結果 --- */
#measure-readout {
  position: absolute; z-index: 15; bottom: 88px; left: 12px;
  background: rgba(255,255,255,.96); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  padding: 10px 14px; font-size: 13px; max-width: 320px;
}
#measure-readout b { color: #005580; font-size: 15px; }
#measure-readout button {
  margin-left: 8px; font-size: 11px; padding: 3px 10px;
  border: 1px solid #999; background: #fff; border-radius: 999px; cursor: pointer;
}

/* --- ピン一覧パネル --- */
#pin-panel {
  position: absolute; z-index: 25; top: 0; right: 0; bottom: 0;
  width: min(320px, 88vw);
  background: #fff; box-shadow: -3px 0 14px rgba(0,0,0,.25);
  transform: translateX(105%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
#pin-panel.open { transform: translateX(0); }
#pin-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; font-weight: 700; color: #1a6b46; border-bottom: 1px solid #eee;
}
#pin-panel-close { border: none; background: none; font-size: 16px; cursor: pointer; color: #888; }
#pin-panel-note { font-size: 11px; color: #999; margin: 8px 16px 0; }
#pin-list { list-style: none; margin: 8px 0 0; padding: 0 12px 20px; overflow-y: auto; flex: 1; }
#pin-list li { border-bottom: 1px solid #f0f0f0; padding: 10px 6px; }
.pin-memo { font-size: 14px; font-weight: 600; }
.pin-sub { font-size: 11px; color: #888; margin-top: 2px; }
.pin-acts { margin-top: 6px; display: flex; gap: 8px; }
.pin-acts button {
  font-size: 11px; padding: 3px 12px; border-radius: 999px;
  border: 1px solid #1a6b46; color: #1a6b46; background: #fff; cursor: pointer;
}
.pin-acts button[data-act="del"] { border-color: #c33; color: #c33; }
.pin-empty { font-size: 12px; color: #999; padding: 14px 6px; }

/* --- レイヤーパネル・エクスポートメニュー --- */
#layer-btn {
  border: 1px solid #1a6b46; background: #fff; color: #1a6b46; border-radius: 999px;
  padding: 6px 12px; font-size: 12px; cursor: pointer; font-weight: 700; white-space: nowrap;
}
#layer-panel, #export-menu {
  position: absolute; z-index: 25; display: none;
  background: #fff; border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.25);
  padding: 12px 16px; min-width: 220px;
}
#layer-panel.open, #export-menu.open { display: block; }
#layer-panel { bottom: 84px; left: 12px; }
#export-menu { top: 58px; right: 58px; }
#layer-panel label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; padding: 6px 0; cursor: pointer; user-select: none;
}
.menu-title { font-size: 11px; color: #999; font-weight: 700; margin: 6px 0 2px; }
#export-menu button {
  display: block; width: 100%; text-align: left;
  border: none; background: none; font-size: 13px; padding: 8px 6px;
  cursor: pointer; border-radius: 6px;
}
#export-menu button:hover { background: #eef7f2; }

/* --- ズームヒント --- */
#zoom-hint {
  position: absolute; z-index: 15; bottom: 88px; left: 50%; transform: translateX(-50%);
  background: rgba(30,30,30,.8); color: #fff; font-size: 12px;
  padding: 8px 16px; border-radius: 999px; pointer-events: none;
}

/* --- 精度区分の凡例 --- */
#seido-legend {
  position: absolute; z-index: 15; bottom: 84px; right: 60px;
  background: rgba(255,255,255,.95); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2); padding: 8px 12px;
  font-size: 11px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 320px;
}
#seido-legend[hidden] { display: none; }
#seido-legend span { display: inline-flex; align-items: center; gap: 3px; }
#seido-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* --- 共有バナー --- */
#shared-banner {
  position: absolute; z-index: 20; top: 58px; left: 50%; transform: translateX(-50%);
  background: #0057d7; color: #fff; border-radius: 999px;
  padding: 8px 8px 8px 18px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 3px 12px rgba(0,0,0,.3);
  max-width: calc(100vw - 24px);
}
#shared-banner[hidden] { display: none; }
#shared-banner button { border: none; background: rgba(255,255,255,.25); color: #fff; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; }

/* --- ピン共有ボタン --- */
#pin-share-row { padding: 0 16px 4px; }
#pin-share-btn {
  width: 100%; font-size: 12px; padding: 8px 0; border-radius: 999px;
  border: 1px solid #0057d7; color: #0057d7; background: #fff; cursor: pointer;
}

/* --- 比較スライダー用の第2地図 --- */
#map-b { position: absolute; inset: 0; }

/* --- ポップアップ --- */
.maplibregl-popup-content { font-size: 13px; line-height: 1.5; border-radius: 8px; }
.popup-chiban { font-size: 17px; font-weight: 700; color: #143; }
.popup-note { font-size: 10.5px; color: #999; margin-top: 6px; border-top: 1px dashed #eee; padding-top: 4px; }

/* --- 印刷 --- */
#print-header { display: none; }
@media print {
  #topbar, #toolbar, #layer-ctrl, #zoom-hint, #pin-panel, #measure-readout,
  #copy-btn, .maplibregl-control-container { display: none !important; }
  #print-header {
    display: block; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: #fff; font-size: 10px; padding: 4px 8px; border-bottom: 1px solid #ccc;
  }
  #chiban-panel { top: 30px; box-shadow: none; border: 1px solid #ccc; }
  html, body, #app, #map { width: 100%; height: 100%; }
}

@media (max-width: 600px) {
  .brand-name { display: none; }
  #chiban-panel { max-width: calc(100vw - 24px); right: 12px; }
  #chiban-main { font-size: 17px; }
}
