:root {
  --sunny: #ff9800;
  --cloudy: #9e9e9e;
  --rainy: #2196f3;
  --header-height: 58px;
  --text: #263238;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

.app-header {
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 1px 5px rgb(0 0 0 / 8%);
}

.app-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 18px;
}

.radar-toggle {
  padding: 6px 11px;
  border: 1px solid #90caf9;
  border-radius: 16px;
  background: #fff;
  color: #1565c0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.radar-toggle:hover {
  background: #e3f2fd;
}

.radar-toggle.active,
.radar-toggle.active:hover {
  border-color: #1976d2;
  background: #1976d2;
  color: #fff;
}

.radar-toggle:disabled {
  cursor: wait;
  opacity: 0.65;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #52606d;
  font-size: 13px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border: 1px solid rgb(0 0 0 / 8%);
  border-radius: 50%;
}

.legend-dot--sunny {
  background: var(--sunny);
}

.legend-dot--cloudy {
  background: var(--cloudy);
}

.legend-dot--rainy {
  background: var(--rainy);
}

#day-selector {
  position: relative;
  z-index: 999;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 1px 4px rgb(0 0 0 / 6%);
  -webkit-overflow-scrolling: touch;
}

#day-selector:empty {
  display: none;
}

.day-button {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.day-button:hover {
  border-color: #b0bec5;
  background: #f5f7f9;
}

.day-button--active,
.day-button--active:hover {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

#map {
  width: 100%;
  height: calc(100% - var(--header-height) - var(--day-selector-height, 49px));
}

#day-selector:empty ~ #map {
  height: calc(100% - var(--header-height));
}

.weather-loading {
  position: absolute;
  z-index: 1000;
  top: calc(var(--header-height) + var(--day-selector-height, 49px) + 12px);
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 1px 5px rgb(0 0 0 / 15%);
  color: #52606d;
  font-size: 12px;
  font-weight: 600;
}

.weather-loading::before {
  width: 11px;
  height: 11px;
  border: 2px solid #cfd8dc;
  border-top-color: #607d8b;
  border-radius: 50%;
  content: "";
  animation: weather-spin 0.8s linear infinite;
}

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

.mountain-popup__weather {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.6;
}

.mountain-popup__links {
  display: flex;
  gap: 10px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  white-space: nowrap;
}

.mountain-popup__links a {
  color: #1565c0;
  text-decoration: none;
}

.mountain-popup__links a:hover {
  text-decoration: underline;
}

.leaflet-tooltip {
  border: 0;
  border-radius: 5px;
  box-shadow: 0 1px 5px rgb(0 0 0 / 18%);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.mountain-popup__name {
  margin-bottom: 5px;
  font-size: 15px;
  font-weight: 700;
}

.mountain-popup__details {
  line-height: 1.7;
}

.recommendations {
  position: absolute;
  z-index: 1000;
  bottom: 24px;
  left: 12px;
  width: 270px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 2px 10px rgb(0 0 0 / 18%);
}

.recommendations__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
}

.recommendations__toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  line-height: 18px;
  cursor: pointer;
}

.recommendations__list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
}

.recommendations__row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 18px 52px;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.recommendations__row:hover {
  background: #f1f5f7;
}

.recommendations__rank {
  color: #78909c;
  font-weight: 700;
}

.recommendations__name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommendations__condition {
  font-size: 14px;
  text-align: center;
}

.recommendations__drive {
  color: #607d8b;
  text-align: right;
  white-space: nowrap;
}

.recommendations--collapsed {
  width: auto;
}

.recommendations--collapsed .recommendations__header {
  gap: 12px;
  border-bottom: 0;
}

.recommendations--collapsed .recommendations__list {
  display: none;
}

.map-error {
  position: absolute;
  z-index: 1000;
  top: 72px;
  left: 50%;
  padding: 10px 14px;
  border: 1px solid #ef9a9a;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
  color: #b71c1c;
  font-size: 13px;
  transform: translateX(-50%);
}

@media (max-width: 560px) {
  :root {
    --header-height: 54px;
  }

  .app-header {
    padding: 0 12px;
  }

  .app-header h1 {
    font-size: 16px;
  }

  .header-tools {
    gap: 8px;
  }

  .radar-toggle {
    padding: 5px 8px;
    font-size: 11px;
  }

  .legend {
    gap: 8px;
    font-size: 11px;
  }

  .legend-item {
    gap: 3px;
  }

  #day-selector {
    gap: 6px;
    padding: 6px 12px;
  }

  .day-button {
    padding: 5px 10px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .app-header h1 {
    font-size: 15px;
  }

  .legend {
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 10px;
  }

  .legend-dot {
    width: 9px;
    height: 9px;
  }

  #day-selector {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .day-button {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .recommendations {
    max-width: calc(100vw - 16px);
    font-size: 11px;
  }

  .recommendations__header {
    font-size: 12px;
  }

  .recommendations__row {
    font-size: 11px;
  }

  .leaflet-popup-content-wrapper {
    max-width: 260px;
  }

  .leaflet-popup-content {
    max-width: 260px;
  }
}
