/* =========================================================
   高速あと何分 — 第一段階スタイル
   緑基調・高速道路標識風 / スマホ縦画面前提
   ========================================================= */

:root {
  --header-bg: #17613f;
  --header-bg-2: #134d31;
  --card-green-1: #1d6642;
  --card-green-2: #123f28;
  --badge-green: #1e7146;
  --num-green: #176b41;
  --accent-green: #2f8a5c;
  --bg: #ebeeec;
  --card-bg: #ffffff;
  --ink: #1f2422;
  --muted: #6f7d75;
  --line: #e6eae7;
  --note-bg: #e7f1ea;

  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-card: 0 6px 18px rgba(20, 60, 40, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* 画面上部から下に引っ張った時のpull-to-refreshを抑止（PHASE6_13）。
     内部スクロールは .scroll 側で通常どおり動く */
  overscroll-behavior-y: none;
}

body {
  background: #d7dcd8;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- アプリ枠（スマホ幅・中央寄せ） ---- */
.app {
  position: relative; /* 目標地点モーダルのオーバーレイ基準 */
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior-y: none; /* pull-to-refresh抑止（PHASE6_13） */
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   1. ヘッダー
   ========================================================= */
.header {
  flex: 0 0 auto;
  background: linear-gradient(160deg, var(--header-bg), var(--header-bg-2));
  color: #fff;
  padding: max(14px, env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 26px 26px;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 54px;
  color: #fff;
  display: block;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.brand-text { flex: 1 1 auto; min-width: 0; }

.brand-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.92;
}

.header-settings {
  position: relative; /* タップ判定領域(::after)の基準（PHASE9_09） */
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 7px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.95;
  -webkit-tap-highlight-color: transparent;
}
.header-settings svg { width: 100%; height: 100%; display: block; }

/* タップ判定領域だけを64×64へ広げる（PHASE9_09）。
   アイコンの見た目（38×38・padding 7px）と位置・レイアウトは変えず、
   透明な余白を上下左右に13pxずつ足す。右はヘッダー内側（画面端まで7px）、
   上はヘッダーのpadding内に収まりステータスバー/safe-areaには掛からない。
   左13pxが重なるヘッダー副題は非操作要素のため干渉しない。 */
.header-settings::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
}

/* =========================================================
   スクロール領域
   ========================================================= */
.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 一覧の端で外側(html/body)へスクロールが連鎖してpull-to-refreshが
     誘発されるのを防ぐ。内部の通常スクロールはそのまま（PHASE6_13） */
  overscroll-behavior-y: contain;
  /* 速度バー撤去（PHASE7_04）により、下部safe-area余白はスクロール領域側で確保する */
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  margin-top: -10px;
}

.error-box {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #fdecea;
  color: #9b1c1c;
  font-size: 14px;
  font-weight: 600;
}

/* =========================================================
   2. 現在走行情報カード
   ========================================================= */
.info-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.info-top {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.info-left {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.route-row { display: flex; align-items: center; gap: 10px; }

.route-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 4px 8px;
  background: var(--badge-green);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--badge-green);
}

.route-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.direction-row { display: flex; align-items: center; gap: 8px; }

.dir-arrow {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--badge-green);
  border-radius: 50%;
  color: var(--badge-green);
  padding: 3px;
}
.dir-arrow svg { width: 100%; height: 100%; }

.direction-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.info-divider {
  flex: 0 0 auto;
  width: 1px;
  background: var(--line);
  align-self: stretch;
}

.info-right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.info-stat { display: flex; align-items: center; gap: 8px; }

.info-ic {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--badge-green);
  display: inline-flex;
}
.info-ic svg { width: 100%; height: 100%; }

.info-text {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.info-text b {
  font-size: 18px;
  color: var(--ink);
  font-weight: 800;
}
.info-unit { font-size: 12px; }

#infoGps { color: var(--badge-green); }

.info-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  padding: 9px 12px;
  background: var(--note-bg);
  border-radius: 12px;
  color: #2c6045;
  font-size: 14px;
  font-weight: 700;
}
.note-ic { width: 18px; height: 18px; display: inline-flex; }
.note-ic svg { width: 100%; height: 100%; }

/* ---- 進行方向の切り替え（PHASE7_01・下り/上り） ---- */
.direction-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
.direction-control-label { font-size: 14px; font-weight: 700; color: #2c6045; }
.direction-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: #e2e7e3;
  border-radius: 999px;
}
.direction-tab {
  border: none;
  border-radius: 999px;
  padding: 6px 18px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, color 0.15s;
}
.direction-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(20, 80, 50, 0.25);
}

/* GPSの役割の小さな注記（PHASE7_01。PHASE9_08でGPS速度ブロックの中へ移動）。
   長い文でも折り返して収まるよう nowrap は付けない（320px幅対応） */
.gps-role-note {
  margin: 6px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- GPS連動トグル（PHASE6_03。PHASE9_08で見出し行＋説明文の2段構成に変更） ---- */
.gps-control {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
/* 見出し「GPS速度」とトグルの1行（従来 .gps-control が持っていた横並び指定） */
.gps-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.gps-control-label { font-size: 14px; font-weight: 700; color: #2c6045; }
.gps-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.gps-toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #c7d2cb;
  transition: background 0.2s;
}
.gps-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.gps-toggle.is-on { color: var(--num-green); }
.gps-toggle.is-on .gps-toggle-track { background: var(--accent-green); }
.gps-toggle.is-on .gps-toggle-thumb { transform: translateX(18px); }

/* GPS状態の色分け（#infoGpsのdata属性で切替） */
#infoGps[data-gps="off"] { color: var(--muted); }
#infoGps[data-gps="acquiring"] { color: #b8860b; }
#infoGps[data-gps="live"] { color: var(--badge-green); }
#infoGps[data-gps="unavailable"] { color: #b4552d; }
#infoGps[data-gps="denied"] { color: #b4552d; }

/* ---- 現在位置の更新（PHASE9_00・簡潔表示。内部状態や時刻は表示しない） ---- */
.pos-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
.pos-now { font-size: 13px; font-weight: 700; color: var(--muted); }
.pos-now b { font-size: 15px; font-weight: 800; color: var(--num-green); }
.pos-now-unit { margin-left: 2px; }
.pos-update-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--accent-green);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 6px rgba(20, 80, 50, 0.30);
  transition: transform 0.08s ease, background-color 0.08s ease,
    box-shadow 0.08s ease, opacity 0.08s ease;
}
/* 押下中: 少し沈む＋色を濃く＋影を弱める（押した実感を出す） */
.pos-update-btn:active {
  background: var(--num-green);
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 1px 2px rgba(20, 80, 50, 0.22);
}
/* 更新中...の一時disabled表示（JS側で短時間だけ付与） */
.pos-update-btn:disabled,
.pos-update-btn.is-updating {
  background: var(--num-green);
  opacity: 0.7;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* ---- 現在位置の手動補正（PHASE6_05） ---- */
.pos-correct-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
.pos-correct-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.pos-correct-btn {
  flex: 0 0 auto;
  border: 1px solid var(--accent-green);
  border-radius: 999px;
  cursor: pointer;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
  color: var(--num-green);
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.pos-correct-btn:active { background: var(--note-bg); }

/* 保存位置から再開した旨の控えめな表示（PHASE6_06） */
.pos-restore-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 2px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-green);
}
.pos-restore-note[hidden] { display: none; }
.pos-restore-ic { width: 14px; height: 14px; flex: 0 0 auto; display: inline-flex; }
.pos-restore-ic svg { width: 100%; height: 100%; }

/* =========================================================
   2-2. まもなくJCT案内帯（PHASE8_02・C案）
   進行方向の次のJCTが10km以内のときだけ表示する控えめな帯。
   大カードより目立たせない（白地・緑の縦アクセントのみ・アニメなし）。
   ========================================================= */
.jct-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border-left: 5px solid var(--accent-green);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.jct-notice[hidden] { display: none; }

.jct-notice-main {
  flex: 1 1 auto;
  min-width: 0; /* 長いJCT名でも折り返せるように */
}
.jct-notice-soon {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  overflow-wrap: anywhere; /* 長いJCT名の折り返し崩れ防止 */
}
.jct-notice-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}
.jct-notice-branch {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-green);
  overflow-wrap: anywhere;
}
.jct-notice-dist {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.jct-notice-unit {
  font-size: 11px;
  margin-left: 1px;
}

/* =========================================================
   3. 次の施設 大型カード
   ========================================================= */
.next-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--card-green-1), var(--card-green-2));
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px rgba(16, 56, 36, 0.28);
  padding: 16px 20px 20px;
  color: #fff;
  margin-bottom: 18px;
  /* 横スワイプ（補助操作）で表示範囲を切替。縦スクロールはネイティブに委ねる */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* スワイプ時の控えめな入場アニメ（下＋方向側から上がってきて定位置に収まる） */
.next-card--enter-next { animation: nextCardEnterNext 0.22s ease-out; }
.next-card--enter-prev { animation: nextCardEnterPrev 0.22s ease-out; }

@keyframes nextCardEnterNext {
  from { transform: translate(10px, 6px) scale(0.985); opacity: 0.55; }
  to { transform: none; opacity: 1; }
}
@keyframes nextCardEnterPrev {
  from { transform: translate(-10px, 6px) scale(0.985); opacity: 0.55; }
  to { transform: none; opacity: 1; }
}

/* 動きに敏感なユーザー向けにアニメを無効化 */
@media (prefers-reduced-motion: reduce) {
  .next-card--enter-next,
  .next-card--enter-prev { animation: none; }
}

.next-tag {
  display: inline-block;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* PHASE9_03: 施設名とGSブランドを1行のflexで横並びにしていたため、狭い画面で
   施設名だけがCJKのmin-content（＝1文字幅）まで潰され縦書き状に割れていた。
   （GSチップ側はwhite-space:nowrapで最も広いチップ幅より縮まず、
     不足分がすべて施設名へ押し付けられていた）
   Gridの2行構成に変え、GSブランドを施設名と同じ列の真下へ送る。
   アイコン列は2行にまたがるので、GSブランドがアイコンの下へ回り込まない。
   row-gapは0にし、チップ行との間隔は .next-head .fac-fuels のmargin-topで作る。
   こうするとGSなしの施設（.fac-fuels自体が生成されない）で余分な行間が出ない */
.next-head {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon name"
    "icon fuels";
  align-items: center;
  column-gap: 12px;
  row-gap: 0;
  z-index: 1;
}

.next-icon {
  grid-area: icon;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  height: 50px;
  padding: 0 10px;
  border: 3px solid #fff;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 800;
}

/* 大型カードのIC番号つきアイコン（一覧バッジと同じ考え方） */
.next-icon--num {
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}
.next-icon--num .next-icon-num { font-size: 24px; }
.next-icon--num .next-icon-type { font-size: 11px; opacity: 0.9; }

.next-name {
  grid-area: name;
  min-width: 0; /* name列（1fr）を超えて広がらせない。長い名前は自然に折り返す */
  font-size: 44px;
  font-weight: 800;
  line-height: 1.0;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* PHASE9_03: z-index:0の「配置済み要素」は、同じスタッキングコンテキスト内の
   非配置インライン要素（施設名・GSチップ）より後に描画されるため、
   従来は装飾SVGが文字の上に薄く重なっていた。負の値にして文字の下へ回す */
.next-deco {
  position: absolute;
  top: -6px;
  right: -8px;
  width: 150px;
  height: 70px;
  z-index: -1;
  opacity: 0.9;
  pointer-events: none;
}

.next-line {
  height: 2px;
  background: rgba(255, 255, 255, 0.28);
  margin: 14px 0 12px;
  border-radius: 2px;
}

.next-stats {
  display: flex;
  align-items: flex-end;
}

.next-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}
.next-stat.time { padding-left: 18px; }

.next-stat .lbl {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.92;
  margin-bottom: -2px;
}

/* PHASE9_03: 残距離・所要時間の大きな数字。
   「あと」列の実幅は (画面幅 − 約82px) ÷ 2 で画面幅に比例して連続的に変わるのに対し、
   従来は56px固定＋段階的な縮小だったため、ブレークポイントのすぐ上の幅
   （375px・480pxなど）で3桁＋小数の距離（203.5km等）が縦区切り線を越え、
   右隣の所要時間・到着時刻に接触していた。

   実測値（Chrome headless + CDP）から、この書体・字送りでは
     「203.5km」の描画幅 ≒ 3.58 × フォントサイズ
     「あと」列の実幅     ≒ 0.469 × 画面幅 − 30.9
   （320px→列119.0px、480px→列194.0px）
   となるため、列幅に収まる最大のサイズを clamp() で連続的に決める。
   こうすると320〜480pxのどの幅でも「必要以上に小さくせず、はみ出さない」
   （上限54pxは480px以上で頭打ち。従来の56pxは480pxでも203.5kmが収まらなかった） */
.next-stat .big {
  font-size: clamp(32px, calc(13vw - 9px), 54px);
  font-weight: 800;
  line-height: 1.0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
/* 単位（km・分）は数字に対する比率を保つ（従来の 24/56 ≒ 0.43em） */
.next-stat .big .unit {
  font-size: 0.43em;
  font-weight: 700;
  margin-left: 2px;
}

.next-stat .arrive {
  margin-top: 6px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  opacity: 0.95;
}
/* 大型カードも時刻部分を一段大きく */
.next-stat .arrive .arrive-time {
  font-size: 23px;
  font-weight: 800;
}

.next-vline {
  flex: 0 0 auto;
  width: 2px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.28);
  margin: 4px 0;
}

.next-empty {
  font-size: 16px;
  font-weight: 700;
  padding: 8px 0 4px;
}

/* =========================================================
   4. この先の施設一覧
   ========================================================= */
.list-heading {
  margin: 4px 4px 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.facility-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* PHASE9_03: 従来は「バッジ46px / 名前1fr / 距離auto / 時間auto / 矢印14px」の
   1行構成だった。固定部だけで約329px使うため、施設名に残る幅は
   「画面幅 − 329px」しかなく、360px端末では約31px（＝1文字＋…）まで潰れていた。
   さらに .fac-fuels（nowrapのチップ）が名前列を溢れて距離欄へ重なっていた。

   これを2段構成へ変更する。上段に施設名＋GSブランド、下段に距離・時間を置くと
   施設名に使える幅が「画面幅 − 144px」へ広がり、収録済みの最長名
   「西那須野塩原IC」(8文字)まで320px幅で全表示できる。
   GSブランドは上段（名前と同じ行）に入るため、距離欄・時間欄とは行が分かれ、
   重なりが構造的に発生しない。
   端末幅の推定に依存しないよう、メディアクエリを使わず全画面幅で2段にする
   （.appはmax-width:480pxのため、480pxでも1行構成では8文字名が入らない）。 */
.fac-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto 14px;
  grid-template-areas:
    "badge name name chevron"
    "badge dist time chevron";
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 14px;
}

/* バッジと矢印は2段全体にまたがり、align-items:centerで縦中央に置かれる */
.fac-badge { grid-area: badge; }
.fac-main { grid-area: name; }
.fac-dist { grid-area: dist; }
.fac-time { grid-area: time; justify-self: end; }
.fac-chevron { grid-area: chevron; }

.fac-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: var(--badge-green);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
}

/* IC番号つきバッジ: 番号を主表示し、種別（IC）を小さく添える。
   icNumberが無い施設は従来の種別のみ表示にフォールバック */
.fac-badge--num {
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}
/* PHASE9_11b: 一覧バッジのIC番号が折り返す問題の修正。
   .fac-badge の内寸は 46px 固定（padding無し）。この書体・19px/weight800での実測幅は
     38-0 = 47.09px（46pxを超えるためハイフン直後で改行 →「38-」「0」に割れていた）
     49-2 = 46.31px（同様に超過。JCTは一覧非表示だが将来の保険）
     30-2 = 45.92px（余裕0.08pxで実質限界）
     40-1 = 43.92px / 42-1 = 43.02px（従来から1行で収まっていた）
   まず white-space: nowrap で折り返しを止め、はみ出し分は letter-spacing の
   最小調整（-0.04em）で吸収する。font-size 19px と .fac-badge の 46px 幅は変更しない
   （バッジ幅を広げると全一覧行のレイアウトに波及するため）。
   調整後の実測幅は 38-0 = 44.06px / 49-2 = 43.27px / 30-2 = 42.89px で、
   従来の 40-1（43.92px）と同等かそれ以下に収まる。1〜2桁番号への影響は 1.5px 程度。 */
.fac-badge--num .fac-badge-num {
  font-size: 19px;
  white-space: nowrap;
  letter-spacing: -0.04em;
}
.fac-badge--num .fac-badge-type { font-size: 10px; opacity: 0.9; }

.fac-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fac-dist, .fac-time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}
.fac-time { align-items: flex-end; }

.fac-dist .lbl, .fac-time .lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.fac-dist .val, .fac-time .val {
  font-size: 26px;
  font-weight: 800;
  color: var(--num-green);
}
.fac-dist .val .unit, .fac-time .val .unit {
  font-size: 14px;
  font-weight: 700;
  margin-left: 1px;
}

.fac-time .arrive {
  margin-top: 3px;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
/* 時刻部分（例: 19:17）だけ大きく濃くして視認性を上げる */
.fac-time .arrive .arrive-time {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.fac-chevron {
  width: 14px;
  height: 22px;
  color: #b9c2bc;
  display: inline-flex;
}
.fac-chevron svg { width: 100%; height: 100%; }

.list-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.list-end {
  margin: 6px 2px 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #9aa8a0;
  letter-spacing: 0.02em;
}

/* =========================================================
   5. 速度モード切替
   （PHASE7_04でトップ画面下部の固定バーから設定シート内へ移動。
     固定バー用の背景・上罫線・上向き影・safe-area余白は解除）
   ========================================================= */
.speed-bar {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.speed-label {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.speed-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.speed-tabs::-webkit-scrollbar { display: none; }

.speed-tab {
  flex: 1 0 auto;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 8px;
  border: none;
  border-radius: 12px;
  background: #f1f4f2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.speed-tab .tab-ic { width: 20px; height: 20px; display: inline-flex; }
.speed-tab .tab-ic svg { width: 100%; height: 100%; }

.speed-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 3px 10px rgba(20, 80, 50, 0.3);
}

/* 任意速度ボタン（PHASE9_08）。速度ボタン列とは別の独立した1行にして、
   320px幅でも既存6ボタンのサイズに影響を与えないようにする */
.custom-speed-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: #f1f4f2;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, color 0.15s;
}
.custom-speed-btn .custom-speed-btn-ic { width: 18px; height: 18px; display: inline-flex; flex: 0 0 auto; }
.custom-speed-btn .custom-speed-btn-ic svg { width: 100%; height: 100%; }
.custom-speed-btn-value { font-size: 15px; font-weight: 800; }
.custom-speed-btn-value[hidden] { display: none; }
.custom-speed-btn.is-selected {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 3px 10px rgba(20, 80, 50, 0.3);
}

/* 狭い画面では6個のボタンが窮屈にならないよう最小幅と左右paddingを少し詰める。
   収まりきらない場合は従来どおり横スクロール（overflow-x: auto）で対応 */
@media (max-width: 420px) {
  .speed-tab {
    min-width: 54px;
    padding: 9px 6px;
  }

  /* 狭い画面では道路情報カードの左右2列（路線名/方向・現在位置/速度/GPS）が
     圧迫され折り返し過多や重なりが起きるため、上下2段に切り替える。
     align-items: stretch（.info-topの既存指定）はそのまま活き、
     .info-left / .info-right ともカード全幅を使えるようになる */
  .info-top {
    flex-direction: column;
    gap: 10px;
  }
  .info-divider {
    width: 100%;
    height: 1px;
  }
}

/* =========================================================
   表示範囲モード
   ========================================================= */
.range-bar { margin: 2px 0 16px; }

.range-label {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.range-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e2e7e3;
  border-radius: 14px;
}

.range-tab {
  flex: 1 1 0;
  min-width: 0; /* 長い目標名でも3等分レイアウトを崩さない */
  padding: 10px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.15s, color 0.15s;
}

.range-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--badge-green), var(--card-green-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(20, 80, 50, 0.25);
}

.range-tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* =========================================================
   長距離見通しカード
   ========================================================= */
.overview-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border-left: 6px solid var(--badge-green);
  padding: 15px 18px;
  margin-bottom: 18px;
}
.overview-card[hidden] { display: none; }

.ov-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--badge-green);
  margin-bottom: 4px;
}

.ov-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.ov-stats {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.ov-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}

.ov-stat .lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.ov-stat .val {
  font-size: 26px;
  font-weight: 800;
  color: var(--num-green);
}
.ov-stat .val .unit {
  font-size: 14px;
  font-weight: 700;
  margin-left: 1px;
}
.ov-stat .val.arrive {
  font-size: 18px;
  color: var(--ink);
}

.ov-pending,
.ov-passed {
  margin: 2px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

/* PHASE9_03: 数字サイズ自体は上の clamp() で連続的に決まるため、
   ここでは時間列の左paddingだけを狭い画面で詰め、到着時刻の逃げ幅を確保する */
@media (max-width: 430px) {
  .next-stat.time { padding-left: 12px; }
}

@media (max-width: 360px) {
  .brand-title { font-size: 30px; }
  .next-name { font-size: 38px; }
  .next-stat.time { padding-left: 8px; }
  .fac-name { font-size: 19px; }
  .ov-stats { gap: 12px; }
  .ov-stat .val { font-size: 22px; }
}

/* 320px級の最狭画面。ここまで来ると施設名も1段小さくしないと
   5文字のSA名（那須高原SA等）が2行に割れる */
@media (max-width: 340px) {
  .next-name { font-size: 30px; }
}

/* 給油ブランド 小チップ（SA/PAのfuelBrands表示） */
.fac-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fac-fuels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fuel-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--badge-green);
  background: #eaf3ee;
  border: 1px solid #cfe3d8;
  border-radius: 6px;
  white-space: nowrap;
}
/* PHASE9_03: 大型カードのGSブランドは施設名の右横ではなく、施設名と同じ列の真下。
   margin-topでチップ行の間隔を作るため、GSなしの施設では余白が一切増えない */
.next-head .fac-fuels {
  grid-area: fuels;
  min-width: 0;
  margin-left: 0;
  margin-top: 8px;
}

/* =========================================================
   スマートICバッジ（PHASE9_11・B案「バッジのみ」）
   GSブランドチップ（.fac-fuels）ともJCT方面案内（.jct-notice-branch）とも
   別要素で、常に独立した1行として出す。
   ・アイコンは付けない。文言は「スマートIC」のみ
   ・white-space: nowrap で横折り返しさせない
   ・width/min-width の固定値を持たない（文字数なりの幅）
   ・施設名やGSブランドと同じ行を奪わないので、320〜430pxで横の競合が起きない
   ・.next-head / .fac-item のGrid定義はいずれも変更していない
   ========================================================= */
.smartic-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start; /* .fac-main（flex column）で横いっぱいに伸びないように */
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  background: var(--badge-green);
  border: 1px solid var(--badge-green);
  border-radius: 999px;
  white-space: nowrap;
}

/* 大型カード用。緑地の上に置くため白の枠線＋半透明地にする。
   .next-head の外（.next-head と .next-line の間）に置かれる独立行 */
.next-smartic {
  margin-top: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.55);
}

/* JCT案内帯用。方面案内文（.jct-notice-branch）の直下に置く独立行 */
.jct-notice-smartic {
  margin-top: 4px;
}

/* =========================================================
   ETC専用バッジ（KENOU-K02・圏央道 坂戸IC／桶川北本IC）
   出入口がETC専用料金所の施設にだけ出す。スマートICバッジとは別要素・別配色で、
   置き場所（独立した1行・.fac-main の縦積み／大カードの区切り線手前）は同じ。
   Grid定義（.next-head / .fac-item）は変更しない。
   ========================================================= */
.etconly-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  background: #5b4a9b;
  border: 1px solid #5b4a9b;
  border-radius: 6px;
  white-space: nowrap;
}

/* 大型カード用。緑地の上に置くため白の枠線＋半透明地にする */
.next-etconly {
  margin-top: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.55);
}

/* =========================================================
   統合表示グループの2段目（PHASE9_13・黒磯板室IC＋黒磯PA）
   現地標識で併記される1組だけを1枚のカードにまとめ、
   併記側（黒磯PA）を主表示の下へ小さく置く。

   ・大カードは .next-name の内側に置くブロック（.next-head のGrid定義は無変更）
   ・一覧カードは .fac-main（flex column）の子（.fac-item のGrid定義は無変更）
   ・種別チップは既存バッジと同じ文言（PA）で、PAであることを明示する
   ・対象外の施設ではDOM自体が生成されないため、余白は一切増えない
   ========================================================= */

/* 大カード: 施設名（44px）の下に置く2段目。名前の約半分のサイズにして主従を明確にする */
.next-subname {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.next-subtype {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}
.next-subtext {
  min-width: 0;
  overflow-wrap: anywhere; /* 想定外に長い併記名でも枠外へはみ出させない */
}

/* 一覧カード: .fac-name（21px）の下。GSチップ・スマートICバッジと同じ縦積みに並ぶ */
.fac-subname {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--muted);
}
.fac-subtype {
  flex: 0 0 auto;
  padding: 0 6px;
  border: 1px solid #cfe3d8;
  border-radius: 6px;
  background: #eaf3ee;
  color: var(--badge-green);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}
.fac-subtext {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 施設名を縮める既存ブレークポイント（430 / 360 / 340px）に合わせて2段目も縮める。
   既存ルールは変更せず、同じ条件の独立ルールとして後ろに置く */
@media (max-width: 360px) {
  .next-subname { font-size: 20px; margin-top: 8px; }
  .fac-subname { font-size: 13px; }
}

@media (max-width: 340px) {
  .next-subname { font-size: 18px; }
  .next-subtype { font-size: 12px; padding: 1px 5px; }
}

/* =========================================================
   目標地点セレクタ（モーダル / 下部シート）
   ========================================================= */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* ソフトキーボード回避（PHASE9_09）。app.js が visualViewport の実測値から
     --kb-inset（アプリ枠の下端が隠れている量）を入れる。未対応環境では 0px。
     box-sizing: border-box のため、この下余白の分だけ内容ボックスが縮み、
     下端寄せのシートと下のシートの max-height:% がそのまま連動する */
  padding-bottom: var(--kb-inset, 0px);
}
.modal-overlay[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 22, 0.45);
}

.target-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 82%;
  background: var(--card-bg);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
  animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(14px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}

/* 設定シート（目標地点セレクタ）だけを画面上部近くまで広げる（PHASE9_09）。
   端末高に対する割合＋safe-areaの実測で決まるため、端末ごとの固定px分岐が要らない。
   ステータスバー/セーフエリアは侵食しない。現在位置補正モーダルは .target-sheet の
   82%のままで見た目を変えない。 */
.settings-sheet {
  max-height: calc(100% - max(12px, env(safe-area-inset-top)));
}

/* 上段（表示設定＋閉じる）以下をまとめた1本のスクロール領域（PHASE9_09）。
   下へスクロールすると速度設定が上に流れ、目標地点一覧がシート全高を使える。
   min-height:0 がないと flex 子要素が縮まずスクロールしない。 */
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* シート内スクロールの外側連鎖を防止（PHASE6_13と同方針） */
}

.target-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.target-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
}
.target-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #eef2ef;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.speed-note,
.target-note {
  margin: 6px 2px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* 速度モードの説明2行（PHASE9_07）。速度ボタンの上に2行続けて置くため行間だけ詰める。
   左右・下の余白は上の .speed-note の既存値をそのまま使う */
.speed-note-current { margin-bottom: 3px; }
.speed-note-fixed { margin-top: 0; }

/* 「目標地点を選ぶ」の見出し・説明・絞り込みタブを1つのまとまりとして
   .sheet-body の上端に貼り付ける（PHASE9_09・実機確認後の追補）。
   タブだけが残って上に空白ができる状態を防ぐ。施設カードはこのブロックの
   下を流れるため、背景をシートと同色にして重なり・透けを防ぐ。 */
.target-sticky {
  position: sticky;
  top: 0;
  z-index: 3; /* 施設カード（静的）より前面 */
  background: var(--card-bg);
}

/* 絞り込みタブと施設カードの間の余白。貼り付き中は境目になるため、
   marginではなくsticky領域の内側のpaddingで確保する */
.target-chips-wrap {
  padding-bottom: 12px;
}
.target-chips {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e2e7e3;
  border-radius: 12px;
  margin-bottom: 0;
}
.target-chip {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.target-chip[aria-selected="true"] {
  background: #fff;
  color: var(--num-green);
  box-shadow: 0 1px 4px rgba(20, 80, 50, 0.18);
}

/* PHASE9_09: 一覧単独の内部スクロールは廃止し、.sheet-body の1本スクロールへ統合した
   （入れ子スクロールを作らないため overflow-y / -webkit-overflow-scrolling を外す） */
.target-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.target-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.target-item[aria-selected="true"] {
  border-color: var(--accent-green);
  background: var(--note-bg);
}
.target-badge {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 4px 8px;
  text-align: center;
  border-radius: 8px;
  background: var(--badge-green);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.target-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-dist {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.target-dist .unit {
  font-size: 12px;
  margin-left: 1px;
}
.target-empty {
  margin: 24px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

/* =========================================================
   現在位置の手動補正モーダル（PHASE6_05）
   ========================================================= */
.correct-current {
  margin: 8px 2px 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--num-green);
}

.correct-msg {
  margin: 0 2px 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--note-bg);
  color: #2c6045;
  font-size: 13px;
  font-weight: 700;
}
.correct-msg[hidden] { display: none; }
.correct-msg.is-error {
  background: #fdecea;
  color: #9b1c1c;
}

.correct-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* シート内スクロールの外側連鎖を防止（PHASE6_13） */
}

.correct-section {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.correct-section:first-child { border-top: none; }

.correct-h {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.correct-select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px; /* iOSで16px未満だと拡大されるため16pxを確保 */
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
}

.correct-offsets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.correct-offset-btn {
  flex: 1 1 auto;
  min-width: 88px;
  padding: 11px 10px;
  border: 1px solid var(--accent-green);
  border-radius: 12px;
  background: #fff;
  color: var(--num-green);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.correct-offset-btn:active {
  background: var(--badge-green);
  color: #fff;
}

.correct-kp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.correct-kp-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  text-align: right;
}
.correct-kp-unit {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.correct-kp-btn {
  flex: 0 0 auto;
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.correct-kp-btn:active { background: var(--num-green); }

/* KP直接入力の対応範囲の補足（PHASE9_05・下りのみ表示） */
.correct-kp-note {
  margin: 8px 2px 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}
.correct-kp-note[hidden] { display: none; }

.correct-reset-btn {
  width: 100%;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f1f4f2;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.correct-reset-btn:active { background: #e2e7e3; }

/* =========================================================
   任意速度の入力モーダル（PHASE9_08）
   現在位置補正モーダルと同じ下部シート構成の小さな入力ダイアログ。
   ========================================================= */
/* PHASE9_09: キーボード表示中は .modal-overlay の下余白の分だけ基準の高さが縮むため、
   この70%も自動で小さくなる。想定外に狭い場合（横向き・巨大キーボード等）でも
   「この速度を使う」へ到達できるよう、最後の保険としてシート内スクロールを許す。 */
.custom-speed-sheet {
  max-height: 70%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.custom-speed-msg {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--note-bg);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--num-green);
}
.custom-speed-msg[hidden] { display: none; }
.custom-speed-msg.is-error {
  background: #fdecea;
  color: #9b1c1c;
}

.custom-speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.custom-speed-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  text-align: right;
}
.custom-speed-unit {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.custom-speed-apply {
  width: 100%;
  margin-top: 12px;
  padding: 13px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-green);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.custom-speed-apply:active { background: var(--num-green); }

.custom-speed-note {
  margin: 10px 2px 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--muted);
}

/* =========================================================
   表示設定（PHASE6_13・画面を常に表示トグル）
   目標地点シート最上段に置き、右側に閉じる×ボタンを並べる
   （PHASE7_03で下部から移動）。トグルの見た目はGPSトグルを流用。
   ========================================================= */
.sheet-top-row {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.settings-section {
  flex: 1 1 auto;
  min-width: 0;
}
.settings-h {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.awake-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
.awake-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.awake-label { font-size: 14px; font-weight: 800; color: #2c6045; }
.awake-note { font-size: 11px; font-weight: 600; color: var(--muted); }
.awake-note.is-warn { color: #b4552d; }
.awake-toggle:disabled { opacity: 0.5; cursor: default; }

/* =========================================================
   トースト（PHASE6_13・補正完了などの短時間通知）
   モーダル(z-index:50)より前面に出す。操作は透過させる。
   ========================================================= */
.app-toast {
  position: absolute;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  margin: 0;
  max-width: calc(100% - 48px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(18, 63, 40, 0.95);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  /* 速度モード切替の2行トースト（PHASE9_07）の改行を有効にする。
     既存の1行トーストは折り返し挙動が変わらない */
  white-space: pre-line;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.app-toast[hidden] { display: none; }
.app-toast.is-show { opacity: 1; }

/* =========================================================
   目標地点の音声案内（PHASE9_16）
   設定シート内のスイッチ1行だけ。中身は表示設定のトグル
   （.awake-control / .gps-toggle）を流用し、ここでは余白と区切り線のみ。
   ========================================================= */
.voice-guide-settings {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* =========================================================
   到着時刻指定／速度案内モード（PHASE9_15）
   すべて新規セレクタ（.speed-guide / .sg-*）と .scroll.speed-guide-on 配下の
   個別指定だけで構成する。既存ルールには一切作用しない。
   ========================================================= */

/* ON中に隠す通常ブロック（個別指定）。
   エラー表示 .error-box と JCT案内帯 .jct-notice は隠さず、ON中もそのまま見せる */
.scroll.speed-guide-on > .info-card,
.scroll.speed-guide-on > .next-card,
.scroll.speed-guide-on > .range-bar,
.scroll.speed-guide-on > .overview-card,
.scroll.speed-guide-on > .list-heading,
.scroll.speed-guide-on > .facility-list { display: none; }

/* 専用パネル（深緑カード）。
   速度案内の表示中だけ .scroll の左右 padding(16px) へ 10px ずつはみ出させ、
   画面端に 6px の均等な余白を残してカードを広く使う（実機確認後の修正）。
   .scroll 自体の余白は変えないため、通常モードへ戻れば従来の幅・余白のまま。
   JCT案内帯・エラー表示は別要素で影響を受けない。内側の余白・文字サイズは変えない */
.speed-guide {
  position: relative;
  background: linear-gradient(165deg, var(--card-green-1), var(--card-green-2));
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px rgba(16, 56, 36, 0.28);
  padding: 14px 16px 16px;
  color: #fff;
  margin: 0 -10px 18px;
}
.speed-guide[hidden] { display: none; }

.sg-mode {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.sg-mode::before,
.sg-mode::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}

/* 目的地・到着目標（青い帯・タップで設定シートを開く） */
.sg-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: #1a56db;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sg-target:active { background: #164bc0; }
.sg-target-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.sg-target-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}
.sg-target-chevron svg { width: 100%; height: 100%; }
.sg-target-when { white-space: nowrap; }
/* ボタン内の文言span・矢印はポインタの対象にしない。押下の対象を常に <button> 自身にして、
   押下中に文言が差し替わってもクリックが同じノードで成立するようにする */
.sg-target > * { pointer-events: none; }

/* 主表示: 必要平均速度（黄色） */
.sg-main-lbl {
  margin: 16px 0 4px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}
.sg-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.sg-main-ic {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  color: #ffd23f;
}
.sg-main-ic svg { width: 100%; height: 100%; }
.sg-main-val {
  font-size: 76px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  color: #ffd23f;
  font-variant-numeric: tabular-nums;
}
.sg-main-unit {
  margin-left: 4px;
  font-size: 26px;
  font-weight: 900;
  color: #ffd23f;
}

/* 必要平均速度の代わりに出す状態メッセージ（期限到達・到達／通過・方向外・情報なし） */
.sg-status {
  margin: 8px 0 0;
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
}

/* 残距離・残り時間 */
.sg-stats {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  margin-top: 12px;
}
.sg-stat { text-align: center; }
.sg-stat-lbl {
  display: block;
  font-size: 14px;
  font-weight: 800;
  opacity: 0.95;
}
.sg-stat-val {
  font-size: 36px;
  font-weight: 900;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.sg-stat-val--text { font-size: 22px; }
.sg-stat-unit {
  margin-left: 3px;
  font-size: 16px;
  font-weight: 800;
}
.sg-vline {
  width: 1px;
  height: 44px;
  background: rgba(255, 255, 255, 0.35);
}

/* 既存ETA（今のペースなら）と目標との時間差 */
.sg-eta {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
}
.sg-eta-lbl {
  font-size: 15px;
  font-weight: 800;
}
.sg-eta-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.sg-eta-time {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.sg-eta-sub {
  font-size: 18px;
  font-weight: 800;
}
.sg-diff {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 15px;
  font-weight: 800;
  flex-wrap: wrap;
}
.sg-diff-ic {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: #ffd23f;
}
.sg-diff-ic svg { width: 100%; height: 100%; }
.sg-diff-val {
  font-size: 20px;
  color: #ffd23f;
}

/* 次の施設（既存の一覧カード .fac-item をそのまま使う） */
.sg-next-lbl {
  margin: 14px 0 8px 2px;
  font-size: 14px;
  font-weight: 800;
}
.sg-next-empty {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 14px;
  font-weight: 700;
}

/* 目標を変更・解除（設定シートを開く） */
.sg-change {
  width: 100%;
  margin-top: 14px;
  padding: 13px 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sg-change:active { background: rgba(255, 255, 255, 0.15); }
/* 2段目（「通常モードへ」）は同じ見た目・幅で、間隔だけ詰める */
.sg-change + .sg-change { margin-top: 8px; }
.sg-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}

/* 設定シート内「到着時刻指定」 */
.sg-settings {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.sg-set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.sg-set-lbl {
  flex: 0 0 64px;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}
.sg-set-select,
.sg-set-time {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px; /* 16px未満にするとiOSで入力時に拡大されるため */
  font-weight: 800;
}
/* 「時」「分」の選択欄（到着目標）。狭い幅や大きめの文字設定では行を分けて収める */
.sg-set-row--time { flex-wrap: wrap; }
.sg-time-fields {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 10px;
}
.sg-time-field {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  gap: 6px;
}
.sg-time-select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  text-align: center;
}
.sg-time-unit {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 800;
  color: var(--muted);
}
.sg-set-preview {
  margin: 10px 2px 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--num-green);
}
.sg-set-clear {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #9b1c1c;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sg-set-clear[hidden] { display: none; }

/* 表示範囲の段の右端「時刻指定モードへ」（PHASE9_15）。
   表示範囲の選択とは別の独立操作なので、枠と間隔で区別する。
   既存 .range-tab のルールは変えず、この上書きだけで文言の折り返しを許容する */
.range-tabs--with-mode { flex-wrap: wrap; }
.range-mode-btn {
  flex: 1.15 1 0;
  margin-left: 6px;
  border: 1.5px solid var(--accent-green);
  background: #fff;
  color: var(--num-green);
  white-space: normal;
  overflow: visible;
  line-height: 1.25;
  padding: 6px 6px;
}
.range-mode-btn:active { background: var(--note-bg); }
.range-mode-btn span { display: inline-block; }

/* 狭い幅（PROJECT_POLICY 13.1 の確認幅 320 / 360px）では主表示と時刻を少し詰める */
@media (max-width: 360px) {
  .sg-main-val { font-size: 64px; }
  .sg-eta-time { font-size: 38px; }
  .sg-stat-val { font-size: 32px; }
}
