* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #333;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
header {
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

header h1:hover {
  color: #94a3b8;
}

.status {
  font-size: 13px;
  color: #94a3b8;
  flex: 1;
}

.status.error {
  color: #f87171;
}

.version-badge {
  font-size: 11px;
  color: #fff;
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid #475569;
  border-radius: 10px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  transition: all 0.2s;
}

.version-badge:hover {
  border-color: #94a3b8;
  background: #334155;
}

.lang-select select {
  background: #334155;
  color: #fff;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.lang-select select:hover {
  background: #475569;
}

.option-caption {
  font-size: 12px;
  color: #94a3b8;
}

/* メインレイアウト */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* サイドバー */
.sidebar {
  width: 320px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}

/* サイドバーヘッダー（トグルボタン） */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 6px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.btn-sidebar-toggle {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 11px;
  color: #64748b;
  line-height: 1;
}

.btn-sidebar-toggle:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
}

.sidebar.collapsed {
  width: auto !important;
  min-width: 0;
}

.sidebar.collapsed .sidebar-body {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  border-bottom: none;
}

.sidebar-resizer.collapsed {
  display: none;
}

.sidebar section {
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

/* サイドバー上部の説明 */
.sidebar .intro {
  background: #f1f5f9;
  padding: 12px 16px;
}

.sidebar .intro p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}

.sidebar .intro .intro-features {
  color: #1e293b;
  margin-bottom: 6px;
}

.sidebar .intro .intro-features strong {
  color: #2563eb;
  font-weight: 600;
}

.sidebar .intro .intro-privacy {
  font-size: 11px;
  color: #64748b;
}

.sidebar .intro .intro-readme {
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}

.sidebar .intro .intro-readme a {
  color: #2563eb;
  text-decoration: none;
}

.sidebar .intro .intro-readme a:hover {
  text-decoration: underline;
}

.sidebar section h2 {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ファイル入力 */
.file-group {
  margin-bottom: 10px;
}

.file-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #475569;
}

/* 小さめのドロップゾーン（ルート/POI用） */
.drop-zone-mini {
  display: block;
  border: 2px dashed #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  transition: all 0.2s;
  cursor: pointer;
}

.drop-zone-mini.dragover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.drop-zone-mini p {
  margin: 0;
}

.drop-zone-mini .hint {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

.drop-zone-mini .loaded-file {
  display: none;
  color: #1e293b;
  font-weight: 500;
  font-size: 12px;
  word-break: break-all;
}

.drop-zone-mini.has-file {
  border-color: #10b981;
  background: #ecfdf5;
}

.drop-zone-mini.has-file .default-text,
.drop-zone-mini.has-file .hint {
  display: none;
}

.drop-zone-mini.has-file .loaded-file {
  display: block;
}

/* ルート情報 */
#route-info {
  font-size: 13px;
  color: #475569;
  margin-top: 6px;
}

/* オプション */
.option-group {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-group label {
  font-size: 13px;
  color: #475569;
  min-width: 80px;
}

.option-group select,
.option-group input[type="number"] {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
}

.option-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* 情報アイコン */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #94a3b8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  cursor: help;
  position: relative;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}

.info-icon::before {
  content: "i";
}

/* JSで制御するツールチップ */
.info-tooltip {
  position: fixed;
  background: #1e293b;
  color: #fff;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: normal;
  font-style: normal;
  font-family: inherit;
  line-height: 1.5;
  width: 220px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  text-align: left;
}

/* ボタン */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #64748b;
  color: #fff;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn + .btn {
  margin-top: 8px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn:disabled:hover {
  background: inherit;
}

.history-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.history-actions .btn {
  flex: 1;
  margin-top: 0;
  padding: 6px 10px;
  font-size: 12px;
}

/* POIテーブル */
.poi-list {
  /* サイドバー全体でスクロールさせるので、ここでは overflow を設定しない */
}

.section-hint {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 8px;
}

.section-hint strong {
  color: #2563eb;
  font-weight: 600;
}

.poi-list-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.poi-list-actions .btn {
  flex: 1;
  margin-top: 0;
  padding: 6px 10px;
  font-size: 12px;
}

.poi-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.poi-list th {
  background: #e2e8f0;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  position: sticky;
  top: 0;
}

.poi-list td {
  padding: 5px 8px;
  border-bottom: 1px solid #f1f5f9;
  word-break: break-all;
}

.poi-list tr.skipped td {
  color: #94a3b8;
  background: #fef2f2;
}

.poi-list tr.added td {
  background: #f0fdf4;
}

/* 地図上のマーカーホバー時のハイライト（.skipped/.addedより後に定義して優先） */
.poi-list tr.hover-highlight td {
  background: #fef3c7;
}

.poi-list .empty {
  text-align: center;
  color: #94a3b8;
  padding: 16px;
}

.btn-delete-poi {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}

.btn-delete-poi:hover {
  background: #fee2e2;
}

.poi-list td.editable {
  cursor: text;
  min-width: 40px;
  transition: background 0.15s;
}

.poi-list td.editable:hover {
  background: #f1f5f9;
}

.poi-list td.editable:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  background: #fff;
}

.poi-list td.editable:empty::before {
  content: '-';
  color: #cbd5e1;
}

.poi-list .poi-type-select {
  width: 100%;
  padding: 2px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}

.poi-list .poi-type-select:hover {
  border-color: #94a3b8;
}

.poi-list .poi-type-select:focus {
  outline: none;
  border-color: #2563eb;
}

/* POI追加ポップアップのselect */
.poi-add-popup select {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 6px;
  box-sizing: border-box;
  background: #fff;
  cursor: pointer;
}

.poi-add-popup select:focus {
  outline: none;
  border-color: #2563eb;
}

/* サイドバーのリサイズハンドル */
.sidebar-resizer {
  width: 5px;
  background: #e2e8f0;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  user-select: none;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: #2563eb;
}

/* 地図エリア（地図 + 標高プロファイル） */
.map-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* 地図 */
#map {
  flex: 1;
  min-height: 0;
}

/* レイヤー切り替えボタンをズームボタンと同じサイズに統一 */
.leaflet-control-layers-toggle {
  width: 30px !important;
  height: 30px !important;
  background-size: 20px 20px !important;
}

/* Google Maps 検索ボタン（地図上コントロール） */
.leaflet-google-maps-control a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 16px;
  line-height: 30px;
  text-decoration: none;
  cursor: pointer;
}

.leaflet-google-maps-control a:hover {
  background: #f4f4f4;
}


/* 標高プロファイル */
.elevation-profile {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.elevation-profile.hidden {
  display: none;
}

.elevation-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  font-size: 12px;
}

.elevation-title {
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.elevation-stats {
  flex: 1;
  color: #64748b;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-elevation-toggle {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 11px;
  color: #64748b;
  line-height: 1;
}

.btn-elevation-toggle:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.elevation-body {
  height: 140px;
  padding: 4px 8px 8px;
}

.elevation-profile.collapsed .elevation-body {
  display: none;
}

.elevation-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.elevation-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.elevation-overlay {
  pointer-events: none;
}

/* ルートのカーソル */
.leaflet-interactive {
  cursor: pointer;
}

/* POIマーカー (divIconのデフォルト余白を除去) */
.poi-marker-icon {
  background: none;
  border: none;
  transition: transform 0.15s;
}

.poi-marker-icon svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* POI追加ポップアップ */
.poi-add-popup h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.poi-add-popup input {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 6px;
  box-sizing: border-box;
}

.poi-add-popup input:focus {
  outline: none;
  border-color: #2563eb;
}

.poi-add-popup .popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.poi-add-popup .popup-actions .btn {
  width: auto;
  flex: 1;
  padding: 5px 10px;
  font-size: 12px;
  margin-top: 0;
  white-space: nowrap;
}
