/* Copyright (c) 2026 gin71
 * SPDX-License-Identifier: MIT
 */

/* ===== GPX Player Web — Styles ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #2a2a4a;
  --overlay-bg: rgba(15, 52, 96, 0.7);
  --radius: 6px;
  --transition: 0.2s ease;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ===== ドロップゾーン ===== */
.dropzone {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  z-index: 1000;
  overflow: hidden auto;
  scrollbar-gutter: stable;
}
.dropzone.hidden { display: none; }
.dropzone-content {
  width: min(960px, calc(100vw - 32px));
  text-align: center;
  padding: 32px 36px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at top, rgba(233, 69, 96, 0.09), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%);
}
.dropzone-content h1 {
  font-size: clamp(2rem, 4vw, 2.7rem);
  margin-bottom: 0.6rem;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.dropzone-content p { color: var(--text-secondary); margin: 0.4rem 0; }
.dropzone-lead { font-size: 1.08rem; max-width: 56rem; margin-inline: auto; color: #f3f0ff; }
.dropzone-guide {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-top: 14px;
  text-align: left;
}
.dropzone-guide section,
.dropzone-picker,
.dropzone-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(22, 33, 62, 0.46);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(8px);
}
.dropzone-guide section {
  padding: 14px 16px;
}
.dropzone-details {
  margin-top: 14px;
  padding: 14px 16px 16px;
  text-align: left;
}
.dropzone-details > h2,
.dropzone-guide h2,
.dropzone-info h3 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}
.section-eyebrow {
  color: #8fb4ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.quickstart-card h2,
.feature-card h2 {
  margin-bottom: 0.85rem;
}
.quickstart-list {
  list-style: none;
  display: grid;
  gap: 10px;
}
.quickstart-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  box-shadow: 0 6px 16px rgba(233, 69, 96, 0.35);
}
.quickstart-list strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}
.quickstart-list p {
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.45;
}
.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.feature-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(143, 180, 255, 0.2);
  background: rgba(15, 52, 96, 0.65);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.82rem;
  line-height: 1;
}
.dropzone-picker {
  margin-top: 14px;
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  border: 1px solid rgba(233, 69, 96, 0.35);
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.18), rgba(15, 52, 96, 0.62));
  box-shadow: 0 16px 36px rgba(233, 69, 96, 0.12), 0 10px 24px rgba(0, 0, 0, 0.16);
}
.dropzone-picker-copy {
  display: grid;
  gap: 4px;
}
.dropzone-picker-kicker {
  color: #ffd2da;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.dropzone-picker strong {
  display: block;
  color: #fff;
  font-size: 1rem;
}
.dropzone-picker p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.84rem;
}
.dropzone-picker input[type="file"] {
  margin-top: 0;
  max-width: 100%;
}
.dropzone-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 0;
}
.dropzone-info section {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
  backdrop-filter: none;
}
.dropzone-info ul {
  padding-left: 1.2rem;
}
.dropzone-info li {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0.25rem 0;
}
.dropzone-info code {
  color: var(--text-primary);
  background: rgba(15, 52, 96, 0.75);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}
.dropzone-content input[type="file"] {
  margin-top: 0;
  max-width: 100%;
}
.dropzone.drag-over { background: rgba(233,69,96,0.1); }
.dropzone.drag-over .dropzone-content { border-color: var(--accent); }

@media (max-width: 780px) {
  .dropzone-content {
    padding: 22px 18px;
  }

  .dropzone-guide,
  .dropzone-info {
    grid-template-columns: 1fr;
  }

  .dropzone-picker {
    align-items: stretch;
  }

  .dropzone-picker input[type="file"] {
    width: 100%;
  }
}

@media (max-height: 760px) {
  .dropzone {
    align-items: flex-start;
    overflow-y: auto;
    padding: 12px 0;
  }

}

@media (prefers-reduced-motion: reduce) {
  .step-badge,
  .feature-chip {
    transition: none !important;
  }
}


/* ===== メインUI ===== */
#main-ui { display: flex; flex-direction: column; height: 100vh; }
#main-ui.hidden { display: none; }

/* ===== 動画オーバーレイコントロール ===== */
/* 動画パネル内、下部中央に配置。ビデオコントロールに重ならないように少し上に配置 */
#video-controls {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  /* height: auto — fit-content は Firefox で未サポート */
  height: auto;
  z-index: 50;
  pointer-events: auto;
  /* デフォルト非表示。マウスが動画上にいる間だけ表示 */
  opacity: 0;
  transition: opacity 0.3s ease;
}
#video-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

.video-controls-inner {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

.video-controls-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-video-control {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s ease;
  width: 44px;
  height: 44px;
  text-align: center;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-video-control:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-skip-stop-time.skip-stop-active {
  background: rgba(78, 204, 163, 0.7);
  border-color: #4ecca3;
}
.btn-skip-stop-time.skip-stop-active:hover {
  background: rgba(78, 204, 163, 1);
}

/* ===== 録画時刻ソースウィジェット ===== */
.video-time-source-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-video-time-source {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: auto;
  min-width: 124px;
  min-height: 42px;
  padding: 5px 8px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.video-time-source-label,
.video-time-offset-label {
  display: block;
  white-space: nowrap;
}

.video-time-offset-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
}
.video-time-source-panel {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%) translateY(4px);
  width: 380px;
  padding: 0;
  background: rgba(30, 30, 40, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.2s;
  backdrop-filter: blur(8px);
}

.video-time-source-panel.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.video-time-source-panel-header {
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  font-weight: 600;
}

.video-time-source-panel-body {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
}

.video-time-settings-group {
  display: grid;
  gap: 8px;
}

.video-time-settings-group-title {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  font-weight: 600;
}

.time-offset-control {
  display: none;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.time-offset-control.visible {
  display: grid;
}

.time-offset-control + .video-time-settings-group {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.video-time-rename-group {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.video-time-source-field {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
}

.video-time-source-field select {
  min-width: 0;
  padding: 4px 6px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 0.7rem;
}

.video-time-source-current {
  padding-top: 4px;
  color: #7de2a8;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre-line;
}

/* ===== 停止スキップウィジェット ===== */
.skip-stop-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* 設定パネル（デフォルトでボタンの下方に表示、position-aboveで上方へ） */
.skip-stop-panel {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
  min-width: 220px;
  padding: 0;
  background: rgba(30, 30, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.2s;
  backdrop-filter: blur(8px);
}

/* ボタンの上方へ表示 */
.skip-stop-panel.position-above {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
}

.skip-stop-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.skip-stop-panel.hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

/* ヘッダー */
.skip-stop-panel-header {
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.02em;
}

.skip-stop-panel-body {
  padding: 10px 12px;
}

/* 閾値コントロール */
.threshold-control {
  margin-bottom: 8px;
}

.threshold-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.threshold-label span:first-child {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
}

.threshold-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4ecca3;
  font-variant-numeric: tabular-nums;
}

/* スライダー行 */
.slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.threshold-slider {
  flex: 1;
  height: 4px;
  accent-color: #4ecca3;
  cursor: pointer;
}

.reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.reset-btn:active {
  background: rgba(78, 204, 163, 0.3);
}

/* 閾値範囲インジケーター */
.threshold-range {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
  margin-bottom: 4px;
}

.range-min,
.range-max {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
}

.auto-marker {
  font-size: 0.6rem;
  color: #4ecca3;
  white-space: nowrap;
}

/* 追加読み込みボタン（inline版） — .btn-video-control と同じサイズ */
/* 個別の上書きは不要（.btn-video-control に width 固定済み） */

.video-speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.video-speed-control label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}
.video-speed-control input[type="range"] {
  width: 100px;
  accent-color: #fff;
  cursor: pointer;
}
.video-speed-control #speed-value {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  min-width: 36px;
}

.video-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

/* ===== パネル透明度スライダー（パネルの外に隣接配置） ===== */
/* JSで位置を動的に設定（パネルの上下に配置） */
.panel-opacity-slider {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: transparent;
  border-radius: 4px;
  z-index: 23;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s;
}
.panel-opacity-slider.visible {
  opacity: 1;
}
.panel-opacity-slider label {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
}
.panel-opacity-slider input[type="range"] {
  flex: 1;
  min-width: 60px;
  max-width: 100px;
  height: 16px;
  accent-color: #fff;
}
.panel-opacity-slider span {
  font-size: 11px;
  color: #fff;
  min-width: 32px;
}

/* ===== GPS操作用コントロールパネル（一括表示/非表示） ===== */
#gps-control-panel {
  position: absolute;
  z-index: 23;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  background: rgba(15, 52, 96, 0.85);
  border-radius: 4px;
  backdrop-filter: blur(4px);
}
#gps-control-panel.visible {
  opacity: 1;
  pointer-events: auto;
}
#gps-control-panel .gps-opacity-control {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
}
#gps-control-panel .gps-opacity-control label {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
}
#gps-control-panel .gps-opacity-control input[type="range"] {
  min-width: 60px;
  max-width: 100px;
  height: 16px;
  accent-color: #fff;
}
#gps-control-panel .gps-opacity-control span {
  font-size: 11px;
  color: #fff;
  min-width: 32px;
}
#gps-control-panel .gps-control-buttons {
  display: flex;
  gap: 4px;
  padding: 0 6px 4px;
}

/* GPSリセットボタン（アイコンのみ） */
.btn-gps-reset {
  font-size: 16px;
  color: #fff;
  background: rgba(233, 69, 96, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  min-width: 28px;
  width: 28px;
  text-align: center;
  line-height: 1.2;
  position: relative;
}
/* ツールチップを即表示 */


.btn-gps-reset:hover {
  background: rgba(233, 69, 96, 1);
}
.btn-gps-reset.reset-active {
  background: rgba(78, 204, 163, 0.7);
  border-color: #4ecca3;
}
.btn-gps-reset.reset-active:hover {
  background: rgba(78, 204, 163, 1);
}

/* 逆ジオコーディング（住所取得）ボタン（アイコンのみ） */
.btn-reverse-geocode {
  font-size: 16px;
  color: #fff;
  background: rgba(100, 120, 200, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  min-width: 28px;
  width: 28px;
  text-align: center;
  line-height: 1.2;
  position: relative;
}


.btn-reverse-geocode:hover {
  background: rgba(100, 120, 200, 0.9);
}
.btn-reverse-geocode.reverse-geocode-active {
  background: rgba(78, 204, 163, 0.7);
  border-color: #4ecca3;
}
.btn-reverse-geocode.reverse-geocode-active:hover {
  background: rgba(78, 204, 163, 1);
}
.btn-reverse-geocode.reverse-geocode-loading {
  background: rgba(100, 120, 200, 0.4);
  cursor: not-allowed;
  opacity: 0.7;
}

/* GPS表示項目設定ボタン（⚙️） — 天気/住所ボタンと同じサイズ */
.btn-gps-config {
  font-size: 16px;
  color: #fff;
  background: rgba(128, 128, 160, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  line-height: 1.2;
  min-width: 28px;
  width: 28px;
  height: 24px;
  text-align: center;
  transition: background 0.2s;
  position: relative;
}
.btn-gps-config:hover {
  background: rgba(128, 128, 160, 0.8);
}
.btn-gps-config.config-active {
  background: rgba(78, 204, 163, 0.7);
  border-color: #4ecca3;
}
.btn-gps-config.config-active:hover {
  background: rgba(78, 204, 163, 1);
}

/* 天気表示ボタン（アイコンのみ） */
.btn-toggle-weather {
  font-size: 16px;
  color: #fff;
  background: rgba(200, 160, 50, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  min-width: 28px;
  width: 28px;
  text-align: center;
  line-height: 1.2;
  position: relative;
}


.btn-toggle-weather:hover {
  background: rgba(200, 160, 50, 0.9);
}
.btn-toggle-weather.weather-active {
  background: rgba(78, 204, 163, 0.7);
  border-color: #4ecca3;
}
.btn-toggle-weather.weather-active:hover {
  background: rgba(78, 204, 163, 1);
}
.btn-toggle-weather.weather-loading {
  background: rgba(200, 160, 50, 0.4);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ===== コンテンツレイアウト ===== */
#content {
  display: flex; flex: 1; min-height: 0;
  position: relative;
}

/* 動画パネル（背景） */
#video-panel {
  flex: 1; position: relative;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center; justify-content: center;
}
#video-player {
  width: 100%; height: 100%;
  object-fit: contain;
}

/* 地図パネル（動画上にオーバーレイ） */
#map-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 320px;
  height: 240px;
  min-width: 200px;
  min-height: 150px;
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  /* パネル自体はマウスイベントを透過させ、中の要素のみ反応させる */
  pointer-events: none;
}
#map {
  width: 100%;
  height: 100%;
  /* 地図操作のためにマウスイベントを有効化 */
  pointer-events: auto;
}

/* 地図ドラッグハンドル（十字矢印、追従/回転/手動ボタンの下） */
#map-drag-handle {
  position: absolute;
  top: 68px;
  right: 4px;
  left: auto;
  width: 32px; height: 32px;
  background: rgba(233, 69, 96, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 20;
  color: #fff;
  font-size: 20px;
  user-select: none;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.38);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: opacity 0.2s;
  /* ハンドルは確実にマウスに反応させる */
  pointer-events: auto;
  /* 初期状態は非表示 */
  opacity: 0;
}
#map-panel:hover #map-drag-handle {
  opacity: 0.88;
}
#map-drag-handle:active {
  cursor: grabbing;
}

/* リサイズハンドル（右下） */
.map-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: var(--accent);
  cursor: nwse-resize;
  z-index: 21;
  pointer-events: auto;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
#map-panel:hover .map-resize-handle {
  opacity: 1;
}

/* ===== 動画上オーバーレイ ===== */
.video-overlay {
  position: absolute;
  top: 10px; right: 10px;
  width: 240px;
  border-radius: var(--radius);
  padding: 0.625em;
  font-size: 0.8rem;
  z-index: 10;
  cursor: default;
  user-select: none;
  color: #fff;
  background: rgba(15, 52, 96, 0.85);
  transition: opacity 0.2s;
  transform-origin: bottom right;
}

.overlay-header {
  font-weight: bold; color: var(--accent); margin-bottom: 0.3125em;
  border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.3125em;
}
.overlay-title {
  font-size: 0.85rem;
}
.video-overlay .overlay-content { line-height: 1.6; }
.video-overlay.snap-active,
#video-controls.snap-active,
#map-panel.snap-active,
#weather-panel.snap-active,
#gps-control-panel.snap-active {
  outline: 2px solid rgba(0, 212, 255, 0.95);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.18), 0 0 18px rgba(0, 212, 255, 0.28);
}

.overlay-row { display: flex; justify-content: space-between; margin: 0.1563em 0; align-items: center; }
.overlay-row .label { color: #ccc; white-space: nowrap; flex: 0 0 auto; }
.overlay-row span:last-child { color: #fff; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.overlay-row span:last-child.no-data { color: transparent; }
#overlay-address {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;
}

/* ===== GPSパネル項目切り替え（クリックでON/OFF） ===== */
.gps-panel-item {
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}
/* ON時：項目カラーを明るい白、完全不透明 */
.gps-panel-item.gps-item-visible { opacity: 1; }
.gps-panel-item.gps-item-visible .label { color: #e0e0e0; }
.gps-panel-item.gps-item-visible .overlay-value { color: #ffffff; }
/* OFF時：項目カラーを薄く、半透明 */
.gps-panel-item.gps-item-hidden { opacity: 0.35; }
.gps-panel-item.gps-item-hidden .label { color: #555; }
.gps-panel-item.gps-item-hidden .overlay-value { color: #555; }
/* 項目が空のときもON/OFFで色分け */
.gps-panel-item.gps-item-hidden .overlay-value:empty,
.gps-panel-item.gps-item-hidden .overlay-value[data-value=""] { color: #555; }

/* 地図パネル操作ボタン（右上、ホバー時表示） */
.map-lock-btn,
.map-street-view-btn {
  position: absolute;
  top: 36px;
  height: 28px;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  z-index: 22;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  color: #fff;
  padding: 0;
  text-decoration: none;
}
.map-lock-btn {
  right: 4px;
  min-width: 56px;
}
#map-panel:hover .map-lock-btn,
#map-panel:hover .map-street-view-btn {
  opacity: 1;
}
.map-lock-btn:hover,
.map-street-view-btn:hover {
  background: var(--accent);
}

.map-tile-selector {
  position: absolute;
  right: 4px;
  top: 4px;
  left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 8px);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(22, 33, 62, 0.68);
  color: #fff;
  font-size: 11px;
  z-index: 23;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s;
}
#map-panel:hover .map-tile-selector {
  opacity: 0.88;
}
.map-tile-selector label {
  white-space: nowrap;
  color: #fff;
  font-weight: 700;
}
.map-tile-selector select {
  min-width: 108px;
  max-width: 170px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(15, 52, 96, 0.78);
  color: #fff;
  font-size: 11px;
  padding: 2px 4px;
}
.map-lock-btn.locked,
.graph-lock-btn.locked {
  background: rgba(78, 204, 163, 0.58);
  border-color: #4ecca3;
  color: #f2fff8;
  box-shadow: 0 0 8px rgba(78, 204, 163, 0.32);
}
.map-lock-btn.unlocked,
.graph-lock-btn.unlocked {
  background: rgba(233, 69, 96, 0.62);
  border-color: var(--accent-hover);
  color: #fff7f9;
  box-shadow: 0 0 8px rgba(233, 69, 96, 0.34);
}
.map-lock-btn.temporary-unlocked {
  background: rgba(249, 168, 37, 0.35);
  border-color: #f9a825;
  color: #fff3d0;
}
.map-lock-btn.rotating {
  background: rgba(90, 132, 255, 0.72);
  border-color: #8fb3ff;
  color: #fff;
  box-shadow: 0 0 10px rgba(90, 132, 255, 0.45);
}

.map-street-view-btn {
  right: 64px;
  width: 28px;
  background: rgba(78, 204, 163, 0.58);
  border-color: #4ecca3;
  box-shadow: 0 0 8px rgba(78, 204, 163, 0.32);
  color: #f2fff8;
  font-size: 14px;
}
#map-panel .maplibregl-ctrl-attrib,
#map-panel .maplibregl-ctrl-attrib.maplibregl-compact {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 12px;
  line-height: 1.35;
  text-shadow: none;
}
#map-panel .maplibregl-ctrl-attrib {
  margin: 0 4px 4px 0;
  align-self: flex-end;
}
#map-panel .maplibregl-ctrl-attrib a {
  color: #0645ad;
  font-weight: 700;
}
#map-panel .maplibregl-ctrl-group {
  background: rgba(255, 255, 255, 0.94);
}

/* グラフ上の動画情報オーバーレイ（動画がある区間） */
.graph-video-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(78, 204, 163, 0.16);
  border: 0;
  box-shadow: none;
  pointer-events: none;
  z-index: 0;
}

/* グラフ上の「動画なし」帯（動画がない区間） */
.graph-no-video {
  position: absolute;
  top: 0;
  height: 100%;
  background: repeating-linear-gradient(
    135deg,
    rgba(233, 69, 96, 0.1) 0,
    rgba(233, 69, 96, 0.1) 6px,
    rgba(40, 40, 40, 0.08) 6px,
    rgba(40, 40, 40, 0.08) 12px
  );
  border: 0;
  pointer-events: none;
  z-index: 0;
}
.graph-coverage-segment::after {
  position: absolute;
  top: 2px;
  left: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}
.graph-video-overlay::after { content: '動画あり'; }
.graph-no-video::after { content: '動画なし'; }
.graph-coverage-label-hidden::after { display: none; }

/* GPSオーバーレイのリサイズハンドル（三角形） */
.resize-handle {
  position: absolute; bottom: 0; right: 0;
  width: 16px; height: 16px;
  background: var(--accent);
  cursor: nwse-resize;
  z-index: 21;
  pointer-events: auto;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
#gps-overlay:hover .resize-handle {
  opacity: 1;
}

/* ===== タイムライン ===== */
#timeline {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}
#timeline-slider { flex: 1; cursor: pointer; }
#timeline-time {
  font-size: 0.8rem; color: var(--text-secondary);
  min-width: 80px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== グラフパネル ===== */
#graph-panel {
  height: 180px; background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.graph-tabs { display: flex; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.graph-tab {
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px 12px; cursor: pointer; font-size: 0.8rem;
  transition: background var(--transition);
}
.graph-tab:hover { color: var(--text-primary); }
.graph-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.graph-lock-btn {
  min-width: 58px;
  font-weight: 700;
}
#graph-canvas { flex: 1; overflow: hidden; }

/* ===== 時刻調整 UI ===== */
/* 表示状態は動画時刻設定パネル内の .visible クラスで制御 */
.time-offset-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5em;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  text-align: center;
}

.time-offset-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.time-offset-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background var(--transition);
  width: 36px;
  text-align: center;
  user-select: none;
}

.time-offset-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 6px 10px;
  text-decoration: none;
  white-space: normal;
  line-height: 1.35;
}

.time-offset-btn:hover,
.time-offset-link:hover {
  color: var(--text-primary);
}

.time-offset-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* グラフ上の再生位置マーカ */
.graph-playhead {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: #ffffff;
  z-index: 0;
  pointer-events: none;
  box-shadow: 0 0 6px #ffffff;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* #chart-canvas を overlay より上層に配置 */
#chart-canvas {
  position: relative;
  z-index: 1;
}

/* グラフ上「再生済み」のグレーオーバーレイ - canvas より下層 */
.graph-played-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 0;
  height: 100%;
  background: rgba(80, 80, 80, 0.4);
  z-index: 0;
  pointer-events: none;
}

/* ===== ユティリティ ===== */
.hidden { display: none !important; }

/* GPSデータがない動画専用モードではGPS依存パネルを表示しない */
.gps-data-dependent-hidden { display: none !important; }

/* ===== カスタムマーカー ===== */
.playback-marker {
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(233,69,96,0.8);
  /* MapLibre positions marker roots with CSS transform; do not animate it. */
  transition: none;
}

/* ===== レスポンシブ ===== */

/* 768px未満: 基本レスポンシブレイアウト・タッチターゲット拡大 */
@media (max-width: 768px) {
  #map-panel {
    width: 100%;
    height: 40%;
    top: auto;
    bottom: 0;
    left: 0;
  }
  #graph-panel { height: 120px; }

  /* モバイルでは動画オーバーレイコントロールをフロー内に配置 */
  #video-controls {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
  }

  /* タッチターゲット・ドラッグ・リサイズハンドルの最低サイズ */
  .map-resize-handle,
  .resize-handle {
    width: 44px;
    height: 44px;
  }
  #map-drag-handle {
    width: 44px;
    height: 44px;
  }
  .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  input[type="range"] {
    height: 44px;
    min-width: 44px;
  }
  .map-lock-btn,
  .graph-lock-btn {
    min-height: 44px;
    min-width: 56px;
    padding: 8px 12px;
  }
  .map-street-view-btn {
    min-height: 44px;
    min-width: 44px;
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  .map-tile-selector {
    min-height: 44px;
    padding: 8px 12px;
  }
  .map-tile-selector select {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 14px;
  }
  .time-offset-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 8px;
  }
  .graph-tab {
    min-height: 44px;
    padding: 8px 14px;
    min-width: 44px;
  }
}

/* 480px未満: 動画コントロールのレイアウト最適化 */
@media (max-width: 480px) {
  #video-controls {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 6px;
  }
  #video-controls .video-controls-inner {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  #timeline {
    padding: 4px 8px;
  }
  #timeline-time {
    min-width: 60px;
    font-size: 0.75rem;
  }
  .video-time-source-panel {
    width: min(380px, calc(100vw - 24px));
  }
  .video-time-source-field {
    grid-template-columns: 1fr;
    gap: 3px;
  }
  .video-overlay {
    width: 180px;
    font-size: 0.75rem;
  }
  .dropzone-content {
    padding: 24px;
  }
  .dropzone-info {
    grid-template-columns: 1fr;
  }
  #map-drag-handle {
    top: 60px;
  }
  .graph-tabs {
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px 4px;
  }
}

/* ===== ローディングオーバーレイ ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4ecda0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-text {
  color: #e0e0e0;
  font-size: 16px;
  margin-top: 16px;
}

/* ===== エラートースト ===== */
.error-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(233, 69, 96, 0.95);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: toast-slide-in 0.3s ease;
  max-width: 90vw;
}

.error-toast.hidden {
  display: none;
}

#error-toast-message {
  font-size: 14px;
}

#error-toast-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== CSP対応：インラインスタイルの外部化 ===== */
.hidden-input { display: none; }
.graph-canvas-container { position: relative; }

/* ===== アクセシビリティ ===== */

/* フォーカス可視化 */
*:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 2px;
}
.btn:focus-visible,
.graph-tab:focus-visible,
.time-offset-btn:focus-visible,
.map-lock-btn:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(78, 205, 160, 0.3);
}
input[type="range"]:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 2px;
}
#dropzone:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 4px;
}

/* ===== インフォメーショントースト ===== */
.info-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(56, 59, 103, 0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: toast-slide-in 0.3s ease;
  max-width: 90vw;
  font-size: 14px;
}

.info-toast.hidden {
  display: none;
}

#info-toast-message {
  font-size: 14px;
}

/* ===== 天気情報パネル（GPS情報パネルと同じスタイル） ===== */

.weather-panel {
  position: absolute;
  left: 10px;
  top: 270px;
  background: rgba(15, 52, 96, 0.85);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 0;
  color: #fff;
  font-size: 0.8rem;
  z-index: 10;
  min-width: 140px;
  width: 200px;
  max-width: none;
  transform-origin: bottom right;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.7;
}

/* 天気パネルリサイズハンドル（右下） */
.weather-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: var(--accent);
  cursor: nwse-resize;
  z-index: 21;
  pointer-events: auto;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
.weather-panel:hover .weather-resize-handle {
  opacity: 1;
}

/* 天気パネル透明度スライダー */
.weather-opacity-slider {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(15, 52, 96, 0.85);
  border-radius: 4px;
  z-index: 23;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s;
}
.weather-opacity-slider.visible {
  opacity: 1;
}
.weather-opacity-slider label {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
}
.weather-opacity-slider input[type="range"] {
  flex: 1;
  min-width: 60px;
  max-width: 100px;
  height: 16px;
  accent-color: #fff;
}
.weather-opacity-slider span {
  font-size: 11px;
  color: #fff;
  min-width: 32px;
}

/* 天気パネルヘッダーは削除済み */

.weather-panel-body {
  padding: 0.625em; /* 10px 10px / 12.8px */
  line-height: 1.6;
}

.weather-panel-row {
  display: flex;
  justify-content: flex-start;
  gap: 0.5em;
  margin: 0.1563em 0; /* GPS overlay-row と同じ */
  white-space: nowrap;
}

.weather-panel-icon {
  font-size: 1.5em;
  flex-shrink: 0;
}

.weather-panel-label {
  color: #ccc;
  flex-shrink: 0;
}

.weather-panel-value {
  color: #fff;
  white-space: nowrap;
  margin-left: auto;
}

.weather-panel-loading {
  padding: 0.625em; /* 10px 10px / 12.8px */
  text-align: center;
  color: #888;
  font-size: 0.9231em; /* 12px / 13px */
}

/* ===== Custom Tooltip (body直下の共有要素で最前面表示) ===== */
.custom-tooltip {
  position: fixed;
  z-index: 2147483647;
  max-width: min(380px, calc(100vw - 8px));
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  padding: 5px 12px;
  border-radius: 5px;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.05s ease, visibility 0s linear 0.05s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.custom-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.04s;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  /* 全ての transition / animation / scroll-behavior を抑制 */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* spinner などの機能的アニメーションは維持 */
  .loading-spinner {
    animation-duration: 0.8s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ===== 追加アクセシビリティ ===== */

/* 低コントラストテキストの改善 */
.overlay-row .label,
.weather-panel-label {
  color: #d0d0d0;
}

.time-offset-display,
#timeline-time {
  color: #c0c0c0;
}

/* 境界線のコントラスト改善（既存デザインを壊さない範囲） */
#timeline,
#graph-panel,
.graph-tabs,
.time-offset-control,
#gps-control-panel,
.panel-opacity-slider,
.weather-opacity-slider,
.map-tile-selector {
  border-color: #3a3a5a;
}

/* disabled 状態のコントラスト改善 */
input:disabled,
button:disabled {
  opacity: 0.6;
}

/* 追加の focus-visible ルール */
.btn-video-control:focus-visible,
.btn-gps-reset:focus-visible,
.btn-reverse-geocode:focus-visible,
.btn-toggle-weather:focus-visible,
.reset-btn:focus-visible,
.map-street-view-btn:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(78, 205, 160, 0.3);
}

#map-tile-source:focus-visible {
  outline: 2px solid #4ecda0;
  outline-offset: 2px;
}

/* video element のフォーカスリング（tabindex="-1" だが念のため） */
video:focus-visible {
  outline: none;
}
