:root {
  --navy: #1b2a4a;
  --navy-2: #2c3e66;
  --yellow: #ffff00;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #dfe2e8;
  --text: #1d2330;
  --muted: #6b7385;
  --ok: #2e7d32;
  --warn: #c77700;
  --bad: #c62828;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 8px 16px; }
.err { color: var(--bad); min-height: 1.5em; margin: 8px 0 0; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.btn.go { background: #1565c0; border-color: #1565c0; color: #fff; font-weight: 700; }
.btn.danger { color: var(--bad); border-color: #f0c4c4; }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
input, select, textarea { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 14px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
label.inline { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--text); }
label.inline select { width: auto; }
label.inline input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
label.radio { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--text); font-size: 16px; }
label.radio input { width: 20px; height: 20px; min-height: 0; }

/* チップ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; min-height: 36px; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }

/* ログイン */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--navy); }
.login-box { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { font-size: 20px; border-left: 6px solid var(--yellow); padding-left: 10px; }

/* 全体の枠 */
#app { position: fixed; inset: 0; }
/* iPhoneのホーム画面から開くと、表示できる高さが上の時計の帯の分だけ短くなり、一番下に何も描けない帯が残る（iOSのくせ）。
   そのときは（app.js が ios-gap を付ける）下のメニューのホームバー用の余白をやめ、その帯をメニューと同じ白にして続きに見せる */
html.ios-gap { --safe-b: 0px; }
html.ios-gap, html.ios-gap body { background: #fff; }
.view { position: absolute; inset: 0 0 calc(var(--tab-h) + var(--safe-b)) 0; }
.view.scroll, .scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--navy); color: #fff; }
.bar .muted { color: #c9d2e6; font-size: 14px; margin-left: auto; }
.bar .btn.small { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.card { background: var(--card); margin: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); }

/* タブ */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: #fff; border-top: 1px solid var(--line); z-index: 1000; }
.tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); }
.tabbar svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--navy); font-weight: 700; }
.tabbar button.on svg { filter: drop-shadow(0 2px 0 var(--yellow)); }

/* 地図 */
#map { position: absolute; inset: 0; background: #e8e8e8; }
.map-top { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 60px; z-index: 500; display: flex; gap: 6px; flex-wrap: wrap; }
.map-top .chip { box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.map-fab { position: absolute; right: 12px; bottom: 24px; z-index: 500; display: flex; flex-direction: column; gap: 12px; }
.fab { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.25); display: grid; place-items: center; cursor: pointer; }
.fab.accent { background: var(--navy); color: var(--yellow); }
.leaflet-bottom.leaflet-left { bottom: 6px; }
.map-top { right: 10px; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; z-index: 600; pointer-events: none; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: var(--bad); box-shadow: 0 0 0 1px #fff; }
.crosshair::before { left: 21px; top: 0; width: 2px; height: 44px; }
.crosshair::after { top: 21px; left: 0; height: 2px; width: 44px; }
.pick-bar { position: absolute; left: 8px; right: 8px; bottom: 12px; z-index: 1001;   /* 地図の切り替え（Leafletは1000）より上に */ background: #fff; border-radius: 14px; padding: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.pick-bar p { margin: 0 0 10px; font-size: 14px; }

/* ポスターの印 */
.pin { position: relative; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin span { position: absolute; inset: 0; transform: rotate(45deg); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--t); letter-spacing: -1px; }
.pin.done::after { content: "✓"; position: absolute; right: -8px; top: -8px; transform: rotate(45deg); width: 16px; height: 16px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 11px; display: grid; place-items: center; border: 1.5px solid #fff; }
.pin.sel { outline: 3px solid var(--yellow); outline-offset: 1px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 1px 4px rgba(0,0,0,.4); }
.name-label { background: rgba(255,255,255,.88); border: 0; box-shadow: none; padding: 0 3px; font-size: 11px; font-weight: 700; color: #222; border-radius: 3px; }
.name-label::before { display: none; }

/* 下から出る詳細 */
.sheet { position: absolute; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 1001; max-height: 72%; overflow-y: auto;
  background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.2); padding: 4px 16px 16px; max-height: 64%; }
.sheet-handle { width: 100%; height: 22px; display: grid; place-items: center; cursor: pointer; }
.sheet-handle::before { content: ""; width: 44px; height: 5px; border-radius: 3px; background: #c9cdd6; }
.sheet h2 { font-size: 18px; margin: 4px 0 2px; }
.sheet .addr { color: var(--muted); margin: 0 0 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 700; background: var(--c, #9e9e9e); color: var(--t, #fff); }
.age { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 700; }
.age.ok { background: #e3f2e5; color: var(--ok); }
.age.warn { background: #fff1d6; color: var(--warn); }
.age.bad { background: #fde3e3; color: var(--bad); }
.age.none { background: #eceff3; color: var(--muted); }
.kv { display: grid; grid-template-columns: 6.5em 1fr; gap: 4px 10px; margin: 8px 0 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 12px; }
.big-actions .btn { min-height: 54px; font-size: 17px; }
.sub-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sub-actions .btn { font-size: 14px; padding: 6px 4px; color: var(--text); }
.sub-actions .btn.danger { color: var(--bad); }
.photos { display: flex; gap: 8px; overflow-x: auto; margin: 6px 0 10px; }
.photos img { height: 96px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.events { list-style: none; padding: 0; margin: 6px 0 0; font-size: 14px; }
.events li { padding: 6px 0; border-top: 1px solid var(--line); }
.events .when { color: var(--muted); margin-right: 8px; }
details summary { cursor: pointer; color: var(--navy-2); padding: 8px 0; }

/* 一覧 */
.list { list-style: none; margin: 0; padding: 0 0 16px; }
.list li { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 16px; }
.list li.done { background: #f3f8f3; }
.list .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list .dist { font-weight: 700; color: var(--navy); min-width: 4.5em; }
.list .addr2 { margin: 4px 0 8px; }
.list .acts { display: flex; gap: 8px; }
.list .acts .btn { flex: 1; }
.list .tap { cursor: pointer; }
.route-filters { padding: 10px 16px 4px; background: #fff; border-bottom: 1px solid var(--line); }
#route-cats, #meibo-ranks { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
#route-cats::-webkit-scrollbar, #meibo-ranks::-webkit-scrollbar { display: none; }
#route-cats .chip, #meibo-ranks .chip { flex: none; }
.route-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; }
.meibo-search { padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.person-row .name { font-weight: 700; font-size: 17px; }
.person-row .kana { color: var(--muted); font-size: 13px; margin-left: 6px; }
.tag { display: inline-block; background: #eef1f6; color: #3a4560; border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 2px 4px 0 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* 全画面の詳細 */
.same-place { background: #fff8d6; border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; font-size: 14px; }
.same-place button { margin: 4px 6px 0 0; }
.panel { position: absolute; inset: 0 0 calc(var(--tab-h) + var(--safe-b)) 0; z-index: 1002; background: var(--bg); display: flex; flex-direction: column; }
.panel #panel-body { flex: 1; }
.panel h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.update-bar { position: absolute; left: 12px; right: 12px; top: calc(var(--safe-t, env(safe-area-inset-top)) + 8px); z-index: 2100;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 14px;
  background: #1b2a4a; color: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.25); font-size: 15px; }
.update-bar .btn { background: #FFFF00; color: #1b2a4a; border-color: #FFFF00; flex: none; }
.toast { position: absolute; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 2000;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: 90%; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,.3); }

.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.9); display: grid; place-items: center; }
.lightbox img { max-width: 100%; max-height: 100%; }

@media (min-width: 760px) {
  .sheet { left: auto; right: 12px; bottom: calc(var(--tab-h) + 12px); width: 420px; border-radius: 16px; max-height: calc(100% - var(--tab-h) - 80px); }
  .view.scroll > *, .panel #panel-body > * { max-width: 760px; margin-left: auto; margin-right: auto; }
}
ul.plain.log li { justify-content: flex-start; font-size: 14px; }
ul.plain.log .when { display: inline-block; min-width: 9.5em; color: var(--muted); }
/* 地図の切り替え（左下）。全体の input の大きさが効いて丸が大きくなっていたので戻す */
.leaflet-control-layers label { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 15px; }
.leaflet-control-layers input { width: auto; min-height: 0; margin: 0; padding: 0; }
/* 同じ場所に重なった名簿の人を選ぶ一覧 */
.people-popup .leaflet-popup-content { margin: 8px 10px; min-width: 150px; }
.people-pick-h { font-size: 12px; color: #555; margin-bottom: 4px; }
.people-pick-b { display: block; width: 100%; text-align: left; font-size: 15px; padding: 10px 8px; border: 0; border-top: 1px solid #eee; background: none; color: #1a1a1a; }
.people-pick-b:active { background: #eef3fb; }
