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

: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 {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 7px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.95;
}
.header-settings svg { width: 100%; height: 100%; display: block; }

/* =========================================================
   スクロール領域
   ========================================================= */
.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);
}

/* 上りモード（暫定）の注記。上り選択中のみ表示 */
.direction-note {
  margin: 8px 2px 0;
  font-size: 12px;
  font-weight: 700;
  color: #86602f;
}
.direction-note[hidden] { display: none; }

/* GPSの役割の小さな注記（PHASE7_01） */
.gps-role-note {
  margin: 6px 2px 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

/* ---- GPS連動トグル（PHASE6_03） ---- */
.gps-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--note-bg);
  border-radius: 12px;
}
.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; }

/* ---- 推定現在位置の更新（PHASE6_04） ---- */
.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-status { font-size: 13px; font-weight: 700; color: var(--muted); }
.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%; }

/* ---- GPS推定KPの参考表示（PHASE6_11・表示専用） ---- */
/* 緑の操作系とは色を分け、「参考情報」であることを見た目でも示す（ニュートラル寄り） */
.gps-estimate {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: #eef2f6;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #3a5567;
}
.gps-estimate[hidden] { display: none; }
.gps-estimate b { font-size: 15px; font-weight: 800; color: #274155; }
.gps-est-tag {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: #cdd8e2;
  color: #3a5567;
  font-size: 11px;
  font-weight: 800;
}
.gps-est-sub { color: var(--muted); font-weight: 700; }
.gps-estimate.is-offroute,
.gps-estimate.is-lowacc {
  background: #f4efe6;
  color: #86602f;
}
.gps-estimate.is-offroute .gps-est-tag,
.gps-estimate.is-lowacc .gps-est-tag {
  background: #e4d6bf;
  color: #86602f;
}

/* ---- 実走テスト記録モード（PHASE6_12・検証用） ---- */
.testlog-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: #f1f3f5;
  border-radius: 10px;
}
.testlog-btn {
  flex: 0 0 auto;
  border: 1px solid #b6c0c8;
  border-radius: 999px;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #40525e;
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.testlog-btn.is-recording {
  border-color: #b4552d;
  color: #fff;
  background: #b4552d;
}
.testlog-status {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.testlog-copy {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: #52616b;
  -webkit-tap-highlight-color: transparent;
}
.testlog-copy:disabled { opacity: 0.45; cursor: default; }
.testlog-copy:not(:disabled):active { background: #3a464e; }
.testlog-clear {
  flex: 0 0 auto;
  border: 1px solid #c9a5a0;
  border-radius: 999px;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #9b4a3a;
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.testlog-clear:disabled { opacity: 0.4; cursor: default; }
.testlog-clear:not(:disabled):active { background: #f6e7e4; }

/* =========================================================
   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;
}

/* =========================================================
   2-3. まもなく料金所案内帯（PHASE10_04）
   進行方向の次の通過案内ポイント（料金所など）が案内範囲内のときだけ表示する帯。
   レイアウト・文字サイズ・余白はJCT案内帯を踏襲し、
   左アクセントの色だけを黄〜オレンジ系にして分岐案内と識別できるようにする。
   ========================================================= */
.route-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border-left: 5px solid #e8a317; /* 料金所＝黄〜オレンジ（JCT案内の緑と識別） */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.route-notice[hidden] { display: none; }

.route-notice-main {
  flex: 1 1 auto;
  min-width: 0; /* 長い料金所名でも折り返せるように */
}
.route-notice-soon {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  overflow-wrap: anywhere; /* 狭い画面幅でも重ならず折り返す */
}
.route-notice-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}
.route-notice-detail {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #b3760c; /* 左アクセントと同系のやや濃い色（本文とのコントラスト確保） */
  overflow-wrap: anywhere;
}
.route-notice-dist {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.route-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;
}

.next-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.next-icon {
  flex: 0 0 auto;
  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 {
  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);
}

.next-deco {
  position: absolute;
  top: -6px;
  right: -8px;
  width: 150px;
  height: 70px;
  z-index: 0;
  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;
}

.next-stat .big {
  font-size: 56px;
  font-weight: 800;
  line-height: 1.0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.next-stat .big .unit {
  font-size: 24px;
  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;
}

.fac-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto 14px;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 14px;
}

.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;
}
.fac-badge--num .fac-badge-num { font-size: 19px; }
.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);
}

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

/* =========================================================
   表示範囲モード
   ========================================================= */
.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);
}

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

/* 給油ブランド 小チップ（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;
}
.next-head .fac-fuels {
  margin-left: 6px;
}

/* =========================================================
   目標地点セレクタ（モーダル / 下部シート）
   ========================================================= */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.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; }
}

.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;
}
.target-note {
  margin: 6px 2px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.target-chips {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e2e7e3;
  border-radius: 12px;
  margin-bottom: 12px;
}
.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);
}

.target-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* シート内スクロールの外側連鎖を防止（PHASE6_13） */
  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); }

.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; }

/* =========================================================
   表示設定（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;
  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; }
