:root {
  --ink: #111827;
  --sub: #6b7280;
  --line: #eceef2;
  --surface: #ffffff;
  --brand: #ff6b4a;
  --brand-ink: #ffffff;
  --ev: #3b6cf6;
  --ev-soft: #e8eefe;
  --level: #0b7a4f;
  --level-soft: #e3f6ee;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --shadow: 0 8px 28px rgba(17, 24, 39, .12), 0 1px 3px rgba(17, 24, 39, .08);
  --dock-h: 0px;
  --top-h: 170px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink); background: #eef0f3; overflow: hidden;
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  font-size: 15px; line-height: 1.6; letter-spacing: .01em;
}
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

#map { position: fixed; inset: 0; }

/* 上部：ロゴ・検索・？・駅チップ（スマホは地図の上に浮かせる） */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 8px;
  grid-template-areas: "brand search help" "chips chips chips";
  padding: calc(env(safe-area-inset-top) + 8px) 10px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { grid-area: brand; display: flex; align-items: center; gap: 8px; }
.logo { flex: none; width: 36px; height: 36px; border-radius: 11px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(17,24,39,.2); }
.logo svg { width: 22px; height: 22px; stroke-width: 2.2; }
.title { display: none; font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.search {
  grid-area: search; min-width: 0;
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
}
.search .ico { width: 20px; height: 20px; color: var(--sub); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; border-radius: 6px; font: inherit; font-size: 16px; background: transparent; color: var(--ink); }
.search input::placeholder { color: #9ca3af; }
.help {
  grid-area: help; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink);
  font-size: 20px; font-weight: 800; line-height: 1; box-shadow: var(--shadow); display: grid; place-items: center;
}
.chips {
  grid-area: chips; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -10px; padding: 0 10px 4px;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; min-height: 44px; font-size: 15px; font-weight: 500; padding: 0 18px; border-radius: 999px;
  border: 0; background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(17,24,39,.18);
}
.chips button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* 現在地ボタン・一覧ボタン */
.fab {
  position: fixed; right: 14px; bottom: calc(var(--dock-h) + 40px); z-index: 12;
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ev);
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.fab svg { width: 24px; height: 24px; }
.fab .dot { fill: currentColor; stroke: none; }
.fab.busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(59,108,246,.15), var(--shadow); } }
.listbtn {
  position: fixed; left: 14px; bottom: calc(var(--dock-h) + 40px); z-index: 12;
  display: inline-flex; align-items: center; gap: 6px; height: 52px; padding: 0 20px; border-radius: 26px; border: 0;
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; box-shadow: var(--shadow);
}
.listbtn svg { width: 20px; height: 20px; }
body.welcome-on.dockmode .fab { display: none; }

/* 一覧（PC＝左の枠、スマホ＝全画面のシート） */
.sheet {
  position: fixed; left: 0; top: 0; bottom: 0; width: 420px; z-index: 20; padding-top: var(--top-h);
  background: var(--surface); box-shadow: 4px 0 24px rgba(17,24,39,.08);
  display: flex; flex-direction: column;
}
.grip { display: none; }
.sheet-head { padding: 6px 20px 8px; }
.sheet-head h1 { margin: 0; font-size: 19px; font-weight: 800; }
.status { margin: 2px 0 0; color: var(--sub); font-size: 13px; }
.scroll { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.list { list-style: none; margin: 0; padding: 4px 14px 0; }

.card {
  position: relative; display: flex; gap: 14px; padding: 16px; margin-bottom: 10px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
}
.card.active, .kcard.active { border-color: transparent; box-shadow: 0 0 0 2px var(--ev), var(--shadow); }
.icon { position: relative; flex: none; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; }
.icon .num { position: absolute; top: -6px; left: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; line-height: 20px; text-align: center; border: 2px solid #fff; }
.icon svg { width: 24px; height: 24px; }
.card.elevator .icon, .kcard.elevator .icon { background: var(--ev-soft); color: var(--ev); }
.card.level .icon, .kcard.level .icon { background: var(--level-soft); color: var(--level); }
.body { min-width: 0; flex: 1; }
.meta { margin: 0; font-size: 13px; color: var(--sub); padding-right: 56px; overflow-wrap: anywhere; }
.name { margin: 2px 0 0; font-size: 16px; font-weight: 700; line-height: 1.45; }
.to { display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 0; font-weight: 700; font-size: 14px; }
.to svg { width: 16px; height: 16px; flex: none; }
.card.elevator .to { color: var(--ev); }
.card.level .to { color: var(--level); }
.summary { margin: 6px 0 0; color: #4b5563; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags:empty { display: none; }
.tag { font-size: 13px; font-weight: 500; padding: 3px 10px; border-radius: 14px; background: #f3f4f6; color: #374151; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.acts a, .gowrap a.go {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 14px; font-weight: 500;
  min-height: 44px; padding: 0 14px; border-radius: 12px; background: #f3f4f6; color: var(--ink);
}
.gowrap { margin-top: 12px; }
.gowrap .gonote { margin: 6px 0 0; }
.gowrap + .acts { margin-top: 8px; }
.gowrap[hidden] { display: none; }
.acts a.go, .gowrap a.go { background: var(--ink); color: #fff; font-weight: 700; }
.gowrap a.go svg { width: 16px; height: 16px; }
.acts a[hidden] { display: none; }
.dist { position: absolute; top: 14px; right: 16px; font-size: 13px; font-weight: 700; color: var(--ink); }
.dist:empty { display: none; }

.foot { padding: 4px 20px calc(env(safe-area-inset-bottom) + 16px); font-size: 13px; color: var(--sub); }
.foot p { margin: 6px 0; }
.foot a { color: var(--sub); }

/* 地図のピン */
.pin-wrap { width: 34px; height: 40px; display: grid; place-items: start center; cursor: pointer; }
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2.5px solid #fff; box-shadow: 0 3px 10px rgba(17,24,39,.3);
  cursor: pointer; transition: transform .15s;
}
.pin b { transform: rotate(45deg); color: #fff; font: 800 13px/1 "Noto Sans JP", system-ui, sans-serif; }
.pin.elevator { background: var(--ev); }
.pin.level { background: var(--level); }
.pin.estimated { opacity: .8; border-style: dashed; }
.pin.active { transform: rotate(-45deg) scale(1.25); }
.me { width: 18px; height: 18px; border-radius: 50%; background: var(--ev); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(59,108,246,.2); }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 0; }

/* メッセージ・初回の案内・入口カードの置き場（スマホは下に固定） */
.dock { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; pointer-events: none; padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
.dock > * { pointer-events: auto; }
.msgbox { margin: 0; }
.msgbox.in-dock { max-height: 52vh; overflow-y: auto; margin: 0 10px 8px; padding: 12px 14px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.msgbox.in-dock .notice { margin-top: 0; }
.msgtext { margin: 0; font-size: 14px; color: var(--ink); }
.msgbox:not(.in-dock) .msgtext { display: none; }
.msgtext:empty { display: none; }

/* 初回の案内 */
.welcome {
  position: relative; margin: 0 10px; padding: 18px 18px 14px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow);
  max-height: min(68vh, 560px); overflow-y: auto; overscroll-behavior: contain;
}
.w-close { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--sub); font-size: 26px; line-height: 1; }
.w-brand { display: flex; align-items: center; gap: 10px; margin: 0; padding-right: 40px; font-size: 14px; color: var(--sub); }
.w-brand .logo { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
.w-brand .logo svg { width: 20px; height: 20px; }
.w-brand b { color: var(--ink); font-size: 16px; font-weight: 800; }
.w-title { margin: 8px 0 0; font-size: 21px; line-height: 1.4; font-weight: 800; }
.w-lead { margin: 6px 0 0; font-size: 14px; color: #374151; }
.w-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ws-t b.plain { font-weight: 400; }
.ws-t b { white-space: nowrap; }
.w-steps li { display: flex; align-items: center; gap: 12px; font-size: 14px; line-height: 1.5; }
.ws-ic { position: relative; flex: none; width: 40px; height: 40px; border-radius: 12px; background: #f3f4f6; color: var(--ink); display: grid; place-items: center; }
.ws-ic svg { width: 22px; height: 22px; }
.ws-ic i { position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; border: 2px solid #fff; font: 800 13px/16px "Noto Sans JP", system-ui, sans-serif; text-align: center; font-style: normal; }
.c-ev { color: var(--ev); }
.c-lv { color: var(--level); }
.w-primary {
  display: block; width: 100%; min-height: 54px; margin-top: 14px; border: 0; border-radius: 16px;
  background: var(--brand); color: #fff; font-size: 17px; font-weight: 800; box-shadow: 0 6px 16px rgba(255,107,74,.35);
}
.w-chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.w-chips button { min-height: 44px; padding: 0 20px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 700; }
.w-cover { margin: 10px 0 0; font-size: 13px; color: var(--sub); }

/* スマホ用の小さな入口カード */
.carousel {
  position: relative; display: flex; align-items: flex-start; gap: 10px; list-style: none; margin: 0; padding: 6px 7vw 8px;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding: 0 7vw; scrollbar-width: none; overscroll-behavior-x: contain;
}
.carousel::-webkit-scrollbar { display: none; }
.kcard, .kinfo {
  flex: none; width: min(86vw, 360px); max-height: min(46vh, calc(100dvh - var(--top-h) - 96px)); scroll-snap-align: center; scroll-snap-stop: always;
  border-radius: 20px; background: var(--surface); box-shadow: 0 4px 16px rgba(17,24,39,.18), 0 1px 3px rgba(17,24,39,.1);
}
.kcard { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 10px 12px 10px; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; transition: box-shadow .15s; }
.k-top { position: relative; display: flex; gap: 10px; min-height: 0; }
.k-main { min-width: 0; flex: 1; padding-right: 0; }
.k-meta { margin: 0; font-size: 13px; line-height: 1.35; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 48px; }
.k-name { margin: 1px 0 0; font-size: 15px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.k-to { display: flex; align-items: center; gap: 4px; margin: 2px 0 0; font-size: 14px; font-weight: 700; line-height: 1.35; }
.k-to svg { width: 16px; height: 16px; flex: none; }
.k-to span { min-width: 0; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.kcard.elevator .k-to { color: var(--ev); }
.kcard.level .k-to { color: var(--level); }
.kcard .dist { top: 0; right: 0; }
.k-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 0; }
.k-tags .tag { flex: 0 1 auto; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; border-radius: 12px; line-height: 1.45; }
.k-sum { margin: 0; font-size: 13px; line-height: 1.45; color: #4b5563; overflow-wrap: anywhere; }
.k-sum[hidden] { display: none; }
.k-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.k-acts a, .k-acts button.detail {
  flex: 1 1 auto; min-width: 0; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; padding: 0 8px;
  border-radius: 12px; background: #f3f4f6; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.k-acts a.go, .k-acts a.primary { background: var(--ink); color: #fff; font-weight: 700; flex-grow: 1.4; }
.k-acts button.detail { background: var(--ev-soft); color: var(--ev); font-weight: 700; }
.k-acts a svg { width: 16px; height: 16px; flex: none; }
.k-acts a[hidden] { display: none; }
.kinfo {
  list-style: none; margin: 0; padding: 12px 14px; background: var(--warn-soft); color: #7c3a07; font-size: 14px; line-height: 1.55;
  overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
.kinfo p { margin: 0; }
.kinfo a { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--ink); color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; }

/* PC（900px以上）：左に一覧、右に地図 */
@media (min-width: 900px) {
  .top {
    right: auto; width: 420px; z-index: 30; padding: 16px 16px 6px;
    grid-template-columns: 1fr auto; grid-template-areas: "brand help" "search search" "chips chips"; gap: 10px;
  }
  .title { display: inline; }
  .search { height: 50px; border-radius: 16px; padding: 0 16px; box-shadow: 0 1px 6px rgba(17,24,39,.14); border: 1px solid var(--line); }
  .help { box-shadow: 0 1px 6px rgba(17,24,39,.14); border: 1px solid var(--line); }
  .chips { margin: 0 -16px; padding: 0 16px 4px; }
  .chips button { box-shadow: none; border: 1px solid var(--line); }
  .chips button[aria-pressed="true"] { border-color: var(--ink); }
  #map { left: 420px; }
  .fab { bottom: 32px; right: 20px; }
  .welcome { margin: 4px 14px 14px; box-shadow: none; border: 1px solid var(--line); max-height: none; overflow: visible; background: #fffaf7; }
  .w-title { font-size: 20px; }
}

/* スマホ：地図を広く使う（下の案内＋一覧シート） */
body.dockmode .dock { display: block; }
body.dockmode .sheet {
  top: 0; left: 0; right: 0; width: 100%; height: 100vh; height: 100dvh; padding-top: 0; z-index: 40; box-shadow: none;
  transform: translateY(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s;
}
body.dockmode.listopen .sheet { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
body.dockmode .grip {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 56px; padding: calc(env(safe-area-inset-top) + 6px) 16px 6px;
  border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 700; text-align: left;
}
body.dockmode .grip svg { width: 22px; height: 22px; }
body.dockmode .welcome .w-title { font-size: 20px; }

/* 追加：注記・確認用の表示 */
.note { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: #92400e; }
.note[hidden], .gonote[hidden] { display: none; }
.gonote { margin: 6px 0 0; font-size: 13px; color: var(--sub); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.choices[hidden], .notice[hidden] { display: none; }
.choices button {
  min-height: 44px; font-size: 15px; font-weight: 500; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.notice { margin: 6px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.notice a { color: var(--warn); font-weight: 700; }
.card.info, li.info {
  list-style: none; margin-bottom: 10px; padding: 14px 16px; border-radius: 18px; background: var(--warn-soft); color: #7c3a07; font-size: 14px;
}
li.info p { margin: 0 0 8px; }
li.info a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--ink); color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; }

/* このサービスについて */
.about { border: 0; padding: 0; width: min(560px, 100%); max-width: 100%; max-height: 90vh; max-height: 90dvh; border-radius: 24px 24px 0 0; margin: auto auto 0; color: var(--ink); background: var(--surface); box-shadow: 0 -8px 40px rgba(17,24,39,.25); }
.about::backdrop { background: rgba(17,24,39,.45); }
.about-in { padding: 0 20px calc(env(safe-area-inset-bottom) + 20px); }
.about-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 6px; background: var(--surface); }
.about-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.x { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #f3f4f6; color: var(--ink); font-size: 24px; line-height: 1; }
.about h3 { margin: 16px 0 4px; font-size: 15px; font-weight: 800; }
.about p { margin: 4px 0; font-size: 14px; }
.about ul { margin: 4px 0; padding-left: 20px; font-size: 14px; }
.about .cautions li { margin: 4px 0; }
.about .foot { padding: 0; }
.legend { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 12px; }
.lg { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800; border: 2px solid #fff; box-shadow: 0 1px 6px rgba(17,24,39,.35); margin: 0 4px; }
.lg-ev { background: var(--ev); }
.lg-lv { background: var(--level); }
.lg-es { opacity: .8; border-style: dashed; }
.lg-no { background: #9ca3af; }
.lg-me { background: var(--ev); border-radius: 50%; width: 18px; height: 18px; margin: 0 9px; box-shadow: 0 0 0 5px rgba(59,108,246,.2); }
.w-reset { margin-top: 12px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 14px; }
@media (min-width: 900px) {
  .about { border-radius: 24px; margin: auto; }
}

/* キーボード操作の見える枠 */
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.search:focus-within { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.search input:focus-visible { outline: 0; }
.card:focus-visible, .kcard:focus-visible, .kinfo:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.pin-wrap:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; border-radius: 12px; }

/* 地図を出せないとき：一覧と検索だけで使う */
body.listonly #map { display: none; }
body.listonly { overflow: auto; }
body.listonly .top, body.listonly .sheet { left: 0; right: 0; width: 100%; max-width: 720px; margin: 0 auto; }
body.listonly .sheet { top: 0; height: auto; bottom: 0; box-shadow: none; }
body.listonly .top { z-index: 30; background: linear-gradient(#fff 80%, rgba(255,255,255,0)); }
body.listonly .chips button { box-shadow: 0 1px 3px rgba(17,24,39,.12); }
body.listonly .fab { bottom: 20px; right: 14px; }
.gowrap a.go[hidden] { display: none; }

.k-caveat { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--sub); }
.kcard:has(a.go[hidden]) .k-caveat { display: none; }

/* ヒント・たたみ・一覧の強調 */
.khint { margin: 0 auto 2px; width: fit-content; max-width: calc(100% - 20px); padding: 4px 12px; border-radius: 999px; background: rgba(17,24,39,.86); color: #fff; font-size: 13px; line-height: 1.4; text-align: center; box-shadow: 0 2px 8px rgba(17,24,39,.25); }
.carousel.folded { display: none; }
.choices { max-height: min(30vh, 220px); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 2px; }
body.dockmode .msgbox.in-dock { max-height: min(52vh, calc(100dvh - var(--top-h) - 24px)); }
body.dockmode .welcome { max-height: min(68vh, 560px, calc(100dvh - var(--top-h) - 24px)); }
.card.flash { animation: flash 2.2s ease-out 1; border-color: var(--ev); box-shadow: 0 0 0 2px var(--ev), var(--shadow); }
@keyframes flash { 0% { background: #dbe6ff; } 100% { background: var(--surface); } }
.kcard > * { flex-shrink: 0; }
.tag { border-radius: 14px; }

.nobr { display: inline-block; }
.welcome { container-type: inline-size; }
body.dockmode .welcome .w-title, .welcome .w-title { font-size: clamp(14px, 5.8cqi, 20px); }
