html, body, #map { height: 100%; margin: 0; }
#map { background: #bcd3e6; }   /* 海の色。タイルが出ない所 (オフライン) では、この上に陸地 (base-map.json) だけ描く */
body { font: 14px/1.4 system-ui, sans-serif; }
[hidden] { display: none !important; }
#ui {
  position: absolute; z-index: 1000; top: calc(10px + env(safe-area-inset-top)); right: 10px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
/* ダブルタップでページが拡大されるのを防ぐ。拡大縮小は地図(Leaflet)だけ */
#ui, #ui *, #lineBar, #lineBar *, #locate, #ciBtn, #mode, #sync, #recallBtn, #pinBtn, #recall, #recall *, #ciSheet, #ciSheet *, #mvBar, #mvBar *, #login, #login *, .leaflet-control, .leaflet-control * { touch-action: manipulation; }
.fab, #panel button { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
#locate {
  position: absolute; z-index: 1000; left: calc(50% - 70px);   /* 画面中央のチェックイン (✅) の左 (右の ● と左右対称) */
  bottom: calc(34px + env(safe-area-inset-bottom));   /* Leaflet の帰属表示と重ならない高さ */
}
/* 長押しで入るコンパスモード (地図が端末の向きに回る)。-webkit-touch-callout: 長押しのメニューを出さない */
#locate { -webkit-touch-callout: none; }
#locate.follow { color: #60a5fa; }   /* 追従中 */
#locate.on { background: #2563eb; color: #fff; }
/* 画面左下のビルド表示 (gyazo-tycoon-viewer の #statbar と同じ役割)。右下は Leaflet の帰属表示 */
#statbar {
  position: absolute; left: 8px; bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 1000;
  max-width: calc(100vw - 16px); padding: 2px 8px; border-radius: 4px; pointer-events: none;
  background: rgba(20, 24, 33, .85); color: #aab; font-size: 11px; line-height: 1.5;
}
#statbar:empty { display: none; }
/* リアルタイム追跡のON/OFF。画面中央のチェックイン (✅) のすぐ右 */
#live {
  position: absolute; z-index: 1000; left: calc(50% + 30px);
  bottom: calc(34px + env(safe-area-inset-bottom));
}
#live.on { background: #dc2626; color: #fff; }
/* 左下: Dawarich との同期 (現在地・追跡・霧/ヒートマップと同じ高さ)。左下のビルド表示 (#statbar) の上 */
#sync {
  position: absolute; z-index: 1000; left: 10px;
  bottom: calc(34px + env(safe-area-inset-bottom));
  font-size: 20px;
}
#sync:disabled { opacity: .7; }
#sync.busy { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 同期の結果など。⚙ を閉じていても見えるように、下のボタンの上に出す */
#toast {
  position: absolute; z-index: 1100; left: 50%; transform: translateX(-50%);
  bottom: calc(134px + var(--lc-h, 0px) + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px);
  padding: 8px 14px; border-radius: 8px; background: rgba(20, 24, 33, .92); color: #eee; font-size: 13px; text-align: center;
  pointer-events: none;
}
/* 右下: 霧 / ヒートマップの切替 (現在地・追跡ボタンと同じ高さ) */
#mode {
  position: absolute; z-index: 1000; right: 10px;
  bottom: calc(34px + env(safe-area-inset-bottom));
  font-size: 20px;
}
#mode.on { background: #ea580c; color: #fff; }
#legend {
  position: absolute; z-index: 1000; right: 10px; bottom: calc(82px + var(--lc-h, 0px) + env(safe-area-inset-bottom)); display: grid; gap: 2px;
  padding: 6px 8px; border-radius: 6px; background: rgba(20, 24, 33, .85); color: #eee; font-size: 12px; pointer-events: none;
}
#legend span { display: flex; align-items: center; gap: 6px; }
#legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.fab {
  width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer; padding: 0;
  background: rgba(20, 24, 33, .85); color: #eee; font-size: 22px; line-height: 40px;
}
#panel {
  background: rgba(20, 24, 33, .85); color: #eee; padding: 10px 12px;
  border-radius: 8px; display: grid; gap: 6px; width: 220px;
}
#panel input[type=range] { width: 100%; }
#panel select { max-width: 100%; }
#panel button { font: inherit; }
#stats { font-size: 12px; opacity: .8; }
.fog-canvas { pointer-events: none; }

#login {
  position: absolute; inset: 0; z-index: 2000; display: grid; place-items: center;
  background: #0b0d12; color: #eee; padding: 16px;
}
#login .card { max-width: 420px; display: grid; gap: 10px; }
#login input, #login button { font: inherit; padding: 10px; border-radius: 6px; border: 1px solid #445; }
#login input { background: #161a24; color: #eee; }
#login button { background: #2563eb; color: #fff; border: 0; }
#login code { word-break: break-all; color: #9cf; }
.err { color: #f88; min-height: 1.4em; margin: 0; }
/* この辺りの履歴: 🕘 (⚙ の下) を押してから地図をタップすると、その周りに来た日の一覧が下から出る */
#recallBtn { font-size: 20px; }   /* ⚙ の下 (#ui の列に並ぶ) */
#recallBtn.on { background: #ea580c; color: #fff; }
#recall {
  position: absolute; z-index: 1001; left: 10px; right: 10px; max-width: 420px;
  bottom: calc(134px + var(--lc-h, 0px) + env(safe-area-inset-bottom)); max-height: 38vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 10px; border-radius: 8px; background: rgba(20, 24, 33, .92); color: #eee; font-size: 13px;
}
#recall[hidden] { display: none; }
#recall button { font: inherit; color: inherit; }
.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#rcClose { border: 0; background: none; font-size: 20px; line-height: 1; padding: 2px 6px; cursor: pointer; }
#rcRadii { display: flex; gap: 6px; margin: 6px 0; }
#rcRadii button { border: 1px solid #556; background: none; border-radius: 12px; padding: 2px 10px; cursor: pointer; }
#rcRadii button[aria-pressed=true] { background: #ea580c; border-color: #ea580c; color: #fff; }
#rcList { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
#rcList button { display: grid; width: 100%; text-align: left; border: 0; background: none; border-radius: 6px; padding: 5px 6px; cursor: pointer; }
#rcList button.sel { background: rgba(234, 88, 12, .35); }
#rcList span { font-size: 12px; opacity: .8; }
#rcList .more { padding: 4px 6px; font-size: 12px; opacity: .7; }

/* チェックインのピン (霧/ヒートマップ・履歴と同じ高さの丸ボタンでオンオフ)。名前は寄ったときだけ (.pin-labels) */
#pinBtn {
  position: absolute; z-index: 1000; right: 58px;
  bottom: calc(34px + env(safe-area-inset-bottom));
  font-size: 20px;
}
#pinBtn.on { background: #7c3aed; color: #fff; }
.pin-label { display: none; background: rgba(20, 24, 33, .88); color: #eee; border: 0; box-shadow: none; font-size: 12px; padding: 1px 6px; }
.pin-label::before { display: none; }
.leaflet-tooltip.pin-label { margin: 0; }   /* 矢印用の余白 (±6px) を消す。置き場所は app.js の layoutPinLabels で計算する */
.pin-labels .pin-label { display: block; }
.me-dot { box-sizing: border-box; border-radius: 50%; background: #2563eb; border: 2px solid #fff; }   /* 現在地。名前・ピンより上 (mePane) */
.pin-labels .pin-label.pin-label-off { visibility: hidden; }   /* 場所が無いときは隠す (大きさは測れるよう display は残す) */
.pin-pop .pin-head { display: flex; align-items: center; gap: 2px; }
.pin-pop strong { overflow-wrap: anywhere; }
.pin-pop ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; font-size: 12px; }
.pin-pop li { display: grid; grid-template-columns: auto 1fr; align-items: start; column-gap: 8px; }   /* 日付の列 | メモの列 (メモは列の中で折り返す) */
.pin-pop ul.editing li { grid-template-columns: auto 1fr auto; }   /* 編集中は右に 鉛筆 | ゴミ箱 */
.pin-pop li.more, .pin-pop li.ed { display: block; }
.pin-pop .when { white-space: nowrap; }
.pin-pop .memo { overflow-wrap: anywhere; }
.pin-pop .acts { display: flex; margin: -3px 0; }
.pin-pop .ic { border: 0; background: none; color: #667; cursor: pointer; padding: 4px; line-height: 0; }
.pin-pop .ic.del { color: #c00; }
.pin-pop .ic svg { width: 16px; height: 16px; display: block; }
.pin-pop .pin-form { display: grid; gap: 4px; margin: 2px 0 4px; }
.pin-pop .pin-form.name { flex: 1; margin: 0; }
.pin-pop .pin-form input { box-sizing: border-box; width: 100%; font: inherit; font-size: 16px; padding: 5px 6px; border: 1px solid #bbb; border-radius: 6px; }   /* 16px: iOS が入力でページを拡大しない */
.pin-pop .btns { display: flex; gap: 6px; }
.pin-pop .btns button { font: inherit; font-size: 12px; padding: 4px 12px; border-radius: 6px; border: 1px solid #bbb; background: none; color: inherit; cursor: pointer; }
.pin-pop .btns .save { background: #2563eb; border-color: #2563eb; color: #fff; }
.pin-pop .edit { margin-top: 6px; border: 0; background: none; color: #667; cursor: pointer; font: inherit; font-size: 12px; padding: 2px 0; }
#rcList .rc-ci { color: #c4b5fd; opacity: 1; }

/* チェックインのシート。画面の下端に置き、ソフトキーボードが出たらその上へ (--kb: キーボードの高さ / --vvh: 見えている高さ。app.js の syncKeyboard が入れる) */
#ciSheet {
  position: absolute; z-index: 1002; left: 10px; right: 10px; max-width: 420px;
  bottom: calc(10px + max(var(--kb, 0px), env(safe-area-inset-bottom)));
  max-height: calc(var(--vvh, 100vh) - 80px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 6px;
  padding: 8px 10px; border-radius: 8px; background: rgba(20, 24, 33, .94); color: #eee; font-size: 13px;
}
#ciSheet[hidden] { display: none; }
/* 場所の位置を直すとき: 画面下にバーを出し、地図のタップで位置を決める */
#mvBar {
  position: absolute; z-index: 1002; left: 10px; right: 10px; max-width: 420px; bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; gap: 6px; padding: 8px 10px; border-radius: 8px; background: rgba(20, 24, 33, .94); color: #eee; font-size: 13px;
}
#mvBar[hidden] { display: none; }
#mvInfo { font-size: 12px; opacity: .85; }
#mvBar .btns { display: flex; gap: 8px; }
#mvBar button { font: inherit; padding: 8px 12px; border-radius: 6px; border: 1px solid #556; background: none; color: inherit; cursor: pointer; }
#mvSave { flex: 1; border: 0 !important; background: #2563eb !important; color: #fff; }
#mvSave:disabled { opacity: .4; cursor: default; }
#ciSheet button, #ciSheet input { font: inherit; }
#ciSheet input { box-sizing: border-box; width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #445; background: #161a24; color: #eee; font-size: 16px; }   /* 16px: iOS が入力でページを拡大しない */
#ciPos { font-size: 12px; opacity: .85; min-height: 1.4em; }
.ci-row, #ciNear { display: flex; flex-wrap: wrap; gap: 6px; }
#ciSheet .ci-row button, #ciNear button { border: 1px solid #556; background: none; color: inherit; border-radius: 12px; padding: 3px 10px; cursor: pointer; }
#ciPick.on { background: #ea580c; border-color: #ea580c; }
.ci-time { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#ciSave { border: 0; border-radius: 6px; padding: 9px; background: #2563eb; color: #fff; cursor: pointer; }
/* チェックイン: 画面下中央 (左に現在地 ◎、右に追跡 ●) */
#ciBtn {
  position: absolute; z-index: 1000; left: 50%; transform: translateX(-50%);
  bottom: calc(34px + env(safe-area-inset-bottom));
  font-size: 20px;
}
/* この日の滞在から選ぶ (時刻欄の日の候補) */
#ciStays summary { cursor: pointer; padding: 2px 0; }
#ciStayList { display: grid; gap: 2px; max-height: 150px; overflow-y: auto;   /* 3件ちょっと (4件目が少し見えて、スクロールできるとわかる) */
  overscroll-behavior: contain; margin-top: 4px; }
#ciStayList button { display: grid; text-align: left; border: 0; background: none; border-radius: 6px; padding: 5px 6px; color: inherit; cursor: pointer; }
#ciStayList button.sel { background: rgba(56, 189, 248, .3); }
#ciStayList button:disabled { opacity: .5; cursor: default; }
#ciStayList span { font-size: 12px; opacity: .85; }
/* 入力中 (キーボードが出ている間): 時刻・滞在候補・位置のボタンを隠し、場所とメモを横に並べて、地図が見える面積を確保する */
#ciSheet.typing .ci-row, #ciSheet.typing .ci-time, #ciSheet.typing #ciStays { display: none; }
#ciSheet.typing { grid-template-columns: 1fr 1fr; }
#ciSheet.typing > * { grid-column: 1 / -1; }
#ciSheet.typing > #ciWhere, #ciSheet.typing > #ciNote { grid-column: auto; }

/* 路線図 (電車・地下鉄・バス): 左上のオンオフ、選んだ路線の駅の吹き出し、画面下のカード */
/* 左上 (ズームの右): 電車・地下鉄・バスのオンオフ。画面を覆いっぱなしだと見づらいので、すぐ切れるよう ⚙ の外に出した。オフの種別は薄く、点を灰色にする */
#lineBar {
  position: absolute; z-index: 1000; top: calc(12px + env(safe-area-inset-top)); left: 54px;
  display: flex; gap: 6px;
}
.ln-pill {
  position: relative; display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px; border-radius: 18px;
  background: rgba(20, 24, 33, .85); color: #eee; font-size: 13px; white-space: nowrap; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.ln-pill input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.ln-pill i { width: 14px; height: 4px; border-radius: 2px; background: var(--c); }
.ln-pill:has(input:not(:checked)) { opacity: .6; }
.ln-pill:has(input:not(:checked)) i { background: #999; }
.ln-pill:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--c); }
.leaflet-tooltip.ln-bubble {
  margin: 0; padding: 2px 6px; font-size: 12px; font-weight: 600; line-height: 1.3; color: #222;
  background: rgba(255, 255, 255, .96); border: 1.5px solid var(--c, #666); border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.leaflet-tooltip.ln-bubble::before { display: none; }   /* Leaflet 標準のしっぽ。下の ::after で丸印を指すしっぽを自前で描く */
.ln-bubble::after {
  content: ''; position: absolute; left: 50%; margin-left: -4px; bottom: -5px; width: 8px; height: 8px;
  background: inherit; border: inherit; border-top: 0; border-left: 0; transform: rotate(45deg);
}
.ln-bubble.leaflet-tooltip-bottom::after { bottom: auto; top: -5px; transform: rotate(225deg); }
.ln-bubble.ln-off { visibility: hidden; }   /* 置き場所が無い吹き出し (寄ると出る) */
#lineCard {
  position: absolute; z-index: 1001; left: 10px; right: 10px; max-width: 420px;
  bottom: calc(82px + env(safe-area-inset-bottom)); padding: 8px 10px 8px 12px; border-radius: 8px;   /* 下のボタン (上端 74px) のすぐ上 */
  background: rgba(20, 24, 33, .92); color: #eee; border-left: 4px solid var(--c, #888); font-size: 13px;
}
#lineCard[hidden] { display: none; }
#lineCard .lc-row { display: flex; align-items: center; gap: 8px; }
#lcCat { flex: none; padding: 1px 8px; border-radius: 10px; background: rgba(255, 255, 255, .18); font-size: 11px; }
#lcName { flex: 1; font-size: 15px; overflow-wrap: anywhere; }
#lcClose { border: 0; background: none; color: inherit; font-size: 20px; line-height: 1; padding: 2px 6px; cursor: pointer; }
#lcSub { margin-top: 2px; font-size: 12px; opacity: .75; }
#lcPick { margin-top: 6px; width: 100%; max-width: 100%; font: inherit; }
