* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
}

header {
  position: relative;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  color: #fff;
  background: #1f4f3b;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
}

.github-link {
  display: flex;
  color: inherit;
}

.github-link svg {
  width: 1.75rem;
  height: 1.75rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.trips-menu {
  position: relative;
}

.trips-menu-toggle {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  background: transparent;
}

.trips-menu-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.trips-menu-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.trips-panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  width: min(24rem, calc(100vw - 1rem));
  max-height: calc(100vh - 5rem);
  padding: 1rem;
  overflow-y: auto;
  color: #17221d;
  background: rgb(255 255 255 / 98%);
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: 0 0.125rem 0.75rem rgb(0 0 0 / 25%);
}

#create-trip {
  width: 100%;
}

.forecast-warning-banner {
  flex-shrink: 0;
  margin: 0;
  padding: 0.5rem 1.25rem;
  color: #a34700;
  font-size: 0.875rem;
  font-weight: 700;
  background: #fff4e5;
  border-bottom: 1px solid #a34700;
}

.app-shell {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#map {
  flex: 1;
}

#map.map-editing,
#map.map-editing .leaflet-interactive {
  cursor: crosshair;
}

.trip-track {
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 1px 2px rgb(0 0 0 / 65%));
  stroke-linecap: round;
  stroke-linejoin: round;
}

.track-direction-icon {
  color: #fff;
  font-size: 0.875rem;
  line-height: 18px;
  text-align: center;
  filter: drop-shadow(0 0 1px #075985) drop-shadow(0 1px 1px rgb(0 0 0 / 80%));
  pointer-events: none;
}

.track-direction-icon span {
  display: block;
}

.forecast-map-icon {
  background: none;
  border: 0;
}

.forecast-map-badge {
  display: flex;
  flex-direction: column;
  width: 160px;
  height: 72px;
  overflow: hidden;
  color: #17221d;
  background: rgb(255 255 255 / 94%);
  border: 1px solid #52655c;
  border-radius: 0.4rem;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
}

.forecast-map-badge-label {
  overflow: hidden;
  padding: 0.2rem 0.35rem;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #1f4f3b;
}

.forecast-map-badge-label.is-fallback {
  background: #a34700;
}

.forecast-map-badge-content {
  display: flex;
  flex: 1;
  min-height: 0;
}

.forecast-map-badge img {
  width: 50px;
  height: 100%;
  object-fit: cover;
}

.forecast-map-badge-content > div {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 0.2rem 0.3rem;
  font-size: 0.7rem;
  line-height: 1.25;
  white-space: nowrap;
}

.forecast-map-badge strong {
  font-size: 0.72rem;
}

.trip-tools {
  position: absolute;
  z-index: 1000;
  top: 0.75rem;
  right: 0.75rem;
  width: min(22rem, calc(100% - 4.5rem));
  max-height: calc(100% - 1.5rem);
  padding: 1rem;
  overflow-y: auto;
  background: rgb(255 255 255 / 95%);
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.75rem rgb(0 0 0 / 25%);
}

.trip-tools-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.trip-tools-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.trip-tools-header input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.5rem;
  color: #183d2d;
  background: #e8f2ed;
}

.icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.trip-tools h2,
.trip-tools p {
  margin-top: 0;
}

.trip-tools.is-viewing .planner-only,
.trip-tools.is-planning .viewer-only {
  display: none !important;
}

.trip-tools h2 {
  margin-bottom: 0.25rem;
  font-size: 1.15rem;
}

.instructions {
  margin-bottom: 0.75rem;
  color: #3f4a45;
  font-size: 0.9rem;
}

.trip-date-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.trip-date-row input {
  padding: 0.4rem;
  font: inherit;
}

.trip-date-row time {
  color: #3f4a45;
}

.tool-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.track-buttons {
  grid-template-columns: repeat(3, 1fr);
}

.stop-buttons,
.file-buttons,
.final-buttons {
  margin-top: 0.5rem;
}

button {
  padding: 0.5rem 0.75rem;
  color: #fff;
  font: inherit;
  background: #1f6549;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #164b36;
}

button:focus-visible,
input:focus-visible {
  outline: 0.2rem solid #e8962e;
  outline-offset: 0.125rem;
}

button:disabled {
  color: #5d6762;
  background: #d7ddd9;
  cursor: not-allowed;
}

.snap-option {
  display: flex;
  gap: 0.5rem;
  align-items: start;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

#trip-status {
  display: block;
  padding: 0.5rem;
  color: #183d2d;
  font-size: 0.875rem;
  background: #e8f2ed;
  border-radius: 0.25rem;
}

#waypoint-list {
  max-height: 7rem;
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  overflow-y: auto;
  font-size: 0.875rem;
}

#waypoint-list .waypoint-select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  color: #183d2d;
  text-align: left;
  background: transparent;
}

#waypoint-list .is-selected .waypoint-select {
  background: #d5eadf;
  outline: 2px solid #1f6549;
}

#waypoint-list:empty {
  display: none;
}

.trip-profile {
  padding: 0.75rem;
  margin: 0.75rem 0;
  background: #f5f8f6;
  border: 1px solid #c8d2cc;
  border-radius: 0.35rem;
}

.trip-mileage {
  margin: 0.5rem 0 0.15rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.profile-totals,
.profile-status,
.profile-help {
  margin: 0 0 0.5rem;
  color: #3f4a45;
  font-size: 0.8rem;
}

.profile-help {
  margin-top: 0.25rem;
}

.elevation-chart:empty + .profile-help {
  display: none;
}

.elevation-chart svg {
  display: block;
  width: 100%;
  height: auto;
  color: #1769aa;
}

.elevation-chart .profile-area {
  fill: rgb(23 105 170 / 18%);
  stroke: currentColor;
  stroke-width: 3;
}

.trip-tools.is-planning .elevation-chart circle {
  fill: #e8962e;
  stroke: #783f00;
  stroke-width: 2;
  cursor: grab;
  touch-action: none;
}

.trip-tools.is-planning .elevation-chart circle.dragging {
  cursor: grabbing;
}

.trip-tools.is-planning .elevation-chart circle:focus-visible {
  stroke-width: 4;
}

.day-summary {
  overflow-x: auto;
}

.day-summary table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

.day-summary caption {
  margin-bottom: 0.25rem;
  font-weight: 700;
  text-align: left;
}

.day-summary th,
.day-summary td {
  padding: 0.25rem;
  text-align: right;
  border-bottom: 1px solid #d7ddd9;
}

.day-summary th:first-child,
.day-summary td:first-child {
  text-align: left;
}

.forecast-panel {
  padding-top: 0.75rem;
  margin: 0.75rem 0;
  border-top: 1px solid #c8d2cc;
}

.forecast-heading {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.forecast-heading h2 {
  margin: 0;
}

.forecast-help {
  margin: 0.5rem 0;
  color: #3f4a45;
  font-size: 0.8rem;
}

#forecast-status {
  display: block;
  color: #3f4a45;
  font-size: 0.875rem;
}

.forecast-card {
  padding: 0.75rem 0;
  border-bottom: 1px solid #d7ddd9;
}

.forecast-card:last-child {
  border-bottom: 0;
}

.forecast-card h3,
.forecast-card p {
  margin: 0 0 0.35rem;
}

.forecast-card h3 {
  font-size: 1rem;
}

.forecast-card.is-fallback h3 {
  color: #a34700;
}

.forecast-warning {
  color: #a34700;
  font-size: 0.875rem;
  font-weight: 700;
}

.forecast-card ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0 0;
}

.forecast-card li + li {
  margin-top: 0.5rem;
}

.forecast-detail {
  color: #3f4a45;
  font-size: 0.8rem;
}

.trip-tools small {
  color: #5d6762;
}

#trip-list,
#past-trip-list {
  padding: 0;
  margin: 0.75rem 0 0;
  list-style: none;
}

.past-trips {
  margin-top: 0.75rem;
}

.past-trips summary {
  color: #183d2d;
  font-weight: 700;
  cursor: pointer;
}

.saved-trip {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #d7ddd9;
}

.saved-trip-name,
.saved-trip-date {
  display: block;
}

.saved-trip-date {
  color: #3f4a45;
  font-size: 0.8rem;
}

.saved-trip-delete {
  background: #a32d2d;
}

.saved-trip-delete:hover:not(:disabled) {
  background: #7e2020;
}

@media (max-width: 35rem) {
  .trip-tools {
    top: auto;
    bottom: 0.5rem;
    right: 0.5rem;
    width: calc(100% - 1rem);
    max-height: 48%;
    padding: 0.75rem;
  }

  .instructions {
    display: none;
  }
}
