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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;
}

#page-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#report-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, #12182a 0%, #1a1a2e 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 14px;
}

#travel-title {
  font-size: 1rem;
  font-weight: 700;
  color: #e8eaed;
  letter-spacing: 0.02em;
}

.route-mode-banner {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(243, 156, 18, 0.12);
  border: 1px solid rgba(243, 156, 18, 0.35);
  color: #f5d76e;
  font-size: 0.72rem;
  line-height: 1.45;
}

.route-mode-banner[hidden] { display: none !important; }

#main-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#travel-panel {
  flex-shrink: 0;
  width: clamp(220px, 16vw, 300px);
  display: flex;
  flex-direction: column;
  background: #12182a;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 0;
}

.tab-bar {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f1420;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #9aa0a6;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab-btn:hover {
  color: #ddd;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #8ab4f8;
  border-bottom-color: #8ab4f8;
  background: rgba(138, 180, 248, 0.08);
}

.tab-panels {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: #3a4a5a transparent;
}

.tab-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 0.78rem;
}

.stat-label { color: #9aa0a6; }
.stat-value { font-weight: 600; text-align: right; }

#highlights-tab {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.highlight-card {
  background: rgba(30, 40, 60, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.highlight-card:hover {
  border-color: rgba(138, 180, 248, 0.5);
  background: rgba(40, 55, 80, 0.95);
}

.highlight-card .hl-icon { font-size: 1rem; margin-bottom: 2px; }
.highlight-card .hl-label {
  font-size: 0.62rem;
  color: #9aa0a6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.highlight-card .hl-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #e8eaed;
  margin-top: 2px;
}

.report-form { font-size: 0.78rem; }
.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.form-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #9aa0a6;
}
.form-row input,
.form-row select,
#food-region {
  background: #2a3a4a;
  border: 1px solid #3a4a5a;
  color: #eee;
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 0.78rem;
  width: 100%;
}

.report-block {
  margin-top: 8px;
  font-size: 0.78rem;
}

.report-block:empty { display: none; }

.equiv-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: #8ab4f8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 4px 0 6px;
}

.equiv-section-title:not(:first-child) { margin-top: 12px; }

.calorie-main {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f5b041;
  margin-bottom: 4px;
}

.equiv-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: #ddd;
}

.equiv-line .eq-name { color: #9aa0a6; }
.equiv-line .eq-val { font-weight: 600; color: #a8d4ff; }

.food-region-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #9aa0a6;
  margin-bottom: 6px;
  font-size: 0.72rem;
}

.report-disclaimer {
  flex-shrink: 0;
  font-size: 0.6rem;
  color: #666;
  padding: 6px 10px 8px;
  line-height: 1.3;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#layout {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  /* 地図 ~55% / タイムライン ~10% / 標高プロファイル ~35% */
  grid-template-rows: minmax(0, 55fr) clamp(64px, 10vh, 100px) minmax(200px, 35fr);
}

#map-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#map { width: 100%; height: 100%; }

.panel {
  position: absolute;
  z-index: 1000;
  background: rgba(15, 20, 35, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #8ab4f8;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#layer-panel {
  top: 10px;
  right: 10px;
  padding: 10px 12px;
}

#layer-panel select {
  background: #2a3a4a;
  border: 1px solid #3a4a5a;
  color: #eee;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  max-width: min(220px, calc(100vw - 80px));
}

#replay-panel {
  position: absolute;
  bottom: 14px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: center;
}

.replay-btn {
  background: #2a3a5a;
  border: 1px solid #4a5a7a;
  color: #eee;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.replay-btn:hover { background: #3a4a6a; }
.replay-btn.active { background: #4a6a9a; border-color: #6a8aba; }

#speed-select {
  background: #2a3a4a;
  border: 1px solid #3a4a5a;
  color: #eee;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.82rem;
  flex-shrink: 0;
}

#profile-readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex-shrink: 0;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.readout-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 68px;
}

.readout-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: #9aa0a6;
  letter-spacing: 0.04em;
}

.readout-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: #c5d4e8;
  font-variant-numeric: tabular-nums;
}

#readout-elevation { color: #7dcea0; }
#readout-distance { color: #a8d4ff; }
#readout-speed { color: #f0b27a; }
#readout-grade { color: #d7bde2; }

#photo-timeline-panel {
  background: #0f1420;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 10px 8px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#photo-timeline-panel .panel-title {
  margin-bottom: 4px;
  flex-shrink: 0;
}

#photo-timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-height: 0;
  align-items: center;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: #3a4a5a #1a1a2e;
}

#photo-timeline::-webkit-scrollbar { height: 6px; }
#photo-timeline::-webkit-scrollbar-thumb { background: #3a4a5a; border-radius: 3px; }

.timeline-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 54px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  background: #2a3a4a;
  transition: border-color 0.15s, transform 0.15s;
}

.timeline-thumb:hover {
  border-color: rgba(138, 180, 248, 0.6);
  transform: scale(1.05);
}

.timeline-thumb.active {
  border-color: #e74c3c;
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

.timeline-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.timeline-thumb .thumb-placeholder,
.photo-popup .thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.25rem;
  color: #8a9aaa;
  background: #2a3a4a;
}

.photo-popup .thumb-placeholder {
  width: 240px;
  height: 180px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.timeline-thumb .time-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 0.55rem;
  background: rgba(0, 0, 0, 0.65);
  color: #ddd;
  text-align: center;
  padding: 1px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#no-photos-hint {
  display: none;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  padding: 12px;
}

#chart-panel {
  background: #12182a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px 10px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#chart-panel .panel-title {
  margin-bottom: 4px;
  flex-shrink: 0;
}

#elevation-chart-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#elevation-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#no-elevation-hint {
  display: none;
  font-size: 0.8rem;
  color: #888;
  padding: 20px;
  text-align: center;
}

.photo-popup img {
  width: 240px;
  height: 180px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 6px;
}

.photo-popup .name { font-size: 0.8rem; font-weight: 600; text-align: center; }
.photo-popup .placement-debug {
  font-size: 0.68rem;
  color: #9aa0a6;
  text-align: left;
  margin: 0.35rem 0;
  line-height: 1.35;
  word-break: break-all;
}
.photo-popup .placement-hint {
  font-size: 0.68rem;
  color: #8ab4f8;
  text-align: center;
  margin: 2px 0 4px;
}
.photo-popup .coords { font-size: 0.72rem; color: #888; text-align: center; }

/* —— Map / profile sync markers —— */
.sync-marker-host {
  background: transparent !important;
  border: none !important;
}

.sync-marker {
  position: relative;
  width: 22px;
  height: 22px;
}

.sync-marker-core {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.sync-marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.55;
  animation: sync-marker-pulse 2s ease-out infinite;
  z-index: 1;
}

.sync-marker--current .sync-marker-core {
  background: #00e5ff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.75);
}

.sync-marker--current .sync-marker-pulse {
  background: rgba(0, 229, 255, 0.35);
}

.sync-marker--playing .sync-marker-core {
  background: #ffe066;
  box-shadow: 0 0 14px rgba(255, 224, 102, 0.9);
}

.sync-marker--playing .sync-marker-pulse {
  background: rgba(255, 224, 102, 0.4);
  animation: sync-marker-pulse 1.1s ease-out infinite;
}

.sync-marker--preview .sync-marker-core {
  background: #ffc107;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.8);
}

.sync-marker--preview .sync-marker-pulse {
  display: none;
}

.sync-marker-host.sync-marker-dimmed {
  opacity: 0.35;
}

@keyframes sync-marker-pulse {
  0% { transform: scale(0.55); opacity: 0.7; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* —— Elevation profile sync overlay —— */
#profile-sync-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  display: none;
}

.profile-sync-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.14), rgba(0, 229, 255, 0.03));
  border-right: 1px solid rgba(0, 229, 255, 0.12);
}

.profile-sync-vline {
  position: absolute;
  top: 0;
  width: 1px;
  transform: translateX(-50%);
  background: rgba(0, 229, 255, 0.55);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.35);
}

.profile-sync-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #00e5ff;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.85);
}

.profile-sync-overlay--preview .profile-sync-fill {
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.16), rgba(255, 193, 7, 0.03));
  border-right-color: rgba(255, 193, 7, 0.2);
}

.profile-sync-overlay--preview .profile-sync-vline {
  background: rgba(255, 193, 7, 0.65);
  box-shadow: 0 0 6px rgba(255, 193, 7, 0.4);
}

.profile-sync-overlay--preview .profile-sync-dot {
  background: #ffc107;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.85);
}

.profile-sync-overlay--playing .profile-sync-fill {
  background: linear-gradient(90deg, rgba(255, 224, 102, 0.16), rgba(255, 224, 102, 0.03));
  border-right-color: rgba(255, 224, 102, 0.22);
}

.profile-sync-overlay--playing .profile-sync-vline {
  background: rgba(255, 224, 102, 0.7);
}

.profile-sync-overlay--playing .profile-sync-dot {
  background: #ffe066;
  box-shadow: 0 0 12px rgba(255, 224, 102, 0.9);
}

#profile-readouts.profile-readouts--live .readout-value {
  color: #ffe9a8;
}

#profile-readouts.profile-readouts--preview .readout-value {
  color: #ffd966;
}

@media (max-width: 900px) {
  #main-split { flex-direction: column; }
  #travel-panel {
    width: 100%;
    max-height: clamp(160px, 24vh, 240px);
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .tab-btn { font-size: 0.68rem; padding: 8px 2px; }
}

@media (max-width: 768px) {
  #layout {
    grid-template-rows: minmax(0, 55fr) clamp(56px, 9vh, 88px) minmax(160px, 35fr);
  }
  .timeline-thumb { width: 56px; height: 42px; }
  #replay-panel { padding: 8px 10px; gap: 6px; }
  .replay-btn { width: 32px; height: 32px; }
}
