/*
 * いたわりルートマップのスタイル。build_dashboard.py が出力HTMLへ丸ごと差し込む。
 *
 * 並び順（下へ行くほど手前に重なる要素）:
 *   header → layer drawer → map → damage pin → cluster bubble
 *   → popup → legend / controls → responsive
 *
 * 色は原則このファイルで完結させるが、損傷レベルと集約円の色だけは
 * app.jsのLEVEL_BANDS／CLUSTER_BANDSからCSS変数(--level-rgb / --cluster-rgb)で渡される。
 */

:root {
  --header-h: 78px;                           /* ヘッダーの高さ。地図の上端位置もこれに追従する */
  --blue: #087fdd;                            /* 凡例ドットの既定色 */

  /* スマホの画面のフチ（ノッチ・ホームバー）に重ならないための余白。
     対応していない端末では0pxになるので、PCの見た目は変わらない。 */
  --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);

  /* 実際に見えている高さ。スマホはURL欄の出入りで変わるため、
     100vhだと画面下のボタンが隠れることがある。
     dvh対応ブラウザでは自動追従し、さらにapp.jsが実測値で上書きする。 */
  --app-height: 100vh;
}

@supports (height: 100dvh) {
  :root { --app-height: 100dvh; }
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #d7dfe2;
  color: #20272c;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* 端末を横向きにしても文字が勝手に拡大されないようにする */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 地図の端までスワイプしたときに、ページ全体が引っぱられるのを防ぐ */
  overscroll-behavior: none;
}

button { font: inherit; }

/* タップした瞬間に灰色の四角が出るのを抑える（押した感じはCSSで別途出している） */
button, a { -webkit-tap-highlight-color: transparent; }

/* ---------- header ---------- */

.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  /* ノッチのぶんだけ内側に寄せる（非対応端末では従来どおり 0/26px） */
  padding-top: var(--safe-t);
  padding-right: max(26px, var(--safe-r));
  padding-bottom: 0;
  padding-left: max(26px, var(--safe-l));
  color: #fff;
  background:
    radial-gradient(circle at 72% -100%, rgba(223,38,50,.26), transparent 46%),
    linear-gradient(96deg, #090a0b, #151719 64%, #0b0c0d);
  box-shadow: 0 7px 25px rgba(0,0,0,.32);
}

.app-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #cf1f2c 0, #f17723 22%, rgba(241,119,35,0) 52%);
}

.brand-logo-wrap {
  width: 168px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.2), 0 4px 15px rgba(0,0,0,.2);
}

.brand-logo { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.header-rule { width: 1px; height: 34px; background: rgba(255,255,255,.18); }

.service-block {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.service-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.service-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 5px 0 0;
  color: rgba(255,255,255,.68);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .035em;
  white-space: nowrap;
  overflow: hidden;
}
.service-subtitle-event { color: rgba(255,255,255,.86); }
.service-subtitle-separator { color: #f18722; font-weight: 700; }
.service-subtitle-period { min-width: 0; font-variant-numeric: tabular-nums; }

/* ---------- layer drawer ---------- */

/* レイヤーボタンは地図の右上に浮かせる（ズームボタンと同じ操作系の見た目） */
.layer-button {
  position: absolute;
  right: 20px;
  top: 20px;
  z-index: 12;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px;
  color: #fff;
  background: #121416;
  box-shadow: 0 10px 28px rgba(0,0,0,.26);
  cursor: pointer;
  transition: .18s ease;
}

.layer-button svg { width: 20px; height: 20px; }
.layer-button:hover { color: #ff7c33; background: #1a1d20; }
.layer-button[aria-expanded="true"] { border-color: rgba(241,119,35,.75); color: #f18722; }

.layer-scrim {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1100;
  background: rgba(9,11,12,.38);
  animation: scrim-in .18s ease-out;
}

.layer-scrim[hidden] { display: none; }

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.layer-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  width: 280px;
  max-width: 84vw;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: rgba(13,15,17,.98);
  box-shadow: -20px 0 48px rgba(0,0,0,.38);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: drawer-in .2s cubic-bezier(.2,.75,.25,1);
}

@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }

.layer-drawer[hidden] { display: none; }

.layer-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  height: var(--header-h);
  padding: 0 12px 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.layer-drawer-head strong { font-size: 13px; font-weight: 800; letter-spacing: .06em; }

.layer-drawer-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  color: #cfd6d9;
  background: rgba(255,255,255,.05);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: .15s ease;
}

.layer-drawer-close:hover { color: #fff; background: rgba(255,255,255,.12); }

.layer-drawer-body { padding: 8px 14px 14px; }

/* 凡例と同じ「見出し＋項目」の組み立てにそろえる */
.layer-group { padding: 10px 0; }
.layer-group + .layer-group { border-top: 1px solid rgba(255,255,255,.1); }

.layer-group-label {
  padding: 0 12px 6px;
  color: rgba(255,255,255,.55);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

/* レベル別・件数別は「すべての〜」の下位項目なので一段下げる */
.layer-sub { margin-left: 14px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.1); }
.layer-sub-caption { padding: 4px 12px 2px; color: rgba(255,255,255,.45); font-size: 8px; letter-spacing: .03em; }

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  color: #9aa2a8;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: .15s ease;
}

.menu-item:hover { background: rgba(255,255,255,.08); }
.menu-item.is-on { color: #fff; }
/* 見本（凡例と同じ点・ピン・集約円）は消灯時も形が分かるよう、彩度だけ落とす */
.menu-item .legend-dot, .menu-item .legend-pin, .menu-item .legend-cluster { opacity: .3; transition: opacity .15s ease; }
.menu-item.is-on .legend-dot, .menu-item.is-on .legend-pin, .menu-item.is-on .legend-cluster { opacity: 1; }

.menu-check {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  position: relative;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 5px;
  background: transparent;
  transition: .15s ease;
}

.menu-item.is-on .menu-check { border-color: #f17723; background: #f17723; }
.menu-item.is-on .menu-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

/* 一部のレベルだけ表示している親項目は、チェックではなく横棒で表す */
.menu-item.is-partial { color: #fff; }
.menu-item.is-partial .menu-check { border-color: #f17723; background: rgba(241,119,35,.22); }
.menu-item.is-partial .menu-check::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 8px;
  height: 2px;
  border-radius: 1px;
  background: #f17723;
}

/* ---------- map ---------- */

.map-root {
  position: fixed;
  top: var(--header-h);
  right: 0;
  left: 0;
  /* bottom:0 だと、スマホでURL欄が出ている間に下端のボタンが隠れることがある。
     実際に見えている高さ(--app-height)から引いて、確実に収まるようにする。 */
  height: calc(var(--app-height) - var(--header-h));
  overflow: hidden;
  background: #d8dfe2;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-root.dragging { cursor: grabbing; }

.tile-pane, .data-canvas, .marker-pane { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transform-origin: 0 0; }
.tile-pane { z-index: 1; }
.data-canvas { z-index: 2; width: 100%; height: 100%; pointer-events: none; }
.marker-pane { z-index: 3; pointer-events: none; }
/* 詳細パネルは凡例やコントロールより前面に置く */
.popup-pane { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 30; pointer-events: none; }

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  border: 0;
  filter: saturate(.64) contrast(.94) brightness(1.035);
  user-select: none;
  -webkit-user-drag: none;
}

.map-vignette {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(17,25,29,.04), transparent 16%, transparent 84%, rgba(17,25,29,.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}

/* ---------- damage pin ---------- */

.damage-marker {
  position: absolute;
  z-index: 5;
  width: 18px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  pointer-events: auto;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(15,25,31,.34));
  transition: transform .16s ease;
}

.damage-marker svg { width: 100%; height: 100%; display: block; }
.damage-marker:hover, .damage-marker:focus-visible { z-index: 12; outline: 0; transform: translate(-50%, -100%) scale(1.28); }
.damage-marker.critical { width: 21px; height: 28px; filter: drop-shadow(0 4px 8px rgba(191,25,37,.42)); }
.damage-marker.is-active { z-index: 14; transform: translate(-50%, -100%) scale(1.28); }

/* ---------- cluster bubble (引き表示) ---------- */

.damage-cluster {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  transition: transform .18s ease;
}

.damage-cluster::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(var(--cluster-rgb), .24) 0%, rgba(var(--cluster-rgb), .13) 46%, rgba(var(--cluster-rgb), 0) 76%);
  filter: blur(var(--cluster-blur, 10px));
}

.damage-cluster:hover { transform: translate(-50%, -50%) scale(1.08); }
.damage-cluster:focus-visible { outline: 0; }
.damage-cluster:hover .cluster-core { background: rgba(var(--cluster-rgb), .58); }

.cluster-core {
  position: relative;
  width: 37%;
  height: 37%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--cluster-fg, #fff);
  background: rgba(var(--cluster-rgb), .42);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  text-shadow: 0 0 6px rgba(255,255,255,.85), 0 1px 2px rgba(255,255,255,.9);
  transition: background .18s ease;
}

/* ---------- popup ----------
   地図から浮かぶプレミアムな情報パネルとして、奥行き・情報階層・操作感を強調する。 */

:root {
  --popup-accent: #07957c;        /* ★ポップアップの基調色。変える場合はこの3色をそろえる */
  --popup-accent-light: #25c4a2;
  --popup-accent-strong: #05745f;
  --popup-ink: #11251f;           /* 値の文字色 */
  --popup-muted: #70817b;         /* ラベルの文字色 */
  --popup-line: #dfeae6;          /* カードの罫線 */
}

.damage-popup {
  position: absolute;
  z-index: 20;
  /* 2カラムのうち緯度経度側がいちばん幅を要る要素。それが1行に収まり、
     かつ間延びしない幅にしている */
  width: 300px;
  overflow: hidden;
  border: 1px solid rgba(210,226,220,.9);
  border-radius: 18px;
  color: var(--popup-ink);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,251,249,.98));
  box-shadow: 0 30px 80px rgba(12,36,29,.24), 0 8px 24px rgba(12,36,29,.12), inset 0 1px 0 rgba(255,255,255,.96);
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  pointer-events: auto;
  animation: popup-in .2s cubic-bezier(.2,.75,.25,1);
}

/* 上端バーは損傷レベルの色（--level-rgb）にする。押したピン・凡例と同じ色で
   「このパネルがどのレベルの地点のものか」を開いた瞬間に伝える */
.damage-popup::before { content: ""; position: absolute; z-index: 2; top: 0; right: 0; left: 0; height: 4px; background: rgb(var(--level-rgb)); }

@keyframes popup-in { from { opacity: 0; transform: translateY(12px) scale(.975); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* 幅の狭い端末では下からのシート表示に切り替える */
.damage-popup.as-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  top: auto;
  bottom: calc(12px + var(--safe-b));
  width: auto;
  max-height: calc(100vh - 24px - var(--safe-b));
  overflow-y: auto;
  border-radius: 24px;
  box-shadow: 0 26px 72px rgba(8,31,24,.28), 0 8px 24px rgba(8,31,24,.14);
  animation: sheet-in .2s ease-out;
}

@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.popup-head { position: relative; display: flex; align-items: center; gap: 9px; padding: 10px 40px 10px 12px; border-bottom: 1px solid rgba(218,231,226,.82); background: linear-gradient(135deg, rgba(236,250,246,.9), rgba(255,255,255,.94) 58%, rgba(235,246,255,.78)); }
.popup-head-icon { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 29px; height: 29px; border-radius: 10px; color: #fff; background: linear-gradient(145deg, var(--popup-accent-light), var(--popup-accent)); box-shadow: 0 6px 14px rgba(7,149,124,.24), inset 0 1px 0 rgba(255,255,255,.35); }
.popup-head-icon svg { width: 16px; height: 16px; }
.popup-head-title { min-width: 0; overflow: hidden; color: #10231d; font-size: 14px; font-weight: 850; letter-spacing: .015em; text-overflow: ellipsis; white-space: nowrap; }
.popup-close { position: absolute; right: 10px; top: 10px; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 1px solid rgba(214,226,222,.9); border-radius: 50%; color: #5d7069; background: rgba(255,255,255,.82); box-shadow: 0 4px 11px rgba(20,48,39,.09); font-size: 15px; line-height: 1; cursor: pointer; transition: color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease; }
.popup-close:hover { color: #173c31; background: #fff; box-shadow: 0 7px 18px rgba(20,48,39,.15); transform: rotate(90deg); }
.popup-close:focus-visible { outline: 3px solid rgba(7,149,124,.2); outline-offset: 2px; }

.popup-body { display: flex; flex-direction: column; gap: 7px; padding: 9px 10px 10px; background: radial-gradient(circle at 100% 0, rgba(37,196,162,.055), transparent 38%), linear-gradient(180deg, rgba(255,255,255,.35), rgba(243,248,246,.7)); }

.popup-grid { display: grid; gap: 6px; }
/* 緯度経度側（右）の値が長いので、レベル側（左）より少し広めにする */
.popup-grid-2 { grid-template-columns: .85fr 1.15fr; }

/* どの項目も「ラベル→値」だけの同じ組み立て。図は置かず要点だけを並べる。
   枠線は使わず、周りより薄い面だけで区切る（枠の入れ子を1段減らすため） */
.popup-card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 7px 9px 8px; overflow: hidden; border-radius: 9px; background: rgba(17,37,31,.035); }
.popup-card small { display: block; color: var(--popup-muted); font-size: 9px; font-weight: 600; letter-spacing: .03em; }
.popup-card b { display: block; margin-top: 3px; overflow: hidden; color: var(--popup-ink); font-size: 13px; font-weight: 850; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }

/* 損傷検知レベルは、凡例と同じピン形状の色見本＋区分名の色文字で示す。
   面は塗らず、カードの地色にそのまま乗せる */
.popup-level-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; }
.popup-level-badge .legend-pin { width: 10px; height: 13px; }
.popup-level-badge b { margin-top: 0; color: rgb(var(--level-rgb)); font-size: 12px; letter-spacing: -.01em; }

.popup-street-button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 8px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; color: #fff; background: linear-gradient(100deg, var(--popup-accent-strong), var(--popup-accent) 58%, #11aa8c); box-shadow: 0 7px 16px rgba(7,149,124,.22), inset 0 1px 0 rgba(255,255,255,.2); font-size: 11px; font-weight: 850; letter-spacing: .01em; text-decoration: none; transition: box-shadow .18s ease, filter .18s ease, transform .18s ease; }
.popup-street-button:hover { box-shadow: 0 12px 26px rgba(7,149,124,.3), inset 0 1px 0 rgba(255,255,255,.25); filter: saturate(1.08) brightness(1.03); transform: translateY(-1px); }
.popup-street-button:focus-visible { outline: 3px solid rgba(7,149,124,.22); outline-offset: 3px; }
.popup-street-button svg { width: 14px; height: 14px; }
/* ---------- legend / controls ---------- */

.legend {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 10;
  width: 252px;
  padding: 12px 0 3px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  color: #fff;
  /* 地図がうっすら透けつつ文字は読める濃度 */
  background: linear-gradient(180deg, rgba(46,53,59,.62), rgba(26,31,35,.7));
  box-shadow: 0 12px 30px rgba(12,18,22,.3), inset 0 1px 0 rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  backdrop-filter: blur(14px) saturate(1.05);
  text-shadow: 0 1px 2px rgba(10,14,17,.75);
  overflow: hidden; /* 表組みの罫線を角丸の内側できれいに切る */
}

.legend-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 14px;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: left;
  cursor: pointer;
}

.legend-caret { width: 7px; height: 7px; flex: 0 0 auto; border: solid rgba(255,255,255,.75); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg) translate(-2px, -2px); transition: transform .18s ease; }
.legend.is-collapsed .legend-title { margin-bottom: 0; }
.legend.is-collapsed .legend-caret { transform: rotate(-135deg) translate(-2px, -2px); }
.legend.is-collapsed .legend-body { display: none; }

/* 「走行履歴／損傷検知／集約円」を、左に区分ラベル・右に項目一覧を並べた表組みにする */
.legend-group {
  display: grid;
  grid-template-columns: 58px 1fr;
  border-top: 1px solid rgba(255,255,255,.16);
}

.legend-group-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 5px;
  background: rgba(255,255,255,.055);
  border-right: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.92);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .03em;
  text-align: center;
  line-height: 1.3;
}

.legend-group-items { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 9px 14px; }
.legend-caption { margin-bottom: 1px; color: rgba(255,255,255,.58); font-size: 7.5px; letter-spacing: .03em; }
.legend-item { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.97); font-size: 10px; font-weight: 600; }

.legend-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--dot-color, var(--blue)); box-shadow: 0 1px 3px rgba(15,22,27,.4); }

.legend-cluster {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(var(--cluster-rgb), .62) 0%, rgba(var(--cluster-rgb), .34) 44%, rgba(var(--cluster-rgb), 0) 72%);
  filter: blur(.6px);
}

.legend-cluster::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: rgba(var(--cluster-rgb), .92); box-shadow: inset 0 0 0 1px rgba(255,255,255,.32); }

.legend-pin {
  flex: 0 0 auto;
  width: 13px;
  height: 17px;
  background: var(--legend-color);
  -webkit-mask: var(--pin-mask) center / contain no-repeat;
  mask: var(--pin-mask) center / contain no-repeat;
}

:root {
  --pin-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 40'%3E%3Cpath d='M15 0C6.7 0 0 6.7 0 15c0 11.2 15 25 15 25s15-13.8 15-25C30 6.7 23.3 0 15 0zm0 20.6a5.6 5.6 0 1 1 0-11.2 5.6 5.6 0 0 1 0 11.2z'/%3E%3C/svg%3E");
}

.zoom-control {
  position: absolute;
  right: 20px;
  bottom: 24px;
  z-index: 12;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px;
  background: #121416;
  box-shadow: 0 10px 28px rgba(0,0,0,.26);
}

.zoom-button { width: 46px; height: 46px; display: grid; place-items: center; border: 0; color: #fff; background: transparent; font-size: 23px; cursor: pointer; }
.zoom-button + .zoom-button { border-top: 1px solid rgba(255,255,255,.12); }
.zoom-button:hover { color: #ff7c33; background: rgba(255,255,255,.07); }
.zoom-button:disabled { color: #555d62; cursor: default; }
.zoom-label { position: absolute; right: 20px; bottom: 132px; z-index: 11; min-width: 46px; padding: 5px 7px; border-radius: 6px; color: #d0d4d6; background: rgba(13,15,17,.82); font-size: 8px; font-weight: 800; text-align: center; }

.osm-attribution { position: absolute; right: 74px; bottom: 7px; z-index: 9; padding: 3px 6px; color: #59646a; background: rgba(255,255,255,.78); font-size: 8px; }
.osm-attribution a { color: #3e626f; }

/* ---------- responsive ---------- */

/* 指で操作する端末では、押しやすさを優先する。
   マウス操作のPCには適用されないので、見た目は変わらない。 */
@media (pointer: coarse) {
  /* ピンは見た目を変えず、当たり判定だけ外側に広げる */
  .damage-marker::after { content: ""; position: absolute; top: -10px; right: -10px; bottom: -10px; left: -10px; }

  /* 指で押す部品は最低44px角を確保する（Apple・Googleの推奨値）。
     画面幅ではなくタッチ操作かどうかで効かせるので、
     タブレットや横向きスマホ（幅が広い端末）にも適用される。 */
  .layer-button,
  .zoom-button,
  .layer-drawer-close,
  .popup-close,
  .menu-item {
    min-width: 44px;
    min-height: 44px;
  }

  .popup-street-button { min-height: 44px; }

  /* 凡例の開閉は文字が小さいので、行そのものを押せる高さにする */
  .legend-title { min-height: 44px; }
}

@media (max-width: 900px) {
  /* ノッチぶんを足すので、横向きでもヘッダーが欠けない */
  :root { --header-h: calc(68px + var(--safe-t)); }
  .app-header {
    height: var(--header-h);
    gap: 12px;
    padding-right: max(14px, var(--safe-r));
    padding-left: max(14px, var(--safe-l));
  }
  .brand-logo-wrap { width: 132px; height: 39px; flex: 0 0 auto; }
  .header-rule { display: none; }
  .service-title { font-size: 15px; }
  .service-subtitle { gap: 6px; margin-top: 3px; font-size: 10px; }
  .legend { width: 226px; }
}

/* スマートフォン（縦） */
@media (max-width: 600px) {
  :root { --header-h: calc(60px + var(--safe-t)); }
  .app-header {
    gap: 10px;
    padding-right: max(12px, var(--safe-r));
    padding-left: max(12px, var(--safe-l));
  }
  .brand-logo-wrap { width: 100px; height: 31px; padding: 3px 6px; }
  /* ロゴとボタンに挟まれても、タイトルがはみ出さず「…」で収まるようにする */
  .service-title { max-width: calc(100vw - 190px); font-size: 13px; letter-spacing: .02em; }
  .service-subtitle {
    margin-top: 2px;
    font-size: clamp(9px, 2.78vw, 10px);
    letter-spacing: .01em;
    text-align: left;
    white-space: nowrap;
  }
  .menu-item { padding: 13px 12px; font-size: 12px; }
  .layer-button { top: 12px; right: max(12px, var(--safe-r)); }

  .legend {
    left: max(12px, var(--safe-l));
    right: auto;
    bottom: calc(12px + var(--safe-b));
    width: auto;
    min-width: 168px;
    max-width: calc(100vw - 86px - var(--safe-l) - var(--safe-r));
    padding: 10px 0 2px;
  }

  .legend-title { padding: 0 12px; }
  .legend-body { max-height: 46vh; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
  .legend-group { grid-template-columns: 46px 1fr; }
  .legend-group-label { padding: 7px 4px; font-size: 8.5px; }
  .legend-group-items { padding: 7px 12px; gap: 5px; }
  .legend-item { font-size: 9px; }
  .legend.is-collapsed { min-width: 0; }

  .zoom-control { right: max(12px, var(--safe-r)); bottom: calc(12px + var(--safe-b)); }
  .zoom-label { right: max(12px, var(--safe-r)); bottom: calc(106px + var(--safe-b)); min-width: 44px; }
  .osm-attribution {
    right: calc(64px + var(--safe-r));
    bottom: calc(3px + var(--safe-b));
    max-width: calc(100vw - 150px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* シート表示は横幅が広がるだけなので、寸法は通常表示と共通にする */
  .damage-popup.as-sheet {
    left: max(8px, var(--safe-l));
    right: max(8px, var(--safe-r));
    bottom: calc(8px + var(--safe-b));
    max-height: calc(var(--app-height) - var(--header-h) - 24px);
    border-radius: 18px;
  }
  .popup-street-button { min-height: 44px; }
}

/* スマートフォン（横）は高さが足りないので、凡例と余白をさらに詰める */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --header-h: calc(52px + var(--safe-t)); }
  .brand-logo-wrap { width: 100px; height: 30px; }
  .service-title { font-size: 13px; }
  .service-subtitle { margin-top: 2px; font-size: 9px; }
  .legend-body { max-height: 38vh; overflow-y: auto; }
  .zoom-label { bottom: calc(100px + var(--safe-b)); }

  /* 横向きは画面が横に広いので、詳細は右側の縦長カードにして地図を隠さない */
  .damage-popup.as-sheet {
    left: auto;
    right: max(12px, var(--safe-r));
    width: min(320px, 46vw);
    max-height: calc(var(--app-height) - var(--header-h) - 24px);
  }
}

/* 地図が描画される前／描画できないときに出す案内 */
.map-fallback {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  width: calc(100% - 48px);
  max-width: 360px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  color: #fff;
  background: rgba(26,31,35,.86);
  box-shadow: 0 12px 30px rgba(12,18,22,.3);
  transform: translate(-50%, -50%);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

.map-fallback strong { display: block; margin-bottom: 6px; font-size: 12px; }
.map-fallback span { color: rgba(255,255,255,.72); font-size: 10px; }
