/* 校内マップ画面（/map/）
   Apple マップに倣った構成：全画面の地図、右上の縦型階数ピッカー、
   下から引き出すシート（PC では左上のカード）。
   レイアウトは HTML/CSS だけで完成させ、JS による並べ替えはしない。 */

@property --sheet-h {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}
@property --offset-peek {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}
@property --offset-mid {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

:root {
  color-scheme: light;
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #8e8e93;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --separator: rgba(60, 60, 67, 0.16);
  --material: rgba(255, 255, 255, 0.78);
  --material-thick: rgba(246, 246, 248, 0.9);
  --card: #ffffff;
  --map-bg: #f3f2ee;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --peek: calc(84px + var(--safe-b));
  --panel-w: 380px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html,
body.map-app {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.map-app {
  background: var(--map-bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
.map-app button > svg,
.map-app a > svg,
.search-field > svg,
.nav-banner-icon > svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Map ---------- */
.map-stage {
  position: fixed;
  inset: 0;
}
.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.map-viewport:active {
  cursor: grabbing;
}
.map-viewport:focus-visible {
  box-shadow: inset 0 0 0 3px var(--blue);
}
#floor-map {
  --map-t: calc(var(--safe-t) + 8px);
  --map-r: var(--safe-r);
  --map-b: var(--peek);
  --map-l: var(--safe-l);
  position: absolute;
  top: var(--map-t);
  left: var(--map-l);
  width: calc(100% - var(--map-l) - var(--map-r));
  height: calc(100% - var(--map-t) - var(--map-b));
  display: block;
  user-select: none;
  -webkit-user-select: none;
}
/* Phones: keep the map centred in the area above the sheet */
@media (max-width: 760px) and (min-height: 501px) {
  #floor-map {
    transition: height 0.38s var(--ease);
  }
  body[data-sheet="mid"] #floor-map,
  body[data-sheet="full"] #floor-map {
    --map-b: 50dvh;
  }
}
#floor-map[hidden] {
  display: none;
}
#floor-map.floor-enter {
  animation: floor-enter 0.28s var(--ease);
}
@keyframes floor-enter {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
}
.map-loading {
  position: absolute;
  inset: 0 0 var(--peek);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.map-loading span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--fill-strong);
  border-top-color: var(--label-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}
.is-ready .map-loading,
.map-viewport:has(#floor-map > *) .map-loading,
.alternate-map .map-loading {
  display: none;
}
.map-toast {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 48px));
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  color: var(--label);
  font-size: 15px;
  text-align: center;
}

/* Route drawing on the floor SVG */
.navigation-halo,
.navigation-line,
.navigation-active {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.navigation-halo {
  stroke: #fff;
  stroke-width: 16;
}
.navigation-line {
  stroke: #8dbdff;
  stroke-width: 10;
}
.navigation-active {
  stroke: var(--blue);
  stroke-width: 11;
}
.navigation-arrow {
  stroke: #fff;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.navigation-pin {
  stroke: #fff;
  stroke-width: 4;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.start-pin {
  fill: var(--blue);
}
.goal-pin {
  fill: var(--red);
}
.stairs-pin {
  fill: #5856d6;
}
.navigation-pin-label {
  fill: #fff;
  font-size: 20px;
  font-weight: 700;
}
.route-origin .room-shape {
  stroke: var(--blue);
  stroke-width: 4;
}
.route-destination .room-shape {
  stroke: var(--red);
  stroke-width: 4;
}
.map-room.is-selected .room-shape {
  stroke: var(--red);
  stroke-width: 5;
}
.query-marker {
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}
.query-marker circle {
  fill: var(--blue);
  stroke: #fff;
  stroke-width: 5;
}
.query-marker-to circle {
  fill: var(--red);
}
.query-marker text {
  fill: #fff;
  font: 700 25px -apple-system, sans-serif;
}

/* 現在地（会場のQRから開いたときの出発地） */
.here-marker {
  pointer-events: none;
}
.here-dot {
  fill: #0a84ff;
  stroke: #fff;
  stroke-width: 6;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}
.here-pulse {
  fill: #0a84ff;
  opacity: 0.25;
  transform-box: fill-box;
  transform-origin: center;
  animation: here-pulse 1.8s ease-out infinite;
}
.here-tag rect {
  fill: #0a84ff;
  stroke: #fff;
  stroke-width: 3;
}
.here-tag text {
  fill: #fff;
  font: 700 20px -apple-system, sans-serif;
}
@keyframes here-pulse {
  from {
    transform: scale(1);
    opacity: 0.35;
  }
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .here-pulse {
    animation: none;
    transform: scale(1.8);
  }
}

/* Campus overview & gym */
.alternate-map-content {
  position: absolute;
  inset: 0;
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
  cursor: auto;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 76px)
    calc(var(--peek) + 24px) calc(var(--safe-l) + 16px);
}
.building-overview {
  display: grid;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}
.building-overview button {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 8px;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s var(--ease);
}
.building-overview button:active {
  transform: scale(0.98);
}
.building-overview strong {
  font-size: 20px;
  text-align: center;
}
.building-overview img {
  width: 100%;
  height: auto;
  display: block;
}
.gym-overview {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 16px;
  background: var(--card);
}
.site-overview {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 16px;
  background: var(--card);
}
/* 学校全体図では右上のボタンを出さず（階も切り替えもいらない）、図を画面の幅いっぱいに出す */
body[data-view="site"] .map-controls {
  display: none;
}
body[data-view="site"] .alternate-map-content {
  padding-right: calc(var(--safe-r) + 10px);
  padding-left: calc(var(--safe-l) + 10px);
}
body[data-view="site"] .site-overview {
  padding: 8px;
}
.site-overview svg {
  display: block;
  width: 100%;
  height: auto;
}
.site-hint {
  margin: 8px 4px 0;
  font-size: 13px;
  color: var(--label-2);
}
.gym-overview img,
.gym-overview svg {
  display: block;
  width: 100%;
  height: auto;
}
.map-error {
  color: var(--red);
  font-size: 14px;
}
/*
  スマホ（縦向き）では、学校全体図・館内図を画面の高さに合わせて大きく出す。横にはみ出す分は横にスクロールして見る
  （開いたときは map-views.js が真ん中を見せる）。--overview-h は図を出せる高さ：上下の余白・カードの余白・下のシートの分を引く
*/
@media (max-width: 760px) and (min-height: 501px) {
  .alternate-map-content {
    --overview-h: calc(100dvh - var(--safe-t) - var(--peek) - 76px);
  }
  .gym-overview,
  .site-overview {
    width: max-content;
    max-width: none;
  }
  .gym-overview svg {
    width: auto;
    height: var(--overview-h);
  }
  /* 学校全体図は下に「建物を押すと…」の一文があるので、その分だけ低くする */
  .site-overview svg {
    width: auto;
    height: calc(var(--overview-h) - 30px);
  }
}

/* ---------- Floating controls ---------- */
.floor-picker,
.control-group,
.query-summary {
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.12);
}
.map-controls {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  right: calc(var(--safe-r) + 12px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition: top 0.3s var(--ease);
}
#floors {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.floor-picker,
.control-group {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
}
.floor-picker button,
.control-group button {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--label);
  cursor: pointer;
}
.floor-picker button + button,
.control-group button + button {
  box-shadow: 0 -0.5px 0 var(--separator);
}
.control-group button {
  color: var(--blue);
}
.control-group svg {
  width: 21px;
  height: 21px;
}
.control-group button[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
}
.control-group button:disabled {
  color: var(--label-3);
  opacity: 0.5;
}

/* 階数ピッカー：Apple マップの屋内表示と同じく上が高い階 */
.floor-picker {
  padding: 4px;
  gap: 2px;
}
.floor-picker button {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--label-2);
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 9px;
  transition:
    background-color 0.2s var(--ease),
    color 0.2s var(--ease);
}
.floor-picker button + button {
  box-shadow: none;
}
.floor-picker small {
  font-size: 11px;
  font-weight: 600;
  margin-left: 1px;
}
.floor-picker button:hover {
  background: var(--fill);
}
.floor-picker button[aria-pressed="true"] {
  background: var(--label);
  color: #fff;
}
/* 経路が通る階・検索結果がある階に印 */
.floor-picker button[data-route]::after,
.floor-picker button[data-hit]::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1.5px var(--card);
}
.floor-picker button[data-hit]:not([data-route])::after {
  background: #ff9500;
}
.alternate-map .floor-picker button[aria-pressed="true"] {
  background: transparent;
  color: var(--label-2);
}
/* 学校全体図では階のボタンを出さない。建物にない階のボタンも出さない */
.floor-picker[hidden],
.floor-picker button[hidden] {
  display: none;
}
/* 体育館の図ではその階（3F）を選択中にする */
.alternate-map .floor-picker.is-gym button[aria-pressed="true"] {
  background: var(--label);
  color: #fff;
}

.zoom-controls {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .zoom-controls {
    display: flex;
  }
}
.alternate-map .zoom-controls,
.alternate-map #reset {
  display: none;
}
.alternate-map .map-controls > .control-group:last-child {
  display: none;
}

/* QR リンクで開いたときの出発地・目的地 */
.query-summary {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: calc(var(--safe-l) + 12px);
  max-width: calc(100% - var(--safe-l) - var(--safe-r) - 92px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.query-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.query-start {
  color: var(--blue);
}
.query-goal {
  color: var(--red);
}
.query-arrow {
  color: var(--label-3);
  flex: none;
}
.query-summary a {
  flex: none;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  text-decoration: none;
}
.has-route .query-summary,
.alternate-map .query-summary {
  display: none;
}

/* ---------- Turn-by-turn banner ---------- */
.nav-banner {
  position: absolute;
  top: calc(var(--safe-t) + 8px);
  left: calc(var(--safe-l) + 8px);
  right: calc(var(--safe-r) + 72px);
  z-index: 5;
  padding: 14px 14px 12px;
  border-radius: 18px;
  background: rgba(28, 28, 30, 0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  animation: banner-in 0.3s var(--ease);
}
@keyframes banner-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}
.map-step-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.nav-banner-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--green);
}
.nav-banner-icon svg {
  transition: transform 0.25s var(--ease);
}
.nav-banner[data-turn="right"] .nav-banner-icon svg {
  transform: rotate(90deg);
}
.nav-banner[data-turn="left"] .nav-banner-icon svg {
  transform: rotate(-90deg);
}
.nav-banner[data-turn="back"] .nav-banner-icon svg {
  transform: rotate(180deg);
}
.nav-banner[data-turn="stairs"] .nav-banner-icon {
  background: #5856d6;
}
.nav-banner[data-turn="arrive"] .nav-banner-icon {
  background: var(--red);
}
.nav-banner-icon svg {
  width: 26px;
  height: 26px;
  stroke-width: 3;
}
#map-step-progress {
  display: block;
  color: rgba(235, 235, 245, 0.6);
  font-size: 13px;
  font-weight: 600;
}
#map-step-instruction {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
}
.nav-banner-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.nav-banner-actions button {
  flex: 1;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.nav-banner-actions button:disabled {
  opacity: 0.35;
}
#map-guidance-close {
  color: #ff6961;
}
.map-nearby {
  margin-top: 12px;
}
.map-nearby h2 {
  margin: 0 0 6px;
  font-size: 13px;
  color: rgba(235, 235, 245, 0.6);
}
#map-nearby-list {
  display: grid;
  gap: 6px;
}
#map-nearby-list button {
  display: grid;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}
#map-nearby-list span {
  font-size: 13px;
  color: rgba(235, 235, 245, 0.6);
}
.map-guidance .query-summary {
  display: none;
}

/* ---------- Sheet ---------- */
.sheet {
  --sheet-h: calc(100dvh - var(--safe-t) - 10px);
  --offset-peek: calc(var(--sheet-h) - var(--peek));
  --offset-mid: calc(var(--sheet-h) - 50dvh);
  --offset: var(--offset-peek);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: var(--sheet-h);
  display: flex;
  flex-direction: column;
  border-radius: 14px 14px 0 0;
  background: var(--material-thick);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 -6px 30px rgba(0, 0, 0, 0.12);
  transform: translateY(var(--drag, var(--offset)));
  transition: transform 0.38s var(--ease);
  touch-action: none;
}
.sheet[data-detent="mid"] {
  --offset: var(--offset-mid);
}
.sheet[data-detent="full"] {
  --offset: 0px;
}
.sheet.is-dragging {
  transition: none;
}
.sheet-grabber {
  flex: none;
  align-self: center;
  width: 64px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  position: relative;
}
.sheet-grabber::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 3px;
  background: rgba(60, 60, 67, 0.3);
}
.sheet-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 calc(var(--safe-r) + 16px) calc(var(--safe-b) + 24px)
    calc(var(--safe-l) + 16px);
}
.sheet[data-detent="peek"] .sheet-scroll {
  overflow: hidden;
}
.sheet-section {
  display: none;
}
.sheet[data-mode="browse"] .sheet-browse,
.sheet[data-mode="place"] .sheet-place,
.sheet[data-mode="route"] .sheet-route {
  display: block;
  animation: section-in 0.25s var(--ease);
}
@keyframes section-in {
  from {
    opacity: 0;
  }
}

/* Search */
.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 2px 0 6px;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label-3);
  cursor: text;
}
.search-field svg {
  flex: none;
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}
.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--label);
  font-size: 17px;
  outline: none;
}
.search-field input::placeholder {
  color: var(--label-3);
}
.search-field:focus-within {
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.35);
}
.round-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}
.round-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.4;
}

/* Lists & cards */
.list-card {
  margin-top: 12px;
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.list-caption {
  margin: 0;
  padding: 10px 16px 4px;
  color: var(--label-2);
  font-size: 13px;
}
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 4px 0;
}
.section-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section-heading span {
  color: var(--label-2);
  font-size: 15px;
}
.room-section .room-list {
  margin-top: 8px;
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.list-card .section-heading {
  margin: 14px 16px 6px;
}
.list-card .section-heading h2 {
  font-size: 17px;
}
.place-list {
  display: flex;
  flex-direction: column;
}
.place-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--label);
  text-align: left;
  cursor: pointer;
  position: relative;
}
.place-row + .place-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 60px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}
.place-row:active,
.place-row:hover,
.place-row[aria-pressed="true"] {
  background: rgba(118, 118, 128, 0.08);
}
.place-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e5ea;
  color: var(--label-2);
  font-size: 12px;
  font-weight: 700;
}
.place-badge.has-event {
  background: #d7efdc;
  color: #2f9e4f;
  font-size: 10px;
}
.place-badge:empty::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aeaeb2;
}
.place-text {
  display: grid;
  min-width: 0;
}
.place-text strong {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-text small {
  color: var(--label-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--label-2);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}
.legend .closed {
  background: repeating-linear-gradient(
    -45deg,
    #f3c34a 0 3px,
    #ffe4a1 3px 6px
  );
}
.legend .outdoor {
  background: #f3eee2;
}
.legend .outside {
  background: #d6dcd9;
}
.side-note {
  margin: 12px 4px 0;
  color: var(--label-2);
  font-size: 13px;
  line-height: 1.5;
}
.link-list {
  display: flex;
  flex-direction: column;
}
.link-list a {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  padding: 0 16px;
  color: var(--blue);
  font-size: 16px;
  text-decoration: none;
}
.link-list a + a::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}
.link-list a span {
  color: var(--label-3);
  font-size: 18px;
}

/* Place card */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 4px;
}
.card-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
#place-location {
  margin: 2px 0 0;
  color: var(--label-2);
  font-size: 15px;
}
.close-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  cursor: pointer;
}
.close-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.6;
}
.place-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.action-primary,
.action-secondary,
.action-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.action-primary {
  flex: 1;
  background: var(--blue);
  color: #fff;
}
.action-primary svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.4;
}
.action-secondary {
  flex: 1;
  background: var(--fill);
  color: var(--blue);
}
.action-primary.wide {
  width: 100%;
  margin-top: 12px;
}
.action-primary:active,
.action-secondary:active,
.action-go:active {
  opacity: 0.75;
}
.place-extra {
  padding: 12px 16px;
}
/* 道案内は補助機能：場所カードの一番下に控えめなリンクとして置く */
.place-route-links {
  margin-top: 12px;
}
.place-route-links a #end-here-label {
  color: inherit;
  font-size: inherit;
}
.place-extra:has(#place-group[hidden]) {
  display: none;
}
#place-group {
  margin: 0;
  font-size: 16px;
}

/* Route card */
.route-form {
  margin-top: 8px;
}
.route-fields {
  position: relative;
  border-radius: 12px;
  background: var(--card);
  padding-right: 52px;
}
.route-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
}
.route-field + .route-field {
  box-shadow: 0 -0.5px 0 var(--separator);
}
.route-field + .route-field::before {
  content: "";
  position: absolute;
  left: 22px;
  top: -10px;
  height: 20px;
  border-left: 2px dotted #c7c7cc;
}
.dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.dot-start {
  background: var(--blue);
}
.dot-goal {
  background: var(--red);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}
.route-field select {
  flex: 1;
  min-width: 0;
  height: 50px;
  border: 0;
  padding: 0 4px 0 0;
  background: transparent;
  color: var(--label);
  font-size: 17px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
}
.route-field select:focus-visible {
  box-shadow: inset 0 -2px 0 var(--blue);
}
.swap-button {
  position: absolute;
  right: 10px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-top: -17px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--blue);
  cursor: pointer;
}
.swap-button svg {
  width: 18px;
  height: 18px;
}
.form-error {
  margin: 10px 4px 0;
  color: var(--red);
  font-size: 14px;
}
/* 経路が出たら、要約と大きな「出発」をカードの一番上に出す */
.route-summary {
  margin-top: 8px;
  padding: 14px 16px 16px;
}
.sheet-route:has(#route-panel[hidden]) .route-summary {
  display: none;
}
.route-summary-text {
  margin-bottom: 12px;
}
.route-summary:has(#route-overview[hidden]) .route-summary-text {
  margin-bottom: 0;
}
/* 結果が出ている間は「経路を検索」を隠す。出発地・目的地を変えると再表示 */
.has-route #map-route-search[data-fresh] #search {
  display: none;
}
#navigation-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
#navigation-floors {
  margin: 2px 0 0;
  color: var(--label-2);
  font-size: 14px;
}
.action-go {
  width: 100%;
  min-height: 54px;
  background: var(--green);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.35);
}
.action-go svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.8;
}
.route-banner {
  padding: 12px 16px;
  font-size: 15px;
}
.route-banner p {
  margin: 0;
}
#step-progress,
#floor-route-status {
  color: var(--label-2);
  font-size: 13px;
}
/* 成功時の手順は下の一覧と案内バナーで見せる */
.has-route #route-banner,
#route-step-controls {
  display: none !important;
}
.route-steps {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.route-steps li {
  counter-increment: step;
  position: relative;
}
.route-steps li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 52px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}
.route-steps button {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.route-steps button::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  font-size: 12px;
  font-weight: 700;
}
.route-steps button[aria-current="step"] {
  background: rgba(0, 122, 255, 0.08);
  font-weight: 600;
}
.route-steps button[aria-current="step"]::before {
  background: var(--blue);
  color: #fff;
}
.route-steps:empty {
  display: none;
}
.route-result .link-list a#swap-route[hidden],
.route-result .link-list a#route-walk-link[hidden] {
  display: none;
}
.route-result .link-list:not(:has(a:not([hidden]))) {
  display: none;
}

/* ---------- Phone landscape ---------- */
@media (max-width: 760px) and (max-height: 500px) {
  .sheet {
    --offset-mid: calc(var(--sheet-h) - 70dvh);
    left: var(--safe-l);
    right: auto;
    width: min(380px, 60vw);
  }
  #floor-map {
    --map-l: calc(var(--safe-l) + min(380px, 60vw));
    --map-b: 0px;
  }
  .map-loading {
    inset: 0;
  }
}

/* ---------- Desktop / tablet: floating panel on the left ---------- */
@media (min-width: 761px) {
  :root {
    --peek: 0px;
  }
  .sheet {
    top: 16px;
    left: 16px;
    right: auto;
    bottom: auto;
    width: var(--panel-w);
    height: auto;
    max-height: calc(100dvh - 32px);
    border-radius: 16px;
    transform: none;
    box-shadow:
      0 0 0 0.5px rgba(0, 0, 0, 0.08),
      0 10px 40px rgba(0, 0, 0, 0.14);
    touch-action: auto;
  }
  .sheet-grabber {
    display: none;
  }
  .sheet-scroll,
  .sheet[data-detent="peek"] .sheet-scroll {
    overflow-y: auto;
    padding: 14px 16px 18px;
  }
  #floor-map {
    --map-t: 16px;
    --map-l: calc(var(--panel-w) + 32px);
    --map-r: 84px;
    --map-b: 16px;
  }
  .alternate-map-content {
    padding: 24px 84px 24px calc(var(--panel-w) + 40px);
  }
  .building-overview {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
  body[data-view="site"] .alternate-map-content {
    padding-right: 24px;
    padding-left: calc(var(--panel-w) + 40px);
  }
  .map-controls {
    top: 16px;
    right: 16px;
  }
  .query-summary {
    top: 16px;
    left: calc(var(--panel-w) + 32px);
    max-width: calc(100% - var(--panel-w) - 130px);
  }
  .nav-banner {
    top: 16px;
    left: calc(var(--panel-w) + 32px);
    right: auto;
    width: min(520px, calc(100% - var(--panel-w) - 130px));
  }
  .map-loading {
    inset: 0 0 0 var(--panel-w);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .map-controls,
  #floor-map.floor-enter,
  .nav-banner,
  .sheet-section {
    transition: none !important;
    animation: none !important;
  }
}

/* Short screens (phones in landscape): compact controls */
@media (max-height: 500px) {
  .floor-picker button {
    height: 32px;
    padding-top: 5px;
  }
  .control-group button {
    height: 36px;
  }
  .map-controls,
  #floors {
    gap: 6px;
  }
  .zoom-controls {
    display: none;
  }
}
